chunk-2d0d7a44.4652efc1.js 1.2 MB

1
  1. (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d0d7a44"],{"784a":function(e,t,i){"use strict";(function(e,i){class r{on(e,t,i){const r=this.e||(this.e={});return(r[e]||(r[e]=[])).push({fn:t,ctx:i}),this}once(e,t,i){const r=this;function s(){r.off(e,s);for(var a=arguments.length,n=new Array(a),o=0;o<a;o++)n[o]=arguments[o];t.apply(i,n)}return s._=t,this.on(e,s,i)}emit(e){const t=((this.e||(this.e={}))[e]||[]).slice();for(var i=arguments.length,r=new Array(1<i?i-1:0),s=1;s<i;s++)r[s-1]=arguments[s];for(let a=0;a<t.length;a+=1)t[a].fn.apply(t[a].ctx,r);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 r=i[e],s=[];if(r&&t)for(let a=0,n=r.length;a<n;a+=1)r[a].fn!==t&&r[a].fn._!==t&&s.push(r[a]);return s.length?i[e]=s:delete i[e],this}}const s="fetch",a="websocket",n="worker",o="player",l="playerAudio",d="playbackTF",h="mp4",c="webm",u="flv",p="webTransport",f="nakedFlow",m="fmp4",g="mpeg4",y={flv:"FLV",m7s:"m7s",hls:"HLS",fmp4:"FMP4",mpeg4:"MPEG4",webrtc:"Webrtc",webTransport:"WebTransport",nakedFlow:"裸流"},A="canvas",b="video",v="debug",_="warn",w="click",S="mouseDownAndUp",E=1e4,T={url:"",playbackConfig:{},fullscreenWatermarkConfig:{},playType:o,playbackForwardMaxRateDecodeIFrame:4,playOptions:{},isLive:!0,isMulti:!1,isCrypto:!1},k={playType:o,container:"",videoBuffer:1e3,videoBufferDelay:1e3,networkDelay:1e4,isResize:!0,isFullResize:!1,isFlv:!1,isHls:!1,isFmp4:!1,isWebrtc:!1,isWebrtcForZLM:!1,isNakedFlow:!1,isMpeg4:!1,debug:!1,debugLevel:_,debugUuid:"",isMulti:!1,hotKey:!1,loadingTimeout:10,heartTimeout:10,timeout:10,pageVisibilityHiddenTimeout:300,loadingTimeoutReplay:!0,heartTimeoutReplay:!0,loadingTimeoutReplayTimes:3,heartTimeoutReplayTimes:3,heartTimeoutReplayUseLastFrameShow:!1,replayUseLastFrameShow:!1,supportDblclickFullscreen:!1,showBandwidth:!1,showPerformance:!1,mseCorrectTimeDuration:20,keepScreenOn:!0,isNotMute:!1,hasAudio:!0,hasVideo:!0,operateBtns:{fullscreen:!1,screenshot:!1,play:!1,audio:!1,record:!1,ptz:!1,quality:!1,zoom:!1,close:!1,scale:!1,performance:!1,aiFace:!1,aiObject:!1,fullscreenFn:null,fullscreenExitFn:null,screenshotFn:null,playFn:null,pauseFn:null,recordFn:null,recordStopFn:null},extendOperateBtns:[],contextmenuBtns:[],watermarkConfig:{},controlAutoHide:!1,hasControl:!1,loadingIcon:!0,loadingText:"",background:"",backgroundLoadingShow:!1,loadingBackground:"",decoder:"./hzPlayer/decoder-pro.js",decoderAudio:"./hzPlayer/decoder-pro-audio.js",decoderWASM:"",isDecoderUseCDN:!1,url:"",rotate:0,mirrorRotate:"none",playbackConfig:{playList:[],fps:"",showControl:!0,showRateBtn:!1,rateConfig:[],isCacheBeforeDecodeForFpsRender:!1,uiUsePlaybackPause:!1,isPlaybackPauseClearCache:!0,isUseFpsRender:!1,isUseLocalCalculateTime:!1,localOneFrameTimestamp:40,supportWheel:!1,useWCS:!1},qualityConfig:[],defaultStreamQuality:"",scaleConfig:["拉伸","缩放","正常"],forceNoOffscreen:!0,hiddenAutoPause:!1,protocol:2,demuxType:u,useWasm:!1,useWCS:!1,useSIMD:!0,wcsUseVideoRender:!0,wasmUseVideoRender:!0,mseUseCanvasRender:!1,hlsUseCanvasRender:!1,useMSE:!1,useOffscreen:!1,useWebGPU:!1,mseDecodeErrorReplay:!0,wcsDecodeErrorReplay:!0,wasmDecodeErrorReplay:!0,autoWasm:!0,webglAlignmentErrorReplay:!0,webglContextLostErrorReplay:!0,openWebglAlignment:!1,syncAudioAndVideo:!1,playbackDelayTime:1e3,playbackFps:25,playbackForwardMaxRateDecodeIFrame:4,playbackCurrentTimeMove:!0,useVideoRender:!0,useCanvasRender:!1,networkDelayTimeoutReplay:!1,recordType:h,checkFirstIFrame:!0,nakedFlowFps:25,audioEngine:null,isShowRecordingUI:!0,isShowZoomingUI:!0,useFaceDetector:!1,useObjectDetector:!1,ptzClickType:w,ptzStopEmitDelay:.3,ptzZoomShow:!1,ptzApertureShow:!1,ptzFocusShow:!1,ptzMoreArrowShow:!1,weiXinInAndroidAudioBufferSize:4800,isCrypto:!1,isSm4Crypto:!1,sm4CryptoKey:"",cryptoKey:"",cryptoIV:"",cryptoKeyUrl:"",autoResize:!1,useWebFullScreen:!1,ptsMaxDiff:3600,aiFaceDetectWidth:192,aiObjectDetectWidth:192,videoRenderSupportScale:!0,mediaSourceTsIsMaxDiffReplay:!0,controlHtml:"",isH265:!1,isWebrtcH265:!1,supportLockScreenPlayAudio:!0,supportHls265:!0,isFmp4Private:!1,isEmitSEI:!1,pauseAndNextPlayUseLastFrameShow:!1,demuxUseWorker:!1},x="init",C="initVideo",L="initAudio",D="audioCode",R="videoCode",I="videoCodec",P="workerEnd",B="closeEnd",U={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",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",destroy:"destroy",beforeDestroy:"beforeDestroy",streamEnd:"streamEnd",streamRate:"streamRate",streamAbps:"streamAbps",streamVbps:"streamVbps",streamDts:"streamDts",streamSuccess:"streamSuccess",streamMessage:"streamMessage",streamError:"streamError",streamStats:"streamStats",mseSourceOpen:"mseSourceOpen",mseSourceClose:"mseSourceClose",mseSourceended:"mseSourceended",mseSourceBufferError:"mseSourceBufferError",mseAddSourceBufferError:"mseAddSourceBufferError",mseSourceBufferBusy:"mseSourceBufferBusy",mseSourceBufferFull:"mseSourceBufferFull",videoWaiting:"videoWaiting",videoTimeUpdate:"videoTimeUpdate",videoSyncAudio:"videoSyncAudio",playToRenderTimes:"playToRenderTimes",playbackTime:"playbackTime",playbackTimestamp:"playbackTimestamp",playbackPrecision:"playbackPrecision",playbackJustTime:"playbackJustTime",playbackStats:"playbackStats",playbackSeek:"playbackSeek",playbackPause:"playbackPause",playbackPauseOrResume:"playbackPauseOrResume",playbackRateChange:"playbackRateChange",playbackPreRateChange:"playbackPreRateChange",ptz:"ptz",streamQualityChange:"streamQualityChange",visibilityChange:"visibilityChange",netBuf:"netBuf",close:"close",networkDelayTimeout:"networkDelayTimeout",togglePerformancePanel:"togglePerformancePanel",viewResizeChange:"viewResizeChange",flvDemuxBufferSizeTooLarge:"flvDemuxBufferSizeTooLarge",talkGetUserMediaSuccess:"talkGetUserMediaSuccess",talkGetUserMediaFail:"talkGetUserMediaFail",talkGetUserMediaTimeout:"talkGetUserMediaTimeout",talkStreamStart:"talkStreamStart",talkStreamOpen:"talkStreamOpen",talkStreamClose:"talkStreamClose",talkStreamError:"talkStreamError",talkStreamInactive:"talkStreamInactive",webrtcDisconnect:"webrtcDisconnect",webrtcFailed:"webrtcFailed",webrtcClosed:"webrtcClosed",webrtcOnConnectionStateChange:"webrtcOnConnectionStateChange",webrtcOnIceConnectionStateChange:"webrtcOnIceConnectionStateChange",crashLog:"crashLog",focus:"focus",blur:"blur",visibilityHiddenTimeout:"visibilityHiddenTimeout",websocketOpen:"websocketOpen",websocketClose:"websocketClose",websocketError:"websocketError",websocketMessage:"websocketMessage",aiObjectDetectorInfo:"aiObjectDetectorInfo",aiFaceDetector:"aiFaceDetector",playFailedAndPaused:"playFailedAndPaused",audioResumeState:"audioResumeState",webrtcStreamH265:"webrtcStreamH265",talkFailedAndStop:"talkFailedAndStop"},F={load:U.load,timeUpdate:U.timeUpdate,videoInfo:U.videoInfo,audioInfo:U.audioInfo,error:U.error,kBps:U.kBps,start:U.start,timeout:U.timeout,loadingTimeout:U.loadingTimeout,loadingTimeoutRetryEnd:U.loadingTimeoutRetryEnd,delayTimeout:U.delayTimeout,delayTimeoutRetryEnd:U.delayTimeoutRetryEnd,fullscreen:"fullscreen",webFullscreen:U.webFullscreen,play:U.play,pause:U.pause,mute:U.mute,stats:U.stats,performance:U.performance,recordingTimestamp:U.recordingTimestamp,recordStart:U.recordStart,recordEnd:U.recordEnd,recordBlob:U.recordBlob,playToRenderTimes:U.playToRenderTimes,playbackSeek:U.playbackSeek,playbackStats:U.playbackStats,playbackTimestamp:U.playbackTimestamp,playbackPauseOrResume:U.playbackPauseOrResume,playbackPreRateChange:U.playbackPreRateChange,playbackRateChange:U.playbackRateChange,ptz:U.ptz,streamQualityChange:U.streamQualityChange,zooming:U.zooming,crashLog:U.crashLog,focus:U.focus,blur:U.blur,visibilityHiddenTimeout:U.visibilityHiddenTimeout,visibilityChange:U.visibilityChange,websocketOpen:U.websocketOpen,websocketClose:U.websocketClose,networkDelayTimeout:U.networkDelayTimeout,aiObjectDetectorInfo:U.aiObjectDetectorInfo,playFailedAndPaused:U.playFailedAndPaused,streamEnd:U.streamEnd,audioResumeState:U.audioResumeState,videoSEI:U.videoSEI,webrtcOnConnectionStateChange:U.webrtcOnConnectionStateChange,webrtcOnIceConnectionStateChange:U.webrtcOnIceConnectionStateChange},M={talkStreamClose:U.talkStreamClose,talkStreamError:U.talkStreamError,talkStreamInactive:U.talkStreamInactive,talkGetUserMediaTimeout:U.talkGetUserMediaTimeout,talkFailedAndStop:U.talkFailedAndStop},O={playError:"playIsNotPauseOrUrlIsNull",fetchError:"fetchError",websocketError:"websocketError",webcodecsH265NotSupport:"webcodecsH265NotSupport",webcodecsDecodeError:"webcodecsDecodeError",webcodecsUnsupportedConfigurationError:"webcodecsUnsupportedConfigurationError",mediaSourceH265NotSupport:"mediaSourceH265NotSupport",mediaSourceDecoderConfigurationError:"mediaSourceDecoderConfigurationError",mediaSourceFull:U.mseSourceBufferFull,mseSourceBufferError:U.mseSourceBufferError,mseAddSourceBufferError:U.mseAddSourceBufferError,mediaSourceAppendBufferError:"mediaSourceAppendBufferError",mediaSourceBufferListLarge:"mediaSourceBufferListLarge",mediaSourceAppendBufferEndTimeout:"mediaSourceAppendBufferEndTimeout",mediaSourceTsIsMaxDiff:"mediaSourceTsIsMaxDiff",mediaSourceUseCanvasRenderPlayFailed:"mediaSourceUseCanvasRenderPlayFailed",wasmDecodeError:"wasmDecodeError",wasmUseVideoRenderError:"wasmUseVideoRenderError",hlsError:"hlsError",webrtcError:"webrtcError",webrtcClosed:"webrtcClosed",webrtcIceCandidateError:"webrtcIceCandidateError",webglAlignmentError:"webglAlignmentError",wasmWidthOrHeightChange:"wasmWidthOrHeightChange",mseWidthOrHeightChange:"mseWidthOrHeightChange",wcsWidthOrHeightChange:"wcsWidthOrHeightChange",tallWebsocketClosedByError:"tallWebsocketClosedByError",flvDemuxBufferSizeTooLarge:U.flvDemuxBufferSizeTooLarge,wasmDecodeVideoNoResponseError:"wasmDecodeVideoNoResponseError",audioChannelError:"audioChannelError",simdH264DecodeVideoWidthIsTooLarge:"simdH264DecodeVideoWidthIsTooLarge",simdDecodeError:"simdDecodeError",webglContextLostError:"webglContextLostError",videoElementPlayingFailed:"videoElementPlayingFailed",videoElementPlayingFailedForWebrtc:"videoElementPlayingFailedForWebrtc"},N="notConnect",j="open",z={download:"download",base64:"base64",blob:"blob"},G="download",H={7:"H264(AVC)",12:"H265(HEVC)",99:"MPEG4"},W="H264(AVC)",V="H265(HEVC)",K={AAC:"AAC",ALAW:"ALAW(g711a)",MULAW:"MULAW(g711u)",MP3:"MP3"},$={10:"AAC",7:"ALAW",8:"MULAW",2:"MP3"},Y=6,q="webcodecs",J="webgl",Q="webgpu",X="offscreen",Z="mse",ee='video/mp4; codecs="avc1.64002A"',te='video/mp4; codecs="hev1.1.6.L123.b0"',ie="oneHour",re="halfHour",se="fiveMin",ae={oneHour:"one-hour",halfHour:"half-hour",tenMin:"ten-min",fiveMin:"five-min"},ne=["oneHour","halfHour","tenMin","fiveMin"],oe=["up","right","down","left","left-up","right-up","left-down","right-down"],le="stop",de="fiStop",he="zoomExpand",ce="zoomNarrow",ue="apertureFar",pe="apertureNear",fe="focusFar",me="focusNear",ge="g711a",ye="g711u",Ae={png:"image/png",jpeg:"image/jpeg",webp:"image/webp"},be="canplay",ve="waiting",_e="timeupdate",we="ratechange",Se="worklet",Ee={encType:ge,packetType:"rtp",rtpSsrc:"0000000000",numberChannels:1,sampleRate:8e3,sampleBitsWidth:16,sendInterval:20,debug:!1,debugLevel:_,testMicrophone:!1,saveRtpToFile:!1,audioBufferLength:160,engine:Se,checkGetUserMediaTimeout:!1,getUserMediaTimeout:1e4},Te="worklet",ke="script",xe="active",Ce={name:"",index:0,icon:"",iconHover:"",iconTitle:"",activeIcon:"",activeIconHover:"",activeIconTitle:"",click:null,activeClick:null},Le={content:"",click:null,index:0},De={container:"",maxSplit:4,split:1,supportDblclickContainerFullscreen:!0,style:{border:"#343434",borderSelect:"#FFCC00",background:"#000"}},Re={dblSelected:"multiDblSelected",selected:"multiSelected",mouseOver:"multiMouseover",mouseOut:"multiMouseout",mouseUp:"multiMouseup"},Ie="3-1",Pe="4-1",Be="load-retry",Ue="load-start";class Fe{constructor(e){this.log=function(t){if(e._opt.debug&&e._opt.debugLevel==v){for(var i=e._opt.debugUuid?`[${e._opt.debugUuid}]`:"",r=arguments.length,s=new Array(1<r?r-1:0),a=1;a<r;a++)s[a-1]=arguments[a];console.log(`JbPro${i}:[✅✅✅][${t}]`,...s)}},this.warn=function(t){if(e._opt.debug&&(e._opt.debugLevel==v||e._opt.debugLevel==_)){for(var i=e._opt.debugUuid?`[${e._opt.debugUuid}]`:"",r=arguments.length,s=new Array(1<r?r-1:0),a=1;a<r;a++)s[a-1]=arguments[a];console.log(`JbPro${i}:[❗❗❗][${t}]`,...s)}},this.error=function(t){for(var i=e._opt.debugUuid?`[${e._opt.debugUuid}]`:"",r=arguments.length,s=new Array(1<r?r-1:0),a=1;a<r;a++)s[a-1]=arguments[a];console.error(`JbPro${i}:[❌❌❌][${t}]`,...s)}}}var Me="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof e?e:"undefined"!=typeof self?self:{};function Oe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Ne(e,t){return e(t={exports:{}},t.exports),t.exports}var je=Ne((function(e){var t,i,r,s,a;t="undefined"!=typeof window&&void 0!==window.document?window.document:{},i=e.exports,r=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"]],r=0,s=i.length,a={};r<s;r++)if((e=i[r])&&e[1]in t){for(r=0;r<e.length;r++)a[i[0][r]]=e[r];return a}return!1}(),s={change:r.fullscreenchange,error:r.fullscreenerror},a={request:function(e,i){return new Promise(function(s,a){var n=function(){this.off("change",n),s()}.bind(this),o=(this.on("change",n),(e=e||t.documentElement)[r.requestFullscreen](i));o instanceof Promise&&o.then(n).catch(a)}.bind(this))},exit:function(){return new Promise(function(e,i){var s,a;this.isFullscreen?(s=function(){this.off("change",s),e()}.bind(this),this.on("change",s),(a=t[r.exitFullscreen]())instanceof Promise&&a.then(s).catch(i)):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){e=s[e],e&&t.addEventListener(e,i,!1)},off:function(e,i){e=s[e],e&&t.removeEventListener(e,i,!1)},raw:r},r?(Object.defineProperties(a,{isFullscreen:{get:function(){return Boolean(t[r.fullscreenElement])}},element:{enumerable:!0,get:function(){return t[r.fullscreenElement]}},isEnabled:{enumerable:!0,get:function(){return Boolean(t[r.fullscreenEnabled])}}}),i?e.exports=a:window.screenfull=a):i?e.exports={isEnabled:!1}:window.screenfull={isEnabled:!1}}));function ze(e){var{profile:e,sampleRate:t,channel:i}=e;return new Uint8Array([175,0,e<<3|(14&t)>>1,(1&t)<<7|i<<3])}je.isEnabled;const Ge=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],He=Ge;function We(e,t){return 1024*(1<arguments.length&&void 0!==t?t:9e4)/e}function Ve(){}function Ke(e){let t=null;var i=["webgl","experimental-webgl","moz-webgl","webkit-3d"];let r=0;for(;!t&&r<i.length;){var s=i[r];try{var a={preserveDrawingBuffer:!0};t=e.getContext(s,a)}catch(e){console.error(e),t=null}t&&"function"==typeof t.getParameter||(t=null),++r}return t}function $e(e){return e.getContext("webgl2")}function Ye(e){let t=0<arguments.length&&void 0!==e?e:"";const i=t.split(","),r=atob(i[1]),s=i[0].replace("data:","").replace(";base64","");let a=r.length,n=new Uint8Array(a);for(;a--;)n[a]=r.charCodeAt(a);return new File([n],"file",{type:s})}function qe(){return(new Date).getTime()}function Je(e,t,i){return Math.max(Math.min(e,Math.max(t,i)),Math.min(t,i))}function Qe(e,t,i){e&&("object"==typeof t&&Object.keys(t).forEach(i=>{Qe(e,i,t[i])}),e.style[t]=i)}function Xe(e,t,i){return i=!(2<arguments.length&&void 0!==i)||i,e?(e=getComputedStyle(e,null).getPropertyValue(t),i?parseFloat(e):e):0}function Ze(){return(performance&&"function"==typeof performance.now?performance:Date).now()}function et(e){let t=0,i=Ze();return r=>{var s;ft(r)&&(t+=r,1e3<=(s=(r=Ze())-i)&&(e(t/s*1e3),i=r,t=0))}}try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){var tt=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));tt instanceof WebAssembly.Module&&(new WebAssembly.Instance(tt),WebAssembly.Instance)}}catch(r){}function it(){return/iphone|ipod|android.*mobile|windows.*phone|blackberry.*mobile/i.test(window.navigator.userAgent.toLowerCase())}function rt(){return!it()&&!/ipad|android(?!.*mobile)|tablet|kindle|silk/i.test(window.navigator.userAgent.toLowerCase())}function st(){var e=window.navigator.userAgent.toLowerCase();return/android/i.test(e)}function at(){const e=window.navigator.userAgent.toLowerCase()||"",t={type:"",version:""},i={IE:window.ActiveXObject||"ActiveXObject"in window,Chrome:-1<e.indexOf("chrome")&&-1<e.indexOf("safari"),Firefox:-1<e.indexOf("firefox"),Opera:-1<e.indexOf("opera"),Safari:-1<e.indexOf("safari")&&-1==e.indexOf("chrome"),Edge:-1<e.indexOf("edge"),QQBrowser:/qqbrowser/.test(e),WeixinBrowser:/MicroMessenger/i.test(e)};for(var r in i)if(i[r]){let i="";if("IE"===r){const t=e.match(/(msie\s|trident.*rv:)([\w.]+)/);t&&2<t.length&&(i=e.match(/(msie\s|trident.*rv:)([\w.]+)/)[2])}else if("Chrome"===r){for(var s in navigator.mimeTypes)"application/360softmgrplugin"===navigator.mimeTypes[s].type&&(r="360");const t=e.match(/chrome\/([\d.]+)/);t&&1<t.length&&(i=t[1])}else if("Firefox"===r){const t=e.match(/firefox\/([\d.]+)/);t&&1<t.length&&(i=t[1])}else if("Opera"===r){const t=e.match(/opera\/([\d.]+)/);t&&1<t.length&&(i=t[1])}else if("Safari"===r){const t=e.match(/version\/([\d.]+)/);t&&1<t.length&&(i=t[1])}else if("Edge"===r){const t=e.match(/edge\/([\d.]+)/);t&&1<t.length&&(i=t[1])}else if("QQBrowser"===r){const t=e.match(/qqbrowser\/([\d.]+)/);t&&1<t.length&&(i=t[1])}t.type=r,t.version=parseInt(i)}return t}function nt(){var e=window.navigator.userAgent.toLowerCase();return e&&/iphone|ipad|ipod|ios/.test(e)}function ot(){const e=window.navigator.userAgent;return!e.match(/Chrome/gi)&&e.match(/Safari/gi)}function lt(e,t){if(0===arguments.length)return null;t=t||"{y}-{m}-{d} {h}:{i}:{s}",e="object"==typeof e?e:(e=+(e=10===(""+e).length?1e3*parseInt(e):e),new Date(e));var i={y:e.getFullYear(),m:e.getMonth()+1,d:e.getDate(),h:e.getHours(),i:e.getMinutes(),s:e.getSeconds(),a:e.getDay()};return t.replace(/{(y|m|d|h|i|s|a)+}/g,(e,t)=>{var r=i[t];return"a"===t?["一","二","三","四","五","六","日"][r-1]:(r=0<e.length&&r<10?"0"+r:r)||0})}function dt(){return"VideoFrame"in window}function ht(e){if("string"!=typeof e)return e;var t=Number(e);return isNaN(t)?e:t}function ct(){return"xxxxxxxxxxxx4xxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))}function ut(e,t){let i,r,s=!1;return function a(){for(var n=arguments.length,o=new Array(n),l=0;l<n;l++)o[l]=arguments[l];if(s)return i=o,void(r=this);s=!0,e.apply(this,o),setTimeout(()=>{s=!1,i&&(a.apply(r,i),i=null,r=null)},t)}}function pt(e){if(null==e||""==e)return"0 Bytes";var t=new Array("Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"),i=(e=parseFloat(e),Math.floor(Math.log(e)/Math.log(1024)));return(e/Math.pow(1024,i)).toFixed(2)+t[i]}function ft(e){return"[object Number]"===Object.prototype.toString.call(e)}function mt(){let e=!1;return!(!("MediaSource"in window)||!window.MediaSource.isTypeSupported(te))||e}function gt(){const e=at();return"chrome"===e.type.toLowerCase()&&107<=e.version}function yt(){let e=!1;return"MediaStreamTrackGenerator"in window||e}function At(){let e=!1;return"MediaStream"in window||e}function bt(e){return null==e}function vt(e){return!0===e||!1===e}function _t(e){return!bt(e)}function wt(e){var t={left:"",right:"",top:"",bottom:"",opacity:1,backgroundColor:"",image:{src:"",width:"100",height:"60"},text:{content:"",fontSize:"14",color:"#000"},rect:{color:"",lineWidth:2,width:"",height:""},html:""},i=Object.assign(t.image,e.image||{}),r=Object.assign(t.text,e.text||{});return Object.assign(t,e,{image:i,text:r})}function St(e,t){return e={container:e||"",text:"",opacity:"",angle:"",color:"",fontSize:"",fontFamily:""},{watermark_parent_node:(e=Object.assign(e,t)).container,watermark_alpha:e.opacity,watermark_angle:e.angle,watermark_fontsize:e.fontSize,watermark_color:e.color,watermark_font:e.fontFamily,watermark_txt:e.text}}function Et(e,t){return new Promise((i,r)=>{let s=wt(t);if(!s.image.src&&!s.text.content)return i(e);let a=document.createElement("canvas"),n=(a.width=t.width,a.height=t.height,a.getContext("2d")),o=0,l=0;ft(s.left)?o=s.left:ft(s.right)&&(o=a.width-s.right),ft(s.top)?l=s.top:ft(s.bottom)&&(l=a.height-s.bottom);const d=new Image;d.src=e,d.onload=()=>{if(n.drawImage(d,0,0),s.image&&s.image.src){const e=new Image;e.src=s.image.src,e.setAttribute("crossOrigin","Anonymous"),e.onload=()=>{o-=s.image.width,n.drawImage(e,o,l,s.image.width,s.image.height),i(a.toDataURL(t.format,t.quality))},e.onerror=e=>{r()}}else s.text&&s.text.content&&(n.font=s.text.fontSize+"px 宋体",n.fillStyle=s.text.color,n.textAlign="right",n.fillText(s.text.content,o,l),i(a.toDataURL(t.format,t.quality)))},d.onerror=e=>{r(e)}})}function Tt(e){var t,i;return-1<e&&(t=e%60,i=(i=Math.floor(e/3600))<10?"0"+i+":":i+":",(e=Math.floor(e/60)%60)<10&&(i+="0"),i+=e+":",(t=Math.round(t))<10&&(i+="0"),i+=t.toFixed(0)),i}function kt(e){let t="";var i,r;return-1<e&&(i=Math.floor(e/60/60)%60,r=Math.floor(e/60)%60,e%=60,r=Math.round(r),t=i<10?"0"+i+":":i+":",r<10&&(t+="0"),t+=r+":",e<10&&(t+="0"),t+=e),t}function xt(e,t){var i=Math.floor(t/60/60)%60,r=Math.floor(t/60)%60;t%=60;return new Date(e).setHours(i,r,t,0)}function Ct(e){return(""+e).length}function Lt(e){return!e||0!==Object.keys(e).length}function Dt(e){return"string"==typeof e}const Rt=()=>{var e=window.navigator.userAgent;return/MicroMessenger/i.test(e)};function It(e){return e=e||window.event,e.target||e.srcElement}function Pt(e){return"function"==typeof e}function Bt(e){let t=0,i=0;var r=e||window.event;return r.pageX||r.pageY?(t=r.pageX,i=r.pageY):(r.clientX||r.clientY)&&(t=e.clientX+document.documentElement.scrollLeft+document.body.scrollLeft,i=e.clientY+document.documentElement.scrollTop+document.body.scrollTop),{posX:t,posY:i}}function Ut(){let e=document.createElement("video"),t=e.canPlayType("application/vnd.apple.mpegurl");return e=null,t}function Ft(e){return $t(e.hasAudio)&&(e.useMSE||e.useWCS&&!e.useOffscreen)}function Mt(e){return e=e.toString().trim().match(/^function\s*\w*\s*\([\w\s,]*\)\s*{([\w\W]*?)}$/)[1],e=new Blob([e],{type:"application/javascript"}),URL.createObjectURL(e)}function Ot(e){e.close()}function Nt(){return"https:"===window.location.protocol||"localhost"===window.location.hostname}function jt(e,t){let i=(e=t?e.filter(e=>e.type===t):e)[0],r=null,s=1;var a;if(0<e.length&&(a=e[1])&&1e5<a.ts-i.ts&&(i=a,s=2),i)for(let n=s;n<e.length;n++){let s=e[n];!(s=t&&s.type!==t?null:s)||1e3<=s.ts-i.ts&&e[n-1].ts-i.ts<1e3&&(r=n+1)}return r}function zt(e){e=(e+"=".repeat((4-e.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/");for(var t=window.atob(e),i=new Uint8Array(t.length),r=0;r<t.length;++r)i[r]=t.charCodeAt(r);return i}function Gt(e){let t="";if("object"==typeof e)try{t=JSON.stringify(e),t=JSON.parse(t)}catch(r){t=e}else t=e;return t}function Ht(){return Gt(T)}function Wt(){return Gt(k)}function Vt(e){return e[0]>>4==1&&0===e[1]}function Kt(e){return!0===e||"true"===e}function $t(e){return!0!==e&&"true"!==e}function Yt(e){return e.replace(/-([a-z])/g,(function(e,t){return t.toUpperCase()}))}class qt{constructor(e){this.destroys=[],this.proxy=this.proxy.bind(this),this.master=e}proxy(e,t,i){let r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(e){if(Array.isArray(t))return t.map(t=>this.proxy(e,t,i,r));e.addEventListener(t,i,r);var s=()=>{Pt(e.removeEventListener)&&e.removeEventListener(t,i,r)};return this.destroys.push(s),s}}destroy(){this.master.debug&&this.master.debug.log("Events","destroy"),this.destroys.forEach(e=>e()),this.destroys=[]}}var Jt="undefined"!=typeof Float32Array?Float32Array:Array;function Qt(){var e=new Jt(16);return Jt!=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 Xt(e){e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1}function Zt(e,t,i){var r=new Jt(3);return r[0]=e,r[1]=t,r[2]=i,r}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)}),tt=new Jt(3),Jt!=Float32Array&&(tt[0]=0,tt[1]=0,tt[2]=0),Vr=new Jt(4),Jt!=Float32Array&&(Vr[0]=0,Vr[1]=0,Vr[2]=0,Vr[3]=0);class ei{constructor(e,t){this.gl=e,t&&this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1),t=this._initShaderProgram(),this._programInfo={program:t,attribLocations:{vertexPosition:e.getAttribLocation(t,"aVertexPosition"),texturePosition:e.getAttribLocation(t,"aTexturePosition")},uniformLocations:{projectionMatrix:e.getUniformLocation(t,"uProjectionMatrix"),modelMatrix:e.getUniformLocation(t,"uModelMatrix"),viewMatrix:e.getUniformLocation(t,"uViewMatrix"),rgbatexture:e.getUniformLocation(t,"rgbaTexture"),ytexture:e.getUniformLocation(t,"yTexture"),utexture:e.getUniformLocation(t,"uTexture"),vtexture:e.getUniformLocation(t,"vTexture"),isyuv:e.getUniformLocation(t,"isyuv")}},this._buffers=this._initBuffers(),this._rgbatexture=this._createTexture(),this._ytexture=this._createTexture(),this._utexture=this._createTexture(),this._vtexture=this._createTexture()}destroy(){this.gl.deleteProgram(this._programInfo.program),this.gl.deleteBuffer(this._buffers.position),this.gl.deleteBuffer(this._buffers.texPosition),this.gl.deleteBuffer(this._buffers.indices),this.gl.deleteTexture(this._rgbatexture),this.gl.deleteTexture(this._ytexture),this.gl.deleteTexture(this._utexture),this.gl.deleteTexture(this._vtexture),this._programInfo=null,this._buffers=null,this._rgbatexture=null,this._ytexture=null,this._utexture=null,this._vtexture=null}_initShaderProgram(){var e=this._loadShader(this.gl.VERTEX_SHADER,"\n attribute vec4 aVertexPosition;\n attribute vec2 aTexturePosition;\n varying lowp vec2 vTexturePosition;\n void main(void) {\n gl_Position = aVertexPosition;\n vTexturePosition = aTexturePosition;\n }\n "),t=this._loadShader(this.gl.FRAGMENT_SHADER,"\n precision highp float;\n varying highp vec2 vTexturePosition;\n uniform int isyuv;\n uniform sampler2D rgbaTexture;\n uniform sampler2D yTexture;\n uniform sampler2D uTexture;\n uniform sampler2D vTexture;\n\n const mat4 YUV2RGB = mat4( 1.1643828125, 0, 1.59602734375, -.87078515625,\n 1.1643828125, -.39176171875, -.81296875, .52959375,\n 1.1643828125, 2.017234375, 0, -1.081390625,\n 0, 0, 0, 1);\n\n\n void main(void) {\n\n if (isyuv>0) {\n\n highp float y = texture2D(yTexture, vTexturePosition).r;\n highp float u = texture2D(uTexture, vTexturePosition).r;\n highp float v = texture2D(vTexture, vTexturePosition).r;\n gl_FragColor = vec4(y, u, v, 1) * YUV2RGB;\n\n } else {\n gl_FragColor = texture2D(rgbaTexture, vTexturePosition);\n }\n }\n "),i=this.gl.createProgram();return this.gl.attachShader(i,e),this.gl.attachShader(i,t),this.gl.linkProgram(i),this.gl.getProgramParameter(i,this.gl.LINK_STATUS)?i:(console.log("Unable to initialize the shader program: "+this.gl.getProgramInfoLog(i)),null)}_loadShader(e,t){const i=this.gl,r=i.createShader(e);return i.shaderSource(r,t),i.compileShader(r),i.getShaderParameter(r,i.COMPILE_STATUS)?r:(console.log("An error occurred compiling the shaders: "+i.getShaderInfoLog(r)),i.deleteShader(r),null)}_initBuffers(){const e=this.gl,t=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,t);var i=[-1,-1,1,-1,1,1,-1,1];e.bufferData(e.ARRAY_BUFFER,new Float32Array(i),e.STATIC_DRAW);var r=(r=[]).concat([0,1],[1,1],[1,0],[0,0]),s=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,s),e.bufferData(e.ARRAY_BUFFER,new Float32Array(r),e.STATIC_DRAW),r=e.createBuffer();return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,r),e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Uint16Array([0,1,2,0,2,3]),e.STATIC_DRAW),{positions:i,position:t,texPosition:s,indices:r}}_createTexture(){var e=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),e}_drawScene(e,t,i){this.gl.viewport(0,0,e,t),this.gl.enable(this.gl.BLEND),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._buffers.position),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this._buffers.positions),this.gl.STATIC_DRAW),this.gl.vertexAttribPointer(this._programInfo.attribLocations.vertexPosition,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this._programInfo.attribLocations.vertexPosition),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._buffers.texPosition),this.gl.vertexAttribPointer(this._programInfo.attribLocations.texturePosition,2,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(this._programInfo.attribLocations.texturePosition),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this._buffers.indices),i?(this.gl.activeTexture(this.gl.TEXTURE0+3),this.gl.bindTexture(this.gl.TEXTURE_2D,this._ytexture),this.gl.activeTexture(this.gl.TEXTURE0+4),this.gl.bindTexture(this.gl.TEXTURE_2D,this._utexture),this.gl.activeTexture(this.gl.TEXTURE0+5),this.gl.bindTexture(this.gl.TEXTURE_2D,this._vtexture)):(this.gl.activeTexture(this.gl.TEXTURE0+2),this.gl.bindTexture(this.gl.TEXTURE_2D,this._rgbatexture)),this.gl.useProgram(this._programInfo.program),this.gl.uniform1i(this._programInfo.uniformLocations.rgbatexture,2),this.gl.uniform1i(this._programInfo.uniformLocations.ytexture,3),this.gl.uniform1i(this._programInfo.uniformLocations.utexture,4),this.gl.uniform1i(this._programInfo.uniformLocations.vtexture,5),this.gl.uniform1i(this._programInfo.uniformLocations.isyuv,i?1:0),this.gl.drawElements(this.gl.TRIANGLES,6,this.gl.UNSIGNED_SHORT,0)}_calRect(e,t,i,r,s,a){var n=2*e/s-1;r=2*(a-t-r)/a-1,e=2*(e+i)/s-1,i=2*(a-t)/a-1;return[n,r,e,r,e,i,n,i]}_clear(){this.gl.clearColor(0,0,0,1),this.gl.clearDepth(1),this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT)}render(e,t,i,r,s){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,r),a.activeTexture(a.TEXTURE2),a.bindTexture(a.TEXTURE_2D,this._vtexture),a.texImage2D(a.TEXTURE_2D,0,a.LUMINANCE,e/2,t/2,0,a.LUMINANCE,a.UNSIGNED_BYTE,s),this._buffers.positions=[-1,-1,1,-1,1,1,-1,1],this._drawScene(e,t,!0)}renderYUV(e,t,i){var r=i.slice(0,e*t),s=i.slice(e*t,e*t*5/4);i=i.slice(e*t*5/4,e*t*3/2);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,r),a.activeTexture(a.TEXTURE1),a.bindTexture(a.TEXTURE_2D,this._utexture),a.texImage2D(a.TEXTURE_2D,0,a.LUMINANCE,e/2,t/2,0,a.LUMINANCE,a.UNSIGNED_BYTE,s),a.activeTexture(a.TEXTURE2),a.bindTexture(a.TEXTURE_2D,this._vtexture),a.texImage2D(a.TEXTURE_2D,0,a.LUMINANCE,e/2,t/2,0,a.LUMINANCE,a.UNSIGNED_BYTE,i),this._buffers.positions=[-1,-1,1,-1,1,1,-1,1],this._drawScene(e,t,!0)}drawDom(e,t,i,r,s){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,s),this._buffers.positions=this._calRect(i,r,s.width,s.height,e,t),this._drawScene(e,t,!1)}}class ti{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);var r=new Float32Array([0,1,1,1,1,0,0,0]),s=e.createBuffer({size:r.byteLength,usage:window.GPUBufferUsage.VERTEX|window.GPUBufferUsage.COPY_DST}),a=(r=(e.queue.writeBuffer(s,0,r),new Uint16Array([0,1,2,0,2,3])),e.createBuffer({size:r.byteLength,usage:window.GPUBufferUsage.INDEX|window.GPUBufferUsage.COPY_DST}));return e.queue.writeBuffer(a,0,r),{positionBuffer:i,texpositionBuffer:s,indexBuffer:a}}_initPipeline(){return new Promise((e,t)=>{const i=this.gpu.device,r=this.gpu.format,s={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:r}]},depthStencil:{depthWriteEnabled:!0,depthCompare:"less",format:"depth24plus"}};i.createRenderPipelineAsync(s).then(t=>{e(t)}).catch(e=>{t(e)})})}_initMatrixGroupInfo(){const e=this.gpu.device,t=this.pipeline,i=Qt();r=(s=m=1)/((f=-1)-m),A=1/((a=-1)-s),h=1/((d=.1)-(l=100)),(c=i)[0]=-2*r,c[1]=0,c[2]=0,c[3]=0,c[4]=0,c[5]=-2*A,c[6]=0,c[7]=0,c[8]=0,c[9]=0,c[10]=2*h,c[11]=0,c[12]=(f+m)*r,c[13]=(s+a)*A,c[14]=(l+d)*h,c[15]=1;var r,s,a,n,o,l,d,h,c,u,p,f=Qt(),m=(Xt(f),Qt()),g=(r=m,s=Zt(0,0,0),a=Zt(0,0,-1),A=Zt(0,1,0),l=s[0],d=s[1],s=s[2],h=A[0],c=A[1],A=A[2],u=a[0],p=a[1],a=a[2],Math.abs(l-u)<1e-6&&Math.abs(d-p)<1e-6&&Math.abs(s-a)<1e-6?Xt(r):(a=s-a,y=c*(a*=g=1/Math.hypot(u=l-u,p=d-p,a))-A*(p*=g),A=A*(u*=g)-h*a,h=h*p-c*u,(g=Math.hypot(y,A,h))?(y*=g=1/g,A*=g,h*=g):h=A=y=0,c=p*h-a*A,n=a*y-u*h,o=u*A-p*y,(g=Math.hypot(c,n,o))?(c*=g=1/g,n*=g,o*=g):o=n=c=0,r[0]=y,r[1]=c,r[2]=u,r[3]=0,r[4]=A,r[5]=n,r[6]=p,r[7]=0,r[8]=h,r[9]=o,r[10]=a,r[11]=0,r[12]=-(y*l+A*d+h*s),r[13]=-(c*l+n*d+o*s),r[14]=-(u*l+p*d+a*s),r[15]=1),e.createBuffer({size:64,usage:window.GPUBufferUsage.UNIFORM|window.GPUBufferUsage.COPY_DST})),y=(e.queue.writeBuffer(g,0,f),e.createBuffer({size:64,usage:window.GPUBufferUsage.UNIFORM|window.GPUBufferUsage.COPY_DST})),A=(e.queue.writeBuffer(y,0,m),e.createBuffer({size:64,usage:window.GPUBufferUsage.UNIFORM|window.GPUBufferUsage.COPY_DST}));return e.queue.writeBuffer(A,0,i),{modelMatrixBuffer:g,viewMatrixBuffer:y,projectMatrixBuffer:A,group:e.createBindGroup({label:"group0",layout:t.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:g}},{binding:1,resource:{buffer:y}},{binding:2,resource:{buffer:A}}]})}}_initTextureGroupInfo(e,t){const i=this.gpu.device,r=this.pipeline,s=i.createTexture({size:[e,t],format:"r8unorm",usage:window.GPUTextureUsage.TEXTURE_BINDING|window.GPUTextureUsage.COPY_DST|window.GPUTextureUsage.RENDER_ATTACHMENT}),a=i.createTexture({size:[e/2,t/2],format:"r8unorm",usage:window.GPUTextureUsage.TEXTURE_BINDING|window.GPUTextureUsage.COPY_DST|window.GPUTextureUsage.RENDER_ATTACHMENT}),n=i.createTexture({size:[e/2,t/2],format:"r8unorm",usage:window.GPUTextureUsage.TEXTURE_BINDING|window.GPUTextureUsage.COPY_DST|window.GPUTextureUsage.RENDER_ATTACHMENT}),o=i.createSampler({magFilter:"linear",minFilter:"linear"}),l=i.createBindGroup({label:"group1",layout:r.getBindGroupLayout(1),entries:[{binding:0,resource:o},{binding:1,resource:s.createView()},{binding:2,resource:a.createView()},{binding:3,resource:n.createView()}]});return{yTexture:s,uTexture:a,vTexture:n,group:l}}_drawScene(){const e=this.gpu.device,t=this.gpu.context,i=e.createCommandEncoder(),r={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"}},s=i.beginRenderPass(r);s.setPipeline(this.pipeline),s.setBindGroup(0,this.matrixGroupInfo.group),s.setBindGroup(1,this.textureGroupInfo.group),s.setVertexBuffer(0,this.buffers.positionBuffer),s.setVertexBuffer(1,this.buffers.texpositionBuffer),s.setIndexBuffer(this.buffers.indexBuffer,"uint16"),s.drawIndexed(6),s.end(),e.queue.submit([i.finish()])}renderYUV(e,t,i){if(this.hasInited){var r=i.slice(0,e*t),s=i.slice(e*t,e*t*5/4);i=i.slice(e*t*5/4,e*t*3/2);const a=this.gpu.device;this.depthTexture||(this.depthTexture=this.gpu.device.createTexture({size:[e,t],format:"depth24plus",usage:window.GPUTextureUsage.RENDER_ATTACHMENT})),this.textureGroupInfo||(this.textureGroupInfo=this._initTextureGroupInfo(e,t)),a.queue.writeTexture({texture:this.textureGroupInfo.yTexture},r,{bytesPerRow:e,rowsPerImage:t},[e,t]),a.queue.writeTexture({texture:this.textureGroupInfo.uTexture},s,{bytesPerRow:e/2,rowsPerImage:t/2},[e/2,t/2]),a.queue.writeTexture({texture:this.textureGroupInfo.vTexture},i,{bytesPerRow:e/2,rowsPerImage:t/2},[e/2,t/2]),this._drawScene()}}clear(){}}class ii extends r{constructor(){super(),this.videoInfo={width:null,height:null,encType:null},this.init=!1}destroy(){this.resetInit(),this.off()}resetInit(){this.videoInfo={width:null,height:null,encType:null},this.init=!1}getHasInit(){return this.init}updateVideoInfo(e){_t(e.encTypeCode)&&(this.videoInfo.encType=H[e.encTypeCode]),_t(e.encType)&&(this.videoInfo.encType=e.encType),_t(e.width)&&(this.videoInfo.width=e.width),_t(e.height)&&(this.videoInfo.height=e.height),_t(this.videoInfo.encType)&&_t(this.videoInfo.height)&&_t(this.videoInfo.width)&&!this.init&&(this.player.emit(U.videoInfo,this.videoInfo),this.init=!0)}getVideoInfo(){return this.videoInfo}clearView(){}play(){}pause(){}getType(){return""}getCanvasType(){return""}isPlaying(){return!0}addContentToCanvas(){}getPlaybackQuality(){return null}}var ri="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof e&&e.global===e?e:void 0;function si(e,t,i){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){li(r.response,t,i)},r.onerror=function(){console.error("could not download file")},r.send()}function ai(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&t.status<=299}function ni(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(r){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 oi=ri.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),li="object"!=typeof window||window!==ri?function(){}:"download"in HTMLAnchorElement.prototype&&!oi?function(e,t,i){var r=ri.URL||ri.webkitURL,s=document.createElementNS("http://www.w3.org/1999/xhtml","a");t=t||e.name||"download",s.download=t,s.rel="noopener","string"==typeof e?(s.href=e,s.origin!==location.origin?ai(s.href)?si(e,t,i):ni(s,s.target="_blank"):ni(s)):(s.href=r.createObjectURL(e),setTimeout((function(){r.revokeObjectURL(s.href)}),4e4),setTimeout((function(){ni(s)}),0))}:"msSaveOrOpenBlob"in navigator?function(e,t,i){var r;t=t||e.name||"download","string"==typeof e?ai(e)?si(e,t,i):((r=document.createElement("a")).href=e,r.target="_blank",setTimeout((function(){ni(r)}))):navigator.msSaveOrOpenBlob((e=e,void 0===(i=i)?i={autoBom:!1}:"object"!=typeof i&&(console.warn("Deprecated: Expected third argument to be a object"),i={autoBom:!i}),i.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([String.fromCharCode(65279),e],{type:e.type}):e),t)}:function(e,t,i,r){if((r=r||open("","_blank"))&&(r.document.title=r.document.body.innerText="downloading..."),"string"==typeof e)return si(e,t,i);t="application/octet-stream"===e.type,i=/constructor/i.test(ri.HTMLElement)||ri.safari;var s,a,n,o=/CriOS\/[\d]+/.test(navigator.userAgent);(o||t&&i||oi)&&"undefined"!=typeof FileReader?((s=new FileReader).onloadend=function(){var e=s.result;e=o?e:e.replace(/^data:[^;]*;/,"data:attachment/file;");r?r.location.href=e:location=e,r=null},s.readAsDataURL(e)):(a=ri.URL||ri.webkitURL,n=a.createObjectURL(e),r?r.location=n:location.href=n,r=null,setTimeout((function(){a.revokeObjectURL(n)}),4e4))};class di{constructor(e,t){this.gl=e,t&&this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1),e=this._initShaderProgram(),this.shaderProgram=e,this.programInfo={program:e,attribLocations:{vertexPosition:this.gl.getAttribLocation(e,"aVertexPosition")},uniformLocations:{linewidth:this.gl.getUniformLocation(e,"uLineWidth"),rect:this.gl.getUniformLocation(e,"uRect"),linecolor:this.gl.getUniformLocation(e,"uLineColor"),resolution:this.gl.getUniformLocation(e,"uResolution")}},this.buffers=this._initBuffers()}destroy(){this.gl.deleteProgram(this.shaderProgram),this.gl.deleteBuffer(this.buffers.position),this.gl.deleteBuffer(this.buffers.indices),this.shaderProgram=null,this.buffers=null}_initShaderProgram(){const e=this.gl,t=this._loadShader(e.VERTEX_SHADER,"\n attribute vec4 aVertexPosition;\n void main(void) {\n gl_Position = aVertexPosition;\n }\n "),i=this._loadShader(e.FRAGMENT_SHADER,"\n precision highp float;\n uniform float uLineWidth;\n uniform vec4 uRect;\n uniform vec3 uLineColor;\n uniform vec2 uResolution;\n\n\n float inBox(vec2 st, vec4 rect){\n\n vec2 bl = step(rect.xy,st);\n float pct = bl.x * bl.y;\n\n vec2 tr = step(st, rect.zw);\n pct *= tr.x * tr.y;\n\n return pct;\n }\n\n void main(void) {\n\n vec2 cur = gl_FragCoord.xy/uResolution;\n\n float xlinewidth = uLineWidth/uResolution.x;\n float ylinewidth = uLineWidth/uResolution.y;\n\n // vec4 outRect = uRect + vec4(-1.*xlinewidth/2., -1.*ylinewidth/2., xlinewidth/2., ylinewidth/2.);\n // vec4 inRect = uRect + vec4(xlinewidth/2., ylinewidth/2., -1.*xlinewidth/2., -1.*ylinewidth/2.);\n\n vec4 outRect = uRect + vec4(-1.*xlinewidth/2., -1.*ylinewidth/2., xlinewidth/2., ylinewidth/2.);\n vec4 inRect = uRect;\n\n float a = inBox(cur, outRect);\n float b = inBox(cur, inRect);\n\n gl_FragColor = mix(vec4(0., 0., 0., 0.), vec4(uLineColor.rgb, 1.0), a-b);\n\n }\n "),r=e.createProgram();return e.attachShader(r,t),e.attachShader(r,i),e.linkProgram(r),e.getProgramParameter(r,e.LINK_STATUS)?r:(console.log("Unable to initialize the shader program: "+e.getProgramInfoLog(r)),null)}_loadShader(e,t){const i=this.gl,r=i.createShader(e);return i.shaderSource(r,t),i.compileShader(r),i.getShaderParameter(r,i.COMPILE_STATUS)?r:(console.log("An error occurred compiling the shaders: "+i.getShaderInfoLog(r)),i.deleteShader(r),null)}_createTexture(){const e=this.gl;var t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),t}_initBuffers(){const e=this.gl,t=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,t),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,1,1,-1,1]),e.STATIC_DRAW);var i=e.createBuffer();return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,i),e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Uint16Array([0,1,2,0,2,3]),e.STATIC_DRAW),{position:t,indices:i}}_drawScene(e){var{canvasWidth:e,canvasHeight:t,rect:i,lineWidth:r,lineColor:s}=e;const a=this.gl,n=this.buffers,o=this.programInfo;a.viewport(0,0,e,t),a.enable(a.BLEND),a.blendFunc(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA),a.bindBuffer(a.ARRAY_BUFFER,n.position),a.vertexAttribPointer(o.attribLocations.vertexPosition,2,a.FLOAT,!1,0,0),a.enableVertexAttribArray(o.attribLocations.vertexPosition),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,n.indices),a.useProgram(o.program),a.uniform2f(o.uniformLocations.resolution,e,t),a.uniform4f(o.uniformLocations.rect,i[0],i[1],i[2],i[3]),a.uniform1f(o.uniformLocations.linewidth,r),a.uniform3f(o.uniformLocations.linecolor,s[0],s[1],s[2]),a.drawElements(a.TRIANGLES,6,a.UNSIGNED_SHORT,0)}drawBox(e){var{x:e,y:t,width:i,height:r,lineWidth:s,lineColor:a,canvasWidth:n,canvasHeight:o}=e,l=(l=e/n,r=(o-t-r)/o,e=(e+i)/n,i=(o-t)/o,(t=new Jt(4))[0]=l,t[1]=r,t[2]=e,t[3]=i,t),a=Zt(1,0,0);this._drawScene({canvasWidth:n,canvasHeight:o,rect:l,lineWidth:s,lineColor:a})}}class hi{constructor(e,t){if(this.canvas=e,e=(this.gl=t).createShader(t.VERTEX_SHADER),t.shaderSource(e,"\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(e),!t.getShaderParameter(e,t.COMPILE_STATUS))throw t.getShaderInfoLog(e);var i=t.createShader(t.FRAGMENT_SHADER);if(t.shaderSource(i,"\n varying highp vec2 uv;\n uniform sampler2D texture;\n void main(void) {\n gl_FragColor = texture2D(texture, uv);\n }\n "),t.compileShader(i),!t.getShaderParameter(i,t.COMPILE_STATUS))throw t.getShaderInfoLog(i);var r=t.createProgram();if(t.attachShader(r,e),t.attachShader(r,i),t.linkProgram(r),!t.getProgramParameter(r,t.LINK_STATUS))throw t.getProgramInfoLog(r);t.useProgram(r);var s=t.createBuffer(),a=(t.bindBuffer(t.ARRAY_BUFFER,s),t.bufferData(t.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),t.STATIC_DRAW),t.getAttribLocation(r,"xy"));t.vertexAttribPointer(a,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(a),a=t.createTexture();t.bindTexture(t.TEXTURE_2D,a),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=s,this.vertexShader=e,this.fragmentShader=i,this.texture=a}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 ci extends ii{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.tempCanvasContentList=[],this._initCanvasRender()}destroy(){super.destroy(),0<this.proxyDestroyList.length&&(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.tempCanvasContentList=[],this.player.$container.removeChild(this.$videoElement),this.init=!1,this.off()}_initContext2D(){this.context2D=this.$videoElement.getContext("2d",0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})}_initContextGl(){this.player.events,this.contextGl=Ke(this.$videoElement),this.contextGl?(this._bindContextGlEvents(),this.webglRender=new ei(this.contextGl,this.player._opt.openWebglAlignment),this.webglRectRender=new di(this.contextGl,this.player._opt.openWebglAlignment)):this.player.debug.error("CommonCanvasLoader","_initContextGl() createContextGL error")}_initContextGl2(){if(this.contextGl=$e(this.$videoElement),this.contextGl){this._bindContextGlEvents(2);try{this.webglRender=new hi(this.$videoElement,this.contextGl)}catch(r){this.player.debug.error("CommonCanvasLoader",`create webgl2Render error is ${r} 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=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1;const t=this.player.events["proxy"],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(()=>{this.player.debug.log("CommonCanvasLoader","createContextGL() version "+e),1===e?this.contextGl=Ke(this.$videoElement):2===e&&(this.contextGl=$e(this.$videoElement)),this.player.debug.log("CommonCanvasLoader","createContextGL success"),this.contextGl&&this.contextGl.getContextAttributes&&this.contextGl.getContextAttributes().stencil?(1===e?(this.webglRender=new ei(this.contextGl,this.player._opt.openWebglAlignment),this.webglRectRender=new di(this.contextGl,this.player._opt.openWebglAlignment)):2===e&&(this.webglRender=new hi(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(O.webglContextLostError))},500)}),r=t(this.$videoElement,"webglcontextrestored",e=>{e.preventDefault(),this.player.debug.log("CommonCanvasLoader","webglcontextrestored ",e)});this.proxyDestroyList.push(i,r)}_initContextGPU(){var e=this.$videoElement;new Promise((t,i)=>{navigator.gpu?navigator.gpu.requestAdapter().then(r=>{r?r.requestDevice().then(s=>{if(s){const a=e.getContext("webgpu");if(a){const e=navigator.gpu.getPreferredCanvasFormat();a.configure({device:s,format:e,alphaMode:"opaque"}),t({adapter:r,device:s,context:a,format:e})}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(e=>{this.webGPURender=new ti(e),this.player.debug.log("CommonCanvasLoader","webGPURender init success")}).catch(e=>{this.player.debug.error("CommonCanvasLoader",`createWebGPUContext error is ${e} and next use webgl render`),this.renderType=J,this._initContextGl()})}initCanvasViewSize(){this.$videoElement.width=this.videoInfo.width,this.$videoElement.height=this.videoInfo.height,this.resize()}screenshot(e,t,i,r){e=e||qe(),r=r||z.download;let s=.92;!Ae[t]&&z[t]&&(r=t,t="png",i=void 0),"string"==typeof i&&(r=i,i=void 0),void 0!==i&&(s=Number(i));const a=Ae[t]||Ae.png,n=this.$videoElement.toDataURL(a,s);if(r===z.base64)return n;{const t=Ye(n);if(r===z.blob)return t;if(r===z.download){const i=a.split("/")[1];li(t,e+"."+i)}}}screenshotWatermark(e){return new Promise((t,i)=>{(e=(e=Dt(e)?{filename:e}:e)||{}).width=this.videoInfo.width,e.height=this.videoInfo.height,e.filename=e.filename||qe(),e.format=e.format?Ae[e.format]:Ae.png,e.quality=Number(e.quality)||.92,e.type=e.type||z.download;const r=this.$videoElement.toDataURL(e.format,e.quality);Et(r,e).then(i=>{if(e.type===z.base64)t(r);else{const r=Ye(i);if(e.type===z.blob)t(r);else if(e.type===z.download){t();const i=e.format.split("/")[1];li(r,e.filename+"."+i)}}}).catch(e=>{i(e)})})}render(){}clearView(){}play(){}pause(){}resize(){this.player.debug.log("canvasVideo","resize");var e=this.player._opt;let t=this.player.width,i=this.player.height;if(e.hasControl&&!e.controlAutoHide){const r=this.controlHeight;it()&&this.player.fullscreen&&e.useWebFullScreen?t-=r:i-=r}let r=this.$videoElement.width,s=this.$videoElement.height;var a=e.rotate,n=(t-r)/2,o=(i-s)/2,l=(270!==a&&90!==a||(r=this.$videoElement.height,s=this.$videoElement.width),t/r),d=i/s;let h=d<l?d:l,c=(e.isResize||l!=d&&(h=l+","+d),"scale("+(h=e.isFullResize?d<l?l:d:h)+")");"none"===e.mirrorRotate&&a&&(c+=" rotate("+a+"deg)"),"level"===e.mirrorRotate?c+=" rotateY(180deg)":"vertical"===e.mirrorRotate&&(c+=" rotateX(180deg)"),this.$videoElement.style.transform=c,this.$videoElement.style.left=n+"px",this.$videoElement.style.top=o+"px"}initFps(){}setStreamFps(){}getStreamFps(){return 25}getType(){return A}getCanvasType(){let e=this.renderType===Q?Q:J;return this.isWcsWebgl2?"webgl2":e}addContentToCanvas(){this.tempCanvasContentList=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[]}}class ui extends ci{constructor(e){super(e),this.yuvList=[],this.controlHeight=38,this.tempTextCanvas=null,this.tempTextCanvasCtx=null,this.player.debug.log("CanvasVideo","init")}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=q,function(){try{var e=document.createElement("canvas");return window.WebGL2RenderingContext&&e.getContext("webgl2")}catch(e){return}}()?(this._initContextGl2(),this.webglRender&&(this.isWcsWebgl2=!0)):this._initContext2D()):this.player._opt.useMSE&&this.player._opt.mseUseCanvasRender?(this.renderType=Z,this._initContext2D()):this.player.isOldHls()&&this.player._opt.useCanvasRender?(this.renderType="hls",this._initContext2D()):this._supportOffscreen()?(this.renderType=X,this._bindOffscreen()):this.player._opt.useWebGPU?(this.renderType=Q,this._initContextGPU()):(this.renderType=J,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);){var e=this.yuvList.shift();this.doRender(e)}}doRender(e){var t;switch(this.player.videoTimestamp=e.ts||0,this.renderType!==Z&&(t={ts:e.ts||0,fps:!0},this.player.updateStats(t)),this.renderType){case X:this.bitmaprenderer.transferFromImageBitmap(e.buffer);break;case J:case Q: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&&(t=this.player.ai.faceDetector.detect({width:this.$videoElement.width,height:this.$videoElement.height,data:e.output})),this.player.objectDetectActive&&this.player.ai&&this.player.ai.objectDetector&&(t=this.player.ai.objectDetector.detect({width:this.$videoElement.width,height:this.$videoElement.height,data:e.output})),this.renderType===Q)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===J)try{this.webglRender.renderYUV(this.$videoElement.width,this.$videoElement.height,t),this.doAddContentToWebGlCanvas()}catch(e){this.player.debug.error("CanvasVideoLoader",`doRender webgl render context is lost ${this.contextGl&&this.contextGl.isContextLost()} and error: `+e.toString())}break;case q:if(this.webglRender)this.webglRender.render(e.videoFrame),Ot(e.videoFrame);else if(this.context2D)if(Pt(e.videoFrame.createImageBitmap))try{e.videoFrame.createImageBitmap().then(t=>{this.context2D.drawImage(t,0,0,this.$videoElement.width,this.$videoElement.height),Ot(e.videoFrame),this.doAddContentToCanvas()})}catch(e){}else this.context2D.drawImage(e.videoFrame,0,0,this.$videoElement.width,this.$videoElement.height),Ot(e.videoFrame),this.doAddContentToCanvas();else this.player.debug.warn("CanvasVideoLoader","doRender() and webcodecs context is lost");break;case Z:case"hls":this.context2D.drawImage(e.$video,0,0,this.$videoElement.width,this.$videoElement.height),this.doAddContentToCanvas()}}clearView(){switch(this.renderType){case X:(function(e,t){const i=document.createElement("canvas");return i.width=e,i.height=t,e=window.createImageBitmap(i,0,0,e,t),i.width=0,i.height=0,e})(this.$videoElement.width,this.$videoElement.height).then(e=>{this.bitmaprenderer.transferFromImageBitmap(e)});break;case J:this.contextGl.clear(this.contextGl.COLOR_BUFFER_BIT);break;case Q:this.webGPURender.clear();break;case q: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 Z:case"hls":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(){if(0<this.tempCanvasContentList.length&&this.context2D){let{ctx:e,list:t}={ctx:this.context2D,list:this.tempCanvasContentList};e.save(),(t||[]).forEach(t=>{"text"===t.type?(e.font=(t.fontSize||12)+"px Arial",e.fillStyle=t.color||"green",e.fillText(t.text,t.x,t.y)):"rect"===t.type&&(e.strokeStyle=t.color||"green",e.lineWidth=t.lineWidth||2,e.strokeRect(t.x,t.y,t.width,t.height))}),e.restore()}}doAddContentToWebGlCanvas(){0<this.tempCanvasContentList.length&&this.contextGl&&this.webglRectRender&&this.tempCanvasContentList.forEach(e=>{var t=e.x,i=e.y;if("rect"===e.type){var r=e.width,s=e.height,a=(a=e.color||"#008000",[parseInt(a.substring(1,3),16)/255,parseInt(a.substring(3,5),16)/255,parseInt(a.substring(5,7),16)/255,1]),n=e.lineWidth||4;r&&s&&this.webglRectRender.drawBox({x:t,y:i,width:r,height:s,lineColor:a,lineWidth:n,canvasWidth:this.$videoElement.width,canvasHeight:this.$videoElement.height})}else if("text"===e.type){const a=e.text||"";a&&(r=e.fontSize||20,s=e.color||"#008000",this.tempTextCanvas||this._initTempTextCanvas(),this.tempTextCanvasCtx.clearRect(0,0,this.tempTextCanvas.width,this.tempTextCanvas.height),this.tempTextCanvasCtx.font=r+"px Arial",this.tempTextCanvasCtx.fillStyle=s,this.tempTextCanvasCtx.textBaseline="top",this.tempTextCanvasCtx.fillText(a,0,0),this.webglRender.drawDom(this.$videoElement.width,this.$videoElement.height,t,i,this.tempTextCanvas))}})}}class pi{constructor(e){this.player=e,this.configList=[],this.shadowRoot=null,this.shadowRootRealDom=null,this.shadowRootInnerDom=null,this.scale=1,this._initDom(),this.player.debug.log("SingleWatermark","int")}destroy(){this.configList=[],this.shadowRootInnerDom=null,this.scale=1,this.shadowRoot&&(this.player.$container.removeChild(this.shadowRootRealDom),this.shadowRoot=null,this.shadowRootInnerDom=null),this.player.debug.log("SingleWatermark","destroy")}resize(){this._resizeDom()}_initDom(){const e=this.player.$container;let t=null;const i=document.createElement("div"),r=(i.setAttribute("style","pointer-events: none !important;display: block !important;"),t="function"==typeof i.attachShadow?i.attachShadow({mode:"open"}):i.shadowRoot||i,document.createElement("div"));r.setAttribute("style","position: absolute; top: 0; left: 0; width: 0; height: 0;display: none;"),t.appendChild(r);var s=e.children,a=Math.floor(Math.random()*(s.length-1));s[a]?e.insertBefore(i,s[a]):e.appendChild(i),this.shadowRootInnerDom=r,this.shadowRootRealDom=i,this.shadowRoot=t}update(e){this._removeDom();let t=[];Array.isArray(e)?t=e:Lt(e)&&t.push(e),e=t.map(e=>wt(e)),this.configList=e,this._updateDom()}_resizeDom(){this.player.$container;const e=this.player.width,t=this.player.height,i=this.player.getVideoInfo();if(i&&0<i.height&&0<i.width){let h=i.width,c=i.height;var r=this.player._opt;let u=t,p=e;if(r.hasControl&&!r.controlAutoHide){const e=r.playType===d?48:38;it()&&this.player.fullscreen&&r.useWebFullScreen?p-=e:u-=e}var s=r.rotate,a=(p-h)/2,n=(u-c)/2,o=(270!==s&&90!==s||(h=i.height,c=i.width),p/h),l=u/c;let f=l<o?l:o,m=(r.isResize||o!=l&&(f=o+","+l),"scale("+(f=r.isFullResize?l<o?o:l:f)+")");"none"===r.mirrorRotate&&s&&(m+=" rotate("+s+"deg)"),"level"===r.mirrorRotate?m+=" rotateY(180deg)":"vertical"===r.mirrorRotate&&(m+=" rotateX(180deg)"),this.scale=-1!==(""+f).indexOf(",")?o:f,this.shadowRootInnerDom.style.transform=m,this.shadowRootInnerDom.style.left=a+"px",this.shadowRootInnerDom.style.top=n+"px",this.shadowRootInnerDom.style.width=i.width+"px",this.shadowRootInnerDom.style.height=i.height+"px",this.shadowRootInnerDom.style.display="block"}}_updateDom(){this.shadowRoot&&this.configList.forEach(e=>{const t=document.createElement("div");let i=null;e.image&&e.image.src?((i=document.createElement("img")).style.height="100%",i.style.width="100%",i.style.objectFit="contain",i.src=e.image.src):e.text&&e.text.content?i=document.createTextNode(e.text.content):(e.rect&&e.rect.color&&e.rect.width||e.html)&&(i=document.createElement("div")),i&&(t.appendChild(i),t.style.visibility="",t.style.position="absolute",t.style.display="block",t.style["-ms-user-select"]="none",t.style["-moz-user-select"]="none",t.style["-webkit-user-select"]="none",t.style["-o-user-select"]="none",t.style["user-select"]="none",t.style["-webkit-touch-callout"]="none",t.style["-webkit-tap-highlight-color"]="rgba(0,0,0,0)",t.style["-webkit-text-size-adjust"]="none",t.style["-webkit-touch-callout"]="none",t.style.opacity=e.opacity,ft(e.left)&&(t.style.left=e.left+"px"),ft(e.right)&&(t.style.right=e.right+"px"),ft(e.top)&&(t.style.top=e.top+"px"),ft(e.bottom)&&(t.style.bottom=e.bottom+"px"),e.backgroundColor&&(t.style.backgroundColor=e.backgroundColor),t.style.overflow="hidden",t.style.zIndex="9999999",e.image&&e.image.src?(t.style.width=e.image.width+"px",t.style.height=e.image.height+"px"):e.text&&e.text.content?(t.style.fontSize=e.text.fontSize+"px",t.style.color=e.text.color):e.rect&&e.rect.color&&e.rect.width?(t.style.width=e.rect.width+"px",t.style.height=e.rect.height+"px",t.style.borderWidth=e.rect.lineWidth+"px",t.style.borderStyle="solid",t.style.borderColor=e.rect.color):e.html&&(t.innerHTML=e.html,t.style.width=e.width+"px",t.style.height=e.height+"px"),this.shadowRootInnerDom.appendChild(t))})}remove(){this._removeDom()}_removeDom(){this.shadowRootInnerDom&&(this.shadowRootInnerDom.innerHTML="")}}class fi extends ii{constructor(e){super(),this.player=e,this.TAG_NAME="Video";const t=document.createElement("video"),i=document.createElement("canvas"),r=(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()&&yt()&&At()&&(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.fixMobileAutoFullscreen(),this.resize(),this.eventListenList=[],this.tempContentList=[],this.contentWatermark=null,this.isRenderRetryPlaying=!1,this.isRenderRetryPlayingTimes=0,this.isRetryPlaying=!1,this.isRetryPlayingTimes=0,this.player.events)["proxy"],s=r(this.$videoElement,"canplay",()=>{this.player.debug.log("Video","canplay"),this._delayPlay&&this._play()}),a=r(this.$videoElement,"waiting",()=>{this.player.debug.log("Video","waiting")}),n=r(this.$videoElement,"loadedmetadata",()=>{this.player.debug.log("Video","loadedmetadata")}),o=r(this.$videoElement,"timeupdate",t=>{t=parseInt(t.timeStamp,10),(this.player.isWebrtcH264()||this.player.isOldHls())&&this.player.emit(U.timeUpdate,t),e.isWebrtcH264()&&(e.handleRender(),e.updateStats({fps:!0}))}),l=r(this.$videoElement,"error",()=>{this.player.debug.error("Video","Error "+this.$videoElement.error.code+"; details: "+this.$videoElement.error.message)});this.eventListenList.push(s,a,o,l,n),this.player.debug.log("Video","init")}destroy(){if(super.destroy(),this.eventListenList&&(this.eventListenList.forEach(e=>{e()}),this.eventListenList=[]),this.contentWatermark&&(this.contentWatermark.destroy(),this.contentWatermark=null),this.tempContentList=[],this.isRenderRetryPlaying=!1,this.isRenderRetryPlayingTimes=0,this.isRetryPlaying=!1,this.isRetryPlayingTimes=0,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(r){}this.player.$container.removeChild(this.$videoElement),this.$videoElement=null}this.trackGenerator&&(this.trackGenerator.stop(),this.trackGenerator=null),this.vwriter&&(this.vwriter.close(),this.vwriter=null),this._delayPlay=!1,this.mediaStream&&(this.mediaStream.getTracks().forEach(e=>e.stop()),this.mediaStream=null),this.off(),this.player.debug.log("Video","destroy")}fixChromeVideoFlashBug(){if(this.player._opt.videoRenderSupportScale&&this._isNeedAddBackDropFilter()){const e=this.player.$container;e.style.backdropFilter="blur(0px)",e.style.transform="translateZ(0)"}}fixMobileAutoFullscreen(){var e=nt(),t=st();(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.setAttribute("x5-video-player-type","h5-page"))}_isNeedAddBackDropFilter(){var e=at().type.toLowerCase();return"chrome"===e||"edge"===e}isPaused(){let e=!0;return this.$videoElement?this.$videoElement.paused:e}isPause(){return this.isPaused()}_getVideoReadyState(){let e=0;return this.$videoElement?this.$videoElement.readyState:e}_getVideoCurrentTime(){let e=0;return this.$videoElement?this.$videoElement.currentTime:e}play(){if(this.$videoElement){var e=this._getVideoReadyState();if(this.player.debug.log("Video","play and readyState: "+e),0===e)return this.player.debug.warn("Video","readyState is 0 and set _delayPlay to true and listen canplay event to play"),void(this._delayPlay=!0);this._play()}}_play(){this.$videoElement&&this.$videoElement.play().then(()=>{this._delayPlay=!1,this.player.debug.log("Video","_play success"),this.isPlaying()?(this.isRetryPlayingTimes=0,this.isRetryPlaying=!1):setTimeout(()=>{this._replay()},100)}).catch(e=>{this.player.debug.error("Video","_play error",e),this.isRetryPlaying=!1,setTimeout(()=>{this._replay()},100)})}_replay(){!this.isPlaying()&&$t(this.isRetryPlaying)&&(this.isRetryPlaying=!0,3<=this.isRetryPlayingTimes?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(O.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(O.videoElementPlayingFailed)):(this.player.debug.warn("Video","_play then but not playing and retry play"),this._play(),this.isRetryPlayingTimes++))}pause(e){this.isPlaying()&&(e?this.$videoElement&&this.$videoElement.pause():setTimeout(()=>{this.$videoElement&&this.$videoElement.pause()},100))}clearView(){this.$videoElement&&(this.$videoElement.pause(),this.$videoElement.currentTime=0,this.$videoElement.src&&(this.$videoElement.src="",this.$videoElement.removeAttribute("src")),this.$videoElement.srcObject&&(this.$videoElement.srcObject=null,this.$videoElement.removeAttribute("srcObject")))}screenshot(e,t,i,r){if(!this._canScreenshot())return this.player.debug.warn("Video","screenshot failed, video is not ready"),null;e=e||qe(),r=r||z.download;let s=.92;!Ae[t]&&z[t]&&(r=t,t="png",i=void 0),"string"==typeof i&&(r=i,i=void 0),void 0!==i&&(s=Number(i)),i=this.$videoElement;let a=this.$canvasElement;a.width=i.videoWidth,a.height=i.videoHeight,this.canvasContext.drawImage(i,0,0,a.width,a.height);const n=Ae[t]||Ae.png,o=a.toDataURL(n,s);if(this.canvasContext.clearRect(0,0,a.width,a.height),a.width=0,a.height=0,r===z.base64)return o;{const t=Ye(o);if(r===z.blob)return t;if(r===z.download){const i=n.split("/")[1];li(t,e+"."+i)}}}screenshotWatermark(e){return new Promise((t,i)=>{if(Dt(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");var r=this.$videoElement;(e=e||{}).width=r.videoWidth,e.height=r.videoHeight,e.filename=e.filename||qe(),e.format=e.format?Ae[e.format]:Ae.png,e.quality=Number(e.quality)||.92,e.type=e.type||z.download;let s=this.$canvasElement;s.width=r.videoWidth,s.height=r.videoHeight,this.canvasContext.drawImage(r,0,0,s.width,s.height);const a=s.toDataURL(e.format,e.quality);this.canvasContext.clearRect(0,0,s.width,s.height),s.width=0,s.height=0,Et(a,e).then(i=>{if(e.type===z.base64)t(a);else{var r=Ye(i);if(e.type===z.blob)t(r);else if(e.type===z.download){t();const i=e.format.split("/")[1];li(r,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&&$t(this.isRenderRetryPlaying)){if(this.isRenderRetryPlaying=!0,3<this.isRenderRetryPlayingTimes)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(O.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.videoTimestamp=e.ts||0,this.player.updateStats({fps:!0,ts:e.ts||0}),e.videoFrame)this.vwriter.write(e.videoFrame),Ot(e.videoFrame);else if(e.output){let s=e.output;this.player.faceDetectActive&&this.player.ai&&this.player.ai.faceDetector&&(s=this.player.ai.faceDetector.detect({width:this.videoInfo.width,height:this.videoInfo.height,data:e.output})),this.player.objectDetectActive&&this.player.ai&&this.player.ai.objectDetector&&(s=this.player.ai.objectDetector.detect({width:this.videoInfo.width,height:this.videoInfo.height,data:e.output}));try{i=s,r={format:"I420",codedWidth:this.videoInfo.width,codedHeight:this.videoInfo.height,timestamp:e.ts};var t=new VideoFrame(i,r);this.vwriter.write(t),Ot(t)}catch(e){this.player.debug.error("Video","render error",e),this.player.emitError(O.wasmUseVideoRenderError,e)}}this.doAddContentToWatermark()}else this.player.debug.warn("Video","render and this.vwriter is null");var i,r}resize(){let e=this.player.width,t=this.player.height;const i=this.player._opt,r=i.rotate;if(i.hasControl&&!i.controlAutoHide){const r=i.playType===d?48:38;it()&&this.player.fullscreen&&i.useWebFullScreen?e-=r:t-=r}this.$videoElement.width=e,this.$videoElement.height=t,270!==r&&90!==r||(this.$videoElement.width=t,this.$videoElement.height=e);let s=(e-this.$videoElement.width)/2,a=(t-this.$videoElement.height)/2,n="contain",o=(i.isResize||(n="fill"),i.isFullResize&&(n="none"),"");"none"===i.mirrorRotate&&r&&(o+=" rotate("+r+"deg)"),"level"===i.mirrorRotate?o+=" rotateY(180deg)":"vertical"===i.mirrorRotate&&(o+=" rotateX(180deg)"),this.player._opt.videoRenderSupportScale&&(this.$videoElement.style.objectFit=n),this.$videoElement.style.transform=o,this.$videoElement.style.left=s+"px",this.$videoElement.style.top=a+"px"}getType(){return b}isPlaying(){return this.$videoElement&&$t(this.$videoElement.paused)&&$t(this.$videoElement.ended)&&0!==this.$videoElement.playbackRate&&0!==this.$videoElement.readyState}_canScreenshot(){return this.$videoElement&&2<=this.$videoElement.readyState}addContentToCanvas(){this.tempContentList=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[]}doAddContentToWatermark(){var e;0<this.tempContentList.length?(this.contentWatermark||(this.contentWatermark=new pi(this.player),this.contentWatermark.resize()),e=this.tempContentList.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.contentWatermark.update(e)):this.contentWatermark&&this.contentWatermark.remove()}getPlaybackQuality(){let e=null;var t;return this.$videoElement&&(e=Pt(this.$videoElement.getVideoPlaybackQuality)?{droppedVideoFrames:(t=this.$videoElement.getVideoPlaybackQuality()).droppedVideoFrames||t.corruptedVideoFrames,totalVideoFrames:t.totalVideoFrames,creationTime:t.creationTime}:{droppedVideoFrames:this.$videoElement.webkitDroppedFrameCount,totalVideoFrames:this.$videoElement.webkitDecodedFrameCount,creationTime:qe()})&&(e.renderedVideoFrames=e.totalVideoFrames-e.droppedVideoFrames),e}}class mi extends ci{constructor(e){super(e),this.controlHeight=48,this.bufferList=[],this.playing=!1,this.playInterval=null,this.fps=1,this.preFps=1,this.streamFps=0,this.playbackRate=1,this._firstTimestamp=null,this._renderFps=0,this._startfpsTime=null,this._startFpsTimestamp=null,this._hasCalcFps=!1,this.player.on(U.playbackPause,e=>{e?(this.pause(),this.player.playback.isPlaybackPauseClearCache&&this.clear()):this.resume()}),this.player.debug.log("CanvasPlaybackLoader","init")}destroy(){this._stopSync(),this._firstTimestamp=null,this.playing=!1,this.playbackRate=1,this.fps=1,this.preFps=1,this.bufferList=[],this._renderFps=0,this._startfpsTime=null,this._startFpsTimestamp=null,this._hasCalcFps=!1,super.destroy(),this.player.debug.log("CanvasPlaybackLoader","destroy")}_initCanvasRender(){this.player._opt.useWCS?(this.renderType=q,this._initContext2D()):this.player._opt.useWebGPU?(this.renderType=Q,this._initContextGPU()):(this.renderType=J,this._initContextGl())}_sync(){this._stopSync(),this._doPlay(),this.playInterval=setInterval(()=>{this._doPlay()},this.fragDuration)}_doPlay(){var e;0<this.bufferList.length&&!this.player.seeking&&(e=this.bufferList.shift())&&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),Ot(e);else if(Pt(e.createImageBitmap))try{e.createImageBitmap().then(t=>{this.context2D.drawImage(t,0,0,this.$videoElement.width,this.$videoElement.height),Ot(e)})}catch(e){}else this.context2D.drawImage(e,0,0,this.$videoElement.width,this.$videoElement.height),Ot(e);else if(this.getCanvasType()===J)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()===Q)try{this.webGPURender?this.webGPURender.renderYUV(this.$videoElement.width,this.$videoElement.height,e):this.player.debug.warn("CanvasVideoLoader","doRender webgpu render is not init")}catch(e){this.player.debug.error("CanvasPlaybackLoader","doRender webgpu render and error: "+e.toString())}}_updateStats(e){this.player.updateStats({fps:!0,ts:e}),this._startfpsTime||(this._startfpsTime=e,this._startFpsTimestamp=qe());var t=e,i=qe(),r=i-this._startFpsTimestamp;r<=1e3?this._renderFps+=1:(this.player.emit(U.playbackStats,{fps:this._renderFps,start:this._startfpsTime,end:t,timestamp:r,dataTimestamp:t-this._startfpsTime,audioBufferSize:this.player.audio?this.player.audio.bufferSize:0,videoBufferSize:this.player.video?this.player.video.bufferSize:0,ts:e}),this._renderFps=0,this._startfpsTime=t,this._startFpsTimestamp=i)}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=Je(this.player.playback.fps,1,100),this.fps=this.preFps)}setFps(e){e!==this.fps?(100<e&&this.player.debug.warn("CanvasPlaybackLoader","setFps max",e),e<0&&this.player.debug.warn("CanvasPlaybackLoader","setFps min",e),this.fps=Je(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);){var e=this.bufferList.shift();this._doRender(e.buffer)}}pushData(e){null===this._firstTimestamp&&(this._firstTimestamp=e.ts);const t={tfTs:e.ts-this._firstTimestamp,ts:e.ts};if(e.videoFrame?t.buffer=e.videoFrame:t.buffer=e.output,e=this.player._opt.playbackConfig.isCacheBeforeDecodeForFpsRender,e||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=jt(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(!e){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(){var e=this.player._opt.playbackDelayTime;0<e?this.delayTimeout=setTimeout(()=>{this.initVideo()},e):this.initVideo()}clearView(){this.contextGl.clear(this.contextGl.COLOR_BUFFER_BIT)}clear(){this.player._opt.useWCS&&this.bufferList.forEach(e=>{e.buffer&&Ot(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 gi{constructor(e){return new(gi.getLoaderFactory(e._opt))(e)}static getLoaderFactory(e){return e.useMSE?e.mseUseCanvasRender?ui:fi:e.isHls&&$t(e.supportHls265)?e.useCanvasRender?ui:fi:e.isWebrtc&&$t(e.isWebrtcH265)?fi:e.useWCS?e.playType===d?mi:!e.useOffscreen&&e.wcsUseVideoRender?fi:ui:e.playType===d?mi:e.wasmUseVideoRender&&!e.useOffscreen?fi:ui}}class yi extends r{constructor(e){super(),this.bufferList=[],this.player=e,this.$audio=null,this.scriptNode=null,this.workletProcessorNode=null,this.hasInitScriptNode=!1,this.audioContext=new(window.AudioContext||window.webkitAudioContext)({sampleRate:48e3}),this.gainNode=this.audioContext.createGain();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.playing=!1,this.audioSyncVideoOption={diff:null},this.audioInfo={encType:"",channels:"",sampleRate:""},this.init=!1,this.hasAudio=!1,this.audioResumeStateTimeout=null,this.on(U.videoSyncAudio,e=>{this.audioSyncVideoOption=e})}destroy(){this.closeAudio(),this.resetInit(),this.audioContext.close(),this.audioContext=null,this.gainNode=null,this.hasAudio=!1,this.playing=!1,this.scriptNode&&(this.scriptNode.onaudioprocess=Ve,this.scriptNode=null),this.workletProcessorNode&&(this.workletProcessorNode.port.onmessage=Ve,this.workletProcessorNode=null),this.audioResumeStateTimeout&&(clearTimeout(this.audioResumeStateTimeout),this.audioResumeStateTimeout=null),this.audioBufferSourceNode=null,this.mediaStreamAudioDestinationNode=null,this.hasInitScriptNode=!1,this.audioSyncVideoOption={diff:null},this.off()}resetInit(){this.audioInfo={encType:"",channels:"",sampleRate:""},this.init=!1}getAudioInfo(){return this.audioInfo}updateAudioInfo(e){e.encTypeCode&&(this.audioInfo.encType=$[e.encTypeCode]),e.channels&&(this.audioInfo.channels=e.channels),e.sampleRate&&(this.audioInfo.sampleRate=e.sampleRate),this.audioInfo.sampleRate&&this.audioInfo.channels&&this.audioInfo.encType&&!this.init&&(this.player.emit(U.audioInfo,this.audioInfo),this.init=!0)}get isPlaying(){return this.playing}get isMute(){return 0===this.gainNode.gain.value}get volume(){return this.gainNode.gain.value}get bufferSize(){return this.bufferList.length}initScriptNode(){}initMobileScriptNode(){}initWorkletScriptNode(){}getEngineType(){return""}mute(e){e?(this.isMute||this.player.emit(U.mute,e),this.setVolume(0),this.clear()):(this.isMute&&this.player.emit(U.mute,e),this.setVolume(this.player.lastVolume||.5))}setVolume(e){e=parseFloat(e).toFixed(2),isNaN(e)||(this.audioEnabled(!0),e=Je(e,0,1),this.gainNode.gain.value=e,this.player.emit(U.volumechange,this.player.volume))}closeAudio(){this.hasInitScriptNode&&(this.scriptNode&&this.scriptNode.disconnect(this.gainNode),this.workletProcessorNode&&this.workletProcessorNode.disconnect(this.gainNode),this.gainNode&&(this.gainNode.disconnect(this.mediaStreamAudioDestinationNode),this.$audio||this.gainNode.disconnect(this.audioContext.destination))),this.clear()}audioEnabled(e){e?this.isStateSuspended()&&(this.audioContext.resume().then(()=>{this.player.emit(U.audioResumeState,{state:this.audioContext.state,isRunning:this.isStateRunning()})}),this.audioResumeStateTimeout=setTimeout(()=>{clearTimeout(this.audioResumeStateTimeout),this.audioResumeStateTimeout=null,this.isStateSuspended()&&this.player.emit(U.audioResumeState,{state:this.audioContext.state,isRunning:this.isStateRunning()})},1e3)):this.isStateRunning()&&this.audioContext.suspend()}isStateRunning(){return"running"===this.audioContext.state}isStateSuspended(){return"suspended"===this.audioContext.state}clear(){this.bufferList=[]}play(e,t){}pause(){this.audioSyncVideoOption={diff:null},this.playing=!1}resume(){this.playing=!0}setRate(e){}getAudioBufferSize(){return 0}}class Ai{constructor(e,t,i,r){this.player=e,this.audio=t,this.channel=i,this.bufferSize=r}extract(e,t){var i=this.provide(t);for(let r=0;r<i.size;r++)e[2*r]=i.left[r],e[2*r+1]=i.right[r];return this.audio.tempAudioTimestamp=i.ts,i.size}provide(e){let t=new Float32Array(e),i=new Float32Array(e),r=0,s=0,a=0,n=e/this.bufferSize;const o=this.audio.bufferList;if(o.length>n){try{for(let e=0;e<n;e++){const e=o.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,s=e.ts}}catch(e){this.player.debug.warn("Processor","provide()",e),t=new Float32Array(0),i=new Float32Array(0)}r=t.length}return{size:r,ts:s,left:t,right:i}}destroy(){this.buffer=null,this.channel=null}}class bi{constructor(){this._vector=new Float32Array,this._position=0,this._frameCount=0}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=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;t=2*(t=t||0);var r=2*(i=0<=i?i:(e.length-t)/2),s=(this.ensureCapacity(i+this._frameCount),this.endIndex);this.vector.set(e.subarray(t,t+r),s),this._frameCount+=i}putBuffer(e,t){let i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;t=t||0,0<=i||(i=e.frameCount-t),this.putSamples(e.vector,e.position+t,i)}receive(e){0<=e&&!(e>this._frameCount)||(e=this.frameCount),this._frameCount-=e,this._position+=e}receiveSamples(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,i=this.startIndex;e.set(this._vector.subarray(i,i+2*t)),this.receive(t)}extract(e){var t=this.startIndex+2*(1<arguments.length&&void 0!==arguments[1]?arguments[1]:0);e.set(this._vector.subarray(t,t+2*(2<arguments.length&&void 0!==arguments[2]?arguments[2]:0)))}ensureCapacity(){var e=parseInt(2*(0<arguments.length&&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(){this.ensureCapacity(this._frameCount+(0<arguments.length&&void 0!==arguments[0]?arguments[0]:0))}rewind(){0<this._position&&(this._vector.set(this._vector.subarray(this.startIndex,this.endIndex)),this._position=0)}}class vi{constructor(e){e?(this._inputBuffer=new bi,this._outputBuffer=new bi):this._inputBuffer=this._outputBuffer=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 _i extends vi{constructor(e){super(e),this.reset(),this._rate=1}set rate(e){this._rate=e}reset(){this.slopeCount=0,this.prevSampleL=0,this.prevSampleR=0}clone(){const e=new _i;return e.rate=this._rate,e}process(){var e=this._inputBuffer.frameCount;this._outputBuffer.ensureAdditionalCapacity(e/this._rate+1),e=this.transpose(e);this._inputBuffer.receive(),this._outputBuffer.put(e)}transpose(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;if(0===e)return 0;const t=this._inputBuffer.vector,i=this._inputBuffer.startIndex,r=this._outputBuffer.vector,s=this._outputBuffer.endIndex;let a=0,n=0;for(;this.slopeCount<1;)r[s+2*n]=(1-this.slopeCount)*this.prevSampleL+this.slopeCount*t[i],r[s+2*n+1]=(1-this.slopeCount)*this.prevSampleR+this.slopeCount*t[i+1],n+=1,this.slopeCount+=this._rate;if(--this.slopeCount,1!==e)e:for(;;){for(;1<this.slopeCount;)if(--this.slopeCount,(a+=1)>=e-1)break e;var o=i+2*a;r[s+2*n]=(1-this.slopeCount)*t[o]+this.slopeCount*t[o+2],r[s+2*n+1]=(1-this.slopeCount)*t[o+1]+this.slopeCount*t[o+3],n+=1,this.slopeCount+=this._rate}return this.prevSampleL=t[i+2*e-2],this.prevSampleR=t[i+2*e-1],n}}function wi(){}class Si extends class{constructor(e){this._pipe=e}get pipe(){return this._pipe}get inputBuffer(){return this._pipe.inputBuffer}get outputBuffer(){return this._pipe.outputBuffer}fillInputBuffer(){throw new Error("fillInputBuffer() not overridden")}fillOutputBuffer(){let e=0<arguments.length&&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()}}{constructor(e,t){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:wi;super(t),this.callback=i,this.sourceSound=e,this.historyBufferSize=22050,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");var t=this.outputBufferPosition-(this._position-e);if(t<0)throw new RangeError("New position falls outside of history buffer");this.outputBufferPosition=t,this._position=e}get sourcePosition(){return this._sourcePosition}set sourcePosition(e){this.clear(),this._sourcePosition=e}onEnd(){this.callback()}fillInputBuffer(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,t=new Float32Array(2*e);e=this.sourceSound.extract(t,e,this._sourcePosition);this._sourcePosition+=e,this.inputBuffer.putSamples(t,0,e)}extract(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;this.fillOutputBuffer(this.outputBufferPosition+t),t=Math.min(t,this.outputBuffer.frameCount-this.outputBufferPosition),this.outputBuffer.extract(e,this.outputBufferPosition,t),e=this.outputBufferPosition+t;return this.outputBufferPosition=Math.min(this.historyBufferSize,e),this.outputBuffer.receive(Math.max(e-this.historyBufferSize,0)),this._position+=t,t}handleSampleData(e){this.extract(e.data,4096)}clear(){super.clear(),this.outputBufferPosition=0}}const Ei=[[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]];class Ti extends vi{constructor(e){super(e),this._quickSeek=!0,this.midBufferDirty=!1,this.midBuffer=null,this.overlapLength=0,this.autoSeqSetting=!0,this.autoSeekSetting=!0,this._tempo=1,this.setParameters(44100,0,0,8)}clear(){super.clear(),this.clearMidBuffer()}clearMidBuffer(){this.midBufferDirty&&(this.midBufferDirty=!1,this.midBuffer=null)}setParameters(e,t,i,r){0<e&&(this.sampleRate=e),0<r&&(this.overlapMs=r),0<t?(this.sequenceMs=t,this.autoSeqSetting=!1):this.autoSeqSetting=!0,0<i?(this.seekWindowMs=i,this.autoSeekSetting=!1):this.autoSeekSetting=!0,this.calculateSequenceParameters(),this.calculateOverlapLength(this.overlapMs),this.tempo=this._tempo}set tempo(e){this._tempo=e,this.calculateSequenceParameters(),this.nominalSkip=this._tempo*(this.seekWindowLength-this.overlapLength),this.skipFract=0,e=Math.floor(this.nominalSkip+.5),this.sampleReq=Math.max(e+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=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;e=(e=this.sampleRate*t/1e3)<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:i<e?i:e}calculateSequenceParameters(){var e;this.autoSeqSetting&&(e=150+-50*this._tempo,e=this.checkLimits(e,50,125),this.sequenceMs=Math.floor(e+.5)),this.autoSeekSetting&&(e=28.333333333333332+-10/1.5*this._tempo,e=this.checkLimits(e,15,25),this.seekWindowMs=Math.floor(e+.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 Ti;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,r=0;for(this.preCalculateCorrelationReferenceStereo(),e=0,t=Number.MIN_VALUE;r<this.seekLength;r+=1)(i=this.calculateCrossCorrelationStereo(2*r,this.refMidBuffer))>t&&(t=i,e=r);return e}seekBestOverlapPositionStereoQuick(){let e,t,i,r,s,a=0;for(this.preCalculateCorrelationReferenceStereo(),t=Number.MIN_VALUE,e=0,r=0,s=0;a<4;a+=1){let n=0;for(;Ei[a][n]&&!((s=r+Ei[a][n])>=this.seekLength);)(i=this.calculateCrossCorrelationStereo(2*s,this.refMidBuffer))>t&&(t=i,e=s),n+=1;r=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[1+e]=this.midBuffer[1+e]*t}calculateCrossCorrelationStereo(e,t){var i=this._inputBuffer.vector;e+=this._inputBuffer.startIndex;let r=0,s=2;for(var a,n=2*this.overlapLength;s<n;s+=2)a=s+e,r+=i[a]*t[s]+i[a+1]*t[s+1];return r}overlap(e){this.overlapStereo(2*e)}overlapStereo(e){var t=this._inputBuffer.vector;e+=this._inputBuffer.startIndex;const i=this._outputBuffer.vector,r=this._outputBuffer.endIndex;let s,a,n=0;for(var o,l,d,h=1/this.overlapLength;n<this.overlapLength;n+=1)a=(this.overlapLength-n)*h,o=n*h,l=(s=2*n)+e,d=s+r,i[d+0]=t[l+0]*o+this.midBuffer[0+s]*a,i[d+1]=t[l+1]*o+this.midBuffer[1+s]*a}process(){var e;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),0<(t=this.seekWindowLength-2*this.overlapLength)&&this._outputBuffer.putBuffer(this._inputBuffer,e+this.overlapLength,t);var t=this._inputBuffer.startIndex+2*(e+this.seekWindowLength-this.overlapLength);this.midBuffer.set(this._inputBuffer.vector.subarray(t,t+2*this.overlapLength)),this.skipFract+=this.nominalSkip,e=Math.floor(this.skipFract),this.skipFract-=e,this._inputBuffer.receive(e)}}}function ki(e,t){return 1e-10<(t<e?e-t:t-e)}class xi{constructor(){this.transposer=new _i(!1),this.stretch=new Ti(!1),this._inputBuffer=new bi,this._intermediateBuffer=new bi,this._outputBuffer=new bi,this._rate=0,this._tempo=0,this.virtualPitch=1,this.virtualRate=1,this.virtualTempo=1,this.calculateEffectiveRateAndTempo()}clear(){this.transposer.clear(),this.stretch.clear()}clone(){const e=new xi;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(){var e=this._tempo,t=this._rate;this._tempo=this.virtualTempo/this.virtualPitch,this._rate=this.virtualRate*this.virtualPitch,ki(this._tempo,e)&&(this.stretch.tempo=this._tempo),ki(this._rate,t)&&(this.transposer.rate=this._rate),1<this._rate?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(){1<this._rate?(this.stretch.process(),this.transposer.process()):(this.transposer.process(),this.stretch.process())}}class Ci{constructor(e,t,i){this.player=e,this.audio=t,this.soundTouch=new xi,this.soundTouch.tempo=1,this.soundTouch.rate=1,this.filter=new Si(i,this.soundTouch)}setRate(e){e!==this.soundTouch.rate&&(this.soundTouch.tempo=e)}provide(e){let t=new Float32Array(2*e),i=this.filter.extract(t,e),r=new Float32Array(i),s=new Float32Array(i);for(let a=0;a<i;a++)r[a]=t[2*a],s[a]=t[2*a+1];return{size:i,left:r,right:s,ts:this.audio.tempAudioTimestamp||0}}destroy(){this.soundTouch&&(this.soundTouch.clear(),this.soundTouch=null),this.filter&&(this.filter=null)}}class Li extends yi{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.clearWorkletUrlTimeout=null,this.player._opt.supportLockScreenPlayAudio&&nt()&&(this.$audio=document.createElement("audio"),Object.assign(this.$audio.style,{position:"absolute",left:"-100%",top:"-100%"}),(e.$container||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)}destroy(){super.destroy(),this.clearWorkletUrlTimeout&&(clearTimeout(this.clearWorkletUrlTimeout),this.clearWorkletUrlTimeout=null),this.eventListenList&&(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=ke,this.player.debug.log("AudioContext","destroy")}isAudioPlaying(){return this.$audio&&$t(this.$audio.paused)&&$t(this.$audio.ended)&&0!==this.$audio.playbackRate&&0!==this.$audio.readyState}_bindAudioProxy(){const e=this.player.events["proxy"],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?this.$audio.readyState:e}audioElementPlay(){if(this.$audio){var e=this._getAudioElementReadyState();if(this.player.debug.log("AudioContext","play and readyState: "+e),!(0!==e||Rt()&&nt()))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===xe}initProcessor(){this.processor=new Ai(this.player,this,this.audioInfo.channels,this.audioBufferSize),this.rateProcessor=new Ci(this.player,this,this.processor)}getAutoAudioEngineType(){let e=this.player._opt.audioEngine||ke;var t=()=>{e=Rt()&&st()?xe:nt()&&this.player._opt.supportLockScreenPlayAudio||!Nt()?ke:Te};return this.player._opt.audioEngine?this.player._opt.audioEngine===Te&&Nt()?e=Te:this.player._opt.audioEngine===xe?e=xe:this.player._opt.audioEngine===ke?e=ke:t():t(),e}getAudioBufferSizeByType(){var e=this.engineType,t=(this.player._opt.hasVideo,this.player._opt.weiXinInAndroidAudioBufferSize);return e!==Te&&e===xe?t||4800:1024}initScriptNode(){this.playing=!0,this.hasInitScriptNode||(this.initProcessor(),this.engineType===Te?this.initWorkletScriptNode():this.engineType===xe?this.initIntervalScriptNode():this.engineType===ke&&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=>{e=e.outputBuffer,this.handleScriptNodeCallback(e)},e.connect(this.gainNode),this.scriptNode=e,this.gainNode.connect(this.mediaStreamAudioDestinationNode),this.$audio?this.$audio.srcObject=this.mediaStreamAudioDestinationNode.stream:this.gainNode.connect(this.audioContext.destination),this.hasInitScriptNode=!0}initIntervalScriptNode(){this.scriptStartTime=0;var e=1e3*this.audioBufferSize/this.audioContext.sampleRate;this.scriptNodeInterval=setInterval(()=>{const e=this.audioContext.createBufferSource(),t=this.audioContext.createBuffer(this.audioInfo.channels,this.audioBufferSize,this.audioContext.sampleRate);this.handleScriptNodeCallback(t,()=>{this.scriptStartTime<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(){const e=Mt((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 r=t[0][0],s=t[0][1];if(0===this.offset&&this.port.postMessage({message:"beep"}),0===this.state)this.state=1;else if(1===this.state&&4<=this.samplesArray.length)this.state=2;else if(2===this.state){const e=this.samplesArray[0];for(let t=0;t<r.length;t++)1===this.channels?r[t]=e.left[t+this.offset]:2===this.channels&&(r[t]=e.left[t+this.offset],s&&(s[t]=e.right[t+this.offset]))}else 1===this.channels?r.fill(0):2===this.channels&&(r.fill(0),s&&s.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.audioContext&&this.audioContext.audioWorklet.addModule(e).then(()=>{if(this.audioContext){let t=[1];2===this.audioInfo.channels&&(t=[1,1]);try{this.workletProcessorNode=new AudioWorkletNode(this.audioContext,"worklet-processor",{numberOfOutputs:this.audioInfo.channels,outputChannelCount:t})}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")})}else this.player.debug.error("AudioContext","initWorkletScriptNode audioContext is null")}),this.clearWorkletUrlTimeout=setTimeout(()=>{URL.revokeObjectURL(e),this.clearWorkletUrlTimeout=null},E)}tierDownToProcessScript(){this.player.debug.log("AudioContext","tierDownToProcessScript"),this.engineType=ke,this.audioBufferSize=this.getAudioBufferSizeByType(),this.initProcessScriptNode(),this.audioElementPlay()}handleScriptNodeCallback(e,t){let i,r=2<arguments.length&&void 0!==arguments[2]&&arguments[2],s=(t=t||Ve,e.length);r&&(i=e,s=this.audioBufferSize);var a,n=this.audioInfo.channels;if(this.bufferList.length&&this.playing)return(a=this.player._opt).syncAudioAndVideo&&a.hasVideo&&(this.calcPlaybackRateBySync(),1e3<this.audioSyncVideoOption.diff)?(this.player.debug.warn("AudioContext",`audioSyncVideoOption more than diff :${this.audioSyncVideoOption.diff}, waiting`),r?i.port.postMessage({message:"zero"}):this.fillScriptNodeOutputBuffer(e,n)):0===(a=this._provide(s)).size?r?i.port.postMessage({message:"zero"}):this.fillScriptNodeOutputBuffer(e,n):(a&&a.ts&&(this.player.audioTimestamp=a.ts),r?i.port.postMessage({message:"data",buffer:a}):this.fillScriptNodeOutputBuffer(e,n,a)),void t();r?i.port.postMessage({message:"zero"}):this.fillScriptNodeOutputBuffer(e,n),t()}fillScriptNodeOutputBuffer(e,t,i){if(1===t){const t=e.getChannelData(0);i&&0!==i.size?t.set(i.left):t.fill(0)}else if(2===t){const t=e.getChannelData(0),r=e.getChannelData(1);i&&0!==i.size?(t.set(i.left),r.set(i.right)):(t.fill(0),r.fill(0))}}play(e,t){this.isMute||(this.hasInitScriptNode?(this.hasAudio=!0,this.bufferList.push({buffer:e,ts:t}),this.player._opt.syncAudioAndVideo||this.calcPlaybackRateByBuffer()):this.player.debug.warn("AudioContext","play has not init script node"))}calcPlaybackRateBySync(){if(!this.isMute&&this.playing){let e=this.playbackRate;this.audioSyncVideoOption.diff<-1e3?(e=this.defaultPlaybackRate+.1,this.player.debug.warn("AudioContext",`audioSyncVideoOption -1000 less than diff :${this.audioSyncVideoOption.diff}, speed up, playbackRate is `+e)):-500<this.audioSyncVideoOption.diff&&(e=this.defaultPlaybackRate),this.updatePlaybackRate(e)}}calcPlaybackRateByBuffer(){if(!this.isMute&&this.playing&&this.getEngineType()!==xe){let i=this.playbackRate;var e=Math.floor(1e3/this.oneBufferDuration),t=Math.floor(5e3/this.oneBufferDuration);if(this.bufferList.length>t)return this.player.debug.warn("AudioContext",`bufferList length ${this.bufferList.length} more than ${t}, and drop`),void this.clear();this.bufferList.length>e?(i=this.defaultPlaybackRate+.1,this.player.debug.warn("AudioContext",`bufferList length ${this.bufferList.length} more than ${e}, speed up, playbackRate is `+i)):this.bufferList.length<e/2&&(i=this.defaultPlaybackRate),this.updatePlaybackRate(i)}}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 Di extends r{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.audioInfo={encType:"",channels:"",sampleRate:""},this.player.debug.log("Audio","init")}destroy(){this.resetInit(),this.off(),this.player.debug.log("Audio","destroy")}resetInit(){this.init=!1,this.audioInfo={encType:"",channels:"",sampleRate:""}}getAudioInfo(){return this.audioInfo}updateAudioInfo(e){_t(e.encTypeCode)&&(this.audioInfo.encType=$[e.encTypeCode]),_t(e.encType)&&(this.audioInfo.encType=e.encType),_t(e.channels)&&(this.audioInfo.channels=e.channels),_t(e.sampleRate)&&(this.audioInfo.sampleRate=e.sampleRate),_t(this.audioInfo.sampleRate)&&_t(this.audioInfo.channels)&&_t(this.audioInfo.encType)&&!this.init&&(this.player.emit(U.audioInfo,this.audioInfo),this.init=!0)}get isPlaying(){return!0}get volume(){return Kt(this.$video.muted)?0:this.$video.volume}get isMute(){return 0===this.$video.volume||Kt(this.$video.muted)}mute(e){this.setVolume(e?0:this.player.lastVolume||.5)}setVolume(e){e=parseFloat(e),isNaN(e)||(e=Je(e,0,1),this.$video.muted&&(this.$video.muted=!1),this.$video.volume=e,this.player.emit(U.volumechange,this.player.volume))}clear(){}play(){}pause(){}resume(){}getEngineType(){return"audio"}isPlaybackRateSpeed(){return!1}getAudioBufferSize(){return 0}}class Ri extends Li{constructor(e){super(e),this.delayTimeout=null,this.player.on(U.playbackPause,e=>{this.listenPlaybackPause(e)}),this.player.debug.log("AudioPlaybackContext","init")}destroy(){this.delayTimeout&&(clearTimeout(this.delayTimeout),this.delayTimeout=null),super.destroy(),this.player.debug.log("AudioPlaybackLoader","destroy")}listenPlaybackPause(e){e?(this.pause(),this.player.playback.isPlaybackPauseClearCache&&this.clear()):this.resume()}initScriptNodeDelay(){var e=this.player._opt.playbackDelayTime;0<e?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 Ii extends Li{constructor(e){super(e),this.TAG_NAME="AudioPlayerLoader",this.player.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this.player.debug.log(this.TAG_NAME,"destroy")}play(e,t){$t(this.playing)||super.play(e,t)}pause(){this.player.debug.log(this.TAG_NAME,"pause"),this.playing=!1,this.clear()}resume(){this.player.debug.log(this.TAG_NAME,"resume"),this.playing=!0}}class Pi{constructor(e){return new(Pi.getLoaderFactory(e._opt))(e)}static getLoaderFactory(e){return e.playType===d?Ri:e.playType===l?Ii:e.isHls&&$t(e.supportHls265)||e.isWebrtc&&$t(e.isWebrtcH265)?Di:Li}}class Bi extends r{constructor(e){super(),this.TAG_NAME="FetchWorkerLoader",this.player=e,this.playing=!1,this.fetchWorker=null,this.workerClearTimeout=null,this.abortController=new AbortController,this.streamRate=et(t=>{e.emit(U.kBps,(t/1024).toFixed(2))}),this.streamRateInterval=null,this._initFetchWorker(),e.debug.log(this.TAG_NAME,"init")}destroy(){this.off(),this.workerClearTimeout&&(clearTimeout(this.workerClearTimeout),this.workerClearTimeout=null),this.fetchWorker&&(this.fetchWorker.postMessage({cmd:"destroy"}),this.fetchWorker.terminate(),this.fetchWorker=null),this._stopStreamRateInterval(),this.streamRate=null,this.player.debug.log(this.TAG_NAME,"destroy")}_initFetchWorker(){var e=function(){const e="The user aborted a request",t="AbortError",i="AbortError",r="fetchError",s="fetchClose",a="fetchSuccess";let n=new class{constructor(){this.abortController=new AbortController}destroy(){this.abort()}fetchStream(n){var o=Object.assign({signal:this.abortController.signal},{headers:(1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}).headers||{}});fetch(n,o).then(n=>{if(!(n.ok&&200<=n.status&&n.status<=299))return this.abort(),void postMessage({cmd:r,message:`fetch response status is ${n.status} and ok is `+n.ok});if(postMessage({cmd:a}),"undefined"!=typeof WritableStream)n.body.pipeTo(new WritableStream({write:e=>{this.streamRate&&this.streamRate(e.byteLength),postMessage({cmd:"buffer",buffer:e},[e.buffer])},close:()=>{postMessage({cmd:s})},abort:s=>{const a=s.toString();-1===a.indexOf(e)&&-1===a.indexOf(t)&&s.name!==i&&(this.abort(),postMessage({cmd:r,message:s.toString()}))}}));else{const a=n.body.getReader(),o=()=>{a.read().then(e=>{var{done:e,value:t}=e;e?postMessage({cmd:s}):(postMessage({cmd:"buffer",buffer:t},[t.buffer]),o())}).catch(s=>{const a=s.toString();-1===a.indexOf(e)&&-1===a.indexOf(t)&&s.name!==i&&(this.abort(),postMessage({cmd:r,message:s.toString()}))})};o()}}).catch(e=>{"AbortError"!==e.name&&(this.abort(),postMessage({cmd:r,message:e.toString()}))})}abort(){this.abortController&&(this.abortController.abort(),this.abortController=null)}};self.onmessage=e=>{var t=e.data;switch(t.cmd){case"fetch":n.fetchStream(t.url,JSON.parse(t.options));break;case"destroy":n.destroy(),n=null}}}.toString().trim().match(/^function\s*\w*\s*\([\w\s,]*\)\s*{([\w\W]*?)}$/)[1];const t=new Blob([e],{type:"text/javascript"}),i=URL.createObjectURL(t),r=new Worker(i);this.workerClearTimeout=setTimeout(()=>{window.URL.revokeObjectURL(i),this.workerClearTimeout=null},E),r.onmessage=e=>{const t=this.player["demux"],i=e.data;switch(i.cmd){case"buffer":this.streamRate&&this.streamRate(i.buffer.byteLength),t.dispatch(i.buffer);break;case"fetchSuccess":this.emit(U.streamSuccess),this._startStreamRateInterval();break;case"fetchClose":t.close(),this.emit(U.streamEnd);break;case"fetchError":t.close(),this.emit(O.fetchError,i.message)}},this.fetchWorker=r}_startStreamRateInterval(){this._stopStreamRateInterval(),this.streamRateInterval=setInterval(()=>{this.streamRate&&this.streamRate(0)},1e3)}_stopStreamRateInterval(){this.streamRateInterval&&(clearInterval(this.streamRateInterval),this.streamRateInterval=null)}fetchStream(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};this.player._times.streamStart=qe(),this.fetchWorker.postMessage({cmd:"fetch",url:e,options:JSON.stringify(t)})}getStreamType(){return s}}class Ui extends r{constructor(e){super(),this.player=e,this.socket=null,this.socketStatus=N,this.wsUrl=null,this.socketDestroyFnList=[],this.streamRate=et(t=>{e.emit(U.kBps,(t/1024).toFixed(2))}),this.streamRateInterval=null,e.debug.log("WebsocketStream","init")}destroy(){this._closeWebSocket(),this.stopStreamRateInterval(),this.wsUrl=null,this.off(),this.player.debug.log("WebsocketStream","destroy")}startStreamRateInterval(){this.stopStreamRateInterval(),this.streamRateInterval=setInterval(()=>{this.streamRate&&this.streamRate(0)},1e3)}stopStreamRateInterval(){this.streamRateInterval&&(clearInterval(this.streamRateInterval),this.streamRateInterval=null)}_createWebSocket(){const e=this.player,{debug:t,events:{proxy:i},demux:r}=e;this.socket=new WebSocket(this.wsUrl),this.socket.binaryType="arraybuffer";var s=i(this.socket,"open",()=>{t.log("WebsocketStream","socket open"),this.socketStatus=j,this.emit(U.streamSuccess),this.player.emit(U.websocketOpen),this.startStreamRateInterval()}),a=i(this.socket,"message",e=>{this.streamRate&&this.streamRate(e.data.byteLength),this._handleMessage(e.data)}),n=i(this.socket,"close",e=>{t.log("WebsocketStream","socket close and code is "+e.code),1006===e.code&&t.error("WebsocketStream","socket close abnormally and code is "+e.code),r.close(),this.socketStatus="close",this.player.emit(U.websocketClose),this.emit(U.streamEnd)}),o=i(this.socket,"error",e=>{t.error("WebsocketStream","socket error",e),this.socketStatus="error",this.emit(O.websocketError,e),r.close(),t.log("WebsocketStream","socket error:",e.isTrusted?"websocket user aborted":"websocket error")});this.socketDestroyFnList.push(s,a,n,o)}_closeWebSocket(){this.socketDestroyFnList.forEach(e=>e()),this.socket&&(this.socket.close(1e3,"Client disconnecting"),this.socket=null),this.socketStatus=N,this.streamRate=null}_handleMessage(e){const t=this.player["demux"];t?t.dispatch(e):this.player.debug.warn("WebsocketStream","websocket handle message demux is null")}fetchStream(e,t){this.player._times.streamStart=qe(),this.wsUrl=e,this._createWebSocket()}sendMessage(e){this.socket?this.socketStatus===j?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 a}}class Fi extends r{constructor(e){super(),(this.player=e).debug.log("HlsStream","init")}destroy(){this.off(),this.player.debug.log("HlsStream","destroy")}fetchStream(e){const t=this.player["hlsDecoder"];this.player._times.streamStart=qe(),t.loadSource(e).then(()=>{this.player.debug.log("HlsStream","loadSource success"),this.emit(U.streamSuccess)}).catch(e=>{this.emit(O.hlsError,e)})}getStreamType(){return"hls"}}class Mi extends r{constructor(e){super(),this.player=e,this.webrctUrl=null,e.debug.log("WebrtcStream","init")}destroy(){this.webrctUrl=null,this.off(),this.player.debug.log("WebrtcStream","destroy")}fetchStream(e){const t=this.player["webrtc"];this.player._times.streamStart=qe(),this.webrctUrl=e.replace("webrtc:",window.location.protocol),t.loadSource(this.webrctUrl).then(()=>{this.player.debug.log("WebrtcStream","loadSource success"),this.emit(U.streamSuccess)}).catch(e=>{this.emit(O.webrtcError,e)})}getStreamType(){return"webrtc"}}class Oi extends r{constructor(e){super(),this.player=e,this.transport=null,this.wtUrl=null,this.streamRate=et(t=>{e.emit(U.kBps,(t/1024).toFixed(2))}),this.streamRateInterval=null,e.debug.log("WebTransportLoader","init")}destroy(){this.abort(),this.off(),this.player.debug.log("WebTransportLoader","destroy")}startStreamRateInterval(){this.stopStreamRateInterval(),this.streamRateInterval=setInterval(()=>{this.streamRate&&this.streamRate(0)},1e3)}stopStreamRateInterval(){this.streamRateInterval&&(clearInterval(this.streamRateInterval),this.streamRateInterval=null)}_createWebTransport(){const e=this.player,{events:{},demux:t}=e;try{this.transport=new WebTransport(this.wtUrl),this.transport.ready.then(()=>{this.emit(U.streamSuccess),this.startStreamRateInterval(),this.transport.createBidirectionalStream().then(e=>{e.readable.pipeTo(new WritableStream(t.input))})}).catch(e=>{this.player.debug.warn("WebTransportLoader","_createWebTransport-ready",e)})}catch(e){this.player.debug.warn("WebTransportLoader","_createWebTransport",e)}}fetchStream(e){this.player._times.streamStart=qe(),this.wtUrl=e.replace(/^wt/,"https"),this._createWebTransport()}abort(){if(this.transport)try{this.transport.close(),this.transport=null}catch(r){this.transport=null}}getStreamType(){return"webTransport"}}class Ni extends r{constructor(e){super(),this.player=e,this.workUrl=null,e.debug.log("WorkerStream","init")}destroy(){this.workUrl=null,this.off(),this.player.debug.log("WorkerStream","destroy")}sendMessage(e){this.player.decoderWorker.workerSendMessage(e)}fetchStream(e){this.workUrl=e,this.player._times.streamStart=qe(),this.player.decoderWorker.workerFetchStream(e)}getStreamType(){var e=this.player._opt.protocol;return n+" "+(2===e?s:a)}}class ji{constructor(e){return new(ji.getLoaderFactory(e._opt))(e)}static getLoaderFactory(e){var{protocol:t,useWasm:i,playType:r,playbackConfig:s}=e;return 2===t?r===l?Ni:r===o?i&&!Ft(e)?Ni:Bi:s.useWCS?Bi:Ni:1===t?r===l?Ni:r===o?i&&!Ft(e)?Ni:Ui:s.useWCS?Ui:Ni:3===t?Fi:4===t?Mi:5===t?Oi:void 0}}var zi=Ne((function(e){function t(e,i){if(!e)throw"First parameter is required.";i=new r(e,i=i||{type:"video"});var a=this;function n(t){t&&(i.initCallback=function(){t(),t=i.initCallback=null});var r=new s(e,i);(p=new r(e,i)).record(),u("recording"),i.disableLogs||console.log("Initialized recorderType:",p.constructor.name,"for output-type:",i.type)}function o(e){if(e=e||function(){},p){if("paused"===a.state)return a.resumeRecording(),void setTimeout((function(){o(e)}),1);"recording"===a.state||i.disableLogs||console.warn('Recording state should be: "recording", however current state is: ',a.state),i.disableLogs||console.log("Stopped recording "+i.type+" stream."),"gif"!==i.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 r,s=p.blob;if(!s){if(!t)throw"Recording failed.";p.blob=s=t}if(s&&!i.disableLogs&&console.log(s.type,"->",g(s.size)),e){try{r=d.createObjectURL(s)}catch(t){}"function"==typeof e.call?e.call(a,r):e(r)}i.autoWriteToDisk&&h((function(e){var t={};t[i.type+"Blob"]=e,D.Store(t)}))}else"function"==typeof e.call?e.call(a,""):e("")}}function l(e){postMessage((new FileReaderSync).readAsDataURL(e))}function h(e,t){if(!e)throw"Pass a callback function over getDataURL.";var r,s=(t||p||{}).blob;if(!s)return i.disableLogs||console.warn("Blob encoder did not finish its job yet."),void setTimeout((function(){h(e,t)}),1e3);"undefined"==typeof Worker||navigator.mozGetUserMedia?((r=new FileReader).readAsDataURL(s),r.onload=function(t){e(t.target.result)}):((r=function(e){try{var t=d.createObjectURL(new Blob([e.toString(),"this.onmessage = function (eee) {"+e.name+"(eee.data);}"],{type:"application/javascript"})),i=new Worker(t);return d.revokeObjectURL(t),i}catch(e){}}(l)).onmessage=function(t){e(t.data)},r.postMessage(s))}function c(e){e=e||0,"paused"!==a.state?"stopped"!==a.state&&(e>=a.recordingDuration?o(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 '+i.type+" recorder.";function m(){!0!==i.disableLogs&&console.warn(f)}var A,b={startRecording:function(t){return i.disableLogs||console.log("RecordRTC version: ",a.version),(i=t?new r(e,t):i).disableLogs||console.log("started recording "+i.type+" stream."),p?(p.clearRecordedData(),p.record(),u("recording"),a.recordingDuration&&c()):n((function(){a.recordingDuration&&c()})),a},stopRecording:o,pauseRecording:function(){p?"recording"===a.state?(u("paused"),p.pause(),i.disableLogs||console.log("Paused recording.")):i.disableLogs||console.warn("Unable to pause the recording. Recording state: ",a.state):m()},resumeRecording:function(){p?"paused"===a.state?(u("recording"),p.resume(),i.disableLogs||console.log("Resumed recording.")):i.disableLogs||console.warn("Unable to resume the recording. Recording state: ",a.state):m()},initRecorder:n,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(),i.disableLogs||console.log("Cleared old recorded data.")):m()},getBlob:function(){if(p)return p.blob;m()},getDataURL:h,toURL:function(){if(p)return d.createObjectURL(p.blob);m()},getInternalRecorder:function(){return p},save:function(e){p?y(p.blob,e):m()},getFromDisk:function(e){p?t.getFromDisk(i.type,e):m()},setAdvertisementArray:function(e){i.advertisement=[];for(var t=e.length,r=0;r<t;r++)i.advertisement.push({duration:r,image:e[r]})},blob:null,bufferSize:0,sampleRate:0,buffer:null,reset:function(){"recording"!==a.state||i.disableLogs||console.warn("Stop an active recorder."),p&&"function"==typeof p.clearRecordedData&&p.clearRecordedData(),p=null,u("inactive"),a.blob=null},onStateChanged:function(e){i.disableLogs||console.log("Recorder state changed:",e)},state:"inactive",getState:function(){return a.state},destroy:function(){var e=i.disableLogs;i={disableLogs:!0},a.reset(),u("destroyed"),b=a=null,_.AudioContextConstructor&&(_.AudioContextConstructor.close(),_.AudioContextConstructor=null),i.disableLogs=e,i.disableLogs||console.log("RecordRTC is destroyed.")},version:"5.6.2"};if(!this)return a=b;for(A in b)this[A]=b[A];return a=this,b}function r(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===k||t.recorderType===T||t.recorderType===B?t.type="video":t.recorderType===R?t.type="gif":t.recorderType===E?t.type="audio":t.recorderType===S&&(b(e,"audio").length&&b(e,"video").length||!b(e,"audio").length&&b(e,"video").length?t.type="video":b(e,"audio").length&&!b(e,"video").length&&(t.type="audio"))),"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(p||h||c)&&(i=E),"undefined"!=typeof MediaRecorder&&"requestData"in MediaRecorder.prototype&&!p&&(i=S),"video"===t.type&&(p||c)&&(i=k,"undefined"!=typeof ReadableStream&&(i=B)),"gif"===t.type&&(i=R),"canvas"===t.type&&(i=T),w()&&i!==T&&i!==R&&"undefined"!=typeof MediaRecorder&&"requestData"in MediaRecorder.prototype&&(b(e,"video").length||b(e,"audio").length)&&("audio"===t.type?"function"==typeof MediaRecorder.isTypeSupported&&MediaRecorder.isTypeSupported("audio/webm")&&(i=S):"function"==typeof MediaRecorder.isTypeSupported&&MediaRecorder.isTypeSupported("video/webm")&&(i=S)),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&&f?S:i}function a(e){this.addStream=function(t){t&&(e=t)},this.mediaType={audio:!0,video:!0},this.startRecording=function(){var i,r,s,a,n=this.mediaType,o=this.mimeType||{audio:null,video:null,gif:null};if("function"!=typeof n.audio&&w()&&!b(e,"audio").length&&(n.audio=!1),"function"!=typeof n.video&&w()&&!b(e,"video").length&&(n.video=!1),"function"!=typeof n.gif&&w()&&!b(e,"video").length&&(n.gif=!1),!n.audio&&!n.video&&!n.gif)throw"MediaStream must have either audio or video tracks.";n.audio&&(i=null,"function"==typeof n.audio&&(i=n.audio),this.audioRecorder=new t(e,{type:"audio",bufferSize:this.bufferSize,sampleRate:this.sampleRate,numberOfAudioChannels:this.numberOfAudioChannels||2,disableLogs:this.disableLogs,recorderType:i,mimeType:o.audio,timeSlice:this.timeSlice,onTimeStamp:this.onTimeStamp}),n.video||this.audioRecorder.startRecording()),n.video&&(i=null,"function"==typeof n.video&&(i=n.video),r=e,w()&&n.audio&&"function"==typeof n.audio&&(a=b(e,"video")[0],u?((r=new m).addTrack(a),i&&i===k&&(i=S)):(r=new m).addTrack(a)),this.videoRecorder=new t(r,{type:"video",video:this.video,canvas:this.canvas,frameInterval:this.frameInterval||10,disableLogs:this.disableLogs,recorderType:i,mimeType:o.video,timeSlice:this.timeSlice,onTimeStamp:this.onTimeStamp,workerPath:this.workerPath,webAssemblyPath:this.webAssemblyPath,frameRate:this.frameRate,bitrate:this.bitrate}),n.audio||this.videoRecorder.startRecording()),n.audio&&n.video&&(s=this,a=!0===w(),!0===(a=!(n.audio instanceof E&&n.video||!0!==n.audio&&!0!==n.video&&n.audio!==n.video)&&a)?(s.audioRecorder=null,s.videoRecorder.startRecording()):s.videoRecorder.initRecorder((function(){s.audioRecorder.initRecorder((function(){s.videoRecorder.startRecording(),s.audioRecorder.startRecording()}))}))),n.gif&&(i=null,"function"==typeof n.gif&&(i=n.gif),this.gifRecorder=new t(e,{type:"gif",frameRate:this.frameRate||200,quality:this.quality||10,disableLogs:this.disableLogs,recorderType:i,mimeType:o.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){var i;"undefined"!=typeof Worker?((i=function(e){e=d.createObjectURL(new Blob([e.toString(),"this.onmessage = function (eee) {"+e.name+"(eee.data);}"],{type:"application/javascript"}));var t,i=new Worker(e);if(void 0!==d)t=d;else{if("undefined"==typeof webkitURL)throw"Neither URL nor webkitURL detected.";t=webkitURL}return t.revokeObjectURL(e),i}((function(e){postMessage((new FileReaderSync).readAsDataURL(e))}))).onmessage=function(e){t(e.data)},i.postMessage(e)):((i=new FileReader).readAsDataURL(e),i.onload=function(e){t(e.target.result)})}this.getBlob((function(i){i.audio&&i.video?t(i.audio,(function(r){t(i.video,(function(t){e({audio:r,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).getFromDisk=function(e,t){if(!t)throw"callback is mandatory.";console.log("Getting recorded "+("all"===e?"blobs":e+" blob ")+" from disk!"),D.Fetch((function(i,r){"all"!==e&&r===e+"Blob"&&t&&t(i),"all"===e&&t&&t(i,r.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){D.Store({audioBlob:t,videoBlob:i,gifBlob:e})}))}))})):e.audio&&e.video?e.audio.getDataURL((function(t){e.video.getDataURL((function(e){D.Store({audioBlob:t,videoBlob:e})}))})):e.audio&&e.gif?e.audio.getDataURL((function(t){e.gif.getDataURL((function(e){D.Store({audioBlob:t,gifBlob:e})}))})):e.video&&e.gif?e.video.getDataURL((function(t){e.gif.getDataURL((function(e){D.Store({videoBlob:t,gifBlob:e})}))})):e.audio?e.audio.getDataURL((function(e){D.Store({audioBlob:e})})):e.video?e.video.getDataURL((function(e){D.Store({videoBlob:e})})):e.gif&&e.gif.getDataURL((function(e){D.Store({gifBlob:e})}))},a.getFromDisk=t.getFromDisk,a.writeToDisk=t.writeToDisk,t.MRecordRTC=a,(e=void 0!==Me?Me:null)&&"undefined"==typeof window&&void 0!==Me&&(Me.navigator={userAgent:"Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45",getUserMedia:function(){}},Me.console||(Me.console={}),void 0!==Me.console.log&&void 0!==Me.console.error||(Me.console.error=Me.console.log=Me.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=Me);var n,o=window.requestAnimationFrame,l=(void 0===o&&("undefined"!=typeof webkitRequestAnimationFrame?o=webkitRequestAnimationFrame:"undefined"!=typeof mozRequestAnimationFrame?o=mozRequestAnimationFrame:"undefined"!=typeof msRequestAnimationFrame?o=msRequestAnimationFrame:void 0===o&&(n=0,o=function(e,t){var i=(new Date).getTime(),r=Math.max(0,16-(i-n)),s=setTimeout((function(){e(i+r)}),r);return n=i+r,s})),window.cancelAnimationFrame),d=(e=(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)})),window.AudioContext),void 0===e&&("undefined"!=typeof webkitAudioContext&&(e=webkitAudioContext),"undefined"!=typeof mozAudioContext&&(e=mozAudioContext)),window.URL),h=(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)),!(-1===navigator.userAgent.indexOf("Edge")||!navigator.msSaveBlob&&!navigator.msSaveOrOpenBlob)),c=!!window.opera||-1!==navigator.userAgent.indexOf("OPR/"),u=-1<navigator.userAgent.toLowerCase().indexOf("firefox")&&"netscape"in window&&/ rv:/.test(navigator.userAgent),p=!c&&!h&&!!navigator.webkitGetUserMedia||A()||-1!==navigator.userAgent.toLowerCase().indexOf("chrome/"),f=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),m=(f&&!p&&-1!==navigator.userAgent.indexOf("CriOS")&&(p=!(f=!1)),window.MediaStream);function g(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 y(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],r=(-1!==i.indexOf(";")&&(i=i.split(";")[0]),t&&-1!==t.indexOf(".")&&(t=(r=t.split("."))[0],i=r[1]),(t||Math.round(9999999999*Math.random())+888888888)+"."+i);return void 0!==navigator.msSaveOrOpenBlob?navigator.msSaveOrOpenBlob(e,r):void 0!==navigator.msSaveBlob?navigator.msSaveBlob(e,r):(t=document.createElement("a"),t.href=d.createObjectURL(e),t.download=r,t.style="display:none;opacity:0;color:transparent;",(document.body||document.documentElement).appendChild(t),"function"==typeof t.click?t.click():(t.target="_blank",t.dispatchEvent(new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0}))),void d.revokeObjectURL(t.href))}function A(){return"undefined"!=typeof window&&"object"==typeof window.process&&"renderer"===window.process.type||!("undefined"==typeof i||"object"!=typeof i.versions||!i.versions.electron)||"object"==typeof navigator&&"string"==typeof navigator.userAgent&&0<=navigator.userAgent.indexOf("Electron")}function b(e,t){return e&&e.getTracks?e.getTracks().filter((function(e){return e.kind===(t||"audio")})):[]}function v(e,t){!("srcObject"in t)&&"mozSrcObject"in t?t.mozSrcObject=e:t.srcObject=e}void 0!==(m=void 0===m&&"undefined"!=typeof webkitMediaStream?webkitMediaStream:m)&&void 0===m.prototype.stop&&(m.prototype.stop=function(){this.getTracks().forEach((function(e){e.stop()}))}),t.invokeSaveAsDialog=y,t.getTracks=b,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,r=new EBML.Decoder,s=EBML.tools,a=new FileReader;a.onload=function(e){r.decode(this.result).forEach((function(e){i.read(e)})),i.stop();var a=s.makeMetadataSeekable(i.metadatas,i.duration,i.cues),n=this.result.slice(i.metadataSize);a=new Blob([a,n],{type:"video/webm"});t(a)},a.readAsArrayBuffer(e)},t.bytesToSize=g,t.isElectron=A;var _={};function w(){if(u||f||h)return!0;var e,t=navigator.userAgent,i=""+parseFloat(navigator.appVersion),r=parseInt(navigator.appVersion,10);return(p||c)&&(e=t.indexOf("Chrome"),i=t.substring(e+7)),-1!==(t=(i=-1!==(t=i.indexOf(";"))?i.substring(0,t):i).indexOf(" "))&&(i=i.substring(0,t)),r=parseInt(""+i,10),isNaN(r)&&(i=""+parseFloat(navigator.appVersion),r=parseInt(navigator.appVersion,10)),49<=r}function S(e,t){var i,r=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.";"audio"===(t=t||{mimeType:"video/webm"}).type&&(b(e,"video").length&&b(e,"audio").length&&(navigator.mozGetUserMedia?(i=new m).addTrack(b(e,"audio")[0]):i=new m(b(e,"audio")),e=i),t.mimeType&&-1!==t.mimeType.toString().toLowerCase().indexOf("audio")||(t.mimeType=p?"audio/webm":"audio/ogg"),t.mimeType&&"audio/ogg"!==t.mimeType.toString().toLowerCase()&&navigator.mozGetUserMedia&&(t.mimeType="audio/ogg"));var s,a=[];function n(){r.timestamps.push((new Date).getTime()),"function"==typeof t.onTimeStamp&&t.onTimeStamp(r.timestamps[r.timestamps.length-1],r.timestamps)}function o(e){return s&&s.mimeType?s.mimeType:e.mimeType||"video/webm"}function l(){a=[],s=null,r.timestamps=[]}this.getArrayOfBlobs=function(){return a},this.record=function(){r.blob=null,r.clearRecordedData(),r.timestamps=[],d=[],a=[];var l=t;t.disableLogs||console.log("Passing following config over MediaRecorder API.",l),s=s&&null,p&&!w()&&(l="video/vp8"),"function"==typeof MediaRecorder.isTypeSupported&&l.mimeType&&!MediaRecorder.isTypeSupported(l.mimeType)&&(t.disableLogs||console.warn("MediaRecorder API seems unable to record mimeType:",l.mimeType),l.mimeType="audio"===t.type?"audio/webm":"video/webm");try{s=new MediaRecorder(e,l),t.mimeType=l.mimeType}catch(i){s=new MediaRecorder(e)}l.mimeType&&!MediaRecorder.isTypeSupported&&"canRecordMimeType"in s&&!1===s.canRecordMimeType(l.mimeType)&&(t.disableLogs||console.warn("MediaRecorder API seems unable to record mimeType:",l.mimeType)),s.ondataavailable=function(e){e.data&&d.push("ondataavailable: "+g(e.data.size)),"number"!=typeof t.timeSlice?!e.data||!e.data.size||e.data.size<100||r.blob?r.recordingCallback&&(r.recordingCallback(new Blob([],{type:o(l)})),r.recordingCallback=null):(r.blob=t.getNativeBlob?e.data:new Blob([e.data],{type:o(l)}),r.recordingCallback&&(r.recordingCallback(r.blob),r.recordingCallback=null)):e.data&&e.data.size&&(a.push(e.data),n(),"function"==typeof t.ondataavailable)&&(e=t.getNativeBlob?e.data:new Blob([e.data],{type:o(l)}),t.ondataavailable(e))},s.onstart=function(){d.push("started")},s.onpause=function(){d.push("paused")},s.onresume=function(){d.push("resumed")},s.onstop=function(){d.push("stopped")},s.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 (",l.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)),!r.manuallyStopped&&s&&"inactive"===s.state?(delete t.timeslice,s.start(6e5)):setTimeout(void 0,1e3),"inactive"!==s.state&&"stopped"!==s.state&&s.stop())},"number"==typeof t.timeSlice?(n(),s.start(t.timeSlice)):s.start(36e5),t.initCallback&&t.initCallback()},this.timestamps=[],this.stop=function(e){e=e||function(){},r.manuallyStopped=!0,s&&(this.recordingCallback=e,"recording"===s.state&&s.stop(),"number"==typeof t.timeSlice&&setTimeout((function(){r.blob=new Blob(a,{type:o(t)}),r.recordingCallback(r.blob)}),100))},this.pause=function(){s&&"recording"===s.state&&s.pause()},this.resume=function(){s&&"paused"===s.state&&s.resume()},this.clearRecordedData=function(){s&&"recording"===s.state&&r.stop(l),l()},this.getInternalRecorder=function(){return s},this.blob=null,this.getState=function(){return s&&s.state||"inactive"};var d=[];this.getAllStates=function(){return d},void 0===t.checkForInactiveTracks&&(t.checkForInactiveTracks=!1),r=this,function i(){if(s&&!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 r.stop()):void setTimeout(i,1e3)}(),this.name="MediaStreamRecorder",this.toString=function(){return this.name}}function E(e,i){if(!b(e,"audio").length)throw"Your stream has no audio tracks.";var r,s=this,a=[],n=[],o=!1,l=0,h=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,r=e.numberOfAudioChannels,s=e.leftBuffers.slice(0),a=e.rightBuffers.slice(0),n=e.sampleRate,o=e.internalInterleavedLength;e=e.desiredSampRate;function l(e,t,i){var r=Math.round(e.length*(t/i)),s=[],a=Number((e.length-1)/(r-1));s[0]=e[0];for(var n,o=1;o<r-1;o++){var l=o*a,d=Number(Math.floor(l)).toFixed(),h=Number(Math.ceil(l)).toFixed();s[o]=(n=e[d],h=e[h],n+(h-n)*(l-d))}return s[r-1]=e[e.length-1],s}function d(e,t){for(var i=new Float64Array(t),r=0,s=e.length,a=0;a<s;a++){var n=e[a];i.set(n,r),r+=n.length}return i}function h(e,t,i){for(var r=i.length,s=0;s<r;s++)e.setUint8(t+s,i.charCodeAt(s))}2===r&&(s=d(s,o),a=d(a,o),e&&(s=l(s,e,n),a=l(a,e,n))),1===r&&(s=d(s,o),e&&(s=l(s,e,n))),e&&(n=e),2===r&&(i=function(e,t){for(var i=e.length+t.length,r=new Float64Array(i),s=0,a=0;a<i;)r[a++]=e[s],r[a++]=t[s],s++;return r}(s,a));o=(i=1===r?s:i).length,e=new ArrayBuffer(44+2*o);var c=new DataView(e);h(c,0,"RIFF"),c.setUint32(4,36+2*o,!0),h(c,8,"WAVE"),h(c,12,"fmt "),c.setUint32(16,16,!0),c.setUint16(20,1,!0),c.setUint16(22,r,!0),c.setUint32(24,n,!0),c.setUint32(28,n*r*2,!0),c.setUint16(32,2*r,!0),c.setUint16(34,16,!0),h(c,36,"data"),c.setUint32(40,2*o,!0);for(var u=o,p=44,f=0;f<u;f++)c.setInt16(p,32767*i[f],!0),p+=2;if(t)return t({buffer:e,view:c});postMessage({buffer:e,view:c})}var r,s,a;e.noWorker?i(e,(function(e){t(e.buffer,e.view)})):(r=i,r=d.createObjectURL(new Blob([r.toString(),";this.onmessage = function (eee) {"+r.name+"(eee.data);}"],{type:"application/javascript"})),(s=new Worker(r)).workerURL=r,(a=s).onmessage=function(e){t(e.data.buffer,e.data.view),d.revokeObjectURL(a.workerURL),a.terminate()},a.postMessage(e))}!0===i.leftChannel&&(h=1),(!(h=1===i.numberOfAudioChannels?1:h)||h<1)&&(h=2),i.disableLogs||console.log("StereoAudioRecorder is set to record number of channels: "+h),void 0===i.checkForInactiveTracks&&(i.checkForInactiveTracks=!0),this.record=function(){if(!1===u())throw"Please make sure MediaStream is active.";_(),S=v=!1,o=!0,void 0!==i.timeSlice&&T()},this.stop=function(e){e=e||function(){},o=!1,p({desiredSampRate:c,sampleRate:A,numberOfAudioChannels:h,internalInterleavedLength:l,leftBuffers:a,rightBuffers:1===h?[]:n,noWorker:i.noWorker},(function(t,i){s.blob=new Blob([i],{type:"audio/wav"}),s.buffer=new ArrayBuffer(i.buffer.byteLength),s.view=i,s.sampleRate=c||A,s.bufferSize=y,s.length=l,S=!1,e&&e(s.blob)}))},(t.Storage=void 0===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)r=f.createJavaScriptNode(y,h,h);else{if(!f.createScriptProcessor)throw"WebAudio API has no support on this browser.";r=f.createScriptProcessor(y,h,h)}m.connect(r),i.bufferSize||(y=r.bufferSize);var A=void 0!==i.sampleRate?i.sampleRate:f.sampleRate||44100,v=((A<22050||96e3<A)&&!i.disableLogs&&console.log("sample-rate must be under range 22050 and 96000."),i.disableLogs||i.desiredSampRate&&console.log("Desired sample-rate: "+i.desiredSampRate),!1);function _(){a=[],l=0,v=o=S=!(n=[]),f=null,s.leftchannel=a,s.rightchannel=n,s.numberOfAudioChannels=h,s.desiredSampRate=c,s.sampleRate=A,s.recordingLength=l,E={left:[],right:[],recordingLength:0}}function w(){r&&(r.onaudioprocess=null,r.disconnect(),r=null),m&&(m.disconnect(),m=null),_()}this.pause=function(){v=!0},this.resume=function(){if(!1===u())throw"Please make sure MediaStream is active.";if(!o)return i.disableLogs||console.log("Seems recording has been restarted."),void this.record();v=!1},this.clearRecordedData=function(){i.checkForInactiveTracks=!1,o&&this.stop(w),w()},this.name="StereoAudioRecorder";var S=!(this.toString=function(){return this.name}),E=(r.onaudioprocess=function(e){var t,d;v||(!1===u()&&(i.disableLogs||console.log("MediaStream seems stopped."),r.disconnect(),o=!1),o?(S||(S=!0,i.onAudioProcessStarted&&i.onAudioProcessStarted(),i.initCallback&&i.initCallback()),t=e.inputBuffer.getChannelData(0),t=new Float32Array(t),a.push(t),2===h&&(e=e.inputBuffer.getChannelData(1),d=new Float32Array(e),n.push(d)),l+=y,s.recordingLength=l,void 0!==i.timeSlice&&(E.recordingLength+=y,E.left.push(t),2===h&&E.right.push(d))):m&&(m.disconnect(),m=null))},f.createMediaStreamDestination?r.connect(f.createMediaStreamDestination()):r.connect(f.destination),this.leftchannel=a,this.rightchannel=n,this.numberOfAudioChannels=h,this.desiredSampRate=c,this.sampleRate=A,s.recordingLength=l,{left:[],right:[],recordingLength:0});function T(){o&&"function"==typeof i.ondataavailable&&void 0!==i.timeSlice&&(E.left.length?(p({desiredSampRate:c,sampleRate:A,numberOfAudioChannels:h,internalInterleavedLength:E.recordingLength,leftBuffers:E.left,rightBuffers:1===h?[]:E.right},(function(e,t){t=new Blob([t],{type:"audio/wav"}),i.ondataavailable(t),setTimeout(T,i.timeSlice)})),E={left:[],right:[],recordingLength:0}):setTimeout(T,i.timeSlice))}}function T(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 r,s,a,n=!(!window.webkitRTCPeerConnection&&!window.webkitGetUserMedia||!window.chrome),o=50,l=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);if(n&&l&&l[2]&&(o=parseInt(l[2],10)),n&&o<52&&(i=!1),i=!t.useWhammyRecorder&&i)if(t.disableLogs||console.log("Your browser supports both MediRecorder API and canvas.captureStream!"),e instanceof HTMLCanvasElement)r=e;else{if(!(e instanceof CanvasRenderingContext2D))throw"Please pass either HTMLCanvasElement or CanvasRenderingContext2D.";r=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 r?e=r.captureStream(25):"mozCaptureStream"in r?e=r.mozCaptureStream(25):"webkitCaptureStream"in r&&(e=r.webkitCaptureStream(25));try{var n=new m;n.addTrack(b(e,"video")[0]),e=n}catch(e){}if(!e)throw"captureStream API are NOT available.";(s=new S(e,{mimeType:t.mimeType||"video/webm"})).record()}else p.frames=[],u=(new Date).getTime(),c();t.initCallback&&t.initCallback()},this.getWebPImages=function(i){var r;"canvas"===e.nodeName.toLowerCase()&&(r=p.frames.length,p.frames.forEach((function(e,i){var s=r-i;t.disableLogs||console.log(s+"/"+r+" frames remaining"),t.onEncodingCallback&&t.onEncodingCallback(s,r),s=e.image.toDataURL("image/webp",1);p.frames[i].image=s})),t.disableLogs||console.log("Generating WebM")),i()};var d=!(this.stop=function(e){a=!1;var r=this;i&&s?s.stop(e):this.getWebPImages((function(){p.compile((function(i){t.disableLogs||console.log("Recording finished!"),r.blob=i,r.blob.forEach&&(r.blob=new Blob([],{type:"video/webm"})),e&&e(r.blob),p.frames=[]}))}))});function h(){p.frames=[],d=a=!1}function c(){return d?(u=(new Date).getTime(),setTimeout(c,500)):"canvas"===e.nodeName.toLowerCase()?(i=(new Date).getTime()-u,u=(new Date).getTime(),p.frames.push({image:(s=(r=document.createElement("canvas")).getContext("2d"),r.width=e.width,r.height=e.height,s.drawImage(e,0,0),r),duration:i}),void(a&&setTimeout(c,t.frameInterval))):void 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)}});var i,r,s}this.pause=function(){d=!0,s instanceof S&&s.pause()},this.resume=function(){d=!1,s instanceof S?s.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 x.Video(100)}function k(e,t){function i(e){e=void 0!==e?e:10;var t=(new Date).getTime()-o;return t?s?(o=(new Date).getTime(),setTimeout(i,100)):(o=(new Date).getTime(),n.paused&&n.play(),h.drawImage(n,0,0,d.width,d.height),l.frames.push({duration:t,image:d.toDataURL("image/webp")}),void(r||setTimeout(i,e,e))):setTimeout(i,e,e)}(t=t||{}).frameInterval||(t.frameInterval=10),t.disableLogs||console.log("Using frames-interval:",t.frameInterval);var r=!(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}),d.width=t.canvas.width||320,d.height=t.canvas.height||240,h=d.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(),o=(new Date).getTime(),l=new x.Video,t.disableLogs||(console.log("canvas resolutions",d.width,"*",d.height),console.log("video width/height",n.width||d.width,"*",n.height||d.height)),i(t.frameInterval)}),s=!(this.stop=function(e){e=e||function(){},r=!0;var i=this;setTimeout((function(){var r,s,a,n,o,h,c,u,p,f,m,g,y,A,b,v,_;r=l.frames,s=-1,n=a=null,o=function(r){l.frames=r,t.advertisement&&t.advertisement.length&&(l.frames=t.advertisement.concat(l.frames)),l.compile((function(t){i.blob=t,i.blob.forEach&&(i.blob=new Blob([],{type:"video/webm"})),e&&e(i.blob)}))},(h=document.createElement("canvas")).width=d.width,h.height=d.height,u=h.getContext("2d"),p=[],f=-1===s,m=s&&0<s&&s<=r.length?s:r.length,g=Math.sqrt(Math.pow(255,2)+Math.pow(255,2)+Math.pow(255,2)),y=a&&0<=a&&a<=1?a:0,A=n&&0<=n&&n<=1?n:0,b=!1,v=-1,_=(c={length:m,functionToLoop:function(e,t){function i(){!b&&n-s<=n*A||(f&&(b=!0),p.push(r[t])),e()}var s,a,n,o;b?i():((o=new Image).onload=function(){u.drawImage(o,0,0,d.width,d.height);var e=u.getImageData(0,0,d.width,d.height);s=0,a=e.data.length,n=e.data.length/4;for(var t=0;t<a;t+=4){var r=e.data[t],l=e.data[t+1],h=e.data[t+2];Math.sqrt(Math.pow(+r,2)+Math.pow(+l,2)+Math.pow(+h,2))<=g*y&&s++}i()},o.src=r[t].image)},callback:function(){(p=p.concat(r.slice(m))).length<=0&&p.push(r[r.length-1]),o(p)}}).length,function e(){++v!==_?setTimeout((function(){c.functionToLoop(e,v)}),1):c.callback()}()}),10)});function a(){l.frames=[],s=!(r=!0)}this.pause=function(){s=!0},this.resume=function(){s=!1,r&&this.record()},this.clearRecordedData=function(){r||this.stop(a),a()},this.name="WhammyRecorder",this.toString=function(){return this.name};var n,o,l,d=document.createElement("canvas"),h=d.getContext("2d")}void 0!==e?_.AudioContext=e:"undefined"!=typeof webkitAudioContext&&(_.AudioContext=webkitAudioContext),t.Storage=_,t.MediaStreamRecorder=S,t.StereoAudioRecorder=E,t.CanvasRecorder=T,t.WhammyRecorder=k,C.prototype.add=function(e,t){if("toDataURL"in(e="canvas"in e?e.canvas: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})},C.prototype.compile=function(e){i=L,i=d.createObjectURL(new Blob([i.toString(),"this.onmessage = function (eee) {"+i.name+"(eee.data);}"],{type:"application/javascript"})),t=new Worker(i),d.revokeObjectURL(i);var t,i=t;i.onmessage=function(t){t.data.error?console.error(t.data.error):e(t.data)},i.postMessage(this.frames)};var x={Video:C};function C(e){this.frames=[],this.duration=e||1,this.quality=.8}function L(e){function t(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 i(e){for(var r=[],s=0;s<e.length;s++){var a=e[s].data,n=(a="string"==typeof(a="number"==typeof(a="object"==typeof a?i(a):a)?t(a.toString(2)):a)?new Uint8Array(a.split("").map((function(e){return e.charCodeAt(0)}))):a).size||a.byteLength||a.length,o=Math.ceil(Math.ceil(Math.log(n)/Math.log(2))/8);n=n.toString(2),n=new Array(7*o+7+1-n.length).join("0")+n,o=new Array(o).join("0")+"1"+n;r.push(function(e){for(var t=[];0<e;)t.push(255&e),e>>=8;return new Uint8Array(t.reverse())}(e[s].id)),r.push(t(o)),r.push(a)}return new Blob(r,{type:"video/webm"})}function r(e){for(var t=0,i={};t<e.length;){var s=e.substr(t,4),a=(a=t,parseInt(e.substr(a+4,4).split("").map((function(e){return e=e.charCodeAt(0).toString(2),new Array(8-e.length+1).join("0")+e})).join(""),2)),n=e.substr(t+4+4,a);t+=8+a,i[s]=i[s]||[],"RIFF"===s||"LIST"===s?i[s].push(r(n)):i[s].push(n)}return i}e=new function(e){var t=function(e){if(e[0]){for(var t=e[0].width,i=e[0].height,r=e[0].duration,s=1;s<e.length;s++)r+=e[s].duration;return{duration:r,width:t,height:i}}postMessage({error:"Something went wrong. Maybe WebP format is not supported in the current browser."})}(e);if(!t)return[];for(var r,s=[{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:(r=t.duration,[].slice.call(new Uint8Array(new Float64Array([r]).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:t.width,id:176},{data:t.height,id:186}]}]}]}]}],a=0,n=0;a<e.length;){for(var o=[],l=0;o.push(e[a]),l+=e[a].duration,++a<e.length&&l<3e4;);var d={id:524531317,data:function(e,t,i){return[{data:e,id:231}].concat(i.map((function(e){var i=function(e){var t=0;if(e.keyframe&&(t|=128),e.invisible&&(t|=8),e.lacing&&(t|=e.lacing<<1),e.discardable&&(t|=1),127<e.trackNum)throw"TrackNumber > 127 not supported";return[128|e.trackNum,e.timecode>>8,255&e.timecode,t].map((function(e){return String.fromCharCode(e)})).join("")+e.frame}({discardable:0,frame:e.data.slice(4),invisible:0,keyframe:1,lacing:0,trackNum:1,timecode:Math.round(t)});return t+=e.duration,{data:i,id:163}})))}(n,0,o)};s[1].data.push(d),n+=l}return i(s)}(e.map((function(e){var t=function(e){for(var t=e.RIFF[0].WEBP[0],i=t.indexOf("*"),r=0,s=[];r<4;r++)s[r]=t.charCodeAt(i+3+r);return{width:16383&(s[1]<<8|s[0]),height:16383&(s[3]<<8|s[2]),data:t,riff:e}}(r(atob(e.image.slice(23))));return t.duration=e.duration,t}))),postMessage(e)}t.Whammy=x;var D={init:function(){var e,t,i,r=this;function s(e){e.createObjectStore(r.dataStoreName)}function a(){var t=e.transaction([r.dataStoreName],"readwrite");function i(e){t.objectStore(r.dataStoreName).get(e).onsuccess=function(t){r.callback&&r.callback(t.target.result,e)}}r.videoBlob&&t.objectStore(r.dataStoreName).put(r.videoBlob,"videoBlob"),r.gifBlob&&t.objectStore(r.dataStoreName).put(r.gifBlob,"gifBlob"),r.audioBlob&&t.objectStore(r.dataStoreName).put(r.audioBlob,"audioBlob"),i("audioBlob"),i("videoBlob"),i("gifBlob")}"undefined"!=typeof indexedDB&&void 0!==indexedDB.open?(t=this.dbName||location.href.replace(/\/|:|#|%|\.|\[|\]/g,""),(i=indexedDB.open(t,1)).onerror=r.onError,i.onsuccess=function(){(e=i.result).onerror=r.onError,e.setVersion&&1!==e.version?e.setVersion(1).onsuccess=function(){s(e),a()}:a()},i.onupgradeneeded=function(e){s(e.target.result)}):console.error("IndexedDB API are not available in this browser.")},Fetch:function(e){return this.callback=e,this.init(),this},Store:function(e){return this.audioBlob=e.audioBlob,this.videoBlob=e.videoBlob,this.gifBlob=e.gifBlob,this.init(),this},onError:function(e){console.error(JSON.stringify(e,null,"\t"))},dataStoreName:"recordRTC",dbName:null};function R(e,t){"undefined"==typeof GIFEncoder&&((i=document.createElement("script")).src="https://www.webrtc-experiment.com/gif-recorder.js",(document.body||document.documentElement).appendChild(i)),t=t||{};var i,r,s=e instanceof CanvasRenderingContext2D||e instanceof HTMLCanvasElement,a=(this.record=function(){"undefined"!=typeof GIFEncoder&&h?(s||(t.width||(t.width=r.offsetWidth||320),t.height||(t.height=r.offsetHeight||240),t.video||(t.video={width:t.width,height:t.height}),t.canvas||(t.canvas={width:t.width,height:t.height}),n.width=t.canvas.width||320,n.height=t.canvas.height||240,r.width=t.video.width||320,r.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(a)return setTimeout((function(){e(i)}),100);p=o(e),i-c<90||(!s&&r.paused&&r.play(),s||d.drawImage(r,0,0,n.width,n.height),t.onGifPreview&&t.onGifPreview(n.toDataURL("image/png")),u.addFrame(d),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=[]})),n=(this.pause=function(){a=!0},this.resume=function(){a=!1},this.clearRecordedData=function(){f.clearedRecordedData=!0,u&&(u.stream().bin=[])},this.name="GifRecorder",this.toString=function(){return this.name},document.createElement("canvas")),d=n.getContext("2d"),h=(s&&(e instanceof CanvasRenderingContext2D?n=(d=e).canvas:e instanceof HTMLCanvasElement&&(d=e.getContext("2d"),n=e)),!0);s||((r=document.createElement("video")).muted=!0,r.autoplay=!0,r.playsInline=!0,h=!1,r.onloadedmetadata=function(){h=!0},v(e,r),r.play());var c,u,p=null,f=this}function I(e,t){t=t||"multi-streams-mixer";var i=[],r=!1,s=document.createElement("canvas"),a=s.getContext("2d"),n=(s.style.opacity=0,s.style.position="absolute",s.style.zIndex=-1,s.style.top="-1000em",s.style.left="-1000em",s.className=t,(document.body||document.documentElement).appendChild(s),this.disableLogs=!1,this.frameInterval=10,this.width=360,this.height=240,this.useGainNode=!0,this),o=window.AudioContext;void 0===o&&("undefined"!=typeof webkitAudioContext&&(o=webkitAudioContext),"undefined"!=typeof mozAudioContext&&(o=mozAudioContext)),window.URL,"undefined"!=typeof navigator&&void 0===navigator.getUserMedia&&(void 0!==navigator.webkitGetUserMedia&&(navigator.getUserMedia=navigator.webkitGetUserMedia),void 0!==navigator.mozGetUserMedia&&(navigator.getUserMedia=navigator.mozGetUserMedia));var l=window.MediaStream,d=(void 0!==(l=void 0===l&&"undefined"!=typeof webkitMediaStream?webkitMediaStream:l)&&void 0===l.prototype.stop&&(l.prototype.stop=function(){this.getTracks().forEach((function(e){e.stop()}))}),{});function h(){var e,t,a;r||(e=i.length,t=!1,a=[],i.forEach((function(e){e.stream||(e.stream={}),e.stream.fullcanvas?t=e:a.push(e)})),t?(s.width=t.stream.width,s.height=t.stream.height):a.length?(s.width=1<e?2*a[0].width:a[0].width,s.height=a[0].height*(9!==e&&10!==e?7!==e&&8!==e?5!==e&&6!==e?3!==e&&4!==e?1:2:3:4:5)):(s.width=n.width||360,s.height=n.height||240),t&&t instanceof HTMLVideoElement&&c(t),a.forEach((function(e,t){c(e,t)})),setTimeout(h,n.frameInterval))}function c(e,t){var i,s,n,o;r||(s=i=0,n=e.width,o=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&&(n=e.stream.width),void 0!==e.stream.height&&(o=e.stream.height),a.drawImage(e,i,s,n,o),"function"==typeof e.stream.onRender&&e.stream.onRender(a,i,s,n,o,t))}function u(e){var i,r,s=document.createElement("video");return i=e,!("srcObject"in(r=s))&&"mozSrcObject"in r?r.mozSrcObject=i:r.srcObject=i,s.className=t,s.muted=!0,s.volume=0,s.width=e.width||n.width||360,s.height=e.height||n.height||240,s.play(),s}function p(t){i=[],(t=t||e).forEach((function(e){var t;e.getTracks().filter((function(e){return"video"===e.kind})).length&&((t=u(e)).stream=e,i.push(t))}))}void 0!==o?d.AudioContext=o:"undefined"!=typeof webkitAudioContext&&(d.AudioContext=webkitAudioContext),this.startDrawingFrames=function(){h()},this.appendStreams=function(t){if(!t)throw"First parameter is required.";(t=t instanceof Array?t:[t]).forEach((function(t){var r,s=new l;t.getTracks().filter((function(e){return"video"===e.kind})).length&&((r=u(t)).stream=t,i.push(r),s.addTrack(t.getTracks().filter((function(e){return"video"===e.kind}))[0])),t.getTracks().filter((function(e){return"audio"===e.kind})).length&&(r=n.audioContext.createMediaStreamSource(t),n.audioDestination=n.audioContext.createMediaStreamDestination(),r.connect(n.audioDestination),s.addTrack(n.audioDestination.stream.getTracks().filter((function(e){return"audio"===e.kind}))[0])),e.push(s)}))},this.releaseStreams=function(){i=[],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,a.clearRect(0,0,s.width,s.height),s.stream&&(s.stream.stop(),s.stream=null)},this.resetVideoStreams=function(e){p(e=!e||e instanceof Array?e:[e])},this.name="MultiStreamsMixer",this.toString=function(){return this.name},this.getMixedStream=function(){r=!1,p(),"captureStream"in s?a=s.captureStream():"mozCaptureStream"in s?a=s.mozCaptureStream():n.disableLogs||console.error("Upgrade to latest Chrome or otherwise enable this flag: chrome://flags/#enable-experimental-web-platform-features"),t=new l,a.getTracks().filter((function(e){return"video"===e.kind})).forEach((function(e){t.addTrack(e)}));var t,i=s.stream=t,a=function(){d.AudioContextConstructor||(d.AudioContextConstructor=new d.AudioContext),n.audioContext=d.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){e.getTracks().filter((function(e){return"audio"===e.kind})).length&&(t++,e=n.audioContext.createMediaStreamSource(e),!0===n.useGainNode&&e.connect(n.gainNode),n.audioSources.push(e))})),t)return n.audioDestination=n.audioContext.createMediaStreamDestination(),n.audioSources.forEach((function(e){e.connect(n.audioDestination)})),n.audioDestination.stream}();return a&&a.getTracks().filter((function(e){return"audio"===e.kind})).forEach((function(e){i.addTrack(e)})),e.forEach((function(e){e.fullcanvas})),i}}function P(e,t){e=e||[];var i,r,s=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 s;i=new I(e,t.elementClass||"multi-streams-mixer"),s=[],e.forEach((function(e){b(e,"video").forEach((function(e){s.push(e)}))})),s.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()),(r=new S(i.getMixedStream(),t)).record()},this.stop=function(e){r&&r.stop((function(t){s.blob=t,e(t),s.clearRecordedData()}))},this.pause=function(){r&&r.pause()},this.resume=function(){r&&r.resume()},this.clearRecordedData=function(){r&&(r.clearRecordedData(),r=null),i&&(i.releaseStreams(),i=null)},this.addStreams=function(s){if(!s)throw"First parameter is required.";s instanceof Array||(s=[s]),e.concat(s),r&&i&&(i.appendStreams(s),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,r,s;function a(o,l){if(!t.workerPath&&!l)return i=!1,fetch("https://unpkg.com/webm-wasm@latest/dist/webm-worker.js").then((function(e){e.arrayBuffer().then((function(e){a(o,e)}))}));!t.workerPath&&l instanceof ArrayBuffer&&(l=new Blob([l],{type:"text/javascript"}),t.workerPath=d.createObjectURL(l)),t.workerPath||console.error("workerPath parameter is missing."),(r=new Worker(t.workerPath)).postMessage(t.webAssemblyPath||"https://unpkg.com/webm-wasm@latest/dist/webm-wasm.wasm"),r.addEventListener("message",(function(a){"READY"===a.data?(r.postMessage({width:t.width,height:t.height,bitrate:t.bitrate||1200,timebaseDen:t.frameRate||30,realtime:t.realtime}),new ReadableStream({start:function(r){var s=document.createElement("canvas"),a=document.createElement("video"),n=!0;a.srcObject=e,a.muted=!0,a.height=t.height,a.width=t.width,a.volume=0,a.onplaying=function(){s.width=t.width,s.height=t.height;var e=s.getContext("2d"),o=1e3/t.frameRate,l=setInterval((function(){if(i&&(clearInterval(l),r.close()),n&&(n=!1,t.onVideoProcessStarted&&t.onVideoProcessStarted()),e.drawImage(a,0,0),"closed"!==r._controlledReadableStream.state)try{r.enqueue(e.getImageData(0,0,t.width,t.height))}catch(e){}}),o)},a.play()}}).pipeTo(new WritableStream({write:function(e){i?console.error("Got image, but recorder is finished!"):r.postMessage(e.data.buffer,[e.data.buffer])}}))):!a.data||s||n.push(a.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(){s=!(n=[]),this.blob=null,a(e),"function"==typeof t.initCallback&&t.initCallback()},this.pause=function(){s=!0},this.resume=function(){s=!1};var n=[];this.stop=function(e){i=!0;var t,s=this;t=function(){s.blob=new Blob(n,{type:"video/webm"}),e(s.blob)},r?(r.addEventListener("message",(function(e){null===e.data&&(r.terminate(),r=null,t())})),r.postMessage(null)):t()},this.name="WebAssemblyRecorder",this.toString=function(){return this.name},this.clearRecordedData=function(){s=!(n=[]),this.blob=null},this.blob=null}t.DiskStorage=D,t.GifRecorder=R,t.MultiStreamRecorder=P,t.RecordRTCPromisesHandler=function(e,i){if(!this)throw'Use "new RecordRTCPromisesHandler()"';if(void 0===e)throw'First argument "MediaStream" is required.';var r=this;r.recordRTC=new t(e,i),this.startRecording=function(){return new Promise((function(e,t){try{r.recordRTC.startRecording(),e()}catch(e){t(e)}}))},this.stopRecording=function(){return new Promise((function(e,t){try{r.recordRTC.stopRecording((function(i){r.blob=r.recordRTC.getBlob(),r.blob&&r.blob.size?e(i):t("Empty blob.",r.blob)}))}catch(e){t(e)}}))},this.pauseRecording=function(){return new Promise((function(e,t){try{r.recordRTC.pauseRecording(),e()}catch(e){t(e)}}))},this.resumeRecording=function(){return new Promise((function(e,t){try{r.recordRTC.resumeRecording(),e()}catch(e){t(e)}}))},this.getDataURL=function(e){return new Promise((function(e,t){try{r.recordRTC.getDataURL((function(t){e(t)}))}catch(e){t(e)}}))},this.getBlob=function(){return new Promise((function(e,t){try{e(r.recordRTC.getBlob())}catch(e){t(e)}}))},this.getInternalRecorder=function(){return new Promise((function(e,t){try{e(r.recordRTC.getInternalRecorder())}catch(e){t(e)}}))},this.reset=function(){return new Promise((function(e,t){try{e(r.recordRTC.reset())}catch(e){t(e)}}))},this.destroy=function(){return new Promise((function(e,t){try{e(r.recordRTC.destroy())}catch(e){t(e)}}))},this.getState=function(){return new Promise((function(e,t){try{e(r.recordRTC.getState())}catch(e){t(e)}}))},this.blob=null,this.version="5.6.2"},t.WebAssemblyRecorder=B}));class Gi{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(){var e=this._total_bytes-this._buffer_index;if(e<=0)console.error("ExpGolomb: _fillCurrentWord() but no bytes available",this._total_bytes,this._buffer_index);else{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(32<e&&console.error("ExpGolomb: readBits() bits exceeded max 32bits!"),e<=this._current_word_bits_left)return t=this._current_word>>>32-e,this._current_word<<=e,this._current_word_bits_left-=e,t;var t=this._current_word_bits_left?this._current_word:0,i=(e=(t>>>=32-this._current_word_bits_left,e-this._current_word_bits_left),e=(this._fillCurrentWord(),Math.min(e,this._current_word_bits_left)),this._current_word>>>32-e);return this._current_word<<=e,this._current_word_bits_left-=e,t<<e|i}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(0!=(this._current_word&2147483648>>>e))return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()}readUEG(){var e=this._skipLeadingZero();return this.readBits(e+1)-1}readSEG(){var e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)}}class Hi{static _ebsp2rbsp(e){let t=e,i=t.byteLength,r=new Uint8Array(i),s=0;for(let a=0;a<i;a++)2<=a&&3===t[a]&&0===t[a-1]&&0===t[a-2]||(r[s]=t[a],s++);return new Uint8Array(r.buffer,0,s)}static parseSPS(e){let t=Hi._ebsp2rbsp(e),i=new Gi(t);i.readByte();e=i.readByte();var r=(i.readByte(),i.readByte());i.readUEG();let s=Hi.getProfileString(e),a=Hi.getLevelString(r),n=1,o=420,l=8;if((100===e||110===e||122===e||244===e||44===e||83===e||86===e||118===e||128===e||138===e||144===e)&&(3===(n=i.readUEG())&&i.readBits(1),n<=3&&(o=[0,420,422,444][n]),l=i.readUEG()+8,i.readUEG(),i.readBits(1),i.readBool())){var d=3!==n?8:12;for(let e=0;e<d;e++)i.readBool()&&(e<6?Hi._skipScalingList(i,16):Hi._skipScalingList(i,64))}if(i.readUEG(),r=i.readUEG(),0===r)i.readUEG();else if(1===r){i.readBits(1),i.readSEG(),i.readSEG();var h=i.readUEG();for(let e=0;e<h;e++)i.readSEG()}e=i.readUEG(),i.readBits(1),r=i.readUEG();var c=i.readUEG(),u=i.readBits(1);0===u&&i.readBits(1),i.readBits(1);let p=0,f=0,m=0,g=0,y=(i.readBool()&&(p=i.readUEG(),f=i.readUEG(),m=i.readUEG(),g=i.readUEG()),1),A=1,b=0,v=!0,_=0,w=0,S=(i.readBool()&&(i.readBool()&&(0<(x=i.readByte())&&x<16?(y=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][x-1],A=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][x-1]):255===x&&(y=i.readByte()<<8|i.readByte(),A=i.readByte()<<8|i.readByte())),i.readBool()&&i.readBool(),i.readBool()&&(i.readBits(4),i.readBool()&&i.readBits(24)),i.readBool()&&(i.readUEG(),i.readUEG()),i.readBool()&&(x=i.readBits(32),k=i.readBits(32),v=i.readBool(),_=k,w=2*x,b=_/w)),1),E=(1===y&&1===A||(S=y/A),0),T=0;T=0===n?(E=1,2-u):(E=3===n?1:2,(1===n?2:1)*(2-u));var k=16*(r+1),x=16*(c+1)*(2-u);k-=(p+f)*E,x-=(m+g)*T,r=Math.ceil(k*S);return i.destroy(),i=null,{profile_string:s,level_string:a,bit_depth:l,ref_frames:e,chroma_format:o,chroma_format_string:Hi.getChromaFormatString(o),frame_rate:{fixed:v,fps:b,fps_den:w,fps_num:_},sar_ratio:{width:y,height:A},codec_size:{width:k,height:x},present_size:{width:r,height:x}}}static parseSPS$2(e){let t=e.subarray(1,4),i="avc1.";for(let P=0;P<3;P++){let e=t[P].toString(16);e.length<2&&(e="0"+e),i+=e}let r=Hi._ebsp2rbsp(e),s=new Gi(r);s.readByte();e=s.readByte();var a=(s.readByte(),s.readByte());s.readUEG();let n=Hi.getProfileString(e),o=Hi.getLevelString(a),l=1,d=420,h=8,c=8;if((100===e||110===e||122===e||244===e||44===e||83===e||86===e||118===e||128===e||138===e||144===e)&&(3===(l=s.readUEG())&&s.readBits(1),l<=3&&(d=[0,420,422,444][l]),h=s.readUEG()+8,c=s.readUEG()+8,s.readBits(1),s.readBool())){var u=3!==l?8:12;for(let e=0;e<u;e++)s.readBool()&&(e<6?Hi._skipScalingList(s,16):Hi._skipScalingList(s,64))}s.readUEG();var p=s.readUEG();if(0===p)s.readUEG();else if(1===p){s.readBits(1),s.readSEG(),s.readSEG();var f=s.readUEG();for(let e=0;e<f;e++)s.readSEG()}p=s.readUEG();var m=(s.readBits(1),s.readUEG()),g=s.readUEG(),y=s.readBits(1);0===y&&s.readBits(1),s.readBits(1);let A=0,b=0,v=0,_=0,w=(s.readBool()&&(A=s.readUEG(),b=s.readUEG(),v=s.readUEG(),_=s.readUEG()),1),S=1,E=0,T=!0,k=0,x=0,C=(s.readBool()&&(s.readBool()&&(0<(I=s.readByte())&&I<16?(w=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][I-1],S=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][I-1]):255===I&&(w=s.readByte()<<8|s.readByte(),S=s.readByte()<<8|s.readByte())),s.readBool()&&s.readBool(),s.readBool()&&(s.readBits(4),s.readBool()&&s.readBits(24)),s.readBool()&&(s.readUEG(),s.readUEG()),s.readBool()&&(I=s.readBits(32),R=s.readBits(32),T=s.readBool(),k=R,x=2*I,E=k/x)),1),L=(1===w&&1===S||(C=w/S),0),D=0;D=0===l?(L=1,2-y):(L=3===l?1:2,(1===l?2:1)*(2-y));var R=16*(m+1),I=16*(g+1)*(2-y);R-=(A+b)*L,I-=(v+_)*D,m=Math.ceil(R*C);return s.destroy(),s=null,{codec_mimetype:i,profile_idc:e,level_idc:a,profile_string:n,level_string:o,chroma_format_idc:l,bit_depth:h,bit_depth_luma:h,bit_depth_chroma:c,ref_frames:p,chroma_format:d,chroma_format_string:Hi.getChromaFormatString(d),frame_rate:{fixed:T,fps:E,fps_den:x,fps_num:k},sar_ratio:{width:w,height:S},codec_size:{width:R,height:I},present_size:{width:m,height:I}}}static _skipScalingList(e,t){let i,r=8,s=8;for(let a=0;a<t;a++)0!==s&&(i=e.readSEG(),s=(r+i+256)%256),r=0===s?r: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 Wi{constructor(e){this.buffer=e,this.buflen=e.length,this.bufpos=0,this.bufoff=0,this.iserro=!1}read(e){let t,i=0;for(;e;){if(e<0||this.bufpos>=this.buflen)return this.iserro=!0,0;this.iserro=!1,t=8<this.bufoff+e?8-this.bufoff:e,i=(i<<=t)+(this.buffer[this.bufpos]>>8-this.bufoff-t&255>>8-t),this.bufoff+=t,e-=t,8==this.bufoff&&(this.bufpos++,this.bufoff=0)}return i}look(e){var t=this.bufpos,i=this.bufoff;e=this.read(e);return this.bufpos=t,this.bufoff=i,e}read_golomb(){let e;for(e=0;0===this.read(1)&&!this.iserro;e++);return(1<<e)+this.read(e)-1}}function Vi(e){const t={},i=new DataView(e.buffer);let r=i.getUint8(0),s=i.getUint8(1);if(i.getUint8(2),i.getUint8(3),1!==r||0===s)return{};var a=1+(3&i.getUint8(4));if(3!=a&&4!=a)return{};var n=31&i.getUint8(5);if(0==n)return{};let o=6;for(let p=0;p<n;p++){var l=i.getUint16(o,!1);if(o+=2,0!==l){let i=new Uint8Array(e.buffer,o,l);if(o+=l,l=Hi.parseSPS(i),0===p){t.sps=i,t.timescale=1e3,t.codecWidth=l.codec_size.width,t.codecHeight=l.codec_size.height,t.presentWidth=l.present_size.width,t.presentHeight=l.present_size.height,t.profile=l.profile_string,t.level=l.level_string,t.bitDepth=l.bit_depth,t.chromaFormat=l.chroma_format,t.sarRatio=l.sar_ratio,t.frameRate=l.frame_rate,!1!==l.frame_rate.fixed&&0!==l.frame_rate.fps_num&&0!==l.frame_rate.fps_den||(t.frameRate={fixed:!0,fps:23.976,fps_num:23976,fps_den:1e3});l=t.frameRate.fps_den;var d=t.frameRate.fps_num;t.refSampleDuration=t.timescale*(l/d);let e=i.subarray(1,4),r="avc1.";for(let t=0;t<3;t++){let i=e[t].toString(16);i.length<2&&(i="0"+i),r+=i}t.codec=r}}}var h=i.getUint8(o);if(0===h)return{};o++;for(let p=0;p<h;p++){var c,u=i.getUint16(o,!1);o+=2,0!==u&&(c=new Uint8Array(e.buffer,o,u),o+=u,t.pps=c)}if(t.videoType="avc",t.sps){const e=t.sps.byteLength,i=new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e]),r=new Uint8Array(e+4);r.set(i,0),r.set(t.sps,4),t.sps=r}if(t.pps){const e=t.pps.byteLength,i=new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e]),r=new Uint8Array(e+4);r.set(i,0),r.set(t.pps,4),t.pps=r}return t}function Ki(e){let{sps:t,pps:i}=e,r=8+t.byteLength+1+2+i.byteLength,s=!1;e=Hi.parseSPS$2(t),66!==t[3]&&77!==t[3]&&88!==t[3]&&(s=!0,r+=4);let a=new Uint8Array(r);a[0]=1,a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=255,a[5]=225;var n=t.byteLength,o=(a[6]=n>>>8,a[7]=255&n,8);a.set(t,8),o+=n,a[o]=1,n=i.byteLength;a[o+1]=n>>>8,a[o+2]=255&n,a.set(i,o+3),o+=3+n,s&&(a[o]=252|e.chroma_format_idc,a[o+1]=248|e.bit_depth_luma-8,a[o+2]=248|e.bit_depth_chroma-8,a[o+3]=0,o+=4);const l=[23,0,0,0,0],d=new Uint8Array(l.length+a.byteLength);return d.set(l,0),d.set(a,l.length),d}function $i(e,t){let i=[];i[0]=t?23:39,i[1]=1,i[2]=0,i[3]=0,i[4]=0;const r=new Uint8Array(i.length+e.byteLength);return r.set(i,0),r.set(e,i.length),r}function Yi(e){return 31&e[0]}function qi(e){return e===Y}function Ji(e){return 7!==e&&8!==e&&!qi(e)}const Qi=e=>{let t=e,i=t.byteLength,r=new Uint8Array(i),s=0;for(let a=0;a<i;a++)2<=a&&3===t[a]&&0===t[a-1]&&0===t[a-2]||(r[s]=t[a],s++);return new Uint8Array(r.buffer,0,s)};function Xi(e){let t={width:0,height:0,profile:0,level:0};e=e.slice(5);do{let a={};if(e.length<23)break;if(a.configurationVersion=e[0],1!=a.configurationVersion)break;a.general_profile_space=e[1]>>6&3,a.general_tier_flag=e[1]>>5&1,a.general_profile_idc=31&e[1],a.general_profile_compatibility_flags=e[2]<<24|e[3]<<16|e[4]<<8|e[5],a.general_constraint_indicator_flags=e[6]<<24|e[7]<<16|e[8]<<8|e[9],a.general_constraint_indicator_flags=a.general_constraint_indicator_flags<<16|e[10]<<8|e[11],a.general_level_idc=e[12],a.min_spatial_segmentation_idc=(15&e[13])<<8|e[14],a.parallelismType=3&e[15],a.chromaFormat=3&e[16],a.bitDepthLumaMinus8=7&e[17],a.bitDepthChromaMinus8=7&e[18],a.avgFrameRate=e[19]<<8|e[20],a.constantFrameRate=e[21]>>6&3,a.numTemporalLayers=e[21]>>3&7,a.temporalIdNested=e[21]>>2&1,a.lengthSizeMinusOne=3&e[21];let n=e[22],o=e.slice(23);for(let e=0;e<n&&!(o.length<3);e++){var i=63&o[0],r=o[1]<<8|o[2];o=o.slice(3);for(let e=0;e<r&&!(o.length<2);e++){var s=o[0]<<8|o[1];if(o.length<2+s)break;if(o=o.slice(2),33==i){let e=new Uint8Array(s);e.set(o.slice(0,s),0),a.psps=function(e){let t={},i=e.length,r=[],s=new Wi(e);s.read(1),s.read(6),s.read(6),s.read(3);for(let l=2;l<i;l++)l+2<i&&3==s.look(24)?(r.push(s.read(8)),r.push(s.read(8)),l+=2,s.read(8)):r.push(s.read(8));let a=new Uint8Array(r),n=new Wi(a);var o;return t.sps_video_parameter_set_id=n.read(4),t.sps_max_sub_layers_minus1=n.read(3),t.sps_temporal_id_nesting_flag=n.read(1),t.profile_tier_level=function(e,t){let i={};i.profile_space=e.read(2),i.tier_flag=e.read(1),i.profile_idc=e.read(5),i.profile_compatibility_flags=e.read(32),i.general_progressive_source_flag=e.read(1),i.general_interlaced_source_flag=e.read(1),i.general_non_packed_constraint_flag=e.read(1),i.general_frame_only_constraint_flag=e.read(1),e.read(32),e.read(12),i.level_idc=e.read(8),i.sub_layer_profile_present_flag=[],i.sub_layer_level_present_flag=[];for(let r=0;r<t;r++)i.sub_layer_profile_present_flag[r]=e.read(1),i.sub_layer_level_present_flag[r]=e.read(1);if(0<t)for(let r=t;r<8;r++)e.read(2);i.sub_layer_profile_space=[],i.sub_layer_tier_flag=[],i.sub_layer_profile_idc=[],i.sub_layer_profile_compatibility_flag=[],i.sub_layer_progressive_source_flag=[],i.sub_layer_interlaced_source_flag=[],i.sub_layer_non_packed_constraint_flag=[],i.sub_layer_frame_only_constraint_flag=[],i.sub_layer_level_idc=[];for(let r=0;r<t;r++)i.sub_layer_profile_present_flag[r]&&(i.sub_layer_profile_space[r]=e.read(2),i.sub_layer_tier_flag[r]=e.read(1),i.sub_layer_profile_idc[r]=e.read(5),i.sub_layer_profile_compatibility_flag[r]=e.read(32),i.sub_layer_progressive_source_flag[r]=e.read(1),i.sub_layer_interlaced_source_flag[r]=e.read(1),i.sub_layer_non_packed_constraint_flag[r]=e.read(1),i.sub_layer_frame_only_constraint_flag[r]=e.read(1),e.read(32),e.read(12)),i.sub_layer_level_present_flag[r]?i.sub_layer_level_idc[r]=e.read(8):i.sub_layer_level_idc[r]=1;return i}(n,t.sps_max_sub_layers_minus1),t.sps_seq_parameter_set_id=n.read_golomb(),t.chroma_format_idc=n.read_golomb(),3==t.chroma_format_idc?t.separate_colour_plane_flag=n.read(1):t.separate_colour_plane_flag=0,t.pic_width_in_luma_samples=n.read_golomb(),t.pic_height_in_luma_samples=n.read_golomb(),t.conformance_window_flag=n.read(1),t.conformance_window_flag?(e=1+(t.chroma_format_idc<2),o=1+(t.chroma_format_idc<3),t.conf_win_left_offset=n.read_golomb()*o,t.conf_win_right_offset=n.read_golomb()*o,t.conf_win_top_offset=n.read_golomb()*e,t.conf_win_bottom_offset=n.read_golomb()*e):(t.conf_win_left_offset=0,t.conf_win_right_offset=0,t.conf_win_top_offset=0,t.conf_win_bottom_offset=0),t}(e),t.profile=a.general_profile_idc,t.level=a.general_level_idc/30,t.width=a.psps.pic_width_in_luma_samples-(a.psps.conf_win_left_offset+a.psps.conf_win_right_offset),t.height=a.psps.pic_height_in_luma_samples-(a.psps.conf_win_top_offset+a.psps.conf_win_bottom_offset)}o=o.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.videoType="hevc",t}function Zi(e){var{vps:e,pps:t,sps:i}=e,r={configurationVersion:1},s=(e=>{let t=Qi(e),i=new Gi(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()}})(e),a=(e=>{let t=Qi(e),i=new Gi(t),r=(i.readByte(),i.readByte(),0),s=0,a=0,n=0;i.readBits(4);var o=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(),v=i.readByte(),_=i.readByte(),w=[],S=[];for(let $=0;$<o;$++)w.push(i.readBool()),S.push(i.readBool());if(0<o)for(let $=o;$<8;$++)i.readBits(2);for(let $=0;$<o;$++)w[$]&&(i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte(),i.readByte()),w[$]&&i.readByte();i.readUEG();e=i.readUEG();var E,T=(3==e&&i.readBits(1),i.readUEG()),k=i.readUEG(),x=(i.readBool()&&(r+=i.readUEG(),s+=i.readUEG(),a+=i.readUEG(),n+=i.readUEG()),i.readUEG()),C=i.readUEG(),L=i.readUEG();for(let $=i.readBool()?0:o;$<=o;$++)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 $=0;$<4;$++)for(let e=0;e<(3===$?2:6);e++)if(i.readBool()){var D=Math.min(64,1<<4+($<<1));1<$&&i.readSEG();for(let e=0;e<D;e++)i.readSEG()}else i.readUEG();i.readBool(),i.readBool(),i.readBool()&&(i.readByte(),i.readUEG(),i.readUEG(),i.readBool());let R=i.readUEG(),I=0;for(let $=0;$<R;$++){let e=!1;if(e=0!==$?i.readBool():e){$===R&&i.readUEG(),i.readBool(),i.readUEG();let e=0;for(let t=0;t<=I;t++){let t=i.readBool(),r=!1;t||(r=i.readBool()),(t||r)&&e++}I=e}else{var P=i.readUEG(),B=i.readUEG();I=P+B;for(let e=0;e<P;e++)i.readUEG(),i.readBool();for(let e=0;e<B;e++)i.readUEG(),i.readBool()}}if(i.readBool()){var U=i.readUEG();for(let e=0;e<U;e++){for(let e=0;e<L+4;e++)i.readBits(1);i.readBits(1)}}let F=0,M=1,O=1,N=!1,j=1,z=1;if(i.readBool(),i.readBool(),i.readBool()){if(i.readBool()&&(0<(E=i.readByte())&&E<16?(M=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][E-1],O=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][E-1]):255===E&&(M=i.readBits(16),O=i.readBits(16))),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(),i.readBool()&&(r+=i.readUEG(),s+=i.readUEG(),a+=i.readUEG(),n+=i.readUEG()),i.readBool()&&(j=i.readBits(32),z=i.readBits(32),i.readBool()&&(i.readUEG(),i.readBool()))){let e,t,r=!1;e=i.readBool(),t=i.readBool(),(e||t)&&((r=i.readBool())&&(i.readByte(),i.readBits(5),i.readBool(),i.readBits(5)),i.readBits(4),i.readBits(4),r&&i.readBits(4),i.readBits(5),i.readBits(5),i.readBits(5));for(let s=0;s<=o;s++){var G=i.readBool();N=G;let s=!1,a=!1;if((s=G?s:i.readBool())?i.readSEG():a=i.readBool(),a||(cpbcnt=i.readUEG()+1),e)for(let e=0;e<1;e++)i.readUEG(),i.readUEG(),r&&(i.readUEG(),i.readUEG());if(t)for(let e=0;e<1;e++)i.readUEG(),i.readUEG(),r&&(i.readUEG(),i.readUEG())}}i.readBool()&&(i.readBool(),i.readBool(),i.readBool(),F=i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG())}i.readBool();let H=`hvc1.${h}.1.L${_}.B0`,W=T,V=k,K=1;return 1!==M&&1!==O&&(K=M/O),i.destroy(),i=null,{codec_mimetype:H,level_string:(_/30).toFixed(1),profile_idc:h,bit_depth:x+8,ref_frames:1,chroma_format:e,chroma_format_string:(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"}})(e),general_level_idc:_,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:v,min_spatial_segmentation_idc:F,constant_frame_rate:0,chroma_format_idc:e,bit_depth_luma_minus8:x,bit_depth_chroma_minus8:C,frame_rate:{fixed:N,fps:z/j,fps_den:j,fps_num:z},sar_ratio:{width:M,height:O},codec_size:{width:W,height:V},present_size:{width:W*K,height:V}}})(i),n=(e=>{let t=Qi(e),i=new Gi(t),r=(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(),i.readBool()),s=i.readBool(),a=1;return s&&r?a=0:s?a=3:r&&(a=2),{parallelismType:a}})(t);r=Object.assign(r,s,a,n);let o=23+(5+e.byteLength)+(5+i.byteLength)+(5+t.byteLength),l=new Uint8Array(o);l[0]=1,l[1]=(3&r.general_profile_space)<<6|(r.general_tier_flag?1:0)<<5|31&r.general_profile_idc,l[2]=r.general_profile_compatibility_flags_1||0,l[3]=r.general_profile_compatibility_flags_2||0,l[4]=r.general_profile_compatibility_flags_3||0,l[5]=r.general_profile_compatibility_flags_4||0,l[6]=r.general_constraint_indicator_flags_1||0,l[7]=r.general_constraint_indicator_flags_2||0,l[8]=r.general_constraint_indicator_flags_3||0,l[9]=r.general_constraint_indicator_flags_4||0,l[10]=r.general_constraint_indicator_flags_5||0,l[11]=r.general_constraint_indicator_flags_6||0,l[12]=60,l[13]=240|(3840&r.min_spatial_segmentation_idc)>>8,l[14]=255&r.min_spatial_segmentation_idc,l[15]=252|3&r.parallelismType,l[16]=252|3&r.chroma_format_idc,l[17]=248|7&r.bit_depth_luma_minus8,l[18]=248|7&r.bit_depth_chroma_minus8,l[19]=0,l[20]=0,l[21]=(3&r.constant_frame_rate)<<6|(7&r.num_temporal_layers)<<3|(r.temporal_id_nested?1:0)<<2|3,l[22]=3,l[23]=160,l[24]=0,l[25]=1,l[26]=(65280&e.byteLength)>>8,l[27]=(255&e.byteLength)>>0,l.set(e,28),l[23+(5+e.byteLength)+0]=161,l[23+(5+e.byteLength)+1]=0,l[23+(5+e.byteLength)+2]=1,l[23+(5+e.byteLength)+3]=(65280&i.byteLength)>>8,l[23+(5+e.byteLength)+4]=(255&i.byteLength)>>0,l.set(i,23+(5+e.byteLength)+5),l[23+(5+e.byteLength+5+i.byteLength)+0]=162,l[23+(5+e.byteLength+5+i.byteLength)+1]=0,l[23+(5+e.byteLength+5+i.byteLength)+2]=1,l[23+(5+e.byteLength+5+i.byteLength)+3]=(65280&t.byteLength)>>8,l[23+(5+e.byteLength+5+i.byteLength)+4]=(255&t.byteLength)>>0,l.set(t,23+(5+e.byteLength+5+i.byteLength)+5);const d=[28,0,0,0,0],h=new Uint8Array(d.length+l.byteLength);return h.set(d,0),h.set(l,d.length),h}function er(e,t){let i=[];i[0]=t?28:44,i[1]=1,i[2]=0,i[3]=0,i[4]=0;const r=new Uint8Array(i.length+e.byteLength);return r.set(i,0),r.set(e,i.length),r}function tr(e){return(126&e[0])>>1}function ir(e){return!(32<=e&&e<=40)}function rr(e){return 16<=e&&e<=21}class sr extends r{constructor(e){super(),this.player=e,this.fileName="",this._isRecording=!1,this._recordingTimestamp=0,this.recordingInterval=null,this.sps=null,this.pps=null,this.vps=null,this.codecId=null,this.mdatBytesLength=0,this.metaInfo={codecWidth:0,codecHeight:0,presentWidth:0,presentHeight:0,refSampleDuration:0,timescale:1e3,avcc:null,videoType:""}}destroy(){this._reset()}get isH264(){return 7===this.codecId}get isH265(){return 12===this.codecId}setFileName(e){this.fileName=e}get isRecording(){return this._isRecording}get recording(){return this._isRecording}get recordTime(){return this._recordingTimestamp}startRecord(){}handleAddNaluTrack(e,t,i,r){}handleAddTrack(e){}stopRecordAndSave(){}startRecordingInterval(){}stopRecordingInterval(){this.recordingInterval&&clearInterval(this.recordingInterval),this.recordingInterval=null}getToTalByteLength(){}_reset(){this.fileName="",this._isRecording=!1,this._recordingTimestamp=0,this.stopRecordingInterval(),this.sps=null,this.pps=null,this.vps=null,this.codecId=null,this.mdatBytesLength=0}initMetaData(e,t){let i;var r=e.slice(5);if(this.codecId=t,this.metaInfo.avcc=r,7===t)i=Vi(r);else if(12===t){i=function(e){var t=23,i=e[23];if(32!=(63&i))return console.warn("parseHEVCDecoderVPSAndSPSAndPPS and vpsTag is "+i),{};t+=2,++t;i=e[27]|e[26]<<8;var r=(t+=2,e.slice(28,28+i)),s=e[t+=i];if(33!=(63&s))return console.warn("parseHEVCDecoderVPSAndSPSAndPPS and sps tag is "+s),{};t+=2;s=e[1+ ++t]|e[t]<<8;var a=e.slice(t+=2,t+s),n=e[t+=s];if(34!=(63&n))return console.warn("parseHEVCDecoderVPSAndSPSAndPPS and pps tag is "+n),{};t+=2,n=e[1+ ++t]|e[t]<<8;const o=e.slice(t+=2,t+n),l=new Uint8Array([s>>>24&255,s>>>16&255,s>>>8&255,255&s]),d=new Uint8Array([n>>>24&255,n>>>16&255,n>>>8&255,255&n]),h=new Uint8Array([i>>>24&255,i>>>16&255,i>>>8&255,255&i]),c=new Uint8Array(4+s),u=(c.set(l,0),c.set(a,4),new Uint8Array(4+n)),p=(u.set(d,0),u.set(o,4),new Uint8Array(4+i));return p.set(h,0),p.set(r,4),{sps:c,pps:u,vps:p}}(r);const t=Xi(e);i=Object.assign(i,t)}i&&(i.vps&&(this.vps=i.vps),i.pps&&(this.pps=i.pps),i.sps&&(this.sps=i.sps),i.presentWidth&&(this.metaInfo.presentWidth=i.presentWidth),i.presentHeight&&(this.metaInfo.presentHeight=i.presentHeight),i.codecWidth&&(this.metaInfo.codecWidth=i.codecWidth),i.codecHeight&&(this.metaInfo.codecHeight=i.codecHeight),i.timescale&&(this.metaInfo.timescale=i.timescale),i.refSampleDuration&&(this.metaInfo.refSampleDuration=i.refSampleDuration),i.videoType&&(this.metaInfo.videoType=i.videoType))}}class ar extends sr{constructor(e){super(e),this.totalByteLength=0,this._startRecordingTimestamp=null,e.debug.log("RecorderRTC","init")}_reset(){super._reset(),this.totalByteLength=0,this._startRecordingTimestamp=null,this.recorder&&(this.recorder.destroy(),this.recorder=null)}destroy(){super.destroy(),this._reset(),this.player.debug.log("RecorderRTC","destroy")}getSeekableBlob(e){const t=new EBML.Reader,i=new EBML.Decoder,r=EBML.tools,s=new FileReader;return new Promise((a,n)=>{s.onload=function(e){i.decode(this.result).forEach((function(e){t.read(e)})),t.stop();var s=r.makeMetadataSeekable(t.metadatas,t.duration,t.cues),n=this.result.slice(t.metadataSize);s=new Blob([s,n],{type:"video/webm"});a(s)},s.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()===A?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),i){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(0<e.getAudioTracks().length){const t=e.getAudioTracks()[0];t&&t.enabled&&i.addTrack(t)}}this.recorder=zi(i,t)}else e.error("RecorderRTC","startRecord error and can not create stream"),this.emit(U.recordCreateError)}catch(t){e.error("RecorderRTC","startRecord error",t),this.emit(U.recordCreateError)}this.recorder&&(this._isRecording=!0,this.player.emit(U.recording,!0),this.recorder.startRecording(),e.log("RecorderRTC","start recording"),this.player.emit(U.recordStart),this.startRecordingInterval())}startRecordingInterval(){this.stopRecordingInterval(),this.recordingInterval=window.setInterval(()=>{this.player.emit(U.recordingTimestamp,this._recordingTimestamp)},1e3)}stopRecordAndSave(){let e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:G,t=1<arguments.length?arguments[1]:void 0;return new Promise((i,r)=>{this.recorder&&this._isRecording||r("recorder is not ready"),t&&this.setFileName(t),this.recorder.stopRecording(()=>{this.player.debug.log("RecorderRTC","stop recording");var t=(this.fileName||qe())+"."+c;if(this.recorder.getBlob(),"blob"===e){const e=this.recorder.getBlob();i(e),this.player.emit(U.recordBlob,e)}else i(),this.recorder.save(t);this.player.emit(U.recordEnd),this._reset(),this.player.emit(U.recording,!1)})})}getToTalByteLength(){return this.totalByteLength}getTotalDuration(){return this.recordTime}getType(){return c}initMetaData(){}}class nr{static init(){for(var e in nr.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:[]},nr.types)nr.types.hasOwnProperty(e)&&(nr.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let t=nr.constants={};t.FTYP=new Uint8Array([105,115,111,109,0,0,2,0,105,115,111,109,105,115,111,50,97,118,99,49,109,112,52,49,0,0,0,0]),t.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),t.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),t.STSC=t.STCO=t.STTS,t.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),t.HDLR_VIDEO=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),t.HDLR_AUDIO=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),t.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),t.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),t.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}static box(e){let t=8,i=null,r=Array.prototype.slice.call(arguments,1),s=r.length;for(let n=0;n<s;n++)t+=r[n].byteLength;(i=new Uint8Array(t))[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 n=0;n<s;n++)i.set(r[n],a),a+=r[n].byteLength;return i}static generateInitSegment(e,t,i){let r=nr.box(nr.types.ftyp,nr.constants.FTYP),s=nr.box(nr.types.free),a=8,n=new Uint8Array;i+a>=Math.pow(2,32)-1?(a=16,(n=new Uint8Array(i+a)).set(new Uint8Array([0,0,0,1]),0),n.set(nr.types.mdat,4),n.set(new Uint8Array([i+8>>>56&255,i+8>>>48&255,i+8>>>40&255,i+8>>>32&255,i+8>>>24&255,i+8>>>16&255,i+8>>>8&255,i+8&255]),8)):((n=new Uint8Array(i+a))[0]=i+8>>>24&255,n[1]=i+8>>>16&255,n[2]=i+8>>>8&255,n[3]=i+8&255,n.set(nr.types.mdat,4));for(let h=0;h<t.length;h++){let e=t[h];e.duration=e.refSampleDuration*e.sequenceNumber;for(let t=0;t<e.sequenceNumber;t++){let i=e.samples[t];i.chunkOffset=r.byteLength+s.byteLength+a;var o=i.data;n.set(o,a),a+=o.byteLength}}let l=nr.moov(e,t),d=new Uint8Array(r.byteLength+l.byteLength+n.byteLength+s.byteLength);return d.set(r,0),d.set(s,r.byteLength),d.set(n,r.byteLength+s.byteLength),d.set(l,r.byteLength+n.byteLength+s.byteLength),d}static moov(e,t){let i=e.timescale,r=e.duration,s=t.length,a=nr.mvhd(i,r),n=new Uint8Array;for(let o=0;o<s;o++){let e=nr.trak(t[o]),i=new Uint8Array(e.byteLength+n.byteLength);i.set(n,0),i.set(e,n.byteLength),(n=new Uint8Array(i.byteLength)).set(i,0)}return nr.box(nr.types.moov,a,n)}static mvhd(e,t){return nr.box(nr.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 nr.box(nr.types.trak,nr.tkhd(e),nr.mdia(e))}static tkhd(e){var t=e.id,i=e.duration,r=e.presentWidth;e=e.presentHeight;return nr.box(nr.types.tkhd,new Uint8Array([0,0,0,15,206,186,253,168,206,186,253,168,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>>8&255,255&r,0,0,e>>>8&255,255&e,0,0]))}static edts(e,t){return nr.box(nr.types.edts,nr.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);var r=e[t].duration;return 0===i&&(i=e[t].refSampleDuration),nr.box(nr.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,r>>>24&255,r>>>16&255,r>>>8&255,255&r,0,0,0,0,0,1,0,0]))}static mdia(e){return nr.box(nr.types.mdia,nr.mdhd(e),nr.hdlr(e),nr.minf(e))}static mdhd(e){var t=e.timescale/e.refSampleDuration;e=t*e.duration/e.timescale;return nr.box(nr.types.mdhd,new Uint8Array([0,0,0,0,206,186,253,168,206,186,253,168,t>>>24&255,t>>>16&255,t>>>8&255,255&t,e>>>24&255,e>>>16&255,e>>>8&255,255&e,85,196,0,0]))}static hdlr(e){var t=nr.constants.HDLR_VIDEO;return nr.box(nr.types.hdlr,t)}static minf(e){var t=nr.box(nr.types.vmhd,nr.constants.VMHD);return nr.box(nr.types.minf,t,nr.dinf(),nr.stbl(e))}static dinf(){return nr.box(nr.types.dinf,nr.box(nr.types.dref,nr.constants.DREF))}static stbl(e){let t=e.samples,i=[{No:1,num:0,sampleDelte:1,chunkNo:1,duration:t[0].duration}],r=[t[0].duration],s=t.length;for(let a=0;a<s;a++)for(let e=0;e<i.length;e++)t[a].duration===i[e].duration?i[e].num++:r.indexOf(t[a].duration)<0&&(r.push(t[a].duration),i.push({No:2,num:0,sampleDelte:1,chunkNo:a+1,duration:t[a].duration}));return nr.box(nr.types.stbl,nr.stsd(e),nr.stts(i),nr.stss(t),nr.stsc(i),nr.stsz(t),nr.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]),r=i.byteLength,s=new Uint8Array(r+8*t);s.set(i,0);for(let a=0;a<t;a++)s.set(new Uint8Array([e[a].num>>>24&255,e[a].num>>>16&255,e[a].num>>>8&255,255&e[a].num,e[a].sampleDelte>>>24&255,e[a].sampleDelte>>>16&255,e[a].sampleDelte>>>8&255,255&e[a].sampleDelte]),r),r+=8;return nr.box(nr.types.stts,s)}static stss(e){let t=[],i=e.length;for(let o=0;o<i;o++)!0===e[o].isKeyframe&&t.push(o+1);let r=t.length,s=new Uint8Array([0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r]),a=s.byteLength,n=new Uint8Array(a+4*r);n.set(s,0);for(let o=0;o<r;o++)n.set(new Uint8Array([t[o]>>>24&255,t[o]>>>16&255,t[o]>>>8&255,255&t[o]]),a),a+=4;return nr.box(nr.types.stss,n)}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]),r=i.byteLength,s=new Uint8Array(r+12*t);s.set(i,0);for(let l=0;l<t;l++){var a=e[l].chunkNo,n=e[l].num,o=e[l].sampleDelte;s.set(new Uint8Array([a>>>24&255,a>>>16&255,a>>>8&255,255&a,n>>>24&255,n>>>16&255,n>>>8&255,255&n,o>>>24&255,o>>>16&255,o>>>8&255,255&o]),r),r+=12}return nr.box(nr.types.stsc,s)}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]),r=i.byteLength,s=new Uint8Array(r+4*t);s.set(i,0);for(let n=0;n<t;n++){var a=e[n].data.byteLength;s.set(new Uint8Array([a>>>24&255,a>>>16&255,a>>>8&255,255&a]),r),r+=4}return nr.box(nr.types.stsz,s)}static stco(e,t){return t=t[0].chunkOffset,nr.box(nr.types.stco,new Uint8Array([0,0,0,0,0,0,0,1,t>>>24&255,t>>>16&255,t>>>8&255,255&t]))}static stsd(e){return"audio"===e.type?"mp3"===e.codec?nr.box(nr.types.stsd,nr.constants.STSD_PREFIX,nr.mp3(e)):nr.box(nr.types.stsd,nr.constants.STSD_PREFIX,nr.mp4a(e)):"avc"===e.videoType?nr.box(nr.types.stsd,nr.constants.STSD_PREFIX,nr.avc1(e)):nr.box(nr.types.stsd,nr.constants.STSD_PREFIX,nr.hvc1(e))}static mp3(e){var t=e.channelCount;e=e.audioSampleRate,t=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,e>>>8&255,255&e,0,0]);return nr.box(nr.types[".mp3"],t)}static mp4a(e){var t=e.channelCount,i=e.audioSampleRate;t=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,i>>>8&255,255&i,0,0]);return nr.box(nr.types.mp4a,t,nr.esds(e))}static esds(e){e=e.config||[];var t=e.length;t=new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e).concat([6,1,2]));return nr.box(nr.types.esds,t)}static avc1(e){var t=e.avcc,i=e.codecWidth;e=e.codecHeight,i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,i>>>8&255,255&i,e>>>8&255,255&e,0,72,0,0,0,72,0,0,0,0,0,0,0,1,13,106,101,115,115,105,98,117,99,97,45,112,114,111,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return nr.box(nr.types.avc1,i,nr.box(nr.types.avcC,t))}static hvc1(e){var t=e.avcc,i=e.codecWidth;e=e.codecHeight,i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,i>>>8&255,255&i,e>>>8&255,255&e,0,72,0,0,0,72,0,0,0,0,0,0,0,1,13,106,101,115,115,105,98,117,99,97,45,112,114,111,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return nr.box(nr.types.hvc1,i,nr.box(nr.types.hvcC,t))}static mvex(e){return nr.box(nr.types.mvex,nr.trex(e))}static trex(e){return e=e.id,e=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]),nr.box(nr.types.trex,e)}static moof(e,t){return nr.box(nr.types.moof,nr.mfhd(e.sequenceNumber),nr.traf(e,t))}static mfhd(e){return e=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e]),nr.box(nr.types.mfhd,e)}static traf(e,t){var i=e.id,r=(i=nr.box(nr.types.tfhd,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),t=nr.box(nr.types.tfdt,new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t])),nr.sdtp(e));e=nr.trun(e,r.byteLength+16+16+8+16+8+8);return nr.box(nr.types.traf,i,t,e,r)}static sdtp(e){let t=e.samples||[],i=t.length,r=new Uint8Array(4+i);for(let a=0;a<i;a++){var s=t[a].flags;r[a+4]=s.isLeading<<6|s.dependsOn<<4|s.isDependedOn<<2|s.hasRedundancy}return nr.box(nr.types.sdtp,r)}static trun(e,t){let i=e.samples||[],r=i.length,s=12+16*r,a=new Uint8Array(s);t+=8+s,a.set([0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,255&r,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0);for(let h=0;h<r;h++){var n=i[h].duration,o=i[h].size,l=i[h].flags,d=i[h].cts;a.set([n>>>24&255,n>>>16&255,n>>>8&255,255&n,o>>>24&255,o>>>16&255,o>>>8&255,255&o,l.isLeading<<2|l.dependsOn,l.isDependedOn<<6|l.hasRedundancy<<4|l.isNonSync,0,0,d>>>24&255,d>>>16&255,d>>>8&255,255&d],12+16*h)}return nr.box(nr.types.trun,a)}static mdat(e){return nr.box(nr.types.mdat,e)}}nr.init();class or extends sr{constructor(e){super(e),this.tagName="recorderMP4",this.totalDuration=0,this.totalByteLength=0,this.bufferList=[],this.cacheTrack={},this.sequenceNumber=0,e.debug.log(this.tagName,"init")}destroy(){super.destroy(),this._reset(),this.player.debug.log(this.tagName,"destroy")}_reset(){super._reset(),this.totalDuration=0,this.totalByteLength=0,this.sequenceNumber=0,this.cacheTrack={},this.bufferList=[]}startRecord(){const e=this.player.debug;this._isRecording=!0,this.player.emit(U.recording,!0),e.log(this.tagName,"start recording"),this.player.emit(U.recordStart),this.startRecordingInterval()}startRecordingInterval(){this.stopRecordingInterval(),this.recordingInterval=window.setInterval(()=>{this.player.emit(U.recordingTimestamp,this.getTotalDuration())},1e3)}formatFmp4Track(e,t,i,r){return{id:1,sequenceNumber:++this.sequenceNumber,size:e.byteLength,dts:i,cts:r,isKeyframe:t,data:e,duration:0,flags:{isLeading:0,dependsOn:t?2:1,isDependedOn:t?1:0,hasRedundancy:0,isNonSync:t?0:1}}}handleAddNaluTrack(e,t,i,r){this.cacheTrack.id&&i>=this.cacheTrack.dts?(this.cacheTrack.duration=i-this.cacheTrack.dts,this.handleAddFmp4Track(this.cacheTrack)):this.cacheTrack={},this.cacheTrack=this.formatFmp4Track(e,t,i,r)}handleAddFmp4Track(e){if(this.isRecording)if(null!==this.sps&&null!==this.pps||!this.isH264)if(null!==this.sps&&null!==this.pps&&null!==this.vps||!this.isH265){const i=Object.assign({},e);i.pts=i.dts+i.cts;var t=i.data;if(i.isKeyframe)if(this.isH264){const e=new Uint8Array(this.sps.byteLength+this.pps.byteLength),r=(e.set(this.sps,0),e.set(this.pps,this.sps.byteLength),new Uint8Array(e.byteLength+t.byteLength));r.set(e,0),r.set(t,e.byteLength),i.data=r}else if(this.isH265){const e=new Uint8Array(this.sps.byteLength+this.pps.byteLength+this.vps.byteLength),r=(e.set(this.vps,0),e.set(this.sps,this.vps.byteLength),e.set(this.pps,this.vps.byteLength+this.sps.byteLength),new Uint8Array(e.byteLength+t.byteLength));r.set(e,0),r.set(t,e.byteLength),i.data=r}i.size=i.data.byteLength,this.totalDuration+=i.duration,this.totalByteLength+=i.data.byteLength,i.duration=0,i.originalDts=i.dts,delete i.id,delete i.sequenceNumber,this.bufferList.push(i)}else this.player.debug.error(this.tagName,"handleAddFmp4Track, is h265 and this.sps or this.pps or this.vps is null ");else this.player.debug.error(this.tagName,"handleAddFmp4Track, is h264 and this.sps or this.pps is null ");else this.player.debug.error(this.tagName,"handleAddFmp4Track, isRecording is false ")}getTotalDuration(){return this.totalDuration/1e3}getType(){return h}getToTalByteLength(){return this.totalByteLength}stopRecordAndSave(){let e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:G,t=1<arguments.length?arguments[1]:void 0;return new Promise((i,r)=>{if(!this.isRecording)return this.player.debug.error(this.tagName,"stop recording fail, isRecording is false "),r("stop recording fail, isRecording is false ");if(0===this.bufferList.length)return this.player.debug.error(this.tagName,"stop recording fail, this.bufferList.length is 0 "),r("stop recording fail, this.bufferList.length is 0 ");if(t&&this.setFileName(t),r={id:1,type:"video",sps:this.sps,pps:this.pps,samples:this.bufferList,sequenceNumber:this.bufferList.length,length:0,addSampleNum:1,duration:0,...this.metaInfo},r=nr.generateInitSegment({timescale:1e3,duration:this.totalDuration},[r],this.totalByteLength),this.player.debug.log(this.tagName,"stop recording"),r=new Blob([r],{type:"application/octet-stream"}),"blob"===e)i(r),this.player.emit(U.recordBlob,r);else{i();{i=(this.fileName||qe())+"."+h;let e=window.URL.createObjectURL(r),t=window.document.createElement("a"),s=(t.download=i,t.href=e,window.document.createEvent("MouseEvents"));s.initEvent("click",!0,!0),t.dispatchEvent(s),setTimeout(()=>{window.URL.revokeObjectURL(e)},nt()?1e3:0)}}this._reset(),this.player.emit(U.recording,!1)})}}class lr{constructor(e){return new(lr.getLoaderFactory(e._opt))(e)}static getLoaderFactory(e){return e.recordType===h&&(e.useWasm||e.useMSE||e.useWCS)?or:ar}}class dr{constructor(e){this.player=e,this.destroyResolve=null,this.workerClearTimeout=null;let t=e._opt.decoder,i=!1;if(0===(t=$t(this.player._opt.useWasm)?e._opt.decoderAudio:t).indexOf("http")&&this.player._opt.isDecoderUseCDN){const e=new Blob([`importScripts("${t}")`],{type:"application/javascript"});t=window.URL.createObjectURL(e),i=!0,this.workerClearTimeout=setTimeout(()=>{window.URL.revokeObjectURL(t),this.workerClearTimeout=null},E)}this.decoderWorker=new Worker(t),this._initDecoderWorker(),e.debug.log("decoderWorker","init and decoder url is "+(i?"":t)),e.on(U.visibilityChange,()=>{this.updateWorkConfig({key:"visibility",value:e.visibility})})}destroy(){return new Promise((e,t)=>{this.player.loaded?(this.player.debug.log("decoderWorker","has loaded and post message to destroy"),this.decoderWorker?(this.decoderWorker.postMessage({cmd:"close"}),this.destroyResolve=e):(this.player.debug.warn("decoderWorker","has loaded but decoderWorker is null and destroy directly"),this._destroy(),setTimeout(()=>{e()},0))):(this.player.debug.log("decoderWorker","has not loaded and destroy directly"),this._destroy(),setTimeout(()=>{e()},0))})}_destroy(){this.workerClearTimeout&&(clearTimeout(this.workerClearTimeout),this.workerClearTimeout=null),this.decoderWorker&&(this.decoderWorker.terminate(),this.decoderWorker=null),this.player.debug.log("decoderWorker","destroy"),this.destroyResolve&&(this.destroyResolve(),this.destroyResolve=null)}_initDecoderWorker(){const{debug:e,events:{}}=this.player;this.decoderWorker.onmessage=t=>{const i=t.data;switch(i.cmd){case x:e.log("decoderWorker","onmessage:",x),this.decoderWorker&&this._initWork(),this.player.loaded||this.player.emit(U.load),this.player.emit(U.decoderWorkerInit);break;case R:e.log("decoderWorker","onmessage:",R,i.code),this.player._times.decodeStart||(this.player._times.decodeStart=qe()),this.player.video.updateVideoInfo({encTypeCode:i.code});break;case I:e.log("decoderWorker","onmessage:",I,i.codecId),this.player.recorder&&this.player.recorder.initMetaData(i.buffer,i.codecId);break;case D:e.log("decoderWorker","onmessage:",D,i.code),this.player.audio&&this.player.audio.updateAudioInfo({encTypeCode:i.code});break;case C:if(e.log("decoderWorker","onmessage:",C,`width:${i.w},height:`+i.h),this.player.video.updateVideoInfo({width:i.w,height:i.h}),!this.player._opt.openWebglAlignment&&i.w/2%4!=0&&this.player.getRenderType()===A)return void this.player.emitError(O.webglAlignmentError);this.player.video.initCanvasViewSize(),this.player._opt.playType===d&&(this.player.video.initFps(),this.player.video.initVideoDelay());break;case L:if(e.log("decoderWorker","onmessage:",L,`channels:${i.channels},sampleRate:`+i.sampleRate),2<i.channels)return void this.player.emitError(O.audioChannelError,`audio channel is ${i.channels}, max is 2`);this.player.audio&&(this.player.audio.updateAudioInfo(i),this.player._opt.playType===o?this.player.audio.initScriptNode():this.player._opt.playType===d&&this.player.audio.initScriptNodeDelay());break;case"render":if(!this.player.video)return void e.warn("decoderWorker","onmessage render but video is null");if(this.player.isPlayer()){if($t(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(U.timeUpdate,i.ts),this.player.updateStats({dfps:!0,buf:i.delay}),this.player._times.videoStart||(this.player._times.videoStart=qe(),this.player.handlePlayToRenderTimes())}else this.player.isPlayback()&&(this.player.updateStats({dfps:!0}),$t(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"videoNalu":this.player.recorder&&this.player.recorder.isRecording&&this.player._opt.recordType===h&&this.player.recorder.handleAddNaluTrack(i.buffer,i.isIFrame,i.ts,i.cts);break;case"videoPayload":const{webcodecsDecoder:t,mseDecoder:r}=this.player;this.player._opt.useWCS&&!this.player._opt.useOffscreen?t.decodeVideo(i.payload,i.ts,i.isIFrame,i.cts):this.player._opt.useMSE&&r.decodeVideo(i.payload,i.ts,i.isIFrame,i.cts);break;case"playAudio":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===o||this.player._opt.playType===d&&($t(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"workerFetch":if(i.type===U.streamSuccess)this.player.stream?this.player.stream.emit(U.streamSuccess):e.warn("decoderWorker","onmessage and workerFetch response stream success but stream is null");else if(i.type===U.streamRate)this.player.emit(U.kBps,(i.value/1024).toFixed(2));else if(i.type===U.streamEnd)this.player?(i.value===a&&this.player.emit(U.websocketClose),this.player.stream?this.player.stream.emit(U.streamEnd):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===O.websocketError)this.player&&this.player.stream?this.player.stream.emit(O.websocketError,i.value):e&&e.warn("decoderWorker","onmessage and workerFetch response websocket error but stream is null");else if(i.type===O.fetchError)this.player&&this.player.stream?this.player.stream.emit(O.fetchError,i.value):e&&e.warn("decoderWorker","onmessage and workerFetch response fetch error but stream is null");else if(i.type===U.streamAbps)this.player.updateStats({abps:i.value});else if(i.type===U.streamVbps)this.player._times.demuxStart||(this.player._times.demuxStart=qe()),this.player.updateStats({vbps:i.value});else if(i.type===U.streamDts)this.player.updateStats({dts:i.value});else if(i.type===U.netBuf)this.player.updateStats({netBuf:i.value});else if(i.type===U.networkDelayTimeout)this.player.emit(U.networkDelayTimeout,i.value);else if(i.type===U.streamStats){const e=JSON.parse(i.value);this.player.updateStats({workerStats:e})}else i.type===U.websocketOpen&&this.player.emit(U.websocketOpen);break;case"iframeIntervalTs":this.player&&(this.player.videoIframeIntervalTs=i.value);break;case"playbackStreamVideoFps":this.player&&this.player.video&&this.player.video.setStreamFps(i.value);break;case"wasmError":i.message&&-1!==i.message.indexOf("Invalid NAL unit size")&&this.player.emitError(O.wasmDecodeError,"");break;case"wasmDecodeVideoNoResponseError":this.player.emitError(O.wasmDecodeVideoNoResponseError);break;case"simdH264DecodeVideoWidthIsTooLarge":this.player.emitError(O.simdH264DecodeVideoWidthIsTooLarge);break;case"wasmWidthOrHeightChange":this.player.emitError(O.wasmWidthOrHeightChange);break;case"simdDecodeError":this.player.emitError(O.simdDecodeError);break;case P:e.log("decoderWorker","onmessage:",P);break;case B:e.log("decoderWorker","onmessage:",B),this._destroy();break;case"tempStream":this.player&&this.player.pushTempStream(i.buffer);break;case"videoSEI":this.player&&this.player.emit(U.videoSEI,{ts:i.ts,data:new Uint8Array(i.buffer)});break;default:this.player[i.cmd]&&this.player[i.cmd](i)}}}_initWork(){var 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,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,isNakedFlow:this.player._opt.isNakedFlow,checkFirstIFrame:this.player._opt.checkFirstIFrame,isCrypto:this.player._opt.isCrypto,isHls265:this.player.isUseHls265(),isFmp4Private:this.player._opt.isFmp4Private,isSm4Crypto:this.player._opt.isSm4Crypto,sm4CryptoKey:this.player._opt.sm4CryptoKey,isEmitSEI:this.player._opt.isEmitSEI};this.decoderWorker.postMessage({cmd:"init",opt:JSON.stringify(e)}),this.player._opt.isCrypto&&(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===o?this.player.isUseHls265()?this._decodeVideoNoDelay(e,t,i):this._decodeVideo(e,t,i):this.player._opt.playType===d&&(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){t={type:2,ts:Math.max(t,0),isIFrame:i},this.decoderWorker.postMessage({cmd:"decode",buffer:e,options:t},[e.buffer])}_decodeVideoNoDelay(e,t,i){this.decoderWorker.postMessage({cmd:"videoDecode",buffer:e,ts:Math.max(t,0),isIFrame:i},[e.buffer])}decodeAudio(e,t){this.player._opt.playType===o?this.player._opt.useWCS||this.player._opt.useMSE||this.player.isUseHls265()?this._decodeAudioNoDelay(e,t):this._decodeAudio(e,t):this.player._opt.playType===d&&(1===this.player.video.rate?this._decodeAudio(e,t):this._decodeAudioNoDelay(e,t))}_decodeAudio(e,t){t={type:1,ts:Math.max(t,0)},this.decoderWorker.postMessage({cmd:"decode",buffer:e,options:t},[e.buffer])}_decodeAudioNoDelay(e,t){this.decoderWorker.postMessage({cmd:"audioDecode",buffer:e,ts:Math.max(t,0)},[e.buffer])}updateWorkConfig(e){this.decoderWorker&&this.decoderWorker.postMessage({cmd:"updateConfig",key:e.key,value:e.value})}workerFetchStream(e){var t=this.player["_opt"];t={protocol:t.protocol,isFlv:t.isFlv,isFmp4:t.isFmp4,isMpeg4:t.isMpeg4,isNakedFlow:t.isNakedFlow};this.decoderWorker.postMessage({cmd:"fetchStream",url:e,opt:JSON.stringify(t)})}clearWorkBuffer(){this.decoderWorker.postMessage({cmd:"clearBuffer",needClear:0<arguments.length&&void 0!==arguments[0]&&arguments[0]})}workerSendMessage(e){this.decoderWorker.postMessage({cmd:"sendWsMessage",message:e})}}function hr(e){const t=e.byteLength,i=new Uint8Array(4),r=(i[0]=t>>>24&255,i[1]=t>>>16&255,i[2]=t>>>8&255,i[3]=255&t,new Uint8Array(t+4));return r.set(i,0),r.set(e,4),r}class cr extends r{constructor(e){super(),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.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.off(),this.player.debug.log("CommonDemux","destroy")}isDropping(){return this.dropping||this.isPushDropping}getDelay(e){return e&&this.player.isDemuxDecodeFirstIIframeInit()?(this.preDelayTimestamp&&this.preDelayTimestamp>e?1e3<this.preDelayTimestamp-e&&this.player.debug.warn("CommonDemux",`getDelay and preDelayTimestamp is ${this.preDelayTimestamp} > timestamp is ${e} more than ${this.preDelayTimestamp-e}ms`):this.firstTimestamp?e&&(t=Date.now()-this.startTimestamp,(i=e-this.firstTimestamp)<=t?(this.isStreamTsMoreThanLocal=!1,this.delay=t-i):(this.isStreamTsMoreThanLocal=!0,this.delay=i-t)):(this.firstTimestamp=e,this.startTimestamp=Date.now(),this.delay=-1),this.preDelayTimestamp=e,this.delay):-1;var t,i}getDelayNotUpdateDelay(e){if(!e||!this.player.isDemuxDecodeFirstIIframeInit())return-1;if(this.preDelayTimestamp&&1e3<this.preDelayTimestamp-e)return this.player.debug.warn("CommonDemux",`getDelayNotUpdateDelay and preDelayTimestamp is ${this.preDelayTimestamp} > timestamp is ${e} more than ${this.preDelayTimestamp-e}ms`),-1;if(this.firstTimestamp){let i=-1;var t;return e&&(t=Date.now()-this.startTimestamp,e-=this.firstTimestamp,i=e<=t?t-e:e-t),i}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(n)?this.player.isPlaybackCacheBeforeDecodeForFpsRender()?this.player.debug.log("CommonDemux","initInterval() and playback and playbackIsCacheBeforeDecodeForFpsRender is true so return"):(this.player.debug.log("CommonDemux","initInterval()"),this._loop(),this.stopId=setInterval(()=>{var e=(new Date).getTime();this.preLoopTimestamp||(this.preLoopTimestamp=e),e-=this.preLoopTimestamp;this.updateHistoryIntervalDiffTimeList(e),100<e&&this.player.debug.warn("CommonDemux","loop demux diff time is "+e),this._loop(),this.preLoopTimestamp=(new Date).getTime()},10)):this.player.debug.log("CommonDemux","initInterval() and is worker stream so return")}clearStopInterval(){this.stopId&&(clearInterval(this.stopId),this.stopId=null)}updateHistoryIntervalDiffTimeList(e){5<this.historyIntervalDiffTimeList.length&&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();var e=()=>{var e;this.bufferList.length&&(e=this.bufferList.shift(),this._doDecoderDecode(e))},t=(e(),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,r=this.player._opt.playType===o;if(this.bufferList.length)if(this.isPushDropping)this.player.debug.warn("CommonDemux","_loop isPushDropping is true and bufferList length is "+this.bufferList.length);else if(this.player._opt.useMSE&&this.player.mseDecoder&&this.player.mseDecoder.getSourceBufferUpdating())this.player.debug.warn("CommonDemux","_loop getSourceBufferUpdating is true and bufferList length is "+this.bufferList.length);else if(this.dropping){e=this.bufferList.shift();const t=this.getDelayNotUpdateDelay(e.ts);for(this.player.debug.warn("CommonDemux",`_loop is dropping and data.ts is ${e.ts}, data.isIFrame is ${e.isIFrame} tempDelay is ${t}, delay is `+this.delay);!e.isIFrame&&this.bufferList.length;)e=this.bufferList.shift();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))}else e=this.bufferList[0],-1===this.getDelay(e.ts)||this.player.isPlayback()?(this.player.isPlayer()&&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.delay>i+t&&r?this.hasIframeInBufferList()?(this.player.debug.warn("CommonDemux",`_loop delay is ${this.delay}, set dropping is true`),this.resetAllDelay(),this.dropping=!0):(this.bufferList.shift(),this._doDecoderDecode(e)):this.delay>t?(this.bufferList.shift(),this._doDecoderDecode(e)):this.delay<0&&this.player.debug.warn("CommonDemux",`_loop delay is ${this.delay} bufferList is `+this.bufferList);else-1!==this.delay&&this.player.debug.log("CommonDemux","loop() bufferList is empty and reset delay"),this.resetAllDelay()}_doDecode(e,t,i,r){const s=this.player;let a={ts:i,cts:4<arguments.length&&void 0!==arguments[4]?arguments[4]:0,type:t,isIFrame:!1};this.player.isPlayer()?(2===t&&s._opt.playType===o&&this.calcNetworkDelay(i),s._opt.useWCS&&!s._opt.useOffscreen||s._opt.useMSE?(2===t&&(a.isIFrame=r),this.pushBuffer(e,a)):2===t?s.decoderWorker&&s.decoderWorker.decodeVideo(e,i,r):1===t&&s._opt.hasAudio&&s.decoderWorker&&s.decoderWorker.decodeAudio(e,i)):this.player.isPlayback()&&(2===t&&(a.isIFrame=r),this.player.isPlaybackOnlyDecodeIFrame()?2===t&&r&&this.pushBuffer(e,a):this.player.isPlaybackCacheBeforeDecodeForFpsRender()||1===this.player.getPlaybackRate()?this.pushBuffer(e,a):2===t?this._doDecoderDecode({ts:a.ts,cts:a.cts,payload:e,type:2,isIFrame:a.isIFrame}):1===t&&s.decoderWorker&&s.decoderWorker.decodeAudio(e,i))}_doDecodeByHls(e,t,i,r){var s=4<arguments.length&&void 0!==arguments[4]?arguments[4]:0;const a=this.player,{webcodecsDecoder:n,mseDecoder:o}=a;2===t?a._opt.useWCS&&!a._opt.useOffscreen?n.decodeVideo(e,i,r,s):a._opt.useMSE?o.decodeVideo(e,i,r,s):a.decoderWorker&&a.decoderWorker.decodeVideo(e,i,r):1===t&&a._opt.hasAudio&&a.decoderWorker&&a.decoderWorker.decodeAudio(e,i)}_doDecodeByFmp4(e,t,i,r){this._doDecode(e,t,i,r,4<arguments.length&&void 0!==arguments[4]?arguments[4]:0)}_doDecoderDecode(e){const t=this.player,{webcodecsDecoder:i,mseDecoder:r}=t;1===e.type?t._opt.hasAudio&&t.decoderWorker&&t.decoderWorker.decodeAudio(e.payload,e.ts):2===e.type&&(t._opt.useWCS&&!t._opt.useOffscreen?i.decodeVideo(e.payload,e.ts,e.isIFrame,e.cts):t._opt.useMSE&&r.decodeVideo(e.payload,e.ts,e.isIFrame,e.cts))}pushBuffer(e,t){const i=this.player._opt.videoBuffer,r=this.player._opt.videoBufferDelay,s=this.player.isPlayer();if(1===t.type&&e[0]>>4==10&&0===e[1])return this.player.debug.log("CommonDemux",`pushBuffer audio ts is ${t.ts}, isAacCodecPacket is true`),void this._doDecoderDecode({ts:t.ts,payload:e,type:1});if(2===t.type&&t.isIFrame&&Vt(e))return this.player.debug.log("CommonDemux",`pushBuffer video ts is ${t.ts}, isVideoSequenceHeader is true`),void this._doDecoderDecode({ts:t.ts,payload:e,type:2,isIFrame:t.isIFrame,cts:t.cts});if(s){if(0<this.preTimestampDuration&&0<this.preTimestamp&&2===t.type){const e=t.ts-this.preTimestamp;e>=2*this.preTimestampDuration-5&&this.player.debug.warn("CommonDemux",`pushBuffer video\n ts is ${t.ts}, preTimestamp is ${this.preTimestamp},\n diff is ${e} and preTimestampDuration is ${this.preTimestampDuration}\n maybe trigger black screen or flower screen`)}if(0<this.preTimestamp&&t.ts<this.preTimestamp&&2===t.type&&36e5<this.preTimestamp-t.ts&&(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&&0<this.preTimestamp&&2===t.type&&this.player.debug.warn("CommonDemux",`pushBuffer video\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.isDemuxDecodeFirstIIframeInit()){var a=this.getDelayNotUpdateDelay(t.ts);this.pushLatestDelay=a;const e=r+i;this.player._opt.useMSE?a>e&&this.delay<e&&0<this.delay&&this.hasIframeInBufferList()&&!1===this.isPushDropping&&!1===this.player.mseDecoder.getSourceBufferUpdating()&&(this.player.debug.warn("CommonDemux",`useMSE, pushLatestDelay is ${a} > ${r+i}, bufferList is ${this.bufferList.length}, delay is ${this.delay} and dropBuffer$2()`),this.dropBuffer$2()):a>e&&this.delay<e&&0<this.delay&&this.hasIframeInBufferList()&&!1===this.isPushDropping&&(this.player.debug.warn("CommonDemux",`useWCS, pushLatestDelay is ${a} > ${r+i},bufferList is ${this.bufferList.length}, delay is ${this.delay} and dropBuffer$2()`),this.dropBuffer$2()),this.isHistoryIntervalDiffTimeAllLarge()&&$t(this.player.visibility)&&(this.player._opt.useMSE?this.hasIframeInBufferList()&&!1===this.isPushDropping&&!1===this.player.mseDecoder.getSourceBufferUpdating()&&(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()))}}if(2===t.type&&(0<this.preTimestamp&&(this.preTimestampDuration=t.ts-this.preTimestamp),this.prevPayloadBufferSize=e.byteLength,this.preTimestamp=t.ts),1===t.type?this.bufferList.push({ts:t.ts,payload:e,type:1}):2===t.type&&this.bufferList.push({ts:t.ts,cts:t.cts,payload:e,type:2,isIFrame:t.isIFrame}),this.player.isPlaybackCacheBeforeDecodeForFpsRender()&&(bt(this.playbackStreamVideoFps)||bt(this.playbackStreamAudioFps))){let e=this.playbackStreamVideoFps,t=this.playbackStreamAudioFps;bt(this.playbackStreamVideoFps)&&0<(e=jt(this.bufferList,2))&&(this.playbackStreamVideoFps=e,this.player.video&&this.player.video.setStreamFps(this.playbackStreamVideoFps),this.playbackStreamFps=t?e+t:e,this.initPlaybackCacheLoop()),bt(this.playbackStreamAudioFps)&&0<(t=jt(this.bufferList,1))&&(this.playbackStreamAudioFps=t,this.playbackStreamFps=e?e+t:t,this.initPlaybackCacheLoop()),bt(this.playbackStreamVideoFps)&&bt(this.playbackStreamAudioFps)&&this.player.debug.log("CommonDemux",`playbackCacheBeforeDecodeForFpsRender, calc streamAudioFps is ${t}, streamVideoFps is ${e}, bufferListLength is `+this.bufferList.length)}}dropBuffer$2(){if(0<this.bufferList.length){this.isPushDropping=!0;let r=this.bufferList.findIndex(e=>Kt(e.isIFrame)&&2===e.type);if(this.isAllIframeInBufferList())for(let t=0;t<this.bufferList.length;t++){var e=this.bufferList[t];e=this.getDelayNotUpdateDelay(e.ts);if(e>=this.getNotDroppingDelayTs()){this.player.debug.log("CommonDemux",`dropBuffer$2() isAllIframeInBufferList() is true, and index is ${t} and tempDelay is ${e} and notDroppingDelayTs is `+this.getNotDroppingDelayTs()),r=t;break}}var t,i;0<=r?(this.bufferList=this.bufferList.slice(r),t=this.bufferList.shift(),i=this.getDelayNotUpdateDelay(t.ts),this._doDecoderDecode(t),this.isPushDropping=!1,this.player.debug.log("CommonDemux",`dropBuffer$2() iFrameIndex is ${r},and bufferList length is ${this.bufferList.length} and tempDelay is ${i} ,delay is ${this.delay} `)):this.isPushDropping=!1}0===this.bufferList.length&&(this.isPushDropping=!1)}clearBuffer(){var e=0<arguments.length&&void 0!==arguments[0]&&arguments[0];this.player.debug.log("CommonDemux",`clearBuffer,buffer length is ${this.bufferList.length}, need clear is `+e),e&&(this.bufferList=[]),this.resetAllDelay(),this.dropping=!0}calcNetworkDelay(e){var t,i,r;this.player.isDemuxDecodeFirstIIframeInit()&&0<e&&(null===this.bufferStartDts?(this.bufferStartDts=e,this.bufferStartLocalTs=qe()):e<this.bufferStartDts&&(this.player.debug.warn("CommonDemux",`calcNetworkDelay dts is ${e} and bufferStartDts is `+this.bufferStartDts),this.bufferStartDts=e,this.bufferStartLocalTs=qe()),(r=(t=e-this.bufferStartDts)<(i=qe()-this.bufferStartLocalTs)?i-t:0)>this.player._opt.networkDelay&&this.player._opt.playType===o&&(this.player.debug.warn("CommonDemux",`delay is more than networkDelay and now dts:${e},start dts is ${this.bufferStartDts}, vs start is ${t},local diff is ${i} ,delay is ${r}, _opt.networkDelay is `+this.player._opt.networkDelay),this.player.emit(U.networkDelayTimeout,r)),this.player.updateStats({netBuf:r}))}calcIframeIntervalTimestamp(e){var t;null===this.preIframeTs?this.preIframeTs=e:this.preIframeTs<e&&(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=>{2===t.type&&(e+=1)}),e}hasIframeInBufferList(){return this.bufferList.some(e=>2===e.type&&e.isIFrame)}isAllIframeInBufferList(){var e=this.getVideoBufferLength();let t=0;return this.bufferList.forEach(e=>{2===e.type&&e.isIFrame&&(t+=1)}),e===t}getInputByteLength(){return 0}getIsStreamTsMoreThanLocal(){return this.isStreamTsMoreThanLocal}close(){}reset(){}findSei(e,t){const i=function(e,t){var i=1<arguments.length&&void 0!==t?t:4;if(!(e.length<4)){const t=e.length,r=[];let s,a=0;for(;a+i<t;)if(s=function(e,t){return(e[t=1<arguments.length&&void 0!==t?t:0]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+(e[t+3]||0)}(e,a),3===i&&(s>>>=8),a+=i,s){if(a+s>t)break;r.push(e.subarray(a,a+s)),a+=s}return r}}(e.slice(5)),r=this.player.video.encType===V;i.forEach(e=>{var i=r?e[0]>>>1&63:31&e[0];(r&&(40==i||39==i)||$t(r)&&i===Y)&&this.player.emit(U.videoSEI,{ts:t,data:e})})}}const ur=Symbol(32),pr=Symbol(16),fr=Symbol(8);class mr{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 t=this,s=function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise((t,i)=>{this.reject=i,this.resolve=e=>{delete this.lastReadPromise,delete this.resolve,delete this.need,t(e)},this.demand(e,!0)||null==(i=this.pull)||i.call(this,e)})},new(r=(r=i=void 0)||Promise)((function(e,a){function n(e){try{l(s.next(e))}catch(e){a(e)}}function o(e){try{l(s.throw(e))}catch(e){a(e)}}function l(t){var i;t.done?e(t.value):((i=t.value)instanceof r?i:new r((function(e){e(i)}))).then(n,o)}l((s=s.apply(t,i||[])).next())}));var t,i,r,s}readU32(){return this.read(ur)}readU16(){return this.read(pr)}readU8(){return this.read(fr)}close(){var e;this.g&&this.g.return(),this.buffer&&this.buffer.subarray(0,0),null!=(e=this.reject)&&e.call(this,new Error("EOF")),delete this.lastReadPromise}flush(){if(this.buffer&&this.need){let t=null;const i=this.buffer.subarray(this.consumed);let r=0;var e=e=>i.length<(r=e);if("number"==typeof this.need){if(e(this.need))return;t=i.subarray(0,r)}else if(this.need===ur){if(e(4))return;t=i[0]<<24|i[1]<<16|i[2]<<8|i[3]}else if(this.need===pr){if(e(2))return;t=i[0]<<8|i[1]}else if(this.need===fr){if(e(1))return;t=i[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(e(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(i.subarray(0,r)),t=this.need}else if(this.g)return void this.g.throw(new Error("Unsupported type"))}else{if(e(this.need.byteLength))return;new Uint8Array(this.need).set(i.subarray(0,r)),t=this.need}return this.consumed+=r,this.g?this.demand(this.g.next(t).value,!0):this.resolve&&this.resolve(t),t}}write(e){if(e instanceof Uint8Array?this.malloc(e.length).set(e):"buffer"in e?this.malloc(e.byteLength).set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):this.malloc(e.byteLength).set(new Uint8Array(e)),!this.g&&!this.resolve)return new Promise(e=>this.pull=e);this.flush()}writeU32(e){this.malloc(4).set([e>>24&255,e>>16&255,e>>8&255,255&e]),this.flush()}writeU16(e){this.malloc(2).set([e>>8&255,255&e]),this.flush()}writeU8(e){this.malloc(1)[0]=e,this.flush()}malloc(e){if(this.buffer){var t=this.buffer.length,i=t+e;if(i<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,i);else{const e=new Uint8Array(i);e.set(this.buffer),this.buffer=e}return this.buffer.subarray(t,i)}return this.buffer=new Uint8Array(e),this.buffer}}mr.U32=ur,mr.U16=pr,mr.U8=fr;var gr,yr="application/json, text/javascript",Ar="text/html",br=/^(?:text|application)\/xml/i,vr=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,_r=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,wr=/^\s*$/,Sr={},Er={},Tr="",kr={type:"GET",beforeSend:xr,success:xr,error:xr,complete:xr,context:null,xhr:function(){return new window.XMLHttpRequest},accepts:{json:yr,xml:"application/xml, text/xml",html:Ar,text:"text/plain","*":"*/".concat("*")},crossDomain:!1,timeout:0,username:null,password:null,processData:!0,promise:xr,contentType:"application/x-www-form-urlencoded; charset=UTF-8"};function xr(){}function Cr(e,t){"object"==typeof e&&(t=e,e=void 0);var i,r=Ur({},t=t||{});for(i in kr)void 0===r[i]&&(r[i]=kr[i]);try{var s={},a=new Promise((function(e,t){s.resolve=e,s.reject=t}));a.resolve=s.resolve,a.reject=s.reject,r.promise=a}catch(e){r.promise={resolve:xr,reject:xr}}a=_r.exec(window.location.href.toLowerCase())||[];var n,o,l,d,h,c=(r.url=((e||r.url||window.location.href)+"").replace(/#.*$/,"").replace(/^\/\//,a[1]+"//"),r.url),u=(r.crossDomain||(r.crossDomain=/^([\w-]+:)?\/\/([^\/]+)/.test(r.url)&&RegExp.$2!==window.location.href),r.dataType);if("jsonp"===u)return/=\?/.test(r.url)||(a=(r.jsonp||"callback")+"=?",r.url=Pr(r.url,a)),l=(n=r).jsonpCallback||"jsonp"+Or(),d=window.document.createElement("script"),h={abort:function(){l in window&&(window[l]=xr)}},a=window.document.getElementsByTagName("head")[0]||window.document.documentElement,d.onerror=function(e){e=e,window.clearTimeout(o),h.abort(),Rr(e.type,h,e.type,n),p()},window[l]=function(e){window.clearTimeout(o),Lr(e,h,n),p()},Br(n),d.src=n.url.replace(/=\?/,"="+l),d.src=Pr(d.src,"_="+(new Date).getTime()),d.async=!0,n.scriptCharset&&(d.charset=n.scriptCharset),a.insertBefore(d,a.firstChild),0<n.timeout&&(o=window.setTimeout((function(){h.abort(),Rr("timeout",h,"timeout",n),p()}),n.timeout)),n.promise.abort=function(){h.abort()},n.promise.xhr=h,n.promise;function p(){d.clearAttributes?d.clearAttributes():d.onload=d.onreadystatechange=d.onerror=null,d.parentNode&&d.parentNode.removeChild(d),d=null,delete window[l]}Br(r);var f=r.accepts[u]||r.accepts["*"],m={};/^([\w-]+:)\/\//.test(r.url)?RegExp.$1:window.location.protocol;var g,y=kr.xhr();r.crossDomain||m["X-Requested-With"]||(m["X-Requested-With"]="XMLHttpRequest"),r.ifModified&&(Sr[c]&&(m["If-Modified-Since"]=Sr[c]),Er[c]&&(m["If-None-Match"]=Er[c])),f&&(-1<(m.Accept=f).indexOf(",")&&(f=f.split(",",2)[0]),y.overrideMimeType&&y.overrideMimeType(f)),f=!/^(?:GET|HEAD)$/.test(r.type.toUpperCase()),(r.data&&f&&!1!==r.contentType||t.contentType)&&(m["Content-Type"]=r.contentType),!1!==r.cache||f||(r.url=(t=/([?&])_=[^&]*/).test(c)?c.replace(t,"$1_="+Or()):c+(/\?/.test(c)?"&":"?")+"_="+Or()),r.headers=Ur(m,r.headers||{}),y.onreadystatechange=function(){if(4===y.readyState){clearTimeout(g);var e,t=!1;if(200<=y.status&&y.status<300||304===y.status){Tr=y.getAllResponseHeaders(),r.ifModified&&((i=Ir("Last-Modified"))&&(Sr[c]=i),(i=Ir("etag"))&&(Er[c]=i)),u=u||(i=y.getResponseHeader("content-type"))&&(i===Ar?"html":i===yr?"json":br.test(i)&&"xml")||"text",e=y.responseText;try{"xml"===u?e=y.responseXML:"json"===u&&(e=wr.test(e)?null:JSON.parse(e))}catch(e){t=e}t?Rr(t,"parseerror",y,r):Lr(e,y,r)}else Rr(null,"error",y,r)}var i},f=!("async"in r)||r.async;if(y.open(r.type,r.url,f,r.username,r.password),r.xhrFields)for(var A in r.xhrFields)y[A]=r.xhrFields[A];for(A in r.mimeType&&y.overrideMimeType&&y.overrideMimeType(r.mimeType),r.headers)void 0!==r.headers[A]&&y.setRequestHeader(A,r.headers[A]+"");return!1===function(e){var t=e.context;if(!1===e.beforeSend.call(t,y,e))return!1}(r)?(y.abort(),!1):(0<r.timeout&&(g=window.setTimeout((function(){y.onreadystatechange=xr,y.abort(),Rr(null,"timeout",y,r)}),r.timeout)),y.send(r.data||null),r.promise.abort=function(){y.abort()},r.promise)}function Lr(e,t,i){var r=i.context,s="success";i.success.call(r,e,s,t),i.promise.resolve(e,s,t),Dr(s,t,i)}function Dr(e,t,i){var r=i.context;i.complete.call(r,t,e)}function Rr(e,t,i,r){var s=r.context;r.error.call(s,i,t,e),r.promise.reject(i,t,e),Dr(t,i,r)}function Ir(e){var t;if(!gr){for(gr={};t=vr.exec(Tr);)gr[t[1].toLowerCase()]=t[2];t=gr[e.toLowerCase()]}return null===t?null:t}function Pr(e,t){return(e+"&"+t).replace(/[&?]{1,2}/,"?")}function Br(e){var t,i;!Fr(e)||e.data instanceof FormData||!e.processData||(e.data=(t=e.data,(i=[]).add=function(e,t){this.push(encodeURIComponent(e)+"="+encodeURIComponent(t))},function e(t,i,r,s){var a=function(e){return"[object Array]"===Object.prototype.toString.call(e)}(i);for(var n in i){var o=i[n];s&&(n=r?s:s+"["+(a?"":n)+"]"),!s&&a?t.add(o.name,o.value):(r?a:Fr)(o)?e(t,o,r,n):t.add(n,o)}}(i,t,void 0),i.join("&").replace("%20","+"))),!e.data||e.type&&"GET"!==e.type.toUpperCase()||(e.url=Pr(e.url,e.data))}function Ur(e){for(var t=Array.prototype.slice.call(arguments,1),i=0,r=t.length;i<r;i++){var s,a=t[i]||{};for(s in a)a.hasOwnProperty(s)&&void 0!==a[s]&&(e[s]=a[s])}return e}function Fr(e){var t=typeof e;return"function"==t||"object"==t&&!!e}function Mr(e){return"function"==typeof e}function Or(){return(new Date).getTime()}function Nr(e){return parseInt(e)===e}function jr(e){if(Nr(e.length)){for(var t=0;t<e.length;t++)if(!Nr(e[t])||e[t]<0||255<e[t])return;return 1}}function zr(e,t){if(e.buffer&&"Uint8Array"===e.name)return t?e.slice?e.slice():Array.prototype.slice.call(e):e;if(Array.isArray(e)){if(jr(e))return new Uint8Array(e);throw new Error("Array contains invalid value: "+e)}if(Nr(e.length)&&jr(e))return new Uint8Array(e);throw new Error("unsupported array-like object")}function Gr(e){return new Uint8Array(e)}function Hr(e,t,i,r,s){null==r&&null==s||(e=e.slice?e.slice(r,s):Array.prototype.slice.call(e,r,s)),t.set(e,i)}Cr.get=function(e,t,i,r){return Mr(t)&&(r=r||i,i=t,t=void 0),Cr({url:e,data:t,success:i,dataType:r})},Cr.post=function(e,t,i,r){return Mr(t)&&(r=r||i,i=t,t=void 0),Cr({type:"POST",url:e,data:t,success:i,dataType:r})},Cr.getJSON=function(e,t,i){return Mr(t)&&(i=t,t=void 0),Cr({url:e,data:t,success:i,dataType:"json"})},Cr.ajaxSetup=function(e,t){return t?Ur(Ur(e,kr),t):Ur(kr,e)};var Wr,Vr={toBytes:function(e){var t=[],i=0;for(e=encodeURI(e);i<e.length;){var r=e.charCodeAt(i++);37===r?(t.push(parseInt(e.substr(i,2),16)),i+=2):t.push(r)}return zr(t)},fromBytes:function(e){for(var t=[],i=0;i<e.length;){var r=e[i];r<128?(t.push(String.fromCharCode(r)),i++):191<r&&r<224?(t.push(String.fromCharCode((31&r)<<6|63&e[i+1])),i+=2):(t.push(String.fromCharCode((15&r)<<12|(63&e[i+1])<<6|63&e[i+2])),i+=3)}return t.join("")}},Kr=(Wr="0123456789abcdef",{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(e){for(var t=[],i=0;i<e.length;i++){var r=e[i];t.push(Wr[(240&r)>>4]+Wr[15&r])}return t.join("")}}),$r={16:10,24:12,32:14},Yr=[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],qr=[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],Jr=[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],Qr=[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],Xr=[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],Zr=[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],es=[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],ts=[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],is=[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],rs=[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],ss=[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],as=[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],ns=[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],os=[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],ls=[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 ds(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}function hs(e){if(!(this instanceof hs))throw Error("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:zr(e,!0)}),this._prepare()}function cs(e){if(!(this instanceof cs))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new hs(e)}function us(e,t){if(!(this instanceof us))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=Gr(16);this._lastCipherblock=zr(t,!0),this._aes=new hs(e)}function ps(e,t,i){if(!(this instanceof ps))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=Gr(16);this.segmentSize=i=i||1,this._shiftRegister=zr(t,!0),this._aes=new hs(e)}function fs(e,t){if(!(this instanceof fs))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=Gr(16);this._lastPrecipher=zr(t,!0),this._lastPrecipherIndex=16,this._aes=new hs(e)}function ms(e){if(!(this instanceof ms))throw Error("Counter must be instanitated with `new`");"number"==typeof(e=0===e||e?e:1)?(this._counter=Gr(16),this.setValue(e)):this.setBytes(e)}function gs(e,t){if(!(this instanceof gs))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",t instanceof ms||(t=new ms(t)),this._counter=t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new hs(e)}hs.prototype._prepare=function(){var e=$r[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,r=4*(e+1),s=this.key.length/4,a=ds(this.key);for(t=0;t<s;t++)this._Ke[i=t>>2][t%4]=a[t],this._Kd[e-i][t%4]=a[t];for(var n,o=0,l=s;l<r;){if(n=a[s-1],a[0]^=qr[n>>16&255]<<24^qr[n>>8&255]<<16^qr[255&n]<<8^qr[n>>24&255]^Yr[o]<<24,o+=1,8!=s)for(t=1;t<s;t++)a[t]^=a[t-1];else{for(t=1;t<s/2;t++)a[t]^=a[t-1];for(n=a[s/2-1],a[s/2]^=qr[255&n]^qr[n>>8&255]<<8^qr[n>>16&255]<<16^qr[n>>24&255]<<24,t=s/2+1;t<s;t++)a[t]^=a[t-1]}for(t=0;t<s&&l<r;)this._Ke[d=l>>2][h=l%4]=a[t],this._Kd[e-d][h]=a[t++],l++}for(var d=1;d<e;d++)for(var h=0;h<4;h++)n=this._Kd[d][h],this._Kd[d][h]=as[n>>24&255]^ns[n>>16&255]^os[n>>8&255]^ls[255&n]},hs.prototype.encrypt=function(e){if(16!=e.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var t=this._Ke.length-1,i=[0,0,0,0],r=ds(e),s=0;s<4;s++)r[s]^=this._Ke[0][s];for(var a=1;a<t;a++){for(s=0;s<4;s++)i[s]=Qr[r[s]>>24&255]^Xr[r[(s+1)%4]>>16&255]^Zr[r[(s+2)%4]>>8&255]^es[255&r[(s+3)%4]]^this._Ke[a][s];r=i.slice()}var n,o=Gr(16);for(s=0;s<4;s++)n=this._Ke[t][s],o[4*s]=255&(qr[r[s]>>24&255]^n>>24),o[4*s+1]=255&(qr[r[(s+1)%4]>>16&255]^n>>16),o[4*s+2]=255&(qr[r[(s+2)%4]>>8&255]^n>>8),o[4*s+3]=255&(qr[255&r[(s+3)%4]]^n);return o},hs.prototype.decrypt=function(e){if(16!=e.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var t=this._Kd.length-1,i=[0,0,0,0],r=ds(e),s=0;s<4;s++)r[s]^=this._Kd[0][s];for(var a=1;a<t;a++){for(s=0;s<4;s++)i[s]=ts[r[s]>>24&255]^is[r[(s+3)%4]>>16&255]^rs[r[(s+2)%4]>>8&255]^ss[255&r[(s+1)%4]]^this._Kd[a][s];r=i.slice()}var n,o=Gr(16);for(s=0;s<4;s++)n=this._Kd[t][s],o[4*s]=255&(Jr[r[s]>>24&255]^n>>24),o[4*s+1]=255&(Jr[r[(s+3)%4]>>16&255]^n>>16),o[4*s+2]=255&(Jr[r[(s+2)%4]>>8&255]^n>>8),o[4*s+3]=255&(Jr[255&r[(s+1)%4]]^n);return o},cs.prototype.encrypt=function(e){if((e=zr(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=Gr(e.length),i=Gr(16),r=0;r<e.length;r+=16)Hr(e,i,0,r,r+16),Hr(i=this._aes.encrypt(i),t,r);return t},cs.prototype.decrypt=function(e){if((e=zr(e)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var t=Gr(e.length),i=Gr(16),r=0;r<e.length;r+=16)Hr(e,i,0,r,r+16),Hr(i=this._aes.decrypt(i),t,r);return t},us.prototype.encrypt=function(e){if((e=zr(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=Gr(e.length),i=Gr(16),r=0;r<e.length;r+=16){Hr(e,i,0,r,r+16);for(var s=0;s<16;s++)i[s]^=this._lastCipherblock[s];this._lastCipherblock=this._aes.encrypt(i),Hr(this._lastCipherblock,t,r)}return t},us.prototype.decrypt=function(e){if((e=zr(e)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var t=Gr(e.length),i=Gr(16),r=0;r<e.length;r+=16){Hr(e,i,0,r,r+16);i=this._aes.decrypt(i);for(var s=0;s<16;s++)t[r+s]=i[s]^this._lastCipherblock[s];Hr(e,this._lastCipherblock,0,r,r+16)}return t},ps.prototype.encrypt=function(e){if(e.length%this.segmentSize!=0)throw new Error("invalid plaintext size (must be segmentSize bytes)");for(var t=zr(e,!0),i=0;i<t.length;i+=this.segmentSize){for(var r=this._aes.encrypt(this._shiftRegister),s=0;s<this.segmentSize;s++)t[i+s]^=r[s];Hr(this._shiftRegister,this._shiftRegister,0,this.segmentSize),Hr(t,this._shiftRegister,16-this.segmentSize,i,i+this.segmentSize)}return t},ps.prototype.decrypt=function(e){if(e.length%this.segmentSize!=0)throw new Error("invalid ciphertext size (must be segmentSize bytes)");for(var t=zr(e,!0),i=0;i<t.length;i+=this.segmentSize){for(var r=this._aes.encrypt(this._shiftRegister),s=0;s<this.segmentSize;s++)t[i+s]^=r[s];Hr(this._shiftRegister,this._shiftRegister,0,this.segmentSize),Hr(e,this._shiftRegister,16-this.segmentSize,i,i+this.segmentSize)}return t},fs.prototype.decrypt=fs.prototype.encrypt=function(e){for(var t=zr(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},ms.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;0<=t;--t)this._counter[t]=e%256,e=parseInt(e/256)},ms.prototype.setBytes=function(e){if(16!=(e=zr(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e},ms.prototype.increment=function(){for(var e=15;0<=e;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}},gs.prototype.decrypt=gs.prototype.encrypt=function(e){for(var t=zr(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};const ys={AES:hs,Counter:ms,ModeOfOperation:{ecb:cs,cbc:us,cfb:ps,ofb:fs,ctr:gs},utils:{hex:Kr,utf8:Vr},padding:{pkcs7:{pad:function(e){var t=16-(e=zr(e,!0)).length%16,i=Gr(e.length+t);Hr(e,i);for(var r=e.length;r<i.length;r++)i[r]=t;return i},strip:function(e){if((e=zr(e,!0)).length<16)throw new Error("PKCS#7 invalid length");var t=e[e.length-1];if(16<t)throw new Error("PKCS#7 padding byte out of range");for(var i=e.length-t,r=0;r<t;r++)if(e[i+r]!==t)throw new Error("PKCS#7 invalid padding byte");var s=Gr(i);return Hr(e,s,0,0,i),s}}},_arrayTest:{coerceArray:zr,createArray:Gr,copyArray:Hr}},As=16,bs=[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],vs=[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 _s(e){const t=[];for(let i=0,r=e.length;i<r;i+=2)t.push(parseInt(e.substr(i,2),16));return t}function ws(e,t){return t&=31,e<<t|e>>>32-t}function Ss(e){return(255&bs[e>>>24&255])<<24|(255&bs[e>>>16&255])<<16|(255&bs[e>>>8&255])<<8|255&bs[255&e]}function Es(e){return e^ws(e,2)^ws(e,10)^ws(e,18)^ws(e,24)}function Ts(e){return e^ws(e,13)^ws(e,23)}function ks(e,t,i,r){let{padding:s="pkcs#7",mode:a,iv:n=[],output:o="string"}=3<arguments.length&&void 0!==r?r:{};if("cbc"===a&&16!==(n="string"==typeof n?_s(n):n).length)throw new Error("iv is invalid");if(16!==(t="string"==typeof t?_s(t):t).length)throw new Error("key is invalid");if(e="string"==typeof e?(0!==i?function(e){const t=[];for(let r=0,s=e.length;r<s;r++){var i=e.codePointAt(r);if(i<=127)t.push(i);else if(i<=2047)t.push(192|i>>>6),t.push(128|63&i);else if(i<=55295||57344<=i&&i<=65535)t.push(224|i>>>12),t.push(128|i>>>6&63),t.push(128|63&i);else{if(!(65536<=i&&i<=1114111))throw t.push(i),new Error("input is not supported");r++,t.push(240|i>>>18&28),t.push(128|i>>>12&63),t.push(128|i>>>6&63),t.push(128|63&i)}}return t}:_s)(e):[...e],("pkcs#5"===s||"pkcs#7"===s)&&0!==i){const t=As-e.length%As;for(let i=0;i<t;i++)e.push(t)}var l=new Array(32);{var d=t,h=l;r=i;const e=new Array(4),s=new Array(4);for(let t=0;t<4;t++)s[0]=255&d[0+4*t],s[1]=255&d[1+4*t],s[2]=255&d[2+4*t],s[3]=255&d[3+4*t],e[t]=s[0]<<24|s[1]<<16|s[2]<<8|s[3];e[0]^=2746333894,e[1]^=1453994832,e[2]^=1736282519,e[3]^=2993693404;for(let t,i=0;i<32;i+=4)t=e[1]^e[2]^e[3]^vs[i+0],h[i+0]=e[0]^=Ts(Ss(t)),t=e[2]^e[3]^e[0]^vs[i+1],h[i+1]=e[1]^=Ts(Ss(t)),t=e[3]^e[0]^e[1]^vs[i+2],h[i+2]=e[2]^=Ts(Ss(t)),t=e[0]^e[1]^e[2]^vs[i+3],h[i+3]=e[3]^=Ts(Ss(t));if(0===r)for(let t,i=0;i<16;i++)t=h[i],h[i]=h[31-i],h[31-i]=t}const c=[];let u=n,p=e.length,f=0;for(;p>=As;){const t=e.slice(f,f+16),r=new Array(16);if("cbc"===a)for(let e=0;e<As;e++)0!==i&&(t[e]^=u[e]);{m=void 0,g=void 0,y=void 0;var m=t,g=r,y=l;const e=new Array(4),i=new Array(4);for(let t=0;t<4;t++)i[0]=255&m[4*t],i[1]=255&m[4*t+1],i[2]=255&m[4*t+2],i[3]=255&m[4*t+3],e[t]=i[0]<<24|i[1]<<16|i[2]<<8|i[3];for(let t,r=0;r<32;r+=4)t=e[1]^e[2]^e[3]^y[r+0],e[0]^=Es(Ss(t)),t=e[2]^e[3]^e[0]^y[r+1],e[1]^=Es(Ss(t)),t=e[3]^e[0]^e[1]^y[r+2],e[2]^=Es(Ss(t)),t=e[0]^e[1]^e[2]^y[r+3],e[3]^=Es(Ss(t));for(let t=0;t<16;t+=4)g[t]=e[3-t/4]>>>24&255,g[t+1]=e[3-t/4]>>>16&255,g[t+2]=e[3-t/4]>>>8&255,g[t+3]=255&e[3-t/4]}for(let e=0;e<As;e++)"cbc"===a&&0===i&&(r[e]^=u[e]),c[f+e]=r[e];"cbc"===a&&(u=0!==i?r:t),p-=As,f+=As}if(("pkcs#5"===s||"pkcs#7"===s)&&0===i){const e=c.length,t=c[e-1];for(let i=1;i<=t;i++)if(c[e-i]!==t)throw new Error("padding is invalid");c.splice(e-t,t)}if("array"===o)return c;if(0!==i)return c.map(e=>1===(e=e.toString(16)).length?"0"+e:e).join("");{var A=c;const e=[];for(let t=0,i=A.length;t<i;t++)240<=A[t]&&A[t]<=247?(e.push(String.fromCodePoint(((7&A[t])<<18)+((63&A[t+1])<<12)+((63&A[t+2])<<6)+(63&A[t+3]))),t+=3):224<=A[t]&&A[t]<=239?(e.push(String.fromCodePoint(((15&A[t])<<12)+((63&A[t+1])<<6)+(63&A[t+2]))),t+=2):192<=A[t]&&A[t]<=223?(e.push(String.fromCodePoint(((31&A[t])<<6)+(63&A[t+1]))),t++):e.push(String.fromCodePoint(A[t]));return e.join("")}}class xs extends cr{constructor(e){super(e),this.input=new mr(this.demux()),e.debug.log("FlvDemux","init")}destroy(){super.destroy(),this.input=null,this.player.debug.log("FlvDemux","destroy")}dispatch(e){this.input?this.input.write(e):this.player&&this.player.debug.warn("FlvDemux","dispatch() this.input is null")}*demux(){yield 9;const e=new ArrayBuffer(4),t=new Uint8Array(e),i=new Uint32Array(e),r=this.player;for(;;){if(!this.input)return;t[3]=0;const e=yield 15,l=e[4];t[0]=e[7],t[1]=e[6],t[2]=e[5];var s=i[0],a=(t[0]=e[10],t[1]=e[9],t[2]=e[8],t[3]=e[11],i[0]),n=(yield s).slice();if(!r)return;switch(l){case 8:r._opt.hasAudio&&(r.updateStats({abps:n.byteLength}),0<n.byteLength&&this._doDecode(n,1,a));break;case 9:if(r._opt.hasVideo){r.updateStats({vbps:n.byteLength,dts:a});const e=n[0]>>4&15,t=1==e;if(1!=e&&2!=e&&r.debug.warn("FlvDemux",`frameType is ${e} is not keyFrame or interFrame`),t&&this.calcIframeIntervalTimestamp(a),0<n.byteLength){i[0]=n[4],i[1]=n[3],i[2]=n[2],i[3]=0;var o=i[0];r._times.demuxStart||(r._times.demuxStart=qe());let e=n;r._opt.isCrypto?r._opt.cryptoKey&&0<r._opt.cryptoKey.byteLength&&r._opt.cryptoIV&&0<r._opt.cryptoIV.byteLength?e=function(e,t,i){t=new Uint8Array(t),i=new Uint8Array(i);const r=e.byteLength;let s=5;for(;s<r;){if(n=(n=e.slice(s,s+4))[3]|n[2]<<8|n[1]<<16|n[0]<<24,n>r)break;var a=e[s+4];if(1==(a&=31)||5==a){const r=e.slice(s+4+2,s+4+n);let o=new ys.ModeOfOperation.ctr(t,new ys.Counter(i));a=o.decrypt(r),o=null,e.set(a,s+4+2)}s=s+4+n}var n;return e}(n,r._opt.cryptoKey,r._opt.cryptoIV):r.debug.error("FlvDemux",`cryptoKey.length is ${r._opt.cryptoKey&&r._opt.cryptoKey.byteLength} or cryptoIV.length is ${r._opt.cryptoIV&&r._opt.cryptoIV.byteLength} null`):r._opt.isSm4Crypto&&r._opt.sm4CryptoKey&&t&&(e=function(e,t){const i=e.byteLength;let r=5;for(;r<i;){if(a=(a=e.slice(r,r+4))[3]|a[2]<<8|a[1]<<16|a[0]<<24,a>i)break;var s=e[r+4];if(1==(s&=31)||5==s){const i=ks(e.slice(r+4+2,r+4+a),t,0,{padding:"none",output:"array"});e.set(i,r+4+2)}r=r+4+a}var a;return e}(n,r._opt.sm4CryptoKey)),r._opt.isEmitSEI&&this.findSei(e,a),this._doDecode(e,2,a,t,o)}}break;default:r.debug.warn("FlvDemux","demux() type is "+l)}}}close(){this.input=null}getInputByteLength(){let e=0;return this.input&&this.input.buffer?this.input.buffer.byteLength:e}}class Cs extends cr{constructor(e){super(e),e.debug.log("M7sDemux","init")}destroy(){super.destroy(),this.player.debug.log("M7sDemux","destroy")}dispatch(e){const t=this.player,i=new DataView(e),r=i.getUint8(0),s=i.getUint32(1,!1);switch(r){case 1:if(t._opt.hasAudio){const i=new Uint8Array(e,5);t.updateStats({abps:i.byteLength}),0<i.byteLength&&this._doDecode(i,r,s)}break;case 2:var a,n;t._opt.hasVideo&&(t._times.demuxStart||(t._times.demuxStart=qe()),5<i.byteLength?(a=new Uint8Array(e,5),n=i.getUint8(5)>>4==1,t.updateStats({vbps:a.byteLength,dts:s}),0<a.byteLength&&(n&&this.calcIframeIntervalTimestamp(s),t._opt.isEmitSEI&&this.findSei(a,s),this._doDecode(a,r,s,n))):this.player.debug.warn("M7sDemux","dispatch","dv byteLength is",i.byteLength))}}}class Ls extends xs{constructor(e){super(e),e.debug.log("WebTransportDemux","init")}destroy(){this.player.debug.log("WebTransportDemux","destroy"),super.destroy()}}var Ds=Oe(Ne((function(e){e.exports=function(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e},e.exports.__esModule=!0,e.exports.default=e.exports})));class Rs extends cr{constructor(e){super(e),Ds(this,"TAG_NAME","NakedFlowDemux"),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,e=new Uint8Array(e),this.extractNALu$2(e)}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(){var 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(){var e=this.player._opt.nakedFlowFps;return this.localDts=this.localDts+parseInt(1e3/e),this.localDts}getNaluAudioDts(){var e=this.player.audio.audioContext.sampleRate,t=this.player.audio.audioBufferSize;return this.localDts+parseInt(t/e*1e3)}extractNALu(e){let t,i,r=0,s=e.byteLength,a=0,n=[];for(;r<s;)switch(t=e[r++],a){case 0:0===t&&(a=1);break;case 1:a=0===t?2:0;break;case 2:case 3:a=0===t?3:(1===t&&r<s&&(e[r],i&&n.push(e.subarray(i,r-a-1)),i=r),0)}return i&&n.push(e.subarray(i,s)),n}extractNALu$2(e){let t=null;if(e&&!(e.byteLength<1)){this.lastBuf?((t=new Uint8Array(e.byteLength+this.lastBuf.length)).set(this.lastBuf),t.set(new Uint8Array(e),this.lastBuf.length)):t=new Uint8Array(e);let i=0,r=-1,s=-2;const a=new Array;for(let e=0;e<t.length;e+=2){const i=t[e],n=t[e+1];0==r&&0==i&&0==n?a.push(e-1):1==n&&0==i&&0==r&&0==s&&a.push(e-2),s=i,r=n}if(1<a.length)for(let e=0;e<a.length-1;++e){const r=t.subarray(a[e],a[e+1]+1);this.handleNALu(r),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(t=7!==i&&8!==i?t:W)||32!==(i=(126&e[0])>>1)&&33!==i&&34!==i||(t=V),t}(t)),this.streamVideoType===W){const e=this.handleAddNaluStartCode(t),i=this.extractNALu(e);if(0===i.length)this.player.debug.warn(this.TAG_NAME,"handleVideoNalu","naluList.length === 0");else{const e=[];if(i.forEach(t=>{var i=Yi(t);8===i||7===i?this.handleVideoH264Nalu(t):Ji(i)&&e.push(t)}),1===e.length)this.handleVideoH264Nalu(e[0]);else{const t=function(e){if(0===e.length)return!1;var t=Yi(e[0]);for(let i=1;i<e.length;i++)if(t!==Yi(e[i]))return!1;return!0}(e);if(t){const t=Yi(e[0]),i=5===t;this.handleVideoH264NaluList(e,i,t)}else e.forEach(e=>{this.handleVideoH264Nalu(e)})}}}else if(this.streamVideoType===V){const e=this.handleAddNaluStartCode(t),i=this.extractNALu(e);if(0===i.length)this.player.debug.warn(this.TAG_NAME,"handleVideoNalu","h265 naluList.length === 0");else{const e=[];if(i.forEach(t=>{var i=tr(t);34===i||33===i||32===i?this.handleVideoH265Nalu(t):ir(i)&&e.push(t)}),1===e.length)this.handleVideoH265Nalu(e[0]);else{const t=function(e){if(0===e.length)return!1;var t=tr(e[0]);for(let i=1;i<e.length;i++)if(t!==tr(e[i]))return!1;return!0}(e);if(t){const t=tr(e[0]),i=rr(t);this.handleVideoH265NaluList(e,i,t)}else e.forEach(e=>{this.handleVideoH265Nalu(e)})}}}else this.player.debug.error(this.TAG_NAME," this.streamVideoType is null")}extractH264PPS(e){e=this.handleAddNaluStartCode(e),this.extractNALu(e).forEach(e=>{qi(Yi(e))?this.extractH264SEI(e):this.handleVideoH264Nalu(e)})}extractH265PPS(e){e=this.handleAddNaluStartCode(e),this.extractNALu(e).forEach(e=>{39===tr(e)?this.extractH265SEI(e):this.handleVideoH265Nalu(e)})}extractH264SEI(e){e=this.handleAddNaluStartCode(e),this.extractNALu(e).forEach(e=>{this.handleVideoH264Nalu(e)})}extractH265SEI(e){e=this.handleAddNaluStartCode(e),this.extractNALu(e).forEach(e=>{this.handleVideoH265Nalu(e)})}handleAddNaluStartCode(e){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)){this.streamAudioType||(this.streamAudioType=K.AAC);let i=new Uint8Array(e);var t=i.slice(0,7);if(i=i.slice(7),!this.isSendAACSeqHeader){const e=(192&t[2])>>6,i=(60&t[2])>>2,r=(1&t[2])<<2|(192&t[3])>>6,s=new Uint8Array([175,0,e<<3|(14&i)>>1,(1&i)<<7|r<<3]);this.isSendAACSeqHeader=!0,this._doDecode(s,1,0,!1,0)}const r=this.getNaluAudioDts(),s=new Uint8Array(i.length+2);s.set([175,1],0),s.set(i,2),this._doDecode(s,1,r,!1,0)}}handleAudioG711ANalu(e){if(e&&!(e.byteLength<1)){this.streamAudioType||(this.streamAudioType=K.ALAW),e=new Uint8Array(e);const t=this.getNaluAudioDts(),i=new Uint8Array(e.length+1);i.set([114],0),i.set(e,1),this._doDecode(i,1,t,!1,0)}}handleAudioG711UNalu(e){if(e&&!(e.byteLength<1)){this.streamAudioType||(this.streamAudioType=K.MULAW),e=new Uint8Array(e);const t=this.getNaluAudioDts(),i=new Uint8Array(e.length+1);i.set([130],0),i.set(e,1),this._doDecode(i,1,t,!1,0)}}handleVideoH264Nalu(e){const t=Yi(e);switch(t){case 7:this.sps=e;break;case 8:this.pps=e}if(this.isSendSeqHeader){if(this.sps&&this.pps){const e=Ki({sps:this.sps,pps:this.pps}),t=this.getNaluDts();this._doDecode(e,2,t,!0,0),this.sps=null,this.pps=null}if(Ji(t)){this.player._times.demuxStart||(this.player._times.demuxStart=qe());const i=5===t,r=this.getNaluDts(),s=function(e){let t=[];t[0]=i?23:39,t[1]=1,t[2]=0,t[3]=0,t[4]=0,t[5]=e.byteLength>>24&255,t[6]=e.byteLength>>16&255,t[7]=e.byteLength>>8&255,t[8]=255&e.byteLength;const r=new Uint8Array(t.length+e.byteLength);return r.set(t,0),r.set(e,t.length),r}(e);this._preDoDecode(s,2,r,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=Ki({sps:this.sps,pps:this.pps});this._doDecode(e,2,0,!0,0),this.sps=null,this.pps=null}}handleVideoH264NaluList(e,t,i){if(this.isSendSeqHeader){this.player._times.demuxStart||(this.player._times.demuxStart=qe());const i=this.getNaluDts(),r=$i(e.reduce((e,t)=>{const i=hr(e),r=hr(t),s=new Uint8Array(i.byteLength+r.byteLength);return s.set(i,0),s.set(r,i.byteLength),s}),t);this._preDoDecode(r,2,i,t,0)}else this.player.debug.warn(this.TAG_NAME,"handleVideoH264NaluList isSendSeqHeader is false")}handleVideoH265Nalu(e){const t=tr(e);switch(t){case 32:this.vps=e;break;case 33:this.sps=e;break;case 34:this.pps=e}if(this.isSendSeqHeader){if(this.vps&&this.sps&&this.pps){const e=Zi({vps:this.vps,sps:this.sps,pps:this.pps}),t=this.getNaluDts();this._doDecode(e,2,t,!0,0),this.vps=null,this.sps=null,this.pps=null}if(ir(t)){this.player._times.demuxStart||(this.player._times.demuxStart=qe());const i=rr(t),r=this.getNaluDts(),s=function(e){let t=[];t[0]=i?28:44,t[1]=1,t[2]=0,t[3]=0,t[4]=0,t[5]=e.byteLength>>24&255,t[6]=e.byteLength>>16&255,t[7]=e.byteLength>>8&255,t[8]=255&e.byteLength;const r=new Uint8Array(t.length+e.byteLength);return r.set(t,0),r.set(e,t.length),r}(e);this._preDoDecode(s,2,r,i,0)}}else if(this.vps&&this.sps&&this.pps){this.isSendSeqHeader=!0;const e=Zi({vps:this.vps,sps:this.sps,pps:this.pps});this._doDecode(e,2,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=qe());const i=this.getNaluDts(),r=er(e.reduce((e,t)=>{const i=hr(e),r=hr(t),s=new Uint8Array(i.byteLength+r.byteLength);return s.set(i,0),s.set(r,i.byteLength),s}),t);this._preDoDecode(r,2,i,t,0)}else this.player.debug.warn(this.TAG_NAME,"handleVideoH265NaluList isSendSeqHeader is false")}_preDoDecode(e,t,i,r,s){this.player.updateStats({vbps:e.byteLength,dts:i}),r&&this.calcIframeIntervalTimestamp(i),this.player._opt.isEmitSEI&&this.findSei(e,i),this._doDecode(e,2,i,r,s)}getInputByteLength(){let e=0;return this.lastBuf?this.lastBuf.byteLength:e}}class Is extends cr{constructor(e){super(e),(this.player=e).debug.log("EmptyDemux","init")}destroy(){super.destroy(),this.player.debug.log("EmptyDemux","destroy")}}var Ps=Ne((function(e,t){function i(e){if(!(e instanceof ArrayBuffer))throw"Needs an array buffer";this.buffer=e,this.dataview=new DataView(e),this.position=0}function r(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?r.LITTLE_ENDIAN:i}function s(e){this.buffers=[],this.bufferIndex=-1,e&&(this.insertBuffer(e),this.bufferIndex=0)}function a(){var e=[],t=(e[3]="ES_Descriptor",e[4]="DecoderConfigDescriptor",e[5]="DecoderSpecificInfo",e[6]="SLConfigDescriptor",this.getDescriptorName=function(t){return e[t]},this),i={};return this.parseOneDescriptor=function(t){for(var r=0,s=t.readUint8(),a=t.readUint8();128&a;)r=(127&a)<<7,a=t.readUint8();return c.debug("MPEG4DescriptorParser","Found "+(e[s]||"Descriptor "+s)+", size "+(r+=127&a)+" at position "+t.getPosition()),(s=new(e[s]?i[e[s]]:i.Descriptor)(r)).parse(t),s},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 r=t.parseOneDescriptor(e);this.descs.push(r)}},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){var t;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?(t=e.readUint8(),this.URL=e.readString(t),this.size-=t+1):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=t.findDescriptor(5);return t&&t.data?31===(i=(248&t.data[0])>>3)&&2<=t.data.length?32+((7&t.data[0])<<3)+((224&t.data[1])>>5):i: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.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}function n(){}function o(){}function l(e){this.stream=e||new s,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}d=new Date,h=4;var d,h,c={setLogLevel:function(e){h=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),h<=1&&console.debug("["+c.getDurationString(new Date-d,1e3)+"]","["+e+"]",t)},log:function(e,t){this.debug(e.msg)},info:function(e,t){h<=2&&console.info("["+c.getDurationString(new Date-d,1e3)+"]","["+e+"]",t)},warn:function(e,t){h<=3&&console.warn("["+c.getDurationString(new Date-d,1e3)+"]","["+e+"]",t)},error:function(e,t){h<=4&&console.error("["+c.getDurationString(new Date-d,1e3)+"]","["+e+"]",t)}},u=(c.getDurationString=function(e,t){var i;function r(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;e/=t||1,t=Math.floor(e/3600);var s=(e-=3600*t,Math.floor(e/60)),a=1e3*(e-=60*s);return a-=1e3*(e=Math.floor(e)),a=Math.floor(a),(i?"-":"")+t+":"+r(s,2)+":"+r(e,2)+"."+r(a,3)},c.printRanges=function(e){var t=e.length;if(0<t){for(var i="",r=0;r<t;r++)0<r&&(i+=","),i+="["+c.getDurationString(e.start(r))+","+c.getDurationString(e.end(r))+"]";return i}return"(empty)"},t.Log=c,i.prototype.getPosition=function(){return this.position},i.prototype.getEndPosition=function(){return this.buffer.byteLength},i.prototype.getLength=function(){return this.buffer.byteLength},i.prototype.seek=function(e){return e=Math.max(0,Math.min(this.buffer.byteLength,e)),this.position=isNaN(e)||!isFinite(e)?0:e,!0},i.prototype.isEos=function(){return this.getPosition()>=this.getEndPosition()},i.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=(i|=this.dataview.getUint8(this.position+1)<<8)|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"},i.prototype.readUint8=function(){return this.readAnyInt(1,!1)},i.prototype.readUint16=function(){return this.readAnyInt(2,!1)},i.prototype.readUint24=function(){return this.readAnyInt(3,!1)},i.prototype.readUint32=function(){return this.readAnyInt(4,!1)},i.prototype.readUint64=function(){return this.readAnyInt(8,!1)},i.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"},i.prototype.readCString=function(){for(var e=[];;){var t=this.readUint8();if(0===t)break;e.push(t)}return String.fromCharCode.apply(null,e)},i.prototype.readInt8=function(){return this.readAnyInt(1,!0)},i.prototype.readInt16=function(){return this.readAnyInt(2,!0)},i.prototype.readInt32=function(){return this.readAnyInt(4,!0)},i.prototype.readInt64=function(){return this.readAnyInt(8,!1)},i.prototype.readUint8Array=function(e){for(var t=new Uint8Array(e),i=0;i<e;i++)t[i]=this.readUint8();return t},i.prototype.readInt16Array=function(e){for(var t=new Int16Array(e),i=0;i<e;i++)t[i]=this.readInt16();return t},i.prototype.readUint16Array=function(e){for(var t=new Int16Array(e),i=0;i<e;i++)t[i]=this.readUint16();return t},i.prototype.readUint32Array=function(e){for(var t=new Uint32Array(e),i=0;i<e;i++)t[i]=this.readUint32();return t},i.prototype.readInt32Array=function(e){for(var t=new Int32Array(e),i=0;i<e;i++)t[i]=this.readInt32();return t},t.MP4BoxStream=i,(r.prototype={}).getPosition=function(){return this.position},r.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);i<t;)i*=2;e=new ArrayBuffer(i);var r=new Uint8Array(this._buffer);new Uint8Array(e,0,r.length).set(r),this.buffer=e,this._byteLength=t}}},r.prototype._trimAlloc=function(){var e,t,i;this._byteLength!=this._buffer.byteLength&&(e=new ArrayBuffer(this._byteLength),t=new Uint8Array(e),i=new Uint8Array(this._buffer,0,t.length),t.set(i),this.buffer=e)},r.BIG_ENDIAN=!1,r.LITTLE_ENDIAN=!0,r.prototype._byteLength=0,Object.defineProperty(r.prototype,"byteLength",{get:function(){return this._byteLength-this._byteOffset}}),Object.defineProperty(r.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(r.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(r.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}}),r.prototype.seek=function(e){e=Math.max(0,Math.min(this.byteLength,e)),this.position=isNaN(e)||!isFinite(e)?0:e},r.prototype.isEof=function(){return this.position>=this._byteLength},r.prototype.mapUint8Array=function(e){this._realloc(+e);var t=new Uint8Array(this._buffer,this.byteOffset+this.position,e);return this.position+=+e,t},r.prototype.readInt32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var i=new Int32Array(e);return r.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),r.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},r.prototype.readInt16Array=function(e,t){e=null==e?this.byteLength-this.position/2:e;var i=new Int16Array(e);return r.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),r.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},r.prototype.readInt8Array=function(e){e=null==e?this.byteLength-this.position:e;var t=new Int8Array(e);return r.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT),this.position+=t.byteLength,t},r.prototype.readUint32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var i=new Uint32Array(e);return r.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),r.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},r.prototype.readUint16Array=function(e,t){e=null==e?this.byteLength-this.position/2:e;var i=new Uint16Array(e);return r.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),r.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},r.prototype.readUint8Array=function(e){e=null==e?this.byteLength-this.position:e;var t=new Uint8Array(e);return r.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT),this.position+=t.byteLength,t},r.prototype.readFloat64Array=function(e,t){e=null==e?this.byteLength-this.position/8:e;var i=new Float64Array(e);return r.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),r.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},r.prototype.readFloat32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var i=new Float32Array(e);return r.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),r.arrayToNative(i,null==t?this.endianness:t),this.position+=i.byteLength,i},r.prototype.readInt32=function(e){return e=this._dataView.getInt32(this.position,null==e?this.endianness:e),this.position+=4,e},r.prototype.readInt16=function(e){return e=this._dataView.getInt16(this.position,null==e?this.endianness:e),this.position+=2,e},r.prototype.readInt8=function(){var e=this._dataView.getInt8(this.position);return this.position+=1,e},r.prototype.readUint32=function(e){return e=this._dataView.getUint32(this.position,null==e?this.endianness:e),this.position+=4,e},r.prototype.readUint16=function(e){return e=this._dataView.getUint16(this.position,null==e?this.endianness:e),this.position+=2,e},r.prototype.readUint8=function(){var e=this._dataView.getUint8(this.position);return this.position+=1,e},r.prototype.readFloat32=function(e){return e=this._dataView.getFloat32(this.position,null==e?this.endianness:e),this.position+=4,e},r.prototype.readFloat64=function(e){return e=this._dataView.getFloat64(this.position,null==e?this.endianness:e),this.position+=8,e},r.endianness=0<new Int8Array(new Int16Array([1]).buffer)[0],r.memcpy=function(e,t,i,r,s){e=new Uint8Array(e,t,s),t=new Uint8Array(i,r,s),e.set(t)},r.arrayToNative=function(e,t){return t==this.endianness?e:this.flipArrayEndianness(e)},r.nativeToEndian=function(e,t){return this.endianness==t?e:this.flipArrayEndianness(e)},r.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 r=i+e.BYTES_PER_ELEMENT-1,s=i;s<r;r--,s++){var a=t[s];t[s]=t[r],t[r]=a}return e},r.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)},r.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))},r.prototype.readCString=function(e){var t=this.byteLength-this.position,i=new Uint8Array(this._buffer,this._byteOffset+this.position),r=t;null!=e&&(r=Math.min(e,t));for(var s=0;s<r&&0!==i[s];s++);var a=String.fromCharCodeUint8.apply(null,[this.mapUint8Array(s)]);return null!=e?this.position+=r-s:s!=t&&(this.position+=1),a},Math.pow(2,32)),p=(r.prototype.readInt64=function(){return this.readInt32()*u+this.readUint32()},r.prototype.readUint64=function(){return this.readUint32()*u+this.readUint32()},r.prototype.readInt64=function(){return this.readUint32()*u+this.readUint32()},r.prototype.readUint24=function(){return(this.readUint8()<<16)+(this.readUint8()<<8)+this.readUint8()},(t.DataStream=r).prototype.save=function(e){var t=new Blob([this.buffer]);if(!window.URL||!URL.createObjectURL)throw"DataStream.save: Can't create object URL.";t=window.URL.createObjectURL(t);var i=document.createElement("a");document.body.appendChild(i),i.setAttribute("href",t),i.setAttribute("download",e),i.setAttribute("target","_self"),i.click(),window.URL.revokeObjectURL(t)},r.prototype._dynamicSize=!0,Object.defineProperty(r.prototype,"dynamicSize",{get:function(){return this._dynamicSize},set:function(e){e||this._trimAlloc(),this._dynamicSize=e}}),r.prototype.shift=function(e){var t=new ArrayBuffer(this._byteLength-e),i=new Uint8Array(t),r=new Uint8Array(this._buffer,e,i.length);i.set(r),this.buffer=t,this.position-=e},r.prototype.writeInt32Array=function(e,t){if(this._realloc(4*e.length),e instanceof Int32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)r.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)},r.prototype.writeInt16Array=function(e,t){if(this._realloc(2*e.length),e instanceof Int16Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)r.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)},r.prototype.writeInt8Array=function(e){if(this._realloc(+e.length),e instanceof Int8Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)r.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])},r.prototype.writeUint32Array=function(e,t){if(this._realloc(4*e.length),e instanceof Uint32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)r.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)},r.prototype.writeUint16Array=function(e,t){if(this._realloc(2*e.length),e instanceof Uint16Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)r.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)},r.prototype.writeUint8Array=function(e){if(this._realloc(+e.length),e instanceof Uint8Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)r.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])},r.prototype.writeFloat64Array=function(e,t){if(this._realloc(8*e.length),e instanceof Float64Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)r.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)},r.prototype.writeFloat32Array=function(e,t){if(this._realloc(4*e.length),e instanceof Float32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)r.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)},r.prototype.writeInt32=function(e,t){this._realloc(4),this._dataView.setInt32(this.position,e,null==t?this.endianness:t),this.position+=4},r.prototype.writeInt16=function(e,t){this._realloc(2),this._dataView.setInt16(this.position,e,null==t?this.endianness:t),this.position+=2},r.prototype.writeInt8=function(e){this._realloc(1),this._dataView.setInt8(this.position,e),this.position+=1},r.prototype.writeUint32=function(e,t){this._realloc(4),this._dataView.setUint32(this.position,e,null==t?this.endianness:t),this.position+=4},r.prototype.writeUint16=function(e,t){this._realloc(2),this._dataView.setUint16(this.position,e,null==t?this.endianness:t),this.position+=2},r.prototype.writeUint8=function(e){this._realloc(1),this._dataView.setUint8(this.position,e),this.position+=1},r.prototype.writeFloat32=function(e,t){this._realloc(4),this._dataView.setFloat32(this.position,e,null==t?this.endianness:t),this.position+=4},r.prototype.writeFloat64=function(e,t){this._realloc(8),this._dataView.setFloat64(this.position,e,null==t?this.endianness:t),this.position+=8},r.prototype.writeUCS2String=function(e,t,i){null==i&&(i=e.length);for(var r=0;r<e.length&&r<i;r++)this.writeUint16(e.charCodeAt(r),t);for(;r<i;r++)this.writeUint16(0)},r.prototype.writeString=function(e,t,i){var r=0;if(null==t||"ASCII"==t)if(null!=i){var s=Math.min(e.length,i);for(r=0;r<s;r++)this.writeUint8(e.charCodeAt(r));for(;r<i;r++)this.writeUint8(0)}else for(r=0;r<e.length;r++)this.writeUint8(e.charCodeAt(r));else this.writeUint8Array(new TextEncoder(t).encode(e.substring(0,i)))},r.prototype.writeCString=function(e,t){var i=0;if(null!=t){var r=Math.min(e.length,t);for(i=0;i<r;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)}},r.prototype.writeStruct=function(e,t){for(var i=0;i<e.length;i+=2){var r=e[i+1];this.writeType(r,t[e[i]],t)}},r.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 a=null,n="ASCII";i=this.position;switch("string"==typeof e&&/:/.test(e)&&(e=(s=e.split(":"))[0],a=parseInt(s[1])),"string"==typeof e&&/,/.test(e)&&(e=(s=e.split(","))[0],n=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,r.BIG_ENDIAN);break;case"int16be":this.writeInt16(t,r.BIG_ENDIAN);break;case"uint32be":this.writeUint32(t,r.BIG_ENDIAN);break;case"int32be":this.writeInt32(t,r.BIG_ENDIAN);break;case"float32be":this.writeFloat32(t,r.BIG_ENDIAN);break;case"float64be":this.writeFloat64(t,r.BIG_ENDIAN);break;case"uint16le":this.writeUint16(t,r.LITTLE_ENDIAN);break;case"int16le":this.writeInt16(t,r.LITTLE_ENDIAN);break;case"uint32le":this.writeUint32(t,r.LITTLE_ENDIAN);break;case"int32le":this.writeInt32(t,r.LITTLE_ENDIAN);break;case"float32le":this.writeFloat32(t,r.LITTLE_ENDIAN);break;case"float64le":this.writeFloat64(t,r.LITTLE_ENDIAN);break;case"cstring":this.writeCString(t,a);break;case"string":this.writeString(t,n,a);break;case"u16string":this.writeUCS2String(t,this.endianness,a);break;case"u16stringle":this.writeUCS2String(t,r.LITTLE_ENDIAN,a);break;case"u16stringbe":this.writeUCS2String(t,r.BIG_ENDIAN,a);break;default:if(3==e.length){for(var o=e[1],l=0;l<t.length;l++)this.writeType(o,t[l]);break}this.writeStruct(e,t)}null!=a&&(this.position=i,this._realloc(a),this.position=i+a)},r.prototype.writeUint64=function(e){var t=Math.floor(e/u);this.writeUint32(t),this.writeUint32(4294967295&e)},r.prototype.writeUint24=function(e){this.writeUint8((16711680&e)>>16),this.writeUint8((65280&e)>>8),this.writeUint8(255&e)},r.prototype.adjustUint32=function(e,t){var i=this.position;this.seek(e),this.writeUint32(t),this.seek(i)},r.prototype.mapInt32Array=function(e,t){this._realloc(4*e);var i=new Int32Array(this._buffer,this.byteOffset+this.position,e);return r.arrayToNative(i,null==t?this.endianness:t),this.position+=4*e,i},r.prototype.mapInt16Array=function(e,t){this._realloc(2*e);var i=new Int16Array(this._buffer,this.byteOffset+this.position,e);return r.arrayToNative(i,null==t?this.endianness:t),this.position+=2*e,i},r.prototype.mapInt8Array=function(e){this._realloc(+e);var t=new Int8Array(this._buffer,this.byteOffset+this.position,e);return this.position+=+e,t},r.prototype.mapUint32Array=function(e,t){this._realloc(4*e);var i=new Uint32Array(this._buffer,this.byteOffset+this.position,e);return r.arrayToNative(i,null==t?this.endianness:t),this.position+=4*e,i},r.prototype.mapUint16Array=function(e,t){this._realloc(2*e);var i=new Uint16Array(this._buffer,this.byteOffset+this.position,e);return r.arrayToNative(i,null==t?this.endianness:t),this.position+=2*e,i},r.prototype.mapFloat64Array=function(e,t){this._realloc(8*e);var i=new Float64Array(this._buffer,this.byteOffset+this.position,e);return r.arrayToNative(i,null==t?this.endianness:t),this.position+=8*e,i},r.prototype.mapFloat32Array=function(e,t){this._realloc(4*e);var i=new Float32Array(this._buffer,this.byteOffset+this.position,e);return r.arrayToNative(i,null==t?this.endianness:t),this.position+=4*e,i},(s.prototype=new r(new ArrayBuffer,0,r.BIG_ENDIAN)).initialized=function(){var e;return-1<this.bufferIndex||(0<this.buffers.length?0===(e=this.buffers[0]).fileStart?(this.buffer=e,this.bufferIndex=0,c.debug("MultiBufferStream","Stream ready for parsing"),!0):(c.warn("MultiBufferStream","The first buffer should have a fileStart of 0"),this.logBufferLevel(),!1):(c.warn("MultiBufferStream","No buffer to start parsing from"),this.logBufferLevel(),!1))},ArrayBuffer.concat=function(e,t){c.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},s.prototype.reduceBuffer=function(e,t,i){var r;return(r=new Uint8Array(i)).set(new Uint8Array(e,t,i)),r.buffer.fileStart=e.fileStart+t,r.buffer.usedBytes=0,r.buffer},s.prototype.insertBuffer=function(e){for(var t=!0,i=0;i<this.buffers.length;i++){var r=this.buffers[i];if(e.fileStart<=r.fileStart){if(e.fileStart===r.fileStart){if(e.byteLength>r.byteLength){this.buffers.splice(i,1),i--;continue}c.warn("MultiBufferStream","Buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+") already appended, ignoring")}else e.fileStart+e.byteLength<=r.fileStart||(e=this.reduceBuffer(e,0,r.fileStart-e.fileStart)),c.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<r.fileStart+r.byteLength){r=r.fileStart+r.byteLength-e.fileStart;var s=e.byteLength-r;if(!(0<s)){t=!1;break}e=this.reduceBuffer(e,r,s)}}t&&(c.debug("MultiBufferStream","Appending new buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+")"),this.buffers.push(e),0===i&&(this.buffer=e))},s.prototype.logBufferLevel=function(e){for(var t,i,r=[],s="",a=0,n=0,o=0;o<this.buffers.length;o++)t=this.buffers[o],0===o?(r.push(i={}),i.start=t.fileStart,i.end=t.fileStart+t.byteLength,s+="["+i.start+"-"):i.end===t.fileStart?i.end=t.fileStart+t.byteLength:((i={}).start=t.fileStart,s+=r[r.length-1].end-1+"], ["+i.start+"-",i.end=t.fileStart+t.byteLength,r.push(i)),a+=t.usedBytes,n+=t.byteLength;0<r.length&&(s+=i.end-1+"]"),e=e?c.info:c.debug,0===this.buffers.length?e("MultiBufferStream","No more buffer in memory"):e("MultiBufferStream",this.buffers.length+" stored buffer(s) ("+a+"/"+n+" bytes), continuous ranges: "+s)},s.prototype.cleanBuffers=function(){for(var e,t=0;t<this.buffers.length;t++)(e=this.buffers[t]).usedBytes===e.byteLength&&(c.debug("MultiBufferStream","Removing buffer #"+t),this.buffers.splice(t,1),t--)},s.prototype.mergeNextBuffer=function(){var e,t,i,r;return this.bufferIndex+1<this.buffers.length&&(e=this.buffers[this.bufferIndex+1]).fileStart===this.buffer.fileStart+this.buffer.byteLength&&(t=this.buffer.byteLength,i=this.buffer.usedBytes,r=this.buffer.fileStart,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=r,c.debug("ISOFile","Concatenating buffer for box parsing (length: "+t+"->"+this.buffer.byteLength+")"),!0)},s.prototype.findPosition=function(e,t,i){for(var r=null,s=-1,a=!0===e?0:this.bufferIndex;a<this.buffers.length&&(r=this.buffers[a]).fileStart<=t;)s=a,i&&(r.fileStart+r.byteLength<=t?r.usedBytes=r.byteLength:r.usedBytes=t-r.fileStart,this.logBufferLevel()),a++;return-1!==s&&(r=this.buffers[s]).fileStart+r.byteLength>=t?(c.debug("MultiBufferStream","Found position in existing buffer #"+s),s):-1},s.prototype.findEndContiguousBuf=function(e){e=void 0!==e?e:this.bufferIndex;var t,i,r=this.buffers[e];if(this.buffers.length>e+1)for(t=e+1;t<this.buffers.length&&(i=this.buffers[t]).fileStart===r.fileStart+r.byteLength;t++)r=i;return r.fileStart+r.byteLength},s.prototype.getEndFilePositionAfter=function(e){var t=this.findPosition(!0,e,!1);return-1!==t?this.findEndContiguousBuf(t):e},s.prototype.addUsedBytes=function(e){this.buffer.usedBytes+=e,this.logBufferLevel()},s.prototype.setAllUsedBytes=function(){this.buffer.usedBytes=this.buffer.byteLength,this.logBufferLevel()},s.prototype.seek=function(e,t,i){return-1!==(t=this.findPosition(t,e,i))?(this.buffer=this.buffers[t],this.bufferIndex=t,this.position=e-this.buffer.fileStart,c.debug("MultiBufferStream","Repositioning parser at buffer position: "+this.position),!0):(c.debug("MultiBufferStream","Position "+e+" not found in buffered data"),!1)},s.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},s.prototype.getLength=function(){return this.byteLength},s.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},t.MultiBufferStream=s,t.MPEG4DescriptorParser=a,{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"]],boxCodes:[],fullBoxCodes:[],containerBoxCodes:[],sampleEntryCodes:{},sampleGroupEntryCodes:[],trackGroupTypes:[],UUIDBoxes:{},UUIDs:[],initialize:function(){p.FullBox.prototype=new p.Box,p.ContainerBox.prototype=new p.Box,p.SampleEntry.prototype=new p.Box,p.TrackGroupTypeBox.prototype=new p.FullBox,p.BASIC_BOXES.forEach((function(e){p.createBoxCtor(e)})),p.FULL_BOXES.forEach((function(e){p.createFullBoxCtor(e)})),p.CONTAINER_BOXES.forEach((function(e){p.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){p.Box.call(this,e,t,i),this.flags=0,this.version=0},ContainerBox:function(e,t,i){p.Box.call(this,e,t,i),this.boxes=[]},SampleEntry:function(e,t,i,r){p.ContainerBox.call(this,e,t),this.hdr_size=i,this.start=r},SampleGroupEntry:function(e){this.grouping_type=e},TrackGroupTypeBox:function(e,t){p.FullBox.call(this,e,t)},createBoxCtor:function(e,t){p.boxCodes.push(e),p[e+"Box"]=function(t){p.Box.call(this,e,t)},p[e+"Box"].prototype=new p.Box,t&&(p[e+"Box"].prototype.parse=t)},createFullBoxCtor:function(e,t){p[e+"Box"]=function(t){p.FullBox.call(this,e,t)},p[e+"Box"].prototype=new p.FullBox,p[e+"Box"].prototype.parse=function(e){this.parseFullHeader(e),t&&t.call(this,e)}},addSubBoxArrays:function(e){if(e)for(var t=(this.subBoxNames=e).length,i=0;i<t;i++)this[e[i]+"s"]=[]},createContainerBoxCtor:function(e,t,i){p[e+"Box"]=function(t){p.ContainerBox.call(this,e,t),p.addSubBoxArrays.call(this,i)},p[e+"Box"].prototype=new p.ContainerBox,t&&(p[e+"Box"].prototype.parse=t)},createMediaSampleEntryCtor:function(e,t,i){p.sampleEntryCodes[e]=[],p[e+"SampleEntry"]=function(e,t){p.SampleEntry.call(this,e,t),p.addSubBoxArrays.call(this,i)},p[e+"SampleEntry"].prototype=new p.SampleEntry,t&&(p[e+"SampleEntry"].prototype.parse=t)},createSampleEntryCtor:function(e,t,i,r){p.sampleEntryCodes[e].push(t),p[t+"SampleEntry"]=function(i){p[e+"SampleEntry"].call(this,t,i),p.addSubBoxArrays.call(this,r)},p[t+"SampleEntry"].prototype=new p[e+"SampleEntry"],i&&(p[t+"SampleEntry"].prototype.parse=i)},createEncryptedSampleEntryCtor:function(e,t,i){p.createSampleEntryCtor.call(this,e,t,i,["sinf"])},createSampleGroupCtor:function(e,t){p[e+"SampleGroupEntry"]=function(t){p.SampleGroupEntry.call(this,e,t)},p[e+"SampleGroupEntry"].prototype=new p.SampleGroupEntry,t&&(p[e+"SampleGroupEntry"].prototype.parse=t)},createTrackGroupCtor:function(e,t){p[e+"TrackGroupTypeBox"]=function(t){p.TrackGroupTypeBox.call(this,e,t)},p[e+"TrackGroupTypeBox"].prototype=new p.TrackGroupTypeBox,t&&(p[e+"TrackGroupTypeBox"].prototype.parse=t)},createUUIDBox:function(e,t,i,r){p.UUIDs.push(e),p.UUIDBoxes[e]=function(r){(t?p.FullBox:i?p.ContainerBox:p.Box).call(this,"uuid",r,e)},p.UUIDBoxes[e].prototype=new(t?p.FullBox:i?p.ContainerBox:p.Box),r&&(p.UUIDBoxes[e].prototype.parse=t?function(e){this.parseFullHeader(e),r&&r.call(this,e)}:r)}});p.initialize(),p.TKHD_FLAG_ENABLED=1,p.TKHD_FLAG_IN_MOVIE=2,p.TKHD_FLAG_IN_PREVIEW=4,p.TFHD_FLAG_BASE_DATA_OFFSET=1,p.TFHD_FLAG_SAMPLE_DESC=2,p.TFHD_FLAG_SAMPLE_DUR=8,p.TFHD_FLAG_SAMPLE_SIZE=16,p.TFHD_FLAG_SAMPLE_FLAGS=32,p.TFHD_FLAG_DUR_EMPTY=65536,p.TFHD_FLAG_DEFAULT_BASE_IS_MOOF=131072,p.TRUN_FLAGS_DATA_OFFSET=1,p.TRUN_FLAGS_FIRST_FLAG=4,p.TRUN_FLAGS_DURATION=256,p.TRUN_FLAGS_SIZE=512,p.TRUN_FLAGS_FLAGS=1024,p.TRUN_FLAGS_CTS_OFFSET=2048,p.Box.prototype.add=function(e){return this.addBox(new p[e+"Box"])},p.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},p.Box.prototype.set=function(e,t){return this[e]=t,this},p.Box.prototype.addEntry=function(e,t){return t=t||"entries",this[t]||(this[t]=[]),this[t].push(e),this},(t.BoxParser=p).parseUUID=function(e){return p.parseHex16(e)},p.parseHex16=function(e){for(var t="",i=0;i<16;i++){var r=e.readUint8().toString(16);t+=1===r.length?"0"+r:r}return t},p.parseOneBox=function(e,t,i){var r,s,a=e.getPosition(),n=0;if(e.getEndPosition()-a<8)return c.debug("BoxParser","Not enough data in stream to parse the type and size of the box"),{code:p.ERR_NOT_ENOUGH_DATA};if(i&&i<8)return c.debug("BoxParser","Not enough bytes left in the parent box to parse a new box"),{code:p.ERR_NOT_ENOUGH_DATA};var o=e.readUint32(),l=e.readString(4),d=l;if(c.debug("BoxParser","Found box of type '"+l+"' and size "+o+" at position "+a),n=8,"uuid"==l){if(e.getEndPosition()-e.getPosition()<16||i-n<16)return e.seek(a),c.debug("BoxParser","Not enough bytes left in the parent box to parse a UUID box"),{code:p.ERR_NOT_ENOUGH_DATA};n+=16,d=s=p.parseUUID(e)}if(1==o){if(e.getEndPosition()-e.getPosition()<8||i&&i-n<8)return e.seek(a),c.warn("BoxParser",'Not enough data in stream to parse the extended size of the "'+l+'" box'),{code:p.ERR_NOT_ENOUGH_DATA};o=e.readUint64(),n+=8}else if(0===o)if(i)o=i;else if("mdat"!==l)return c.error("BoxParser","Unlimited box size not supported for type: '"+l+"'"),r=new p.Box(l,o),{code:p.OK,box:r,size:r.size};return 0!==o&&o<n?(c.error("BoxParser","Box of type "+l+" has an invalid size "+o+" (too small to be a box)"),{code:p.ERR_NOT_ENOUGH_DATA,type:l,size:o,hdr_size:n,start:a}):0!==o&&i&&i<o?(c.error("BoxParser","Box of type '"+l+"' has a size "+o+" greater than its container size "+i),{code:p.ERR_NOT_ENOUGH_DATA,type:l,size:o,hdr_size:n,start:a}):0!==o&&a+o>e.getEndPosition()?(e.seek(a),c.info("BoxParser","Not enough data in stream to parse the entire '"+l+"' box"),{code:p.ERR_NOT_ENOUGH_DATA,type:l,size:o,hdr_size:n,start:a}):t?{code:p.OK,type:l,size:o,hdr_size:n,start:a}:(p[l+"Box"]?r=new p[l+"Box"](o):"uuid"!==l?(c.warn("BoxParser","Unknown box type: '"+l+"'"),(r=new p.Box(l,o)).has_unparsed_data=!0):p.UUIDBoxes[s]?r=new p.UUIDBoxes[s](o):(c.warn("BoxParser","Unknown uuid type: '"+s+"'"),(r=new p.Box(l,o)).uuid=s,r.has_unparsed_data=!0),r.hdr_size=n,r.start=a,r.write===p.Box.prototype.write&&"mdat"!==r.type&&(c.info("BoxParser","'"+d+"' box writing not yet implemented, keeping unparsed data in memory for later write"),r.parseDataAndRewind(e)),r.parse(e),(i=e.getPosition()-(r.start+r.size))<0?(c.warn("BoxParser","Parsing of box '"+d+"' did not read the entire indicated box data size (missing "+-i+" bytes), seeking forward"),e.seek(r.start+r.size)):0<i&&(c.error("BoxParser","Parsing of box '"+d+"' read "+i+" more bytes than the indicated box data size, seeking backwards"),0!==r.size&&e.seek(r.start+r.size)),{code:p.OK,box:r,size:r.size})},p.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)},p.Box.prototype.parseDataAndRewind=function(e){this.data=e.readUint8Array(this.size-this.hdr_size),e.position-=this.size-this.hdr_size},p.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},p.FullBox.prototype.parseFullHeader=function(e){this.version=e.readUint8(),this.flags=e.readUint24(),this.hdr_size+=4},p.FullBox.prototype.parse=function(e){this.parseFullHeader(e),this.data=e.readUint8Array(this.size-this.hdr_size)},p.ContainerBox.prototype.parse=function(e){for(;e.getPosition()<this.start+this.size;){if((i=p.parseOneBox(e,!1,this.size-(e.getPosition()-this.start))).code!==p.OK)return;var t,i=i.box;this.boxes.push(i),this.subBoxNames&&-1!=this.subBoxNames.indexOf(i.type)?this[this.subBoxNames[this.subBoxNames.indexOf(i.type)]+"s"].push(i):this[t="uuid"!==i.type?i.type:i.uuid]?c.warn("Box of type "+t+" already stored in field of this type"):this[t]=i}},p.Box.prototype.parseLanguage=function(e){this.language=e.readUint16(),e=[],e[0]=this.language>>10&31,e[1]=this.language>>5&31,e[2]=31&this.language,this.languageString=String.fromCharCode(e[0]+96,e[1]+96,e[2]+96)},p.SAMPLE_ENTRY_TYPE_VISUAL="Visual",p.SAMPLE_ENTRY_TYPE_AUDIO="Audio",p.SAMPLE_ENTRY_TYPE_HINT="Hint",p.SAMPLE_ENTRY_TYPE_METADATA="Metadata",p.SAMPLE_ENTRY_TYPE_SUBTITLE="Subtitle",p.SAMPLE_ENTRY_TYPE_SYSTEM="System",p.SAMPLE_ENTRY_TYPE_TEXT="Text",p.SampleEntry.prototype.parseHeader=function(e){e.readUint8Array(6),this.data_reference_index=e.readUint16(),this.hdr_size+=8},p.SampleEntry.prototype.parse=function(e){this.parseHeader(e),this.data=e.readUint8Array(this.size-this.hdr_size)},p.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},p.SampleEntry.prototype.parseFooter=function(e){p.ContainerBox.prototype.parse.call(this,e)},p.createMediaSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_HINT),p.createMediaSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_METADATA),p.createMediaSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_SUBTITLE),p.createMediaSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_SYSTEM),p.createMediaSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_TEXT),p.createMediaSampleEntryCtor(p.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)})),p.createMediaSampleEntryCtor(p.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)})),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"avc1"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"avc2"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"avc3"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"avc4"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"av01"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"hvc1"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"hev1"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"vvc1"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"vvi1"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"vvs1"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"vvcN"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"vp08"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"vp09"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_AUDIO,"mp4a"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_AUDIO,"ac-3"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_AUDIO,"ec-3"),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_AUDIO,"Opus"),p.createEncryptedSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_VISUAL,"encv"),p.createEncryptedSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_AUDIO,"enca"),p.createEncryptedSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_SUBTITLE,"encu"),p.createEncryptedSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_SYSTEM,"encs"),p.createEncryptedSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_TEXT,"enct"),p.createEncryptedSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_METADATA,"encm"),p.createBoxCtor("a1lx",(function(e){var t=16*(1+(1&e.readUint8()));this.layer_size=[];for(var i=0;i<3;i++)this.layer_size[i]=16==t?e.readUint16():e.readUint32()})),p.createBoxCtor("a1op",(function(e){this.op_index=e.readUint8()})),p.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)})),p.createBoxCtor("av1C",(function(e){var t=e.readUint8();if(t>>7&!1)c.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 c.error("av1C reserved_2 parsing problem");t=this.size-this.hdr_size-4,this.configOBUs=e.readUint8Array(t)}else c.error("av1C reserved_1 parsing problem");else c.error("av1C version "+this.version+" not supported")})),p.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;0<i&&(this.ext=e.readUint8Array(i))})),p.createBoxCtor("btrt",(function(e){this.bufferSizeDB=e.readUint32(),this.maxBitrate=e.readUint32(),this.avgBitrate=e.readUint32()})),p.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()})),p.createBoxCtor("clli",(function(e){this.max_content_light_level=e.readUint16(),this.max_pic_average_light_level=e.readUint16()})),p.createFullBoxCtor("co64",(function(e){var t,i=e.readUint32();if(this.chunk_offsets=[],0===this.version)for(t=0;t<i;t++)this.chunk_offsets.push(e.readUint64())})),p.createFullBoxCtor("CoLL",(function(e){this.maxCLL=e.readUint16(),this.maxFALL=e.readUint16()})),p.createBoxCtor("colr",(function(e){var t;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(),t=e.readUint8(),this.full_range_flag=t>>7):"rICC"!==this.colour_type&&"prof"!==this.colour_type||(this.ICC_profile=e.readUint8Array(this.size-4))})),p.createFullBoxCtor("cprt",(function(e){this.parseLanguage(e),this.notice=e.readCString()})),p.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())})),p.createFullBoxCtor("ctts",(function(e){var t,i=e.readUint32();if(this.sample_counts=[],this.sample_offsets=[],0===this.version)for(t=0;t<i;t++){this.sample_counts.push(e.readUint32());var r=e.readInt32();r<0&&c.warn("BoxParser","ctts box uses negative values without using version 1"),this.sample_offsets.push(r)}else if(1==this.version)for(t=0;t<i;t++)this.sample_counts.push(e.readUint32()),this.sample_offsets.push(e.readInt32())})),p.createBoxCtor("dac3",(function(e){var t=e.readUint8(),i=e.readUint8();e=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|e>>5&7})),p.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 r={},s=(this.ind_subs.push(r),e.readUint8()),a=e.readUint8(),n=e.readUint8();r.fscod=s>>6,r.bsid=s>>1&31,r.bsmod=(1&s)<<4|a>>4&15,r.acmod=a>>1&7,r.lfeon=1&a,r.num_dep_sub=n>>1&15,0<r.num_dep_sub&&(r.chan_loc=(1&n)<<8|e.readUint8())}})),p.createFullBoxCtor("dfLa",(function(e){var t=[],i=["STREAMINFO","PADDING","APPLICATION","SEEKTABLE","VORBIS_COMMENT","CUESHEET","PICTURE","RESERVED"];for(this.parseFullHeader(e);;){var r=e.readUint8(),s=Math.min(127&r,i.length-1);if(s?e.readUint8Array(e.readUint24()):(e.readUint8Array(13),this.samplerate=e.readUint32()>>12,e.readUint8Array(20)),t.push(i[s]),128&r)break}this.numMetadataBlocks=t.length+" ("+t.join(", ")+")"})),p.createBoxCtor("dimm",(function(e){this.bytessent=e.readUint64()})),p.createBoxCtor("dmax",(function(e){this.time=e.readUint32()})),p.createBoxCtor("dmed",(function(e){this.bytessent=e.readUint64()})),p.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()}})),p.createFullBoxCtor("dref",(function(e){var t;this.entries=[];for(var i=e.readUint32(),r=0;r<i;r++){if((t=p.parseOneBox(e,!1,this.size-(e.getPosition()-this.start))).code!==p.OK)return;t=t.box,this.entries.push(t)}})),p.createBoxCtor("drep",(function(e){this.bytessent=e.readUint64()})),p.createFullBoxCtor("elng",(function(e){this.extended_language=e.readString(this.size-this.hdr_size)})),p.createFullBoxCtor("elst",(function(e){this.entries=[];for(var t=e.readUint32(),i=0;i<t;i++){var r={};this.entries.push(r),1===this.version?(r.segment_duration=e.readUint64(),r.media_time=e.readInt64()):(r.segment_duration=e.readUint32(),r.media_time=e.readInt32()),r.media_rate_integer=e.readInt16(),r.media_rate_fraction=e.readInt16()}})),p.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)})),p.createFullBoxCtor("esds",(function(e){e=e.readUint8Array(this.size-this.hdr_size);var t=new a;this.esd=t.parseOneDescriptor(new r(e.buffer,0,r.BIG_ENDIAN))})),p.createBoxCtor("fiel",(function(e){this.fieldCount=e.readUint8(),this.fieldOrdering=e.readUint8()})),p.createBoxCtor("frma",(function(e){this.data_format=e.readString(4)})),p.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;4<=t;)this.compatible_brands[i]=e.readString(4),t-=4,i++})),p.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)))})),p.createBoxCtor("hvcC",(function(e){this.configurationVersion=e.readUint8(),i=e.readUint8(),this.general_profile_space=i>>6,this.general_tier_flag=(32&i)>>5,this.general_profile_idc=31&i,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(),i=e.readUint8(),this.constantFrameRate=i>>6,this.numTemporalLayers=(13&i)>>3,this.temporalIdNested=(4&i)>>2,this.lengthSizeMinusOne=3&i,this.nalu_arrays=[];for(var t,i,r=e.readUint8(),s=0;s<r;s++)for(var a=[],n=(this.nalu_arrays.push(a),i=e.readUint8(),a.completeness=(128&i)>>7,a.nalu_type=63&i,e.readUint16()),o=0;o<n;o++){var l={};a.push(l),t=e.readUint16(),l.data=e.readUint8Array(t)}})),p.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=p.parseOneBox(e,!1,this.size-(e.getPosition()-this.start))).code!==p.OK)return;"infe"!==t.box.type&&c.error("BoxParser","Expected 'infe' box, got "+t.box.type),this.item_infos[i]=t.box}})),p.createFullBoxCtor("iloc",(function(e){var t=e.readUint8(),i=(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=[],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 r=0;r<i;r++){var s={};if(this.items.push(s),this.version<2)s.item_ID=e.readUint16();else{if(2!==this.version)throw"version of iloc box not supported";s.item_ID=e.readUint16()}switch(1===this.version||2===this.version?s.construction_method=15&e.readUint16():s.construction_method=0,s.data_reference_index=e.readUint16(),this.base_offset_size){case 0:s.base_offset=0;break;case 4:s.base_offset=e.readUint32();break;case 8:s.base_offset=e.readUint64();break;default:throw"Error reading base offset size"}var a=e.readUint16();s.extents=[];for(var n=0;n<a;n++){var o={};if(s.extents.push(o),1===this.version||2===this.version)switch(this.index_size){case 0:o.extent_index=0;break;case 4:o.extent_index=e.readUint32();break;case 8:o.extent_index=e.readUint64();break;default:throw"Error reading extent index"}switch(this.offset_size){case 0:o.extent_offset=0;break;case 4:o.extent_offset=e.readUint32();break;case 8:o.extent_offset=e.readUint64();break;default:throw"Error reading extent index"}switch(this.length_size){case 0:o.extent_length=0;break;case 4:o.extent_length=e.readUint32();break;case 8:o.extent_length=e.readUint64();break;default:throw"Error reading extent index"}}}})),p.createBoxCtor("imir",(function(e){e=e.readUint8(),this.reserved=e>>7,this.axis=1&e})),p.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),c.warn("BoxParser","Cannot parse extension type"),void e.seek(this.start+this.size);2<=this.version&&(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()))})),p.createFullBoxCtor("ipma",(function(e){var t,i;for(entry_count=e.readUint32(),this.associations=[],t=0;t<entry_count;t++){var r={},s=(this.associations.push(r),this.version<1?r.id=e.readUint16():r.id=e.readUint32(),e.readUint8());for(r.props=[],i=0;i<s;i++){var a=e.readUint8(),n={};r.props.push(n),n.essential=(128&a)>>7==1,1&this.flags?n.property_index=(127&a)<<8|e.readUint8():n.property_index=127&a}}})),p.createFullBoxCtor("iref",(function(e){var t;for(this.references=[];e.getPosition()<this.start+this.size;){if((t=p.parseOneBox(e,!0,this.size-(e.getPosition()-this.start))).code!==p.OK)return;(t=new(0===this.version?p.SingleItemTypeReferenceBox:p.SingleItemTypeReferenceBoxLarge)(t.type,t.size,t.hdr_size,t.start)).write===p.Box.prototype.write&&"mdat"!==t.type&&(c.warn("BoxParser",t.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),t.parseDataAndRewind(e)),t.parse(e),this.references.push(t)}})),p.createBoxCtor("irot",(function(e){this.angle=3&e.readUint8()})),p.createFullBoxCtor("ispe",(function(e){this.image_width=e.readUint32(),this.image_height=e.readUint32()})),p.createFullBoxCtor("kind",(function(e){this.schemeURI=e.readCString(),this.value=e.readCString()})),p.createFullBoxCtor("leva",(function(e){var t=e.readUint8();this.levels=[];for(var i=0;i<t;i++){var r={},s=((this.levels[i]=r).track_ID=e.readUint32(),e.readUint8());switch(r.padding_flag=s>>7,r.assignment_type=127&s,r.assignment_type){case 0:r.grouping_type=e.readString(4);break;case 1:r.grouping_type=e.readString(4),r.grouping_type_parameter=e.readUint32();break;case 2:case 3:break;case 4:r.sub_track_id=e.readUint32();break;default:c.warn("BoxParser","Unknown leva assignement type")}}})),p.createBoxCtor("lsel",(function(e){this.layer_id=e.readUint16()})),p.createBoxCtor("maxr",(function(e){this.period=e.readUint32(),this.bytes=e.readUint32()})),p.createBoxCtor("mdcv",(function(e){this.display_primaries=[],this.display_primaries[0]={},this.display_primaries[0].x=e.readUint16(),this.display_primaries[0].y=e.readUint16(),this.display_primaries[1]={},this.display_primaries[1].x=e.readUint16(),this.display_primaries[1].y=e.readUint16(),this.display_primaries[2]={},this.display_primaries[2].x=e.readUint16(),this.display_primaries[2].y=e.readUint16(),this.white_point={},this.white_point.x=e.readUint16(),this.white_point.y=e.readUint16(),this.max_display_mastering_luminance=e.readUint32(),this.min_display_mastering_luminance=e.readUint32()})),p.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()})),p.createFullBoxCtor("mehd",(function(e){1&this.flags&&(c.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()})),p.createFullBoxCtor("meta",(function(e){this.boxes=[],p.ContainerBox.prototype.parse.call(this,e)})),p.createFullBoxCtor("mfhd",(function(e){this.sequence_number=e.readUint32()})),p.createFullBoxCtor("mfro",(function(e){this._size=e.readUint32()})),p.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()})),p.createBoxCtor("npck",(function(e){this.packetssent=e.readUint32()})),p.createBoxCtor("nump",(function(e){this.packetssent=e.readUint64()})),p.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()})),p.createBoxCtor("pasp",(function(e){this.hSpacing=e.readUint32(),this.vSpacing=e.readUint32()})),p.createBoxCtor("payl",(function(e){this.text=e.readString(this.size-this.hdr_size)})),p.createBoxCtor("payt",(function(e){this.payloadID=e.readUint32();var t=e.readUint8();this.rtpmap_string=e.readString(t)})),p.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()})),p.createFullBoxCtor("pitm",(function(e){0===this.version?this.item_id=e.readUint16():this.item_id=e.readUint32()})),p.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()})),p.createBoxCtor("pmax",(function(e){this.bytes=e.readUint32()})),p.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()})),p.createFullBoxCtor("pssh",(function(e){if(this.system_id=p.parseHex16(e),0<this.version){var t=e.readUint32();this.kid=[];for(var i=0;i<t;i++)this.kid[i]=p.parseHex16(e)}var r=e.readUint32();0<r&&(this.data=e.readUint8Array(r))})),p.createFullBoxCtor("clef",(function(e){this.width=e.readUint32(),this.height=e.readUint32()})),p.createFullBoxCtor("enof",(function(e){this.width=e.readUint32(),this.height=e.readUint32()})),p.createFullBoxCtor("prof",(function(e){this.width=e.readUint32(),this.height=e.readUint32()})),p.createContainerBoxCtor("tapt",null,["clef","prof","enof"]),p.createBoxCtor("rtp ",(function(e){this.descriptionformat=e.readString(4),this.sdptext=e.readString(this.size-this.hdr_size-4)})),p.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()})),p.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()})),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_METADATA,"mett",(function(e){this.parseHeader(e),this.content_encoding=e.readCString(),this.mime_format=e.readCString(),this.parseFooter(e)})),p.createSampleEntryCtor(p.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)})),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_SUBTITLE,"sbtt",(function(e){this.parseHeader(e),this.content_encoding=e.readCString(),this.mime_format=e.readCString(),this.parseFooter(e)})),p.createSampleEntryCtor(p.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)})),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_SUBTITLE,"stxt",(function(e){this.parseHeader(e),this.content_encoding=e.readCString(),this.mime_format=e.readCString(),this.parseFooter(e)})),p.createSampleEntryCtor(p.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)})),p.createSampleEntryCtor(p.SAMPLE_ENTRY_TYPE_METADATA,"wvtt",(function(e){this.parseHeader(e),this.parseFooter(e)})),p.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 r=this.description_length-4-4*i;for(this.num_output_samples=[],this.num_total_samples=[],t=0;t<r/4;t++)this.num_output_samples[t]=e.readUint16(),this.num_total_samples[t]=e.readUint16()})),p.createSampleGroupCtor("avll",(function(e){this.layerNumber=e.readUint8(),this.accurateStatisticsFlag=e.readUint8(),this.avgBitRate=e.readUint16(),this.avgFrameRate=e.readUint16()})),p.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(),r=0;r<i;r++){var s={};this.dependency.push(s),s.subSeqDirectionFlag=e.readUint8(),s.layerNumber=e.readUint8(),s.subSequenceIdentifier=e.readUint16()}})),p.createSampleGroupCtor("dtrt",(function(e){c.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),p.createSampleGroupCtor("mvif",(function(e){c.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),p.createSampleGroupCtor("prol",(function(e){this.roll_distance=e.readInt16()})),p.createSampleGroupCtor("rap ",(function(e){e=e.readUint8(),this.num_leading_samples_known=e>>7,this.num_leading_samples=127&e})),p.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)c.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()}})),p.createSampleGroupCtor("roll",(function(e){this.roll_distance=e.readInt16()})),p.SampleGroupEntry.prototype.parse=function(e){c.warn("BoxParser","Unknown Sample Group type: "+this.grouping_type),this.data=e.readUint8Array(this.description_length)},p.createSampleGroupCtor("scif",(function(e){c.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),p.createSampleGroupCtor("scnm",(function(e){c.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),p.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=p.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))})),p.createSampleGroupCtor("stsa",(function(e){c.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),p.createSampleGroupCtor("sync",(function(e){e=e.readUint8(),this.NAL_unit_type=63&e})),p.createSampleGroupCtor("tele",(function(e){e=e.readUint8(),this.level_independently_decodable=e>>7})),p.createSampleGroupCtor("tsas",(function(e){c.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),p.createSampleGroupCtor("tscl",(function(e){c.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),p.createSampleGroupCtor("vipr",(function(e){c.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),p.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 r={};this.entries.push(r),r.sample_count=e.readInt32(),r.group_description_index=e.readInt32()}})),p.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))})),p.createBoxCtor("sdp ",(function(e){this.sdptext=e.readString(this.size-this.hdr_size)})),p.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 r=0;r<i;r++)t=e.readUint8(),this.is_leading[r]=t>>6,this.sample_depends_on[r]=t>>4&3,this.sample_is_depended_on[r]=t>>2&3,this.sample_has_redundancy[r]=3&t})),p.createFullBoxCtor("senc"),p.createFullBoxCtor("sgpd",(function(e){this.grouping_type=e.readString(4),c.debug("BoxParser","Found Sample Groups of type "+this.grouping_type),1===this.version?this.default_length=e.readUint32():this.default_length=0,2<=this.version&&(this.default_group_description_index=e.readUint32()),this.entries=[];for(var t=e.readUint32(),i=0;i<t;i++){var r=new(p[this.grouping_type+"SampleGroupEntry"]?p[this.grouping_type+"SampleGroupEntry"]:p.SampleGroupEntry)(this.grouping_type);this.entries.push(r),1===this.version&&0===this.default_length?r.description_length=e.readUint32():r.description_length=this.default_length,r.write===p.SampleGroupEntry.prototype.write&&(c.info("BoxParser","SampleGroup for type "+this.grouping_type+" writing not yet implemented, keeping unparsed data in memory for later write"),r.data=e.readUint8Array(r.description_length),e.position-=r.description_length),r.parse(e)}})),p.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 r={},s=(this.references.push(r),e.readUint32());r.reference_type=s>>31&1,r.referenced_size=2147483647&s,r.subsegment_duration=e.readUint32(),s=e.readUint32(),r.starts_with_SAP=s>>31&1,r.SAP_type=s>>28&7,r.SAP_delta_time=268435455&s}})),p.SingleItemTypeReferenceBox=function(e,t,i,r){p.Box.call(this,e,t),this.hdr_size=i,this.start=r},p.SingleItemTypeReferenceBox.prototype=new p.Box,p.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]=e.readUint16()},p.SingleItemTypeReferenceBoxLarge=function(e,t,i,r){p.Box.call(this,e,t),this.hdr_size=i,this.start=r},p.SingleItemTypeReferenceBoxLarge.prototype=new p.Box,p.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]=e.readUint32()},p.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()})),p.createFullBoxCtor("smhd",(function(e){this.balance=e.readUint16(),e.readUint16()})),p.createFullBoxCtor("ssix",(function(e){this.subsegments=[];for(var t=e.readUint32(),i=0;i<t;i++){var r={};this.subsegments.push(r),r.ranges=[];for(var s=e.readUint32(),a=0;a<s;a++){var n={};r.ranges.push(n),n.level=e.readUint8(),n.range_size=e.readUint24()}}})),p.createFullBoxCtor("stco",(function(e){var t=e.readUint32();if(this.chunk_offsets=[],0===this.version)for(var i=0;i<t;i++)this.chunk_offsets.push(e.readUint32())})),p.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()})),p.createFullBoxCtor("sthd"),p.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()})),p.createFullBoxCtor("stsc",(function(e){var t,i=e.readUint32();if(this.first_chunk=[],this.samples_per_chunk=[],this.sample_description_index=[],0===this.version)for(t=0;t<i;t++)this.first_chunk.push(e.readUint32()),this.samples_per_chunk.push(e.readUint32()),this.sample_description_index.push(e.readUint32())})),p.createFullBoxCtor("stsd",(function(e){var t,i,r,s;for(this.entries=[],r=e.readUint32(),t=1;t<=r;t++){if((i=p.parseOneBox(e,!0,this.size-(e.getPosition()-this.start))).code!==p.OK)return;p[i.type+"SampleEntry"]?((s=new p[i.type+"SampleEntry"](i.size)).hdr_size=i.hdr_size,s.start=i.start):(c.warn("BoxParser","Unknown sample entry type: "+i.type),s=new p.SampleEntry(i.type,i.size,i.hdr_size,i.start)),s.write===p.SampleEntry.prototype.write&&(c.info("BoxParser","SampleEntry "+s.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),s.parseDataAndRewind(e)),s.parse(e),this.entries.push(s)}})),p.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()})),p.createFullBoxCtor("stsh",(function(e){var t,i=e.readUint32();if(this.shadowed_sample_numbers=[],this.sync_sample_numbers=[],0===this.version)for(t=0;t<i;t++)this.shadowed_sample_numbers.push(e.readUint32()),this.sync_sample_numbers.push(e.readUint32())})),p.createFullBoxCtor("stss",(function(e){var t,i=e.readUint32();if(0===this.version)for(this.sample_numbers=[],t=0;t<i;t++)this.sample_numbers.push(e.readUint32())})),p.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})),p.createFullBoxCtor("stts",(function(e){var t,i,r=e.readUint32();if(this.sample_counts=[],this.sample_deltas=[],0===this.version)for(t=0;t<r;t++)this.sample_counts.push(e.readUint32()),(i=e.readInt32())<0&&(c.warn("BoxParser","File uses negative stts sample delta, using value 1 instead, sync may be lost!"),i=1),this.sample_deltas.push(i)})),p.createFullBoxCtor("stvi",(function(e){var t=e.readUint32();this.single_view_allowed=3&t,this.stereo_scheme=e.readUint32();var i;t=e.readUint32();for(this.stereo_indication_type=e.readString(t),this.boxes=[];e.getPosition()<this.start+this.size;){if((i=p.parseOneBox(e,!1,this.size-(e.getPosition()-this.start))).code!==p.OK)return;i=i.box,this.boxes.push(i),this[i.type]=i}})),p.createBoxCtor("styp",(function(e){p.ftypBox.prototype.parse.call(this,e)})),p.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 r=e.readUint8();this.sample_sizes[t]=r>>4&15,this.sample_sizes[t+1]=15&r}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 c.error("BoxParser","Error in length field in stz2 box")})),p.createFullBoxCtor("subs",(function(e){var t,i,r,s=e.readUint32();for(this.entries=[],t=0;t<s;t++){var a={};if((this.entries[t]=a).sample_delta=e.readUint32(),a.subsamples=[],0<(r=e.readUint16()))for(i=0;i<r;i++){var n={};a.subsamples.push(n),1==this.version?n.size=e.readUint32():n.size=e.readUint16(),n.priority=e.readUint8(),n.discardable=e.readUint8(),n.codec_specific_parameters=e.readUint32()}}})),p.createFullBoxCtor("tenc",(function(e){var t;e.readUint8(),0===this.version?e.readUint8():(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=p.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))})),p.createFullBoxCtor("tfdt",(function(e){1==this.version?this.baseMediaDecodeTime=e.readUint64():this.baseMediaDecodeTime=e.readUint32()})),p.createFullBoxCtor("tfhd",(function(e){var t=0;this.track_id=e.readUint32(),this.size-this.hdr_size>t&&this.flags&p.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&p.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&p.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&p.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&p.TFHD_FLAG_SAMPLE_FLAGS?this.default_sample_flags=e.readUint32():this.default_sample_flags=0})),p.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(),r=0;r<i;r++)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)]()})),p.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()})),p.createBoxCtor("tmax",(function(e){this.time=e.readUint32()})),p.createBoxCtor("tmin",(function(e){this.time=e.readUint32()})),p.createBoxCtor("totl",(function(e){this.bytessent=e.readUint32()})),p.createBoxCtor("tpay",(function(e){this.bytessent=e.readUint32()})),p.createBoxCtor("tpyl",(function(e){this.bytessent=e.readUint64()})),p.TrackGroupTypeBox.prototype.parse=function(e){this.parseFullHeader(e),this.track_group_id=e.readUint32()},p.createTrackGroupCtor("msrc"),p.TrackReferenceTypeBox=function(e,t,i,r){p.Box.call(this,e,t),this.hdr_size=i,this.start=r},p.TrackReferenceTypeBox.prototype=new p.Box,p.TrackReferenceTypeBox.prototype.parse=function(e){this.track_ids=e.readUint32Array((this.size-this.hdr_size)/4)},p.trefBox.prototype.parse=function(e){for(var t;e.getPosition()<this.start+this.size;){if((t=p.parseOneBox(e,!0,this.size-(e.getPosition()-this.start))).code!==p.OK)return;(t=new p.TrackReferenceTypeBox(t.type,t.size,t.hdr_size,t.start)).write===p.Box.prototype.write&&"mdat"!==t.type&&(c.info("BoxParser","TrackReference "+t.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),t.parseDataAndRewind(e)),t.parse(e),this.boxes.push(t)}},p.createFullBoxCtor("trep",(function(e){for(this.track_ID=e.readUint32(),this.boxes=[];e.getPosition()<this.start+this.size;){if((ret=p.parseOneBox(e,!1,this.size-(e.getPosition()-this.start))).code!==p.OK)return;box=ret.box,this.boxes.push(box)}})),p.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()})),p.createBoxCtor("trpy",(function(e){this.bytessent=e.readUint64()})),p.createFullBoxCtor("trun",(function(e){var t=0;if(this.sample_count=e.readUint32(),this.size-this.hdr_size>(t+=4)&&this.flags&p.TRUN_FLAGS_DATA_OFFSET?(this.data_offset=e.readInt32(),t+=4):this.data_offset=0,this.size-this.hdr_size>t&&this.flags&p.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&p.TRUN_FLAGS_DURATION&&(this.sample_duration[i]=e.readUint32()),this.flags&p.TRUN_FLAGS_SIZE&&(this.sample_size[i]=e.readUint32()),this.flags&p.TRUN_FLAGS_FLAGS&&(this.sample_flags[i]=e.readUint32()),this.flags&p.TRUN_FLAGS_CTS_OFFSET&&(0===this.version?this.sample_composition_time_offset[i]=e.readUint32():this.sample_composition_time_offset[i]=e.readInt32())})),p.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()})),p.createFullBoxCtor("txtC",(function(e){this.config=e.readCString()})),p.createFullBoxCtor("url ",(function(e){1!==this.flags&&(this.location=e.readCString())})),p.createFullBoxCtor("urn ",(function(e){this.name=e.readCString(),0<this.size-this.hdr_size-this.name.length-1&&(this.location=e.readCString())})),p.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;")})),p.createUUIDBox("d08a4f1810f34a82b6c832d8aba183d3",!0,!1,(function(e){this.system_id=p.parseHex16(e);var t=e.readUint32();0<t&&(this.data=e.readUint8Array(t))})),p.createUUIDBox("a2394f525a9b4f14a2446c427c648df4",!0,!1),p.createUUIDBox("8974dbce7be74c5184f97148f9882554",!0,!1,(function(e){this.default_AlgorithmID=e.readUint24(),this.default_IV_size=e.readUint8(),this.default_KID=p.parseHex16(e)})),p.createUUIDBox("d4807ef2ca3946958e5426cb9e46a79f",!0,!1,(function(e){this.fragment_count=e.readUint8(),this.entries=[];for(var t=0;t<this.fragment_count;t++){var i={},r=0,s=0;s=1===this.version?(r=e.readUint64(),e.readUint64()):(r=e.readUint32(),e.readUint32());i.absolute_time=r,i.absolute_duration=s,this.entries.push(i)}})),p.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())})),p.createFullBoxCtor("vmhd",(function(e){this.graphicsmode=e.readUint16(),this.opcolor=e.readUint16Array(3)})),p.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.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)})),p.createBoxCtor("vttC",(function(e){this.text=e.readString(this.size-this.hdr_size)})),p.createFullBoxCtor("vvcC",(function(e){var t,i={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(i.stream_read_1_bytes(e),i.extract_bits(5),this.lengthSizeMinusOne=i.extract_bits(2),this.ptl_present_flag=i.extract_bits(1),this.ptl_present_flag){if(i.stream_read_2_bytes(e),this.ols_idx=i.extract_bits(9),this.num_sublayers=i.extract_bits(3),this.constant_frame_rate=i.extract_bits(2),this.chroma_format_idc=i.extract_bits(2),i.stream_read_1_bytes(e),this.bit_depth_minus8=i.extract_bits(3),i.extract_bits(5),i.stream_read_2_bytes(e),i.extract_bits(2),this.num_bytes_constraint_info=i.extract_bits(6),this.general_profile_idc=i.extract_bits(7),this.general_tier_flag=i.extract_bits(1),this.general_level_idc=e.readUint8(),i.stream_read_1_bytes(e),this.ptl_frame_only_constraint_flag=i.extract_bits(1),this.ptl_multilayer_enabled_flag=i.extract_bits(1),this.general_constraint_info=new Uint8Array(this.num_bytes_constraint_info),this.num_bytes_constraint_info){for(o=0;o<this.num_bytes_constraint_info-1;o++){var r=i.extract_bits(6),s=(i.stream_read_1_bytes(e),i.extract_bits(2));this.general_constraint_info[o]=r<<2|s}this.general_constraint_info[this.num_bytes_constraint_info-1]=i.extract_bits(6)}else i.extract_bits(6);for(i.stream_read_1_bytes(e),this.ptl_sublayer_present_mask=0,t=this.num_sublayers-2;0<=t;--t){var a=i.extract_bits(1);this.ptl_sublayer_present_mask|=a<<t}for(t=this.num_sublayers;t<=8&&1<this.num_sublayers;++t)i.extract_bits(1);for(t=this.num_sublayers-2;0<=t;--t)this.ptl_sublayer_present_mask&1<<t&&(this.sublayer_level_idc[t]=e.readUint8());if(this.ptl_num_sub_profiles=e.readUint8(),this.general_sub_profile_idc=[],this.ptl_num_sub_profiles)for(o=0;o<this.ptl_num_sub_profiles;o++)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=[];for(var n=e.readUint8(),o=0;o<n;o++){var l=[],d=(this.nalu_arrays.push(l),i.stream_read_1_bytes(e),l.completeness=i.extract_bits(1),i.extract_bits(2),l.nalu_type=i.extract_bits(5),1);for(13!=l.nalu_type&&12!=l.nalu_type&&(d=e.readUint16()),t=0;t<d;t++){var h=e.readUint16();l.push({data:e.readUint8Array(h),length:h})}}})),p.createFullBoxCtor("vvnC",(function(e){var t=strm.readUint8();this.lengthSizeMinusOne=3&t})),p.SampleEntry.prototype.isVideo=function(){return!1},p.SampleEntry.prototype.isAudio=function(){return!1},p.SampleEntry.prototype.isSubtitle=function(){return!1},p.SampleEntry.prototype.isMetadata=function(){return!1},p.SampleEntry.prototype.isHint=function(){return!1},p.SampleEntry.prototype.getCodec=function(){return this.type.replace(".","")},p.SampleEntry.prototype.getWidth=function(){return""},p.SampleEntry.prototype.getHeight=function(){return""},p.SampleEntry.prototype.getChannelCount=function(){return""},p.SampleEntry.prototype.getSampleRate=function(){return""},p.SampleEntry.prototype.getSampleSize=function(){return""},p.VisualSampleEntry.prototype.isVideo=function(){return!0},p.VisualSampleEntry.prototype.getWidth=function(){return this.width},p.VisualSampleEntry.prototype.getHeight=function(){return this.height},p.AudioSampleEntry.prototype.isAudio=function(){return!0},p.AudioSampleEntry.prototype.getChannelCount=function(){return this.channel_count},p.AudioSampleEntry.prototype.getSampleRate=function(){return this.samplerate},p.AudioSampleEntry.prototype.getSampleSize=function(){return this.samplesize},p.SubtitleSampleEntry.prototype.isSubtitle=function(){return!0},p.MetadataSampleEntry.prototype.isMetadata=function(){return!0},p.decimalToHex=function(e,t){var i=Number(e).toString(16);for(t=null==t?2:t;i.length<t;)i="0"+i;return i},p.avc1SampleEntry.prototype.getCodec=p.avc2SampleEntry.prototype.getCodec=p.avc3SampleEntry.prototype.getCodec=p.avc4SampleEntry.prototype.getCodec=function(){var e=p.SampleEntry.prototype.getCodec.call(this);return this.avcC?e+"."+p.decimalToHex(this.avcC.AVCProfileIndication)+p.decimalToHex(this.avcC.profile_compatibility)+p.decimalToHex(this.avcC.AVCLevelIndication):e},p.hev1SampleEntry.prototype.getCodec=p.hvc1SampleEntry.prototype.getCodec=function(){var e=p.SampleEntry.prototype.getCodec.call(this);if(this.hvcC){switch(e+=".",this.hvcC.general_profile_space){case 0:e+="";break;case 1:e+="A";break;case 2:e+="B";break;case 3:e+="C"}e=e+this.hvcC.general_profile_idc+".";for(var t=this.hvcC.general_profile_compatibility,i=0,r=0;r<32&&(i|=1&t,31!=r);r++)i<<=1,t>>=1;e=e+p.decimalToHex(i,0)+".",0===this.hvcC.general_tier_flag?e+="L":e+="H",e+=this.hvcC.general_level_idc;var s=!1,a="";for(r=5;0<=r;r--)(this.hvcC.general_constraint_indicator[r]||s)&&(a="."+p.decimalToHex(this.hvcC.general_constraint_indicator[r],0)+a,s=!0);e+=a}return e},p.vvc1SampleEntry.prototype.getCodec=p.vvi1SampleEntry.prototype.getCodec=function(){var e=p.SampleEntry.prototype.getCodec.call(this);if(this.vvcC){e+="."+this.vvcC.general_profile_idc,this.vvcC.general_tier_flag?e+=".H":e+=".L",e+=this.vvcC.general_level_idc;var t="";if(this.vvcC.general_constraint_info){var i,r=[],s=0;s=(s|=this.vvcC.ptl_frame_only_constraint<<7)|this.vvcC.ptl_multilayer_enabled<<6;for(l=0;l<this.vvcC.general_constraint_info.length;++l)s|=this.vvcC.general_constraint_info[l]>>2&63,r.push(s),s&&(i=l),s=this.vvcC.general_constraint_info[l]>>2&3;if(void 0===i)t=".CA";else{t=".C";for(var a="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",n=0,o=0,l=0;l<=i;++l)for(n=n<<8|r[l],o+=8;5<=o;)t+=a[n>>o-5&31],n&=(1<<(o-=5))-1;o&&(t+=a[31&(n<<=5-o)])}}e+=t}return e},p.mp4aSampleEntry.prototype.getCodec=function(){var e,t,i=p.SampleEntry.prototype.getCodec.call(this);return this.esds&&this.esds.esd?(e=this.esds.esd.getOTI(),t=this.esds.esd.getAudioConfig(),i+"."+p.decimalToHex(e)+(t?"."+t:"")):i},p.stxtSampleEntry.prototype.getCodec=function(){var e=p.SampleEntry.prototype.getCodec.call(this);return this.mime_format?e+"."+this.mime_format:e},p.vp08SampleEntry.prototype.getCodec=p.vp09SampleEntry.prototype.getCodec=function(){var e=p.SampleEntry.prototype.getCodec.call(this),t=this.vpcC.level,i=this.vpcC.bitDepth;return e+".0"+this.vpcC.profile+"."+(t=0==t?"00":t)+"."+(8==i?"08":i)},p.av01SampleEntry.prototype.getCodec=function(){var e,t=p.SampleEntry.prototype.getCodec.call(this),i=this.av1C.seq_level_idx_0;return 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=i<10?"0"+i:i)+(this.av1C.seq_tier_0?"H":"M")+"."+e},p.Box.prototype.writeHeader=function(e,t){this.size+=8,this.size>u&&(this.size+=8),"uuid"===this.type&&(this.size+=16),c.debug("BoxWriter","Writing box "+this.type+" of size: "+this.size+" at position "+e.getPosition()+(t||"")),this.size>u?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>u&&e.writeUint64(this.size)},p.FullBox.prototype.writeHeader=function(e){this.size+=4,p.Box.prototype.writeHeader.call(this,e," v="+this.version+" f="+this.flags),e.writeUint8(this.version),e.writeUint24(this.flags)},p.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))},p.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);c.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},p.TrackReferenceTypeBox.prototype.write=function(e){this.size=4*this.track_ids.length,this.writeHeader(e),e.writeUint32Array(this.track_ids)},p.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)},p.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])},p.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)},p.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])},p.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;c.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},p.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)},p.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)}},p.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)},p.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)},p.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)},p.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)},p.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)},p.mehdBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4,this.writeHeader(e),e.writeUint32(this.fragment_duration)},p.mfhdBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4,this.writeHeader(e),e.writeUint32(this.sequence_number)},p.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)},p.SampleEntry.prototype.writeHeader=function(e){this.size=8,p.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)},p.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;c.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},p.SampleEntry.prototype.write=function(e){this.writeHeader(e),e.writeUint8Array(this.data),this.size+=this.data.length,c.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},p.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)},p.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)},p.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)},p.SampleGroupEntry.prototype.write=function(e){e.writeUint8Array(this.data)},p.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)}},p.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),2<=this.version&&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)},p.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)}},p.smhdBox.prototype.write=function(e){this.version=0,this.flags=1,this.size=4,this.writeHeader(e),e.writeUint16(this.balance),e.writeUint16(0)},p.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)},p.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])},p.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;c.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},p.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])},p.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)},p.stszBox.prototype.write=function(e){var t,i=!0;if(this.version=0,(this.flags=0)<this.sample_sizes.length)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)},p.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])},p.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)},p.tfhdBox.prototype.write=function(e){this.version=0,this.size=4,this.flags&p.TFHD_FLAG_BASE_DATA_OFFSET&&(this.size+=8),this.flags&p.TFHD_FLAG_SAMPLE_DESC&&(this.size+=4),this.flags&p.TFHD_FLAG_SAMPLE_DUR&&(this.size+=4),this.flags&p.TFHD_FLAG_SAMPLE_SIZE&&(this.size+=4),this.flags&p.TFHD_FLAG_SAMPLE_FLAGS&&(this.size+=4),this.writeHeader(e),e.writeUint32(this.track_id),this.flags&p.TFHD_FLAG_BASE_DATA_OFFSET&&e.writeUint64(this.base_data_offset),this.flags&p.TFHD_FLAG_SAMPLE_DESC&&e.writeUint32(this.default_sample_description_index),this.flags&p.TFHD_FLAG_SAMPLE_DUR&&e.writeUint32(this.default_sample_duration),this.flags&p.TFHD_FLAG_SAMPLE_SIZE&&e.writeUint32(this.default_sample_size),this.flags&p.TFHD_FLAG_SAMPLE_FLAGS&&e.writeUint32(this.default_sample_flags)},p.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)},p.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)},p.trunBox.prototype.write=function(e){this.version=0,this.size=4,this.flags&p.TRUN_FLAGS_DATA_OFFSET&&(this.size+=4),this.flags&p.TRUN_FLAGS_FIRST_FLAG&&(this.size+=4),this.flags&p.TRUN_FLAGS_DURATION&&(this.size+=4*this.sample_duration.length),this.flags&p.TRUN_FLAGS_SIZE&&(this.size+=4*this.sample_size.length),this.flags&p.TRUN_FLAGS_FLAGS&&(this.size+=4*this.sample_flags.length),this.flags&p.TRUN_FLAGS_CTS_OFFSET&&(this.size+=4*this.sample_composition_time_offset.length),this.writeHeader(e),e.writeUint32(this.sample_count),this.flags&p.TRUN_FLAGS_DATA_OFFSET&&(this.data_offset_position=e.getPosition(),e.writeInt32(this.data_offset)),this.flags&p.TRUN_FLAGS_FIRST_FLAG&&e.writeUint32(this.first_sample_flags);for(var t=0;t<this.sample_count;t++)this.flags&p.TRUN_FLAGS_DURATION&&e.writeUint32(this.sample_duration[t]),this.flags&p.TRUN_FLAGS_SIZE&&e.writeUint32(this.sample_size[t]),this.flags&p.TRUN_FLAGS_FLAGS&&e.writeUint32(this.sample_flags[t]),this.flags&p.TRUN_FLAGS_CTS_OFFSET&&(0===this.version?e.writeUint32(this.sample_composition_time_offset[t]):e.writeInt32(this.sample_composition_time_offset[t]))},p["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)},p["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)},p.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)},p.cttsBox.prototype.unpack=function(e){for(var t,i=0,r=0;r<this.sample_counts.length;r++)for(t=0;t<this.sample_counts[r];t++)e[i].pts=e[i].dts+this.sample_offsets[r],i++},p.sttsBox.prototype.unpack=function(e){for(var t,i=0,r=0;r<this.sample_counts.length;r++)for(t=0;t<this.sample_counts[r];t++)e[i].dts=0===i?0:e[i-1].dts+this.sample_deltas[r],i++},p.stcoBox.prototype.unpack=function(e){for(var t=0;t<this.chunk_offsets.length;t++)e[t].offset=this.chunk_offsets[t]},p.stscBox.prototype.unpack=function(e){for(var t,i,r=0,s=0,a=0;a<this.first_chunk.length;a++)for(t=0;t<(a+1<this.first_chunk.length?this.first_chunk[a+1]:1/0);t++)for(s++,i=0;i<this.samples_per_chunk[a];i++){if(!e[r])return;e[r].description_index=this.sample_description_index[a],e[r].chunk_index=s,r++}},p.stszBox.prototype.unpack=function(e){for(var t=0;t<this.sample_sizes.length;t++)e[t].size=this.sample_sizes[t]},p.DIFF_BOXES_PROP_NAMES=["boxes","entries","references","subsamples","items","item_infos","extents","associations","subsegments","ranges","seekLists","seekPoints","esd","levels"],p.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"],p.boxEqualFields=function(e,t){if(e&&!t)return!1;for(var i in e)if(!(-1<p.DIFF_BOXES_PROP_NAMES.indexOf(i)||e[i]instanceof p.Box||t[i]instanceof p.Box||void 0===e[i]||void 0===t[i]||"function"==typeof e[i]||"function"==typeof t[i]||e.subBoxNames&&-1<e.subBoxNames.indexOf(i.slice(0,4))||t.subBoxNames&&-1<t.subBoxNames.indexOf(i.slice(0,4))||"data"===i||"start"===i||"size"===i||"creation_time"===i||"modification_time"===i||-1<p.DIFF_PRIMITIVE_ARRAY_PROP_NAMES.indexOf(i)||e[i]===t[i]))return!1;return!0},p.boxEqual=function(e,t){if(!p.boxEqualFields(e,t))return!1;for(var i=0;i<p.DIFF_BOXES_PROP_NAMES.length;i++){var r=p.DIFF_BOXES_PROP_NAMES[i];if(e[r]&&t[r]&&!p.boxEqual(e[r],t[r]))return!1}return!0},n.prototype.parseSample=function(e){var t,r={resources:[]},s=new i(e.data.buffer);if(e.subsamples&&0!==e.subsamples.length){if(r.documentString=s.readString(e.subsamples[0].size),1<e.subsamples.length)for(t=1;t<e.subsamples.length;t++)r.resources[t]=s.readUint8Array(e.subsamples[t].size)}else r.documentString=s.readString(e.data.length);return"undefined"!=typeof DOMParser&&(r.document=(new DOMParser).parseFromString(r.documentString,"application/xml")),r},o.prototype.parseSample=function(e){return new i(e.data.buffer).readString(e.data.length)},o.prototype.parseConfig=function(e){return e=new i(e.buffer),e.readUint32(),e.readCString()},t.XMLSubtitlein4Parser=n,t.Textin4Parser=o,l.prototype.setSegmentOptions=function(e,t,i){var r,s=this.getTrackById(e);s&&(this.fragmentedTracks.push(r={}),r.id=e,r.user=t,(r.trak=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)))},l.prototype.unsetSegmentOptions=function(e){for(var t=-1,i=0;i<this.fragmentedTracks.length;i++)this.fragmentedTracks[i].id==e&&(t=i);-1<t&&this.fragmentedTracks.splice(t,1)},l.prototype.setExtractionOptions=function(e,t,i){var r,s=this.getTrackById(e);s&&(this.extractedTracks.push(r={}),r.id=e,r.user=t,(r.trak=s).nextSample=0,r.nb_samples=1e3,r.samples=[],i&&i.nbSamples&&(r.nb_samples=i.nbSamples))},l.prototype.unsetExtractionOptions=function(e){for(var t=-1,i=0;i<this.extractedTracks.length;i++)this.extractedTracks[i].id==e&&(t=i);-1<t&&this.extractedTracks.splice(t,1)},l.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=p.parseOneBox(this.stream,!1)).code===p.ERR_NOT_ENOUGH_DATA){if(this.processIncompleteBox){if(this.processIncompleteBox(e))continue;return}return}var i="uuid"!==(t=e.box).type?t.type:t.uuid;switch(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]&&c.warn("ISOFile","Duplicate Box of type: "+i+", overriding previous occurrence"),this[i]=t}this.updateUsedBytes&&this.updateUsedBytes(t,e)}},l.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?(c.warn("ISOFile","Ignoring empty buffer (fileStart: "+e.fileStart+")"),this.stream.logBufferLevel(),!1):(c.info("ISOFile","Processing buffer (fileStart: "+e.fileStart+")"),e.usedBytes=0,this.stream.insertBuffer(e),this.stream.logBufferLevel(),!!this.stream.initialized()||(c.warn("ISOFile","Not ready to start parsing"),!1))},l.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||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&&(c.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),c.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize())),i},l.prototype.getInfo=function(){var e,t,i,r,s,a,n={},o=new Date("1904-01-01T00:00:00Z").getTime();if(this.moov)for(n.hasMoov=!0,n.duration=this.moov.mvhd.duration,n.timescale=this.moov.mvhd.timescale,n.isFragmented=null!=this.moov.mvex,n.isFragmented&&this.moov.mvex.mehd&&(n.fragment_duration=this.moov.mvex.mehd.fragment_duration),n.isProgressive=this.isProgressive,n.hasIOD=null!=this.moov.iods,n.brands=[],n.brands.push(this.ftyp.major_brand),n.brands=n.brands.concat(this.ftyp.compatible_brands),n.created=new Date(o+1e3*this.moov.mvhd.creation_time),n.modified=new Date(o+1e3*this.moov.mvhd.modification_time),n.tracks=[],n.audioTracks=[],n.videoTracks=[],n.subtitleTracks=[],n.metadataTracks=[],n.hintTracks=[],n.otherTracks=[],e=0;e<this.moov.traks.length;e++){if(a=(i=this.moov.traks[e]).mdia.minf.stbl.stsd.entries[0],n.tracks.push(r={}),r.id=i.tkhd.track_id,r.name=i.mdia.hdlr.name,r.references=[],i.tref)for(t=0;t<i.tref.boxes.length;t++)r.references.push(s={}),s.type=i.tref.boxes[t].type,s.track_ids=i.tref.boxes[t].track_ids;i.edts&&(r.edits=i.edts.elst.entries),r.created=new Date(o+1e3*i.tkhd.creation_time),r.modified=new Date(o+1e3*i.tkhd.modification_time),r.movie_duration=i.tkhd.duration,r.movie_timescale=n.timescale,r.layer=i.tkhd.layer,r.alternate_group=i.tkhd.alternate_group,r.volume=i.tkhd.volume,r.matrix=i.tkhd.matrix,r.track_width=i.tkhd.width/65536,r.track_height=i.tkhd.height/65536,r.timescale=i.mdia.mdhd.timescale,r.cts_shift=i.mdia.minf.stbl.cslg,r.duration=i.mdia.mdhd.duration,r.samples_duration=i.samples_duration,r.codec=a.getCodec(),r.kind=i.udta&&i.udta.kinds.length?i.udta.kinds[0]:{schemeURI:"",value:""},r.language=i.mdia.elng?i.mdia.elng.extended_language:i.mdia.mdhd.languageString,r.nb_samples=i.samples.length,r.size=i.samples_size,r.bitrate=8*r.size*r.timescale/r.samples_duration,a.isAudio()?(r.type="audio",n.audioTracks.push(r),r.audio={},r.audio.sample_rate=a.getSampleRate(),r.audio.channel_count=a.getChannelCount(),r.audio.sample_size=a.getSampleSize()):a.isVideo()?(r.type="video",n.videoTracks.push(r),r.video={},r.video.width=a.getWidth(),r.video.height=a.getHeight()):a.isSubtitle()?(r.type="subtitles",n.subtitleTracks.push(r)):a.isHint()?(r.type="metadata",n.hintTracks.push(r)):a.isMetadata()?(r.type="metadata",n.metadataTracks.push(r)):(r.type="metadata",n.otherTracks.push(r))}else n.hasMoov=!1;if(n.mime="",n.hasMoov&&n.tracks){for(n.videoTracks&&0<n.videoTracks.length?n.mime+='video/mp4; codecs="':n.audioTracks&&0<n.audioTracks.length?n.mime+='audio/mp4; codecs="':n.mime+='application/mp4; codecs="',e=0;e<n.tracks.length;e++)0!==e&&(n.mime+=","),n.mime+=n.tracks[e].codec;n.mime+='"; profiles="',n.mime+=this.ftyp.compatible_brands.join(),n.mime+='"'}return n},l.prototype.processSamples=function(e){var t;if(this.sampleProcessingStarted){if(this.isFragmentationInitialized&&null!==this.onSegment)for(t=0;t<this.fragmentedTracks.length;t++)for(var i=this.fragmentedTracks[t],r=i.trak;r.nextSample<r.samples.length&&this.sampleProcessingStarted;){c.debug("ISOFile","Creating media fragment on track #"+i.id+" for sample "+r.nextSample);var s=this.createFragment(i.id,r.nextSample,i.segmentStream);if(!s)break;if(i.segmentStream=s,r.nextSample++,(r.nextSample%i.nb_samples==0||e||r.nextSample>=r.samples.length)&&(c.info("ISOFile","Sending fragmented data on track #"+i.id+" for samples ["+Math.max(0,r.nextSample-i.nb_samples)+","+(r.nextSample-1)+"]"),c.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize()),this.onSegment&&this.onSegment(i.id,i.user,i.segmentStream.buffer,r.nextSample,e||r.nextSample>=r.samples.length),i.segmentStream=null,i!==this.fragmentedTracks[t]))break}if(null!==this.onSamples)for(t=0;t<this.extractedTracks.length;t++){var a=this.extractedTracks[t];for(r=a.trak;r.nextSample<r.samples.length&&this.sampleProcessingStarted;){c.debug("ISOFile","Exporting on track #"+a.id+" sample #"+r.nextSample);var n=this.getSample(r,r.nextSample);if(!n)break;if(r.nextSample++,a.samples.push(n),(r.nextSample%a.nb_samples==0||r.nextSample>=r.samples.length)&&(c.debug("ISOFile","Sending samples on track #"+a.id+" for sample "+r.nextSample),this.onSamples&&this.onSamples(a.id,a.user,a.samples),a.samples=[],a!==this.extractedTracks[t]))break}}}},l.prototype.getBox=function(e){return e=this.getBoxes(e,!0),e.length?e[0]:null},l.prototype.getBoxes=function(e,t){var i=[];return l._sweep.call(this,e,i,t),i},l._sweep=function(e,t,i){for(var r in this.type&&this.type==e&&t.push(this),this.boxes){if(t.length&&i)return;l._sweep.call(this.boxes[r],e,t,i)}},l.prototype.getTrackSamplesInfo=function(e){return e=this.getTrackById(e),e?e.samples:void 0},l.prototype.getTrackSample=function(e,t){return e=this.getTrackById(e),this.getSample(e,t)},l.prototype.releaseUsedSamples=function(e,t){var i=0,r=this.getTrackById(e);r.lastValidSample||(r.lastValidSample=0);for(var s=r.lastValidSample;s<t;s++)i+=this.releaseSample(r,s);c.info("ISOFile","Track #"+e+" released samples up to "+t+" (released size: "+i+", remaining: "+this.samplesDataSize+")"),r.lastValidSample=t},l.prototype.start=function(){this.sampleProcessingStarted=!0,this.processSamples(!1)},l.prototype.stop=function(){this.sampleProcessingStarted=!1},l.prototype.flush=function(){c.info("ISOFile","Flushing remaining samples"),this.updateSampleLists(),this.processSamples(!0),this.stream.cleanBuffers(),this.stream.logBufferLevel(!0)},l.prototype.seekTrack=function(e,t,i){var r,s,a,n,o=0,l=0;if(0===i.samples.length)return c.info("ISOFile","No sample in track, cannot seek! Using time "+c.getDurationString(0,1)+" and offset: 0"),{offset:0,time:0};for(r=0;r<i.samples.length;r++){if(s=i.samples[r],0===r)l=0,n=s.timescale;else if(s.cts>e*s.timescale){l=r-1;break}t&&s.is_sync&&(o=r)}for(t&&(l=o),e=i.samples[l].cts,i.nextSample=l;i.samples[l].alreadyRead===i.samples[l].size&&i.samples[l+1];)l++;return a=i.samples[l].offset+i.samples[l].alreadyRead,c.info("ISOFile","Seeking to "+(t?"RAP":"")+" sample #"+i.nextSample+" on track "+i.tkhd.track_id+", time "+c.getDurationString(e,n)+" and offset: "+a),{offset:a,time:e/n}},l.prototype.seek=function(e,t){var i,r,s=this.moov,a={offset:1/0,time:1/0};if(this.moov){for(r=0;r<s.traks.length;r++)i=s.traks[r],(i=this.seekTrack(e,t,i)).offset<a.offset&&(a.offset=i.offset),i.time<a.time&&(a.time=i.time);return c.info("ISOFile","Seeking at time "+c.getDurationString(a.time,1)+" needs a buffer with a fileStart position of "+a.offset),a.offset===1/0?a={offset:this.nextParsePosition,time:0}:a.offset=this.stream.getEndFilePositionAfter(a.offset),c.info("ISOFile","Adjusted seek position (after checking data already in buffer): "+a.offset),a}throw"Cannot seek: moov not received!"},l.prototype.equal=function(e){for(var t=0;t<this.boxes.length&&t<e.boxes.length;){var i=this.boxes[t],r=e.boxes[t];if(!p.boxEqual(i,r))return!1;t++}return!0},(t.ISOFile=l).prototype.lastBoxStartPosition=0,l.prototype.parsingMdat=null,l.prototype.nextParsePosition=0,l.prototype.discardMdatData=!1,l.prototype.processIncompleteBox=function(e){var t;return"mdat"===e.type?(t=new p[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):(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,!1))},l.prototype.hasIncompleteMdat=function(){return null!==this.parsingMdat},l.prototype.processIncompleteMdat=function(){var e=this.parsingMdat;return this.stream.seek(e.start+e.size,!1,this.discardMdatData)?(c.debug("ISOFile","Found 'mdat' end in buffered data"),!(this.parsingMdat=null)):(this.nextParsePosition=this.stream.findEndContiguousBuf(),!1)},l.prototype.restoreParsePosition=function(){return this.stream.seek(this.lastBoxStartPosition,!0,this.discardMdatData)},l.prototype.saveParsePosition=function(){this.lastBoxStartPosition=this.stream.getPosition()},l.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))},l.prototype.add=p.Box.prototype.add,l.prototype.addBox=p.Box.prototype.addBox,l.prototype.init=function(e){e=e||{};var t=(this.add("ftyp").set("major_brand",e.brands&&e.brands[0]||"iso4").set("minor_version",0).set("compatible_brands",e.brands||["iso4"]),this.add("moov"));return t.add("mvhd").set("timescale",e.timescale||600).set("rate",e.rate||65536).set("creation_time",0).set("modification_time",0).set("duration",e.duration||0).set("volume",e.width?0:256).set("matrix",[65536,0,0,0,65536,0,0,0,1073741824]).set("next_track_id",1),t.add("mvex"),this},l.prototype.addTrack=function(e){this.moov||this.init(e);var t=e||{},r=(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",this.moov.add("trak")),this.moov.mvhd.next_track_id=t.id+1,e.add("tkhd").set("flags",p.TKHD_FLAG_ENABLED|p.TKHD_FLAG_IN_MOVIE|p.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),e.add("mdia")),s=(r.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"),r.add("hdlr").set("handler",t.hdlr||"vide").set("name",t.name||"Track created with MP4Box.js"),r.add("elng").set("extended_language",t.language||"fr-FR"),r.add("minf"));if(void 0!==p[t.type+"SampleEntry"]){var a,n,o,l=new p[t.type+"SampleEntry"],d=(l.data_reference_index=1,"");for(a in p.sampleEntryCodes)for(var h=p.sampleEntryCodes[a],c=0;c<h.length;c++)if(-1<h.indexOf(t.type)){d=a;break}switch(d){case"Visual":s.add("vmhd").set("graphicsmode",0).set("opcolor",[0,0,0]),l.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&&(n=new p.avcCBox,o=new i(t.avcDecoderConfigRecord),n.parse(o),l.addBox(n));break;case"Audio":s.add("smhd").set("balance",t.balance||0),l.set("channel_count",t.channel_count||2).set("samplesize",t.samplesize||16).set("samplerate",t.samplerate||65536);break;case"Hint":s.add("hmhd");break;case"Subtitle":s.add("sthd"),"stpp"===t.type&&l.set("namespace",t.namespace||"nonamespace").set("schema_location",t.schema_location||"").set("auxiliary_mime_types",t.auxiliary_mime_types||"");break;default:s.add("nmhd")}return t.description&&l.addBox(t.description),t.description_boxes&&t.description_boxes.forEach((function(e){l.addBox(e)})),s.add("dinf").add("dref").addEntry((new p["url Box"]).set("flags",1)),r=s.add("stbl"),r.add("stsd").addEntry(l),r.add("stts").set("sample_counts",[]).set("sample_deltas",[]),r.add("stsc").set("first_chunk",[]).set("samples_per_chunk",[]).set("sample_description_index",[]),r.add("stco").set("chunk_offsets",[]),r.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(e),t.id}},p.Box.prototype.computeSize=function(e){e=e||new r,e.endianness=r.BIG_ENDIAN,this.write(e)},l.prototype.addSample=function(e,t,i){i=i||{};var r={};e=this.getTrackById(e);if(null!==e)return r.number=e.samples.length,r.track_id=e.tkhd.track_id,r.timescale=e.mdia.mdhd.timescale,r.description_index=i.sample_description_index?i.sample_description_index-1:0,r.description=e.mdia.minf.stbl.stsd.entries[r.description_index],r.data=t,r.size=t.byteLength,r.alreadyRead=r.size,r.duration=i.duration||1,r.cts=i.cts||0,r.dts=i.dts||0,r.is_sync=i.is_sync||!1,r.is_leading=i.is_leading||0,r.depends_on=i.depends_on||0,r.is_depended_on=i.is_depended_on||0,r.has_redundancy=i.has_redundancy||0,r.degradation_priority=i.degradation_priority||0,r.offset=0,r.subsamples=i.subsamples,e.samples.push(r),e.samples_size+=r.size,e.samples_duration+=r.duration,e.first_dts||(e.first_dts=i.dts),this.processSamples(),e=this.createSingleSampleMoof(r),this.addBox(e),e.computeSize(),e.trafs[0].truns[0].data_offset=e.size+8,this.add("mdat").data=new Uint8Array(t),r},l.prototype.createSingleSampleMoof=function(e){var t=e.is_sync?1<<25:65536,i=new p.moofBox,r=(i.add("mfhd").set("sequence_number",this.nextMoofNumber),this.nextMoofNumber++,i.add("traf")),s=this.getTrackById(e.track_id);return r.add("tfhd").set("track_id",e.track_id).set("flags",p.TFHD_FLAG_DEFAULT_BASE_IS_MOOF),r.add("tfdt").set("baseMediaDecodeTime",e.dts-(s.first_dts||0)),r.add("trun").set("flags",p.TRUN_FLAGS_DATA_OFFSET|p.TRUN_FLAGS_DURATION|p.TRUN_FLAGS_SIZE|p.TRUN_FLAGS_FLAGS|p.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},l.prototype.lastMoofIndex=0,l.prototype.samplesDataSize=0,l.prototype.resetTables=function(){var e,t;for(this.initial_duration=this.moov.mvhd.duration,e=this.moov.mvhd.duration=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=[],(i=t.mdia.minf.stbl.stts).sample_counts=[],i.sample_deltas=[],(i=t.mdia.minf.stbl.ctts)&&(i.sample_counts=[],i.sample_offsets=[]);var i=t.mdia.minf.stbl.stss;i=t.mdia.minf.stbl.boxes.indexOf(i);-1!=i&&(t.mdia.minf.stbl.boxes[i]=null)}},l.initSampleGroups=function(e,t,i,r,s){var a,n,o,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=[]),n=0;n<i.length;n++){for(l=i[n].grouping_type+"/"+i[n].grouping_type_parameter,o=new d(i[n].grouping_type,i[n].grouping_type_parameter,i[n]),t&&(t.sample_groups_info[l]=o),e.sample_groups_info[l]||(e.sample_groups_info[l]=o),a=0;a<r.length;a++)r[a].grouping_type===i[n].grouping_type&&(o.description=r[a],o.description.used=!0);if(s)for(a=0;a<s.length;a++)s[a].grouping_type===i[n].grouping_type&&(o.fragment_description=s[a],o.fragment_description.used=!0,o.is_fragment=!0)}if(t){if(s)for(n=0;n<s.length;n++)!s[n].used&&2<=s[n].version&&(l=s[n].grouping_type+"/0",(o=new d(s[n].grouping_type,0)).is_fragment=!0,t.sample_groups_info[l]||(t.sample_groups_info[l]=o))}else for(n=0;n<r.length;n++)!r[n].used&&2<=r[n].version&&(l=r[n].grouping_type+"/0",o=new d(r[n].grouping_type,0),e.sample_groups_info[l]||(e.sample_groups_info[l]=o))},l.setSampleGroupProperties=function(e,t,i,r){var s,a,n;for(s in t.sample_groups=[],r)t.sample_groups[s]={},t.sample_groups[s].grouping_type=r[s].grouping_type,t.sample_groups[s].grouping_type_parameter=r[s].grouping_type_parameter,i>=r[s].last_sample_in_run&&(r[s].last_sample_in_run<0&&(r[s].last_sample_in_run=0),r[s].entry_index++,r[s].entry_index<=r[s].sbgp.entries.length-1&&(r[s].last_sample_in_run+=r[s].sbgp.entries[r[s].entry_index].sample_count)),r[s].entry_index<=r[s].sbgp.entries.length-1?t.sample_groups[s].group_description_index=r[s].sbgp.entries[r[s].entry_index].group_description_index:t.sample_groups[s].group_description_index=-1,0!==t.sample_groups[s].group_description_index&&(n=r[s].fragment_description||r[s].description,0<t.sample_groups[s].group_description_index?(a=65535<t.sample_groups[s].group_description_index?(t.sample_groups[s].group_description_index>>16)-1:t.sample_groups[s].group_description_index-1,n&&0<=a&&(t.sample_groups[s].description=n.entries[a])):n&&2<=n.version&&0<n.default_group_description_index&&(t.sample_groups[s].description=n.entries[n.default_group_description_index-1]))},l.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))},l.prototype.buildSampleLists=function(){for(var e,t=0;t<this.moov.traks.length;t++)e=this.moov.traks[t],this.buildTrakSampleLists(e)},l.prototype.buildTrakSampleLists=function(e){var t,i,r,s,a,n,o,d,h,c,u,p,f,m,g,y,A,b,v,_,w,S,E,T;if(e.samples=[],e.samples_duration=0,e.samples_size=0,i=e.mdia.minf.stbl.stco||e.mdia.minf.stbl.co64,r=e.mdia.minf.stbl.stsc,s=e.mdia.minf.stbl.stsz||e.mdia.minf.stbl.stz2,a=e.mdia.minf.stbl.stts,n=e.mdia.minf.stbl.ctts,o=e.mdia.minf.stbl.stss,d=e.mdia.minf.stbl.stsd,h=e.mdia.minf.stbl.subs,p=e.mdia.minf.stbl.stdp,c=e.mdia.minf.stbl.sbgps,u=e.mdia.minf.stbl.sgpds,w=_=v=b=-1,T=E=S=0,l.initSampleGroups(e,null,c,u),void 0!==s){for(t=0;t<s.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).size=s.sample_sizes[t],e.samples_size+=k.size,0===t?(f=0,k.chunk_index=m=1,k.chunk_run_index=f,A=r.samples_per_chunk[f],y=0,g=f+1<r.first_chunk.length?r.first_chunk[f+1]-1:1/0):t<A?(k.chunk_index=m,k.chunk_run_index=f):(m++,y=0,(k.chunk_index=m)<=g||(g=1+ ++f<r.first_chunk.length?r.first_chunk[f+1]-1:1/0),k.chunk_run_index=f,A+=r.samples_per_chunk[f]),k.description_index=r.sample_description_index[k.chunk_run_index]-1,k.description=d.entries[k.description_index],k.offset=i.chunk_offsets[k.chunk_index-1]+y,y+=k.size,b<t&&(v++,b<0&&(b=0),b+=a.sample_counts[v]),0<t?(e.samples[t-1].duration=a.sample_deltas[v],e.samples_duration+=e.samples[t-1].duration,k.dts=e.samples[t-1].dts+e.samples[t-1].duration):k.dts=0,n?(_<=t&&(w++,_<0&&(_=0),_+=n.sample_counts[w]),k.cts=e.samples[t].dts+n.sample_offsets[w]):k.cts=k.dts,o?(t==o.sample_numbers[S]-1?(k.is_sync=!0,S++):(k.is_sync=!1,k.degradation_priority=0),h&&h.entries[E].sample_delta+T==t+1&&(k.subsamples=h.entries[E].subsamples,T+=h.entries[E].sample_delta,E++)):k.is_sync=!0,l.process_sdtp(e.mdia.minf.stbl.sdtp,k,k.number),k.degradation_priority=p?p.priority[t]:0,h&&h.entries[E].sample_delta+T==t&&(k.subsamples=h.entries[E].subsamples,T+=h.entries[E].sample_delta),(0<c.length||0<u.length)&&l.setSampleGroupProperties(e,k,t,e.sample_groups_info)}0<t&&(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)}},l.prototype.updateSampleLists=function(){var e,t,i,r,s,a,n,o,d,h,c,u;if(void 0!==this.moov)for(;this.lastMoofIndex<this.moofs.length;)if(n=this.moofs[this.lastMoofIndex],this.lastMoofIndex++,"moof"==n.type)for(o=n,e=0;e<o.trafs.length;e++){for(d=o.trafs[e],h=this.getTrackById(d.tfhd.track_id),c=this.getTrexById(d.tfhd.track_id),t=d.tfhd.flags&p.TFHD_FLAG_SAMPLE_DESC?d.tfhd.default_sample_description_index:c?c.default_sample_description_index:1,i=d.tfhd.flags&p.TFHD_FLAG_SAMPLE_DUR?d.tfhd.default_sample_duration:c?c.default_sample_duration:0,r=d.tfhd.flags&p.TFHD_FLAG_SAMPLE_SIZE?d.tfhd.default_sample_size:c?c.default_sample_size:0,s=d.tfhd.flags&p.TFHD_FLAG_SAMPLE_FLAGS?d.tfhd.default_sample_flags:c?c.default_sample_flags:0,(d.sample_number=0)<d.sbgps.length&&l.initSampleGroups(h,d,d.sbgps,h.mdia.minf.stbl.sgpds,d.sgpds),v=0;v<d.truns.length;v++)for(var f=d.truns[v],m=0;m<f.sample_count;m++){(u={}).moof_number=this.lastMoofIndex,u.number_in_traf=d.sample_number,d.sample_number++,u.number=h.samples.length,d.first_sample_index=h.samples.length,h.samples.push(u),u.track_id=h.tkhd.track_id,u.timescale=h.mdia.mdhd.timescale,u.description_index=t-1,u.description=h.mdia.minf.stbl.stsd.entries[u.description_index],u.size=r,f.flags&p.TRUN_FLAGS_SIZE&&(u.size=f.sample_size[m]),h.samples_size+=u.size,u.duration=i,f.flags&p.TRUN_FLAGS_DURATION&&(u.duration=f.sample_duration[m]),h.samples_duration+=u.duration,h.first_traf_merged||0<m?u.dts=h.samples[h.samples.length-2].dts+h.samples[h.samples.length-2].duration:(d.tfdt?u.dts=d.tfdt.baseMediaDecodeTime:u.dts=0,h.first_traf_merged=!0),u.cts=u.dts,f.flags&p.TRUN_FLAGS_CTS_OFFSET&&(u.cts=u.dts+f.sample_composition_time_offset[m]),g=s,f.flags&p.TRUN_FLAGS_FLAGS?g=f.sample_flags[m]:0===m&&f.flags&p.TRUN_FLAGS_FIRST_FLAG&&(g=f.first_sample_flags),u.is_sync=!(g>>16&1),u.is_leading=g>>26&3,u.depends_on=g>>24&3,u.is_depended_on=g>>22&3,u.has_redundancy=g>>20&3,u.degradation_priority=65535&g;var g=!!(d.tfhd.flags&p.TFHD_FLAG_BASE_DATA_OFFSET),y=!!(d.tfhd.flags&p.TFHD_FLAG_DEFAULT_BASE_IS_MOOF),A=!!(f.flags&p.TRUN_FLAGS_DATA_OFFSET);g=g?d.tfhd.base_data_offset:y||0===v?o.start:a;u.offset=0===v&&0===m?A?g+f.data_offset:g:a,a=u.offset+u.size,(0<d.sbgps.length||0<d.sgpds.length||0<h.mdia.minf.stbl.sbgps.length||0<h.mdia.minf.stbl.sgpds.length)&&l.setSampleGroupProperties(h,u,u.number_in_traf,d.sample_groups_info)}if(d.subs){h.has_fragment_subsamples=!0;for(var b=d.first_sample_index,v=0;v<d.subs.entries.length;v++)b+=d.subs.entries[v].sample_delta,(u=h.samples[b-1]).subsamples=d.subs.entries[v].subsamples}}},l.prototype.getSample=function(e,t){var i=e.samples[t];if(!this.moov)return null;if(i.data){if(i.alreadyRead==i.size)return i}else i.data=new Uint8Array(i.size),i.alreadyRead=0,this.samplesDataSize+=i.size,c.debug("ISOFile","Allocating sample #"+t+" on track #"+e.tkhd.track_id+" of size "+i.size+" (total: "+this.samplesDataSize+")");for(;;){var s=this.stream.findPosition(!0,i.offset+i.alreadyRead,!1);if(!(-1<s))return null;var a=(s=this.stream.buffers[s]).byteLength-(i.offset+i.alreadyRead-s.fileStart);if(i.size-i.alreadyRead<=a)return c.debug("ISOFile","Getting sample #"+t+" data (alreadyRead: "+i.alreadyRead+" offset: "+(i.offset+i.alreadyRead-s.fileStart)+" read size: "+(i.size-i.alreadyRead)+" full size: "+i.size+")"),r.memcpy(i.data.buffer,i.alreadyRead,s,i.offset+i.alreadyRead-s.fileStart,i.size-i.alreadyRead),s.usedBytes+=i.size-i.alreadyRead,this.stream.logBufferLevel(),i.alreadyRead=i.size,i;if(0==a)return null;c.debug("ISOFile","Getting sample #"+t+" partial data (alreadyRead: "+i.alreadyRead+" offset: "+(i.offset+i.alreadyRead-s.fileStart)+" read size: "+a+" full size: "+i.size+")"),r.memcpy(i.data.buffer,i.alreadyRead,s,i.offset+i.alreadyRead-s.fileStart,a),i.alreadyRead+=a,s.usedBytes+=a,this.stream.logBufferLevel()}},l.prototype.releaseSample=function(e,t){return e=e.samples[t],e.data?(this.samplesDataSize-=e.size,e.data=null,e.alreadyRead=0,e.size):0},l.prototype.getAllocatedSampleDataSize=function(){return this.samplesDataSize},l.prototype.getCodecs=function(){for(var e="",t=0;t<this.moov.traks.length;t++)0<t&&(e+=","),e+=this.moov.traks[t].mdia.minf.stbl.stsd.entries[0].getCodec();return e},l.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},l.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},l.prototype.items=[],l.prototype.itemsDataSize=0,l.prototype.flattenItemInfo=function(){var e=this.items,t=this.meta;if(null!=t&&void 0!==t.hdlr&&void 0!==t.iinf){for(l=0;l<t.iinf.item_infos.length;l++)(r={}).id=t.iinf.item_infos[l].item_ID,(e[r.id]=r).ref_to=[],r.name=t.iinf.item_infos[l].item_name,0<t.iinf.item_infos[l].protection_index&&(r.protection=t.ipro.protections[t.iinf.item_infos[l].protection_index-1]),t.iinf.item_infos[l].item_type?r.type=t.iinf.item_infos[l].item_type:r.type="mime",r.content_type=t.iinf.item_infos[l].content_type,r.content_encoding=t.iinf.item_infos[l].content_encoding;if(t.iloc)for(l=0;l<t.iloc.items.length;l++){var i=t.iloc.items[l],r=e[i.item_ID];switch(0!==i.data_reference_index&&(c.warn("Item storage with reference to other files: not supported"),r.source=t.dinf.boxes[i.data_reference_index-1]),i.construction_method){case 0:break;case 1:case 2:c.warn("Item storage with construction_method : not supported")}for(r.extents=[],a=r.size=0;a<i.extents.length;a++)r.extents[a]={},r.extents[a].offset=i.extents[a].extent_offset+i.base_offset,r.extents[a].length=i.extents[a].extent_length,r.extents[a].alreadyRead=0,r.size+=r.extents[a].length}if(t.pitm&&(e[t.pitm.item_id].primary=!0),t.iref)for(l=0;l<t.iref.references.length;l++)for(var s=t.iref.references[l],a=0;a<s.references.length;a++)e[s.from_item_ID].ref_to.push({type:s.type,id:s.references[a]});if(t.iprp)for(var n=0;n<t.iprp.ipmas.length;n++)for(var o=t.iprp.ipmas[n],l=0;l<o.associations.length;l++){var d=o.associations[l];for(void 0===(r=e[d.id]).properties&&(r.properties={},r.properties.boxes=[]),a=0;a<d.props.length;a++){var h=d.props[a];0<h.property_index&&h.property_index-1<t.iprp.ipco.boxes.length&&(h=t.iprp.ipco.boxes[h.property_index-1],r.properties[h.type]=h,r.properties.boxes.push(h))}}}},l.prototype.getItem=function(e){var t;if(!this.meta)return null;if(!(t=this.items[e]).data&&t.size)t.data=new Uint8Array(t.size),t.alreadyRead=0,this.itemsDataSize+=t.size,c.debug("ISOFile","Allocating item #"+e+" of size "+t.size+" (total: "+this.itemsDataSize+")");else if(t.alreadyRead===t.size)return t;for(var i=0;i<t.extents.length;i++){var s=t.extents[i];if(s.alreadyRead!==s.length){var a=this.stream.findPosition(!0,s.offset+s.alreadyRead,!1);if(!(-1<a))return null;var n=(a=this.stream.buffers[a]).byteLength-(s.offset+s.alreadyRead-a.fileStart);if(!(s.length-s.alreadyRead<=n))return c.debug("ISOFile","Getting item #"+e+" extent #"+i+" partial data (alreadyRead: "+s.alreadyRead+" offset: "+(s.offset+s.alreadyRead-a.fileStart)+" read size: "+n+" full extent size: "+s.length+" full item size: "+t.size+")"),r.memcpy(t.data.buffer,t.alreadyRead,a,s.offset+s.alreadyRead-a.fileStart,n),s.alreadyRead+=n,t.alreadyRead+=n,a.usedBytes+=n,this.stream.logBufferLevel(),null;c.debug("ISOFile","Getting item #"+e+" extent #"+i+" data (alreadyRead: "+s.alreadyRead+" offset: "+(s.offset+s.alreadyRead-a.fileStart)+" read size: "+(s.length-s.alreadyRead)+" full extent size: "+s.length+" full item size: "+t.size+")"),r.memcpy(t.data.buffer,t.alreadyRead,a,s.offset+s.alreadyRead-a.fileStart,s.length-s.alreadyRead),a.usedBytes+=s.length-s.alreadyRead,this.stream.logBufferLevel(),t.alreadyRead+=s.length-s.alreadyRead,s.alreadyRead=s.length}}return t.alreadyRead===t.size?t:null},l.prototype.releaseItem=function(e){var t=this.items[e];if(t.data){this.itemsDataSize-=t.size,t.data=null;for(var i=t.alreadyRead=0;i<t.extents.length;i++)t.extents[i].alreadyRead=0;return t.size}return 0},l.prototype.processItems=function(e){for(var t in this.items)t=this.items[t],this.getItem(t.id),e&&!t.sent&&(e(t),t.sent=!0,t.data=null)},l.prototype.hasItem=function(e){for(var t in this.items)if(t=this.items[t],t.name===e)return t.id;return-1},l.prototype.getMetaHandler=function(){return this.meta?this.meta.hdlr.handler:null},l.prototype.getPrimaryItem=function(){return this.meta&&this.meta.pitm?this.getItem(this.meta.pitm.item_id):null},l.prototype.itemToFragmentedTrackFile=function(e){e=e||{};if(null==(e=e.itemId?this.getItem(e.itemId):this.getPrimaryItem()))return null;var t=new l,i=(t.discardMdatData=!1,{type:e.type,description_boxes:e.properties.boxes});e.properties.ispe&&(i.width=e.properties.ispe.image_width,i.height=e.properties.ispe.image_height),i=t.addTrack(i);return i?(t.addSample(i,e.data),t):null},l.prototype.write=function(e){for(var t=0;t<this.boxes.length;t++)this.boxes[t].write(e)},l.prototype.createFragment=function(e,t,i){e=this.getTrackById(e);var s=this.getSample(e,t);return null==s?(s=e.samples[t],this.nextSeekPosition?this.nextSeekPosition=Math.min(s.offset+s.alreadyRead,this.nextSeekPosition):this.nextSeekPosition=e.samples[t].offset+s.alreadyRead,null):(e=i||new r,e.endianness=r.BIG_ENDIAN,t=this.createSingleSampleMoof(s),t.write(e),t.trafs[0].truns[0].data_offset=t.size+8,c.debug("MP4Box","Adjusting data_offset with new value "+t.trafs[0].truns[0].data_offset),e.adjustUint32(t.trafs[0].truns[0].data_offset_position,t.trafs[0].truns[0].data_offset),i=new p.mdatBox,i.data=s.data,i.write(e),e)},l.writeInitializationSegment=function(e,t,i,s){c.debug("ISOFile","Generating initialization segment");var a,n=new r,o=(n.endianness=r.BIG_ENDIAN,e.write(n),t.add("mvex"));for(i&&o.add("mehd").set("fragment_duration",i),a=0;a<t.traks.length;a++)o.add("trex").set("track_id",t.traks[a].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(n),n.buffer},l.prototype.save=function(e){var t=new r;t.endianness=r.BIG_ENDIAN,this.write(t),t.save(e)},l.prototype.getBuffer=function(){var e=new r;return e.endianness=r.BIG_ENDIAN,this.write(e),e.buffer},l.prototype.initializeSegmentation=function(){var e,t,i,r;for(null===this.onSegment&&c.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 s=new p.moovBox;s.mvhd=this.moov.mvhd,s.boxes.push(s.mvhd),i=this.getTrackById(this.fragmentedTracks[e].id),s.boxes.push(i),s.traks.push(i),(r={}).id=i.tkhd.track_id,r.user=this.fragmentedTracks[e].user,r.buffer=l.writeInitializationSegment(this.ftyp,s,this.moov.mvex&&this.moov.mvex.mehd?this.moov.mvex.mehd.fragment_duration:void 0,0<this.moov.traks[e].samples.length?this.moov.traks[e].samples[0].duration:0),t.push(r)}return t},p.Box.prototype.printHeader=function(e){this.size+=8,this.size>u&&(this.size+=8),"uuid"===this.type&&(this.size+=16),e.log(e.indent+"size:"+this.size),e.log(e.indent+"type:"+this.type)},p.FullBox.prototype.printHeader=function(e){this.size+=4,p.Box.prototype.printHeader.call(this,e),e.log(e.indent+"version:"+this.version),e.log(e.indent+"flags:"+this.flags)},p.Box.prototype.print=function(e){this.printHeader(e)},p.ContainerBox.prototype.print=function(e){this.printHeader(e);for(var t,i=0;i<this.boxes.length;i++)this.boxes[i]&&(t=e.indent,e.indent+=" ",this.boxes[i].print(e),e.indent=t)},l.prototype.print=function(e){e.indent="";for(var t=0;t<this.boxes.length;t++)this.boxes[t]&&this.boxes[t].print(e)},p.mvhdBox.prototype.print=function(e){p.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)},p.tkhdBox.prototype.print=function(e){p.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 f=function(e,t){return e=void 0===e||e,t=new l(t),t.discardMdatData=!e,t};t.createFile=f}));function Bs(e){return e.reduce((e,t)=>256*e+t)}function Us(e){const t=[101,103,119,99],i=e.length-28,r=e.slice(i,i+t.length);return t.every((e,t)=>e===r[t])}Ps.Log,Ps.MP4BoxStream,Ps.DataStream,Ps.MultiBufferStream,Ps.MPEG4DescriptorParser,Ps.BoxParser,Ps.XMLSubtitlein4Parser,Ps.Textin4Parser,Ps.ISOFile,Ps.createFile;class Fs{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&&50<this.l)return e;if(this.l++,this.d)return e;var 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);Us(t)&&this.c++}else{var i=function(e,t){var i=function(e,t){for(let i=0;i<e.byteLength-t.length;i++)for(let r=0;r<t.length&&e[i+r]===t[r];r++)if(r===t.length-1)return i;return null}(e,t);if(i){const t=Bs(e.slice(i+16,i+16+8));return[t,Bs(e.slice(i+24,i+24+8)),e.slice(i+32,i+32+t).map(e=>~e)]}return null}(t,this.t);if(!i)return e;var r=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(r instanceof Error)return console.error(r.message),this.d=!0,e;this.A=!0,this.u=i[1],Us(t)&&this.c++,WebAssembly.instantiate(i[2],r).then(e=>{if("function"!=typeof(t=e.instance.exports).parse||"object"!=typeof t.memory)return this.d=!0,void console.error("video_error_3");var t;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 Ms extends cr{constructor(e){super(e),Ds(this,"TAG_NAME","Fmp4Loader"),this.player=e,this.mp4Box=Ps.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 Fs),this._listenMp4Box(),e.debug.log(this.TAG_NAME,"init")}destroy(){this.mp4Box&&(this.mp4Box.flush(),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,2,0,!0,0)),this.mp4Box.setExtractionOptions(t.id)}if(i){this.audioTrackId=i.id;const e=i.audio||{},t=He.indexOf(e.sample_rate),a=i.codec.replace("mp4a.40.","");this.mp4Box.setExtractionOptions(i.id);var r={profile:parseInt(a,10),sampleRate:t,channel:e.channel_count},s=ze(r);this.player.debug.log(this.TAG_NAME,"aacADTSHeader",s,"config",r),this._doDecodeByFmp4(s,1,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 s of i){const e=s.data,t=s.is_sync,i=1e3*s.cts/s.timescale;s.duration,s.timescale,this.player.updateStats({vbps:e.byteLength,dts:i}),t&&this.calcIframeIntervalTimestamp(i);var r=(this.isHevc?er:$i)(e,t);this.player._opt.isEmitSEI&&this.findSei(r,i),this._doDecodeByFmp4(r,2,i,t,0)}else if(e===this.audioTrackId)for(const s of i){const e=s.data,t=(this.player.updateStats({abps:e.byteLength}),1e3*s.cts/s.timescale),i=(s.duration,s.timescale,new Uint8Array(e.byteLength+2));i.set([175,1],0),i.set(e,2),this._doDecodeByFmp4(i,1,t,!1,0)}else this.player.debug.warn(this.TAG_NAME,"onSamples() trackId error",e)}getSeqHeader(e){const t=this.mp4Box.getTrackById(e.id);for(const i of t.mdia.minf.stbl.stsd.entries)if(i.avcC||i.hvcC){const e=new Ps.DataStream(void 0,0,Ps.DataStream.BIG_ENDIAN);let t=[];t=i.avcC?(i.avcC.write(e),[23,0,0,0,0]):(this.isHevc=!0,i.hvcC.write(e),[28,0,0,0,0]);const r=new Uint8Array(e.buffer,8),s=new Uint8Array(t.length+r.length);return s.set(t,0),s.set(r,t.length),s}return null}dispatch(e){let t=new Uint8Array(e);"string"!=typeof e?"object"==typeof e?((t=this.transportDescarmber?this.transportDescarmber.transport(t):t).buffer.fileStart=this.offset,this.offset+=t.byteLength,this.mp4Box.appendBuffer(t.buffer)):this.player.debug.warn(this.TAG_NAME,"dispatch()","data is not object",e):this.player.debug.warn(this.TAG_NAME,"dispatch()","data is string",e)}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=qe()+".fmp4",i.click(),URL.revokeObjectURL(t)}}class Os extends cr{constructor(e){super(e),Ds(this,"LOG_NAME","Mpeg4Loader"),this.player=e,this.player.debug.log(this.LOG_NAME,"init")}destroy(){super.destroy(),this.player.debug.log(this.LOG_NAME,"destroy")}}class Ns{constructor(e){return new(Ns.getLoaderFactory(e))(e)}static getLoaderFactory(e){var t=e._opt.demuxType;return"m7s"===t?Cs:t===u||e.isWebrtcH265()?xs:t===p?Ls:t===f?Rs:t===m?Ms:t===g?Os:Is}}class js extends r{constructor(e){super(),this.player=e,this.hasInit=!1,this.isDecodeFirstIIframe=!!$t(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("Webcodecs","init")}destroy(){this.decoder&&($t(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("Webcodecs","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._times.videoStart||(this.player._times.videoStart=qe(),this.player.handlePlayToRenderTimes()),this.player.video.render({videoFrame:e,ts:e.timestamp}),this.player.handleRender(),this.player.updateStats({dfps:!0,buf:this.player.demux&&this.player.demux.delay||0})):this.player.isPlayback()&&(this.player.updateStats({dfps:!0}),$t(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})):!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("Webcodecs","VideoDecoder handleError:",e.code,e);const t=e.toString();-1!==t.indexOf("Unsupported configuration")?this.player.emitError(O.webcodecsUnsupportedConfigurationError,t):-1!==t.indexOf("Decoder failure")&&this.player.emitError(O.webcodecsDecodeError,t)}decodeVideo(e,t,i,r){if(this.hasInit)if(this.isDecodeFirstIIframe||i||this.player.debug.warn("Webcodecs","VideoDecoder isDecodeFirstIIframe false and isIframe is false"),!this.isDecodeFirstIIframe&&i&&(this.isDecodeFirstIIframe=!0),this.isDecodeFirstIIframe)if(this.isDecodeStateClosed())this.player.debug.warn("Webcodecs","VideoDecoder isDecodeStateClosed true");else{if(i&&0===e[1]){const t=15&e[0];let i={};7==t?i=Vi(e.slice(5)):12==t&&(i=Xi(e));const r=this.player.video.videoInfo;r&&r.width&&r.height&&i&&i.codecWidth&&i.codecHeight&&(i.codecWidth!==r.width||i.codecHeight!==r.height)&&(this.player.debug.warn("Webcodecs",`decodeVideo: video width or height is changed, old width is ${videoWidth}, old height is ${videoHeight}, new width is ${i.codecWidth}, new height is ${i.codecHeight}, and emit change event`),this.isWidthOrHeightChanged=!0,this.player.emitError(O.wcsWidthOrHeightChange))}if(this.isWidthOrHeightChanged)this.player.debug.warn("Webcodecs","decodeVideo: video width or height is changed, and return");else if(Vt(e))this.player.debug.warn("Webcodecs","decodeVideo and payload is video sequence header so drop this frame");else if(e.byteLength<12)this.player.debug.warn("Webcodecs","decodeVideo and payload is too small , payload length is "+e.byteLength);else{let n=!1,o=(new Date).getTime();this.prevTimestamp||(this.prevTimestamp=o,n=!0);var s=o-this.prevTimestamp,a=(s=(((this.decodeDiffTimestamp=s)<5||500<s)&&!n&&this.player.debug.warn("Webcodecs","decodeVideo diff time is ",s),e.slice(5)),new EncodedVideoChunk({data:s,timestamp:t,type:i?"key":"delta"}));this.player.emit(U.timeUpdate,t),this.player.recorder&&this.player.recorder.isRecording&&this.player._opt.recordType===h&&this.player.recorder.handleAddNaluTrack(s,i,t,r);try{this.decoder.decode(a)}catch(e){this.player.debug.error("Webcodecs","VideoDecoder",e);const t=e.toString();-1===t.indexOf("A key frame is required after configure() or flush()")&&-1===t.indexOf("Cannot call 'decode' on a closed codec")||this.player.emitError(O.webcodecsDecodeError)}this.prevTimestamp=(new Date).getTime()}}else this.player.debug.warn("Webcodecs","VideoDecoder isDecodeFirstIIframe false");else if(i&&0===e[1]){const t=15&e[0];if(this.player.video.updateVideoInfo({encTypeCode:t}),12==t&&!gt()){const e=at();return this.player.debug.warn("Webcodecs","WebcodecsDecoder not support hevc decode",e.type,e.version),void this.emit(O.webcodecsH265NotSupport)}this.player._times.decodeStart||(this.player._times.decodeStart=qe());let i=null,r=null;const a=e.slice(5);7==t?(i=function(e){let t=e.subarray(1,4),i="avc1.";for(let r=0;r<3;r++){let e=t[r].toString(16);e.length<2&&(e="0"+e),i+=e}return{codec:i,description:e}}(a),r=Vi(a)):12==t&&((s=a).subarray(1,4),i={codec:"hev1.1.6.L120.90",description:s},r=Xi(e)),r&&r.codecWidth&&r.codecHeight&&(i.codedHeight=r.codecHeight,i.codedWidth=r.codecWidth),this.player.recorder&&this.player._opt.recordType===h&&this.player.recorder.initMetaData(e,t),this.player.debug.log("Webcodecs","decodeVideo and webcodecs configure",i);try{this.decoder.configure(i),this.hasInit=!0}catch(e){this.player.debug.log("Webcodecs","configure error",e.code,e)}}}getDecodeDiffTimes(){return this.decodeDiffTimestamp}isDecodeStateClosed(){return"closed"===this.decoder.state}isDecodeStateConfigured(){return"configured"===this.decoder.state}isDecodeStateUnConfigured(){return"unconfigured"===this.decoder.state}}const zs={play:"播放",pause:"暂停",audio:"",mute:"",screenshot:"截图",loading:"",fullscreen:"全屏",fullscreenExit:"退出全屏",record:"录制",recordStop:"停止录制",narrow:"缩小",expand:"放大",ptz:"操作盘",ptzActive:"操作盘激活",zoom:"电子放大",zoomStop:"关闭电子放大",close:"关闭",performance:"性能面板",performanceActive:"性能面板激活",face:"人脸识别",faceActive:"人脸识别激活"};var Gs=Object.keys(zs).reduce((e,t)=>(e[t]=`\n <i class="jessibuca-icon jessibuca-icon-${t}"></i>\n ${zs[t]?`<span class="icon-title-tips"><span class="icon-title">${zs[t]}</span></span>`:""}\n`,e),{});function Hs(e,t){let i=!1;return e.forEach(e=>{i||e.startTimestamp<=t&&e.endTimestamp>t&&(i=!0)}),i}function Ws(e,t,i){let r=0<arguments.length&&void 0!==e?e:[],s=1<arguments.length&&void 0!==t?t:[],a=2<arguments.length?i:void 0;const n=r.length,o=s.length,l=Math.max(n,o),d=2e3,h=Math.ceil(l/d);let c=0,u=0;!function e(){let t="",i="";for(let a=0;a<d;a++){const e=r[u],a=(e&&(t+=`\n <div class="jessibuca-playback-time-minute-one${e.hasRecord?" active":""}${e.isStart?" start":""}" data-has-record="${e.hasRecord}"\n data-time="${e.timestamp}" data-type="${e.dataType}">\n <span class="jessibuca-playback-time-title-tips ${u>n-60?"jessibuca-playback-time-title-tips-left":""}"><span class="jessibuca-playback-time-title">${e.title}</span></span>\n </div>\n `),s[u]);a&&(i+=`\n <div class="jessibuca-playback-time-hour" data-hour="${a.hour}" data-min="${a.min}" data-second="${a.second}"><span class="jessibuca-playback-time-hour-text">${a.title}</span></div>\n `),u+=1}t&&a.$playbackTimeListOne.insertAdjacentHTML("beforeend",t),i&&a.$playbackTimeListSecond.insertAdjacentHTML("beforeend",i),(c+=1)<h&&(a.rafId=window.requestAnimationFrame(e))}()}function Vs(e,t){Ws(function(e){let t=0<arguments.length&&void 0!==e?e:[],i=[];var r,s,a,n=(t[0]||{}).startTimestamp;for(let l=0;l<1440;l++){var o=l%60==0;let e=!1;n&&(e=Hs(t,(r=n,s=l,a=void 0,a=Math.floor(s/60)%60,s=Math.floor(s%60),new Date(r).setHours(a,s,0,0)))),i.push({title:function(e,t){let i="";var r;return-1<e&&(r=Math.floor(e/60)%60,e%=60,e=Math.round(e),i=r<10?"0"+r+":":r+":",e<10&&(i+="0"),i+=e,bt(t)||(t<10&&(t="0"+t),i+=":"+t)),i}(l),timestamp:l,dataType:"min",hasRecord:e,isStart:o})}return i}(e),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)}var Ks=(e,t)=>{const{proxy:i}=e["events"],r=document.createElement("object");r.setAttribute("aria-hidden","true"),r.setAttribute("tabindex",-1),r.type="text/html",r.data="about:blank",Qe(r,{display:"block",position:"absolute",top:"0",left:"0",height:"100%",width:"100%",overflow:"hidden",pointerEvents:"none",zIndex:"-1"});let s=e.width,a=e.height;const n=ut(()=>{e.width===s&&e.height===a||(s=e.width,a=e.height,e.emit(U.resize),u())},500),o=(i(r,"load",()=>{i(r.contentDocument.defaultView,"resize",()=>{n()})}),e.$container.appendChild(r),e.on(U.destroy,()=>{e.$container.removeChild(r)}),e.on(U.volumechange,()=>{var i,r,s;0===(i=e.volume)?(Qe(t.$volumeOn,"display","none"),Qe(t.$volumeOff,"display","flex"),Qe(t.$volumeHandle,"top","48px")):t.$volumeHandle&&t.$volumePanel&&(r=Xe(t.$volumePanel,"height")||60,s=Xe(t.$volumeHandle,"height"),Qe(t.$volumeHandle,"top",r-(r-s)*i-s+"px"),Qe(t.$volumeOn,"display","flex"),Qe(t.$volumeOff,"display","none")),t.$volumePanelText&&(t.$volumePanelText.innerHTML=parseInt(100*i))}),e.on(U.loading,i=>{Qe(t.$loading,"display",i?"flex":"none"),($t(e._opt.backgroundLoadingShow)&&Kt(i)||$t(i))&&Qe(t.$poster,"display","none"),i&&Qe(t.$playBig,"display","none"),it()||i||(e._opt.useMSE?setTimeout(()=>{o()},500):o())}),()=>{t.$loadingBgImage&&t.$loadingBg&&(t.$loadingBgImage.width=0,t.$loadingBgImage.height=0,t.$loadingBgImage.src="",Qe(t.$loadingBg,"display","none"))}),l=t=>{e.fullscreen&&It(t)!==e.$container||h()},h=i=>{i=vt(i)?i:e.fullscreen,Qe(t.$fullscreenExit,"display",i?"flex":"none"),Qe(t.$fullscreen,"display",i?"none":"flex")},c=()=>e._opt.playType===d&&e._opt.playbackConfig.showControl,u=i=>{it()&&t.$controls&&e._opt.useWebFullScreen&&setTimeout(()=>{if(e.fullscreen){const i=c()?48:38;var r=e.height/2-e.width+i/2,s=e.height/2-i/2;t.$controls.style.transform=`translateX(${-r}px) translateY(-${s}px) rotate(-90deg)`}else t.$controls.style.transform="translateX(0) translateY(0) rotate(0)";i&&i()},10)};try{je.on("change",l),e.events.destroys.push(()=>{je.off("change",l)})}catch(e){}e.on(U.webFullscreen,e=>{it()&&(h(e),u(()=>{f()}))}),e.on(U.recording,()=>{e.playing&&(Qe(t.$record,"display",e.recording?"none":"flex"),Qe(t.$recordStop,"display",e.recording?"flex":"none"),(e._opt.hasControl||e._opt.isShowRecordingUI)&&Qe(t.$recording,"display",e.recording?"flex":"none"))}),e.on(U.recordingTimestamp,e=>{t.$recordingTime&&(t.$recordingTime.innerHTML=Tt(e))}),e.on(U.zooming,()=>{e.playing&&(Qe(t.$zoom,"display",e.zooming?"none":"flex"),Qe(t.$zoomStop,"display",e.zooming?"flex":"none"),(e._opt.hasControl||e._opt.isShowZoomingUI)&&Qe(t.$zoomControls,"display",e.zooming?"flex":"none"))}),e.on(U.playing,e=>{p(e)});const p=i=>{Qe(t.$play,"display",i?"none":"flex"),Qe(t.$playBig,"display",i?"none":"block"),Qe(t.$pause,"display",i?"flex":"none"),Qe(t.$screenshot,"display",i?"flex":"none"),Qe(t.$record,"display",i?"flex":"none"),Qe(t.$qualityMenu,"display",i?"flex":"none"),Qe(t.$volume,"display",i?"flex":"none"),Qe(t.$ptz,"display",i?"flex":"none"),Qe(t.$zoom,"display",i?"flex":"none"),Qe(t.$scaleMenu,"display",i?"flex":"none"),Qe(t.$faceDetect,"display",i?"flex":"none"),Qe(t.$controlHtml,"display",i?"flex":"none"),e.isPlayback()&&Qe(t.$speedMenu,"display",i?"flex":"none"),h(),t.extendBtnList.forEach(e=>{e.$iconWrap&&Qe(e.$iconWrap,"display",i?"flex":"none"),e.$activeIconWrap&&Qe(e.$activeIconWrap,"display","none")}),e._opt.showPerformance?Qe(t.$performanceActive,"display",i?"flex":"none"):Qe(t.$performance,"display",i?"flex":"none"),Qe(t.$poster,"display","none"),Qe(t.$ptzActive,"display","none"),Qe(t.$recordStop,"display","none"),Qe(t.$zoomStop,"display","none"),Qe(t.$faceDetectActive,"display","none"),i||(t.$speed&&(t.$speed.innerHTML="0 KB/s"),Qe(t.$zoomControls,"display","none"),Qe(t.$recording,"display","none"),t.$ptzControl&&t.$ptzControl.classList.remove("jessibuca-ptz-controls-show")),f()},f=(e.on(U.playbackPause,e=>{p(!e)}),e.on(U.kBps,i=>{i=function(e){if(null==e||""===e||0===parseFloat(e)||"NaN"===e)return"0 KB/s";var t=["KB/s","MB/s","GB/s","TB/s","PB/s","EB/s","ZB/s","YB/s"],i=(e=parseFloat(e),Math.floor(Math.log(e)/Math.log(1024)));let r=e/Math.pow(1024,i);return(r=r.toFixed(2))+(t[i]||t[0])}(i),t.kbpsShow=i,e._opt.showBandwidth&&(t.$speed&&(t.$speed.innerHTML=i),f())}),()=>{if(c()){let i=t.controlsInnerRect.width-t.controlsLeftRect.width-t.controlsRightRect.width-t.controlsPlaybackBtnsRect.width;it()&&e.webFullscreen&&(i=t.controlsInnerRect.height-t.controlsLeftRect.height-t.controlsRightRect.height-t.controlsPlaybackBtnsRect.height),t.$playbackTimeInner.style.width=i+"px"}});if(c()){const i=()=>{if(c()){let r=0;var i=e.playback&&e.playback.playingTimestamp;if(i){const s=new Date(i),a=s.getHours(),n=s.getMinutes(),o=s.getSeconds();e.playback.is60Min?r=60*a+n:e.playback.is30Min?r=2*(60*a+n)+parseInt(o/30,10):e.playback.is10Min?r=6*(60*a+n)+parseInt(o/10,10):e.playback.is5Min?r=12*(60*a+n)+parseInt(o/5,10):e.playback.is1Min&&(r=60*(60*a+n)+parseInt(o,10)),t.$playbackCurrentTime.style.left=r+"px"}}},r=e=>{t.$playbackNarrow.classList.remove("disabled"),t.$playbackExpand.classList.remove("disabled"),e===ie&&t.$playbackNarrow.classList.add("disabled"),e===se&&t.$playbackExpand.classList.add("disabled")},s=()=>{var e=t.$playbackCurrentTime.style.left;let i=parseInt(e,10);e=t.controlsPlaybackTimeInner.width,i=0<i-e/2?parseInt(i-e/2,10):0,t.$playbackTimeInner.scrollLeft=i};e._opt.showBandwidth&&(t.$controlsLeft.style.width="90px"),e.on(U.playbackTime,e=>{t.$playbackCurrentTimeText&&(t.$playbackCurrentTimeText.innerText=lt(e,"{h}:{i}:{s}")),i()}),e.on(U.playbackPrecision,(e,a)=>{t.$playbackTimeScroll.classList.remove(ae.oneHour,ae.halfHour,ae.fiveMin,ae.tenMin),t.$playbackTimeScroll.classList.add(ae[e]),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="",e){case ie:Vs(a,t);break;case re:o=t,Ws(function(e){let t=0<arguments.length&&void 0!==e?e:[],i=[];var r=(t[0]||{}).startTimestamp;for(let a=0;a<1440;a++){let e=60*a,n=e%1800==0,o=!1;r&&(o=Hs(t,xt(r,e))),i.push({title:kt(e),timestamp:e,dataType:"second",hasRecord:o,isStart:n});var s=60*a+30;n=s%1800==0,r&&(o=Hs(t,xt(r,s))),i.push({title:kt(s),timestamp:s,dataType:"second",hasRecord:o,isStart:n})}return i}(a),function(){let e=[];for(let t=0;t<24;t++){let i=t+":00",r=t+":30";t<10&&(i="0"+i,r="0"+r),e.push({title:i,hour:t,min:0,second:0}),e.push({title:r,hour:t,min:30,second:0})}return e}(),o);break;case"tenMin":o=t,Ws(function(e){let t=0<arguments.length&&void 0!==e?e:[],i=[];var r=(t[0]||{}).startTimestamp;for(let s=0;s<144;s++)for(let e=0;e<60;e++){let a=10*e+600*s,n=a%600==0,o=!1;r&&(o=Hs(t,xt(r,a))),i.push({title:kt(a),timestamp:a,dataType:"second",isStart:n,hasRecord:o})}return i}(a),function(){let e=[];for(let i=0;i<24;i++){let r=i+":00";i<10&&(r="0"+r),e.push({title:r,hour:i,min:0,second:0});for(let s=1;s<6;s++){var t=s+"0";e.push({title:r.replace(":00",":"+t),hour:i,min:10*s,second:0})}}return e}(),o);break;case se:n=t,Ws(function(e){let t=0<arguments.length&&void 0!==e?e:[],i=[];var r=(t[0]||{}).startTimestamp;for(let s=0;s<288;s++)for(let e=0;e<60;e++){let a=5*e+300*s,n=a%300==0,o=!1;r&&(o=Hs(t,xt(r,a))),i.push({title:kt(a),timestamp:a,dataType:"second",isStart:n,hasRecord:o})}return i}(a),function(){let e=[];for(let r=0;r<24;r++){let s=r+":00";r<10&&(s="0"+s),e.push({title:s,hour:r,min:0,second:0}),e.push({title:s.replace(":00",":05"),hour:r,min:5,second:0});for(let a=1;a<6;a++){var t=a+"0",i=a+"5";e.push({title:s.replace(":00",":"+t),hour:r,min:10*a,second:0}),e.push({title:s.replace(":00",":"+i),hour:r,min:10*a+5,second:0})}}return e}(),n)}var n,o;i(),r(e),s()},16)}),e.on(U.resize,()=>{f()}),f()}if(e._opt.operateBtns.quality&&0<e._opt.qualityConfig.length){e.on(U.streamQualityChange,e=>{i(e)});const i=e=>{t.$qualityText.innerText=e,t.$qualityMenuItems.forEach(t=>{var i=t.dataset.quality;t.classList.remove("jessibuca-quality-menu-item-active"),i===e&&t.classList.add("jessibuca-quality-menu-item-active")})};{const i=e._opt.qualityConfig||[];let r="";i.forEach(e=>{r+=`\n <div class="jessibuca-quality-menu-item" data-quality="${e}">${e}</div>\n `}),r&&(t.$qualityMenuList.insertAdjacentHTML("beforeend",r),Object.defineProperty(t,"$qualityMenuItems",{value:e.$container.querySelectorAll(".jessibuca-quality-menu-item")}),setTimeout(()=>{var t=i[0];e.streamQuality=t},0))}e.streamQuality&&i(e.streamQuality)}if(e._opt.operateBtns.scale&&0<e._opt.scaleConfig.length){e.on(U.viewResizeChange,e=>{i(e)});const i=i=>{var r=e._opt.scaleConfig[i];t.$scaleText.innerText=r,t.$scaleMenuItems.forEach(e=>{var t=e.dataset.scale;e.classList.remove("jessibuca-scale-menu-item-active"),ht(t)===ht(i)&&e.classList.add("jessibuca-scale-menu-item-active")})};{const i=e._opt.scaleConfig||[];let r="";i.forEach((e,t)=>{r+=`\n <div class="jessibuca-scale-menu-item" data-scale="${t}">${e}</div>\n `}),r&&(t.$scaleMenuList.insertAdjacentHTML("beforeend",r),Object.defineProperty(t,"$scaleMenuItems",{value:e.$container.querySelectorAll(".jessibuca-scale-menu-item")}))}i(e.scaleType)}if(e.isPlayback()&&e._opt.playbackConfig.showRateBtn&&0<e._opt.playbackConfig.rateConfig.length){e.on(U.playbackRateChange,e=>{i(e)});const i=i=>{var r=e._opt.playbackConfig.rateConfig.find(e=>ht(e.value)===ht(i));r&&(t.$speedText.innerText=r.label,t.$speedMenuItems.forEach(e=>{var t=e.dataset.speed;e.classList.remove("jessibuca-speed-menu-item-active"),ht(t)===ht(i)&&e.classList.add("jessibuca-speed-menu-item-active")}))};{const i=e._opt.playbackConfig.rateConfig;let r="";i.forEach((e,t)=>{r+=`\n <div class="jessibuca-speed-menu-item" data-speed="${e.value}">${e.label}</div>\n `}),r&&(t.$speedMenuList.insertAdjacentHTML("beforeend",r),Object.defineProperty(t,"$speedMenuItems",{value:e.$container.querySelectorAll(".jessibuca-speed-menu-item")}))}const r=e.playback?e.playback.playbackRate:1;i(r)}e.on(U.stats,(function(){var i,r,s,a,n,o,l,d,h,c,u,p,f,m,g,b,v,_,w=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};e._opt.showPerformance?(Qe(t.$performancePanel,"display","block"),t.$performancePanel.innerHTML="",_=window.performance&&window.performance.memory?window.performance.memory:null,i=e.video&&e.video.videoInfo||{},r=e.audio&&e.audio.audioInfo||{},s=e._times||{},a=e.getRenderType(),n=e.getCanvasRenderType(),o=e.getDecodeType(),l=e.getDemuxType(),d=e.getStreamType(),h=e.getAudioEngineType(),p=e.getRecordingDuration(),f=e.getRecordingByteLength(),c=e.isAudioPlaybackRateSpeed(),u=e.videoIframeIntervalTs,p=Tt(p),f=pt(f),m=e.isPlayback()?"录播":"直播",g=w.isDropping,b=e.control?e.control.kbpsShow:"0 KB/s",v=e.getVideoPlaybackQuality(),_=`\n <div class="jessibuca-performance-item">\n <span>版本 "7-18-2023"</span>\n </div>\n ${_?`\n <div class="jessibuca-performance-item">\n <span>内存大小限制 ${pt(_.jsHeapSizeLimit)}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>可使用的内存 ${pt(_.totalJSHeapSize)}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>已使用的内存 ${pt(_.usedJSHeapSize)}</span>\n </div>\n `:""}\n ${_&&_.usedJSHeapSize>_.totalJSHeapSize?'\n <div class="jessibuca-performance-item">\n <span>可能内存泄漏 是}</span>\n </div>\n ':""}\n <div class="jessibuca-performance-item">\n <span>播放模式 ${m}</span>\n </div>\n ${e.isPlayback()?`\n <div class="jessibuca-performance-item">\n <span>播放倍率 ${e.playback.rate}倍</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>播放模式 ${e.playback.isUseFpsRender?"固定FPS":"动态FPS"}</span>\n </div>\n ${e.playback.isUseFpsRender?`\n <div class="jessibuca-performance-item">\n <span>固定FPS ${e.video.getStreamFps()}</span>\n </div>\n `:""}\n `:""}\n <div class="jessibuca-performance-item">\n <span>解封装模式 ${y[l]}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>解码模式 ${o}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>渲染组件 ${a}</span>\n </div>\n ${a===A?`\n <div class="jessibuca-performance-item">\n <span>渲染引擎 ${n}</span>\n </div>\n `:""}\n <div class="jessibuca-performance-item">\n <span>网络请求组件 ${d}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>视频格式 ${i.encType||"-"}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>视频(宽x高) ${i.width||"-"}x${i.height||"-"}</span>\n </div>\n ${e.isPlayer()?`\n <div class="jessibuca-performance-item">\n <span>视频GOP(ms) ${u||"-"}</span>\n </div>\n `:""}\n <div class="jessibuca-performance-item">\n <span>音频格式 ${K[r.encType]||"-"}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>音频引擎 ${h||"-"}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>音频通道 ${r.channels||"-"}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>音频采样率 ${r.sampleRate||"-"}</span>\n </div>\n ${e.isPlayer()?`\n <div class="jessibuca-performance-item">\n <span>播放器初始化(ms) ${s.playTimestamp}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>开始请求地址(ms) ${s.streamTimestamp}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>请求响应(ms) ${s.streamResponseTimestamp}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>解封装(ms) ${s.demuxTimestamp}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>解码(ms) ${s.decodeTimestamp}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>页面开始渲染(ms) ${s.videoTimestamp}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>初始化到页面渲染(ms) ${s.allTimestamp}</span>\n </div>\n ${e.recording?`\n <div class="jessibuca-performance-item">\n <span>视频录制时间 ${p}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>视频录制大小 ${f}</span>\n </div>\n `:""}\n `:""}\n <div class="jessibuca-performance-item">\n <span>音频码率(bit) ${w.abps}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>视频码率(bit) ${w.vbps}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>视频帧率(fps) ${w.fps}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>视频峰值帧率(fps) ${w.maxFps}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>解码帧率(fps) ${w.dfps}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>音频缓冲帧 ${w.audioBuffer}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>音频缓冲时长(ms) ${w.audioBufferDelayTs}</span>\n </div>\n ${e.isPlayer()?`\n <div class="jessibuca-performance-item">\n <span>视频待解码帧 ${w.demuxBuffer}</span>\n </div>\n `:`\n <div class="jessibuca-performance-item">\n <span>缓存时长(ms) ${w.playbackCacheDataDuration}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>视频待渲染帧 ${w.playbackVideoBuffer}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>视频待解码帧 ${w.demuxBuffer}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>音频待解码帧 ${w.audioDemuxBuffer}</span>\n </div>\n `}\n <div class="jessibuca-performance-item">\n <span>待解封装数据(byte) ${w.flvBuffer}</span>\n </div>\n ${e._opt.useMSE?`\n <div class="jessibuca-performance-item">\n <span>MSE缓冲时长(ms) ${w.mseDelay}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>MSE解码间隔(ms) ${w.mseDecodeDiffTimes}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>MSE解码时间(ms) ${w.mseTs}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>MSE播放模式 ${1<w.mseDecodePlaybackRate?"加速":"正常"}</span>\n </div>\n `:""}\n ${e._opt.useWCS?`\n <div class="jessibuca-performance-item">\n <span>WCS解码间隔(ms) ${w.wcsDecodeDiffTimes}</span>\n </div>\n `:""}\n ${e.isOldHls()?`<div class="jessibuca-performance-item">\n <span>HLS缓冲时长(ms) ${w.hlsDelay}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>HLS播放模式 ${1<w.hlsDecodePlaybackRate?"加速":"正常"}</span>\n </div>\n `:""}\n ${e.isUseHls265()?`<div class="jessibuca-performance-item">\n <span>HLS缓冲时长(ms) ${w.hlsDelay}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>HLS待解码帧 ${w.hlsDemuxLength}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>HLS待解码视频帧 ${w.hlsDemuxVideoLength}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>HLS待解码音频帧 ${w.hlsDemuxAudioLength}</span>\n </div>\n `:""}\n ${e.isPlayer()&&v?`\n <div class="jessibuca-performance-item">\n <span>已渲染帧 ${v.renderedVideoFrames}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>已丢弃帧 ${v.droppedVideoFrames}</span>\n </div>\n `:""}\n ${e.isPlayer()?`\n <div class="jessibuca-performance-item">\n <span>网络延迟(ms) ${w.netBuf}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>缓冲时长(ms) ${w.buf}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>最新缓冲时长(ms) ${w.pushLatestDelay}</span>\n </div>\n `:""}\n <div class="jessibuca-performance-item">\n <span>视频显示时间(ms) ${w.ts}</span>\n </div>\n ${e._opt.hasAudio&&e.isAudioNotMute()?`\n <div class="jessibuca-performance-item">\n <span>音频显示时间(ms) ${w.audioTs}</span>\n </div>\n ${e._opt.hasVideo?`\n <div class="jessibuca-performance-item">\n <span>音视频同步时间戳(ms) ${w.ts-w.audioTs}</span>\n </div>\n `:""}\n <div class="jessibuca-performance-item">\n <span>音频播放模式 ${c?"加速":"正常"}</span>\n </div>\n `:""}\n <div class="jessibuca-performance-item">\n <span>视频解码时间(ms) ${w.dts}</span>\n </div>\n ${e.isPlayer()?`\n <div class="jessibuca-performance-item">\n <span>解码前-解码后延迟(ms) ${w.delayTs}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>总延迟(网络+解码)(ms) ${w.totalDelayTs}</span>\n </div>\n `:""}\n ${e.isPlayer()&&w.isStreamTsMoreThanLocal?'<div class="jessibuca-performance-item">\n <span>是否超过一倍率推流 是</span>\n </div>\n ':""}\n ${e.isPlayer()?`\n <div class="jessibuca-performance-item">\n <span>是否在丢帧 ${g}</span>\n </div>\n `:""}\n <div class="jessibuca-performance-item">\n <span>网速 ${b}</span>\n </div>\n <div class="jessibuca-performance-item">\n <span>播放时长(s) ${Tt(w.pTs)}</span>\n </div>\n <div class="jessibuca-performance-item-block"></div>\n `,t.$performancePanel.insertAdjacentHTML("beforeend",_)):(t.$performancePanel.innerHTML="",Qe(t.$performancePanel,"display","none"))})),e.on(U.togglePerformancePanel,e=>{Qe(t.$performance,"display",e?"none":"flex"),Qe(t.$performanceActive,"display",e?"flex":"none")}),e.on(U.faceDetectActive,e=>{Qe(t.$faceDetect,"display",e?"none":"flex"),Qe(t.$faceDetectActive,"display",e?"flex":"none")})};function $s(e,t){var i,r;t=(t=void 0===t?{}:t).insertAt;e&&"undefined"!=typeof document&&(i=document.head||document.getElementsByTagName("head")[0],(r=document.createElement("style")).type="text/css","top"===t&&i.firstChild?i.insertBefore(r,i.firstChild):i.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e)))}function Ys(e,t){t instanceof Element?e.appendChild(t):e.insertAdjacentHTML("beforeend",String(t)),e.lastElementChild||e.lastChild}function qs(e,t,i){e.style[t]=i}function Js(e,t){return e.composedPath&&-1<e.composedPath().indexOf(t)}function Qs(e){let t=!1;return e&&e.parentNode&&(e.parentNode.removeChild(e),t=!0),t}$s('@-webkit-keyframes rotation{0%{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(1turn)}}@keyframes rotation{0%{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(1turn)}}@-webkit-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}}@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}}.jessibuca-container .jessibuca-icon{cursor:pointer;width:16px;height:16px;display:inline-block}.jessibuca-container .jessibuca-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}.jessibuca-container .jessibuca-ptz-controls.jessibuca-ptz-controls-show{visibility:visible;opacity:1}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-ptz-bg-active.jessibuca-ptz-bg-active-up{transform:rotate(-90deg)}.jessibuca-container .jessibuca-ptz-bg-active.jessibuca-ptz-bg-active-left{transform:rotate(180deg)}.jessibuca-container .jessibuca-ptz-bg-active.jessibuca-ptz-bg-active-down{transform:rotate(90deg)}.jessibuca-container .jessibuca-ptz-bg-active.jessibuca-ptz-bg-active-left-up{transform:rotate(-135deg)}.jessibuca-container .jessibuca-ptz-bg-active.jessibuca-ptz-bg-active-right-up{transform:rotate(-45deg)}.jessibuca-container .jessibuca-ptz-bg-active.jessibuca-ptz-bg-active-left-down{transform:rotate(135deg)}.jessibuca-container .jessibuca-ptz-bg-active.jessibuca-ptz-bg-active-right-down{transform:rotate(45deg)}.jessibuca-container .jessibuca-ptz-bg-active.jessibuca-ptz-bg-active-show{visibility:visible;opacity:1}.jessibuca-container .jessibuca-ptz-control{position:absolute;left:53px;top:53px;width:50px;height:50px;background:#fff;border-radius:50%;transition:left .3s,top .3s}.jessibuca-container .jessibuca-ptz-control.jessibuca-ptz-control-left{left:33px}.jessibuca-container .jessibuca-ptz-control.jessibuca-ptz-control-up{top:33px}.jessibuca-container .jessibuca-ptz-control.jessibuca-ptz-control-right{left:73px}.jessibuca-container .jessibuca-ptz-control.jessibuca-ptz-control-down{top:73px}.jessibuca-container .jessibuca-ptz-control.jessibuca-ptz-control-left-up{top:39px;left:39px}.jessibuca-container .jessibuca-ptz-control.jessibuca-ptz-control-left-down{left:39px;top:67px}.jessibuca-container .jessibuca-ptz-control.jessibuca-ptz-control-right-up{top:39px;left:67px}.jessibuca-container .jessibuca-ptz-control.jessibuca-ptz-control-right-down{top:67px;left:67px}.jessibuca-container .jessibuca-ptz-icon{position:relative}.jessibuca-container .jessibuca-ptz-icon:hover .icon-title-tips{visibility:visible;opacity:1}.jessibuca-container .jessibuca-ptz-btns{display:block;position:absolute;left:0;top:156px;width:156px;box-sizing:border-box;padding:0 30px}.jessibuca-container .jessibuca-ptz-btns .jessibuca-ptz-btn{display:flex;justify-content:space-between}.jessibuca-container .jessibuca-ptz-expand .jessibuca-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%}.jessibuca-container .jessibuca-ptz-expand:hover .jessibuca-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%}.jessibuca-container .jessibuca-ptz-narrow .jessibuca-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}.jessibuca-container .jessibuca-ptz-narrow:hover .jessibuca-ptz-narrow-icon{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcBAMAAACAI8KnAAAAJ1BMVEVHcEyZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZn+/v7X19ckk9ihAAAACnRSTlMA9+NCAsuKJsRiPv/2GwAAAJlJREFUGNNjYAAC5gxFoTYDBijw1FoFBIumQHjsUavAYGkBmGu0CgqUwRqlYNyFIO2Fq+BAnIGBJQrBXerAwLkKCUxgYELmKjBYIXMXM2Qhc5cxdCFzVzBoIXMXMYAcsRsMdgEdgs4FKT4DBqdAitGMQrMIzRkojlRB9wKaB9G8z+CMGjgshjCuMCjoWNxRAxYt2KGRYgJiAQAnZcjElaB/xwAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-ptz-aperture-far .jessibuca-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}.jessibuca-container .jessibuca-ptz-aperture-far:hover .jessibuca-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%}.jessibuca-container .jessibuca-ptz-aperture-near .jessibuca-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}.jessibuca-container .jessibuca-ptz-aperture-near:hover .jessibuca-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%}.jessibuca-container .jessibuca-ptz-focus-far .jessibuca-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}.jessibuca-container .jessibuca-ptz-focus-far:hover .jessibuca-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%}.jessibuca-container .jessibuca-ptz-focus-near .jessibuca-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}.jessibuca-container .jessibuca-ptz-focus-near:hover .jessibuca-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%}.jessibuca-container .jessibuca-ptz-arrow{cursor:pointer;position:absolute;width:0;height:0}.jessibuca-container .jessibuca-ptz-arrow-up{left:71px;top:15px;border:7px solid transparent;border-bottom:10px solid #fff}.jessibuca-container .jessibuca-ptz-arrow-right{top:71px;right:15px;border:7px solid transparent;border-left:10px solid #fff}.jessibuca-container .jessibuca-ptz-arrow-left{left:15px;top:71px;border:7px solid transparent;border-right:10px solid #fff}.jessibuca-container .jessibuca-ptz-arrow-down{left:71px;bottom:15px;border:7px solid transparent;border-top:10px solid #fff}.jessibuca-container .jessibuca-ptz-arrow-left-up{transform:rotate(45deg);left:32px;top:33px;border:7px solid transparent;border-right:10px solid #fff}.jessibuca-container .jessibuca-ptz-arrow-right-up{transform:rotate(-45deg);right:32px;top:33px;border:7px solid transparent;border-left:10px solid #fff}.jessibuca-container .jessibuca-ptz-arrow-left-down{transform:rotate(45deg);left:32px;bottom:33px;border:7px solid transparent;border-top:10px solid #fff}.jessibuca-container .jessibuca-ptz-arrow-right-down{transform:rotate(-45deg);right:32px;bottom:33px;border:7px solid transparent;border-top:10px solid #fff}.jessibuca-container .jessibuca-loading-bg{display:none;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}.jessibuca-container .jessibuca-loading-bg img{width:100%;height:100%}.jessibuca-container .jessibuca-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}.jessibuca-container .jessibuca-play-big{position:absolute;display:none;height:100%;width:100%;background:rgba(0,0,0,.4)}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-play-big:hover:after{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEVHcEz///////////////////////////////////////////8Uel1nAAAAC3RSTlMA+rbVFUecgC7rYhEEz+4AAACbSURBVDjL1dMhDsJAEIXhdeiGpKYWQVKDWc8ReojFc4ReAlPFFQazad7lIGkb0jK/WEPSsZ+YN5mZEP5UrZIP0vgE0Kv3oPlIJlAk8AJM4ASYwAkww2+ABfQg0ImgugPYsfNBVl99kA0AsjOArAPQpRTGHiBB8whxM0y+3skXNltsvMYriIWrpWPA80mFJ5qL3gAfB1/tcAt7rzdiV+HEgs1oBgAAAABJRU5ErkJggg==")}.jessibuca-container .jessibuca-recording{display:none;position:absolute;left:50%;top:0;padding:0 3px;transform:translateX(-50%);justify-content:space-around;align-items:center;width:95px;height:20px;background:#000;opacity:1;border-radius:0 0 8px 8px;z-index:1}.jessibuca-container .jessibuca-recording .jessibuca-recording-red-point{width:8px;height:8px;background:#ff1f1f;border-radius:50%;-webkit-animation:magentaPulse 1s linear infinite;animation:magentaPulse 1s linear infinite}.jessibuca-container .jessibuca-recording .jessibuca-recording-time{font-size:14px;font-weight:500;color:#ddd}.jessibuca-container .jessibuca-recording .jessibuca-icon-recordStop{width:16px;height:16px;cursor:pointer}.jessibuca-container .jessibuca-zoom-controls{display:none;position:absolute;left:50%;top:0;padding:0 3px;transform:translateX(-50%);justify-content:space-around;align-items:center;width:150px;height:30px;background:#000;opacity:1;border-radius:0 0 8px 8px;z-index:1}.jessibuca-container .jessibuca-zoom-controls .jessibuca-zoom-narrow{width:16px;height:16px;cursor:pointer}.jessibuca-container .jessibuca-zoom-controls .jessibuca-zoom-tips{font-size:14px;font-weight:500;color:#ddd}.jessibuca-container .jessibuca-zoom-controls .jessibuca-zoom-expand,.jessibuca-container .jessibuca-zoom-controls .jessibuca-zoom-stop2{width:16px;height:16px;cursor:pointer}.jessibuca-container .jessibuca-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}.jessibuca-container .jessibuca-loading-text{line-height:20px;font-size:13px;color:#fff;margin-top:10px}.jessibuca-container .jessibuca-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}.jessibuca-container .jessibuca-controls .jessibuca-controls-item{position:relative;display:flex;justify-content:center;padding:0 8px}.jessibuca-container .jessibuca-controls .jessibuca-controls-item:hover .icon-title-tips{visibility:visible;opacity:1}.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-face,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-face-active,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-fullscreen,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-fullscreen-exit,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-icon-audio,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-microphone-close,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-pause,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-performance,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-performance-active,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-play,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-ptz,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-ptz-active,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-quality-menu,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-record,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-record-stop,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-scale-menu,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-screenshot,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-speed-menu,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-template-menu,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-volume,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-zoom,.jessibuca-container .jessibuca-controls .jessibuca-controls-item.jessibuca-zoom-stop{display:none}.jessibuca-container .jessibuca-controls .jessibuca-controls-item-html{position:relative;display:none;justify-content:center}.jessibuca-container .jessibuca-controls .jessibuca-icon-audio,.jessibuca-container .jessibuca-controls .jessibuca-icon-mute{z-index:1}.jessibuca-container .jessibuca-controls .jessibuca-controls-bottom{display:flex;justify-content:space-between;height:100%}.jessibuca-container .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-left,.jessibuca-container .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-right{display:flex;align-items:center}.jessibuca-container.jessibuca-controls-show .jessibuca-controls{opacity:1;visibility:visible}.jessibuca-container.jessibuca-controls-show-auto-hide .jessibuca-controls{opacity:.8;visibility:visible;display:none}.jessibuca-container.jessibuca-hide-cursor *{cursor:none!important}.jessibuca-container .jessibuca-icon-loading{width:50px;height:50px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAIVBMVEVHcEx4eHh4eHh4eHh4eHh3d3d4eHh4eHh4eHh4eHh4eHiqaCaRAAAACnRSTlMAikwX3CxpwZ7zIGi5xgAAAZ9JREFUOMt9lb9Lw0AUx2Njqm4iGEqmEnBxslKUdhJctFMVcW5wKZ0CLpJJQRw6iVqQbg3FtPdX+l5+XHJ3796bQj557773fe8ujtOI+6jz5p84dHjTkYD4+RhT9CIRZWRPJr1bChnbY532GhT4oUpbI6HEuqvgIH9544dh9J4/rpr0Ms8oV3zMNT7X1MXSmaznzfHjM4n72moe5n8ryYrW9rKRvgf0S93JA7yKa9lbzUg3keJb8OVCtwkrFmoO4MnsAuj5rGqnZg+GZXUXkl9NjEui9n3YA9XgpMgakLXz6ujMTIgrCkPVv0Jil8KgKQN/wRN69hLcb1vrbR2nQkxwiZTGQ5Teb7TO8PUaS8Q03sE+zkjP8qbjzgJtEhRbV4gnlkOFeM7hDYNdxPbiYFvKSHN6L2NmY5WzMYPtplZdTxncRvn2sI+DHIoug22jWMaA12Y7BrXzrG8BX32XPMDKWVzw1bdMOnH1KNqNi8toqn7JGumZnStXLi0e4tcP6R3I635Nc/mzsMxl9aux9b78UVmn2pve8u6eR50j9c0/ywzyVl5+z84AAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%;-webkit-animation:rotation 1s linear infinite;animation:rotation 1s linear infinite}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-icon-play{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAIVBMVEVHcEzMzMzMzMzNzc3MzMzPz8/Nzc3MzMzMzMzMzMzMzMzLVn6fAAAACnRSTlMA+duduRUwSGSD8toSsAAAAI9JREFUOMvV07ENgzAQhWG3lLSp6MwCViYIRSpG8AiM4FWMaPymDBKESMF/cQ0S136F353vnLuo3gp1kOYEoCXW4LFKIZAnqAXYICeASoAdzgG+cApwgF4EfwF+oDkCqIwA6gnyAKA8AaizQhsBAjzuqUHofInGIQbjRxXjMrTJuHDestR4Bng4eGrN0929PqNfzC6h06weAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-icon-pause{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEVHcEzMzMzHx8fMzMzMzMzOzs7MzMz4IlKVAAAABnRSTlMA6xIU1hVqIuOVAAAAMUlEQVQ4y2NgGFYgLS3RAEQziQFZoxKjEqMSaBJpEAkgIw1ZQlBQRAEs4QhkDeIMDgAWx1gMHyIL4wAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-pause:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEVHcEz///////////////////////+3ygHaAAAABnRSTlMA7OgSFBXMmAA4AAAAM0lEQVQ4y2NgGFYgLS3JAUQzi6WlJY5KjEqMSqBJpEEkgIw0ZAklJSUDsISikpLQIM7gAJjhWp6XcaOxAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-record{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAHlBMVEVHcEzGxsbMzMzMzMzLy8vMzMzMzMzNzc3MzMzMzMxEZ/aQAAAACXRSTlMADPKKKeBxlV6neZ4mAAAArUlEQVQ4y2NgGDZgJhpowCURAJeYpIQENJEkCgWRgCeShAGyjfgl2EqwS7BFToZJiLg4ICTEImdOh0pwRM6cDJcIjpw5E6aDFeh8B5gECBCUYAkKCoMbNXNSOlyCgUEQ4apJJmxIEkjOVWFgxi4RgEsikGQJnEYp4pLA6VxUDyJLIAUJcRLIwY7qXKSIQvOHWCQODzKIleBPPjgTHM4kijNR48oGkajiYUMykwMAAfmZhUjBISQAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-record:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJ1BMVEVHcEz///////////////////////////////////////////////8NopmKAAAADHRSTlMA8gyMLeRw1x2DBpWGN2QDAAAAt0lEQVQ4y2NgGDbgDBpIwCVRAJc4KIgEZM4EwCU2KSEBHySJCcg29iBJGCBLgHUs24FdYlnNYZiESksDXKJALebMaagES8yZw3CJypgzZ2A6WIHOd4BJgABMgh2XBEtpaBjcqDMHs+ESDFyLEK46aMGGkEB2rgQDJ3aJAFwSUSRL4DQKp+VHcTkXxYMoEkhBQpwEcrCjSCBHFJo/1GIO408MOJMPzgSHM4niTNS4skENqnjYkMzkAEgzyFpeX6L3AAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-icon-fullscreenExit{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAG1BMVEVHcEzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMxi4XDRAAAACHRSTlMAf3WqJmy+7azWNnMAAADNSURBVDjLxZQ9E4IwDIaLfMzCOTDSOz07OjLir5CR0dmJFVHIzzZtnMzbOzcyZHnuaXpJWmO2ji4GhpAzzZeQzw8FKCj1pMHss9OgpwsGOS0YGOcVUMPsfBVkmJoVCBJW0FFB6SFIaMKAlRGDnEiDkuM00lP3SmL6H5QSh+iIr9ZWVWntUV9Z4qWbHAWrhcUYNLC4Wwm3xb1r2mOQYoVn2EKFAVb81KHiQQq6L3vSUoMBUmSzgCKbVeiL3eTp3Odf8H1sxRAZZNZt/Vt8AHcPQbiQQVF+AAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-icon-audio{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAIVBMVEVHcEzKysrMzMzMzMzMzMzMzMzMzMzMzMzMzMzNzc3MzMz8gU00AAAACnRSTlMAL0jMZKt96hGJsSKv1QAAAJ9JREFUOMvN078KQFAYBfCbJEw2q6SUyWxTnsJT2JTJ6D38Gb6n5PpT6BwbuaNfTnz3fEp9fZwAP7czD0MsGCzBYJcEYsGwBEHQQRB0EII1CMAWdAOzyJUvJ4jyDVyZVHKGpj9guEI2IuhaDFadYnCkIm9I+kPgn8t+kI7kOsT72HcwQnJR9Gofy8DrwwtHK8pLzdeALg5fNb6cdJ1fOjOGYrl5CLFcggAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-audio:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJ1BMVEVHcEz///////////////////////////////////////////////8NopmKAAAADHRSTlMAL0TQf2frEaZYt8E+idL4AAAAnUlEQVQ4y2NgoDdgUcAuzr4Hh4TaGQHsBp3BLsG+BoeE2hnsEkCDsEqADMIqATIImwTYICwSEIPQJFhnBjKInUGSUA2CSPCcOcIwB1ki5xRM4iiDDrKEzQlsEuUF2CVY0jbgkDhjMLQkEkj0IM4gQQ1EHMHOOXMiakRpTiQQtXgTA+7kgzvB4UyiuBM17myAM+Pgzmq4MyfO7EwjAAAEf+BAxqI/agAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-icon-face:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAnUExURUdwTP///////////////////////////////////////////////w2imYoAAAAMdFJOUwBAgBvfrFmcw4wrbtGliFoAAAD2SURBVDjLY2AYRkAJCAygbEZBQUEBKJvpDBDAODpA9kGYxEGgKphuIaBuhASqyYzESjBu79yIVWIP0NoCLBIsR4WZJY5gkYiZACRqFJAlGMG8EyAmK1hMGdkp7M4gkus4RrCwBIApFwwJmwlgqsYAQ6IAIrEAwygHHEaxngJbfhRDgg0sxHoMM7Z0AmC+RAPsJ4S5NE5gid8VoHg8sgHTDh/PzM60HkzLc44bgKMf3RKuMwoQ+dNIgswJDAycUDPYjhgwMCsjxYcJLA6AMYISUTkBMLsaUCVqEqAcngPEJx+SJJDSLii1HySU2lHyByi1Kwy9LA4AqflRBKNSA88AAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-faceActive{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAhUExURUdwTBCT2xKV2hGY2hKW2xGW2xGW2xGW2xKX3BGX3BKW23povfoAAAAKdFJOUwBAgRybs9hZLG6hrV9tAAAA80lEQVQ4y2NgGEZACQgMoGxGQUFBASibaRUQwDhaQPZCmMRCoCqYbiGgboQEqsmMxEowTgmZiFViFtBaBywSbEuFmcWWYZGIUgASXgrIEoxg3lIQkxUspozsFJZkEMmxBCNY2MD2MqRhSFgpgCkvAwwJBxwSbAk4jGJZAbZ8KYYEO8S5yzFjSysA5kt0s5YKc6guwxK/baB4XDYB045Vi4pCyrMwLa9aYgCOfgc0cY5VEGurViIJMhcAlULNYF9mwMCsjBQfZrA4AMYISkRVBcDsCkCV8CqAcrgWEJ98SJJASrug1L6QUGpHyR+g1K4w9LI4ALk0RHtSETFcAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-faceActive:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAhUExURUdwTHzD63zE6n7H7H3F7H3F633G63zF7H3G7H3F7H3F68TinBIAAAAKdFJOUwBAgR+Z31ipwW4yAjb9AAAA+UlEQVQ4y2NgGEZACQgMoGxGQUFBASibaRUQwDhaQPZCmMRCoCqYbiGgboQEqsmMxEowTmmZiFViFtBaBywSrMuFmSWWYpGoUgASXgrIEowgHtsKEJMDLKaM7BSWYLCaJRjBwloAploxJKwUwJSXAYYE2KUMVRgSrAFgKhTDKPbFIJJ5OYYEG1iIfRlmbGkVwHyJBlhWCDNrrMASvxageFw6AdOOqKCklrQuTMuzlhiAo98BTZx5FcTarJXIgglApVBr2ZYaMDArI8WHKSwOgDGCElFZBTC7GlAlvBKgHK4FxCcfkiSQ0i4otS8klNpR8gcotSsMvSwOAIs+RIlIrewIAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-icon-zoomStop:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAqUExURUdwTBKV2hGW2xKW2xKW2xKW2xGV3BGW2xGW3BGX2xKW3BKW2xCX2xKW2yDN61kAAAANdFJOUwCAVKxm3T/DmhrxKw97YQBGAAABaklEQVQ4y2NgIA6wGqCLMCqAqV4HdIm9F0Ek22UMM9hiG4AkVzQDA+cmx+YyJJnDlw8wMNQaNpfevbu0QgxJgrN3JQPD3VvhjU57kESnOZqvvXuJgcEXxVFMEkDt1w11gZYwoVgue3d5SzaQSgCydZG1TMkBU8vBuq9guBcqNBNDgj0GQrMEb0CVYEmA2ViANRQZ795tQPZduADciXcVUNSthGu4hGrAJawagBIXsWoAClzGqgEocRWrBqDIrQNQDTPRXZ8A0cB41wBNQgGiQfbubTQJAagGDB0GIA0OsnevbkCTCADiu4J374ahW34JqAEIbiXMRJOAgkvMKJYgJBx6717AKiF4F4eOu+jxgQCXGHBIKPDgkBC8JYCURJDtQHYWN4oEcvpZiyR+C9lZtkgSKKG1CyGOGrxItleixjrcLFBWRAYcMIkG9NQMiY67N7AlcxAQwMwA6SBxM2xZQ3jtVRPsRQ83sg8ACMIUxzzE8wsAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-close{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAeUExURUdwTM3Nzc7Ozs7Ozs3Nzc3NzcrKys3Nzc3Nzc3NzePZJxkAAAAJdFJOUwCtKdPBGAmNTt3jdDcAAADfSURBVDjL1dOxDoIwEADQgwR07GTCZtI/IGHgAzBhM9EPkMTB0Y3V0ZXIcn/rtRR6pefgSKeSu3ellyvA9lZ/5F9p/3K7PZY8oPG5BD6MpPUSgIITzdIStifAshjRQV1PCFT8TxaicTzzwEwINOEdHVmDmcTAkRhMhMAp7iQRjcMtDhCp8SA1v0ARGIIK/gnkv0p1OBTS4QRUIpE7DiYYXTBrzcld3JIrAarXrps4AVNwRSZgExoJmIyAaAdsShUMn/JF2fh4YEkpAcgvnuwYCIb6EbbbP4PsDfLD2dD6Av1qTvAQlzUTAAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-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%}.jessibuca-container .jessibuca-icon-narrow{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAzUExURUdwTP///////////////////////////////////////////////////////////////8/RimEAAAAQdFJOUwAyqXf5Hu1TZxDRmrxFjN7ZJa7NAAABXElEQVRIx92VS5KFIAxFgfALoLL/1XaVKPBCQteb9KAzM3Ik3FyiUv8rQqo0MsrL0VQmfJDWa1/5OPn1x1hxFWNMsv3ZsN/vJZy6ZVzoJWam/rcemA+pXwQWoLQXSZN8fAiaDy1dxKMlkvZsdiaIuC3pWPmgKccAIDToYk5x6ykahpF209B3i2sBtAic6wlHRRhHQJhrOghQOAeWyTaRAM1h9ELcq9AuInYVqMXzMBqwO2QC3IU7y5X0+MLYKa44nSFQlR5foxvxYVlN+3CIfbhvhUcKGHE42NX6G7O+do0rYHYbVGTuAz+BCjcHMn9zh/M8stsySp3CoAn8PHFFHJjPl2qa3jiYrBXY7tzIGRwi6mg+nbgQs++8t+tQDnyDNrEQev2fVJt3hIoE8dl1AYXWHrkzvkScJRdHizsiAASNtEk7S/NtXUbs70RSXxKgviPKFz99bVIB9SfxA8uZLAsxki39AAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-narrow:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAnUExURUdwTMzMzMzMzM3NzczMzM7Ozs3NzczMzMzMzMzMzMzMzMzMzMzMzH6OaiEAAAAMdFJOUwBv7U2hEB4zt9NZixFhg1cAAAF+SURBVDjLY2CgF+CacwYKXFHEWXtg4mcOLUCWKDqDAKeRxJnBIhounWDaASFRAzJiO5CR5QNkHUHYoAPkioKZ7CAZAZgEB5AzHcpmBLKPwyRszpw5gWzsSRgbaNIEFIfAXAxkJiBcsgeh7MyZg0hu50RYcuaMAqqnTsMlNiAHgw7c9jNnCpAl9sCtPHMISEQJgoAwxPUGUAmgL9h1IEHYAPYJ1L2g0OGEhi3QfTHwQAFJMCECPQhFggUqAfRCDkIC5DwnSPwJoNhxKICBgS0NBEDuXAN3Ptx5EOADVgiRcEBOGIhIOHPmGJIEIyJMkeMJ7I2jiPhASkw9CJN9kKKZgfsM3G6QZoS79iClH+YzCPsyQL5EVnVmMpgVDQ7kwzAJcEDNNgsNXwINfAOEZ0FASQeWsA8jeQoVwLVUwoVUULUwrISJJ6xB1cJgDcpshxoDGLhgEQYDbIaCUqUMkPhAziRIGRUkcRJbFl6DS4LrDGoyR9HSgFWC3bORnFIEAI39IME59Pz6AAAAAElFTkSuQmCC") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-expand{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAtUExURUdwTM3NzczMzMzMzMzMzMzMzMvLy8vLy8zMzMzMzMzMzMzMzMzMzMzMzMzMzAmiiJAAAAAOdFJOUwAqre7XQBoOxWGeiHNRIXj5WAAAAcNJREFUOMu1VLtKQ0EQ3Ygx5FEIPhpFVLAIaNAUPkACWliGYGEpMWKjIKktJGBjIWIhiAgSRGwESWkhwcpGEAUtRJCYmBjFzDc4szv7uCpYOcXd2T07u2fOzF4h/jLf01H/xdzP9a4koFWi2W/rs8A26UXWwNiEu+5PWADyDnDorMOrPSwo7x186DjYJm/GAM84q+9JzkUKMRnQtkv2Y+j3MtCM/pTeFcHJO/s3nguJCM/QG7MMKaRggBSN99NyJ97ypoEPmSVAjsZ1gE8NyB0hgBcaw4Ywq9AEUKUxgEenGUi5EXTJjgIqdGlnBqCxkFb0FS2o42cXSOFEHPfM69yhzLKQIbEepieIbVgDNSEWXSDiAKsGwKNadA0L7lGUz/LmBia2uaXKk+c80p48iro6nE+IMxdY31sGcq4kPlMQK16NN5S1iJQ6EZNKIKmGKZS8bCUqp9jEw0J7VVtaPInFJdGU8NLObGMhT11MITJua9DT6ONuJWlGNdBGIg0R9271fFp1j0oFx0+vj1nJER3SDl4zIYGYs1h0Q4JJA5z43RCLDKi8cvYZntNy/Er1KpSch7j0uH+X1VKUfv1J+I1a/2xf3OKDpNnEfRYAAAAASUVORK5CYII=") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-expand:hover{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAA5UExURUdwTP///////////////////////////////////////////////////////////////////////308lk0AAAASdFJOUwBFnl8nDsur9hnq2jeLum17VecmAZgAAAGgSURBVEjH1VbZdsUgCIz7boz//7Fto3FBzLk9fSpvUUdgGDDH8WfjV6JKqZC8+eR0kLmZVky8H/cxA7PpBSJoRsyy3XliM24UP8/y1iQW1tljUIl479mQvlv5utptAzE8NMTC5kPkCdZV3VAA4OpFfHGdKoJhCTixJ0NPe7pki9eo3hbGtbLkOwXSqY6ueQgI6PXxN11dASWAEwL6DRQ4LIlLABgEUGIg3UWJycyAvl89DBRHyOxIG+emeLgMNxNRYQLUCJnLWj9lzzqKzsJY7fbloVDjoJw4AUrOYZH2HZXRgKYGSJ8DSkgGdl3YhlThhkoZC8pFGWt1CWzVH0rMsa10jTTNhWMvAAlKf4CUoDT40hFACgF8K5jzAdR4cxVmtX9LZWmgLngTFIMNb5EZQNAWVcgUIHmPoOhkesbPCY+bOs+XAeEedfp5xjxSsXBY8qcJsiKtlZIbHhe+RWQbaUqBylmGK8Lld1sQQuEHbdAbxHFhTqhprK8IccLAFRnrJLGXLkjdnqLTgMrir53xF2OMcLFq4Rf/B0RjQvin9gVLNDmYNA/hrAAAAABJRU5ErkJggg==") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-menu-icon-text,.jessibuca-container .jessibuca-quality-icon-text,.jessibuca-container .jessibuca-scale-icon-text,.jessibuca-container .jessibuca-speed-icon-text{font-size:14px;min-width:30px;height:20px;line-height:20px;cursor:pointer;text-align:center}.jessibuca-container .jessibuca-speed{font-size:14px;color:#fff}.jessibuca-container .jessibuca-menu-list,.jessibuca-container .jessibuca-quality-menu-list,.jessibuca-container .jessibuca-scale-menu-list,.jessibuca-container .jessibuca-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:-webkit-max-content;width:-moz-max-content;width:max-content}.jessibuca-container .jessibuca-menu-list.jessibuca-menu-shown,.jessibuca-container .jessibuca-menu-list.jessibuca-quality-menu-shown,.jessibuca-container .jessibuca-menu-list.jessibuca-scale-menu-shown,.jessibuca-container .jessibuca-menu-list.jessibuca-speed-menu-shown,.jessibuca-container .jessibuca-quality-menu-list.jessibuca-menu-shown,.jessibuca-container .jessibuca-quality-menu-list.jessibuca-quality-menu-shown,.jessibuca-container .jessibuca-quality-menu-list.jessibuca-scale-menu-shown,.jessibuca-container .jessibuca-quality-menu-list.jessibuca-speed-menu-shown,.jessibuca-container .jessibuca-scale-menu-list.jessibuca-menu-shown,.jessibuca-container .jessibuca-scale-menu-list.jessibuca-quality-menu-shown,.jessibuca-container .jessibuca-scale-menu-list.jessibuca-scale-menu-shown,.jessibuca-container .jessibuca-scale-menu-list.jessibuca-speed-menu-shown,.jessibuca-container .jessibuca-speed-menu-list.jessibuca-menu-shown,.jessibuca-container .jessibuca-speed-menu-list.jessibuca-quality-menu-shown,.jessibuca-container .jessibuca-speed-menu-list.jessibuca-scale-menu-shown,.jessibuca-container .jessibuca-speed-menu-list.jessibuca-speed-menu-shown{visibility:visible;opacity:1}.jessibuca-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}.jessibuca-container .icon-title{display:inline-block;padding:5px 10px;font-size:12px;white-space:nowrap;color:#fff}.jessibuca-container .jessibuca-quality-menu{padding:8px 0}.jessibuca-container .jessibuca-menu-item,.jessibuca-container .jessibuca-quality-menu-item,.jessibuca-container .jessibuca-scale-menu-item,.jessibuca-container .jessibuca-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}.jessibuca-container .jessibuca-menu-item:hover,.jessibuca-container .jessibuca-quality-menu-item:hover,.jessibuca-container .jessibuca-scale-menu-item:hover,.jessibuca-container .jessibuca-speed-menu-item:hover{background-color:hsla(0,0%,100%,.2)}.jessibuca-container .jessibuca-menu-item:focus,.jessibuca-container .jessibuca-quality-menu-item:focus,.jessibuca-container .jessibuca-scale-menu-item:focus,.jessibuca-container .jessibuca-speed-menu-item:focus{outline:none}.jessibuca-container .jessibuca-menu-item.jessibuca-menu-item-active,.jessibuca-container .jessibuca-menu-item.jessibuca-quality-menu-item-active,.jessibuca-container .jessibuca-menu-item.jessibuca-scale-menu-item-active,.jessibuca-container .jessibuca-menu-item.jessibuca-speed-menu-item-active,.jessibuca-container .jessibuca-quality-menu-item.jessibuca-menu-item-active,.jessibuca-container .jessibuca-quality-menu-item.jessibuca-quality-menu-item-active,.jessibuca-container .jessibuca-quality-menu-item.jessibuca-scale-menu-item-active,.jessibuca-container .jessibuca-quality-menu-item.jessibuca-speed-menu-item-active,.jessibuca-container .jessibuca-scale-menu-item.jessibuca-menu-item-active,.jessibuca-container .jessibuca-scale-menu-item.jessibuca-quality-menu-item-active,.jessibuca-container .jessibuca-scale-menu-item.jessibuca-scale-menu-item-active,.jessibuca-container .jessibuca-scale-menu-item.jessibuca-speed-menu-item-active,.jessibuca-container .jessibuca-speed-menu-item.jessibuca-menu-item-active,.jessibuca-container .jessibuca-speed-menu-item.jessibuca-quality-menu-item-active,.jessibuca-container .jessibuca-speed-menu-item.jessibuca-scale-menu-item-active,.jessibuca-container .jessibuca-speed-menu-item.jessibuca-speed-menu-item-active{color:#2298fc}.jessibuca-container .jessibuca-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}.jessibuca-container .jessibuca-volume-panel-wrap.jessibuca-volume-panel-wrap-show{visibility:visible;opacity:1}.jessibuca-container .jessibuca-volume-panel{cursor:pointer;position:absolute;top:21px;height:60px;width:50px;overflow:hidden}.jessibuca-container .jessibuca-volume-panel-text{position:absolute;left:0;top:0;width:50px;height:20px;line-height:20px;text-align:center;color:#fff;font-size:12px}.jessibuca-container .jessibuca-volume-panel-handle{position:absolute;top:48px;left:50%;width:12px;height:12px;border-radius:12px;margin-left:-6px;background:#fff}.jessibuca-container .jessibuca-volume-panel-handle:before{bottom:-54px;background:#fff}.jessibuca-container .jessibuca-volume-panel-handle:after{bottom:6px;background:hsla(0,0%,100%,.2)}.jessibuca-container .jessibuca-volume-panel-handle:after,.jessibuca-container .jessibuca-volume-panel-handle:before{content:"";position:absolute;display:block;left:50%;width:3px;margin-left:-1px;height:60px}.jessibuca-container.jessibuca-fullscreen-web .jessibuca-controls{width:100vh}.jessibuca-container.jessibuca-fullscreen-web .jessibuca-play-big:after{transform:translate(-50%,-50%) rotate(270deg)}.jessibuca-container.jessibuca-fullscreen-web .jessibuca-loading{flex-direction:row}.jessibuca-container.jessibuca-fullscreen-web .jessibuca-loading-text{transform:rotate(270deg)}.jessibuca-container .jessibuca-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}.jessibuca-container .jessibuca-contextmenus .jessibuca-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)}.jessibuca-container .jessibuca-contextmenus .jessibuca-contextmenu a{color:#fff;text-decoration:none}.jessibuca-container .jessibuca-contextmenus .jessibuca-contextmenu span{display:inline-block;padding:0 7px}.jessibuca-container .jessibuca-contextmenus .jessibuca-contextmenu span.art-current,.jessibuca-container .jessibuca-contextmenus .jessibuca-contextmenu span:hover{color:var(--theme)}.jessibuca-container .jessibuca-contextmenus .jessibuca-contextmenu:hover{background-color:hsla(0,0%,100%,.1)}.jessibuca-container .jessibuca-contextmenus .jessibuca-contextmenu:last-child{border-bottom:none}.jessibuca-container.jessibuca-contextmenus-show .jessibuca-contextmenus{display:flex}.jessibuca-container-playback .jessibuca-controls{height:48px}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center{flex:1;display:flex;box-sizing:border-box;justify-content:space-between;font-size:12px}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-controls-playback-time{box-sizing:border-box;flex:1;position:relative;height:100%}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-controls-playback-time-inner{width:300px;height:100%;overflow-y:hidden;overflow-x:auto}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-controls-playback-current-time{position:absolute;left:0;top:0;height:15px;width:1px;background-color:red;text-align:center;z-index:1}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-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}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-controls-playback-time-scroll{position:relative;width:1440px;margin:0 auto}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-controls-playback-time-scroll.one-hour{width:1440px}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-controls-playback-time-scroll.half-hour{width:2880px}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-controls-playback-time-scroll.ten-min{width:8640px}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-controls-playback-time-scroll.five-min{width:17280px}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-controls-playback-time-scroll.one-min{width:86400px}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-controls-playback-time-list{position:relative;background-color:#ccc;height:48px}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-day{height:100%;overflow:hidden}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-one-wrap{height:8px;z-index:1}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-second-wrap{height:25px}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-controls-playback-btns{display:flex;align-items:center}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-minute-one,.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-second-one{float:left;width:1px;height:8px;margin:0;cursor:default;position:relative;z-index:1}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-minute-one.active,.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-second-one.active{background-color:orange;cursor:pointer}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-minute-one.start,.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-second-one.start{background-color:#999}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-minute-one:hover .jessibuca-playback-time-title-tips,.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-second-one:hover .jessibuca-playback-time-title-tips{visibility:visible;opacity:1}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-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}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-title-tips.jessibuca-playback-time-title-tips-left{transform:translateX(-100%)}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-title-tips .jessibuca-playback-time-title{display:inline-block;padding:2px 5px;font-size:12px;white-space:nowrap;color:#fff}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-hour,.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-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}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-hour:first-child,.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-minute:first-child{border-left:0}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-hour:first-child .jessibuca-playback-time-hour-text,.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-minute:first-child .jessibuca-playback-time-hour-text{left:0}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-hour:after,.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-minute:after{content:"";position:absolute;left:0;top:-8px;width:1px;height:14px;background-color:#999}.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-hour-text,.jessibuca-container-playback .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-center .jessibuca-playback-time-minute-text{position:absolute;left:-13px}.jessibuca-container-playback .jessibuca-playback-expand.disabled .jessibuca-icon-expand,.jessibuca-container-playback .jessibuca-playback-narrow.disabled .jessibuca-icon-narrow{cursor:no-drop}.jessibuca-container-playback.jessibuca-fullscreen-web .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-playback-time-inner{overflow-y:auto}.jessibuca-zoom-control{cursor:-webkit-grab;cursor:grab}.jessibuca-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}.jessibuca-performance-panel .jessibuca-performance-item{display:flex;align-items:center;margin-top:3px;color:#fff}.jessibuca-performance-panel .jessibuca-performance-item-block{height:10px}');class Xs{constructor(e){this.player=e,this.extendBtnList=[],h=this,(l=e)._opt.hasControl&&l._opt.controlAutoHide?l.$container.classList.add("jessibuca-controls-show-auto-hide"):l.$container.classList.add("jessibuca-controls-show"),c=l._opt,u=c.operateBtns,p=`\n <div class="jessibuca-controls-center">\n <div class="jessibuca-controls-playback-time">\n <div class="jessibuca-controls-playback-time-inner">\n <div class="jessibuca-controls-playback-time-scroll">\n <div class="jessibuca-controls-playback-time-list">\n <div class="jessibuca-playback-time-day">\n <div class="jessibuca-playback-time-one-wrap"></div>\n <div class="jessibuca-playback-time-second-wrap"></div>\n </div>\n </div>\n <div class="jessibuca-controls-playback-current-time">\n <div class="jessibuca-controls-playback-current-time-text">00:00:00</div>\n </div>\n </div>\n </div>\n </div>\n <div class="jessibuca-controls-playback-btns">\n <div class="jessibuca-controls-item jessibuca-playback-narrow">${Gs.narrow}</div>\n <div class="jessibuca-controls-item jessibuca-playback-expand">${Gs.expand}</div>\n </div>\n </div>\n `,l.$container.insertAdjacentHTML("beforeend",`\n ${c.background?`<div class="jessibuca-poster" style="background-image: url(${c.background})"></div>`:""}\n <div class="jessibuca-loading-bg">\n <img class="jessibuca-loading-bg-image" src="" alt="">\n </div>\n ${c.loadingIcon?`\n <div class="jessibuca-loading">\n ${Gs.loading}\n <div class="jessibuca-loading-text">${c.loadingText}</div>\n </div>\n `:""}\n ${c.hasControl&&u.play?'<div class="jessibuca-play-big"></div>':""}\n ${c.hasControl&&u.ptz?`\n <div class="jessibuca-ptz-controls">\n <div class="jessibuca-ptz-bg-active"></div>\n <div class="jessibuca-ptz-arrow jessibuca-ptz-arrow-up" data-arrow="up"></div>\n <div class="jessibuca-ptz-arrow jessibuca-ptz-arrow-right" data-arrow="right"></div>\n <div class="jessibuca-ptz-arrow jessibuca-ptz-arrow-down" data-arrow="down"></div>\n <div class="jessibuca-ptz-arrow jessibuca-ptz-arrow-left" data-arrow="left"></div>\n ${c.ptzMoreArrowShow?'\n <div class="jessibuca-ptz-arrow jessibuca-ptz-arrow-left-up" data-arrow="left-up"></div>\n <div class="jessibuca-ptz-arrow jessibuca-ptz-arrow-right-up" data-arrow="right-up"></div>\n <div class="jessibuca-ptz-arrow jessibuca-ptz-arrow-left-down" data-arrow="left-down"></div>\n <div class="jessibuca-ptz-arrow jessibuca-ptz-arrow-right-down" data-arrow="right-down"></div>\n ':""}\n <div class="jessibuca-ptz-control"></div>\n <div class="jessibuca-ptz-btns">\n ${c.ptzZoomShow?'\n <div class="jessibuca-ptz-btn">\n <div class="jessibuca-ptz-expand jessibuca-ptz-icon">\n <i class="jessibuca-ptz-expand-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">缩放+</span>\n </span>\n </div>\n <div class="jessibuca-ptz-narrow jessibuca-ptz-icon">\n <i class="jessibuca-ptz-narrow-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">缩放-</span>\n </span>\n </div>\n </div>\n ':""}\n ${c.ptzApertureShow?'\n <div class="jessibuca-ptz-btn">\n <div class="jessibuca-ptz-aperture-far jessibuca-ptz-icon">\n <i class="jessibuca-ptz-aperture-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">光圈+</span>\n </span>\n </div>\n <div class="jessibuca-ptz-aperture-near jessibuca-ptz-icon">\n <i class="jessibuca-ptz-aperture-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">光圈-</span>\n </span>\n </div>\n </div>\n ':""}\n ${c.ptzFocusShow?'\n <div class="jessibuca-ptz-btn">\n <div class="jessibuca-ptz-focus-far jessibuca-ptz-icon">\n <i class="jessibuca-ptz-focus-icon"></i>\n <span class="icon-title-tips">\n <span class="icon-title">聚焦+</span>\n </span>\n </div>\n <div class="jessibuca-ptz-focus-near jessibuca-ptz-icon">\n <i class="jessibuca-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\n </div>\n `:""}\n ${c.hasVideo?`\n <div class="jessibuca-zoom-controls">\n <div class="jessibuca-zoom-narrow">${Gs.narrow}</div>\n <div class="jessibuca-zoom-tips">电子放大</div>\n <div class="jessibuca-zoom-expand">${Gs.expand}</div>\n <div class="jessibuca-zoom-stop2">${Gs.zoomStop}</div>\n </div>\n <div class="jessibuca-recording">\n <div class="jessibuca-recording-red-point"></div>\n <div class="jessibuca-recording-time">00:00:00</div>\n <div class="jessibuca-icon-recordStop jessibuca-recording-stop">${Gs.recordStop}</div>\n </div>\n `:""}\n\n ${c.hasControl?`\n <div class="jessibuca-controls">\n <div class="jessibuca-controls-bottom">\n <div class="jessibuca-controls-left">\n ${c.showBandwidth?'<div class="jessibuca-controls-item jessibuca-speed"></div>':""}\n <div class="jessibuca-controls-item-html">${c.controlHtml}</div>\n </div>\n ${c.playType===d&&c.playbackConfig.showControl?p:""}\n\n <div class="jessibuca-controls-right">\n ${c.playType===d&&c.playbackConfig.showRateBtn?'\n <div class="jessibuca-controls-item-wrap">\n <div class="jessibuca-controls-item jessibuca-speed-menu">\n <div class="jessibuca-speed-icon-text"></div>\n <div class="jessibuca-speed-menu-list"></div>\n </div>\n </div>\n ':""}\n ${u.close?`<div class="jessibuca-controls-item-wrap"><div class="jessibuca-controls-item jessibuca-close">${Gs.close}</div></div>`:""}\n ${u.performance?`<div class="jessibuca-controls-item-wrap"><div class="jessibuca-controls-item jessibuca-performance">${Gs.performance}</div><div class="jessibuca-controls-item jessibuca-performance-active">${Gs.performanceActive}</div></div>`:""}\n ${u.aiFace?`<div class="jessibuca-controls-item-wrap"><div class="jessibuca-controls-item jessibuca-face">${Gs.face}</div><div class="jessibuca-controls-item jessibuca-face-active">${Gs.faceActive}</div></div>`:""}\n ${u.quality?'\n <div class="jessibuca-controls-item-wrap">\n <div class="jessibuca-controls-item jessibuca-quality-menu">\n <div class="jessibuca-quality-icon-text"></div>\n <div class="jessibuca-quality-menu-list"></div>\n </div>\n </div>\n ':""}\n ${u.scale?'\n <div class="jessibuca-controls-item-wrap">\n <div class="jessibuca-controls-item jessibuca-scale-menu">\n <div class="jessibuca-scale-icon-text"></div>\n <div class="jessibuca-scale-menu-list"></div>\n </div>\n </div>\n ':""}\n ${u.audio?`\n <div class="jessibuca-controls-item-wrap">\n <div class="jessibuca-controls-item jessibuca-volume">\n ${Gs.audio}\n ${Gs.mute}\n <div class="jessibuca-volume-panel-wrap">\n <div class="jessibuca-volume-panel">\n <div class="jessibuca-volume-panel-handle"></div>\n </div>\n <div class="jessibuca-volume-panel-text"></div>\n </div>\n </div>\n </div>\n `:""}\n ${u.play?`<div class="jessibuca-controls-item-wrap"><div class="jessibuca-controls-item jessibuca-play">${Gs.play}</div><div class="jessibuca-controls-item jessibuca-pause">${Gs.pause}</div></div>`:""}\n ${u.screenshot?`<div class="jessibuca-controls-item-wrap"><div class="jessibuca-controls-item jessibuca-screenshot">${Gs.screenshot}</div></div>`:""}\n ${u.record?` <div class="jessibuca-controls-item-wrap"><div class="jessibuca-controls-item jessibuca-record">${Gs.record}</div><div class="jessibuca-controls-item jessibuca-record-stop">${Gs.recordStop}</div></div>`:""}\n ${u.ptz?` <div class="jessibuca-controls-item-wrap"><div class="jessibuca-controls-item jessibuca-ptz">${Gs.ptz}</div><div class="jessibuca-controls-item jessibuca-ptz-active">${Gs.ptzActive}</div></div>`:""}\n ${u.zoom?` <div class="jessibuca-controls-item-wrap"><div class="jessibuca-controls-item jessibuca-zoom">${Gs.zoom}</div><div class="jessibuca-controls-item jessibuca-zoom-stop">${Gs.zoomStop}</div></div>`:""}\n ${u.fullscreen?`<div class="jessibuca-controls-item-wrap"><div class="jessibuca-controls-item jessibuca-fullscreen">${Gs.fullscreen}</div><div class="jessibuca-controls-item jessibuca-fullscreen-exit">${Gs.fullscreenExit}</div></div>`:""}\n </div>\n </div>\n </div>\n `:""}\n <div class="jessibuca-performance-panel"></div>\n <div class="jessibuca-contextmenus"></div>\n `),Object.defineProperty(h,"$poster",{value:l.$container.querySelector(".jessibuca-poster")}),Object.defineProperty(h,"$loadingBg",{value:l.$container.querySelector(".jessibuca-loading-bg")}),Object.defineProperty(h,"$loadingBgImage",{value:l.$container.querySelector(".jessibuca-loading-bg-image")}),Object.defineProperty(h,"$loading",{value:l.$container.querySelector(".jessibuca-loading")}),Object.defineProperty(h,"$loadingText",{value:l.$container.querySelector(".jessibuca-loading-text")}),Object.defineProperty(h,"$play",{value:l.$container.querySelector(".jessibuca-play")}),Object.defineProperty(h,"$playBig",{value:l.$container.querySelector(".jessibuca-play-big")}),Object.defineProperty(h,"$recording",{value:l.$container.querySelector(".jessibuca-recording")}),Object.defineProperty(h,"$recordingTime",{value:l.$container.querySelector(".jessibuca-recording-time")}),Object.defineProperty(h,"$recordingStop",{value:l.$container.querySelector(".jessibuca-recording-stop")}),Object.defineProperty(h,"$pause",{value:l.$container.querySelector(".jessibuca-pause")}),Object.defineProperty(h,"$controls",{value:l.$container.querySelector(".jessibuca-controls")}),Object.defineProperty(h,"$controlsInner",{value:l.$container.querySelector(".jessibuca-controls-bottom")}),Object.defineProperty(h,"$controlsLeft",{value:l.$container.querySelector(".jessibuca-controls-left")}),Object.defineProperty(h,"$controlsRight",{value:l.$container.querySelector(".jessibuca-controls-right")}),Object.defineProperty(h,"$volume",{value:l.$container.querySelector(".jessibuca-volume")}),Object.defineProperty(h,"$volumePanelWrap",{value:l.$container.querySelector(".jessibuca-volume-panel-wrap")}),Object.defineProperty(h,"$volumePanelText",{value:l.$container.querySelector(".jessibuca-volume-panel-text")}),Object.defineProperty(h,"$volumePanel",{value:l.$container.querySelector(".jessibuca-volume-panel")}),Object.defineProperty(h,"$volumeHandle",{value:l.$container.querySelector(".jessibuca-volume-panel-handle")}),Object.defineProperty(h,"$volumeOn",{value:l.$container.querySelector(".jessibuca-icon-audio")}),Object.defineProperty(h,"$volumeOff",{value:l.$container.querySelector(".jessibuca-icon-mute")}),Object.defineProperty(h,"$fullscreen",{value:l.$container.querySelector(".jessibuca-fullscreen")}),Object.defineProperty(h,"$fullscreenExit",{value:l.$container.querySelector(".jessibuca-fullscreen-exit")}),Object.defineProperty(h,"$record",{value:l.$container.querySelector(".jessibuca-record")}),Object.defineProperty(h,"$recordStop",{value:l.$container.querySelector(".jessibuca-record-stop")}),Object.defineProperty(h,"$screenshot",{value:l.$container.querySelector(".jessibuca-screenshot")}),Object.defineProperty(h,"$speed",{value:l.$container.querySelector(".jessibuca-speed")}),Object.defineProperty(h,"$controlHtml",{value:l.$container.querySelector(".jessibuca-controls-item-html")}),Object.defineProperty(h,"$playbackTime",{value:l.$container.querySelector(".jessibuca-controls-playback-time")}),Object.defineProperty(h,"$playbackTimeInner",{value:l.$container.querySelector(".jessibuca-controls-playback-time-inner")}),Object.defineProperty(h,"$playbackTimeScroll",{value:l.$container.querySelector(".jessibuca-controls-playback-time-scroll")}),Object.defineProperty(h,"$playbackTimeList",{value:l.$container.querySelector(".jessibuca-controls-playback-time-list")}),Object.defineProperty(h,"$playbackTimeListOne",{value:l.$container.querySelector(".jessibuca-playback-time-one-wrap")}),Object.defineProperty(h,"$playbackTimeListSecond",{value:l.$container.querySelector(".jessibuca-playback-time-second-wrap")}),Object.defineProperty(h,"$playbackCurrentTime",{value:l.$container.querySelector(".jessibuca-controls-playback-current-time")}),Object.defineProperty(h,"$playbackCurrentTimeText",{value:l.$container.querySelector(".jessibuca-controls-playback-current-time-text")}),Object.defineProperty(h,"$controlsPlaybackBtns",{value:l.$container.querySelector(".jessibuca-controls-playback-btns")}),Object.defineProperty(h,"$playbackNarrow",{value:l.$container.querySelector(".jessibuca-playback-narrow")}),Object.defineProperty(h,"$playbackExpand",{value:l.$container.querySelector(".jessibuca-playback-expand")}),Object.defineProperty(h,"$ptz",{value:l.$container.querySelector(".jessibuca-ptz")}),Object.defineProperty(h,"$ptzActive",{value:l.$container.querySelector(".jessibuca-ptz-active")}),Object.defineProperty(h,"$ptzControl",{value:l.$container.querySelector(".jessibuca-ptz-controls")}),Object.defineProperty(h,"$ptzBgActive",{value:l.$container.querySelector(".jessibuca-ptz-bg-active")}),Object.defineProperty(h,"$ptzControlCircular",{value:l.$container.querySelector(".jessibuca-ptz-control")}),Object.defineProperty(h,"$ptzArrows",{value:l.$container.querySelectorAll(".jessibuca-ptz-arrow")}),Object.defineProperty(h,"$ptzExpand",{value:l.$container.querySelector(".jessibuca-ptz-expand")}),Object.defineProperty(h,"$ptzNarrow",{value:l.$container.querySelector(".jessibuca-ptz-narrow")}),Object.defineProperty(h,"$ptzApertureFar",{value:l.$container.querySelector(".jessibuca-ptz-aperture-far")}),Object.defineProperty(h,"$ptzApertureNear",{value:l.$container.querySelector(".jessibuca-ptz-aperture-near")}),Object.defineProperty(h,"$ptzFocusFar",{value:l.$container.querySelector(".jessibuca-ptz-focus-far")}),Object.defineProperty(h,"$ptzFocusNear",{value:l.$container.querySelector(".jessibuca-ptz-focus-near")}),Object.defineProperty(h,"$qualityText",{value:l.$container.querySelector(".jessibuca-quality-icon-text")}),Object.defineProperty(h,"$qualityMenu",{value:l.$container.querySelector(".jessibuca-quality-menu")}),Object.defineProperty(h,"$qualityMenuList",{value:l.$container.querySelector(".jessibuca-quality-menu-list")}),Object.defineProperty(h,"$scaleText",{value:l.$container.querySelector(".jessibuca-scale-icon-text")}),Object.defineProperty(h,"$scaleMenu",{value:l.$container.querySelector(".jessibuca-scale-menu")}),Object.defineProperty(h,"$scaleMenuList",{value:l.$container.querySelector(".jessibuca-scale-menu-list")}),Object.defineProperty(h,"$zoom",{value:l.$container.querySelector(".jessibuca-zoom")}),Object.defineProperty(h,"$zoomStop",{value:l.$container.querySelector(".jessibuca-zoom-stop")}),Object.defineProperty(h,"$zoomNarrow",{value:l.$container.querySelector(".jessibuca-zoom-narrow")}),Object.defineProperty(h,"$zoomExpand",{value:l.$container.querySelector(".jessibuca-zoom-expand")}),Object.defineProperty(h,"$zoomStop2",{value:l.$container.querySelector(".jessibuca-zoom-stop2")}),Object.defineProperty(h,"$close",{value:l.$container.querySelector(".jessibuca-close")}),Object.defineProperty(h,"$zoomControls",{value:l.$container.querySelector(".jessibuca-zoom-controls")}),Object.defineProperty(h,"$performancePanel",{value:l.$container.querySelector(".jessibuca-performance-panel")}),Object.defineProperty(h,"$performance",{value:l.$container.querySelector(".jessibuca-performance")}),Object.defineProperty(h,"$performanceActive",{value:l.$container.querySelector(".jessibuca-performance-active")}),Object.defineProperty(h,"$faceDetect",{value:l.$container.querySelector(".jessibuca-face")}),Object.defineProperty(h,"$faceDetectActive",{value:l.$container.querySelector(".jessibuca-face-active")}),Object.defineProperty(h,"$contextmenus",{value:l.$container.querySelector(".jessibuca-contextmenus")}),Object.defineProperty(h,"$speedText",{value:l.$container.querySelector(".jessibuca-speed-icon-text")}),Object.defineProperty(h,"$speedMenu",{value:l.$container.querySelector(".jessibuca-speed-menu")}),Object.defineProperty(h,"$speedMenuList",{value:l.$container.querySelector(".jessibuca-speed-menu-list")}),0<e._opt.extendOperateBtns.length&&e._opt.extendOperateBtns.forEach(e=>{this.addExtendBtn(e)}),o=this,Object.defineProperty(o,"controlsRect",{get:()=>o.$controls.getBoundingClientRect()}),Object.defineProperty(o,"controlsInnerRect",{get:()=>o.$controlsInner.getBoundingClientRect()}),Object.defineProperty(o,"controlsLeftRect",{get:()=>o.$controlsLeft.getBoundingClientRect()}),Object.defineProperty(o,"controlsRightRect",{get:()=>o.$controlsRight.getBoundingClientRect()}),Object.defineProperty(o,"controlsPlaybackTimeInner",{get:()=>o.$playbackTimeInner&&o.$playbackTimeInner.getBoundingClientRect()||{}}),Object.defineProperty(o,"controlsPlaybackBtnsRect",{get:()=>o.$controlsPlaybackBtns&&o.$controlsPlaybackBtns.getBoundingClientRect()||{width:0}}),Ks(e,this);{var t=e,i=this;const s=t["events"]["proxy"],a=t._opt,n=a.operateBtns;function r(e){var{bottom:t,height:r}=i.$volumePanel.getBoundingClientRect(),s=i.$volumeHandle.getBoundingClientRect()["height"];return Je(t-e.y-s/2,0,r-s/2)/(r-s)}if(s(window,["click","contextmenu"],e=>{-1<e.composedPath().indexOf(t.$container)?i.isFocus=!0:i.isFocus=!1}),s(window,"orientationchange",()=>{setTimeout(()=>{t.resize()},300)}),s(i.$controls,"click",e=>{e.stopPropagation()}),n.play&&(s(i.$pause,"click",e=>{a.playType===d&&a.playbackConfig.uiUsePlaybackPause?t.playbackPause=!0:Pt(n.pauseFn)?n.pauseFn():t.pauseForControl()}),s(i.$play,"click",e=>{a.playType===d&&t.playbackPause?t.playbackPause=!1:Pt(n.playFn)?n.playFn():t.playForControl().then(()=>{t.resumeAudioAfterPause()})})),s(i.$playBig,"click",e=>{a.playType===d&&t.playbackPause?t.playbackPause=!1:Pt(n.playFn)?n.playFn():t.playForControl().then(()=>{t.resumeAudioAfterPause()})}),n.screenshot&&s(i.$screenshot,"click",e=>{e.stopPropagation(),Pt(n.screenshotFn)?n.screenshotFn():t.video.screenshot()}),n.audio&&(s(i.$volume,"mouseover",()=>{i.$volumePanelWrap.classList.add("jessibuca-volume-panel-wrap-show")}),s(i.$volume,"mouseout",()=>{i.$volumePanelWrap.classList.remove("jessibuca-volume-panel-wrap-show")}),s(i.$volumeOn,"click",e=>{e.stopPropagation(),Qe(i.$volumeOn,"display","none"),Qe(i.$volumeOff,"display","block"),e=t.volume,t.volume=0,t._lastVolume=e}),s(i.$volumeOff,"click",e=>{e.stopPropagation(),Qe(i.$volumeOn,"display","block"),Qe(i.$volumeOff,"display","none"),t.volume=t.lastVolume||.5}),s(i.$volumePanel,"click",e=>{e.stopPropagation(),t.volume=r(e)}),s(i.$volumeHandle,"mousedown",()=>{i.isVolumeDroging=!0}),s(i.$volumeHandle,"mousemove",e=>{i.isVolumeDroging&&(t.volume=r(e))}),s(document,"mouseup",()=>{i.isVolumeDroging&&(i.isVolumeDroging=!1)})),n.record&&(s(i.$record,"click",e=>{e.stopPropagation(),Pt(n.recordFn)?n.recordFn():t.recording=!0}),s(i.$recordStop,"click",e=>{e.stopPropagation(),Pt(n.recordStopFn)?n.recordStopFn():t.recording=!1})),s(i.$recordingStop,"click",e=>{e.stopPropagation(),Pt(n.recordStopFn)?n.recordStopFn():t.recording=!1}),n.fullscreen&&(s(i.$fullscreen,"click",e=>{e.stopPropagation(),Pt(n.fullscreenFn)?n.fullscreenFn():t.fullscreen=!0}),s(i.$fullscreenExit,"click",e=>{e.stopPropagation(),Pt(n.fullscreenExitFn)?n.fullscreenExitFn():t.fullscreen=!1})),n.ptz){if(s(i.$ptz,"click",e=>{e.stopPropagation(),Qe(i.$ptzActive,"display","flex"),Qe(i.$ptz,"display","none"),i.$ptzControl.classList.add("jessibuca-ptz-controls-show")}),s(i.$ptzActive,"click",e=>{e.stopPropagation(),Qe(i.$ptz,"display","flex"),Qe(i.$ptzActive,"display","none"),i.$ptzControl.classList.remove("jessibuca-ptz-controls-show")}),i.$ptzArrows.forEach(e=>{if(a.ptzClickType===w)s(e,"click",e=>{e.stopPropagation(),e=e.currentTarget.dataset.arrow,i.$ptzBgActive.classList.add("jessibuca-ptz-bg-active-show"),i.$ptzBgActive.classList.add("jessibuca-ptz-bg-active-"+e),i.$ptzControlCircular.classList.add("jessibuca-ptz-control-"+e),t.emit(U.ptz,Yt(e)),setTimeout(()=>{i.$ptzBgActive.classList.remove("jessibuca-ptz-bg-active-show"),oe.forEach(e=>{i.$ptzBgActive.classList.remove("jessibuca-ptz-bg-active-"+e),i.$ptzControlCircular.classList.remove("jessibuca-ptz-control-"+e)}),t.emit(U.ptz,le)},1e3*a.ptzStopEmitDelay)});else if(a.ptzClickType===S){let r=!1;s(e,"mousedown",e=>{e.stopPropagation(),r=!0,e=e.currentTarget.dataset.arrow,i.$ptzBgActive.classList.add("jessibuca-ptz-bg-active-show"),i.$ptzBgActive.classList.add("jessibuca-ptz-bg-active-"+e),i.$ptzControlCircular.classList.add("jessibuca-ptz-control-"+e),t.emit(U.ptz,Yt(e))});const a=()=>{r=!1,i.$ptzBgActive.classList.remove("jessibuca-ptz-bg-active-show"),oe.forEach(e=>{i.$ptzBgActive.classList.remove("jessibuca-ptz-bg-active-"+e),i.$ptzControlCircular.classList.remove("jessibuca-ptz-control-"+e)}),t.emit(U.ptz,le)};s(e,"mouseup",e=>{e.stopPropagation(),r&&a()}),s(window,"mouseup",e=>{e.stopPropagation(),r&&a()})}}),a.ptzZoomShow)if(a.ptzClickType===w)s(i.$ptzExpand,"click",e=>{e.stopPropagation(),t.emit(U.ptz,he),setTimeout(()=>{t.emit(U.ptz,le)},1e3*a.ptzStopEmitDelay)}),s(i.$ptzNarrow,"click",e=>{e.stopPropagation(),t.emit(U.ptz,ce),setTimeout(()=>{t.emit(U.ptz,le)},1e3*a.ptzStopEmitDelay)});else if(a.ptzClickType===S){let e=!1,r=!1;s(i.$ptzExpand,"mousedown",i=>{i.stopPropagation(),e=!0,t.emit(U.ptz,he)}),s(i.$ptzNarrow,"mousedown",e=>{e.stopPropagation(),r=!0,t.emit(U.ptz,ce)});const a=()=>{e=!1,r=!1,t.emit(U.ptz,le)};s(i.$ptzExpand,"mouseup",t=>{t.stopPropagation(),e&&a()}),s(i.$ptzNarrow,"mouseup",e=>{e.stopPropagation(),r&&a()}),s(window,"mouseup",t=>{t.stopPropagation(),(e||r)&&a()})}if(a.ptzApertureShow)if(a.ptzClickType===w)s(i.$ptzApertureFar,"click",e=>{e.stopPropagation(),t.emit(U.ptz,ue),setTimeout(()=>{t.emit(U.ptz,de)},1e3*a.ptzStopEmitDelay)}),s(i.$ptzApertureNear,"click",e=>{e.stopPropagation(),t.emit(U.ptz,pe),setTimeout(()=>{t.emit(U.ptz,de)},1e3*a.ptzStopEmitDelay)});else if(a.ptzClickType===S){let e=!1,r=!1;s(i.$ptzApertureFar,"mousedown",i=>{i.stopPropagation(),e=!0,t.emit(U.ptz,ue)}),s(i.$ptzApertureNear,"mousedown",e=>{e.stopPropagation(),r=!0,t.emit(U.ptz,pe)});const a=()=>{e=!1,r=!1,t.emit(U.ptz,de)};s(i.$ptzApertureFar,"mouseup",t=>{t.stopPropagation(),e&&a()}),s(i.$ptzApertureNear,"mouseup",e=>{e.stopPropagation(),r&&a()}),s(window,"mouseup",t=>{t.stopPropagation(),(e||r)&&a()})}if(a.ptzFocusShow)if(a.ptzClickType===w)s(i.$ptzFocusFar,"click",e=>{e.stopPropagation(),t.emit(U.ptz,fe),setTimeout(()=>{t.emit(U.ptz,de)},1e3*a.ptzStopEmitDelay)}),s(i.$ptzFocusNear,"click",e=>{e.stopPropagation(),t.emit(U.ptz,me),setTimeout(()=>{t.emit(U.ptz,de)},1e3*a.ptzStopEmitDelay)});else if(a.ptzClickType===S){let e=!1,r=!1;s(i.$ptzFocusFar,"mousedown",i=>{i.stopPropagation(),e=!0,t.emit(U.ptz,fe)}),s(i.$ptzFocusNear,"mousedown",e=>{e.stopPropagation(),r=!0,t.emit(U.ptz,me)});const a=()=>{e=!1,r=!1,t.emit(U.ptz,de)};s(i.$ptzFocusFar,"mouseup",t=>{t.stopPropagation(),e&&a()}),s(i.$ptzFocusNear,"mouseup",e=>{e.stopPropagation(),r&&a()}),s(window,"mouseup",t=>{t.stopPropagation(),(e||r)&&a()})}}if(n.performance&&(s(i.$performance,"click",e=>{e.stopPropagation(),t.togglePerformancePanel(!0)}),s(i.$performanceActive,"click",e=>{e.stopPropagation(),t.togglePerformancePanel(!1)})),n.aiFace&&(s(i.$faceDetect,"click",e=>{e.stopPropagation(),t.faceDetect(!0)}),s(i.$faceDetectActive,"click",e=>{e.stopPropagation(),t.faceDetect(!1)})),t._opt.hasControl&&t._opt.controlAutoHide){s(t.$container,"mouseover",()=>{t.fullscreen||(Qe(i.$controls,"display","block"),r())}),s(t.$container,"mousemove",()=>{t.$container&&i.$controls&&(t.fullscreen,"none"===i.$controls.style.display&&(Qe(i.$controls,"display","block"),r()))}),s(t.$container,"mouseout",()=>{a(),Qe(i.$controls,"display","none")});let e=null;const r=()=>{a(),e=setTimeout(()=>{Qe(i.$controls,"display","none")},5e3)},a=()=>{e&&(clearTimeout(e),e=null)}}t._opt.playType===d&&(s(i.$playbackNarrow,"click",e=>{e.stopPropagation(),t.playback&&t.playback.narrowPrecision()}),s(i.$playbackExpand,"click",e=>{e.stopPropagation(),t.playback&&t.playback.expandPrecision()}),s(i.$playbackTimeList,"click",e=>{const i=It(e);i.matches("div.jessibuca-playback-time-minute-one")&&t.playback&&t.playback.seek(i.dataset)}),t._opt.playbackConfig.showRateBtn&&(s(i.$speedMenu,"mouseover",()=>{i.$speedMenuList.classList.add("jessibuca-speed-menu-shown")}),s(i.$speedMenu,"mouseout",()=>{i.$speedMenuList.classList.remove("jessibuca-speed-menu-shown")}),s(i.$speedMenuList,"click",e=>{const i=It(e);if(i.matches("div.jessibuca-speed-menu-item")){const e=i.dataset;t.emit(U.playbackPreRateChange,e.speed)}})),t._opt.playbackConfig.supportWheel&&s(i.$playbackTimeInner,"wheel",e=>{e.preventDefault(),0<(e.wheelDelta?e.wheelDelta/120:-(e.detail||0)/3)?t.playback&&t.playback.expandPrecision():t.playback&&t.playback.narrowPrecision()})),n.quality&&(s(i.$qualityMenu,"mouseover",()=>{i.$qualityMenuList.classList.add("jessibuca-quality-menu-shown")}),s(i.$qualityMenu,"mouseout",()=>{i.$qualityMenuList.classList.remove("jessibuca-quality-menu-shown")}),s(i.$qualityMenuList,"click",e=>{const i=It(e);if(i.matches("div.jessibuca-quality-menu-item")){const e=i.dataset;t.streamQuality=e.quality}})),n.scale&&(s(i.$scaleMenu,"mouseover",()=>{i.$scaleMenuList.classList.add("jessibuca-scale-menu-shown")}),s(i.$scaleMenu,"mouseout",()=>{i.$scaleMenuList.classList.remove("jessibuca-scale-menu-shown")}),s(i.$scaleMenuList,"click",e=>{const i=It(e);if(i.matches("div.jessibuca-scale-menu-item")){const e=i.dataset;t.setScaleMode(e.scale)}})),n.zoom&&(s(i.$zoom,"click",e=>{e.stopPropagation(),t.zooming=!0}),s(i.$zoomStop,"click",e=>{e.stopPropagation(),t.zooming=!1})),s(i.$zoomExpand,"click",e=>{e.stopPropagation(),t.zoom&&t.zoom.expandPrecision()}),s(i.$zoomNarrow,"click",e=>{e.stopPropagation(),t.zoom&&t.zoom.narrowPrecision()}),s(i.$zoomStop2,"click",e=>{e.stopPropagation(),t.zooming=!1}),n.close&&s(i.$close,"click",e=>{e.stopPropagation(),t.doDestroy()})}if(e._opt.hotKey){var s=e,a=this;const t=s["events"]["proxy"],i={};function n(e,t){i[e]?i[e].push(t):i[e]=[t]}n(27,()=>{s.fullscreen&&(s.fullscreen=!1)}),n(38,()=>{s.volume+=.05}),n(40,()=>{s.volume-=.05}),t(window,"keydown",e=>{if(a.isFocus){const t=document.activeElement.tagName.toUpperCase(),r=document.activeElement.getAttribute("contenteditable");if("INPUT"!==t&&"TEXTAREA"!==t&&""!==r&&"true"!==r){const t=i[e.keyCode];t&&(e.preventDefault(),t.forEach(e=>e()))}}})}var o,l,h,c,u,p;this.btnIndex=0,this.kbpsShow="0 KB/s",this.player.debug.log("Control","init")}destroy(){var e;this.$performancePanel&&(this.$performancePanel.innerHTML="",Qs(this.$performancePanel)||(e=this.player.$container.querySelector(".jessibuca-performance-panel"))&&this.player.$container&&this.player.$container.removeChild(e)),this.$poster&&!Qs(this.$poster)&&(e=this.player.$container.querySelector(".jessibuca-poster"))&&this.player.$container&&this.player.$container.removeChild(e),this.$loading&&!Qs(this.$loading)&&(e=this.player.$container.querySelector(".jessibuca-loading"))&&this.player.$container&&this.player.$container.removeChild(e),this.$loadingBg&&!Qs(this.$loadingBg)&&(e=this.player.$container.querySelector(".jessibuca-loading-bg"))&&this.player.$container&&this.player.$container.removeChild(e),this.$controls&&!Qs(this.$controls)&&(e=this.player.$container.querySelector(".jessibuca-controls"))&&this.player.$container&&this.player.$container.removeChild(e),this.$playBig&&!Qs(this.$playBig)&&(e=this.player.$container.querySelector(".jessibuca-play-big"))&&this.player.$container&&this.player.$container.removeChild(e),this.$recording&&!Qs(this.$recording)&&(e=this.player.$container.querySelector(".jessibuca-recording"))&&this.player.$container&&this.player.$container.removeChild(e),this.$ptzControl&&!Qs(this.$ptzControl)&&(e=this.player.$container.querySelector(".jessibuca-ptz-controls"))&&this.player.$container&&this.player.$container.removeChild(e),this.$zoomControls&&!Qs(this.$zoomControls)&&(e=this.player.$container.querySelector(".jessibuca-zoom-controls"))&&this.player.$container&&this.player.$container.removeChild(e),this.$contextmenus&&(this.$contextmenus.innerHTML="",Qs(this.$contextmenus)||(e=this.player.$container.querySelector(".jessibuca-contextmenus"))&&this.player.$container&&this.player.$container.removeChild(e)),this.btnIndex=0,this.extendBtnList=[],this.kbpsShow="0 KB/s",this.player.$container&&(this.player.$container.classList.remove("jessibuca-controls-show-auto-hide"),this.player.$container.classList.remove("jessibuca-controls-show")),this.player.debug.log("control","destroy")}getBtnIndex(){return this.btnIndex++}autoSize(){const e=this.player,t=(e.$container.style.padding="0 0",e.width),i=e.height,r=t/i,s=e.video.$videoElement.width/e.video.$videoElement.height;if(r>s){const r=(t-i*s)/2;e.$container.style.padding=`0 ${r}px`}else{const r=(i-t/s)/2;e.$container.style.padding=r+"px 0"}}initLoadingBackground(){var e=this.player;if(e._opt.loadingBackground&&(e._opt.heartTimeoutReplayUseLastFrameShow||e._opt.replayUseLastFrameShow||e._opt.pauseAndNextPlayUseLastFrameShow)){let r=e.height;var t=e._opt,i=(t.hasControl&&!t.controlAutoHide&&(r-=t.playType===d?48:38),this.$loadingBgImage.width=e.width,this.$loadingBgImage.height=r,t.rotate);270!==i&&90!==i||(control.$loadingBgImage.width=r,control.$loadingBgImage.height=e.width),this.$loadingBgImage.src=e._opt.loadingBackground;let s="contain",a=(t.isResize||(s="fill"),t.isFullResize&&(s="none"),"");"none"===t.mirrorRotate&&i&&(a+=" rotate("+i+"deg)"),"level"===t.mirrorRotate?a+=" rotateY(180deg)":"vertical"===t.mirrorRotate&&(a+=" rotateX(180deg)"),this.$loadingBgImage.style.transform=a,this.$loadingBgImage.style.objectFit=s,qs(this.$loadingBg,"display","block")}}_validateExtendBtn(e){let t=!0;return 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),t&&!e.icon&&(this.player.debug.warn("Control","extend button icon is required"),t=!1),t}addExtendBtn(){let e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};var t=Gt(Ce);if(e=Object.assign({},t,e),this._validateExtendBtn(e)){const t=e.name||"",i=this.$controlsRight,r=e.activeIcon&&e.activeClick,s=`\n <div class="jessibuca-controls-item-wrap">\n ${e.icon?`<div class="jessibuca-controls-item jessibuca-control-extend-${t}">\n <i class="jessibuca-icon jessibuca-icon-extend-${t}"></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="jessibuca-controls-item jessibuca-control-extend-${t}-active">\n <i class="jessibuca-icon jessibuca-icon-extend-${t}-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 `,a=Array.from(i.children)[e.index],n=(a?a.insertAdjacentHTML("beforebegin",s):Ys(i,s),e.icon?i.querySelector(".jessibuca-icon-extend-"+t):null),o=e.icon?i.querySelector(".jessibuca-control-extend-"+t):null,l=e.activeIcon?i.querySelector(`.jessibuca-icon-extend-${t}-active`):null,d=e.activeIcon?i.querySelector(`.jessibuca-control-extend-${t}-active`):null,{proxy:h}=this.player["events"];e.icon&&(qs(n,"background",`url(${e.icon}) no-repeat center`),qs(n,"background-size","100% 100%"),qs(o,"display","none"),e.iconHover&&(h(n,"mouseover",()=>{qs(n,"background",`url(${e.iconHover}) no-repeat center`),qs(n,"background-size","100% 100%")}),h(n,"mouseout",()=>{qs(n,"background",`url(${e.icon}) no-repeat center`),qs(n,"background-size","100% 100%")}))),e.activeIcon&&(qs(l,"background",`url(${e.activeIcon}) no-repeat center`),qs(l,"background-size","100% 100%"),qs(d,"display","none"),e.activeIconHover&&(h(l,"mouseover",()=>{qs(l,"background",`url(${e.activeIconHover}) no-repeat center`),qs(l,"background-size","100% 100%")}),h(l,"mouseout",()=>{qs(l,"background",`url(${e.activeIcon}) no-repeat center`),qs(l,"background-size","100% 100%")}))),e.click&&n&&h(n,"click",t=>{t.preventDefault(),r&&(qs(o,"display","none"),qs(d,"display","flex")),e.click.call(this.player,this,t)}),e.activeClick&&l&&h(l,"click",t=>{t.preventDefault(),qs(o,"display","flex"),qs(d,"display","none"),e.activeClick.call(this.player,this,t)}),this.extendBtnList.push({name:t,$iconWrap:o,$activeIconWrap:d})}}updateLoadingText(e){this.$loadingText&&(this.$loadingText.innerText=e)}}$s(".jessibuca-container{position:relative;width:100%;height:100%;overflow:hidden}.jessibuca-container.jessibuca-fullscreen-web{position:fixed;z-index:9999;left:0;top:0;right:0;bottom:0;width:100vw!important;height:100vh!important;background:#000}");class Zs{static init(){for(var e in Zs.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:[]},Zs.types)Zs.types.hasOwnProperty(e)&&(Zs.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let t=Zs.constants={};t.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),t.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),t.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),t.STSC=t.STCO=t.STTS,t.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),t.HDLR_VIDEO=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),t.HDLR_AUDIO=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),t.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),t.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),t.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}static box(e){let t=8,i=null,r=Array.prototype.slice.call(arguments,1),s=r.length;for(let n=0;n<s;n++)t+=r[n].byteLength;(i=new Uint8Array(t))[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 n=0;n<s;n++)i.set(r[n],a),a+=r[n].byteLength;return i}static generateInitSegment(e){let t=Zs.box(Zs.types.ftyp,Zs.constants.FTYP),i=Zs.moov(e),r=new Uint8Array(t.byteLength+i.byteLength);return r.set(t,0),r.set(i,t.byteLength),r}static moov(e){var t=Zs.mvhd(e.timescale,e.duration),i=Zs.trak(e);e=Zs.mvex(e);return Zs.box(Zs.types.moov,t,i,e)}static mvhd(e,t){return Zs.box(Zs.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 Zs.box(Zs.types.trak,Zs.tkhd(e),Zs.mdia(e))}static tkhd(e){var t=e.id,i=e.duration,r=e.presentWidth;e=e.presentHeight;return Zs.box(Zs.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>>8&255,255&r,0,0,e>>>8&255,255&e,0,0]))}static mdia(e){return Zs.box(Zs.types.mdia,Zs.mdhd(e),Zs.hdlr(e),Zs.minf(e))}static mdhd(e){var t=e.timescale;e=e.duration;return Zs.box(Zs.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,e>>>24&255,e>>>16&255,e>>>8&255,255&e,85,196,0,0]))}static hdlr(e){return e="audio"===e.type?Zs.constants.HDLR_AUDIO:Zs.constants.HDLR_VIDEO,Zs.box(Zs.types.hdlr,e)}static minf(e){var t="audio"===e.type?Zs.box(Zs.types.smhd,Zs.constants.SMHD):Zs.box(Zs.types.vmhd,Zs.constants.VMHD);return Zs.box(Zs.types.minf,t,Zs.dinf(),Zs.stbl(e))}static dinf(){return Zs.box(Zs.types.dinf,Zs.box(Zs.types.dref,Zs.constants.DREF))}static stbl(e){return Zs.box(Zs.types.stbl,Zs.stsd(e),Zs.box(Zs.types.stts,Zs.constants.STTS),Zs.box(Zs.types.stsc,Zs.constants.STSC),Zs.box(Zs.types.stsz,Zs.constants.STSZ),Zs.box(Zs.types.stco,Zs.constants.STCO))}static stsd(e){return"audio"===e.type?Zs.box(Zs.types.stsd,Zs.constants.STSD_PREFIX,Zs.mp4a(e)):"avc"===e.videoType?Zs.box(Zs.types.stsd,Zs.constants.STSD_PREFIX,Zs.avc1(e)):Zs.box(Zs.types.stsd,Zs.constants.STSD_PREFIX,Zs.hvc1(e))}static mp4a(e){var t=e.channelCount,i=e.audioSampleRate;t=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,i>>>8&255,255&i,0,0]);return Zs.box(Zs.types.mp4a,t,Zs.esds(e))}static esds(e){e=e.config||[];var t=e.length;t=new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e).concat([6,1,2]));return Zs.box(Zs.types.esds,t)}static avc1(e){var t=e.avcc,i=e.codecWidth;e=e.codecHeight,i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,i>>>8&255,255&i,e>>>8&255,255&e,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return Zs.box(Zs.types.avc1,i,Zs.box(Zs.types.avcC,t))}static hvc1(e){var t=e.avcc,i=e.codecWidth;e=e.codecHeight,i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,i>>>8&255,255&i,e>>>8&255,255&e,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return Zs.box(Zs.types.hvc1,i,Zs.box(Zs.types.hvcC,t))}static mvex(e){return Zs.box(Zs.types.mvex,Zs.trex(e))}static trex(e){return e=e.id,e=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]),Zs.box(Zs.types.trex,e)}static moof(e,t){return Zs.box(Zs.types.moof,Zs.mfhd(e.sequenceNumber),Zs.traf(e,t))}static mfhd(e){return e=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e]),Zs.box(Zs.types.mfhd,e)}static traf(e,t){var i=e.id,r=(i=Zs.box(Zs.types.tfhd,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),t=Zs.box(Zs.types.tfdt,new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t])),Zs.sdtp(e));e=Zs.trun(e,r.byteLength+16+16+8+16+8+8);return Zs.box(Zs.types.traf,i,t,e,r)}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,Zs.box(Zs.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);t=e.duration;var r=e.size,s=e.flags;e=e.cts;return i.set([t>>>24&255,t>>>16&255,t>>>8&255,255&t,r>>>24&255,r>>>16&255,r>>>8&255,255&r,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.isNonSync,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e],12),Zs.box(Zs.types.trun,i)}static mdat(e){return Zs.box(Zs.types.mdat,e)}}Zs.init();class ea extends r{constructor(e){super(),this.player=e,this.isAvc=!0,this.mediaSource=new window.MediaSource,this.sourceBuffer=null,this.hasInit=!1,this.isInitInfo=!1,this.cacheTrack={},this.timeInit=!1,this.sequenceNumber=0,this.dropping=!1,this.firstRenderTime=null,this.$videoElement=null,this.mediaSourceAppendBufferFull=!1,this.mediaSourceAppendBufferError=!1,this.mediaSourceAddSourceBufferError=!1,this.mediaSourceError=!1,this.isDecodeFirstIIframe=!!$t(e._opt.checkFirstIFrame),this.prevTimestamp=null,this.decodeDiffTimestamp=null,this.prevDts=null,this.prevPayloadBufferSize=0,this.isWidthOrHeightChanged=!1,this.prevTs=null,this.mediaSourceObjectURL=window.URL.createObjectURL(this.mediaSource),this.eventListenList=[],this.tempFmp4List=[],e._opt.mseUseCanvasRender?(this.$videoElement=document.createElement("video"),this.$videoElement.src=this.mediaSourceObjectURL,this.initVideoEvents()):(this.player.video.$videoElement.src=this.mediaSourceObjectURL,this.$videoElement=this.player.video.$videoElement),this._bindMediaSourceEvents(),e.debug.log("MediaSource","init")}destroy(){this.stop(),this.eventListenList.length&&(this.eventListenList.forEach(e=>e()),this.eventListenList=[]),this.tempFmp4List=[],this.mediaSource=null,this.sourceBuffer=null,this.hasInit=!1,this.isInitInfo=!1,this.sequenceNumber=0,this.cacheTrack={},this.timeInit=!1,this.mediaSourceAppendBufferFull=!1,this.mediaSourceAppendBufferError=!1,this.mediaSourceAddSourceBufferError=!1,this.mediaSourceError=!1,this.isDecodeFirstIIframe=!1,this.prevTimestamp=null,this.prevDts=null,this.prevPayloadBufferSize=0,this.prevTs=null,this.firstRenderTime=null,this.isWidthOrHeightChanged=!1,this.dropping=!1,this.$videoElement&&(this.player._opt.mseUseCanvasRender&&this.$videoElement.src&&(this.$videoElement.src="",this.$videoElement.removeAttribute("src")),this.$videoElement=null),this.mediaSourceObjectURL&&(window.URL.revokeObjectURL(this.mediaSourceObjectURL),this.mediaSourceObjectURL=null),this.off(),this.player.debug.log("MediaSource","destroy")}get state(){return this.mediaSource&&this.mediaSource.readyState}get isStateOpen(){return"open"===this.state}get isStateClosed(){return"closed"===this.state}get isStateEnded(){return"ended"===this.state}get duration(){return this.mediaSource&&this.mediaSource.duration||-1}set duration(e){this.mediaSource.duration=e}_bindMediaSourceEvents(){const{proxy:e}=this.player["events"],t=e(this.mediaSource,"sourceopen",()=>{this.player&&this.player.emit(U.mseSourceOpen)}),i=e(this.mediaSource,"sourceclose",()=>{this.player&&this.player.emit(U.mseSourceClose)}),r=e(this.mediaSource,"sourceended",()=>{this.player&&this.player.emit(U.mseSourceended)});if(this.eventListenList.push(t,i,r),this.player.isPlayer){const t=e(this.$videoElement,_e,e=>{this._handleUpdatePlaybackRate(),!this.player._opt.mseUseCanvasRender||this.player.checkIsInRender()?this.player.handleRender():(e=parseInt(e.timeStamp,10),this.player.debug.warn("MediaSource",`mseUseCanvasRender is true and $videoElement ts is ${e}, but not in render`))}),i=e(this.$videoElement,we,()=>{this.player.debug.log("MediaSource","video playback Rate change",this.$videoElement&&this.$videoElement.playbackRate)});this.eventListenList.push(t,i)}}initVideoEvents(){const e=this.player.events["proxy"],t=e(this.$videoElement,be,()=>{this.player.debug.log("MediaSource","video canplay"),this.$videoElement.play().then(()=>{this.player.debug.log("MediaSource","video play")}).catch(e=>{this.player.debug.error("MediaSource","video play error ",e),this.player.emitError(O.mediaSourceUseCanvasRenderPlayFailed,e)})}),i=e(this.$videoElement,ve,()=>{this.player.debug.log("MediaSource","video waiting")}),r=e(this.$videoElement,_e,e=>{e=parseInt(e.timeStamp,10),this.player.emit(U.videoTimeUpdate,e),this.$videoElement.paused&&(this.player.debug.warn("MediaSource","video is paused and next try to replay"),this.$videoElement.play().then(()=>{this.player.debug.log("MediaSource","video is paused and replay success")}).catch(e=>{this.player.debug.warn("MediaSource","video is paused and replay error ",e)}))});this.eventListenList.push(t,i,r)}decodeVideo(e,t,i,r){const s=this.player;if(s)if(this.player.isDestroyed())this.player.debug.warn("MediaSource","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={};7==t?i=Vi(e.slice(5)):12==t&&(i=Xi(e));const r=this.player.video.videoInfo;r&&r.width&&r.height&&i&&i.codecWidth&&i.codecHeight&&(i.codecWidth!==r.width||i.codecHeight!==r.height)&&(this.player.debug.warn("MediaSource",`\n decodeVideo: video width or height is changed,\n old width is ${r.width}, old height is ${r.height},\n new width is ${i.codecWidth}, new height is ${i.codecHeight},\n and emit change event`),this.isWidthOrHeightChanged=!0,this.player.emitError(O.mseWidthOrHeightChange))}if(this.isWidthOrHeightChanged)this.player.debug.warn("MediaSource","decodeVideo: video width or height is changed, and return");else if(Vt(e))this.player.debug.warn("MediaSource","decodeVideo and payload is video sequence header so drop this frame");else if(e.byteLength<12)this.player.debug.warn("MediaSource","decodeVideo and payload is too small , payload length is "+e.byteLength);else{null===this.firstRenderTime&&(this.firstRenderTime=t);let s=t-this.firstRenderTime;if(s<0&&(this.player.debug.warn("MediaSource",`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),s=null===this.prevDts?0:this.prevDts+this.player._opt.mseCorrectTimeDuration,this._checkTsIsMaxDiff(t)))return this.player.debug.warn("MediaSource",`decodeVideo is max diff , ts is ${t} and prevTs is ${this.prevTs}, diff is `+(this.prevTs-t)),void this.emit(O.mediaSourceTsIsMaxDiff);if(null!==this.prevDts&&s<=this.prevDts){if(this.player.debug.warn("MediaSource",`\n decodeVideo dts is less than(or equal) prev dts ,\n dts is ${s} 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},\n and mseCorrectTimeDuration is ${this.player._opt.mseCorrectTimeDuration},\n and prevPayloadBufferSize is ${this.prevPayloadBufferSize} and payload size is `+e.byteLength),s===this.prevDts&&this.prevPayloadBufferSize===e.byteLength)return void this.player.debug.warn("MediaSource","decodeVideo dts is equal to prev dts and payload size is equal to prev payload size so drop this frame");if(s=this.prevDts+this.player._opt.mseCorrectTimeDuration,this._checkTsIsMaxDiff(t))return this.player.debug.warn("MediaSource",`decodeVideo is max diff , ts is ${t} and prevTs is ${this.prevTs}, diff is ${this.prevTs-t} and emit replay`),void this.emit(O.mediaSourceTsIsMaxDiff)}this._decodeVideo(e,s,i,r,t),this.prevDts=s,this.prevPayloadBufferSize=e.byteLength,this.prevTs=t,this.player.getRenderType()===b&&this.player.video&&this.player.video.doAddContentToWatermark()}}else this.player.debug.warn("MediaSource","decodeVideo isDecodeFirstIIframe false");else if(i&&0===e[1]){const r=15&e[0];s.video.updateVideoInfo({encTypeCode:r}),12!=r||mt()?(s._times.decodeStart||(s._times.decodeStart=qe()),this.hasInit=this._decodeConfigurationRecord(e,t,i,r)):this.emit(O.mediaSourceH265NotSupport)}else this.player.debug.warn("MediaSource",`decodeVideo has not init , isIframe is ${i} , payload is `+e[1])}_checkTsIsMaxDiff(e){return 0<this.prevTs&&e<this.prevTs&&36e5<this.prevTs-e}_decodeConfigurationRecord(e,t,i,r){let s=e.slice(5),a={};return 7===r?a=Vi(s):12===r&&(a=Xi(e)),this.player.recorder&&this.player._opt.recordType===h&&this.player.recorder.initMetaData(e,r),0===a.codecWidth&&0===a.codecHeight?(this.player.debug.warn("MediaSource","_decodeConfigurationRecord",a),this.emit(O.mediaSourceDecoderConfigurationError),!1):(e={id:1,type:"video",timescale:1e3,duration:0,avcc:s,codecWidth:a.codecWidth,codecHeight:a.codecHeight,videoType:a.videoType},e=Zs.generateInitSegment(e),this.isAvc=7===r,this.appendBuffer(e.buffer),this.sequenceNumber=0,this.cacheTrack={},!(this.timeInit=!1))}_decodeVideo(e,t,i,r,s){const a=this.player;let n=e.slice(5),o=n.byteLength,l=(new Date).getTime(),d=!1;this.prevTimestamp||(this.prevTimestamp=l,d=!0),e=l-this.prevTimestamp,((this.decodeDiffTimestamp=e)<5||500<e)&&!d&&a.debug.warn("MediaSource",`_decodeVideo now time is ${l} and prev time is ${this.prevTimestamp}, diff time is ${e} ms`);const c=this.$videoElement,u=a._opt.videoBufferDelay+a._opt.videoBuffer;if(1<c.buffered.length&&(this.removeBuffer(c.buffered.start(0),c.buffered.end(0)),this.timeInit=!1),this.dropping&&this.cacheTrack.id&&t-this.cacheTrack.dts>u)a.debug.warn("MediaSource","dropping time is ",t-this.cacheTrack.dts),this.dropping=!1,this.cacheTrack={};else if(this.cacheTrack.id&&t>=this.cacheTrack.dts){let e=8+this.cacheTrack.size,i=new Uint8Array(e),r=(i[0]=e>>>24&255,i[1]=e>>>16&255,i[2]=e>>>8&255,i[3]=255&e,i.set(Zs.types.mdat,4),i.set(this.cacheTrack.data,8),this.cacheTrack.duration=t-this.cacheTrack.dts,this.player.recorder&&this.player.recorder.isRecording&&this.player._opt.recordType===h&&this.player.recorder.handleAddFmp4Track(this.cacheTrack),Zs.moof(this.cacheTrack,this.cacheTrack.dts)),n=new Uint8Array(r.byteLength+i.byteLength);n.set(r,0),n.set(i,r.byteLength),this.appendBuffer(n.buffer),a.emit(U.timeUpdate,s),a.videoTimestamp=s,a.updateStats({fps:!0,ts:s,mseTs:t,buf:a.demux&&a.demux.delay||0}),a._times.videoStart||(a._times.videoStart=qe(),a.handlePlayToRenderTimes())}else a.debug.log("MediaSource",`timeInit set false , cacheTrack = {} now dts is ${t}, and ts is ${s} cacheTrack dts is `+(this.cacheTrack&&this.cacheTrack.dts)),this.timeInit=!1,this.cacheTrack={};this.cacheTrack||(this.cacheTrack={}),this.cacheTrack.id=1,this.cacheTrack.sequenceNumber=++this.sequenceNumber,this.cacheTrack.size=o,this.cacheTrack.dts=t,this.cacheTrack.cts=r,this.cacheTrack.isKeyframe=i,this.cacheTrack.data=n,this.cacheTrack.flags={isLeading:0,dependsOn:i?2:1,isDependedOn:i?1:0,hasRedundancy:0,isNonSync:i?0:1},this.timeInit||1!==c.buffered.length||(a.debug.log("MediaSource","timeInit set true"),this.timeInit=!0,c.currentTime=c.buffered.end(0)),!this.isInitInfo&&0<c.videoWidth&&0<c.videoHeight&&(a.debug.log("MediaSource",`updateVideoInfo: ${c.videoWidth},`+c.videoHeight),a.video.updateVideoInfo({width:c.videoWidth,height:c.videoHeight}),a.video.initCanvasViewSize(),this.isInitInfo=!0),a._opt.mseUseCanvasRender&&a.video.render({$video:c,ts:t}),this.prevTimestamp=(new Date).getTime()}appendBuffer(e){const{debug:t,events:{proxy:i}}=this.player;if(this.mediaSourceAddSourceBufferError)t.warn("MediaSource","this.mediaSourceAddSourceBufferError is true");else{if(null===this.sourceBuffer){var r=this.isAvc?ee:te;try{this.sourceBuffer=this.mediaSource.addSourceBuffer(r)}catch(e){return t.error("MediaSource","this.mediaSource.addSourceBuffer()",e.code,e),this.player.emitError(O.mseAddSourceBufferError,e),void(this.mediaSourceAddSourceBufferError=!0)}if(this.sourceBuffer){const e=i(this.sourceBuffer,"error",e=>{this.player.emitError(O.mseSourceBufferError,e)}),t=i(this.sourceBuffer,"updateend",()=>{});this.eventListenList.push(e,t)}}if(this.mediaSourceAppendBufferFull)t.warn("MediaSource","this.mediaSourceAppendBufferFull is true");else if(this.mediaSourceAppendBufferError)t.warn("MediaSource","this.mediaSourceAppendBufferError is true");else if(!1===this.sourceBuffer.updating&&this.isStateOpen)try{let i=e;if(0<this.tempFmp4List.length){t.log("MediaSource",`this.tempFmp4List.length = ${this.tempFmp4List.length} and merge buffer`);let r=0;this.tempFmp4List.push(e);for(let e=0;e<this.tempFmp4List.length;e++)r+=this.tempFmp4List[e].byteLength;const s=new Uint8Array(r);let a=0;for(let e=0;e<this.tempFmp4List.length;e++)s.set(this.tempFmp4List[e],a),a+=this.tempFmp4List[e].byteLength;i=s,this.tempFmp4List=[]}this.sourceBuffer.appendBuffer(i)}catch(e){t.error("MediaSource","this.sourceBuffer.appendBuffer()",e.code,e),22===e.code?(this.stop(),this.mediaSourceAppendBufferFull=!0,this.emit(O.mediaSourceFull)):11===e.code?(this.stop(),this.mediaSourceAppendBufferError=!0,this.emit(O.mediaSourceAppendBufferError)):(t.error("MediaSource","appendBuffer error",e),this.player.emitError(U.mseSourceBufferError,e))}else this.isStateClosed?this.player.emitError(O.mseSourceBufferError,"mediaSource is not attached to video or mediaSource is closed"):this.isStateEnded?this.player.emitError(O.mseSourceBufferError,"mediaSource is end"):Kt(this.sourceBuffer.updating)&&(t.warn("MediaSource","mseSourceBufferBusy"),this.player.emit(U.mseSourceBufferBusy),this.tempFmp4List.push(e))}}getSourceBufferUpdating(){return this.sourceBuffer&&this.sourceBuffer.updating}stop(){this.abortSourceBuffer(),this.endOfStream(),this.removeSourceBuffer()}dropSourceBuffer(e){const t=this.$videoElement;this.dropping=e,0<t.buffered.length&&1<t.buffered.end(0)-t.currentTime&&(this.player.debug.warn("MediaSource","dropSourceBuffer",`$video.buffered.end(0) is ${t.buffered.end(0)} - $video.currentTime `+t.currentTime),t.currentTime=t.buffered.end(0))}checkSourceBufferDelay(){const e=this.$videoElement;let t=0;return(t=0<e.buffered.length?e.buffered.end(e.buffered.length-1)-e.currentTime:t)<0&&(this.player.debug.warn("MediaSource",`checkSourceBufferDelay end(0) is ${e.buffered.end(0)} - currentTime is ${e.currentTime} and result < 0 and result is `+t),t=0),t}getDecodeDiffTimes(){return this.decodeDiffTimestamp}removeBuffer(e,t){if(this.isStateOpen&&!1===this.sourceBuffer.updating)try{this.sourceBuffer.remove(e,t)}catch(e){this.player.debug.warn("MediaSource","removeBuffer() error",e)}else this.player.debug.warn("MediaSource","removeBuffer() this.isStateOpen is",this.isStateOpen,"this.sourceBuffer.updating",this.sourceBuffer.updating)}endOfStream(){if(this.isStateOpen&&this.$videoElement&&1<=this.$videoElement.readyState)try{this.mediaSource.endOfStream()}catch(r){this.player.debug.warn("MediaSource","endOfStream() error",r)}}abortSourceBuffer(){this.isStateOpen&&this.sourceBuffer&&(this.sourceBuffer.abort(),this.sourceBuffer=null)}removeSourceBuffer(){if(!this.isStateClosed&&this.mediaSource&&this.sourceBuffer)try{this.mediaSource.removeSourceBuffer(this.sourceBuffer)}catch(r){this.player.debug.warn("MediaSource","removeSourceBuffer() error",r)}}_handleUpdatePlaybackRate(){if(this.$videoElement){const r=this.$videoElement;var e=(this.player._opt.videoBuffer+this.player._opt.videoBufferDelay)/1e3;const s=r.buffered;s.length&&s.start(0);var t=s.length?s.end(s.length-1):0;let a=r.currentTime;var i=t-a;e=Math.max(5,3+e),e=(e<i?(this.player.debug.warn("MediaSource",`handleUpdatePlaybackRate and buffered is ${t} and current is ${a} , delay buffer is more than ${e} is ${i} and new time is `+t),r.currentTime=t,a=r.currentTime):i<0&&(this.player.debug.warn("MediaSource",`handleUpdatePlaybackRate and delay buffer is ${t} - current is ${a} = ${i} < 0 and check video is paused : ${r.paused} `),r.paused&&r.play()),this._getPlaybackRate(t-a));r.playbackRate!==e&&(this.player.debug.warn("MediaSource",`handleUpdatePlaybackRate and buffered is ${t} and current time is ${a} and delay is ${t-a} set playbackRate is ${e} `),r.playbackRate=e)}}getDecodePlaybackRate(){let e=0;var t=this.$videoElement;return t?t.playbackRate:e}_getPlaybackRate(e){var t=this.$videoElement,i=this.player._opt.videoBuffer,r=i+this.player._opt.videoBufferDelay;return e*=1e3,1===t.playbackRate?r<e?1.2:1:e<=i?1:t.playbackRate}}const ta=()=>"wakeLock"in navigator&&-1===window.navigator.userAgent.indexOf("Samsung")&&$t(nt());class ia{constructor(e){this.player=e,this.enabled=!1,ta()?(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&&4<this.noSleepVideo.currentTime&&(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(r){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 r=document.createElement("source");r.src=i,r.type="video/"+t,e.appendChild(r)}get isEnabled(){return this.enabled}enable(){const e=this.player.debug;return ta()?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}):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(){ta()?(this._wakeLock&&this._wakeLock.release(),this._wakeLock=null):this.noSleepVideo&&this.noSleepVideo.pause(),this.enabled=!1,this.player.debug.log("wakeLock","Disabling wake lock.")}}var ra=Oe(Ne((function(e,t){"undefined"!=typeof window&&(e.exports=(()=>{var e={"./src/config.ts":(e,t,i)=>{i.r(t),i.d(t,{enableStreamingMode:()=>function(e){var t=e.loader;t!==f.default&&t!==p.default?(y.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):(0,f.fetchSupported)()&&(e.loader=f.default,e.progressive=!0,e.enableSoftwareAES=!0,y.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))},hlsDefaultConfig:()=>_,mergeConfig:()=>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"');return A({},e,t)}});t=i("./src/controller/abr-controller.ts");var r=i("./src/controller/audio-stream-controller.ts"),s=i("./src/controller/audio-track-controller.ts"),a=i("./src/controller/subtitle-stream-controller.ts"),n=i("./src/controller/subtitle-track-controller.ts"),o=i("./src/controller/buffer-controller.ts"),l=i("./src/controller/timeline-controller.ts"),d=i("./src/controller/cap-level-controller.ts"),h=i("./src/controller/fps-controller.ts"),c=i("./src/controller/eme-controller.ts"),u=i("./src/controller/cmcd-controller.ts"),p=i("./src/utils/xhr-loader.ts"),f=i("./src/utils/fetch-loader.ts"),m=i("./src/utils/cues.ts"),g=i("./src/utils/mediakeys-helper.ts"),y=i("./src/utils/logger.ts");function A(){return(A=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i,r=arguments[t];for(i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e}).apply(this,arguments)}function b(e,t){var i,r=Object.keys(e);return Object.getOwnPropertySymbols&&(i=Object.getOwnPropertySymbols(e),t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)),r}function v(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?b(Object(i),!0).forEach((function(t){var r,s;r=e,t=i[s=t],(s=function(){var e=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);if(t=t.call(e,"string"),"object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(s);return"symbol"==typeof e?e:String(e)}())in r?Object.defineProperty(r,s,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[s]=t})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):b(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}var _=v(v({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength: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,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:p.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:t.default,bufferController:o.default,capLevelController:d.default,fpsController:h.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:g.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},{cueHandler:m.default,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:a.SubtitleStreamController,subtitleTrackController:n.default,timelineController:l.TimelineController,audioStreamController:r.default,audioTrackController:s.default,emeController:c.default,cmcdController:u.default})},"./src/controller/abr-controller.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>c});var r=i("./src/polyfills/number.ts"),s=i("./src/utils/ewma-bandwidth-estimator.ts"),a=i("./src/events.ts"),n=i("./src/errors.ts"),o=i("./src/types/loader.ts"),l=i("./src/utils/logger.ts");function d(e,t){for(var i,r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,"symbol"==typeof(i=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);if(t=t.call(e,"string"),"object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(s.key))?i:String(i),s)}}function h(e){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,e=(this.hls=e).config,this.bwEstimator=new s.default(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate),this.registerListeners()}(t=h.prototype).registerListeners=function(){var e=this.hls;e.on(a.Events.FRAG_LOADING,this.onFragLoading,this),e.on(a.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(a.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(a.Events.ERROR,this.onError,this)},t.unregisterListeners=function(){var e=this.hls;e.off(a.Events.FRAG_LOADING,this.onFragLoading,this),e.off(a.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(a.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(a.Events.ERROR,this.onError,this)},t.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},t.onFragLoading=function(e,t){var i=t.frag;i.type!==o.PlaylistLevelType.MAIN||this.timer||(this.fragCurrent=i,this.partCurrent=null!=(i=t.part)?i:null,this.timer=self.setInterval(this.onCheck,100))},t.onLevelLoaded=function(e,t){var i=this.hls.config;t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)},t._abandonRulesCheck=function(){var e=this.fragCurrent,t=this.partCurrent,i=this.hls,s=i.autoLevelEnabled,n=i.media;if(e&&n){var o=(t||e).stats,d=(t||e).duration;if(o.aborted||o.loaded&&o.loaded===o.total||0===e.level)return this.clearTimer(),void(this._nextAutoLevel=-1);if(s&&!n.paused&&n.playbackRate&&n.readyState&&(s=i.mainForwardBufferInfo,null!==s)){var h=performance.now()-o.loading.start;n=Math.abs(n.playbackRate);if(!(h<=500*d/n)){var c=o.loaded&&o.loading.first,u=this.bwEstimator.getEstimate(),p=i.levels,f=i.minAutoLevel,m=p[e.level],g=(m=o.total||Math.max(o.loaded,Math.round(d*m.maxBitrate/8)),c?1e3*o.loaded/h:0),y=(m=g?(m-o.loaded)/g:8*m/u,s.len/n);if(!(m<=y)){for(var A=Number.POSITIVE_INFINITY,b=e.level-1;f<b;b--){var v=p[b].maxBitrate;if((A=g?d*v/(6.4*g):d*v/u)<y)break}m<=A||(l.logger.warn("Fragment "+e.sn+(t?" part "+t.index:"")+" of level "+e.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+b+"\n Current BW estimate: "+((0,r.isFiniteNumber)(u)?(u/1024).toFixed(3):"Unknown")+" Kb/s\n Estimated load time for current fragment: "+m.toFixed(3)+" s\n Estimated load time for the next fragment: "+A.toFixed(3)+" s\n Time to underbuffer: "+y.toFixed(3)+" s"),i.nextLoadLevel=b,c&&this.bwEstimator.sample(h,o.loaded),this.clearTimer(),(e.loader||e.keyLoader)&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),i.trigger(a.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:o}))}}}}},t.onFragLoaded=function(e,t){var i,s,n,l,d=t.frag;t=t.part;d.type===o.PlaylistLevelType.MAIN&&(0,r.isFiniteNumber)(d.sn)&&(i=(t||d).stats,n=(t||d).duration,this.clearTimer(),this.lastLoadedFragLevel=d.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate&&(s=((l=this.hls.levels[d.level]).loaded?l.loaded.bytes:0)+i.loaded,n=(l.loaded?l.loaded.duration:0)+n,l.loaded={bytes:s,duration:n},l.realBitrate=Math.round(8*s/n)),d.bitrateTest&&(l={stats:i,frag:d,part:t,id:d.type},this.onFragBuffered(a.Events.FRAG_BUFFERED,l)))},t.onFragBuffered=function(e,t){var i,r=t.frag;t=t.part,t=(t||r).stats;t.aborted||r.type!==o.PlaylistLevelType.MAIN||"initSegment"===r.sn||(i=t.parsing.end-t.loading.start,this.bwEstimator.sample(i,t.loaded),t.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0)},t.onError=function(e,t){var i;if((null==(i=t.frag)?void 0:i.type)===o.PlaylistLevelType.MAIN)if(t.type===n.ErrorTypes.KEY_SYSTEM_ERROR)this.clearTimer();else switch(t.details){case n.ErrorDetails.FRAG_LOAD_ERROR:case n.ErrorDetails.FRAG_LOAD_TIMEOUT:case n.ErrorDetails.KEY_LOAD_ERROR:case n.ErrorDetails.KEY_LOAD_TIMEOUT:this.clearTimer()}},t.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},t.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,i=this.hls,r=i.maxAutoLevel,s=i.config,a=i.minAutoLevel,n=i.media;t=t?t.duration:e?e.duration:0,e=n&&0!==n.playbackRate?Math.abs(n.playbackRate):1,n=this.bwEstimator?this.bwEstimator.getEstimate():s.abrEwmaDefaultEstimate,i=i.mainForwardBufferInfo,i=(i?i.len:0)/e,e=this.findBestLevel(n,a,r,i,s.abrBandWidthFactor,s.abrBandWidthUpFactor);if(0<=e)return e;l.logger.trace((i?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var o,d=t?Math.min(t,s.maxStarvationDelay):s.maxStarvationDelay,h=s.abrBandWidthFactor,c=s.abrBandWidthUpFactor;return i||(o=this.bitrateTestDelay)&&(d=(t?Math.min(t,s.maxLoadingDelay):s.maxLoadingDelay)-o,l.logger.trace("bitrate test took "+Math.round(1e3*o)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*d)+" ms"),h=c=1),e=this.findBestLevel(n,a,r,i+d,h,c),Math.max(e,0)},t.findBestLevel=function(e,t,i,s,a,n){for(var o,d=this.fragCurrent,h=this.partCurrent,c=this.lastLoadedFragLevel,u=this.hls.levels,p=u[c],f=!(null==p||null==(o=p.details)||!o.live),m=null==p?void 0:p.codecSet,g=h?h.duration:d?d.duration:0,y=i;t<=y;y--){var A=u[y];if(A&&(!m||A.codecSet===m)){A=A.details,A=(h?null==A?void 0:A.partTarget:null==A?void 0:A.averagetargetduration)||g;var b,v=u[y].maxBitrate,_=v*A/(b=y<=c?a*e:n*e);if(l.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+y+"/"+Math.round(b)+"/"+v+"/"+A+"/"+s+"/"+_),v<b&&(0==_||!(0,r.isFiniteNumber)(_)||f&&!this.bitrateTestDelay||_<s))return y}}return-1},d((t=h).prototype,[{key:"nextAutoLevel",get:function(){var e=this._nextAutoLevel,t=this.bwEstimator;return-1===e||t.canEstimate()?(t=this.getNextABRAutoLevel(),-1!==e&&this.hls.levels[t].loadError?e:t=-1!==e?Math.min(e,t):t):e},set:function(e){this._nextAutoLevel=e}}]),Object.defineProperty(t,"prototype",{writable:!1});const c=h},"./src/controller/audio-stream-controller.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>_});var r,s=i("./src/polyfills/number.ts"),a=i("./src/controller/base-stream-controller.ts"),n=i("./src/events.ts"),o=i("./src/utils/buffer-helper.ts"),l=i("./src/controller/fragment-tracker.ts"),d=i("./src/types/level.ts"),h=i("./src/types/loader.ts"),c=i("./src/loader/fragment.ts"),u=i("./src/demux/chunk-cache.ts"),p=i("./src/demux/transmuxer-interface.ts"),f=i("./src/types/transmuxer.ts"),m=i("./src/controller/fragment-finders.ts"),g=i("./src/utils/discontinuities.ts"),y=i("./src/errors.ts");function A(){return(A=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i,r=arguments[t];for(i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e}).apply(this,arguments)}function b(e,t){return(b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function v(e,t,i){return(e=r.call(this,e,t,i,"[audio-stream-controller]")||this).videoBuffer=null,e.videoTrackCC=-1,e.waitingVideoCC=-1,e.audioSwitch=!1,e.trackId=-1,e.waitingData=null,e.mainDetails=null,e.bufferFlushed=!1,e.cachedTrackLoadedData=null,e._registerListeners(),e}r=a.default,t=r,(i=v).prototype=Object.create(t.prototype),b(i.prototype.constructor=i,t),(i=v.prototype).onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var e=this.hls;e.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(n.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(n.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(n.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(n.Events.ERROR,this.onError,this),e.on(n.Events.BUFFER_RESET,this.onBufferReset,this),e.on(n.Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(n.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(n.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(n.Events.FRAG_BUFFERED,this.onFragBuffered,this)},i._unregisterListeners=function(){var e=this.hls;e.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(n.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(n.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(n.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(n.Events.ERROR,this.onError,this),e.off(n.Events.BUFFER_RESET,this.onBufferReset,this),e.off(n.Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(n.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(n.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(n.Events.FRAG_BUFFERED,this.onFragBuffered,this)},i.onInitPtsFound=function(e,t){var i=t.frag,r=t.id;t=t.initPTS;"main"===r&&(r=i.cc,this.initPTS[i.cc]=t,this.log("InitPTS for cc: "+r+" found from main: "+t),this.videoTrackCC=r,this.state===a.State.WAITING_INIT_PTS&&this.tick())},i.startLoad=function(e){if(!this.levels)return this.startPosition=e,void(this.state=a.State.STOPPED);var t=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),(this.fragLoadError=0)<t&&-1===e?(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t,this.state=a.State.IDLE):(this.loadedmetadata=!1,this.state=a.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()},i.doTick=function(){switch(this.state){case a.State.IDLE:this.doTickIdle();break;case a.State.WAITING_TRACK:var e=this.levels,t=this.trackId;t=null==e||null==(e=e[t])?void 0:e.details;if(t){if(this.waitForCdnTuneIn(t))break;this.state=a.State.WAITING_INIT_PTS}break;case a.State.FRAG_LOADING_WAITING_RETRY:e=performance.now(),t=this.retryDate,(!t||t<=e||null!=(t=this.media)&&t.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=a.State.IDLE);break;case a.State.WAITING_INIT_PTS:var i,s;e=this.waitingData;e?(t=e.frag,i=e.part,s=e.cache,e=e.complete,void 0!==this.initPTS[t.cc]?(this.waitingData=null,this.waitingVideoCC=-1,this.state=a.State.FRAG_LOADING,i={frag:t,part:i,payload:s.flush(),networkDetails:null},this._handleFragmentLoadProgress(i),e&&r.prototype._handleFragmentLoadComplete.call(this,i)):this.videoTrackCC!==this.waitingVideoCC?(this.log("Waiting fragment cc ("+t.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment()):(s=this.getLoadPosition(),e=o.BufferHelper.bufferInfo(this.mediaBuffer,s,this.config.maxBufferHole),(0,m.fragmentWithinToleranceTest)(e.end,this.config.maxFragLookUpTolerance,t)<0&&(this.log("Waiting fragment cc ("+t.cc+") @ "+t.start+" cancelled because another fragment at "+e.end+" is needed"),this.clearWaitingFragment()))):this.state=a.State.IDLE}this.onTickEnd()},i.clearWaitingFragment=function(){var e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=a.State.IDLE)},i.resetLoadingState=function(){this.clearWaitingFragment(),r.prototype.resetLoadingState.call(this)},i.onTickEnd=function(){var e=this.media;e&&e.readyState&&(this.lastCurrentTime=e.currentTime)},i.doTickIdle=function(){var e=this.hls,t=this.levels,i=this.media,r=this.trackId,s=e.config;if(t&&t[r]&&(i||!this.startFragRequested&&s.startFragPrefetch))if(s=t[r].details,!s||s.live&&this.levelLastLoaded!==r||this.waitForCdnTuneIn(s))this.state=a.State.WAITING_TRACK;else if(t=this.mediaBuffer||this.media,this.bufferFlushed&&t&&(this.bufferFlushed=!1,this.afterBufferFlushed(t,c.ElementaryStreamTypes.AUDIO,h.PlaylistLevelType.AUDIO)),r=this.getFwdBufferInfo(t,h.PlaylistLevelType.AUDIO),null!==r){if(t=this.audioSwitch,!t&&this._streamEnded(r,s))return e.trigger(n.Events.BUFFER_EOS,{type:"audio"}),void(this.state=a.State.ENDED);var o,l;e=this.getFwdBufferInfo(this.videoBuffer||this.media,h.PlaylistLevelType.MAIN);r.len>=this.getMaxBufferLength(null==e?void 0:e.len)&&!t||(o=s.fragments[0].start,l=r.end,t&&i&&(l=t=this.getLoadPosition(),s.PTSKnown&&t<o&&(r.end>o||r.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=o+.05)),e&&l>e.end+s.targetduration||!(e&&e.len||!r.len)||((t=this.getNextFragment(l,s))?this.loadFragment(t,s,l):this.bufferFlushed=!0))}},i.getMaxBufferLength=function(e){var t=r.prototype.getMaxBufferLength.call(this);return e?Math.max(t,e):t},i.onMediaDetaching=function(){this.videoBuffer=null,r.prototype.onMediaDetaching.call(this)},i.onAudioTracksUpdated=function(e,t){t=t.audioTracks,this.resetTransmuxer(),this.levels=t.map((function(e){return new d.Level(e)}))},i.onAudioTrackSwitching=function(e,t){var i=!!t.url;this.trackId=t.id,t=this.fragCurrent;t&&t.abortRequests(),this.fragCurrent=null,this.clearWaitingFragment(),i?this.setInterval(100):this.resetTransmuxer(),i?(this.audioSwitch=!0,this.state=a.State.IDLE):this.state=a.State.STOPPED,this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},i.onLevelLoaded=function(e,t){this.mainDetails=t.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(n.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},i.onAudioTrackLoaded=function(e,t){if(null!=this.mainDetails){var i=this.levels,r=t.details,s=t.id;if(i){this.log("Track "+s+" loaded ["+r.startSN+","+r.endSN+"],duration:"+r.totalduration);i=i[s];var n=0;if(r.live||null!=(o=i.details)&&o.live){var o=this.mainDetails;if(r.fragments[0]||(r.deltaUpdateFailed=!0),r.deltaUpdateFailed||!o)return;n=!i.details&&r.hasProgramDateTime&&o.hasProgramDateTime?((0,g.alignMediaPlaylistByPDT)(r,o),r.fragments[0].start):this.alignPlaylists(r,i.details)}i.details=r,this.levelLastLoaded=s,this.startFragRequested||!this.mainDetails&&r.live||this.setStartPosition(i.details,n),this.state!==a.State.WAITING_TRACK||this.waitForCdnTuneIn(r)||(this.state=a.State.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+s)}else this.cachedTrackLoadedData=t},i._handleFragmentLoadProgress=function(e){var t,i,r,s,n=e.frag,o=e.part,l=(e=e.payload,this.config),d=this.trackId,c=this.levels;c?(c=c[d],console.assert(c,"Audio track is defined on fragment load progress"),t=c.details,console.assert(t,"Audio track details are defined on fragment load progress"),l=l.defaultAudioCodec||c.audioCodec||"mp4a.40.2",c=(c=this.transmuxer)||(this.transmuxer=new p.default(this.hls,h.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this))),i=this.initPTS[n.cc],r=null==(r=n.initSegment)?void 0:r.data,void 0!==i?(s=o?o.index:-1,s=new f.ChunkMetadata(n.level,n.sn,n.stats.chunkCount,e.byteLength,s,-1!==s),c.push(e,r,l,"",n,o,t.totalduration,!1,s,i)):(this.log("Unknown video PTS for cc "+n.cc+", waiting for video PTS before demuxing audio frag "+n.sn+" of ["+t.startSN+" ,"+t.endSN+"],track "+d),(this.waitingData=this.waitingData||{frag:n,part:o,cache:new u.default,complete:!1}).cache.push(new Uint8Array(e)),this.waitingVideoCC=this.videoTrackCC,this.state=a.State.WAITING_INIT_PTS)):this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+n.sn+" of level "+n.level+" will not be buffered")},i._handleFragmentLoadComplete=function(e){this.waitingData?this.waitingData.complete=!0:r.prototype._handleFragmentLoadComplete.call(this,e)},i.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},i.onBufferCreated=function(e,t){var i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)},i.onFragBuffered=function(e,t){var i=t.frag;t=t.part;i.type===h.PlaylistLevelType.AUDIO?this.fragContextChanged(i)?this.warn("Fragment "+i.sn+(t?" p: "+t.index:"")+" of level "+i.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):("initSegment"!==i.sn&&(this.fragPrevious=i,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(n.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(i,t)):this.loadedmetadata||i.type!==h.PlaylistLevelType.MAIN||null!=(t=this.videoBuffer||this.media)&&t.buffered.length&&(this.loadedmetadata=!0)},i.onError=function(e,t){if(t.type!==y.ErrorTypes.KEY_SYSTEM_ERROR)switch(t.details){case y.ErrorDetails.FRAG_LOAD_ERROR:case y.ErrorDetails.FRAG_LOAD_TIMEOUT:case y.ErrorDetails.FRAG_PARSING_ERROR:case y.ErrorDetails.KEY_LOAD_ERROR:case y.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(h.PlaylistLevelType.AUDIO,t);break;case y.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case y.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==a.State.ERROR&&this.state!==a.State.STOPPED&&(this.state=t.fatal?a.State.ERROR:a.State.IDLE,this.warn(t.details+" while loading frag, switching to "+this.state+" state"));break;case y.ErrorDetails.BUFFER_FULL_ERROR:var i,s;"audio"!==t.parent||this.state!==a.State.PARSING&&this.state!==a.State.PARSED||(i=!0,(i=(s=this.getFwdBufferInfo(this.mediaBuffer,h.PlaylistLevelType.AUDIO))&&.5<s.len?!this.reduceMaxBufferLength(s.len):i)&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,r.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState())}else this.onFragmentOrKeyLoadError(h.PlaylistLevelType.AUDIO,t)},i.onBufferFlushed=function(e,t){t.type===c.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0,this.state===a.State.ENDED&&(this.state=a.State.IDLE))},i._handleTransmuxComplete=function(e){var t=this.hls,i=e.remuxResult,r=(e=e.chunkMeta,this.getCurrentContext(e));if(!r)return this.warn("The loading context changed while buffering fragment "+e.sn+" of level "+e.level+". This chunk will not be buffered."),void this.resetStartWhenNotLoaded(e.level);var s,o,l,d=r.frag,h=r.part,u=(r=r.level.details,i.audio),p=i.text,f=i.id3;i=i.initSegment;!this.fragContextChanged(d)&&r&&(this.state=a.State.PARSING,this.audioSwitch&&u&&this.completeAudioSwitch(),null!=i&&i.tracks&&(this._bufferInitSegment(i.tracks,d,e),t.trigger(n.Events.FRAG_PARSING_INIT_SEGMENT,{frag:d,id:"audio",tracks:i.tracks})),u&&(i=u.startPTS,o=u.endPTS,l=u.startDTS,s=u.endDTS,h&&(h.elementaryStreams[c.ElementaryStreamTypes.AUDIO]={startPTS:i,endPTS:o,startDTS:l,endDTS:s}),d.setElementaryStreamInfo(c.ElementaryStreamTypes.AUDIO,i,o,l,s),this.bufferFragmentData(u,d,h,e)),null!=f&&null!=(i=f.samples)&&i.length&&(o=A({id:"audio",frag:d,details:r},f),t.trigger(n.Events.FRAG_PARSING_METADATA,o)),p&&(l=A({id:"audio",frag:d,details:r},p),t.trigger(n.Events.FRAG_PARSING_USERDATA,l)))},i._bufferInitSegment=function(e,t,i){var r;this.state===a.State.PARSING&&(e.video&&delete e.video,(r=e.audio)&&(r.levelCodec=r.codec,r.id="audio",this.log("Init audio buffer, container:"+r.container+", codecs[parsed]=["+r.codec+"]"),this.hls.trigger(n.Events.BUFFER_CODECS,e),null!=(e=r.initSegment)&&e.byteLength&&(r={type:"audio",frag:t,part:null,chunkMeta:i,parent:t.type,data:e},this.hls.trigger(n.Events.BUFFER_APPENDING,r)),this.tick()))},i.loadFragment=function(e,t,i){var n=this.fragmentTracker.getState(e);this.fragCurrent=e,!this.audioSwitch&&n!==l.FragmentState.NOT_LOADED&&n!==l.FragmentState.PARTIAL||("initSegment"===e.sn?this._loadInitSegment(e,t):t.live&&!(0,s.isFiniteNumber)(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=a.State.WAITING_INIT_PTS):(this.startFragRequested=!0,r.prototype.loadFragment.call(this,e,t,i)))},i.completeAudioSwitch=function(){var e=this.hls,t=this.media,i=this.trackId;t&&(this.log("Switching audio track : flushing all audio"),r.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,e.trigger(n.Events.AUDIO_TRACK_SWITCHED,{id:i})};const _=v},"./src/controller/audio-track-controller.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>h});var r,s=i("./src/events.ts"),a=i("./src/errors.ts"),n=(t=i("./src/controller/base-playlist-controller.ts"),i("./src/types/loader.ts"));function o(e,t){for(var i,r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,"symbol"==typeof(i=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);if(t=t.call(e,"string"),"object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(s.key))?i:String(i),s)}}function l(e,t){return(l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function d(e){return(e=r.call(this,e,"[audio-track-controller]")||this).tracks=[],e.groupId=null,e.tracksInGroup=[],e.trackId=-1,e.trackName="",e.selectDefaultTrack=!0,e.registerListeners(),e}r=t.default,i=r,(t=d).prototype=Object.create(i.prototype),l(t.prototype.constructor=t,i),(t=d.prototype).registerListeners=function(){var e=this.hls;e.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(s.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(s.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(s.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(s.Events.ERROR,this.onError,this)},t.unregisterListeners=function(){var e=this.hls;e.off(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(s.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(s.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(s.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(s.Events.ERROR,this.onError,this)},t.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,r.prototype.destroy.call(this)},t.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},t.onManifestParsed=function(e,t){this.tracks=t.audioTracks||[]},t.onAudioTrackLoaded=function(e,t){var i,r=t.id,s=t.details,a=this.tracksInGroup[r];a?(i=a.details,a.details=t.details,this.log("audioTrack "+r+" loaded ["+s.startSN+"-"+s.endSN+"]"),r===this.trackId&&(this.retryCount=0,this.playlistLoaded(r,t,i))):this.warn("Invalid audio track id "+r)},t.onLevelLoading=function(e,t){this.switchLevel(t.level)},t.onLevelSwitching=function(e,t){this.switchLevel(t.level)},t.switchLevel=function(e){var t,i;e=this.hls.levels[e];null!=e&&e.audioGroupIds&&(t=e.audioGroupIds[e.urlId],this.groupId!==t&&(this.groupId=t,e=this.tracks.filter((function(e){return!t||e.groupId===t})),this.selectDefaultTrack&&!e.some((function(e){return e.default}))&&(this.selectDefaultTrack=!1),i={audioTracks:this.tracksInGroup=e},this.log("Updating audio tracks, "+e.length+' track(s) found in "'+t+'" group-id'),this.hls.trigger(s.Events.AUDIO_TRACKS_UPDATED,i),this.selectInitialTrack()))},t.onError=function(e,t){r.prototype.onError.call(this,e,t),!t.fatal&&t.context&&t.context.type===n.PlaylistContextType.AUDIO_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&this.retryLoadingOrFail(t)},t.setAudioTrack=function(e){var t,i,r,a,n,o,l=this.tracksInGroup;e<0||e>=l.length?this.warn("Invalid id passed to audio-track controller"):(this.clearTimer(),t=l[this.trackId],this.log("Now switching to audio-track index "+e),i=(l=l[e]).id,r=void 0===(r=l.groupId)?"":r,a=l.name,n=l.type,o=l.url,this.trackId=e,this.trackName=a,this.selectDefaultTrack=!1,this.hls.trigger(s.Events.AUDIO_TRACK_SWITCHING,{id:i,groupId:r,name:a,type:n,url:o}),l.details&&!l.details.live||(e=this.switchParams(l.url,null==t?void 0:t.details),this.loadPlaylist(e)))},t.selectInitialTrack=function(){var e=this.tracksInGroup;console.assert(e.length,"Initial audio track should be selected when tracks are known"),e=this.trackName,e=this.findTrackId(e)||this.findTrackId();-1!==e?this.setAudioTrack(e):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(s.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},t.findTrackId=function(e){for(var t=this.tracksInGroup,i=0;i<t.length;i++){var r=t[i];if((!this.selectDefaultTrack||r.default)&&(!e||e===r.name))return r.id}return-1},t.loadPlaylist=function(e){r.prototype.loadPlaylist.call(this);var t=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(t)){var i=t.id,a=t.groupId;t=t.url;if(e)try{t=e.addDirectives(t)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log("loading audio-track playlist for id: "+i),this.clearTimer(),this.hls.trigger(s.Events.AUDIO_TRACK_LOADING,{url:t,id:i,groupId:a,deliveryDirectives:e||null})}},o((i=d).prototype,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}}]),Object.defineProperty(i,"prototype",{writable:!1});const h=d},"./src/controller/base-playlist-controller.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>o});var r=i("./src/types/level.ts"),s=i("./src/controller/level-helper.ts"),a=i("./src/utils/logger.ts"),n=i("./src/errors.ts"),o=((t=l.prototype).destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},t.onError=function(e,t){!t.fatal||t.type!==n.ErrorTypes.NETWORK_ERROR&&t.type!==n.ErrorTypes.KEY_SYSTEM_ERROR||this.stopLoad()},t.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},t.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.requestScheduled=-1,this.loadPlaylist()},t.stopLoad=function(){this.canLoad=!1,this.clearTimer()},t.switchParams=function(e,t){var i=null==t?void 0:t.renditionReports;if(i)for(var s=0;s<i.length;s++){var n,o=i[s],l=void 0;try{l=new self.URL(o.URI,t.url).href}catch(e){a.logger.warn("Could not construct new URL for Rendition Report: "+e),l=o.URI||""}if(l===e.slice(-l.length))return l=parseInt(o["LAST-MSN"])||(null==t?void 0:t.lastPartSn),o=parseInt(o["LAST-PART"])||(null==t?void 0:t.lastPartIndex),this.hls.config.lowLatencyMode&&(n=Math.min(t.age-t.partTarget,t.targetduration),0<=o&&n>t.partTarget&&(o+=1)),new r.HlsUrlParameters(l,0<=o?o:void 0,r.HlsSkip.No)}},t.loadPlaylist=function(e){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())},t.shouldLoadTrack=function(e){return this.canLoad&&e&&!!e.url&&(!e.details||e.details.live)},t.playlistLoaded=function(e,t,i){var r=this,a=t.details,n=t.stats,o=self.performance.now(),l=n.loading.first?Math.max(0,o-n.loading.first):0;if(a.advancedDateTime=Date.now()-l,a.live||null!=i&&i.live){if(a.reloaded(i),i&&this.log("live playlist "+e+" "+(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:"MISSED")),i&&0<a.fragments.length&&(0,s.mergeDetails)(i,a),this.canLoad&&a.live){l=void 0;var d,h=void 0;if(a.canBlockReload&&a.endSN&&a.advanced){var c=this.hls.config.lowLatencyMode,u=a.lastPartSn,p=a.endSN,f=a.lastPartIndex,m=u===p;u=(-1!==f?(l=m?p+1:u,h=m?c?0:f:f+1):l=p+1,a.age),f=u+a.ageHeader,p=Math.min(f-a.partTarget,1.5*a.targetduration);if(0<p&&(i&&p>i.tuneInGoal?(this.warn("CDN Tune-in goal increased from: "+i.tuneInGoal+" to: "+p+" with playlist age: "+a.age),p=0):(l+=f=Math.floor(p/a.targetduration),void 0!==h&&(h+=Math.round(p%a.targetduration/a.partTarget)),this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+u.toFixed(2)+"s goal: "+p+" skip sn "+f+" to part "+h)),a.tuneInGoal=p),d=this.getDeliveryDirectives(a,t.deliveryDirectives,l,h),c||!m)return void this.loadPlaylist(d)}else d=this.getDeliveryDirectives(a,t.deliveryDirectives,l,h);i=this.hls.mainForwardBufferInfo,u=i?i.end-i.len:0,f=1e3*(a.edge-u),p=(0,s.computeReloadInterval)(a,f),a.updated?o>this.requestScheduled+p&&(this.requestScheduled=n.loading.start):this.requestScheduled=-1,void 0!==l&&a.canBlockReload?this.requestScheduled=n.loading.first+p-(1e3*a.partTarget||1e3):this.requestScheduled=(-1===this.requestScheduled?o:this.requestScheduled)+p,c=this.requestScheduled-o,c=Math.max(0,c),this.log("reload live playlist "+e+" in "+Math.round(c)+" ms"),this.timer=self.setTimeout((function(){return r.loadPlaylist(d)}),c)}}else this.clearTimer()},t.getDeliveryDirectives=function(e,t,i,s){var a=(0,r.getSkipValue)(e,i);return null!=t&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,s=t.part,a=r.HlsSkip.No),new r.HlsUrlParameters(i,s,a)},t.retryLoadingOrFail=function(e){var t,i=this,r=this.hls.config,s=this.retryCount<r.levelLoadingMaxRetry;return s?(this.requestScheduled=-1,this.retryCount++,-1<e.details.indexOf("LoadTimeOut")&&null!=(t=e.context)&&t.deliveryDirectives?(this.warn("retry playlist loading #"+this.retryCount+' after "'+e.details+'"'),this.loadPlaylist()):(t=Math.min(Math.pow(2,this.retryCount)*r.levelLoadingRetryDelay,r.levelLoadingMaxRetryTimeout),this.timer=self.setTimeout((function(){return i.loadPlaylist()}),t),this.warn("retry playlist loading #"+this.retryCount+" in "+t+' ms after "'+e.details+'"'))):(this.warn('cannot recover from error "'+e.details+'"'),this.clearTimer(),e.fatal=!0),s},l);function l(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=a.logger.log.bind(a.logger,t+":"),this.warn=a.logger.warn.bind(a.logger,t+":"),this.hls=e}},"./src/controller/base-stream-controller.ts":(e,t,i)=>{i.r(t),i.d(t,{State:()=>_,default:()=>w});var r=i("./src/polyfills/number.ts"),s=(t=i("./src/task-loop.ts"),i("./src/controller/fragment-tracker.ts")),a=i("./src/utils/buffer-helper.ts"),n=i("./src/utils/logger.ts"),o=i("./src/events.ts"),l=i("./src/errors.ts"),d=i("./src/types/transmuxer.ts"),h=i("./src/utils/mp4-tools.ts"),c=i("./src/utils/discontinuities.ts"),u=i("./src/controller/fragment-finders.ts"),p=i("./src/controller/level-helper.ts"),f=i("./src/loader/fragment-loader.ts"),m=i("./src/crypt/decrypter.ts"),g=i("./src/utils/time-ranges.ts"),y=i("./src/types/loader.ts");function A(e,t){for(var i,r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,"symbol"==typeof(i=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);if(t=t.call(e,"string"),"object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(s.key))?i:String(i),s)}}function b(e,t){return(b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}var v,_={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},w=(v=t.default,i=v,(t=S).prototype=Object.create(i.prototype),b(t.prototype.constructor=t,i),(t=S.prototype).doTick=function(){this.onTickEnd()},t.onTickEnd=function(){},t.startLoad=function(e){},t.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort();var e=this.fragCurrent;e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=_.STOPPED},t._streamEnded=function(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;e=t.partList;return null!=e&&e.length?(e=e[e.length-1],a.BufferHelper.isBuffered(this.media,e.start+e.duration/2)):(e=t.fragments[t.fragments.length-1].type,this.fragmentTracker.isEndListAppended(e))},t.getLevelDetails=function(){var e;if(this.levels&&null!==this.levelLastLoaded)return null==(e=this.levels[this.levelLastLoaded])?void 0:e.details},t.onMediaAttached=function(e,t){t=this.media=this.mediaBuffer=t.media,this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("ended",this.onvended),t=this.config,this.levels&&t.autoStartLoad&&this.state===_.STOPPED&&this.startLoad(t.startPosition)},t.onMediaDetaching=function(){var e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&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()},t.onMediaSeeking=function(){var e=this.config,t=this.fragCurrent,i=this.media,s=this.mediaBuffer,n=this.state,o=i?i.currentTime:0;s=a.BufferHelper.bufferInfo(s||i,o,e.maxBufferHole);this.log("media seeking to "+((0,r.isFiniteNumber)(o)?o.toFixed(3):o)+", state: "+n),this.state===_.ENDED?this.resetLoadingState():t&&(n=e.maxFragLookUpTolerance,e=t.start-n,n=t.start+t.duration+n,(!s.len||n<s.start||e>s.end)&&(n=n<o,(o<e||n)&&(n&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests()),this.resetLoadingState()))),i&&(this.lastCurrentTime=o),this.loadedmetadata||s.len||(this.nextLoadPosition=this.startPosition=o),this.tickImmediate()},t.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},t.onLevelSwitching=function(e,t){this.fragLoadError=0},t.onHandlerDestroying=function(){this.stopLoad(),v.prototype.onHandlerDestroying.call(this)},t.onHandlerDestroyed=function(){this.state=_.STOPPED,this.hls.off(o.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),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,v.prototype.onHandlerDestroyed.call(this)},t.loadFragment=function(e,t,i){this._loadFragForPlayback(e,t,i)},t._loadFragForPlayback=function(e,t,i){var r=this;this._doFragLoad(e,t,i,(function(t){if(r.fragContextChanged(e))return r.warn("Fragment "+e.sn+(t.part?" p: "+t.part.index:"")+" of level "+e.level+" was dropped during download."),void r.fragmentTracker.removeFragment(e);e.stats.chunkCount++,r._handleFragmentLoadProgress(t)})).then((function(t){var i;t&&(r.fragLoadError=0,i=r.state,r.fragContextChanged(e)?i!==_.FRAG_LOADING&&(r.fragCurrent||i!==_.PARSING)||(r.fragmentTracker.removeFragment(e),r.state=_.IDLE):("payload"in t&&(r.log("Loaded fragment "+e.sn+" of level "+e.level),r.hls.trigger(o.Events.FRAG_LOADED,t)),r._handleFragmentLoadComplete(t)))})).catch((function(t){r.state!==_.STOPPED&&r.state!==_.ERROR&&(r.warn(t),r.resetFragmentLoading(e))}))},t.flushMainBuffer=function(e,t,i){void 0===i&&(i=null),e-t&&(e={startOffset:e,endOffset:t,type:i},this.fragLoadError=0,this.hls.trigger(o.Events.BUFFER_FLUSHING,e))},t._loadInitSegment=function(e,t){var i=this;this._doFragLoad(e,t).then((function(t){if(t&&!i.fragContextChanged(e)&&i.levels)return t;throw new Error("init load aborted")})).then((function(t){var r,s=i.hls,a=t.payload,n=e.decryptdata;return a&&0<a.byteLength&&n&&n.key&&n.iv&&"AES-128"===n.method?(r=self.performance.now(),i.decrypter.decrypt(new Uint8Array(a),n.key.buffer,n.iv.buffer).then((function(i){var a=self.performance.now();return s.trigger(o.Events.FRAG_DECRYPTED,{frag:e,payload:i,stats:{tstart:r,tdecrypt:a}}),t.payload=i,t}))):t})).then((function(t){var r=i.fragCurrent,s=i.hls,a=i.levels;if(!a)throw new Error("init load aborted, missing levels");a=a[e.level].details,console.assert(a,"Level details are defined when init segment is loaded"),a=e.stats,i.state=_.IDLE,i.fragLoadError=0,e.data=new Uint8Array(t.payload),a.parsing.start=a.buffering.start=self.performance.now(),a.parsing.end=a.buffering.end=self.performance.now(),t.frag===r&&s.trigger(o.Events.FRAG_BUFFERED,{stats:a,frag:r,part:null,id:e.type}),i.tick()})).catch((function(t){i.state!==_.STOPPED&&i.state!==_.ERROR&&(i.warn(t),i.resetFragmentLoading(e))}))},t.fragContextChanged=function(e){var t=this.fragCurrent;return!e||!t||e.level!==t.level||e.sn!==t.sn||e.urlId!==t.urlId},t.fragBufferedComplete=function(e,t){var i=this.mediaBuffer||this.media;this.log("Buffered "+e.type+" sn: "+e.sn+(t?" part: "+t.index:"")+" of "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+e.level+" (frag:["+(e.startPTS||NaN).toFixed(3)+"-"+(e.endPTS||NaN).toFixed(3)+"] > buffer:"+(i?g.default.toString(a.BufferHelper.getBuffered(i)):"(detached)")+")"),this.state=_.IDLE,i&&(!this.loadedmetadata&&e.type==y.PlaylistLevelType.MAIN&&i.buffered.length&&(null==(t=this.fragCurrent)?void 0:t.sn)===(null==(e=this.fragPrevious)?void 0:e.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},t.seekToStartPos=function(){},t._handleFragmentLoadComplete=function(e){var t,i,r=this.transmuxer;r&&(i=e.frag,t=e.part,e=!(e=e.partsLoaded)||0===e.length||e.some((function(e){return!e})),i=new d.ChunkMetadata(i.level,i.sn,i.stats.chunkCount+1,0,t?t.index:-1,!e),r.flush(i))},t._handleFragmentLoadProgress=function(e){},t._doFragLoad=function(e,t,i,s){var a=this;if(void 0===i&&(i=null),!this.levels)throw new Error("frag load aborted, missing levels");var n=null;if(!e.encrypted||null!=(d=e.decryptdata)&&d.key?!e.encrypted&&t.encryptedFragments.length&&this.keyLoader.loadClear(e,t.encryptedFragments):(this.log("Loading key for "+e.sn+" of ["+t.startSN+"-"+t.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+e.level),this.state=_.KEY_LOADING,this.fragCurrent=e,n=this.keyLoader.load(e).then((function(e){if(!a.fragContextChanged(e.frag))return a.hls.trigger(o.Events.KEY_LOADED,e),e})),this.hls.trigger(o.Events.KEY_LOADING,{frag:e}),this.throwIfFragContextChanged("KEY_LOADING")),i=Math.max(e.start,i||0),this.config.lowLatencyMode&&t){var l=t.partList;if(l&&s){i>e.end&&t.fragmentHint&&(e=t.fragmentHint);var d,h=this.getNextPart(l,e,i);if(-1<h)return d=l[h],this.log("Loading part sn: "+e.sn+" p: "+d.index+" cc: "+e.cc+" of playlist ["+t.startSN+"-"+t.endSN+"] parts [0-"+h+"-"+(l.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(i.toFixed(3))),this.nextLoadPosition=d.start+d.duration,this.state=_.FRAG_LOADING,this.hls.trigger(o.Events.FRAG_LOADING,{frag:e,part:l[h],targetBufferTime:i}),this.throwIfFragContextChanged("FRAG_LOADING parts"),n?n.then((function(t){return!t||a.fragContextChanged(t.frag)?null:a.doFragPartsLoad(e,l,h,s)})).catch((function(e){return a.handleFragLoadError(e)})):this.doFragPartsLoad(e,l,h,s).catch((function(e){return a.handleFragLoadError(e)}));if(!e.url||this.loadedEndOfParts(l,i))return Promise.resolve(null)}}this.log("Loading fragment "+e.sn+" cc: "+e.cc+" "+(t?"of ["+t.startSN+"-"+t.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(i.toFixed(3))),(0,r.isFiniteNumber)(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=_.FRAG_LOADING,this.hls.trigger(o.Events.FRAG_LOADING,{frag:e,targetBufferTime:i}),this.throwIfFragContextChanged("FRAG_LOADING");var c=this.config.progressive;return c&&n?n.then((function(t){return!t||a.fragContextChanged(null==t?void 0:t.frag)?null:a.fragmentLoader.load(e,s)})).catch((function(e){return a.handleFragLoadError(e)})):Promise.all([this.fragmentLoader.load(e,c?s:void 0),n]).then((function(e){return e=e[0],!c&&e&&s&&s(e),e})).catch((function(e){return a.handleFragLoadError(e)}))},t.throwIfFragContextChanged=function(e){if(null===this.fragCurrent)throw new Error("frag load aborted, context changed in "+e)},t.doFragPartsLoad=function(e,t,i,r){var s=this;return new Promise((function(a,n){var l=[];!function i(d){var h=t[d];s.fragmentLoader.loadPart(e,h,r).then((function(r){var n=(l[h.index]=r).part;s.hls.trigger(o.Events.FRAG_LOADED,r),r=t[d+1];if(!r||r.fragment!==e)return a({frag:e,part:n,partsLoaded:l});i(d+1)})).catch(n)}(i)}))},t.handleFragLoadError=function(e){var t;return"data"in e?(t=e.data,e.data&&t.details===l.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(o.Events.ERROR,t)):this.hls.trigger(o.Events.ERROR,{type:l.ErrorTypes.OTHER_ERROR,details:l.ErrorDetails.INTERNAL_EXCEPTION,err:e,fatal:!0}),null},t._handleTransmuxerFlush=function(e){var t,i,r,s=this.getCurrentContext(e);s&&this.state===_.PARSING?(t=s.frag,i=s.part,s=s.level,r=self.performance.now(),t.stats.parsing.end=r,i&&(i.stats.parsing.end=r),this.updateLevelTiming(t,i,s,e.partial)):this.fragCurrent||this.state===_.STOPPED||this.state===_.ERROR||(this.state=_.IDLE)},t.getCurrentContext=function(e){var t=this.levels,i=e.level,r=e.sn;e=e.part;return t&&t[i]?(t=t[i],i=-1<e?(0,p.getPartWith)(t,r,e):null,e=i?i.fragment:(0,p.getFragmentWithSN)(t,r,this.fragCurrent),e?{frag:e,part:i,level:t}:null):(this.warn("Levels object was unset while buffering fragment "+r+" of level "+i+". The current chunk will not be buffered."),null)},t.bufferFragmentData=function(e,t,i,r){var s,a,n;e&&this.state===_.PARSING&&(n=e.data1,s=e.data2,(a=(a=n)&&s?(0,h.appendUint8Array)(n,s):a)&&a.length&&(n={type:e.type,frag:t,part:i,chunkMeta:r,parent:t.type,data:a},this.hls.trigger(o.Events.BUFFER_APPENDING,n),e.dropped&&e.independent&&!i&&this.flushBufferGap(t)))},t.flushBufferGap=function(e){var t,i,r=this.media;r&&(a.BufferHelper.isBuffered(r,r.currentTime)?(t=r.currentTime,r=a.BufferHelper.bufferInfo(r,t,0),i=e.duration,i=Math.min(2*this.config.maxFragLookUpTolerance,.25*i),r=Math.max(Math.min(e.start-i,r.end-i),t+i),e.start-r>i&&this.flushMainBuffer(r,e.start)):this.flushMainBuffer(0,e.start))},t.getFwdBufferInfo=function(e,t){var i=this.config,s=this.getLoadPosition();if(!(0,r.isFiniteNumber)(s))return null;var n=a.BufferHelper.bufferInfo(e,s,i.maxBufferHole);return 0===n.len&&void 0!==n.nextStart&&(t=this.fragmentTracker.getBufferedFrag(s,t),t&&n.nextStart<t.end)?a.BufferHelper.bufferInfo(e,s,Math.max(n.nextStart,i.maxBufferHole)):n},t.getMaxBufferLength=function(e){var t=this.config;e=e?Math.max(8*t.maxBufferSize/e,t.maxBufferLength):t.maxBufferLength;return Math.min(e,t.maxMaxBufferLength)},t.reduceMaxBufferLength=function(e){var t=this.config;e=e||t.maxBufferLength;return t.maxMaxBufferLength>=e&&(t.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)},t.getNextFragment=function(e,t){var i=t.fragments,r=i.length;if(!r)return null;var s,a=this.config,n=i[0].start;if(t.live){var o=a.initialLiveManifestSize;if(r<o)return this.warn("Not enough fragments to start playback (have: "+r+", need: "+o+")"),null;t.PTSKnown||this.startFragRequested||-1!==this.startPosition||(s=this.getInitialLiveFragment(t,i),this.startPosition=s?this.hls.liveSyncPosition||s.start:e)}else e<=n&&(s=i[0]);return s||(r=a.lowLatencyMode?t.partEnd:t.fragmentEnd,s=this.getFragmentAtPosition(e,r,t)),this.mapToInitFragWhenRequired(s)},t.mapToInitFragWhenRequired=function(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment},t.getNextPart=function(e,t,i){for(var r=-1,s=!1,a=!0,n=0,o=e.length;n<o;n++){var l=e[n];a=a&&!l.independent;if(-1<r&&i<l.start)break;var d=l.loaded;d?r=-1:(s||l.independent||a)&&l.fragment===t&&(r=n),s=d}return r},t.loadedEndOfParts=function(e,t){return e=e[e.length-1],e&&t>e.start&&e.loaded},t.getInitialLiveFragment=function(e,t){var i,r=this.fragPrevious,s=null;return r?(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),s=(0,u.findFragmentByPDT)(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),s||((i=r.sn+1)>=e.startSN&&i<=e.endSN&&(i=t[i-e.startSN],r.cc===i.cc&&this.log("Live playlist, switching playlist, load frag with next SN: "+(s=i).sn)),s||(s=(0,u.findFragWithCC)(t,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+s.sn))):null!==(i=this.hls.liveSyncPosition)&&(s=this.getFragmentAtPosition(i,this.bitrateTest?e.fragmentEnd:e.edge,e)),s},t.getFragmentAtPosition=function(e,t,i){var r=this.config,a=this.fragPrevious,n=i.fragments,o=i.endSN,l=i.fragmentHint,d=r.maxFragLookUpTolerance;r=!!(r.lowLatencyMode&&i.partList&&l);return r&&l&&!this.bitrateTest&&(n=n.concat(l),o=l.sn),(l=e<t?(0,u.findFragmentByPTS)(a,n,e,t-d<e?0:d):n[n.length-1])&&(t=l.sn-i.startSN,(a=this.fragmentTracker.getState(l)===s.FragmentState.OK?l:a)&&l.sn===a.sn&&!r&&a&&l.level===a.level&&(e=n[1+t],l=l.sn<o&&this.fragmentTracker.getState(e)!==s.FragmentState.OK?(this.log("SN "+l.sn+" just loaded, load next one: "+e.sn),e):null)),l},t.synchronizeToLiveEdge=function(e){var t,i,r,s,a=this.config,n=this.media;n&&(t=this.hls.liveSyncPosition,i=n.currentTime,s=e.fragments[0].start,r=e.edge,s=i>=s-a.maxFragLookUpTolerance&&i<=r,null!==t&&n.duration>t&&(i<t||!s)&&(a=void 0!==a.liveMaxLatencyDuration?a.liveMaxLatencyDuration:a.liveMaxLatencyDurationCount*e.targetduration,(!s&&n.readyState<4||i<r-a)&&(this.loadedmetadata||(this.nextLoadPosition=t),n.readyState&&(this.warn("Playback: "+i.toFixed(3)+" is located too far from the end of live sliding playlist: "+r+", reset currentTime to : "+t.toFixed(3)),n.currentTime=t))))},t.alignPlaylists=function(e,t){var i=this.levels,s=this.levelLastLoaded,a=this.fragPrevious;i=null!==s?i[s]:null,s=e.fragments.length;if(!s)return this.warn("No fragments in live playlist"),0;var n=e.fragments[0].start,o=!t,l=e.alignedSliding&&(0,r.isFiniteNumber)(n);return o||!l&&!n?((0,c.alignStream)(a,i,e),o=e.fragments[0].start,this.log("Live playlist sliding: "+o.toFixed(2)+" start-sn: "+(t?t.startSN:"na")+"->"+e.startSN+" prev-sn: "+(a?a.sn:"na")+" fragments: "+s),o):n},t.waitForCdnTuneIn=function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)},t.setStartPosition=function(e,t){var i,s=this.startPosition;-1!==(s=s<t?-1:s)&&-1!==this.lastCurrentTime||(i=e.startTimeOffset,(0,r.isFiniteNumber)(i)?(s=t+i,i<0&&(s+=e.totalduration),s=Math.min(Math.max(t,s),t+e.totalduration),this.log("Start time offset "+i+" found in playlist, adjust startPosition to "+s),this.startPosition=s):e.live?s=this.hls.liveSyncPosition||t:this.startPosition=s=0,this.lastCurrentTime=s),this.nextLoadPosition=s},t.getLoadPosition=function(){var e=this.media,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t},t.handleFragLoadAborted=function(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))},t.resetFragmentLoading=function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===_.FRAG_LOADING_WAITING_RETRY)||(this.state=_.IDLE)},t.onFragmentOrKeyLoadError=function(e,t){if(t.fatal)return this.stopLoad(),void(this.state=_.ERROR);var i,r=this.config,s=(!t.chunkMeta||(s=this.getCurrentContext(t.chunkMeta))&&(t.frag=s.frag,t.levelRetry=!0,this.fragLoadError=r.fragLoadingMaxRetry),t.frag);s&&s.type===e&&(i=this.fragCurrent,console.assert(i&&s.sn===i.sn&&s.level===i.level&&s.urlId===i.urlId,"Frag load error must match current frag to retry"),this.fragLoadError+1<=r.fragLoadingMaxRetry?(this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),i=Math.min(Math.pow(2,this.fragLoadError)*r.fragLoadingRetryDelay,r.fragLoadingMaxRetryTimeout),this.warn("Fragment "+s.sn+" of "+e+" "+s.level+" failed to load, retrying in "+i+"ms"),this.retryDate=self.performance.now()+i,this.fragLoadError++,this.state=_.FRAG_LOADING_WAITING_RETRY):t.levelRetry?(e===y.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=_.IDLE):(n.logger.error(t.details+" reaches max retry, redispatch as fatal ..."),t.fatal=!0,this.hls.stopLoad(),this.state=_.ERROR))},t.afterBufferFlushed=function(e,t,i){e&&(e=a.BufferHelper.getBuffered(e),this.fragmentTracker.detectEvictedFragments(t,e,i),this.state===_.ENDED&&this.resetLoadingState())},t.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=_.IDLE},t.resetStartWhenNotLoaded=function(e){this.loadedmetadata||(this.startFragRequested=!1,null!=(e=this.levels?this.levels[e].details:null)&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition)},t.updateLevelTiming=function(e,t,i,r){var s=this,a=i.details;console.assert(!!a,"level.details must be defined"),Object.keys(e.elementaryStreams).reduce((function(t,n){var l=e.elementaryStreams[n];if(l){var d=l.endPTS-l.startPTS;return d<=0?(s.warn("Could not parse fragment "+e.sn+" "+n+" duration reliably ("+d+")"),t||!1):(d=r?0:(0,p.updateFragPTSDTS)(a,e,l.startPTS,l.endPTS,l.startDTS,l.endDTS),s.hls.trigger(o.Events.LEVEL_PTS_UPDATED,{details:a,level:i,drift:d,type:n,frag:e,start:l.startPTS,end:l.endPTS}),!0)}return t}),!1)||(this.warn("Found no media in fragment "+e.sn+" of level "+i.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=_.PARSED,this.hls.trigger(o.Events.FRAG_PARSED,{frag:e,part:t})},t.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},A((i=S).prototype,[{key:"state",get:function(){return this._state},set:function(e){var t=this._state;t!==e&&(this._state=e,this.log(t+"->"+e))}}]),Object.defineProperty(i,"prototype",{writable:!1}),S);function S(e,t,i,r){var s;return(s=v.call(this)||this).hls=void 0,s.fragPrevious=null,s.fragCurrent=null,s.fragmentTracker=void 0,s.transmuxer=null,s._state=_.STOPPED,s.media=null,s.mediaBuffer=null,s.config=void 0,s.bitrateTest=!1,s.lastCurrentTime=0,s.nextLoadPosition=0,s.startPosition=0,s.loadedmetadata=!1,s.fragLoadError=0,s.retryDate=0,s.levels=null,s.fragmentLoader=void 0,s.keyLoader=void 0,s.levelLastLoaded=null,s.startFragRequested=!1,s.decrypter=void 0,s.initPTS=[],s.onvseeking=null,s.onvended=null,s.logPrefix="",s.log=void 0,s.warn=void 0,s.logPrefix=r,s.log=n.logger.log.bind(n.logger,r+":"),s.warn=n.logger.warn.bind(n.logger,r+":"),s.hls=e,s.fragmentLoader=new f.default(e.config),s.keyLoader=i,s.fragmentTracker=t,s.config=e.config,s.decrypter=new m.default(e.config),e.on(o.Events.LEVEL_SWITCHING,s.onLevelSwitching,function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(s)),s}},"./src/controller/buffer-controller.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>u});var r=i("./src/polyfills/number.ts"),s=i("./src/events.ts"),a=i("./src/utils/logger.ts"),n=i("./src/errors.ts"),o=i("./src/utils/buffer-helper.ts"),l=(t=i("./src/utils/mediasource-helper.ts"),i("./src/loader/fragment.ts")),d=i("./src/controller/buffer-operation-queue.ts"),h=(0,t.getMediaSource)(),c=/([ha]vc.)(?:\.[^.,]+)+/,u=((i=p.prototype).hasSourceTypes=function(){return 0<this.getSourceBufferTypes().length||0<Object.keys(this.pendingTracks).length},i.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},i.registerListeners=function(){var e=this.hls;e.on(s.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(s.Events.BUFFER_RESET,this.onBufferReset,this),e.on(s.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(s.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(s.Events.BUFFER_EOS,this.onBufferEos,this),e.on(s.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(s.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(s.Events.FRAG_PARSED,this.onFragParsed,this),e.on(s.Events.FRAG_CHANGED,this.onFragChanged,this)},i.unregisterListeners=function(){var e=this.hls;e.off(s.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(s.Events.BUFFER_RESET,this.onBufferReset,this),e.off(s.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(s.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(s.Events.BUFFER_EOS,this.onBufferEos,this),e.off(s.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(s.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(s.Events.FRAG_PARSED,this.onFragParsed,this),e.off(s.Events.FRAG_CHANGED,this.onFragChanged,this)},i._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new d.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},i.onManifestParsed=function(e,t){var i=2;(!t.audio||t.video)&&t.altAudio||(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,this.details=null,a.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},i.onMediaAttaching=function(e,t){var i;t=this.media=t.media;t&&h&&((i=this.mediaSource=new h).addEventListener("sourceopen",this._onMediaSourceOpen),i.addEventListener("sourceended",this._onMediaSourceEnded),i.addEventListener("sourceclose",this._onMediaSourceClose),t.src=self.URL.createObjectURL(i),this._objectUrl=t.src)},i.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,i=this._objectUrl;if(t){if(a.logger.log("[buffer-controller]: media source detaching"),"open"===t.readyState)try{t.endOfStream()}catch(e){a.logger.warn("[buffer-controller]: onMediaDetaching: "+e.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(i&&self.URL.revokeObjectURL(i),e.src===i?(e.removeAttribute("src"),e.load()):a.logger.warn("[buffer-controller]: media.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(s.Events.MEDIA_DETACHED,void 0)},i.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach((function(t){var i=e.sourceBuffer[t];try{i&&(e.removeBufferListeners(t),e.mediaSource&&e.mediaSource.removeSourceBuffer(i),e.sourceBuffer[t]=void 0)}catch(i){a.logger.warn("[buffer-controller]: Failed to reset the "+t+" buffer",i)}})),this._initSourceBuffer()},i.onBufferCodecs=function(e,t){var i=this,r=this.getSourceBufferTypes().length;Object.keys(t).forEach((function(e){var s,n,o,l,d,h,u,p;r?(s=i.tracks[e])&&"function"==typeof s.buffer.changeType&&(n=(h=t[e]).id,o=h.codec,l=h.levelCodec,d=h.container,h=h.metadata,(u=(s.levelCodec||s.codec).replace(c,"$1"))!==(p=(l||o).replace(c,"$1"))&&(i.appendChangeType(e,d+";codecs="+(l||o)),a.logger.log("[buffer-controller]: switching codec "+u+" to "+p),i.tracks[e]={buffer:s.buffer,codec:o,container:d,levelCodec:l,metadata:h,id:n})):i.pendingTracks[e]=t[e]})),r||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},i.appendChangeType=function(e,t){var i=this,r=this.operationQueue;r.append({execute:function(){var s=i.sourceBuffer[e];s&&(a.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+t),s.changeType(t)),r.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){a.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",t)}},e)},i.onBufferAppending=function(e,t){var i=this,r=this.hls,l=this.operationQueue,d=this.tracks,h=t.data,c=t.type,u=t.frag,p=t.part,f=t.chunkMeta,m=f.buffering[c],g=(t=self.performance.now(),m.start=t,u.stats.buffering),y=p?p.stats.buffering:null,A=(t=(0===g.start&&(g.start=t),y&&0===y.start&&(y.start=t),d.audio),!1),b=("audio"===c&&"audio/mpeg"===(null==t?void 0:t.container)&&(A=!this.lastMpegAudioChunk||1===f.id||this.lastMpegAudioChunk.sn!==f.sn,this.lastMpegAudioChunk=f),u.start);l.append({execute:function(){var e,t;m.executeStart=self.performance.now(),A&&(e=i.sourceBuffer[c])&&(t=b-e.timestampOffset,.1<=Math.abs(t)&&(a.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+b+" (delta: "+t+") sn: "+u.sn+")"),e.timestampOffset=b)),i.appendExecutor(h,c)},onStart:function(){},onComplete:function(){var e,t=self.performance.now(),r=(m.executeEnd=m.end=t,0===g.first&&(g.first=t),y&&0===y.first&&(y.first=t),i.sourceBuffer),a={};for(e in r)a[e]=o.BufferHelper.getBuffered(r[e]);i.appendError=0,i.hls.trigger(s.Events.BUFFER_APPENDED,{type:c,frag:u,part:p,chunkMeta:f,parent:u.type,timeRanges:a})},onError:function(e){a.logger.error("[buffer-controller]: Error encountered while trying to append to the "+c+" SourceBuffer",e);var t={type:n.ErrorTypes.MEDIA_ERROR,parent:u.type,details:n.ErrorDetails.BUFFER_APPEND_ERROR,err:e,fatal:!1};e.code===DOMException.QUOTA_EXCEEDED_ERR?t.details=n.ErrorDetails.BUFFER_FULL_ERROR:(i.appendError++,t.details=n.ErrorDetails.BUFFER_APPEND_ERROR,i.appendError>r.config.appendErrorMaxRetry&&(a.logger.error("[buffer-controller]: Failed "+r.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),t.fatal=!0,r.stopLoad())),r.trigger(s.Events.ERROR,t)}},c)},i.onBufferFlushing=function(e,t){function i(e){return{execute:r.removeExecutor.bind(r,e,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(s.Events.BUFFER_FLUSHED,{type:e})},onError:function(t){a.logger.warn("[buffer-controller]: Failed to remove from "+e+" SourceBuffer",t)}}}var r=this,n=this.operationQueue;t.type?n.append(i(t.type),t.type):this.getSourceBufferTypes().forEach((function(e){n.append(i(e),e)}))},i.onFragParsed=function(e,t){var i=this,r=t.frag,n=t.part,o=(t=[],(n||r).elementaryStreams);o[l.ElementaryStreamTypes.AUDIOVIDEO]?t.push("audiovideo"):(o[l.ElementaryStreamTypes.AUDIO]&&t.push("audio"),o[l.ElementaryStreamTypes.VIDEO]&&t.push("video")),0===t.length&&a.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+r.type+" level: "+r.level+" sn: "+r.sn),this.blockBuffers((function(){var e=self.performance.now();r.stats.buffering.end=e,n&&(n.stats.buffering.end=e),e=(n||r).stats;i.hls.trigger(s.Events.FRAG_BUFFERED,{frag:r,part:n,stats:e,id:r.type})}),t)},i.onFragChanged=function(e,t){this.flushBackBuffer()},i.onBufferEos=function(e,t){var i=this;this.getSourceBufferTypes().reduce((function(e,r){var s=i.sourceBuffer[r];return!s||t.type&&t.type!==r||(s.ending=!0,s.ended||(s.ended=!0,a.logger.log("[buffer-controller]: "+r+" sourceBuffer now EOS"))),e&&!(s&&!s.ended)}),!0)&&(a.logger.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers((function(){i.getSourceBufferTypes().forEach((function(e){e=i.sourceBuffer[e],e&&(e.ending=!1)}));var e=i.mediaSource;e&&"open"===e.readyState?(a.logger.log("[buffer-controller]: Calling mediaSource.endOfStream()"),e.endOfStream()):e&&a.logger.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+e.readyState)})))},i.onLevelUpdated=function(e,t){t=t.details,t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},i.flushBackBuffer=function(){var e,t,i,n,l,d=this.hls,h=this.details,c=this.media,u=this.sourceBuffer;c&&null!==h&&(e=this.getSourceBufferTypes()).length&&(t=h.live&&null!==d.config.liveBackBufferLength?d.config.liveBackBufferLength:d.config.backBufferLength,!(0,r.isFiniteNumber)(t)||t<0||(i=c.currentTime,n=h.levelTargetDuration,c=Math.max(t,n),l=Math.floor(i/n)*n-c,e.forEach((function(e){var t=u[e];if(t){var r=o.BufferHelper.getBuffered(t);if(0<r.length&&l>r.start(0)){if(d.trigger(s.Events.BACK_BUFFER_REACHED,{bufferEnd:l}),h.live)d.trigger(s.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:l});else if(t.ended&&r.end(r.length-1)-i<2*n)return void a.logger.info("[buffer-controller]: Cannot flush "+e+" back buffer while SourceBuffer is in ended state");d.trigger(s.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:l,type:e})}}}))))},i.updateMediaElementDuration=function(){var e,t,i,s,n,o;this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState&&(e=this.details,t=this.hls,n=this.media,i=this.mediaSource,s=e.fragments[0].start+e.totalduration,n=n.duration,o=(0,r.isFiniteNumber)(i.duration)?i.duration:0,e.live&&t.config.liveDurationInfinity?(a.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),i.duration=1/0,this.updateSeekableRange(e)):(o<s&&n<s||!(0,r.isFiniteNumber)(n))&&(a.logger.log("[buffer-controller]: Updating Media Source duration to "+s.toFixed(3)),i.duration=s))},i.updateSeekableRange=function(e){var t=this.mediaSource,i=e.fragments;i.length&&e.live&&null!=t&&t.setLiveSeekableRange&&(i=Math.max(0,i[0].start),e=Math.max(i,i+e.totalduration),t.setLiveSeekableRange(i,e))},i.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,i=this.pendingTracks,r=Object.keys(i).length;(r&&!e||2===r)&&(this.createSourceBuffers(i),this.pendingTracks={},0===(e=this.getSourceBufferTypes()).length?this.hls.trigger(s.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"}):e.forEach((function(e){t.executeNext(e)})))},i.createSourceBuffers=function(e){var t=this.sourceBuffer,i=this.mediaSource;if(!i)throw Error("createSourceBuffers called when mediaSource was null");var r,o=0;for(r in e)if(!t[r]){var l=e[r];if(!l)throw Error("source buffer exists for track "+r+", however track does not");var d=l.levelCodec||l.codec,h=l.container+";codecs="+d;a.logger.log("[buffer-controller]: creating sourceBuffer("+h+")");try{var c=t[r]=i.addSourceBuffer(h),u=r;this.addBufferListener(u,"updatestart",this._onSBUpdateStart),this.addBufferListener(u,"updateend",this._onSBUpdateEnd),this.addBufferListener(u,"error",this._onSBUpdateError),this.tracks[r]={buffer:c,codec:d,container:l.container,levelCodec:l.levelCodec,metadata:l.metadata,id:l.id},o++}catch(e){a.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+e.message),this.hls.trigger(s.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,mimeType:h})}}o&&this.hls.trigger(s.Events.BUFFER_CREATED,{tracks:this.tracks})},i._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},i._onSBUpdateEnd=function(e){var t=this.operationQueue;t.current(e).onComplete(),t.shiftAndExecuteNext(e)},i._onSBUpdateError=function(e,t){a.logger.error("[buffer-controller]: "+e+" SourceBuffer error",t),this.hls.trigger(s.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1}),e=this.operationQueue.current(e),e&&e.onError(t)},i.removeExecutor=function(e,t,i){var s=this.media,n=this.mediaSource,o=this.operationQueue,l=this.sourceBuffer[e];if(!s||!n||!l)return a.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void o.shiftAndExecuteNext(e);s=(0,r.isFiniteNumber)(s.duration)?s.duration:1/0,n=(0,r.isFiniteNumber)(n.duration)?n.duration:1/0,t=Math.max(0,t),i=Math.min(i,s,n),t<i&&!l.ending?(l.ended=!1,a.logger.log("[buffer-controller]: Removing ["+t+","+i+"] from the "+e+" SourceBuffer"),console.assert(!l.updating,e+" sourceBuffer must not be updating"),l.remove(t,i)):o.shiftAndExecuteNext(e)},i.appendExecutor=function(e,t){var i=this.operationQueue,r=this.sourceBuffer[t];if(!r)return a.logger.warn("[buffer-controller]: Attempting to append to the "+t+" SourceBuffer, but it does not exist"),void i.shiftAndExecuteNext(t);r.ended=!1,console.assert(!r.updating,t+" sourceBuffer must not be updating"),r.appendBuffer(e)},i.blockBuffers=function(e,t){var i=this;if(!(t=void 0===t?this.getSourceBufferTypes():t).length)return a.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);var r=this.operationQueue,s=t.map((function(e){return r.appendBlocker(e)}));Promise.all(s).then((function(){e(),t.forEach((function(e){var t=i.sourceBuffer[e];t&&t.updating||r.shiftAndExecuteNext(e)}))}))},i.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},i.addBufferListener=function(e,t,i){var r=this.sourceBuffer[e];r&&(i=i.bind(this,e),this.listeners[e].push({event:t,listener:i}),r.addEventListener(t,i))},i.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach((function(e){t.removeEventListener(e.event,e.listener)}))},p);function p(e){var t=this;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.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var e=t.hls,i=t.media,r=t.mediaSource;a.logger.log("[buffer-controller]: Media source opened"),i&&(t.updateMediaElementDuration(),e.trigger(s.Events.MEDIA_ATTACHED,{media:i})),r&&r.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){a.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){a.logger.log("[buffer-controller]: Media source ended")},this.hls=e,this._initSourceBuffer(),this.registerListeners()}},"./src/controller/buffer-operation-queue.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>s});var r=i("./src/utils/logger.ts"),s=((t=a.prototype).append=function(e,t){var i=this.queues[t];i.push(e),1===i.length&&this.buffers[t]&&this.executeNext(t)},t.insertAbort=function(e,t){this.queues[t].unshift(e),this.executeNext(t)},t.appendBlocker=function(e){var t,i=new Promise((function(e){t=e})),r={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(r,e),i},t.executeNext=function(e){var t=this.buffers,i=this.queues,s=t[e];i=i[e];if(i.length){var a=i[0];try{a.execute()}catch(t){r.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),a.onError(t),s&&s.updating||(i.shift(),this.executeNext(e))}}},t.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},t.current=function(e){return this.queues[e][0]},a);function a(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}},"./src/controller/cap-level-controller.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>n});var r=i("./src/events.ts");function s(e,t){for(var i,r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,"symbol"==typeof(i=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);if(t=t.call(e,"string"),"object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(s.key))?i:String(i),s)}}function a(e){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}(t=a.prototype).setStreamController=function(e){this.streamController=e},t.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},t.registerListeners=function(){var e=this.hls;e.on(r.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(r.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(r.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(r.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},t.unregisterListener=function(){var e=this.hls;e.off(r.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(r.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(r.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(r.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},t.onFpsDropLevelCapping=function(e,t){a.isLevelAllowed(t.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(t.droppedLevel)},t.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null},t.onManifestParsed=function(e,t){var i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()},t.onBufferCodecs=function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()},t.onMediaDetaching=function(){this.stopCapping()},t.detectPlayerSize=function(){var e,t;this.media&&0<this.mediaHeight&&0<this.mediaWidth&&(e=this.hls.levels).length&&((t=this.hls).autoLevelCapping=this.getMaxLevel(e.length-1),t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping)},t.getMaxLevel=function(e){var t=this,i=this.hls.levels;return i.length?(i=i.filter((function(i,r){return a.isLevelAllowed(r,t.restrictedLevels)&&r<=e})),this.clientRect=null,a.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)):-1},t.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},t.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},t.getDimensions=function(){if(this.clientRect)return this.clientRect;var e,t=this.media,i={width:0,height:0};return t&&(e=t.getBoundingClientRect(),i.width=e.width,i.height=e.height,i.width||i.height||(i.width=e.right-e.left||t.width||0,i.height=e.bottom-e.top||t.height||0)),this.clientRect=i},a.isLevelAllowed=function(e,t){return-1===(t=void 0===t?[]:t).indexOf(e)},a.getMaxLevelByMediaSize=function(e,t,i){if(!e||!e.length)return-1;for(var r,s=e.length-1,a=0;a<e.length;a+=1){var n=e[a];if((n.width>=t||n.height>=i)&&(!(r=e[a+1])||n.width!==r.width||n.height!==r.height)){s=a;break}}return s},s((t=a).prototype,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return e}}]),Object.defineProperty(t,"prototype",{writable:!1});const n=a},"./src/controller/cmcd-controller.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>u});var r=i("./src/events.ts"),s=i("./src/types/cmcd.ts"),a=i("./src/utils/buffer-helper.ts"),n=i("./src/utils/logger.ts");function o(e,t){for(var i,r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,"symbol"==typeof(i=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);if(t=t.call(e,"string"),"object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(s.key))?i:String(i),s)}}function l(e,t,i){t&&o(e.prototype,t),i&&o(e,i),Object.defineProperty(e,"prototype",{writable:!1})}function d(e,t){var i,r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e){if(e){if("string"==typeof e)return h(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(t="Object"===t&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?h(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length)return r&&(e=r),i=0,function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);i<t;i++)r[i]=e[i];return r}function c(){return(c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i,r=arguments[t];for(i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e}).apply(this,arguments)}(t=p.prototype).registerListeners=function(){var e=this.hls;e.on(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(r.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(r.Events.BUFFER_CREATED,this.onBufferCreated,this)},t.unregisterListeners=function(){var e=this.hls;e.off(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(r.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(r.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},t.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},t.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},t.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},t.onBufferCreated=function(e,t){var i;this.audioBuffer=null==(i=t.tracks.audio)?void 0:i.buffer,this.videoBuffer=null==(i=t.tracks.video)?void 0:i.buffer},t.createData=function(){var e;return{v:s.CMCDVersion,sf:s.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},t.apply=function(e,t){c(t=void 0===t?{}:t,this.createData());var i=t.ot===s.CMCDObjectType.INIT||t.ot===s.CMCDObjectType.VIDEO||t.ot===s.CMCDObjectType.MUXED;this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering),this.useHeaders?(i=p.toHeaders(t),Object.keys(i).length&&(e.headers||(e.headers={}),c(e.headers,i))):(i=p.toQuery(t))&&(e.url=p.appendQueryToUri(e.url,i))},t.getObjectType=function(e){var t=e.type;return"subtitle"===t?s.CMCDObjectType.TIMED_TEXT:"initSegment"===e.sn?s.CMCDObjectType.INIT:"audio"===t?s.CMCDObjectType.AUDIO:"main"===t?this.hls.audioTracks.length?s.CMCDObjectType.VIDEO:s.CMCDObjectType.MUXED:void 0},t.getTopBandwidth=function(e){for(var t=0,i=this.hls,r=d(e===s.CMCDObjectType.AUDIO?i.audioTracks:(e=-1<(e=i.maxAutoLevel)?e+1:i.levels.length,i.levels.slice(0,e)));!(a=r()).done;){var a=a.value;a.bitrate>t&&(t=a.bitrate)}return 0<t?t:NaN},t.getBufferLength=function(e){var t=this.hls.media;e=e===s.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;return e&&t?1e3*a.BufferHelper.bufferInfo(e,t.currentTime,this.config.maxBufferHole).len:NaN},t.createPlaylistLoader=function(){var e=this.config.pLoader,t=this.applyPlaylistData,i=e||this.config.loader;return(e=r.prototype).destroy=function(){this.loader.destroy()},e.abort=function(){this.loader.abort()},e.load=function(e,i,r){t(e),this.loader.load(e,i,r)},l(r,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),r;function r(e){this.loader=void 0,this.loader=new i(e)}},t.createFragmentLoader=function(){var e=this.config.fLoader,t=this.applyFragmentData,i=e||this.config.loader;return(e=r.prototype).destroy=function(){this.loader.destroy()},e.abort=function(){this.loader.abort()},e.load=function(e,i,r){t(e),this.loader.load(e,i,r)},l(r,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),r;function r(e){this.loader=void 0,this.loader=new i(e)}},p.uuid=function(){var e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)},p.serialize=function(e){for(var t=[],i=function(e){return Math.round(e)},r=function(e){return 100*i(e/100)},s={br:i,d:i,bl:r,dl:r,mtp:r,nor:function(e){return encodeURIComponent(e)},rtp:r,tb:i},a=d(Object.keys(e||{}).sort());!(l=a()).done;){var n,o,l=l.value,h=e[l];n=h,Number.isNaN(n)||null==n||""===n||!1===n||"v"===l&&1===h||"pr"==l&&1===h||(n=typeof(h=(n=s[l])?n(h):h),o=void 0,o="ot"===l||"sf"===l||"st"===l?l+"="+h:"boolean"==n?l:"number"==n?l+"="+h:l+"="+JSON.stringify(h),t.push(o))}return t.join(",")},p.toHeaders=function(e){for(var t={},i=["Object","Request","Session","Status"],r=[{},{},{},{}],s={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},a=0,n=Object.keys(e);a<n.length;a++){var o=n[a];r[null!=s[o]?s[o]:1][o]=e[o]}for(var l=0;l<r.length;l++){var d=p.serialize(r[l]);d&&(t["CMCD-"+i[l]]=d)}return t},p.toQuery=function(e){return"CMCD="+encodeURIComponent(p.serialize(e))},p.appendQueryToUri=function(e,t){if(!t)return e;var i=e.includes("?")?"&":"?";return e+i+t};var u=p;function p(e){var t=this,i=(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.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){t.initialized&&(t.starved=!0),t.buffering=!0},this.onPlaying=function(){t.initialized||(t.initialized=!0),t.buffering=!1},this.applyPlaylistData=function(e){try{t.apply(e,{ot:s.CMCDObjectType.MANIFEST,su:!t.initialized})}catch(e){n.logger.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=function(e){try{var i=e.frag,r=t.hls.levels[i.level],a=t.getObjectType(i),o={d:1e3*i.duration,ot:a};a!==s.CMCDObjectType.VIDEO&&a!==s.CMCDObjectType.AUDIO&&a!=s.CMCDObjectType.MUXED||(o.br=r.bitrate/1e3,o.tb=t.getTopBandwidth(a)/1e3,o.bl=t.getBufferLength(a)),t.apply(e,o)}catch(e){n.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=e,this.config=e.config),e.cmcd);null!=i&&(e.pLoader=this.createPlaylistLoader(),e.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||p.uuid(),this.cid=i.contentId,this.useHeaders=!0===i.useHeaders,this.registerListeners())}},"./src/controller/eme-controller.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>S});var r=i("./src/events.ts"),s=i("./src/errors.ts"),a=i("./src/utils/logger.ts"),n=i("./src/utils/mediakeys-helper.ts"),o=i("./src/utils/keysystem-util.ts"),l=i("./src/utils/numeric-encoding-utils.ts"),d=i("./src/loader/level-key.ts"),h=i("./src/utils/hex.ts"),c=i("./src/utils/mp4-tools.ts"),u=(t=i("./node_modules/eventemitter3/index.js"),i.n(t));function p(e){var t="function"==typeof Map?new Map:void 0;return(p=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return f(e,arguments,g(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),m(i,e)})(e)}function f(e,t,i){return(f=function(){if("undefined"!=typeof Reflect&&Reflect.construct&&!Reflect.construct.sham){if("function"==typeof Proxy)return 1;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),1}catch(e){return}}}()?Reflect.construct.bind():function(e,t,i){var r=[null];r.push.apply(r,t),t=new(Function.bind.apply(e,r));return i&&m(t,i.prototype),t}).apply(null,arguments)}function m(e,t){return(m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function g(e){return(g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var y="[eme]";(i=A.prototype).destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null},i.registerListeners=function(){this.hls.on(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(r.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(r.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},i.unregisterListeners=function(){this.hls.off(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(r.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(r.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},i.getLicenseServerUrl=function(e){var t=this.config,i=t.drmSystems;t=t.widevineLicenseUrl,i=i[e];if(i)return i.licenseUrl;if(e===n.KeySystems.WIDEVINE&&t)return t;throw new Error('no license server URL configured for key-system "'+e+'"')},i.getServerCertificateUrl=function(e){var t=this.config.drmSystems[e];if(t)return t.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+e+'"]')},i.attemptKeySystemAccess=function(e){function t(e,t,i){return!!e&&i.indexOf(e)===t}var i=this,r=this.hls.levels,a=r.map((function(e){return e.audioCodec})).filter(t),n=r.map((function(e){return e.videoCodec})).filter(t);return a.length+n.length===0&&n.push("avc1.42e01e"),new Promise((function(t,r){!function e(o){var l=o.shift();i.getMediaKeysPromise(l,a,n).then((function(e){return t({keySystem:l,mediaKeys:e})})).catch((function(t){o.length?e(o):r(t instanceof _?t:new _({type:s.ErrorTypes.KEY_SYSTEM_ERROR,details:s.ErrorDetails.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))}))}(e)}))},i.requestMediaKeySystemAccess=function(e,t){var i,r=this.config.requestMediaKeySystemAccessFunc;return"function"!=typeof r?(i="Configured requestMediaKeySystemAccess is not a function "+r,null===n.requestMediaKeySystemAccess&&"http:"===self.location.protocol&&(i="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(i))):r(e,t)},i.getMediaKeysPromise=function(e,t,i){var r,s=this,a=(t=(0,n.getSupportedMediaKeySystemConfigurations)(e,t,i,this.config.drmSystemOptions),this.keySystemAccessPromises[e]);i=null==a?void 0:a.keySystemAccess;return i?i.then((function(){return a.mediaKeys})):(this.log('Requesting encrypted media "'+e+'" key-system access with config: '+JSON.stringify(t)),i=this.requestMediaKeySystemAccess(e,t),r=this.keySystemAccessPromises[e]={keySystemAccess:i},i.catch((function(t){s.log('Failed to obtain access to key-system "'+e+'": '+t)})),i.then((function(t){s.log('Access for key-system "'+t.keySystem+'" obtained');var i=s.fetchServerCertificate(e);return s.log('Create media-keys for "'+e+'"'),r.mediaKeys=t.createMediaKeys().then((function(t){return s.log('Media-keys created for "'+e+'"'),i.then((function(i){return i?s.setMediaKeysServerCertificate(t,e,i):t}))})),r.mediaKeys.catch((function(t){s.error('Failed to create media-keys for "'+e+'"}: '+t)})),r.mediaKeys})))},i.createMediaKeySessionContext=function(e){var t=e.decryptdata,i=e.keySystem,r=(e=e.mediaKeys,console.assert(!!e,"mediaKeys is defined"),this.log('Creating key-system session "'+i+'" keyId: '+h.default.hexDump(t.keyId||[])),e.createSession());t={decryptdata:t,keySystem:i,mediaKeys:e,mediaKeysSession:r,keyStatus:"status-pending"};return this.mediaKeySessions.push(t),t},i.renewKeySession=function(e){var t,i,r=e.decryptdata;r.pssh?(t=this.createMediaKeySessionContext(e),i=this.getKeyIdString(r),this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(t,"cenc",r.pssh,"expired")):this.warn("Could not renew expired session. Missing pssh initData."),this.removeSession(e)},i.getKeyIdString=function(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return h.default.hexDump(e.keyId)},i.updateKeySession=function(e,t){var i=e.mediaKeysSession;return this.log('Updating key-session "'+i.sessionId+'" for keyID '+h.default.hexDump((null==(e=e.decryptdata)?void 0:e.keyId)||[])+"\n } (data length: "+(t&&t.byteLength)+")"),i.update(t)},i.selectKeySystemFormat=function(e){var 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},i.getKeyFormatPromise=function(e){var t=this;return new Promise((function(i,r){var s=(0,n.getKeySystemsForConfig)(t.config),a=e.map(n.keySystemFormatToKeySystemDomain).filter((function(e){return!!e&&-1!==s.indexOf(e)}));return t.getKeySystemSelectionPromise(a).then((function(e){e=e.keySystem;var t=(0,n.keySystemDomainToKeySystemFormat)(e);t?i(t):r(new Error('Unable to find format for key-system "'+e+'"'))})).catch(r)}))},i.loadKey=function(e){var t=this,i=e.keyInfo.decryptdata,r=this.getKeyIdString(i),s="(keyId: "+r+' format: "'+i.keyFormat+'" method: '+i.method+" uri: "+i.uri+")",a=(this.log("Starting session for key "+s),this.keyIdToKeySessionPromise[r]);return a||(a=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(i).then((function(r){var a=r.keySystem,n=r.mediaKeys;return t.throwIfDestroyed(),t.log("Handle encrypted media sn: "+e.frag.sn+" "+e.frag.type+": "+e.frag.level+" using key "+s),t.attemptSetMediaKeys(a,n).then((function(){t.throwIfDestroyed();var e=t.createMediaKeySessionContext({keySystem:a,mediaKeys:n,decryptdata:i});return t.generateRequestWithPreferredKeySession(e,"cenc",i.pssh,"playlist-key")}))}))).catch((function(e){return t.handleError(e)})),a},i.throwIfDestroyed=function(e){if(!this.hls)throw new Error("invalid state")},i.handleError=function(e){this.hls&&(this.error(e.message),e instanceof _?this.hls.trigger(r.Events.ERROR,e.data):this.hls.trigger(r.Events.ERROR,{type:s.ErrorTypes.KEY_SYSTEM_ERROR,details:s.ErrorDetails.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))},i.getKeySystemForKeyPromise=function(e){var t=this.getKeyIdString(e);t=this.keyIdToKeySessionPromise[t];return t||(e=(t=(0,n.keySystemFormatToKeySystemDomain)(e.keyFormat))?[t]:(0,n.getKeySystemsForConfig)(this.config),this.attemptKeySystemAccess(e))},i.getKeySystemSelectionPromise=function(e){if(0===(e=e.length?e:(0,n.getKeySystemsForConfig)(this.config)).length)throw new _({type:s.ErrorTypes.KEY_SYSTEM_ERROR,details:s.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(e)},i._onMediaEncrypted=function(e){var t,i,r=this,s=e.initDataType,a=e.initData;if(this.debug('"'+e.type+'" event: init data type: "'+s+'"'),null!==a){if("sinf"===s&&this.config.drmSystems[n.KeySystems.FAIRPLAY]){var o=(0,c.bin2str)(new Uint8Array(a));try{var u=(0,l.base64Decode)(JSON.parse(o).sinf),p=(0,c.parseSinf)(new Uint8Array(u));if(!p)return;t=p.subarray(8,24),i=n.KeySystems.FAIRPLAY}catch(e){return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{if(o=(0,c.parsePssh)(a),null===o)return;0===o.version&&o.systemId===n.KeySystemIds.WIDEVINE&&o.data&&(t=o.data.subarray(8,24)),i=(0,n.keySystemIdToKeySystemDomain)(o.systemId)}if(i&&t){for(var f=h.default.hexDump(t),m=this.keyIdToKeySessionPromise,g=this.mediaKeySessions,y=m[f],A=0;A<g.length;A++){var b=function(e){var i=g[e];e=i.decryptdata;if(e.pssh||!e.keyId)return"continue";var n=h.default.hexDump(e.keyId);return f===n||-1!==e.uri.replace(/-/g,"").indexOf(f)?(y=m[n],delete m[n],e.pssh=new Uint8Array(a),e.keyId=t,y=m[f]=y.then((function(){return r.generateRequestWithPreferredKeySession(i,s,a,"encrypted-event-key-match")})),"break"):void 0}(A);if("continue"!==b&&"break"===b)break}(y=y||(m[f]=this.getKeySystemSelectionPromise([i]).then((function(e){var i=e.keySystem,o=e.mediaKeys,l=(r.throwIfDestroyed(),new d.LevelKey("ISO-23001-7",f,null!=(e=(0,n.keySystemDomainToKeySystemFormat)(i))?e:""));return l.pssh=new Uint8Array(a),l.keyId=t,r.attemptSetMediaKeys(i,o).then((function(){r.throwIfDestroyed();var e=r.createMediaKeySessionContext({decryptdata:l,keySystem:i,mediaKeys:o});return r.generateRequestWithPreferredKeySession(e,s,a,"encrypted-event-no-match")}))})))).catch((function(e){return r.handleError(e)}))}}},i._onWaitingForKey=function(e){this.log('"'+e.type+'" event')},i.attemptSetMediaKeys=function(e,t){var i=this,r=this.setMediaKeysQueue.slice(),s=(this.log('Setting media-keys for "'+e+'"'),Promise.all(r).then((function(){if(i.media)return i.media.setMediaKeys(t);throw new Error("Attempted to set mediaKeys without media element attached")})));return this.setMediaKeysQueue.push(s),s.then((function(){i.log('Media-keys set for "'+e+'"'),r.push(s),i.setMediaKeysQueue=i.setMediaKeysQueue.filter((function(e){return-1===r.indexOf(e)}))}))},i.generateRequestWithPreferredKeySession=function(e,t,i,r){var a=this,l=null==(l=this.config.drmSystems)||null==(l=l[e.keySystem])?void 0:l.generateRequest;if(l)try{var d=l.call(this.hls,t,i,e);if(!d)throw new Error("Invalid response from configured generateRequest filter");t=d.initDataType,i=e.decryptdata.pssh=d.initData?new Uint8Array(d.initData):null}catch(e){if(this.warn(e.message),null!=(l=this.hls)&&l.config.debug)throw e}if(null===i)return this.log('Skipping key-session request for "'+r+'" (no initData)'),Promise.resolve(e);var h=this.getKeyIdString(e.decryptdata),c=(this.log('Generating key-session request for "'+r+'": '+h+" (init data type: "+t+" length: "+(i?i.byteLength:null)+")"),new(u())),p=(e.mediaKeysSession.onmessage=function(t){var i,r=e.mediaKeysSession;r?(i=t.messageType,t=t.message,a.log('"'+i+'" message event for session "'+r.sessionId+'" message size: '+t.byteLength),"license-request"===i||"license-renewal"===i?a.renewLicense(e,t).catch((function(e){a.handleError(e),c.emit("error",e)})):"license-release"===i?e.keySystem===n.KeySystems.FAIRPLAY&&(a.updateKeySession(e,(0,o.strToUtf8array)("acknowledged")),a.removeSession(e)):a.warn('unhandled media key message type "'+i+'"')):c.emit("error",new Error("invalid state"))},e.mediaKeysSession.onkeystatuseschange=function(t){var i;e.mediaKeysSession?(a.onKeyStatusChange(e),i=e.keyStatus,c.emit("keyStatus",i),"expired"===i&&(a.warn(e.keySystem+" expired for key "+h),a.renewKeySession(e))):c.emit("error",new Error("invalid state"))},new Promise((function(e,t){c.on("error",t),c.on("keyStatus",(function(i){i.startsWith("usable")?e():"output-restricted"===i?t(new _({type:s.ErrorTypes.KEY_SYSTEM_ERROR,details:s.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===i?t(new _({type:s.ErrorTypes.KEY_SYSTEM_ERROR,details:s.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'+i+'"')):"expired"===i?t(new Error("key expired while generating request")):a.warn('unhandled key status change "'+i+'"')}))})));return e.mediaKeysSession.generateRequest(t,i).then((function(){var t;a.log('Request generated for key-session "'+(null==(t=e.mediaKeysSession)?void 0:t.sessionId)+'" keyId: '+h)})).catch((function(e){throw new _({type:s.ErrorTypes.KEY_SYSTEM_ERROR,details:s.ErrorDetails.KEY_SYSTEM_NO_SESSION,error:e,fatal:!1},"Error generating key-session request: "+e)})).then((function(){return p})).catch((function(t){throw c.removeAllListeners(),a.removeSession(e),t})).then((function(){return c.removeAllListeners(),e}))},i.onKeyStatusChange=function(e){var t=this;e.mediaKeysSession.keyStatuses.forEach((function(i,r){t.log('key status change "'+i+'" for keyStatuses keyId: '+h.default.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))+" session keyId: "+h.default.hexDump(new Uint8Array(e.decryptdata.keyId||[]))+" uri: "+e.decryptdata.uri),e.keyStatus=i}))},i.fetchServerCertificate=function(e){var t=this;return new Promise((function(i,r){var a=t.getServerCertificateUrl(e);if(!a)return i();t.log('Fetching serverCertificate for "'+e+'"');var n=new XMLHttpRequest;n.open("GET",a,!0),n.responseType="arraybuffer",n.onreadystatechange=function(){n.readyState===XMLHttpRequest.DONE&&(200===n.status?i(n.response):r(new _({type:s.ErrorTypes.KEY_SYSTEM_ERROR,details:s.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n},'"'+e+'" certificate request XHR failed ('+a+"). Status: "+n.status+" ("+n.statusText+")")))},n.send()}))},i.setMediaKeysServerCertificate=function(e,t,i){var r=this;return new Promise((function(a,n){e.setServerCertificate(i).then((function(s){r.log("setServerCertificate "+(s?"success":"not supported by CDM")+" ("+(null==i?void 0:i.byteLength)+') on "'+t+'"'),a(e)})).catch((function(e){n(new _({type:s.ErrorTypes.KEY_SYSTEM_ERROR,details:s.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))}))}))},i.renewLicense=function(e,t){var i=this;return this.requestLicense(e,new Uint8Array(t)).then((function(t){return i.updateKeySession(e,new Uint8Array(t)).catch((function(e){throw new _({type:s.ErrorTypes.KEY_SYSTEM_ERROR,details:s.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:e,fatal:!0},e.message)}))}))},i.setupLicenseXHR=function(e,t,i,r){var s=this,a=this.config.licenseXhrSetup;return a?Promise.resolve().then((function(){if(i.decryptdata)return a.call(s.hls,e,t,i,r);throw new Error("Key removed")})).catch((function(n){if(i.decryptdata)return e.open("POST",t,!0),a.call(s.hls,e,t,i,r);throw n})).then((function(i){return e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:i||r}})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:r}))},i.requestLicense=function(e,t){var i=this;return new Promise((function(r,a){var n=i.getLicenseServerUrl(e.keySystem),o=(i.log("Sending license request to URL: "+n),new XMLHttpRequest);o.responseType="arraybuffer",o.onreadystatechange=function(){if(!i.hls||!e.mediaKeysSession)return a(new Error("invalid state"));if(4===o.readyState)if(200===o.status){i._requestLicenseFailureCount=0;var l=o.response,d=(i.log("License received "+(l instanceof ArrayBuffer?l.byteLength:l)),i.config.licenseResponseCallback);if(d)try{l=d.call(i.hls,o,n,e)}catch(l){i.error(l)}r(l)}else i._requestLicenseFailureCount++,3<i._requestLicenseFailureCount||400<=o.status&&o.status<500?a(new _({type:s.ErrorTypes.KEY_SYSTEM_ERROR,details:s.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o},"License Request XHR failed ("+n+"). Status: "+o.status+" ("+o.statusText+")")):(d=3-i._requestLicenseFailureCount+1,i.warn("Retrying license request, "+d+" attempts left"),i.requestLicense(e,t).then(r,a))},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,i.setupLicenseXHR(o,n,e,t).then((function(e){var t=e.xhr;e=e.licenseChallenge;t.send(e)}))}))},i.onMediaAttached=function(e,t){this.config.emeEnabled&&(t=t.media,(this.media=t).addEventListener("encrypted",this.onMediaEncrypted),t.addEventListener("waitingforkey",this.onWaitingForKey))},i.onMediaDetached=function(){var e=this,t=this.media,i=this.mediaKeySessions,r=(t&&(t.removeEventListener("encrypted",this.onMediaEncrypted),t.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},d.LevelKey.clearKeyUriToKeyIdMap(),i.length);A.CDMCleanupPromise=Promise.all(i.map((function(t){return e.removeSession(t)})).concat(null==t?void 0:t.setMediaKeys(null).catch((function(i){e.log("Could not clear media keys: "+i+". media.src: "+(null==t?void 0:t.src))})))).then((function(){r&&(e.log("finished closing key sessions and clearing media keys"),i.length=0)})).catch((function(i){e.log("Could not close sessions and clear media keys: "+i+". media.src: "+(null==t?void 0:t.src))}))},i.onManifestLoaded=function(e,t){t=t.sessionKeys;t&&this.config.emeEnabled&&!this.keyFormatPromise&&(t=t.reduce((function(e,t){return-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e}),[]),this.log("Selecting key-system from session-keys "+t.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(t))},i.removeSession=function(e){var t=this,i=e.mediaKeysSession,r=e.licenseXhr;if(i)return this.log("Remove licenses and keys and close session "+i.sessionId),i.onmessage=null,i.onkeystatuseschange=null,r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0,-1<(r=this.mediaKeySessions.indexOf(e))&&this.mediaKeySessions.splice(r,1),i.remove().catch((function(e){t.log("Could not remove session: "+e)})).then((function(){return i.close()})).catch((function(e){t.log("Could not close session: "+e)}))},t=A;function A(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=A.CDMCleanupPromise?[A.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=a.logger.debug.bind(a.logger,y),this.log=a.logger.log.bind(a.logger,y),this.warn=a.logger.warn.bind(a.logger,y),this.error=a.logger.error.bind(a.logger,y),this.hls=e,this.config=e.config,this.registerListeners()}t.CDMCleanupPromise=void 0,b=p(Error),i=b,(v=w).prototype=Object.create(i.prototype),m(v.prototype.constructor=v,i);var b,v,_=w;function w(e,t){return(t=b.call(this,t)||this).data=void 0,(t.data=e).err=e.error,t}const S=t},"./src/controller/fps-controller.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>n});var r=i("./src/events.ts"),s=i("./src/utils/logger.ts");function a(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()}(t=a.prototype).setStreamController=function(e){this.streamController=e},t.registerListeners=function(){this.hls.on(r.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},t.unregisterListeners=function(){this.hls.off(r.Events.MEDIA_ATTACHING,this.onMediaAttaching)},t.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},t.onMediaAttaching=function(e,t){var i=this.hls.config;i.capLevelOnFPSDrop&&(t=t.media instanceof self.HTMLVideoElement?t.media:null,(this.media=t)&&"function"==typeof t.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod))},t.checkFPS=function(e,t,i){var a,n,o,l,d=performance.now();t&&(this.lastTime&&(l=d-this.lastTime,a=i-this.lastDroppedFrames,n=t-this.lastDecodedFrames,l=1e3*a/l,(o=this.hls).trigger(r.Events.FPS_DROP,{currentDropped:a,currentDecoded:n,totalDroppedFrames:i}),0<l&&a>o.config.fpsDroppedMonitoringThreshold*n&&(l=o.currentLevel,s.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+l),0<l&&(-1===o.autoLevelCapping||o.autoLevelCapping>=l)&&(o.trigger(r.Events.FPS_DROP_LEVEL_CAPPING,{level:--l,droppedLevel:o.currentLevel}),o.autoLevelCapping=l,this.streamController.nextLevelSwitch()))),this.lastTime=d,this.lastDroppedFrames=i,this.lastDecodedFrames=t)},t.checkFPSInterval=function(){var e,t=this.media;t&&(this.isVideoPlaybackQualityAvailable?(e=t.getVideoPlaybackQuality(),this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)):this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount))};const n=a},"./src/controller/fragment-finders.ts":(e,t,i)=>{i.r(t),i.d(t,{findFragWithCC:()=>function(e,t){return s.default.search(e,(function(e){return e.cc<t?1:e.cc>t?-1:0}))},findFragmentByPDT:()=>function(e,t,i){if(null===t||!Array.isArray(e)||!e.length||!(0,r.isFiniteNumber)(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(var s=0;s<e.length;++s){var a=e[s];if(n(t,i,a))return a}return null},findFragmentByPTS:()=>function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0);var n=null;return e?n=t[e.sn-t[0].sn+1]||null:0===i&&0===t[0].start&&(n=t[0]),n&&0===a(i,r,n)?n:(t=s.default.search(t,a.bind(null,i,r)),!t||t===e&&n?n:t)},fragmentWithinToleranceTest:()=>a,pdtWithinToleranceTest:()=>n});var r=i("./src/polyfills/number.ts"),s=i("./src/utils/binary-search.ts");function a(e,t,i){return void 0===t&&(t=0),i.start<=(e=void 0===e?0:e)&&i.start+i.duration>e?0:(t=Math.min(t,i.duration+(i.deltaPTS||0)),i.start+i.duration-t<=e?1:i.start-t>e&&i.start?-1:0)}function n(e,t,i){return t=1e3*Math.min(t,i.duration+(i.deltaPTS||0)),(i.endProgramDateTime||0)-t>e}},"./src/controller/fragment-tracker.ts":(e,t,i)=>{i.r(t),i.d(t,{FragmentState:()=>r,FragmentTracker:()=>n});var r,s=i("./src/events.ts"),a=i("./src/types/loader.ts"),n=((t=r=r||{}).NOT_LOADED="NOT_LOADED",t.APPENDING="APPENDING",t.PARTIAL="PARTIAL",t.OK="OK",(i=o.prototype)._registerListeners=function(){var e=this.hls;e.on(s.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.on(s.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(s.Events.FRAG_LOADED,this.onFragLoaded,this)},i._unregisterListeners=function(){var e=this.hls;e.off(s.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.off(s.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(s.Events.FRAG_LOADED,this.onFragLoaded,this)},i.destroy=function(){this._unregisterListeners(),this.fragments=this.endListFragments=this.timeRanges=this.activeFragment=this.activeParts=null},i.getAppendedFrag=function(e,t){if(t===a.PlaylistLevelType.MAIN){var i=this.activeFragment,r=this.activeParts;if(!i)return null;if(r)for(var s=r.length;s--;){var n=r[s],o=n?n.end:i.appendedPTS;if(n.start<=e&&void 0!==o&&e<=o)return 9<s&&(this.activeParts=r.slice(s-9)),n}else if(i.start<=e&&void 0!==i.appendedPTS&&e<=i.appendedPTS)return i}return this.getBufferedFrag(e,t)},i.getBufferedFrag=function(e,t){for(var i=this.fragments,r=Object.keys(i),s=r.length;s--;){var a=i[r[s]];if((null==a?void 0:a.body.type)===t&&a.buffered&&(a=a.body,a.start<=e&&e<=a.end))return a}return null},i.detectEvictedFragments=function(e,t,i){var r=this;this.timeRanges&&(this.timeRanges[e]=t),Object.keys(this.fragments).forEach((function(s){var a=r.fragments[s];a&&(a.buffered||a.loaded?(s=a.range[e])&&s.time.some((function(e){return e=!r.isTimeBuffered(e.startPTS,e.endPTS,t),e&&r.removeFragment(a.body),e})):a.body.type===i&&r.removeFragment(a.body))}))},i.detectPartialFragments=function(e){var t,i=this,r=this.timeRanges,s=e.frag,a=e.part;r&&"initSegment"!==s.sn&&(e=d(s),(t=this.fragments[e])&&(Object.keys(r).forEach((function(e){var n,o=s.elementaryStreams[e];o&&(n=r[e],o=null!==a||!0===o.partial,t.range[e]=i.getBufferedTimes(s,a,o,n))})),t.loaded=null,Object.keys(t.range).length?(t.buffered=!0,t.body.endList&&(this.endListFragments[t.body.type]=t)):this.removeFragment(t.body)))},i.fragBuffered=function(e){e=d(e),e=this.fragments[e],e&&(e.loaded=null,e.buffered=!0)},i.getBufferedTimes=function(e,t,i,r){for(var s={time:[],partial:i},a=(t||e).start,n=(t||e).end,o=e.minEndPTS||n,l=e.maxStartPTS||a,d=0;d<r.length;d++){var h=r.start(d)-this.bufferPadding,c=r.end(d)+this.bufferPadding;if(h<=l&&o<=c){s.time.push({startPTS:Math.max(a,r.start(d)),endPTS:Math.min(n,r.end(d))});break}if(a<c&&h<n)s.partial=!0,s.time.push({startPTS:Math.max(a,r.start(d)),endPTS:Math.min(n,r.end(d))});else if(n<=h)break}return s},i.getPartialFragment=function(e){var t,i,r=null,s=0,a=this.bufferPadding,n=this.fragments;return Object.keys(n).forEach((function(o){o=n[o],o&&l(o)&&(t=o.body.start-a,i=o.body.end+a,t<=e&&e<=i&&(t=Math.min(e-t,i-e),s<=t&&(r=o.body,s=t)))})),r},i.isEndListAppended=function(e){return e=this.endListFragments[e],void 0!==e&&(e.buffered||l(e))},i.getState=function(e){return e=d(e),e=this.fragments[e],e?e.buffered?l(e)?r.PARTIAL:r.OK:r.APPENDING:r.NOT_LOADED},i.isTimeBuffered=function(e,t,i){for(var r,s,a=0;a<i.length;a++){if(r=i.start(a)-this.bufferPadding,s=i.end(a)+this.bufferPadding,r<=e&&t<=s)return!0;if(t<=r)return!1}return!1},i.onFragLoaded=function(e,t){var i=t.frag,r=t.part;"initSegment"===i.sn||i.bitrateTest||r||(r=d(i),this.fragments[r]={body:i,loaded:t,buffered:!1,range:Object.create(null)})},i.onBufferAppended=function(e,t){var i=this,r=t.frag,s=t.part,n=t.timeRanges;r.type===a.PlaylistLevelType.MAIN&&(this.activeFragment!==r&&((this.activeFragment=r).appendedPTS=void 0),s?((t=this.activeParts)||(this.activeParts=t=[]),t.push(s)):this.activeParts=null),this.timeRanges=n,Object.keys(n).forEach((function(e){var t=n[e];if(i.detectEvictedFragments(e,t),!s&&r.type===a.PlaylistLevelType.MAIN){var o=r.elementaryStreams[e];if(o)for(var l=0;l<t.length;l++){var d=t.end(l);d<=o.endPTS&&d>o.startPTS?r.appendedPTS=Math.max(d,r.appendedPTS||0):r.appendedPTS=o.endPTS}}}))},i.onFragBuffered=function(e,t){this.detectPartialFragments(t)},i.hasFragment=function(e){return e=d(e),!!this.fragments[e]},i.removeFragmentsInRange=function(e,t,i){var r=this;Object.keys(this.fragments).forEach((function(s){s=r.fragments[s];s&&s.buffered&&(s=s.body).type===i&&s.start<t&&s.end>e&&r.removeFragment(s)}))},i.removeFragment=function(e){var t=d(e);e.stats.loaded=0,e.clearElementaryStreamInfo(),e.appendedPTS=void 0,delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},i.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activeFragment=null,this.activeParts=null},o);function o(e){this.activeFragment=null,this.activeParts=null,this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=e,this._registerListeners()}function l(e){var t;return e.buffered&&((null==(t=e.range.video)?void 0:t.partial)||(null==(t=e.range.audio)?void 0:t.partial))}function d(e){return e.type+"_"+e.level+"_"+e.urlId+"_"+e.sn}},"./src/controller/gap-controller.ts":(e,t,i)=>{i.r(t),i.d(t,{MAX_START_GAP_JUMP:()=>l,SKIP_BUFFER_HOLE_STEP_SECONDS:()=>d,SKIP_BUFFER_RANGE_START:()=>h,STALL_MINIMUM_DURATION_MS:()=>o,default:()=>c});var r=i("./src/utils/buffer-helper.ts"),s=i("./src/errors.ts"),a=i("./src/events.ts"),n=i("./src/utils/logger.ts"),o=250,l=2,d=.1,h=.05,c=((t=u.prototype).destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},t.poll=function(e,t){var i=this.config,s=this.media,a=this.stalled;if(null!==s){var d=s.currentTime,h=s.seeking,c=this.seeking&&!h,u=!this.seeking&&h;if(this.seeking=h,d===e){if((u||c)&&(this.stalled=null),!(s.paused&&!h||s.ended||0===s.playbackRate)&&r.BufferHelper.getBuffered(s).length&&(e=r.BufferHelper.bufferInfo(s,d,0),u=0<e.len,c=e.nextStart||0,u||c)){if(h){if(u=e.len>l,t=!c||t&&t.start<=d||l<c-d&&!this.fragmentTracker.getPartialFragment(d),u||t)return;this.moved=!1}if(!this.moved&&null!==this.stalled&&(u=Math.max(c,e.start||0)-d,t=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,c=null!=t&&null!=(c=t.details)&&c.live?2*t.details.targetduration:l,0<u&&u<=c))return void this._trySkipBufferHole(null);t=self.performance.now(),null!==a?(u=t-a,!h&&o<=u&&(this._reportStall(e),!this.media)||(c=r.BufferHelper.bufferInfo(s,d,i.maxBufferHole),this._tryFixBufferStall(c,u))):this.stalled=t}}else this.moved=!0,null!==a&&(this.stallReported&&(h=self.performance.now()-a,n.logger.warn("playback not stuck anymore @"+d+", after "+Math.round(h)+"ms"),this.stallReported=!1),this.stalled=null,this.nudgeRetry=0)}},t._tryFixBufferStall=function(e,t){var i=this.config,r=this.fragmentTracker,s=this.media;null!==s&&(s=s.currentTime,(!(r=r.getPartialFragment(s))||!this._trySkipBufferHole(r)&&this.media)&&e.len>i.maxBufferHole&&t>1e3*i.highBufferWatchdogPeriod&&(n.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer()))},t._reportStall=function(e){var t=this.hls,i=this.media;!this.stallReported&&i&&(this.stallReported=!0,n.logger.warn("Playback stalling at @"+i.currentTime+" due to low buffer ("+JSON.stringify(e)+")"),t.trigger(a.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e.len}))},t._trySkipBufferHole=function(e){var t=this.config,i=this.hls,o=this.media;if(null===o)return 0;for(var l=o.currentTime,c=0,u=r.BufferHelper.getBuffered(o),p=0;p<u.length;p++){var f=u.start(p);if(l+t.maxBufferHole>=c&&l<f)return f=Math.max(f+h,o.currentTime+d),n.logger.warn("skipping hole, adjusting currentTime from "+l+" to "+f),this.moved=!0,this.stalled=null,o.currentTime=f,e&&i.trigger(a.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+l+" to "+f,frag:e}),f;c=u.end(p)}return 0},t._tryNudgeBuffer=function(){var e,t=this.config,i=this.hls,r=this.media,o=this.nudgeRetry;null!==r&&(e=r.currentTime,this.nudgeRetry++,o<t.nudgeMaxRetry?(o=e+(o+1)*t.nudgeOffset,n.logger.warn("Nudging 'currentTime' from "+e+" to "+o),r.currentTime=o,i.trigger(a.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})):(n.logger.error("Playhead still not moving while enough data buffered @"+e+" after "+t.nudgeMaxRetry+" nudges"),i.trigger(a.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})))},u);function u(e,t,i,r){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=r}},"./src/controller/id3-track-controller.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>p});var r=i("./src/polyfills/number.ts"),s=i("./src/events.ts"),a=i("./src/utils/texttrack-utils.ts"),n=i("./src/demux/id3.ts"),o=i("./src/loader/date-range.ts"),l=i("./src/types/demuxer.ts");function d(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var h=function(){var e=d();try{new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function c(e,t){return e.getTime()/1e3-t}function u(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}(t=u.prototype).destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},t._registerListeners=function(){var e=this.hls;e.on(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(s.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(s.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(s.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},t._unregisterListeners=function(){var e=this.hls;e.off(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(s.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(s.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(s.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},t.onMediaAttached=function(e,t){this.media=t.media},t.onMediaDetaching=function(){this.id3Track&&((0,a.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},t.onManifestLoading=function(){this.dateRangeCuesAppended={}},t.createTrack=function(e){return e=this.getID3Track(e.textTracks),e.mode="hidden",e},t.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var i=e[t];if("metadata"===i.kind&&"id3"===i.label)return(0,a.sendAddTrackEvent)(i,this.media),i}return this.media.addTextTrack("metadata","id3")}},t.onFragParsingMetadata=function(e,t){if(this.media){var i=this.hls.config,r=i.enableEmsgMetadataCues,s=i.enableID3MetadataCues;if(r||s){var a=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var o=d(),c=0;c<a.length;c++){var u=a[c].type;if((u!==l.MetadataSchema.emsg||r)&&s){var p=n.getID3Frames(a[c].data);if(p){var f=a[c].pts,m=f+a[c].duration;(m=h<m?h:m)-f<=0&&(m=f+.25);for(var g=0;g<p.length;g++){var y,A=p[g];n.isTimeStampFrame(A)||(this.updateId3CueEnds(f),(y=new o(f,m,"")).value=A,u&&(y.type=u),this.id3Track.addCue(y))}}}}}}},t.updateId3CueEnds=function(e){var t,i=null==(t=this.id3Track)?void 0:t.cues;if(i)for(var r=i.length;r--;){var s=i[r];s.startTime<e&&s.endTime===h&&(s.endTime=e)}},t.onBufferFlushing=function(e,t){var i,r,s=t.startOffset,n=t.endOffset,o=(t=t.type,this.id3Track),d=this.hls;d&&(d=d.config,i=d.enableEmsgMetadataCues,r=d.enableID3MetadataCues,o&&(i||r)&&(0,a.removeCuesInRange)(o,s,n,"audio"===t?function(e){return e.type===l.MetadataSchema.audioId3&&r}:"video"===t?function(e){return e.type===l.MetadataSchema.emsg&&i}:function(e){return e.type===l.MetadataSchema.audioId3&&r||e.type===l.MetadataSchema.emsg&&i}))},t.onLevelUpdated=function(e,t){var i=this;t=t.details;if(this.media&&t.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var s=this.dateRangeCuesAppended,a=this.id3Track,n=t.dateRanges,u=Object.keys(n);if(a)for(var p=Object.keys(s).filter((function(e){return!u.includes(e)})),f=p.length;f--;)!function(e){var t=p[e];Object.keys(s[t].cues).forEach((function(e){a.removeCue(s[t].cues[e])})),delete s[t]}(f);if(t=t.fragments[t.fragments.length-1],0!==u.length&&(0,r.isFiniteNumber)(null==t?void 0:t.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var m=t.programDateTime/1e3-t.start,g=d(),y=0;y<u.length;y++)!function(e){e=u[e];var t=n[e],r=s[e],a=(null==r?void 0:r.cues)||{},d=(null==r?void 0:r.durationKnown)||!1,p=c(t.startDate,m),f=h,y=t.endDate;y?(f=c(y,m),d=!0):t.endOnNext&&!d&&(y=u.reduce((function(e,i){var r=n[i];return r.class===t.class&&r.id!==i&&r.startDate>t.startDate&&e.push(r),e}),[]).sort((function(e,t){return e.startDate.getTime()-t.startDate.getTime()}))[0])&&(f=c(y.startDate,m),d=!0);for(var A,b=Object.keys(t.attr),v=0;v<b.length;v++){var _,w,S=b[v];S!==o.DateRangeAttribute.ID&&S!==o.DateRangeAttribute.CLASS&&S!==o.DateRangeAttribute.START_DATE&&S!==o.DateRangeAttribute.DURATION&&S!==o.DateRangeAttribute.END_DATE&&S!==o.DateRangeAttribute.END_ON_NEXT&&((w=a[S])?d&&!r.durationKnown&&(w.endTime=f):(_=t.attr[S],w=new g(p,f,""),S!==o.DateRangeAttribute.SCTE35_OUT&&S!==o.DateRangeAttribute.SCTE35_IN||(A=_,_=Uint8Array.from(A.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),w.value={key:S,data:_},w.type=l.MetadataSchema.dateRange,i.id3Track.addCue(w),a[S]=w))}s[e]={cues:a,dateRange:t,durationKnown:d}}(y)}}};const p=u},"./src/controller/latency-controller.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>o});var r=i("./src/errors.ts"),s=i("./src/events.ts"),a=i("./src/utils/logger.ts");function n(e,t){for(var i,r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,"symbol"==typeof(i=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);if(t=t.call(e,"string"),"object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(s.key))?i:String(i),s)}}(t=l.prototype).destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},t.registerListeners=function(){this.hls.on(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(s.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(s.Events.ERROR,this.onError,this)},t.unregisterListeners=function(){this.hls.off(s.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(s.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(s.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(s.Events.ERROR,this.onError)},t.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},t.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},t.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},t.onLevelUpdated=function(e,t){t=t.details,(this.levelDetails=t).advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},t.onError=function(e,t){t.details===r.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,a.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},t.timeupdate=function(){var e,t,i,r=this.media,s=this.levelDetails;r&&s&&(this.currentTime=r.currentTime,null!==(t=this.computeLatency())&&(this._latency=t,i=(e=this.config).lowLatencyMode,e=e.maxLiveSyncPlaybackRate,i&&1!==e&&null!==(i=this.targetLatency)&&(i=(t-=i)<Math.min(this.maxLatency,i+s.targetduration),s.live&&i&&.05<t&&1<this.forwardBufferLength?(s=Math.min(2,Math.max(1,e)),i=Math.round(2/(1+Math.exp(-.75*t-this.edgeStalled))*20)/20,r.playbackRate=Math.min(s,Math.max(1,i))):1!==r.playbackRate&&0!==r.playbackRate&&(r.playbackRate=1))))},t.estimateLiveEdge=function(){var e=this.levelDetails;return null===e?null:e.edge+e.age},t.computeLatency=function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime},n((t=l).prototype,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(null===e)return null;var t=e.holdBack,i=e.partHoldBack,r=(e=e.targetduration,this.config),s=r.liveSyncDuration,a=r.liveSyncDurationCount,n=(r=r.lowLatencyMode,this.hls.userConfig);r=r&&i||t;return(r=n.liveSyncDuration||n.liveSyncDurationCount||0===r?void 0!==s?s:a*e:r)+Math.min(+this.stallCount,e)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,i=this.levelDetails;if(null===e||null===t||null===i)return null;var r=i.edge;e=e-t-this.edgeStalled,t=r-i.totalduration,r-=this.config.lowLatencyMode&&i.partTarget||i.targetduration;return Math.min(Math.max(t,e),r)}},{key:"drift",get:function(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}}]),Object.defineProperty(t,"prototype",{writable:!1});var o=l;function l(e){var t=this;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=function(){return t.timeupdate()},this.hls=e,this.config=e.config,this.registerListeners()}},"./src/controller/level-controller.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>f});var r=i("./src/types/level.ts"),s=i("./src/events.ts"),a=i("./src/errors.ts"),n=i("./src/utils/codecs.ts"),o=i("./src/controller/level-helper.ts"),l=(t=i("./src/controller/base-playlist-controller.ts"),i("./src/types/loader.ts"));function d(){return(d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i,r=arguments[t];for(i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e}).apply(this,arguments)}function h(e,t){for(var i,r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,"symbol"==typeof(i=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);if(t=t.call(e,"string"),"object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(s.key))?i:String(i),s)}}function c(e,t){return(c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}var u,p=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),f=(u=t.default,i=u,(t=m).prototype=Object.create(i.prototype),c(t.prototype.constructor=t,i),(t=m.prototype)._registerListeners=function(){var e=this.hls;e.on(s.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(s.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(s.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(s.Events.ERROR,this.onError,this)},t._unregisterListeners=function(){var e=this.hls;e.off(s.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(s.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(s.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(s.Events.ERROR,this.onError,this)},t.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,u.prototype.destroy.call(this)},t.startLoad=function(){this._levels.forEach((function(e){e.loadError=0})),u.prototype.startLoad.call(this)},t.onManifestLoaded=function(e,t){var i,l,d=[],h=[],c=[],u={},f=!1,m=!1,g=!1;if(t.levels.forEach((function(e){var t=e.attrs,i=(f=f||!(!e.width||!e.height),m=m||!!e.videoCodec,g=g||!!e.audioCodec,p&&e.audioCodec&&-1!==e.audioCodec.indexOf("mp4a.40.34")&&(e.audioCodec=void 0),e.bitrate+"-"+e.attrs.RESOLUTION+"-"+e.attrs.CODECS);(l=u[i])?l.url.push(e.url):(l=new r.Level(e),u[i]=l,d.push(l)),t&&(t.AUDIO&&(0,o.addGroupId)(l,"audio",t.AUDIO),t.SUBTITLES&&(0,o.addGroupId)(l,"text",t.SUBTITLES))})),d=(d=(f||m)&&g?d.filter((function(e){var t=e.videoCodec,i=e.width;e=e.height;return!!t||!(!i||!e)})):d).filter((function(e){var t=e.audioCodec;e=e.videoCodec;return(!t||(0,n.isCodecSupportedInMp4)(t,"audio"))&&(!e||(0,n.isCodecSupportedInMp4)(e,"video"))})),t.audioTracks&&(h=t.audioTracks.filter((function(e){return!e.audioCodec||(0,n.isCodecSupportedInMp4)(e.audioCodec,"audio")})),(0,o.assignTrackIdsByGroup)(h)),t.subtitles&&(c=t.subtitles,(0,o.assignTrackIdsByGroup)(c)),0<d.length){i=d[0].bitrate,d.sort((function(e,t){return e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"]?(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1:e.bitrate!==t.bitrate?e.bitrate-t.bitrate:e.attrs.SCORE!==t.attrs.SCORE?e.attrs.decimalFloatingPoint("SCORE")-t.attrs.decimalFloatingPoint("SCORE"):f&&e.height!==t.height?e.height-t.height:0})),this._levels=d;for(var y=0;y<d.length;y++)if(d[y].bitrate===i){this._firstLevel=y,this.log("manifest loaded, "+d.length+" level(s) found, first bitrate: "+i);break}var A=g&&!m;c={levels:d,audioTracks:h,subtitleTracks:c,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:g,video:m,altAudio:!A&&h.some((function(e){return!!e.url}))};this.hls.trigger(s.Events.MANIFEST_PARSED,c),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(s.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,reason:"no level with compatible codecs found in manifest"})},t.onError=function(e,t){if(u.prototype.onError.call(this,e,t),!t.fatal){var i=t.context,s=this._levels[this.currentLevelIndex];if(i&&(i.type===l.PlaylistContextType.AUDIO_TRACK&&s.audioGroupIds&&i.groupId===s.audioGroupIds[s.urlId]||i.type===l.PlaylistContextType.SUBTITLE_TRACK&&s.textGroupIds&&i.groupId===s.textGroupIds[s.urlId]))this.redundantFailover(this.currentLevelIndex);else{var n,o,d=!1,h=!0;switch(t.details){case a.ErrorDetails.FRAG_LOAD_ERROR:case a.ErrorDetails.FRAG_LOAD_TIMEOUT:case a.ErrorDetails.KEY_LOAD_ERROR:case a.ErrorDetails.KEY_LOAD_TIMEOUT:t.frag&&(o=t.frag.type===l.PlaylistLevelType.MAIN?t.frag.level:this.currentLevelIndex,(c=this._levels[o])?(c.fragmentError++,c.fragmentError>this.hls.config.fragLoadingMaxRetry&&(n=o)):n=o);break;case a.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var c=s.attrs["HDCP-LEVEL"];c&&(this.hls.maxHdcpLevel=r.HdcpLevels[r.HdcpLevels.indexOf(c)-1],this.warn('Restricting playback to HDCP-LEVEL of "'+this.hls.maxHdcpLevel+'" or lower'));case a.ErrorDetails.FRAG_PARSING_ERROR:case a.ErrorDetails.KEY_SYSTEM_NO_SESSION:n=(null==(o=t.frag)?void 0:o.type)===l.PlaylistLevelType.MAIN?t.frag.level:this.currentLevelIndex,t.levelRetry=!1;break;case a.ErrorDetails.LEVEL_LOAD_ERROR:case a.ErrorDetails.LEVEL_LOAD_TIMEOUT:i&&(i.deliveryDirectives&&(h=!1),n=i.level),d=!0;break;case a.ErrorDetails.REMUX_ALLOC_ERROR:n=null!=(c=t.level)?c:this.currentLevelIndex,d=!0}void 0!==n&&this.recoverLevel(t,n,d,h)}}},t.recoverLevel=function(e,t,i,r){var s=e.details,a=this._levels[t];if(a.loadError++,i){if(!this.retryLoadingOrFail(e))return void(this.currentLevelIndex=-1);e.levelRetry=!0}if(r)if(i=a.url.length,1<i&&a.loadError<i)e.levelRetry=!0,this.redundantFailover(t);else if(-1===this.manualLevelIndex){for(var n=-1,o=this._levels,l=o.length;l--;){var d=(l+this.currentLevelIndex)%o.length;if(d!==this.currentLevelIndex&&0===o[d].loadError){n=d;break}}-1<n&&this.currentLevelIndex!==n?(this.warn(s+": switch to "+n),e.levelRetry=!0,this.hls.nextAutoLevel=n):!1===e.levelRetry&&(e.fatal=!0)}},t.redundantFailover=function(e){var t,i=this._levels[e],r=i.url.length;1<r&&(t=(i.urlId+1)%r,this.warn("Switching to redundant URL-id "+t),this._levels.forEach((function(e){e.urlId=t})),this.level=e)},t.onFragLoaded=function(e,t){t=t.frag;void 0!==t&&t.type===l.PlaylistLevelType.MAIN&&void 0!==(t=this._levels[t.level])&&(t.fragmentError=0,t.loadError=0)},t.onLevelLoaded=function(e,t){var i,r=t.level,s=t.details,a=this._levels[r];if(!a)return this.warn("Invalid level index "+r),void(null!=(i=t.deliveryDirectives)&&i.skip&&(s.deltaUpdateFailed=!0));r===this.currentLevelIndex?(0===a.fragmentError&&(a.loadError=0,this.retryCount=0),this.playlistLoaded(r,t,a.details)):null!=(i=t.deliveryDirectives)&&i.skip&&(s.deltaUpdateFailed=!0)},t.onAudioTrackSwitched=function(e,t){var i=this.hls.levels[this.currentLevelIndex];if(i&&i.audioGroupIds){for(var r=-1,s=this.hls.audioTracks[t.id].groupId,a=0;a<i.audioGroupIds.length;a++)if(i.audioGroupIds[a]===s){r=a;break}r!==i.urlId&&(i.urlId=r,this.startLoad())}},t.loadPlaylist=function(e){u.prototype.loadPlaylist.call(this);var t=this.currentLevelIndex,i=this._levels[t];if(this.canLoad&&i&&0<i.url.length){var r=i.urlId;i=i.url[r];if(e)try{i=e.addDirectives(i)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log("Attempt loading level index "+t+(void 0!==(null==e?void 0:e.msn)?" at sn "+e.msn+" part "+e.part:"")+" with URL-id "+r+" "+i),this.clearTimer(),this.hls.trigger(s.Events.LEVEL_LOADING,{url:i,level:t,id:r,deliveryDirectives:e||null})}},t.removeLevel=function(e,t){function i(e,i){return i!==t}var r=this._levels.filter((function(r,s){return s!==e||1<r.url.length&&void 0!==t&&(r.url=r.url.filter(i),r.audioGroupIds&&(r.audioGroupIds=r.audioGroupIds.filter(i)),r.textGroupIds&&(r.textGroupIds=r.textGroupIds.filter(i)),!(r.urlId=0))})).map((function(e,t){var i=e.details;return null!=i&&i.fragments&&i.fragments.forEach((function(e){e.level=t})),e}));this._levels=r,this.hls.trigger(s.Events.LEVELS_UPDATED,{levels:r})},h((i=m).prototype,[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;if(0!==t.length&&(this.currentLevelIndex!==e||null==(i=t[e])||!i.details)){if(e<0||e>=t.length){var i=e<0;if(this.hls.trigger(s.Events.ERROR,{type:a.ErrorTypes.OTHER_ERROR,details:a.ErrorDetails.LEVEL_SWITCH_ERROR,level:e,fatal:i,reason:"invalid level idx"}),i)return;e=Math.min(e,t.length-1)}this.clearTimer();i=this.currentLevelIndex;var r=t[i];t=t[e],i=(this.log("switching to level "+e+" from "+i),d({},t,{level:this.currentLevelIndex=e,maxBitrate:t.maxBitrate,uri:t.uri,urlId:t.urlId})),e=(delete i._urlId,this.hls.trigger(s.Events.LEVEL_SWITCHING,i),t.details);e&&!e.live||(i=this.switchParams(t.uri,null==r?void 0:r.details),this.loadPlaylist(i))}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){var e;return void 0===this._startLevel?void 0!==(e=this.hls.config.startLevel)?e:this._firstLevel:this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}]),Object.defineProperty(i,"prototype",{writable:!1}),m);function m(e){return(e=u.call(this,e,"[level-controller]")||this)._levels=[],e._firstLevel=-1,e._startLevel=void 0,e.currentLevelIndex=-1,e.manualLevelIndex=-1,e.onParsedComplete=void 0,e._registerListeners(),e}},"./src/controller/level-helper.ts":(e,t,i)=>{i.r(t),i.d(t,{addGroupId:()=>function(e,t,i){switch(t){case"audio":e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds.push(i);break;case"text":e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds.push(i)}},addSliding:()=>u,adjustSliding:()=>c,assignTrackIdsByGroup:()=>function(e){var t={};e.forEach((function(e){var i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++}))},computeReloadInterval:()=>function(e,t){void 0===t&&(t=1/0);var i=1e3*e.targetduration;return e.updated?(e=e.fragments).length&&t<4*i&&(t=1e3*e[e.length-1].duration)<i&&(i=t):i/=2,Math.round(i)},getFragmentWithSN:()=>function(e,t,i){if(!e||!e.details)return null;var r;e=e.details;return(r=e.fragments[t-e.startSN])||((r=e.fragmentHint)&&r.sn===t?r:t<e.startSN&&i&&i.sn===t?i:null)},getPartWith:()=>function(e,t,i){if(!e||!e.details)return null;var r=e.details.partList;if(r)for(var s=r.length;s--;){var a=r[s];if(a.index===i&&a.fragment.sn===t)return a}return null},mapFragmentIntersection:()=>h,mapPartIntersection:()=>d,mergeDetails:()=>function(e,t){for(var i=null,o=e.fragments,u=o.length-1;0<=u;u--){var p=o[u].initSegment;if(p){i=p;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;var f,m,g,y=0;if(h(e,t,(function(e,s){e.relurl&&(y=e.cc-s.cc),(0,r.isFiniteNumber)(e.startPTS)&&(0,r.isFiniteNumber)(e.endPTS)&&(s.start=s.startPTS=e.startPTS,s.startDTS=e.startDTS,s.appendedPTS=e.appendedPTS,s.maxStartPTS=e.maxStartPTS,s.endPTS=e.endPTS,s.endDTS=e.endDTS,s.minEndPTS=e.minEndPTS,s.duration=e.endPTS-e.startPTS,s.duration&&(f=s),t.PTSKnown=t.alignedSliding=!0),s.elementaryStreams=e.elementaryStreams,s.loader=e.loader,s.stats=e.stats,s.urlId=e.urlId,e.initSegment&&(s.initSegment=e.initSegment,i=e.initSegment)})),i&&(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach((function(e){var t;e.initSegment&&e.initSegment.relurl!==(null==(t=i)?void 0:t.relurl)||(e.initSegment=i)})),t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some((function(e){return!e})),t.deltaUpdateFailed){s.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var A=t.skippedSegments;A--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=(w=e.dateRanges,m=t.dateRanges,_=t.recentlyRemovedDateranges,g=n({},w),_&&_.forEach((function(e){delete g[e]})),Object.keys(m).forEach((function(e){var t=new a.DateRange(m[e].attr,g[e]);t.isValid?g[e]=t:s.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(m[e].attr)+'"')})),g));var b=t.fragments;if(y){s.logger.warn("discontinuity sliding from playlist, take drift into account");for(var v=0;v<b.length;v++)b[v].cc+=y}t.skippedSegments&&(t.startCC=t.fragments[0].cc),d(e.partList,t.partList,(function(e,t){t.elementaryStreams=e.elementaryStreams,t.stats=e.stats})),f?l(t,f,f.startPTS,f.endPTS,f.startDTS,f.endDTS):c(e,t),b.length&&(t.totalduration=t.edge-b[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var _,w=t.advancedDateTime;t.advanced&&w?(_=t.edge,t.driftStart||(t.driftStartTime=w,t.driftStart=_),t.driftEndTime=w,t.driftEnd=_):(t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime)},updateFragPTSDTS:()=>l,updatePTS:()=>function(e,t,i){o(e[t],e[i])}});var r=i("./src/polyfills/number.ts"),s=i("./src/utils/logger.ts"),a=i("./src/loader/date-range.ts");function n(){return(n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i,r=arguments[t];for(i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e}).apply(this,arguments)}function o(e,t){var i,s=t.startPTS;(0,r.isFiniteNumber)(s)?(i=0,(s=t.sn>e.sn?(i=s-e.start,e):(i=e.start-s,t)).duration!==i&&(s.duration=i)):t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.start=e.start+(e.minEndPTS-e.start):t.start=e.start+e.duration:t.start=Math.max(e.start-t.duration,0)}function l(e,t,i,a,n,l){a-i<=0&&(s.logger.warn("Fragment should have a positive duration",t),a=i+t.duration,l=n+t.duration);var d=i,h=a,c=t.startPTS,u=t.endPTS,p=((0,r.isFiniteNumber)(c)&&(p=Math.abs(c-i),(0,r.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(p,t.deltaPTS):t.deltaPTS=p,d=Math.max(i,c),i=Math.min(i,c),n=Math.min(n,t.startDTS),h=Math.min(a,u),a=Math.max(a,u),l=Math.max(l,t.endDTS)),t.duration=a-i,i-t.start);t.start=t.startPTS=i,t.maxStartPTS=d,t.startDTS=n,t.endPTS=a,t.minEndPTS=h,t.endDTS=l;var f;c=t.sn;if(!e||c<e.startSN||c>e.endSN)return 0;u=c-e.startSN;var m=e.fragments;for(m[u]=t,f=u;0<f;f--)o(m[f],m[f-1]);for(f=u;f<m.length-1;f++)o(m[f],m[f+1]);return e.fragmentHint&&o(m[m.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,p}function d(e,t,i){if(e&&t)for(var r=0,s=0,a=e.length;s<=a;s++){var n=e[s],o=t[s+r];n&&o&&n.index===o.index&&n.fragment.sn===o.fragment.sn?i(n,o):r--}}function h(e,t,i){for(var r=t.skippedSegments,s=Math.max(e.startSN,t.startSN)-t.startSN,a=(e.fragmentHint?1:0)+(r?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,n=t.startSN-e.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,d=s;d<=a;d++){var h=l[n+d],c=o[d];r&&!c&&d<r&&(c=t.fragments[d]=h),h&&c&&i(h,c)}}function c(e,t){var i=t.startSN+t.skippedSegments-e.startSN;e=e.fragments;i<0||i>=e.length||u(t,e[i].start)}function u(e,t){if(t){for(var i=e.fragments,r=e.skippedSegments;r<i.length;r++)i[r].start+=t;e.fragmentHint&&(e.fragmentHint.start+=t)}}},"./src/controller/stream-controller.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>A});var r=i("./src/polyfills/number.ts"),s=i("./src/controller/base-stream-controller.ts"),a=i("./src/is-supported.ts"),n=i("./src/events.ts"),o=i("./src/utils/buffer-helper.ts"),l=i("./src/controller/fragment-tracker.ts"),d=i("./src/types/loader.ts"),h=i("./src/loader/fragment.ts"),c=i("./src/demux/transmuxer-interface.ts"),u=i("./src/types/transmuxer.ts"),p=i("./src/controller/gap-controller.ts"),f=i("./src/errors.ts");function m(e,t){for(var i,r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,"symbol"==typeof(i=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);if(t=t.call(e,"string"),"object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(s.key))?i:String(i),s)}}function g(e,t){return(g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}y=s.default,t=y,(i=b).prototype=Object.create(t.prototype),g(i.prototype.constructor=i,t),(i=b.prototype)._registerListeners=function(){var e=this.hls;e.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(n.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(n.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(n.Events.ERROR,this.onError,this),e.on(n.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(n.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(n.Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(n.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(n.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(n.Events.FRAG_BUFFERED,this.onFragBuffered,this)},i._unregisterListeners=function(){var e=this.hls;e.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(n.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(n.Events.ERROR,this.onError,this),e.off(n.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(n.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(n.Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(n.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(n.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(n.Events.FRAG_BUFFERED,this.onFragBuffered,this)},i.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},i.startLoad=function(e){var t,i,r;this.levels?(t=this.lastCurrentTime,i=this.hls,this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,this.startFragRequested||(-1===(r=i.startLevel)&&(i.config.testBandwidth&&1<this.levels.length?this.bitrateTest=!(r=0):r=i.nextAutoLevel),this.level=i.nextLoadLevel=r,this.loadedmetadata=!1),0<t&&-1===e&&(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=s.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()):(this._forceStartLoad=!0,this.state=s.State.STOPPED)},i.stopLoad=function(){this._forceStartLoad=!1,y.prototype.stopLoad.call(this)},i.doTick=function(){switch(this.state){case s.State.IDLE:this.doTickIdle();break;case s.State.WAITING_LEVEL:var e=this.levels,t=this.level;t=null==e||null==(e=e[t])?void 0:e.details;if(!t||t.live&&this.levelLastLoaded!==this.level)break;if(this.waitForCdnTuneIn(t))break;this.state=s.State.IDLE;break;case s.State.FRAG_LOADING_WAITING_RETRY:e=self.performance.now(),t=this.retryDate,(!t||t<=e||null!=(t=this.media)&&t.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=s.State.IDLE)}this.onTickEnd()},i.onTickEnd=function(){y.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},i.doTickIdle=function(){var e=this.hls,t=this.levelLastLoaded,i=this.levels,r=this.media,a=e.config,o=e.nextLoadLevel;if(null!==t&&(r||!this.startFragRequested&&a.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&i&&i[o]&&(t=i[o],r=this.getMainFwdBufferInfo(),null!==r)){if(a=this.getLevelDetails(),a&&this._streamEnded(r,a))return i={},this.altAudio&&(i.type="video"),this.hls.trigger(n.Events.BUFFER_EOS,i),void(this.state=s.State.ENDED);if(this.level=e.nextLoadLevel=o,a=t.details,!a||this.state===s.State.WAITING_LEVEL||a.live&&this.levelLastLoaded!==o)return this.level=o,void(this.state=s.State.WAITING_LEVEL);r.len>=this.getMaxBufferLength(t.maxBitrate)||(this.backtrackFragment&&this.backtrackFragment.start>r.end&&(this.backtrackFragment=null),i=this.backtrackFragment?this.backtrackFragment.start:r.end,e=this.getNextFragment(i,a),this.couldBacktrack&&!this.fragPrevious&&e&&"initSegment"!==e.sn&&this.fragmentTracker.getState(e)!==l.FragmentState.OK?(t=(null!=(o=this.backtrackFragment)?o:e).sn-a.startSN,(o=a.fragments[t-1])&&e.cc===o.cc&&this.fragmentTracker.removeFragment(e=o)):this.backtrackFragment&&r.len&&(this.backtrackFragment=null),e&&this.fragmentTracker.getState(e)===l.FragmentState.OK&&this.nextLoadPosition>i&&((o=((t=this.audioOnly&&!this.altAudio?h.ElementaryStreamTypes.AUDIO:h.ElementaryStreamTypes.VIDEO)===h.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media)&&this.afterBufferFlushed(o,t,d.PlaylistLevelType.MAIN),e=this.getNextFragment(this.nextLoadPosition,a)),e&&(!e.initSegment||e.initSegment.data||this.bitrateTest||(e=e.initSegment),this.loadFragment(e,a,i)))}},i.loadFragment=function(e,t,i){var r=this.fragmentTracker.getState(e);this.fragCurrent=e,r===l.FragmentState.NOT_LOADED?"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,y.prototype.loadFragment.call(this,e,t,i)):r===l.FragmentState.APPENDING?this.reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e):0===(null==(t=this.media)?void 0:t.buffered.length)&&this.fragmentTracker.removeAllFragments()},i.getAppendedFrag=function(e){return e=this.fragmentTracker.getAppendedFrag(e,d.PlaylistLevelType.MAIN),e&&"fragment"in e?e.fragment:e},i.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,d.PlaylistLevelType.MAIN)},i.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},i.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},i.nextLevelSwitch=function(){var e,t=this.levels,i=this.media;null!=i&&i.readyState&&((e=this.getAppendedFrag(i.currentTime))&&1<e.start&&this.flushMainBuffer(0,e.start-1),e=!i.paused&&t?(e=t[this.hls.nextLoadLevel],(t=this.fragLastKbps)&&this.fragCurrent?this.fragCurrent.duration*e.maxBitrate/(1e3*t)+1:0):0,(t=this.getBufferedFrag(i.currentTime+e))&&(i=this.followingBufferedFrag(t))&&(this.abortCurrentFrag(),e=i.maxStartPTS||i.start,i=i.duration,t=Math.max(t.end,e+Math.min(Math.max(i-this.config.maxFragLookUpTolerance,.5*i),.75*i)),this.flushMainBuffer(t,Number.POSITIVE_INFINITY)))},i.abortCurrentFrag=function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&e.abortRequests(),this.state){case s.State.KEY_LOADING:case s.State.FRAG_LOADING:case s.State.FRAG_LOADING_WAITING_RETRY:case s.State.PARSING:case s.State.PARSED:this.state=s.State.IDLE}this.nextLoadPosition=this.getLoadPosition()},i.flushMainBuffer=function(e,t){y.prototype.flushMainBuffer.call(this,e,t,this.altAudio?"video":null)},i.onMediaAttached=function(e,t){y.prototype.onMediaAttached.call(this,e,t),e=t.media,this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),e.addEventListener("playing",this.onvplaying),e.addEventListener("seeked",this.onvseeked),this.gapController=new p.default(this.config,e,this.fragmentTracker,this.hls)},i.onMediaDetaching=function(){var e=this.media;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),y.prototype.onMediaDetaching.call(this)},i.onMediaPlaying=function(){this.tick()},i.onMediaSeeked=function(){var e=this.media;e=e?e.currentTime:null;(0,r.isFiniteNumber)(e)&&this.log("Media seeked to "+e.toFixed(3)),this.tick()},i.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(n.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},i.onManifestParsed=function(e,t){var i,r=!1,s=!1;t.levels.forEach((function(e){(i=e.audioCodec)&&(-1!==i.indexOf("mp4a.40.2")&&(r=!0),-1!==i.indexOf("mp4a.40.5")&&(s=!0))})),this.audioCodecSwitch=r&&s&&!(0,a.changeTypeSupported)(),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},i.onLevelLoading=function(e,t){var i=this.levels;i&&this.state===s.State.IDLE&&(!(i=i[t.level]).details||i.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(i.details))&&(this.state=s.State.WAITING_LEVEL)},i.onLevelLoaded=function(e,t){var i=this.levels,r=t.level,a=t.details,o=a.totalduration;if(i){if(this.log("Level "+r+" loaded ["+a.startSN+","+a.endSN+"], cc ["+a.startCC+", "+a.endCC+"] duration:"+o),o=this.fragCurrent,!o||this.state!==s.State.FRAG_LOADING&&this.state!==s.State.FRAG_LOADING_WAITING_RETRY||o.level!==t.level&&o.loader&&(this.state=s.State.IDLE,this.backtrackFragment=null,o.abortRequests()),t=i[r],o=0,a.live||null!=(i=t.details)&&i.live){if(a.fragments[0]||(a.deltaUpdateFailed=!0),a.deltaUpdateFailed)return;o=this.alignPlaylists(a,t.details)}if(t.details=a,this.levelLastLoaded=r,this.hls.trigger(n.Events.LEVEL_UPDATED,{details:a,level:r}),this.state===s.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=s.State.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,o),this.tick()}else this.warn("Levels were reset while loading level "+r)},i._handleFragmentLoadProgress=function(e){var t,i,r,s,a,n,o,l=e.frag,h=e.part,p=(e=e.payload,this.levels);p?(t=(p=p[l.level]).details)?(i=p.videoCodec,r=t.PTSKnown||!t.live,s=null==(s=l.initSegment)?void 0:s.data,p=this._getAudioCodec(p),a=this.transmuxer=this.transmuxer||new c.default(this.hls,d.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),n=h?h.index:-1,n=new u.ChunkMetadata(l.level,l.sn,l.stats.chunkCount,e.byteLength,n,-1!==n),o=this.initPTS[l.cc],a.push(e,s,p,i,l,h,t.totalduration,r,n,o)):this.warn("Dropping fragment "+l.sn+" of level "+l.level+" after level details were reset"):this.warn("Levels were reset while fragment load was in progress. Fragment "+l.sn+" of level "+l.level+" will not be buffered")},i.onAudioTrackSwitching=function(e,t){var i=this.altAudio,r=!!t.url;t=t.id;r||(this.mediaBuffer!==this.media?(this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media,(r=this.fragCurrent)&&(this.log("Switching to main audio track, cancel main fragment load"),r.abortRequests()),this.resetTransmuxer(),this.resetLoadingState()):this.audioOnly&&this.resetTransmuxer(),r=this.hls,i&&r.trigger(n.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),r.trigger(n.Events.AUDIO_TRACK_SWITCHED,{id:t}))},i.onAudioTrackSwitched=function(e,t){var i;t=t.id,t=!!this.hls.audioTracks[t].url;t&&(i=this.videoBuffer)&&this.mediaBuffer!==i&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i),this.altAudio=t,this.tick()},i.onBufferCreated=function(e,t){var i,r=t.tracks,s=!1;for(i in r){var a,n,o=r[i];"main"===o.id?(n=o,"video"===(a=i)&&(o=r[i])&&(this.videoBuffer=o.buffer)):s=!0}s&&n?(this.log("Alternate track found, use "+a+".buffered to schedule main fragment loading"),this.mediaBuffer=n.buffer):this.mediaBuffer=this.media},i.onFragBuffered=function(e,t){var i=t.frag;t=t.part;if(!i||i.type===d.PlaylistLevelType.MAIN){if(this.fragContextChanged(i))return this.warn("Fragment "+i.sn+(t?" p: "+t.index:"")+" of level "+i.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===s.State.PARSED&&(this.state=s.State.IDLE));var r=(t||i).stats;this.fragLastKbps=Math.round(8*r.total/(r.buffering.end-r.loading.first)),"initSegment"!==i.sn&&(this.fragPrevious=i),this.fragBufferedComplete(i,t)}},i.onError=function(e,t){if(t.type!==f.ErrorTypes.KEY_SYSTEM_ERROR)switch(t.details){case f.ErrorDetails.FRAG_LOAD_ERROR:case f.ErrorDetails.FRAG_LOAD_TIMEOUT:case f.ErrorDetails.FRAG_PARSING_ERROR:case f.ErrorDetails.KEY_LOAD_ERROR:case f.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(d.PlaylistLevelType.MAIN,t);break;case f.ErrorDetails.LEVEL_LOAD_ERROR:case f.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==s.State.ERROR&&(t.fatal?(this.warn(""+t.details),this.state=s.State.ERROR):t.levelRetry||this.state!==s.State.WAITING_LEVEL||(this.state=s.State.IDLE));break;case f.ErrorDetails.BUFFER_FULL_ERROR:var i,r;"main"!==t.parent||this.state!==s.State.PARSING&&this.state!==s.State.PARSED||(i=!0,(i=(r=this.getFwdBufferInfo(this.media,d.PlaylistLevelType.MAIN))&&.5<r.len?!this.reduceMaxBufferLength(r.len):i)&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState())}else this.onFragmentOrKeyLoadError(d.PlaylistLevelType.MAIN,t)},i.checkBuffer=function(){var e,t=this.media,i=this.gapController;t&&i&&t.readyState&&(!this.loadedmetadata&&o.BufferHelper.getBuffered(t).length||(e=this.state!==s.State.IDLE?this.fragCurrent:null,i.poll(this.lastCurrentTime,e)),this.lastCurrentTime=t.currentTime)},i.onFragLoadEmergencyAborted=function(){this.state=s.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},i.onBufferFlushed=function(e,t){var i;t=t.type;(t!==h.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio)&&(i=(t===h.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media,this.afterBufferFlushed(i,t,d.PlaylistLevelType.MAIN))},i.onLevelsUpdated=function(e,t){this.levels=t.levels},i.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},i.seekToStartPos=function(){var e,t,i,r=this.media;r&&(e=r.currentTime,0<=(t=this.startPosition)&&e<t&&(r.seeking?this.log("could not seek to "+t+", already seeking at "+e):(0<(i=((i=o.BufferHelper.getBuffered(r)).length?i.start(0):0)-t)&&(i<this.config.maxBufferHole||i<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+i+" to match buffer start"),this.startPosition=t+=i),this.log("seek to target start position "+t+" from current time "+e),r.currentTime=t)))},i._getAudioCodec=function(e){return e=this.config.defaultAudioCodec||e.audioCodec,this.audioCodecSwap&&e&&(this.log("Swapping audio codec"),e=-1!==e.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),e},i._loadBitrateTestFrag=function(e,t){var i=this;e.bitrateTest=!0,this._doFragLoad(e,t).then((function(t){var r,a=i.hls;t&&!i.fragContextChanged(e)&&(i.fragLoadError=0,i.state=s.State.IDLE,i.startFragRequested=!1,i.bitrateTest=!1,(r=e.stats).parsing.start=r.parsing.end=r.buffering.start=r.buffering.end=self.performance.now(),a.trigger(n.Events.FRAG_LOADED,t),e.bitrateTest=!1)}))},i._handleTransmuxComplete=function(e){var t="main",i=this.hls,a=e.remuxResult,o=(e=e.chunkMeta,this.getCurrentContext(e));if(!o)return this.warn("The loading context changed while buffering fragment "+e.sn+" of level "+e.level+". This chunk will not be buffered."),void this.resetStartWhenNotLoaded(e.level);var l=o.frag,d=o.part,c=(o=o.level,a.video),u=a.text,p=a.id3,f=a.initSegment,m=o.details,g=this.altAudio?void 0:a.audio;if(!this.fragContextChanged(l)){if(this.state=s.State.PARSING,f&&(f.tracks&&(this._bufferInitSegment(o,f.tracks,l,e),i.trigger(n.Events.FRAG_PARSING_INIT_SEGMENT,{frag:l,id:t,tracks:f.tracks})),o=f.initPTS,f=f.timescale,(0,r.isFiniteNumber)(o)&&(this.initPTS[l.cc]=o,i.trigger(n.Events.INIT_PTS_FOUND,{frag:l,id:t,initPTS:o,timescale:f}))),c&&!1!==a.independent){if(m){o=c.startPTS,f=c.endPTS;var y=c.startDTS,A=c.endDTS;if(d)d.elementaryStreams[c.type]={startPTS:o,endPTS:f,startDTS:y,endDTS:A};else if(c.firstKeyFrame&&c.independent&&1===e.id&&(this.couldBacktrack=!0),c.dropped&&c.independent){var b=this.getMainFwdBufferInfo();if((b?b.end:this.getLoadPosition())+this.config.maxBufferHole<(c.firstKeyFramePTS||o)-this.config.maxBufferHole)return void this.backtrack(l);l.setElementaryStreamInfo(c.type,l.start,f,l.start,A,!0)}l.setElementaryStreamInfo(c.type,o,f,y,A),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(c,l,d,e)}}else if(!1===a.independent)return void this.backtrack(l);g&&(b=g.startPTS,o=g.endPTS,f=g.startDTS,y=g.endDTS,d&&(d.elementaryStreams[h.ElementaryStreamTypes.AUDIO]={startPTS:b,endPTS:o,startDTS:f,endDTS:y}),l.setElementaryStreamInfo(h.ElementaryStreamTypes.AUDIO,b,o,f,y),this.bufferFragmentData(g,l,d,e)),m&&null!=p&&null!=(A=p.samples)&&A.length&&(c={id:t,frag:l,details:m,samples:p.samples},i.trigger(n.Events.FRAG_PARSING_METADATA,c)),m&&u&&(a={id:t,frag:l,details:m,samples:u.samples},i.trigger(n.Events.FRAG_PARSING_USERDATA,a))}},i._bufferInitSegment=function(e,t,i,r){var a,o,l,d,h,c=this;this.state===s.State.PARSING&&(this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio,a=t.audio,o=t.video,l=t.audiovideo,a&&(d=e.audioCodec,h=navigator.userAgent.toLowerCase(),this.audioCodecSwitch&&(d=d&&(-1!==d.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),1!==a.metadata.channelCount&&-1===h.indexOf("firefox")&&(d="mp4a.40.5")),-1!==h.indexOf("android")&&"audio/mpeg"!==a.container&&this.log("Android: force audio codec to "+(d="mp4a.40.2")),e.audioCodec&&e.audioCodec!==d&&this.log('Swapping manifest audio codec "'+e.audioCodec+'" for "'+d+'"'),a.levelCodec=d,a.id="main",this.log("Init audio buffer, container:"+a.container+", codecs[selected/level/parsed]=["+(d||"")+"/"+(e.audioCodec||"")+"/"+a.codec+"]")),o&&(o.levelCodec=e.videoCodec,o.id="main",this.log("Init video buffer, container:"+o.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+o.codec+"]")),l&&this.log("Init audiovideo buffer, container:"+l.container+", codecs[level/parsed]=["+(e.attrs.CODECS||"")+"/"+l.codec+"]"),this.hls.trigger(n.Events.BUFFER_CODECS,t),Object.keys(t).forEach((function(e){var s=t[e].initSegment;null!=s&&s.byteLength&&c.hls.trigger(n.Events.BUFFER_APPENDING,{type:e,data:s,frag:i,part:null,chunkMeta:r,parent:i.type})})),this.tick())},i.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer||this.media,d.PlaylistLevelType.MAIN)},i.backtrack=function(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=s.State.IDLE},i.checkFragmentChanged=function(){var e,t=this.media,i=null;t&&1<t.readyState&&!1===t.seeking&&(e=t.currentTime,o.BufferHelper.isBuffered(t,e)?i=this.getAppendedFrag(e):o.BufferHelper.isBuffered(t,e+.1)&&(i=this.getAppendedFrag(e+.1)),i&&(this.backtrackFragment=null,t=this.fragPlaying,e=i.level,t&&i.sn===t.sn&&t.level===e&&i.urlId===t.urlId||(this.fragPlaying=i,this.hls.trigger(n.Events.FRAG_CHANGED,{frag:i}),t&&t.level===e||this.hls.trigger(n.Events.LEVEL_SWITCHED,{level:e}))))},m((t=b).prototype,[{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}},{key:"currentProgramDateTime",get:function(){var e=this.media;if(e){e=e.currentTime;var t=this.currentFrag;if(t&&(0,r.isFiniteNumber)(e)&&(0,r.isFiniteNumber)(t.programDateTime))return e=t.programDateTime+1e3*(e-t.start),new Date(e)}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),Object.defineProperty(t,"prototype",{writable:!1});var y,A=b;function b(e,t,i){return(e=y.call(this,e,t,i,"[stream-controller]")||this).audioCodecSwap=!1,e.gapController=null,e.level=-1,e._forceStartLoad=!1,e.altAudio=!1,e.audioOnly=!1,e.fragPlaying=null,e.onvplaying=null,e.onvseeked=null,e.fragLastKbps=0,e.couldBacktrack=!1,e.backtrackFragment=null,e.audioCodecSwitch=!1,e.videoBuffer=null,e._registerListeners(),e}},"./src/controller/subtitle-stream-controller.ts":(e,t,i)=>{i.r(t),i.d(t,{SubtitleStreamController:()=>m});var r=i("./src/events.ts"),s=i("./src/utils/buffer-helper.ts"),a=i("./src/controller/fragment-finders.ts"),n=i("./src/utils/discontinuities.ts"),o=i("./src/controller/level-helper.ts"),l=i("./src/controller/fragment-tracker.ts"),d=i("./src/controller/base-stream-controller.ts"),h=i("./src/types/loader.ts"),c=i("./src/types/level.ts");function u(e,t){for(var i,r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,"symbol"==typeof(i=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);if(t=t.call(e,"string"),"object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(s.key))?i:String(i),s)}}function p(e,t){return(p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}f=d.default,t=f,(i=y).prototype=Object.create(t.prototype),p(i.prototype.constructor=i,t),(i=y.prototype).onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var e=this.hls;e.on(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(r.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(r.Events.ERROR,this.onError,this),e.on(r.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(r.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(r.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(r.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(r.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(r.Events.FRAG_BUFFERED,this.onFragBuffered,this)},i._unregisterListeners=function(){var e=this.hls;e.off(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(r.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(r.Events.ERROR,this.onError,this),e.off(r.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(r.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(r.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(r.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(r.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(r.Events.FRAG_BUFFERED,this.onFragBuffered,this)},i.startLoad=function(e){this.stopLoad(),this.state=d.State.IDLE,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},i.onLevelLoaded=function(e,t){this.mainDetails=t.details},i.onSubtitleFragProcessed=function(e,t){var i=t.frag;t=t.success;if(this.fragPrevious=i,this.state=d.State.IDLE,t){var r=this.tracksBuffered[this.currentTrackId];if(r){for(var s,a=i.start,n=0;n<r.length;n++)if(a>=r[n].start&&a<=r[n].end){s=r[n];break}t=i.start+i.duration,s?s.end=t:r.push(s={start:a,end:t}),this.fragmentTracker.fragBuffered(i)}}},i.onBufferFlushing=function(e,t){var i,r,s,a=t.startOffset,n=t.endOffset;0===a&&n!==Number.POSITIVE_INFINITY&&(i=this.currentTrackId,(r=this.levels).length&&r[i]&&r[i].details&&((s=n-r[i].details.targetduration)<=0||(t.endOffsetSubtitles=Math.max(0,s),this.tracksBuffered.forEach((function(e){for(var t=0;t<e.length;)if(e[t].end<=s)e.shift();else{if(!(e[t].start<s))break;e[t].start=s,t++}})),this.fragmentTracker.removeFragmentsInRange(a,s,h.PlaylistLevelType.SUBTITLE))))},i.onFragBuffered=function(e,t){this.loadedmetadata||t.frag.type!==h.PlaylistLevelType.MAIN||null!=(t=this.media)&&t.buffered.length&&(this.loadedmetadata=!0)},i.onError=function(e,t){t=t.frag,t&&t.type===h.PlaylistLevelType.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state=d.State.IDLE)},i.onSubtitleTracksUpdated=function(e,t){var i=this;t=t.subtitleTracks;this.tracksBuffered=[],this.levels=t.map((function(e){return new c.Level(e)})),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach((function(e){i.tracksBuffered[e.id]=[]})),this.mediaBuffer=null},i.onSubtitleTrackSwitch=function(e,t){this.currentTrackId=t.id,this.levels.length&&-1!==this.currentTrackId?(null!=(t=this.levels[this.currentTrackId])&&t.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,t&&this.setInterval(500)):this.clearInterval()},i.onSubtitleTrackLoaded=function(e,t){var i=t.details,r=(t=t.id,this.currentTrackId),s=this.levels;if(s.length){var l=s[r];if(!(t>=s.length||t!==r)&&l){if(this.mediaBuffer=this.mediaBufferTimeRanges,s=0,i.live||null!=(r=l.details)&&r.live){if(r=this.mainDetails,i.deltaUpdateFailed||!r)return;var h=r.fragments[0];l.details?0===(s=this.alignPlaylists(i,l.details))&&h&&(s=h.start,(0,o.addSliding)(i,s)):i.hasProgramDateTime&&r.hasProgramDateTime?((0,n.alignMediaPlaylistByPDT)(i,r),s=i.fragments[0].start):h&&(s=h.start,(0,o.addSliding)(i,s))}l.details=i,this.levelLastLoaded=t,this.startFragRequested||!this.mainDetails&&i.live||this.setStartPosition(l.details,s),this.tick(),!i.live||this.fragCurrent||!this.media||this.state!==d.State.IDLE||(0,a.findFragmentByPTS)(null,i.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0)}}},i._handleFragmentLoadComplete=function(e){var t,i=this,s=e.frag,a=(e=e.payload,s.decryptdata),n=this.hls;!this.fragContextChanged(s)&&e&&0<e.byteLength&&a&&a.key&&a.iv&&"AES-128"===a.method&&(t=performance.now(),this.decrypter.decrypt(new Uint8Array(e),a.key.buffer,a.iv.buffer).then((function(e){var i=performance.now();n.trigger(r.Events.FRAG_DECRYPTED,{frag:s,payload:e,stats:{tstart:t,tdecrypt:i}})})).catch((function(e){i.warn(e.name+": "+e.message),i.state=d.State.IDLE})))},i.doTick=function(){var e,t,i,r,n,o,c,u;this.media?this.state===d.State.IDLE&&(u=this.currentTrackId,(e=this.levels).length&&e[u]&&e[u].details&&(u=(e=e[u].details).targetduration,t=this.config,r=this.getLoadPosition(),i=(r=s.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],r-u,t.maxBufferHole)).end,r=r.len,n=this.getFwdBufferInfo(this.media,h.PlaylistLevelType.MAIN),r>this.getMaxBufferLength(null==n?void 0:n.len)+u||(console.assert(e,"Subtitle track details are defined on idle subtitle stream controller tick"),n=(r=e.fragments).length,u=e.edge,o=null,c=this.fragPrevious,i<u?(u=t.maxFragLookUpTolerance,!(o=(0,a.findFragmentByPTS)(c,r,Math.max(r[0].start,i),u))&&c&&c.start<r[0].start&&(o=r[0])):o=r[n-1],o&&(o=this.mapToInitFragWhenRequired(o),this.fragmentTracker.getState(o)===l.FragmentState.NOT_LOADED&&this.loadFragment(o,e,i))))):this.state=d.State.IDLE},i.getMaxBufferLength=function(e){var t=f.prototype.getMaxBufferLength.call(this);return e?Math.max(t,e):t},i.loadFragment=function(e,t,i){"initSegment"===(this.fragCurrent=e).sn?this._loadInitSegment(e,t):(this.startFragRequested=!0,f.prototype.loadFragment.call(this,e,t,i))},u((t=y).prototype,[{key:"mediaBufferTimeRanges",get:function(){return new g(this.tracksBuffered[this.currentTrackId]||[])}}]),Object.defineProperty(t,"prototype",{writable:!1});var f,m=y,g=function(e){function t(t,i,r){if((i>>>=0)>r-1)throw new DOMException("Failed to execute '"+t+"' on 'TimeRanges': The index provided ("+i+") is greater than the maximum bound ("+r+")");return e[i][t]}this.buffered=void 0,this.buffered={get length(){return e.length},end:function(i){return t("end",i,e.length)},start:function(i){return t("start",i,e.length)}}};function y(e,t,i){return(e=f.call(this,e,t,i,"[subtitle-stream-controller]")||this).levels=[],e.currentTrackId=-1,e.tracksBuffered=[],e.mainDetails=null,e._registerListeners(),e}},"./src/controller/subtitle-track-controller.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>c});var r,s=i("./src/events.ts"),a=i("./src/utils/texttrack-utils.ts"),n=(t=i("./src/controller/base-playlist-controller.ts"),i("./src/types/loader.ts"));function o(e,t){for(var i,r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,"symbol"==typeof(i=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);if(t=t.call(e,"string"),"object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(s.key))?i:String(i),s)}}function l(e,t){return(l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function d(e){var t;return(t=r.call(this,e,"[subtitle-track-controller]")||this).media=null,t.tracks=[],t.groupId=null,t.tracksInGroup=[],t.trackId=-1,t.selectDefaultTrack=!0,t.queuedDefaultTrack=-1,t.trackChangeListener=function(){return t.onTextTracksChanged()},t.asyncPollTrackChange=function(){return t.pollTrackChange(0)},t.useTextTrackPolling=!1,t.subtitlePollingInterval=-1,t._subtitleDisplay=!0,t.registerListeners(),t}function h(e){for(var t=[],i=0;i<e.length;i++){var r=e[i];"subtitles"===r.kind&&r.label&&t.push(e[i])}return t}r=t.default,i=r,(t=d).prototype=Object.create(i.prototype),l(t.prototype.constructor=t,i),(t=d.prototype).destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,r.prototype.destroy.call(this)},t.registerListeners=function(){var e=this.hls;e.on(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(s.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(s.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(s.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(s.Events.ERROR,this.onError,this)},t.unregisterListeners=function(){var e=this.hls;e.off(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(s.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(s.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(s.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(s.Events.ERROR,this.onError,this)},t.onMediaAttached=function(e,t){this.media=t.media,this.media&&(-1<this.queuedDefaultTrack&&(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))},t.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},t.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),-1<this.trackId&&(this.queuedDefaultTrack=this.trackId),h(this.media.textTracks).forEach((function(e){(0,a.clearCurrentCues)(e)})),this.subtitleTrack=-1,this.media=null)},t.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},t.onManifestParsed=function(e,t){this.tracks=t.subtitleTracks},t.onSubtitleTrackLoaded=function(e,t){var i,r=t.id,s=t.details,a=this.trackId;a=this.tracksInGroup[a];a?(i=a.details,a.details=t.details,this.log("subtitle track "+r+" loaded ["+s.startSN+"-"+s.endSN+"]"),r===this.trackId&&(this.retryCount=0,this.playlistLoaded(r,t,i))):this.warn("Invalid subtitle track id "+r)},t.onLevelLoading=function(e,t){this.switchLevel(t.level)},t.onLevelSwitching=function(e,t){this.switchLevel(t.level)},t.switchLevel=function(e){var t,i,r,a;e=this.hls.levels[e];null!=e&&e.textGroupIds&&(t=e.textGroupIds[e.urlId],this.groupId!==t&&(e=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,i=this.tracks.filter((function(e){return!t||e.groupId===t})),this.tracksInGroup=i,r=this.findTrackId(null==e?void 0:e.name)||this.findTrackId(),this.groupId=t,a={subtitleTracks:i},this.log("Updating subtitle tracks, "+i.length+' track(s) found in "'+t+'" group-id'),this.hls.trigger(s.Events.SUBTITLE_TRACKS_UPDATED,a),-1!==r&&this.setSubtitleTrack(r,e)))},t.findTrackId=function(e){for(var t=this.tracksInGroup,i=0;i<t.length;i++){var r=t[i];if((!this.selectDefaultTrack||r.default)&&(!e||e===r.name))return r.id}return-1},t.onError=function(e,t){r.prototype.onError.call(this,e,t),!t.fatal&&t.context&&t.context.type===n.PlaylistContextType.SUBTITLE_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&this.retryLoadingOrFail(t)},t.loadPlaylist=function(e){r.prototype.loadPlaylist.call(this);var t=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(t)){var i=t.id,a=t.groupId;t=t.url;if(e)try{t=e.addDirectives(t)}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(s.Events.SUBTITLE_TRACK_LOADING,{url:t,id:i,groupId:a,deliveryDirectives:e||null})}},t.toggleTrackModes=function(e){var t,i=this,r=this.media,s=this.trackId;r&&(t=(r=h(r.textTracks)).filter((function(e){return e.groupId===i.groupId})),-1===e?[].slice.call(r).forEach((function(e){e.mode="disabled"})):(r=t[s])&&(r.mode="disabled"),(s=t[e])&&(s.mode=this.subtitleDisplay?"showing":"hidden"))},t.setSubtitleTrack=function(e,t){var i,r,a,n,o,l=this.tracksInGroup;this.media?(this.trackId!==e&&this.toggleTrackModes(e),this.trackId===e&&(-1===e||null!=(i=l[e])&&i.details)||e<-1||e>=l.length||(this.clearTimer(),i=l[e],this.log("Switching to subtitle track "+e),this.trackId=e,i?(l=i.id,r=i.groupId,a=i.name,n=i.type,o=i.url,this.hls.trigger(s.Events.SUBTITLE_TRACK_SWITCH,{id:l,groupId:void 0===r?"":r,name:a,type:n,url:o}),l=this.switchParams(i.url,null==t?void 0:t.details),this.loadPlaylist(l)):this.hls.trigger(s.Events.SUBTITLE_TRACK_SWITCH,{id:e}))):this.queuedDefaultTrack=e},t.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var e=-1,t=h(this.media.textTracks),i=0;i<t.length;i++)if("hidden"===t[i].mode)e=i;else if("showing"===t[i].mode){e=i;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}},o((i=d).prototype,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,-1<this.trackId&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1;var t=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,t)}}]),Object.defineProperty(i,"prototype",{writable:!1});const c=d},"./src/controller/timeline-controller.ts":(e,t,i)=>{i.r(t),i.d(t,{TimelineController:()=>p});var r=i("./src/polyfills/number.ts"),s=i("./src/events.ts"),a=i("./src/utils/cea-608-parser.ts"),n=i("./src/utils/output-filter.ts"),o=i("./src/utils/webvtt-parser.ts"),l=i("./src/utils/texttrack-utils.ts"),d=i("./src/utils/imsc1-ttml-parser.ts"),h=i("./src/utils/mp4-tools.ts"),c=i("./src/types/loader.ts"),u=i("./src/utils/logger.ts"),p=((t=f.prototype).destroy=function(){var e=this.hls;e.off(s.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(s.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(s.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(s.Events.FRAG_LOADING,this.onFragLoading,this),e.off(s.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(s.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(s.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(s.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(s.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(s.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},t.addCues=function(e,t,i,r,a){for(var n,o,l,d=!1,h=a.length;h--;){var c=a[h],u=(n=c[0],u=c[1],o=t,Math.min(u,i)-Math.max(n,o));if(0<=u&&(c[0]=Math.min(c[0],t),c[1]=Math.max(c[1],i),d=!0,.5<u/(i-t)))return}d||a.push([t,i]),this.config.renderTextTracksNatively?(l=this.captionsTracks[e],this.Cues.newCue(l,t,i,r)):(l=this.Cues.newCue(null,t,i,r),this.hls.trigger(s.Events.CUES_PARSED,{type:"captions",cues:l,track:e}))},t.onInitPtsFound=function(e,t){var i=this,r=t.frag,a=t.id,n=t.initPTS,o=(t=t.timescale,this.unparsedVttFrags);"main"===a&&(this.initPTS[r.cc]=n,this.timescale[r.cc]=t),o.length&&(this.unparsedVttFrags=[],o.forEach((function(e){i.onFragLoaded(s.Events.FRAG_LOADED,e)})))},t.getExistingTrack=function(e){var t=this.media;if(t)for(var i=0;i<t.textTracks.length;i++){var r=t.textTracks[i];if(r[e])return r}return null},t.createCaptionsTrack=function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)},t.createNativeTrack=function(e){var t,i,r,s,a;this.captionsTracks[e]||(s=this.captionsProperties,t=this.captionsTracks,i=this.media,r=(s=s[e]).label,s=s.languageCode,(a=this.getExistingTrack(e))?(t[e]=a,(0,l.clearCurrentCues)(t[e]),(0,l.sendAddTrackEvent)(t[e],i)):(a=this.createTextTrack("captions",r,s))&&(a[e]=!0,t[e]=a))},t.createNonNativeTrack=function(e){var t;this.nonNativeCaptionsTracks[e]||(t=this.captionsProperties[e])&&(t={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media},this.nonNativeCaptionsTracks[e]=t,this.hls.trigger(s.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[t]}))},t.createTextTrack=function(e,t,i){var r=this.media;if(r)return r.addTextTrack(e,t,i)},t.onMediaAttaching=function(e,t){this.media=t.media,this._cleanTracks()},t.onMediaDetaching=function(){var e=this.captionsTracks;Object.keys(e).forEach((function(t){(0,l.clearCurrentCues)(e[t]),delete e[t]})),this.nonNativeCaptionsTracks={}},t.onManifestLoading=function(){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.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},t._cleanTracks=function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var i=0;i<t.length;i++)(0,l.clearCurrentCues)(t[i])}},t.onSubtitleTracksUpdated=function(e,t){var i,r=this,a=(t=(this.textTracks=[],t.subtitleTracks||[]),t.some((function(e){return e.textCodec===d.IMSC1_CODEC})));(this.config.enableWebVTT||a&&this.config.enableIMSC1)&&(a=this.tracks&&t&&this.tracks.length===t.length,this.tracks=t||[],this.config.renderTextTracksNatively?(i=this.media?this.media.textTracks:[],this.tracks.forEach((function(e,t){var s,a,n;if(t<i.length){for(var o=null,d=0;d<i.length;d++)if(a=i[d],n=e,a&&a.label===n.name&&!a.textTrack1&&!a.textTrack2){o=i[d];break}o&&(s=o)}s?(0,l.clearCurrentCues)(s):(t=r._captionsOrSubtitlesFromCharacteristics(e),(s=r.createTextTrack(t,e.name,e.lang))&&(s.mode="disabled")),s&&(s.groupId=e.groupId,r.textTracks.push(s))}))):!a&&this.tracks&&this.tracks.length&&(t=this.tracks.map((function(e){return{label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}})),this.hls.trigger(s.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:t})))},t._captionsOrSubtitlesFromCharacteristics=function(e){if(null!=(t=e.attrs)&&t.CHARACTERISTICS){var t=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS);e=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(t&&e)return"captions"}return"subtitles"},t.onManifestLoaded=function(e,t){var i=this;this.config.enableCEA708Captions&&t.captions&&t.captions.forEach((function(e){var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);t&&(t="textTrack"+t[1],(t=i.captionsProperties[t])&&(t.label=e.name,e.lang&&(t.languageCode=e.lang),t.media=e))}))},t.closedCaptionsForLevel=function(e){return e=this.hls.levels[e.level],null==e?void 0:e.attrs["CLOSED-CAPTIONS"]},t.onFragLoading=function(e,t){var i,r=this.cea608Parser1,s=this.cea608Parser2,a=this.lastSn,n=this.lastPartIndex;this.enabled&&r&&s&&t.frag.type===c.PlaylistLevelType.MAIN&&(i=t.frag.sn,t=null!=(t=null==t||null==(t=t.part)?void 0:t.index)?t:-1,i===a+1||i===a&&t===n+1||(r.reset(),s.reset()),this.lastSn=i,this.lastPartIndex=t)},t.onFragLoaded=function(e,t){var i=t.frag,a=t.payload,n=this.initPTS,o=this.unparsedVttFrags;if(i.type===c.PlaylistLevelType.SUBTITLE)if(a.byteLength){if(!(0,r.isFiniteNumber)(n[i.cc]))return o.push(t),void(n.length&&this.hls.trigger(s.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Missing initial subtitle PTS")}));o=i.decryptdata,n="stats"in t;null!=o&&o.encrypted&&!n||(t=this.tracks[i.level],(o=this.vttCCs)[i.cc]||(o[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),t&&t.textCodec===d.IMSC1_CODEC?this._parseIMSC1(i,a):this._parseVTTs(i,a,o))}else this.hls.trigger(s.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})},t._parseIMSC1=function(e,t){var i=this,r=this.hls;(0,d.parseIMSC1)(t,this.initPTS[e.cc],this.timescale[e.cc],(function(t){i._appendCues(t,e.level),r.trigger(s.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(function(t){u.logger.log("Failed to parse IMSC1: "+t),r.trigger(s.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})}))},t._parseVTTs=function(e,t,i){var r=this,a=this.hls,n=null!=(n=e.initSegment)&&n.data?(0,h.appendUint8Array)(e.initSegment.data,new Uint8Array(t)):t;(0,o.parseWebVTT)(n,this.initPTS[e.cc],this.timescale[e.cc],i,e.cc,e.start,(function(t){r._appendCues(t,e.level),a.trigger(s.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(function(i){r._fallbackToIMSC1(e,t),u.logger.log("Failed to parse VTT cue: "+i),a.trigger(s.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:i})}))},t._fallbackToIMSC1=function(e,t){var i=this,r=this.tracks[e.level];r.textCodec||(0,d.parseIMSC1)(t,this.initPTS[e.cc],this.timescale[e.cc],(function(){r.textCodec=d.IMSC1_CODEC,i._parseIMSC1(e,t)}),(function(){r.textCodec="wvtt"}))},t._appendCues=function(e,t){var i,r,a=this.hls;this.config.renderTextTracksNatively?(i=this.textTracks[t])&&"disabled"!==i.mode&&e.forEach((function(e){return(0,l.addCueToTrack)(i,e)})):(r=this.tracks[t])&&(r=r.default?"default":"subtitles"+t,a.trigger(s.Events.CUES_PARSED,{type:"subtitles",cues:e,track:r}))},t.onFragDecrypted=function(e,t){var i=t.frag;i.type===c.PlaylistLevelType.SUBTITLE&&((0,r.isFiniteNumber)(this.initPTS[i.cc])?this.onFragLoaded(s.Events.FRAG_LOADED,t):this.unparsedVttFrags.push(t))},t.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},t.onFragParsingUserdata=function(e,t){var i=this.cea608Parser1,r=this.cea608Parser2;if(this.enabled&&i&&r){var s=t.frag,a=t.samples;if(s.type!==c.PlaylistLevelType.MAIN||"NONE"!==this.closedCaptionsForLevel(s))for(var n=0;n<a.length;n++){var o=a[n].bytes;o&&(o=this.extractCea608Data(o),i.addData(a[n].pts,o[0]),r.addData(a[n].pts,o[1]))}}},t.onBufferFlushing=function(e,t){var i,r,s=t.startOffset,a=t.endOffset,n=t.endOffsetSubtitles,o=(t=t.type,this.media);!o||o.currentTime<a||(t&&"video"!==t||(i=this.captionsTracks,Object.keys(i).forEach((function(e){return(0,l.removeCuesInRange)(i[e],s,a)}))),this.config.renderTextTracksNatively&&0===s&&void 0!==n&&(r=this.textTracks,Object.keys(r).forEach((function(e){return(0,l.removeCuesInRange)(r[e],s,n)}))))},t.extractCea608Data=function(e){for(var t=[[],[]],i=31&e[0],r=2,s=0;s<i;s++){var a=e[r++],n=127&e[r++],o=127&e[r++];0==n&&0==o||0==(4&a)||0!=(a&=3)&&1!=a||(t[a].push(n),t[a].push(o))}return t},f);function f(e){var t,i,r,o;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.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,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}},this.config.enableCEA708Captions&&(t=new n.default(this,"textTrack1"),i=new n.default(this,"textTrack2"),r=new n.default(this,"textTrack3"),o=new n.default(this,"textTrack4"),this.cea608Parser1=new a.default(1,t,i),this.cea608Parser2=new a.default(3,r,o)),e.on(s.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(s.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(s.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(s.Events.FRAG_LOADING,this.onFragLoading,this),e.on(s.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(s.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(s.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(s.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(s.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(s.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}},"./src/crypt/aes-crypto.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>r}),s.prototype.decrypt=function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)};var r=s;function s(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}},"./src/crypt/aes-decryptor.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>s,removePadding:()=>function(e){var t=e.byteLength,i=t&&new DataView(e.buffer).getUint8(t-1);return i?(0,r.sliceUint8)(e,0,t-i):e}});var r=i("./src/utils/typed-array.ts");(t=a.prototype).uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),i=new Uint32Array(4),r=0;r<4;r++)i[r]=t.getUint32(4*r);return i},t.initTable=function(){var e=this.sBox,t=this.invSBox,i=this.subMix,r=i[0],s=i[1],a=i[2],n=i[3],o=(i=this.invSubMix,i[0]),l=i[1],d=i[2],h=i[3],c=new Uint32Array(256),u=0,p=0,f=0;for(f=0;f<256;f++)c[f]=f<128?f<<1:f<<1^283;for(f=0;f<256;f++){var m=p^p<<1^p<<2^p<<3^p<<4,g=(e[u]=m=m>>>8^255&m^99,c[t[m]=u]),y=c[g],A=c[y],b=257*c[m]^16843008*m;r[u]=b<<24|b>>>8,s[u]=b<<16|b>>>16,a[u]=b<<8|b>>>24,n[u]=b,o[m]=(b=16843009*A^65537*y^257*g^16843008*u)<<24|b>>>8,l[m]=b<<16|b>>>16,d[m]=b<<8|b>>>24,h[m]=b,u?(u=g^c[c[c[A^g]]],p^=c[c[p]]):u=p=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),i=!0,r=0;r<t.length&&i;)i=t[r]===this.key[r],r++;if(!i){this.key=t;var s=this.keySize=t.length;if(4!==s&&6!==s&&8!==s)throw new Error("Invalid aes key size="+s);for(var a,n,o,l=this.ksRows=4*(s+6+1),d=this.keySchedule=new Uint32Array(l),h=this.invKeySchedule=new Uint32Array(l),c=this.sBox,u=this.rcon,p=(e=this.invSubMix,e[0]),f=e[1],m=e[2],g=e[3],y=0;y<l;y++)y<s?n=d[y]=t[y]:(o=n,y%s==0?(o=c[(o=o<<8|o>>>24)>>>24]<<24|c[o>>>16&255]<<16|c[o>>>8&255]<<8|c[255&o],o^=u[y/s|0]<<24):6<s&&y%s==4&&(o=c[o>>>24]<<24|c[o>>>16&255]<<16|c[o>>>8&255]<<8|c[255&o]),d[y]=n=(d[y-s]^o)>>>0);for(a=0;a<l;a++)y=l-a,o=3&a?d[y]:d[y-4],h[a]=a<4||y<=4?o:p[c[o>>>24]]^f[c[o>>>16&255]]^m[c[o>>>8&255]]^g[c[255&o]],h[a]=h[a]>>>0}},t.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},t.decrypt=function(e,t,i){for(var r,s,a,n,o,l,d,h,c,u,p,f,m,g,y=this.keySize+6,A=this.invKeySchedule,b=this.invSBox,v=this.invSubMix,_=v[0],w=v[1],S=v[2],E=v[3],T=(v=this.uint8ArrayToUint32Array_(i),v[0]),k=v[1],x=v[2],C=v[3],L=new Int32Array(e),D=new Int32Array(L.length),R=this.networkToHostOrderSwap;t<L.length;){for(c=R(L[t]),u=R(L[t+1]),p=R(L[t+2]),f=R(L[t+3]),o=c^A[0],l=f^A[1],d=p^A[2],h=u^A[3],m=4,g=1;g<y;g++)r=_[o>>>24]^w[l>>16&255]^S[d>>8&255]^E[255&h]^A[m],s=_[l>>>24]^w[d>>16&255]^S[h>>8&255]^E[255&o]^A[m+1],a=_[d>>>24]^w[h>>16&255]^S[o>>8&255]^E[255&l]^A[m+2],n=_[h>>>24]^w[o>>16&255]^S[l>>8&255]^E[255&d]^A[m+3],o=r,l=s,d=a,h=n,m+=4;r=b[o>>>24]<<24^b[l>>16&255]<<16^b[d>>8&255]<<8^b[255&h]^A[m],s=b[l>>>24]<<24^b[d>>16&255]<<16^b[h>>8&255]<<8^b[255&o]^A[m+1],a=b[d>>>24]<<24^b[h>>16&255]<<16^b[o>>8&255]<<8^b[255&l]^A[m+2],n=b[h>>>24]<<24^b[o>>16&255]<<16^b[l>>8&255]<<8^b[255&d]^A[m+3],D[t]=R(r^T),D[t+1]=R(n^k),D[t+2]=R(a^x),D[t+3]=R(s^C),T=c,k=u,x=p,C=f,t+=4}return D.buffer};var s=a;function a(){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()}},"./src/crypt/decrypter.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>d});var r=i("./src/crypt/aes-crypto.ts"),s=i("./src/crypt/fast-aes-key.ts"),a=i("./src/crypt/aes-decryptor.ts"),n=i("./src/utils/logger.ts"),o=i("./src/utils/mp4-tools.ts"),l=i("./src/utils/typed-array.ts"),d=((t=h.prototype).destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},t.isSync=function(){return this.useSoftware},t.flush=function(){var e=this.currentResult,t=this.remainderData;return!e||t?(n.logger.error("[softwareDecrypt] "+(t?"overflow bytes: "+t.byteLength:"no result")),this.reset(),null):(t=new Uint8Array(e),this.reset(),this.removePKCS7Padding?(0,a.removePadding)(t):t)},t.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},t.decrypt=function(e,t,i){var r=this;return this.useSoftware?new Promise((function(s,a){r.softwareDecrypt(new Uint8Array(e),t,i);var n=r.flush();n?s(n.buffer):a(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(e),t,i)},t.softwareDecrypt=function(e,t,i){var r=this.currentIV,s=this.currentResult,n=this.remainderData;this.logOnce("JS AES decrypt"),n&&(e=(0,o.appendUint8Array)(n,e),this.remainderData=null),n=this.getValidChunk(e);return n.length?(r&&(i=r),e=this.softwareDecrypter,(e=e||(this.softwareDecrypter=new a.default)).expandKey(t),r=s,this.currentResult=e.decrypt(n.buffer,0,i),this.currentIV=(0,l.sliceUint8)(n,-16).buffer,r||null):null},t.webCryptoDecrypt=function(e,t,i){var a=this,o=this.subtle;return this.key===t&&this.fastAesKey||(this.key=t,this.fastAesKey=new s.default(o,t)),this.fastAesKey.expandKey().then((function(t){return o?(a.logOnce("WebCrypto AES decrypt"),new r.default(o,new Uint8Array(i)).decrypt(e.buffer,t)):Promise.reject(new Error("web crypto not initialized"))})).catch((function(r){return n.logger.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+r.name+": "+r.message),a.onWebCryptoError(e,t,i)}))},t.onWebCryptoError=function(e,t,i){if(this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i),e=this.flush(),e)return e.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},t.getValidChunk=function(e){var t=e,i=e.length-e.length%16;return i!==e.length&&(t=(0,l.sliceUint8)(e,0,i),this.remainderData=(0,l.sliceUint8)(e,i)),t},t.logOnce=function(e){this.logEnabled&&(n.logger.log("[decrypter]: "+e),this.logEnabled=!1)},h);function h(e,t){if(t=(void 0===t?{}:t).removePKCS7Padding,t=void 0===t||t,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)try{var i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch(e){}null===this.subtle&&(this.useSoftware=!0)}},"./src/crypt/fast-aes-key.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>r}),s.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])};var r=s;function s(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}},"./src/demux/aacdemuxer.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>d});t=i("./src/demux/base-audio-demuxer.ts");var r,s=i("./src/demux/adts.ts"),a=i("./src/utils/logger.ts"),n=i("./src/demux/id3.ts");function o(e,t){return(o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function l(e,t){var i;return(i=r.call(this)||this).observer=void 0,i.config=void 0,i.observer=e,i.config=t,i}r=t.default,i=r,(t=l).prototype=Object.create(i.prototype),o(t.prototype.constructor=t,i),(t=l.prototype).resetInitSegment=function(e,t,i,s){r.prototype.resetInitSegment.call(this,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}},l.probe=function(e){if(!e)return!1;for(var t=(n.getID3Data(e,0)||[]).length,i=e.length;t<i;t++)if(s.probe(e,t))return a.logger.log("ADTS sync word found !"),!0;return!1},t.canParse=function(e,t){return s.canParse(e,t)},t.appendFrame=function(e,t,i){if(s.initTrackConfig(e,this.observer,t,i,e.manifestCodec),e=s.appendFrame(e,t,i,this.basePTS,this.frameIndex),e&&0===e.missing)return e};const d=l},"./src/demux/adts.ts":(e,t,i)=>{i.r(t),i.d(t,{appendFrame:()=>function(e,t,i,r,s){var a,n,o;r+=s*u(e.samplerate),s=p(t,i);return s?(n=s.frameLength,s=s.headerLength,n=s+n,(o=Math.max(0,i+n-t.length))?(a=new Uint8Array(n-s)).set(t.subarray(i+s,t.length),0):a=t.subarray(i+s,i+n),s={unit:a,pts:r},o||e.samples.push(s),{sample:s,length:n,missing:o}):(e=t.length-i,(a=new Uint8Array(e)).set(t.subarray(i,t.length),0),{sample:{unit:a,pts:r},length:e,missing:-1})},canGetFrameLength:()=>h,canParse:()=>function(e,t){return h(e,t)&&o(e,t)&&d(e,t)<=e.length-t},getAudioConfig:()=>n,getFrameDuration:()=>u,getFullFrameLength:()=>d,getHeaderLength:()=>l,initTrackConfig:()=>function(e,t,i,s,a){e.samplerate||(t=n(t,i,s,a))&&(e.config=t.config,e.samplerate=t.samplerate,e.channelCount=t.channelCount,e.codec=t.codec,e.manifestCodec=t.manifestCodec,r.logger.log("parsed codec:"+e.codec+", rate:"+t.samplerate+", channels:"+t.channelCount))},isHeader:()=>c,isHeaderPattern:()=>o,parseFrameHeader:()=>p,probe:()=>function(e,t){if(c(e,t)){var i=l(e,t);if(t+i>=e.length)return!1;var r=d(e,t);return!(r<=i)&&(i=t+r,i===e.length||c(e,i))}return!1}});var r=i("./src/utils/logger.ts"),s=i("./src/errors.ts"),a=i("./src/events.ts");function n(e,t,i,n){var o,l,d=navigator.userAgent.toLowerCase(),h=n,c=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],u=1+((192&t[i+2])>>>6),p=(60&t[i+2])>>>2;if(!(c.length-1<p))return o=(1&t[i+2])<<2,o|=(192&t[i+3])>>>6,r.logger.log("manifest codec:"+n+", ADTS type:"+u+", samplingIndex:"+p),t=/firefox/i.test(d)?6<=p?(u=5,l=new Array(4),p-3):(u=2,l=new Array(2),p):-1!==d.indexOf("android")?(u=2,l=new Array(2),p):(u=5,l=new Array(4),n&&(-1!==n.indexOf("mp4a.40.29")||-1!==n.indexOf("mp4a.40.5"))||!n&&6<=p?p-3:((n&&-1!==n.indexOf("mp4a.40.2")&&(6<=p&&1==o||/vivaldi/i.test(d))||!n&&1==o)&&(u=2,l=new Array(2)),p)),l[0]=u<<3,l[0]|=(14&p)>>1,l[1]|=(1&p)<<7,l[1]|=o<<3,5===u&&(l[1]|=(14&t)>>1,l[2]=(1&t)<<7,l[2]|=8,l[3]=0),{config:l,samplerate:c[p],channelCount:o,codec:"mp4a.40."+u,manifestCodec:h};e.trigger(a.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+p})}function o(e,t){return 255===e[t]&&240==(246&e[t+1])}function l(e,t){return 1&e[t+1]?7:9}function d(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function h(e,t){return t+5<e.length}function c(e,t){return t+1<e.length&&o(e,t)}function u(e){return 9216e4/e}function p(e,t){var i=l(e,t);if(t+i<=e.length&&(e=d(e,t)-i,0<e))return{headerLength:i,frameLength:e}}},"./src/demux/base-audio-demuxer.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>c,initPTSFn:()=>d});var r=i("./src/polyfills/number.ts"),s=i("./src/demux/id3.ts"),a=i("./src/types/demuxer.ts"),n=i("./src/demux/dummy-demuxed-track.ts"),o=i("./src/utils/mp4-tools.ts"),l=i("./src/utils/typed-array.ts");(t=h.prototype).resetInitSegment=function(e,t,i,r){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},t.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},t.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},t.canParse=function(e,t){return!1},t.appendFrame=function(e,t,i){},t.demux=function(e,t){this.cachedData&&(e=(0,o.appendUint8Array)(this.cachedData,e),this.cachedData=null);var i,h,c=s.getID3Data(e,0),u=c?c.length:0,p=this._audioTrack,f=this._id3Track,m=c?s.getTimeStamp(c):void 0,g=e.length;for((null===this.basePTS||0===this.frameIndex&&(0,r.isFiniteNumber)(m))&&(this.basePTS=d(m,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),c&&0<c.length&&f.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:c,type:a.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});u<g;)this.canParse(e,u)?(h=this.appendFrame(p,e,u))?(this.frameIndex++,this.lastPTS=h.sample.pts,i=u+=h.length):u=g:s.canParse(e,u)?(c=s.getID3Data(e,u),f.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:c,type:a.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY}),i=u+=c.length):u++,u===g&&i!==g&&(h=(0,l.sliceUint8)(e,i),this.cachedData?this.cachedData=(0,o.appendUint8Array)(this.cachedData,h):this.cachedData=h);return{audioTrack:p,videoTrack:(0,n.dummyTrack)(),id3Track:f,textTrack:(0,n.dummyTrack)()}},t.demuxSampleAes=function(e,t,i){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},t.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:(0,n.dummyTrack)(),id3Track:this._id3Track,textTrack:(0,n.dummyTrack)()}},t.destroy=function(){};var d=function(e,t,i){return(0,r.isFiniteNumber)(e)?90*e:9e4*t+(i||0)};function h(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}const c=h},"./src/demux/chunk-cache.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>r}),(i=s.prototype).push=function(e){this.chunks.push(e),this.dataLength+=e.length},i.flush=function(){var e=this.chunks,t=this.dataLength;return e.length?(e=1===e.length?e[0]:function(e){for(var i=new Uint8Array(t),r=0,s=0;s<e.length;s++){var a=e[s];i.set(a,r),r+=a.length}return i}(e),this.reset(),e):new Uint8Array(0)},i.reset=function(){this.chunks.length=0,this.dataLength=0};var r=s;function s(){this.chunks=[],this.dataLength=0}},"./src/demux/dummy-demuxed-track.ts":(e,t,i)=>{i.r(t),i.d(t,{dummyTrack:()=>function(e,t){return{type:e=void 0===e?"":e,id:-1,pid:-1,inputTimeScale:t=void 0===t?9e4:t,sequenceNumber:-1,samples:[],dropped:0}}})},"./src/demux/exp-golomb.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>s});var r=i("./src/utils/logger.ts");(t=a.prototype).loadWord=function(){var e=this.data,t=this.bytesAvailable,i=e.byteLength-t,r=new Uint8Array(4);t=Math.min(4,t);if(0===t)throw new Error("no bytes available");r.set(e.subarray(i,i+t)),this.word=new DataView(r.buffer).getUint32(0),this.bitsAvailable=8*t,this.bytesAvailable-=t},t.skipBits=function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e||(e=(e-=this.bitsAvailable)-((t=e>>3)<<3),this.bytesAvailable-=t,this.loadWord()),this.word<<=e,this.bitsAvailable-=e},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),i=this.word>>>32-t;if(32<e&&r.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,0<this.bitsAvailable)this.word<<=t;else{if(!(0<this.bytesAvailable))throw new Error("no bits available");this.loadWord()}return 0<(t=e-t)&&this.bitsAvailable?i<<t|this.readBits(t):i},t.skipLZ=function(){for(var e=0;e<this.bitsAvailable;++e)if(0!=(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},t.skipScalingList=function(e){for(var t=8,i=8,r=0;r<e;r++)t=0===(i=0!==i?(t+this.readEG()+256)%256:i)?t:i},t.readSPS=function(){var e,t,i,r=0,s=0,a=0,n=0,o=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),m=(o(),o());if(l(5),c(3),o(),p(),(100===m||110===m||122===m||244===m||44===m||83===m||86===m||118===m||128===m)&&(m=d(),3===m&&c(1),p(),p(),c(1),h()))for(t=3!==m?8:12,i=0;i<t;i++)h()&&f(i<6?16:64);if(p(),m=d(),0===m)d();else if(1===m)for(c(1),u(),u(),e=d(),i=0;i<e;i++)u();p(),c(1);m=d(),p=d(),l=l(1);var g=(0===l&&c(1),c(1),h()&&(r=d(),s=d(),a=d(),n=d()),[1,1]);if(h()&&h())switch(o()){case 1:g=[1,1];break;case 2:g=[12,11];break;case 3:g=[10,11];break;case 4:g=[16,11];break;case 5:g=[40,33];break;case 6:g=[24,11];break;case 7:g=[20,11];break;case 8:g=[32,11];break;case 9:g=[80,33];break;case 10:g=[18,11];break;case 11:g=[15,11];break;case 12:g=[64,33];break;case 13:g=[160,99];break;case 14:g=[4,3];break;case 15:g=[3,2];break;case 16:g=[2,1];break;case 255:g=[o()<<8|o(),o()<<8|o()]}return{width:Math.ceil(16*(m+1)-2*r-2*s),height:(2-l)*(p+1)*16-(l?2:4)*(a+n),pixelRatio:g}},t.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()};const s=a;function a(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}},"./src/demux/id3.ts":(e,t,i)=>{i.r(t),i.d(t,{canParse:()=>l,decodeFrame:()=>p,getID3Data:()=>n,getID3Frames:()=>u,getTimeStamp:()=>d,isFooter:()=>a,isHeader:()=>s,isTimeStampFrame:()=>h,testables:()=>b,utf8ArrayToStr:()=>A});var r,s=function(e,t){return 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},a=function(e,t){return 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},n=function(e,t){for(var i=t,r=0;s(e,t);)r=(r+=10)+o(e,t+6),a(e,t+10)&&(r+=10),t+=r;if(0<r)return e.subarray(i,i+r)},o=function(e,t){var i=0;i=(127&e[t])<<21;return(i=(i|=(127&e[t+1])<<14)|(127&e[t+2])<<7)|127&e[t+3]},l=function(e,t){return s(e,t)&&o(e,t+6)+10<=e.length-t},d=function(e){for(var t=u(e),i=0;i<t.length;i++){var r=t[i];if(h(r))return y(r)}},h=function(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info},c=function(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),i=o(e,4);return{type:t,size:i,data:e.subarray(10,10+i)}},u=function(e){for(var t=0,i=[];s(e,t);){for(var r=o(e,t+6),n=(t+=10)+r;t+8<n;){var l=c(e.subarray(t)),d=p(l);d&&i.push(d),t+=l.size+10}a(e,t)&&(t+=10)}return i},p=function(e){return("PRIV"===e.type?f:"W"===e.type[0]?g:m)(e)},f=function(e){var t,i;if(!(e.size<2))return t=A(e.data,!0),i=new Uint8Array(e.data.subarray(t.length+1)),{key:e.type,info:t,data:i.buffer}},m=function(e){if(!(e.size<2)){var t;if("TXXX"===e.type)return t=1,t+=(i=A(e.data.subarray(1),!0)).length+1,t=A(e.data.subarray(t)),{key:e.type,info:i,data:t};var i=A(e.data.subarray(1));return{key:e.type,data:i}}},g=function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,i=A(e.data.subarray(1),!0);t=(t+=i.length+1,A(e.data.subarray(t)));return{key:e.type,info:i,data:t}}return i=A(e.data),{key:e.type,data:i}},y=function(e){var t;if(8===e.data.byteLength)return t=1&(e=new Uint8Array(e.data))[3],e=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7],e/=45,t&&(e+=47721858.84),Math.round(e)},A=function(e,t){var i,s;if(void 0===t&&(t=!1),r=r||void 0===self.TextDecoder?r:new self.TextDecoder("utf-8"),r)return i=r.decode(e),t?-1!==(s=i.indexOf("\0"))?i.substring(0,s):i:i.replace(/\0/g,"");for(var a,n,o,l=e.length,d="",h=0;h<l;){if(0===(a=e[h++])&&t)return d;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(a);break;case 12:case 13:n=e[h++],d+=String.fromCharCode((31&a)<<6|63&n);break;case 14:n=e[h++],o=e[h++],d+=String.fromCharCode((15&a)<<12|(63&n)<<6|(63&o)<<0)}}return d},b={decodeTextFrame:m}},"./src/demux/mp3demuxer.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>d});t=i("./src/demux/base-audio-demuxer.ts");var r,s=i("./src/demux/id3.ts"),a=i("./src/utils/logger.ts"),n=i("./src/demux/mpegaudio.ts");function o(e,t){return(o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function l(){return r.apply(this,arguments)||this}r=t.default,i=r,(t=l).prototype=Object.create(i.prototype),o(t.prototype.constructor=t,i),(t=l.prototype).resetInitSegment=function(e,t,i,s){r.prototype.resetInitSegment.call(this,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}},l.probe=function(e){if(!e)return!1;for(var t=(s.getID3Data(e,0)||[]).length,i=e.length;t<i;t++)if(n.probe(e,t))return a.logger.log("MPEG Audio sync word found !"),!0;return!1},t.canParse=function(e,t){return n.canParse(e,t)},t.appendFrame=function(e,t,i){if(null!==this.basePTS)return n.appendFrame(e,t,i,this.basePTS,this.frameIndex)};const d=l},"./src/demux/mp4demuxer.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>l});var r=i("./src/polyfills/number.ts"),s=i("./src/types/demuxer.ts"),a=i("./src/utils/mp4-tools.ts"),n=i("./src/demux/dummy-demuxed-track.ts"),o=/\/emsg[-/]ID3/i;(t=d.prototype).resetTimeStamp=function(){},t.resetInitSegment=function(e,t,i,r){var s,o,l,d=this.videoTrack=(0,n.dummyTrack)("video",1),h=this.audioTrack=(0,n.dummyTrack)("audio",1),c=this.txtTrack=(0,n.dummyTrack)("text",1);this.id3Track=(0,n.dummyTrack)("id3",1),this.timeOffset=0,e&&e.byteLength&&((e=(0,a.parseInitSegment)(e)).video&&(s=(l=e.video).id,o=l.timescale,l=l.codec,d.id=s,d.timescale=c.timescale=o,d.codec=l),e.audio&&(o=(s=e.audio).id,l=s.timescale,e=s.codec,h.id=o,h.timescale=l,h.codec=e),c.id=a.RemuxerTrackIdConfig.text,d.sampleDuration=0,d.duration=h.duration=r)},t.resetContiguity=function(){},d.probe=function(e){return e=16384<e.length?e.subarray(0,16384):e,0<(0,a.findBox)(e,["moof"]).length},t.demux=function(e,t){this.timeOffset=t;var i=e,r=this.videoTrack,s=this.txtTrack;this.config.progressive?(this.remainderData&&(i=(0,a.appendUint8Array)(this.remainderData,e)),e=(0,a.segmentValidRange)(i),this.remainderData=e.remainder,r.samples=e.valid||new Uint8Array):r.samples=i,e=this.extractID3Track(r,t);return s.samples=(0,a.parseSamples)(t,r),{videoTrack:r,audioTrack:this.audioTrack,id3Track:e,textTrack:this.txtTrack}},t.flush=function(){var e=this.timeOffset,t=this.videoTrack,i=this.txtTrack,r=(t.samples=this.remainderData||new Uint8Array,this.remainderData=null,this.extractID3Track(t,this.timeOffset));return i.samples=(0,a.parseSamples)(e,t),{videoTrack:t,audioTrack:(0,n.dummyTrack)(),id3Track:r,textTrack:(0,n.dummyTrack)()}},t.extractID3Track=function(e,t){var i=this.id3Track;return e.samples.length&&(e=(0,a.findBox)(e.samples,["emsg"]))&&e.forEach((function(e){var n,l;e=(0,a.parseEmsg)(e);o.test(e.schemeIdUri)&&(n=(0,r.isFiniteNumber)(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale,(l=4294967295===e.eventDuration?Number.POSITIVE_INFINITY:e.eventDuration/e.timeScale)<=.001&&(l=Number.POSITIVE_INFINITY),e=e.payload,i.samples.push({data:e,len:e.byteLength,dts:n,pts:n,type:s.MetadataSchema.emsg,duration:l}))})),i},t.demuxSampleAes=function(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},t.destroy=function(){};const l=d;function d(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}},"./src/demux/mpegaudio.ts":(e,t,i)=>{i.r(t),i.d(t,{appendFrame:()=>function(e,t,i,r,s){if(!(i+24>t.length)){var a=l(t,i);if(a&&i+a.frameLength<=t.length)return r+=s*(9e4*a.samplesPerFrame/a.sampleRate),s={unit:t.subarray(i,i+a.frameLength),pts:r,dts:r},e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(s),{sample:s,length:a.frameLength,missing:0}}},canParse:()=>function(e,t){return d(e,t)&&4<=e.length-t},isHeader:()=>h,isHeaderPattern:()=>d,parseHeader:()=>l,probe:()=>function(e,t){var i,r;return!!(t+1<e.length&&d(e,t))&&(r=l(e,t),i=4,null!=r&&r.frameLength&&(i=r.frameLength),(r=t+i)===e.length||h(e,r))}});var r=null,s=[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],a=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],n=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],o=[0,1,1,4];function l(e,t){var i,l,d,h,c,u=e[t+1]>>3&3,p=e[t+1]>>1&3,f=e[t+2]>>4&15,m=e[t+2]>>2&3;if(1!=u&&0!=f&&15!=f&&3!=m)return c=e[t+2]>>1&1,i=e[t+3]>>6,f=1e3*s[14*(3==u?3-p:3==p?3:4)+f-1],m=a[3*(3==u?0:2==u?1:2)+m],l=3==i?1:2,h=8*(u=n[u][p])*(d=o[p]),u=Math.floor(u*f/m+c)*d,null===r&&(c=(navigator.userAgent||"").match(/Chrome\/(\d+)/i),r=c?parseInt(c[1]):0),r&&r<=87&&2==p&&224e3<=f&&0==i&&(e[t+3]=128|e[t+3]),{sampleRate:m,channelCount:l,frameLength:u,samplesPerFrame:h}}function d(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function h(e,t){return t+1<e.length&&d(e,t)}},"./src/demux/sample-aes.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>a});var r=i("./src/crypt/decrypter.ts"),s=i("./src/utils/mp4-tools.ts");(t=n.prototype).decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)},t.decryptAacSample=function(e,t,i){var r,s=this,a=e[t].unit;a.length<=16||(r=(r=a.subarray(16,a.length-a.length%16)).buffer.slice(r.byteOffset,r.byteOffset+r.length),this.decryptBuffer(r).then((function(r){r=new Uint8Array(r),a.set(r,16),s.decrypter.isSync()||s.decryptAacSamples(e,t+1,i)})))},t.decryptAacSamples=function(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}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,i=new Int8Array(t),r=0,s=32;s<e.length-16;s+=160,r+=16)i.set(e.subarray(s,s+16),r);return i},t.getAvcDecryptedUnit=function(e,t){for(var i=new Uint8Array(t),r=0,s=32;s<e.length-16;s+=160,r+=16)e.set(i.subarray(r,r+16),s);return e},t.decryptAvcSample=function(e,t,i,r,a){var n=this,o=(0,s.discardEPB)(a.data),l=this.getAvcEncryptedData(o);this.decryptBuffer(l.buffer).then((function(s){a.data=n.getAvcDecryptedUnit(o,s),n.decrypter.isSync()||n.decryptAvcSamples(e,t,i+1,r)}))},t.decryptAvcSamples=function(e,t,i,r){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length)return void r();for(var s=e[t].units;!(i>=s.length);i++){var a=s[i];if(!(a.data.length<=48||1!==a.type&&5!==a.type||(this.decryptAvcSample(e,t,i,r,a),this.decrypter.isSync())))return}}};const a=n;function n(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new r.default(t,{removePKCS7Padding:!1})}},"./src/demux/transmuxer-interface.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>h});var r=i("./src/demux/webworkify-webpack.js"),s=i("./src/events.ts"),a=i("./src/demux/transmuxer.ts"),n=i("./src/utils/logger.ts"),o=i("./src/errors.ts"),l=(t=i("./src/utils/mediasource-helper.ts"),i("./node_modules/eventemitter3/index.js")),d=(0,t.getMediaSource)()||{isTypeSupported:function(){return!1}},h=((i=c.prototype).destroy=function(){var e=this.worker;e?(e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null,this.onwmsg=void 0):(e=this.transmuxer)&&(e.destroy(),this.transmuxer=null),e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},i.push=function(e,t,i,r,s,o,l,d,h,c){var u=this,p=(h.transmuxing.start=self.performance.now(),this.transmuxer),f=this.worker,m=(o||s).start,g=s.decryptdata,y=this.frag,A=!(y&&s.cc===y.cc),b=!(y&&h.level===y.level),v=y?h.sn-y.sn:-1,_=this.part?h.part-this.part.index:-1,w=0==v&&1<h.id&&h.id===(null==y?void 0:y.stats.chunkCount),S=(w=!b&&(1==v||0==v&&(1==_||w&&_<=0)),self.performance.now());(b||v||0===s.stats.parsing.start)&&(s.stats.parsing.start=S),!o||!_&&w||(o.stats.parsing.start=S),S=!(y&&(null==(v=s.initSegment)?void 0:v.url)===(null==(_=y.initSegment)?void 0:_.url)),v=new a.TransmuxState(A,w,d,b,m,S);w&&!A&&!S||(n.logger.log("[transmuxer-interface, "+s.type+"]: Starting new transmux session for sn: "+h.sn+" p: "+h.part+" level: "+h.level+" id: "+h.id+"\n discontinuity: "+A+"\n trackSwitch: "+b+"\n contiguous: "+w+"\n accurateTimeOffset: "+d+"\n timeOffset: "+m+"\n initSegmentChange: "+S),y=new a.TransmuxConfig(i,r,t,l,c),this.configureTransmuxer(y)),this.frag=s,this.part=o,f?f.postMessage({cmd:"demux",data:e,decryptdata:g,chunkMeta:h,state:v},e instanceof ArrayBuffer?[e]:[]):p&&(_=p.push(e,g,h,v),(0,a.isPromise)(_)?(p.async=!0,_.then((function(e){u.handleTransmuxComplete(e)})).catch((function(e){u.transmuxerError(e,h,"transmuxer-interface push error")}))):(p.async=!1,this.handleTransmuxComplete(_)))},i.flush=function(e){var t=this,i=(e.transmuxing.start=self.performance.now(),this.transmuxer),r=this.worker;r?r.postMessage({cmd:"flush",chunkMeta:e}):i&&(r=i.flush(e),(0,a.isPromise)(r)||i.async?(r=(0,a.isPromise)(r)?r:Promise.resolve(r)).then((function(i){t.handleFlushResult(i,e)})).catch((function(i){t.transmuxerError(i,e,"transmuxer-interface flush error")})):this.handleFlushResult(r,e))},i.transmuxerError=function(e,t,i){this.hls&&this.hls.trigger(s.Events.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:i})},i.handleFlushResult=function(e,t){var i=this;e.forEach((function(e){i.handleTransmuxComplete(e)})),this.onFlush(t)},i.onWorkerMessage=function(e){var t=e.data,i=this.hls;switch(t.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":n.logger[t.data.logType]&&n.logger[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)}},i.configureTransmuxer=function(e){var t=this.worker,i=this.transmuxer;t?t.postMessage({cmd:"configure",config:e}):i&&i.configure(e)},i.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},c);function c(e,t,i,h){function c(e,t){(t=t||{}).frag=p.frag,t.id=p.id,p.hls.trigger(e,t)}var u,p=this,f=(this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,e.config);this.hls=e,this.id=t,this.useWorker=!!f.enableWorker,this.onTransmuxComplete=i,this.onFlush=h,this.observer=new l.EventEmitter,this.observer.on(s.Events.FRAG_DECRYPTED,c),this.observer.on(s.Events.ERROR,c),i={mp4:d.isTypeSupported("video/mp4"),mpeg:d.isTypeSupported("audio/mpeg"),mp3:d.isTypeSupported('audio/mp4; codecs="mp3"')},h=navigator.vendor;if(this.useWorker&&"undefined"!=typeof Worker){n.logger.log("demuxing in webworker");try{u=this.worker=(0,r.default)("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),u.addEventListener("message",this.onwmsg),u.onerror=function(e){p.useWorker=!1,n.logger.warn("Exception in webworker, fallback to inline"),p.hls.trigger(s.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:new Error(e.message+" ("+e.filename+":"+e.lineno+")")})},u.postMessage({cmd:"init",typeSupported:i,vendor:h,id:t,config:JSON.stringify(f)})}catch(e){n.logger.warn("Error in worker:",e),n.logger.error("Error while initializing DemuxerWorker, fallback to inline"),u&&self.URL.revokeObjectURL(u.objectURL),this.transmuxer=new a.default(this.observer,i,f,h,t),this.worker=null}}else this.transmuxer=new a.default(this.observer,i,f,h,t)}},"./src/demux/transmuxer-worker.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>function(e){function t(t,i){e.postMessage({event:t,data:i})}var i=new n.EventEmitter;i.on(s.Events.FRAG_DECRYPTED,t),i.on(s.Events.ERROR,t),e.addEventListener("message",(function(n){var d=n.data;switch(d.cmd){case"init":var c,u=JSON.parse(d.config);for(c in e.transmuxer=new r.default(i,d.typeSupported,u,d.vendor,d.id),(0,a.enableLogs)(u.debug,d.id),a.logger)!function(e){a.logger[e]=function(i){t("workerLog",{logType:e,message:i})}}(c);t("init",null);break;case"configure":e.transmuxer.configure(d.config);break;case"demux":u=e.transmuxer.push(d.data,d.decryptdata,d.chunkMeta,d.state),(0,r.isPromise)(u)?(e.transmuxer.async=!0,u.then((function(t){l(e,t)})).catch((function(e){t(s.Events.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:d.chunkMeta,fatal:!1,error:e,err:e,reason:"transmuxer-worker push error"})}))):(e.transmuxer.async=!1,l(e,u));break;case"flush":var p=d.chunkMeta;u=e.transmuxer.flush(p);(0,r.isPromise)(u)||e.transmuxer.async?(u=(0,r.isPromise)(u)?u:Promise.resolve(u)).then((function(t){h(e,t,p)})).catch((function(e){t(s.Events.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:d.chunkMeta,fatal:!1,error:e,err:e,reason:"transmuxer-worker flush error"})})):h(e,u,p)}}))}});var r=i("./src/demux/transmuxer.ts"),s=i("./src/events.ts"),a=i("./src/utils/logger.ts"),n=i("./node_modules/eventemitter3/index.js"),o=i("./src/errors.ts");function l(e,t){if(!((i=t.remuxResult).audio||i.video||i.text||i.id3||i.initSegment))return!1;var i=[],r=t.remuxResult,s=r.audio;r=r.video;return s&&d(i,s),r&&d(i,r),e.postMessage({event:"transmuxComplete",data:t},i),!0}function d(e,t){t.data1&&e.push(t.data1.buffer),t.data2&&e.push(t.data2.buffer)}function h(e,t,i){t.reduce((function(t,i){return l(e,i)||t}),!1)||e.postMessage({event:"transmuxComplete",data:t[0]}),e.postMessage({event:"flush",data:i})}},"./src/demux/transmuxer.ts":(e,t,i)=>{i.r(t),i.d(t,{TransmuxConfig:()=>A,TransmuxState:()=>b,default:()=>f,isPromise:()=>y});var r,s=i("./src/events.ts"),a=i("./src/errors.ts"),n=i("./src/crypt/decrypter.ts"),o=(t=i("./src/demux/aacdemuxer.ts"),i("./src/demux/mp4demuxer.ts")),l=i("./src/demux/tsdemuxer.ts"),d=i("./src/demux/mp3demuxer.ts"),h=i("./src/remux/mp4-remuxer.ts"),c=i("./src/remux/passthrough-remuxer.ts"),u=i("./src/utils/logger.ts");try{r=self.performance.now.bind(self.performance)}catch(e){u.logger.debug("Unable to use Performance API on this environment"),r=self.Date.now}var p=[{demux:o.default,remux:c.default},{demux:l.default,remux:h.default},{demux:t.default,remux:h.default},{demux:d.default,remux:h.default}],f=((i=g.prototype).configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},i.push=function(e,t,i,s){var a=this,n=i.transmuxing,o=(e=(n.executeStart=r(),new Uint8Array(e)),this.currentTransmuxState),l=this.transmuxConfig,d=(s=(s&&(this.currentTransmuxState=s),s||o),o=s.contiguous,s.discontinuity),h=s.trackSwitch,c=s.accurateTimeOffset,u=s.timeOffset,p=(s=s.initSegmentChange,l.audioCodec),f=l.videoCodec,g=l.defaultInitPts,y=l.duration,A=(l=l.initSegmentData,A=null,A=0<e.byteLength&&null!=t&&null!=t.key&&null!==t.iv&&null!=t.method?t:A);if(A&&"AES-128"===A.method){var b=this.getDecrypter();if(!b.isSync())return this.decryptionPromise=b.webCryptoDecrypt(e,A.key.buffer,A.iv.buffer).then((function(e){return e=a.push(e,null,i),a.decryptionPromise=null,e})),this.decryptionPromise;if(b=b.softwareDecrypt(e,A.key.buffer,A.iv.buffer),!b)return n.executeEnd=r(),m(i);e=new Uint8Array(b)}return b=this.needsProbing(d,h),b&&this.configureTransmuxer(e),(d||h||s||b)&&this.resetInitSegment(l,p,f,y,t),(d||s||b)&&this.resetInitialTimestamp(g),o||this.resetContiguity(),h=this.transmux(e,A,u,c,i),l=this.currentTransmuxState,l.contiguous=!0,l.discontinuity=!1,l.trackSwitch=!1,n.executeEnd=r(),h},i.flush=function(e){var t=this,i=e.transmuxing,n=(i.executeStart=r(),this.decrypter),o=this.currentTransmuxState,l=this.decryptionPromise;if(l)return l.then((function(){return t.flush(e)}));var d=[];l=o.timeOffset,!n||(o=n.flush())&&d.push(this.push(o,null,e)),n=this.demuxer,o=this.remuxer;return n&&o?(o=n.flush(l),y(o)?o.then((function(i){return t.flushRemux(d,i,e),d})):(this.flushRemux(d,o,e),d)):(this.observer.emit(s.Events.ERROR,s.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),i.executeEnd=r(),[m(e)])},i.flushRemux=function(e,t,i){var s=t.audioTrack,a=t.videoTrack,n=t.id3Track,o=(t=t.textTrack,this.currentTransmuxState),l=o.accurateTimeOffset;o=o.timeOffset,u.logger.log("[transmuxer.ts]: Flushed fragment "+i.sn+(-1<i.part?" p: "+i.part:"")+" of level "+i.level),s=this.remuxer.remux(s,a,n,t,o,l,!0,this.id);e.push({remuxResult:s,chunkMeta:i}),i.transmuxing.executeEnd=r()},i.resetInitialTimestamp=function(e){var t=this.demuxer,i=this.remuxer;t&&i&&(t.resetTimeStamp(e),i.resetTimeStamp(e))},i.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},i.resetInitSegment=function(e,t,i,r,s){var a=this.demuxer,n=this.remuxer;a&&n&&(a.resetInitSegment(e,t,i,r),n.resetInitSegment(e,t,i,s))},i.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},i.transmux=function(e,t,i,r,s){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,i,r,s):this.transmuxUnencrypted(e,i,r,s)},i.transmuxUnencrypted=function(e,t,i,r){e=this.demuxer.demux(e,t,!1,!this.config.progressive);var s=e.audioTrack,a=e.videoTrack,n=e.id3Track;e=e.textTrack;return{remuxResult:this.remuxer.remux(s,a,n,e,t,i,!1,this.id),chunkMeta:r}},i.transmuxSampleAes=function(e,t,i,r,s){var a=this;return this.demuxer.demuxSampleAes(e,t,i).then((function(e){return{remuxResult:a.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,i,r,!1,a.id),chunkMeta:s}}))},i.configureTransmuxer=function(e){for(var t,i=this.config,r=this.observer,s=this.typeSupported,a=this.vendor,n=0,l=p.length;n<l;n++)if(p[n].demux.probe(e)){t=p[n];break}t||(u.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),t={demux:o.default,remux:c.default});var d=this.demuxer,h=this.remuxer,f=t.remux,m=t.demux;h&&h instanceof f||(this.remuxer=new f(r,i,s,a)),d&&d instanceof m||(this.demuxer=new m(r,i,s),this.probe=m.probe)},i.needsProbing=function(e,t){return!this.demuxer||!this.remuxer||e||t},i.getDecrypter=function(){return this.decrypter||(this.decrypter=new n.default(this.config))},g),m=function(e){return{remuxResult:{},chunkMeta:e}};function g(e,t,i,r,s){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=r,this.id=s}function y(e){return"then"in e&&e.then instanceof Function}var A=function(e,t,i,r,s){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=r,this.defaultInitPts=s},b=function(e,t,i,r,s,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=r,this.timeOffset=s,this.initSegmentChange=a}},"./src/demux/tsdemuxer.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>y});var r=i("./src/demux/adts.ts"),s=i("./src/demux/mpegaudio.ts"),a=i("./src/demux/exp-golomb.ts"),n=i("./src/demux/sample-aes.ts"),o=i("./src/events.ts"),l=i("./src/utils/mp4-tools.ts"),d=i("./src/utils/logger.ts"),h=i("./src/errors.ts"),c=i("./src/types/demuxer.ts");function u(){return(u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i,r=arguments[t];for(i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e}).apply(this,arguments)}function p(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._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=e,this.config=t,this.typeSupported=i}function f(e,t,i,r){return{key:e,frame:!1,pts:t,dts:i,units:[],debug:r,length:0}}function m(e){var t,i,r,s,a=0,n=e.data;if(!e||0===e.size)return null;for(;n[0].length<19&&1<n.length;){var o=new Uint8Array(n[0].length+n[1].length);o.set(n[0]),o.set(n[1],n[0].length),n[0]=o,n.splice(1,1)}if(1!==((t=n[0])[0]<<16)+(t[1]<<8)+t[2])return null;if((i=(t[4]<<8)+t[5])&&i>e.size-6)return null;var l=t[7],h=(192&l&&(r=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,64&l?54e5<r-(s=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2)&&(d.logger.warn(Math.round((r-s)/9e4)+"s delta between PTS and DTS, align them"),r=s):s=r),(l=t[8])+9);if(e.size<=h)return null;e.size-=h;for(var c=new Uint8Array(e.size),u=0,p=n.length;u<p;u++){var f=(t=n[u]).byteLength;if(h){if(f<h){h-=f;continue}t=t.subarray(h),f-=h,h=0}c.set(t,a),a+=f}return i&&(i-=l+3),{data:c,pts:r,dts:s,len:i}}function g(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var i=t.samples,r=i.length;if(!r)return t.dropped++;i=i[r-1],e.pts=i.pts,e.dts=i.dts}t.samples.push(e)}e.debug.length&&d.logger.log(e.pts+"/"+e.dts+":"+e.debug)}p.probe=function(e){return e=p.syncOffset(e),0<e&&d.logger.warn("MPEG2-TS detected but first sync word found @ offset "+e),-1!==e},p.syncOffset=function(e){for(var t=Math.min(940,e.length-376)+1,i=0;i<t;){if(71===e[i]&&71===e[i+188])return i;i++}return-1},p.createTrack=function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:l.RemuxerTrackIdConfig[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}},(t=p.prototype).resetInitSegment=function(e,t,i,r){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=p.createTrack("video"),this._audioTrack=p.createTrack("audio",r),this._id3Track=p.createTrack("id3"),this._txtTrack=p.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i,this._duration=r},t.resetTimeStamp=function(){},t.resetContiguity=function(){var e=this._audioTrack,t=this._avcTrack,i=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},t.demux=function(e,t,i,r){void 0===r&&(r=!1),(i=void 0!==i&&i)||(this.sampleAes=null);var s,a=this._avcTrack,n=this._audioTrack,c=this._id3Track,u=this._txtTrack,f=a.pid,g=a.pesData,y=n.pid,A=c.pid,b=n.pesData,v=c.pesData,_=null,w=this.pmtParsed,S=this._pmtId,E=e.length;if(this.remainderData&&(E=(e=(0,l.appendUint8Array)(this.remainderData,e)).length,this.remainderData=null),E<188&&!r)return this.remainderData=e,{audioTrack:n,videoTrack:a,id3Track:c,textTrack:u};var T=Math.max(0,p.syncOffset(e));(E-=(E-T)%188)<e.byteLength&&!r&&(this.remainderData=new Uint8Array(e.buffer,E,e.buffer.byteLength-E));for(var k,x=0,C=T;C<E;C+=188)if(71===e[C]){var L=!!(64&e[C+1]),D=((31&e[C+1])<<8)+e[C+2],R=void 0;if(1<(48&e[C+3])>>4){if((R=C+5+e[C+4])===C+188)continue}else R=C+4;switch(D){case f:L&&(g&&(s=m(g))&&this.parseAVCPES(a,u,s,!1),g={data:[],size:0}),g&&(g.data.push(e.subarray(R,C+188)),g.size+=C+188-R);break;case y:if(L){if(b&&(s=m(b)))switch(n.segmentCodec){case"aac":this.parseAACPES(n,s);break;case"mp3":this.parseMPEGPES(n,s)}b={data:[],size:0}}b&&(b.data.push(e.subarray(R,C+188)),b.size+=C+188-R);break;case A:L&&(v&&(s=m(v))&&this.parseID3PES(c,s),v={data:[],size:0}),v&&(v.data.push(e.subarray(R,C+188)),v.size+=C+188-R);break;case 0:L&&(R+=e[R]+1),S=this._pmtId=(31&(I=e)[(k=R)+10])<<8|I[k+11];break;case S:L&&(R+=e[R]+1);var I=function(e,t,i,r){var s={audio:-1,avc:-1,id3:-1,segmentCodec:"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;){var n=(31&e[t+1])<<8|e[t+2];switch(e[t]){case 207:if(!r){d.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===s.audio&&(s.audio=n);break;case 21:-1===s.id3&&(s.id3=n);break;case 219:if(!r){d.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===s.avc&&(s.avc=n);break;case 3:case 4:!0!==i.mpeg&&!0!==i.mp3?d.logger.log("MPEG audio found, not supported in this browser"):-1===s.audio&&(s.audio=n,s.segmentCodec="mp3");break;case 36:d.logger.warn("Unsupported HEVC stream type found")}t+=5+((15&e[t+3])<<8|e[t+4])}return s}(e,R,this.typeSupported,i);0<(f=I.avc)&&(a.pid=f),0<(y=I.audio)&&(n.pid=y,n.segmentCodec=I.segmentCodec),0<(A=I.id3)&&(c.pid=A),null===_||w||(d.logger.log("unknown PID '"+_+"' in TS found"),_=null,C=T-188),w=this.pmtParsed=!0;break;case 17:case 8191:break;default:_=D}}else x++;0<x&&this.observer.emit(o.Events.ERROR,o.Events.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+x+" TS packet/s that do not start with 0x47"}),a.pesData=g,n.pesData=b,c.pesData=v;var P={audioTrack:n,videoTrack:a,id3Track:c,textTrack:u};return r&&this.extractRemainingSamples(P),P},t.flush=function(){var e=this.remainderData;return this.remainderData=null,e=e?this.demux(e,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},t.extractRemainingSamples=function(e){var t,i=e.audioTrack,r=e.videoTrack,s=e.id3Track,a=(e=e.textTrack,r.pesData),n=i.pesData,o=s.pesData;if(a&&(t=m(a))?(this.parseAVCPES(r,e,t,!0),r.pesData=null):r.pesData=a,n&&(t=m(n))){switch(i.segmentCodec){case"aac":this.parseAACPES(i,t);break;case"mp3":this.parseMPEGPES(i,t)}i.pesData=null}else null!=n&&n.size&&d.logger.log("last AAC PES packet truncated,might overlap between fragments"),i.pesData=n;o&&(t=m(o))?(this.parseID3PES(s,t),s.pesData=null):s.pesData=o},t.demuxSampleAes=function(e,t,i){return e=this.demux(e,i,!0,!this.config.progressive),i=this.sampleAes=new n.default(this.observer,this.config,t),this.decrypt(e,i)},t.decrypt=function(e,t){return new Promise((function(i){var r=e.audioTrack,s=e.videoTrack;r.samples&&"aac"===r.segmentCodec?t.decryptAacSamples(r.samples,0,(function(){s.samples?t.decryptAvcSamples(s.samples,0,0,(function(){i(e)})):i(e)})):s.samples&&t.decryptAvcSamples(s.samples,0,0,(function(){i(e)}))}))},t.destroy=function(){this._duration=0},t.parseAVCPES=function(e,t,i,r){var s,n=this,o=this.parseAVCNALu(e,i.data),d=this.avcSample,h=!1;i.data=null,d&&o.length&&!e.audFound&&(g(d,e),d=this.avcSample=f(!1,i.pts,i.dts,"")),o.forEach((function(r){switch(r.type){case 1:s=!0,(d=d||(n.avcSample=f(!0,i.pts,i.dts,""))).frame=!0;var o=r.data;h&&4<o.length&&(2!==(o=new a.default(o).readSliceType())&&4!==o&&7!==o&&9!==o||(d.key=!0));break;case 5:s=!0,(d=d||(n.avcSample=f(!0,i.pts,i.dts,""))).key=!0,d.frame=!0;break;case 6:s=!0,(0,l.parseSEIMessageFromNALu)(r.data,1,i.pts,t.samples);break;case 7:if(h=s=!0,!e.sps){o=new a.default(r.data).readSPS(),e.width=o.width,e.height=o.height,e.pixelRatio=o.pixelRatio,e.sps=[r.data],e.duration=n._duration;for(var c=r.data.subarray(1,4),u="avc1.",p=0;p<3;p++){var m=c[p].toString(16);u+=m=m.length<2?"0"+m:m}e.codec=u}break;case 8:s=!0,e.pps||(e.pps=[r.data]);break;case 9:s=!1,e.audFound=!0,d&&g(d,e),d=n.avcSample=f(!1,i.pts,i.dts,"");break;case 12:s=!0;break;default:s=!1,d&&(d.debug+="unknown NAL "+r.type+" ")}d&&s&&d.units.push(r)})),r&&d&&(g(d,e),this.avcSample=null)},t.getLastNalUnit=function(e){var t,i=this.avcSample;return null!=(e=i=i&&0!==i.units.length?i:e[e.length-1])&&e.units?(e=i.units)[e.length-1]:t},t.parseAVCNALu=function(e,t){var i,r,s,a,n,o,l=t.byteLength,d=e.naluState||0,h=d,c=[],u=0,p=-1,f=0;for(-1===d&&(f=31&t[p=0],d=0,u=1);u<l;)i=t[u++],d=d?1!==d?i?1===i?(0<=p?(s={data:t.subarray(p,u-d-1),type:f},c.push(s)):(s=this.getLastNalUnit(e.samples))&&(h&&u<=4-h&&s.state&&(s.data=s.data.subarray(0,s.data.byteLength-h)),0<(r=u-d-1))&&((a=new Uint8Array(s.data.byteLength+r)).set(s.data,0),a.set(t.subarray(0,r),s.data.byteLength),s.data=a,s.state=0),u<l?(f=31&t[p=u],0):-1):0:3:i?0:2:i?0:1;return 0<=p&&0<=d&&(n={data:t.subarray(p,l),type:f,state:d},c.push(n)),0===c.length&&(n=this.getLastNalUnit(e.samples))&&((o=new Uint8Array(n.data.byteLength+t.byteLength)).set(n.data,0),o.set(t,n.data.byteLength),n.data=o),e.naluState=d,c},t.parseAACPES=function(e,t){var i,s,a,n,l,c=0,u=this.aacOverFlow,p=t.data;for(u&&(this.aacOverFlow=null,f=u.missing,n=u.sample.unit.byteLength,-1===f?((l=new Uint8Array(n+p.byteLength)).set(u.sample.unit,0),l.set(p,n),p=l):(l=n-f,u.sample.unit.set(p.subarray(0,f),l),e.samples.push(u.sample),c=u.missing)),i=c,s=p.length;i<s-1&&!r.isHeader(p,i);i++);if(i===c||(n=i<s-1?(a="AAC PES did not start with ADTS header,offset:"+i,!1):(a="no ADTS header found in AAC PES",!0),d.logger.warn("parsing error:"+a),this.observer.emit(o.Events.ERROR,o.Events.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.FRAG_PARSING_ERROR,fatal:n,reason:a}),!n)){if(r.initTrackConfig(e,this.observer,p,i,this.audioCodec),void 0!==t.pts)m=t.pts;else{if(!u)return void d.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var f=r.getFrameDuration(e.samplerate),m=u.sample.pts+f}for(var g,y=0;i<s;){if(i+=(g=r.appendFrame(e,p,i,m,y)).length,g.missing){this.aacOverFlow=g;break}for(y++;i<s-1&&!r.isHeader(p,i);i++);}}},t.parseMPEGPES=function(e,t){var i=t.data,r=i.length,a=0,n=0,o=t.pts;if(void 0!==o)for(;n<r;)if(s.isHeader(i,n)){var l=s.appendFrame(e,i,n,o,a);if(!l)break;n+=l.length,a++}else n++;else d.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},t.parseID3PES=function(e,t){void 0!==t.pts?(t=u({},t,{type:this._avcTrack?c.MetadataSchema.emsg:c.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY}),e.samples.push(t)):d.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")};const y=p},"./src/demux/webworkify-webpack.js":(e,t,i)=>{i.r(t),i.d(t,{default:()=>function(e,t){t=t||{};var r={main:i.m},l=t.all?{main:Object.keys(r.main)}:function(t){for(var r={main:[e]},o={main:[]},l={main:{}};function(e){return Object.keys(e).reduce((function(t,i){return t||0<e[i].length}),!1)}(r);)for(var d=Object.keys(r),h=0;h<d.length;h++){var c=d[h],u=r[c].pop();if(l[c]=l[c]||{},!l[c][u]&&t[c][u]){l[c][u]=!0,o[c]=o[c]||[],o[c].push(u);for(var p=function(e,t,r){var o={},l=(o[r]=[],t.toString().replace(/^"[^"]+"/,"function"));t=l.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/)||l.match(/^\(\w+,\s*\w+,\s*(\w+)\)\s?\=\s?\>/);if(!t)return o;t=t[1];for(var d,h=new RegExp("(\\\\n|\\W)"+n(t)+a,"g");d=h.exec(l);)"dll-reference"!==d[3]&&o[r].push(d[3]);for(h=new RegExp("\\("+n(t)+'\\("(dll-reference\\s('+s+'))"\\)\\)'+a,"g");d=h.exec(l);)e[d[2]]||(o[r].push(d[1]),e[d[2]]=i(d[1]).m),o[d[2]]=o[d[2]]||[],o[d[2]].push(d[4]);for(var c,u=Object.keys(o),p=0;p<u.length;p++)for(var f=0;f<o[u[p]].length;f++)c=o[u[p]][f],isNaN(+c)||(o[u[p]][f]=+o[u[p]][f]);return o}(t,t[c][u],c),f=Object.keys(p),m=0;m<f.length;m++)r[f[m]]=r[f[m]]||[],r[f[m]]=r[f[m]].concat(p[f[m]])}}return o}(r),d="",h=(t=(Object.keys(l).filter((function(e){return"main"!==e})).forEach((function(e){for(var t=0;l[e][t];)t++;l[e].push(t),r[e][t]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",d=d+"var "+e+" = ("+o(l,r,t,modules)+")();\n"})),d=d+"new (("+o(l,r,e,"main")+")())(self);",new window.Blob([d],{type:"text/javascript"})),t=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(t),new window.Worker(t));return h.objectURL=t,h}});var r=function(){function e(r){var s=i[r];return void 0!==s||(s=i[r]={exports:{}},t[r].call(s.exports,s,s.exports,e)),s.exports}var t=ENTRY_MODULE,i={},r=(e.m=t,e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,{a:i}),i},e.d=function(t,i){for(var r in i)e.o(i,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:i[r]})},e.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},e.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},e(ENTRY_MODULE));return r.default||r}.toString().split("ENTRY_MODULE"),s="[\\.|\\-|\\+|\\w|/|@]+",a="\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)";function n(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function o(e,t,i,s){return e=e[s].map((function(e){return'"'+e+'": '+t[s][e].toString().replace(/^"[^"]+"/,"function")})).join(","),r[0]+"{"+e+"}"+r[1]+'"'+i+'"'+r[2]}},"./src/errors.ts":(e,t,i)=>{var r,s;i.r(t),i.d(t,{ErrorDetails:()=>s,ErrorTypes:()=>r}),(i=r=r||{}).NETWORK_ERROR="networkError",i.MEDIA_ERROR="mediaError",i.KEY_SYSTEM_ERROR="keySystemError",i.MUX_ERROR="muxError",i.OTHER_ERROR="otherError",(t=s=s||{}).KEY_SYSTEM_NO_KEYS="keySystemNoKeys",t.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",t.KEY_SYSTEM_NO_SESSION="keySystemNoSession",t.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",t.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",t.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",t.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",t.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",t.MANIFEST_LOAD_ERROR="manifestLoadError",t.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",t.MANIFEST_PARSING_ERROR="manifestParsingError",t.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",t.LEVEL_EMPTY_ERROR="levelEmptyError",t.LEVEL_LOAD_ERROR="levelLoadError",t.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",t.LEVEL_SWITCH_ERROR="levelSwitchError",t.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",t.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",t.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",t.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",t.FRAG_LOAD_ERROR="fragLoadError",t.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",t.FRAG_DECRYPT_ERROR="fragDecryptError",t.FRAG_PARSING_ERROR="fragParsingError",t.REMUX_ALLOC_ERROR="remuxAllocError",t.KEY_LOAD_ERROR="keyLoadError",t.KEY_LOAD_TIMEOUT="keyLoadTimeOut",t.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",t.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",t.BUFFER_APPEND_ERROR="bufferAppendError",t.BUFFER_APPENDING_ERROR="bufferAppendingError",t.BUFFER_STALLED_ERROR="bufferStalledError",t.BUFFER_FULL_ERROR="bufferFullError",t.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",t.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",t.INTERNAL_EXCEPTION="internalException",t.INTERNAL_ABORTED="aborted",t.UNKNOWN="unknown"},"./src/events.ts":(e,t,i)=>{var r;i.r(t),i.d(t,{Events:()=>r}),(i=r=r||{}).MEDIA_ATTACHING="hlsMediaAttaching",i.MEDIA_ATTACHED="hlsMediaAttached",i.MEDIA_DETACHING="hlsMediaDetaching",i.MEDIA_DETACHED="hlsMediaDetached",i.BUFFER_RESET="hlsBufferReset",i.BUFFER_CODECS="hlsBufferCodecs",i.BUFFER_CREATED="hlsBufferCreated",i.BUFFER_APPENDING="hlsBufferAppending",i.BUFFER_APPENDED="hlsBufferAppended",i.BUFFER_EOS="hlsBufferEos",i.BUFFER_FLUSHING="hlsBufferFlushing",i.BUFFER_FLUSHED="hlsBufferFlushed",i.MANIFEST_LOADING="hlsManifestLoading",i.MANIFEST_LOADED="hlsManifestLoaded",i.MANIFEST_PARSED="hlsManifestParsed",i.LEVEL_SWITCHING="hlsLevelSwitching",i.LEVEL_SWITCHED="hlsLevelSwitched",i.LEVEL_LOADING="hlsLevelLoading",i.LEVEL_LOADED="hlsLevelLoaded",i.LEVEL_UPDATED="hlsLevelUpdated",i.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",i.LEVELS_UPDATED="hlsLevelsUpdated",i.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",i.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",i.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",i.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",i.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",i.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",i.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",i.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",i.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",i.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",i.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",i.CUES_PARSED="hlsCuesParsed",i.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",i.INIT_PTS_FOUND="hlsInitPtsFound",i.FRAG_LOADING="hlsFragLoading",i.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",i.FRAG_LOADED="hlsFragLoaded",i.FRAG_DECRYPTED="hlsFragDecrypted",i.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",i.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",i.FRAG_PARSING_METADATA="hlsFragParsingMetadata",i.FRAG_PARSED="hlsFragParsed",i.FRAG_BUFFERED="hlsFragBuffered",i.FRAG_CHANGED="hlsFragChanged",i.FPS_DROP="hlsFpsDrop",i.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",i.ERROR="hlsError",i.DESTROYING="hlsDestroying",i.KEY_LOADING="hlsKeyLoading",i.KEY_LOADED="hlsKeyLoaded",i.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",i.BACK_BUFFER_REACHED="hlsBackBufferReached"},"./src/hls.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>b});var r=i("./node_modules/url-toolkit/src/url-toolkit.js"),s=i("./src/loader/playlist-loader.ts"),a=i("./src/controller/id3-track-controller.ts"),n=i("./src/controller/latency-controller.ts"),o=i("./src/controller/level-controller.ts"),l=i("./src/controller/fragment-tracker.ts"),d=i("./src/loader/key-loader.ts"),h=i("./src/controller/stream-controller.ts"),c=i("./src/is-supported.ts"),u=i("./src/utils/logger.ts"),p=i("./src/config.ts"),f=i("./node_modules/eventemitter3/index.js"),m=i("./src/events.ts"),g=i("./src/errors.ts"),y=i("./src/types/level.ts");function A(e,t){for(var i,r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,"symbol"==typeof(i=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);if(t=t.call(e,"string"),"object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(s.key))?i:String(i),s)}}v.isSupported=function(){return(0,c.isSupported)()},(t=v.prototype).createController=function(e,t){return e?(e=new e(this),t&&t.push(e),e):null},t.on=function(e,t,i){this._emitter.on(e,t,i=void 0===i?this:i)},t.once=function(e,t,i){this._emitter.once(e,t,i=void 0===i?this:i)},t.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},t.off=function(e,t,i,r){this._emitter.off(e,t,i=void 0===i?this:i,r)},t.listeners=function(e){return this._emitter.listeners(e)},t.emit=function(e,t,i){return this._emitter.emit(e,t,i)},t.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){u.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),this.trigger(m.Events.ERROR,{type:g.ErrorTypes.OTHER_ERROR,details:g.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:e,error:t})}return!1},t.listenerCount=function(e){return this._emitter.listenerCount(e)},t.destroy=function(){u.logger.log("destroy"),this.trigger(m.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(e){return e.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(e){return e.destroy()})),this.coreComponents.length=0},t.attachMedia=function(e){u.logger.log("attachMedia"),this._media=e,this.trigger(m.Events.MEDIA_ATTACHING,{media:e})},t.detachMedia=function(){u.logger.log("detachMedia"),this.trigger(m.Events.MEDIA_DETACHING,void 0),this._media=null},t.loadSource=function(e){this.stopLoad();var t=this.media,i=this.url,s=this.url=r.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});u.logger.log("loadSource:"+s),t&&i&&i!==s&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(t)),this.trigger(m.Events.MANIFEST_LOADING,{url:e})},t.startLoad=function(e){void 0===e&&(e=-1),u.logger.log("startLoad("+e+")"),this.networkControllers.forEach((function(t){t.startLoad(e)}))},t.stopLoad=function(){u.logger.log("stopLoad"),this.networkControllers.forEach((function(e){e.stopLoad()}))},t.swapAudioCodec=function(){u.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},t.recoverMediaError=function(){u.logger.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},t.removeLevel=function(e,t){this.levelController.removeLevel(e,t=void 0===t?0:t)},t=[{key:"version",get:function(){return"1.3.2"}},{key:"Events",get:function(){return m.Events}},{key:"ErrorTypes",get:function(){return g.ErrorTypes}},{key:"ErrorDetails",get:function(){return g.ErrorDetails}},{key:"DefaultConfig",get:function(){return v.defaultConfig||p.hlsDefaultConfig},set:function(e){v.defaultConfig=e}}],A((i=v).prototype,[{key:"levels",get:function(){return this.levelController.levels||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){u.logger.log("set currentLevel:"+e),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){u.logger.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){u.logger.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){u.logger.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){u.logger.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){e=!!e,e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(u.logger.log("set autoLevelCapping:"+e),this._autoLevelCapping=e)}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){-1<y.HdcpLevels.indexOf(e)&&(this._maxHdcpLevel=e)}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var i=e.length,r=0;r<i;r++)if(e[r].maxBitrate>=t)return r;return 0}},{key:"maxAutoLevel",get:function(){var e=this.levels,t=this.autoLevelCapping,i=this.maxHdcpLevel;t=-1===t&&e&&e.length?e.length-1:t;if(i)for(var r=t;r--;){var s=e[r].attrs["HDCP-LEVEL"];if(s&&s<=i)return r}return t}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}]),A(i,t),Object.defineProperty(i,"prototype",{writable:!1});var b=v;function v(e){void 0===e&&(e={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new f.EventEmitter,this._autoLevelCapping=void 0,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;var t=this.config=(0,p.mergeConfig)(v.DefaultConfig,e),i=(e=(this.userConfig=e,(0,u.enableLogs)(t.debug,"Hls instance"),this._autoLevelCapping=-1,t.progressive&&(0,p.enableStreamingMode)(t),t.abrController),t.bufferController),r=t.capLevelController,c=t.fpsController,m=(e=this.abrController=new e(this),i=this.bufferController=new i(this),r=this.capLevelController=new r(this),c=new c(this),new s.default(this)),g=new a.default(this),y=this.levelController=new o.default(this),A=new l.FragmentTracker(this),b=new d.default(this.config),_=this.streamController=new h.default(this,A,b);r.setStreamController(_),c.setStreamController(_),m=[m,y,_],this.networkControllers=m,y=[e,i,r,c,g,A],this.audioTrackController=this.createController(t.audioTrackController,m),_=t.audioStreamController,_&&m.push(new _(this,A,b)),this.subtitleTrackController=this.createController(t.subtitleTrackController,m),e=t.subtitleStreamController;e&&m.push(new e(this,A,b)),this.createController(t.timelineController,y),b.emeController=this.emeController=this.createController(t.emeController,y),this.cmcdController=this.createController(t.cmcdController,y),this.latencyController=this.createController(n.default,y),this.coreComponents=y}b.defaultConfig=void 0},"./src/is-supported.ts":(e,t,i)=>{i.r(t),i.d(t,{changeTypeSupported:()=>function(){var e=s();return"function"==typeof(null==e||null==(e=e.prototype)?void 0:e.changeType)},isSupported:()=>function(){var e=(0,r.getMediaSource)();if(!e)return!1;var t=s();e=e&&"function"==typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),t=!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove;return!!e&&!!t}});var r=i("./src/utils/mediasource-helper.ts");function s(){return self.SourceBuffer||self.WebKitSourceBuffer}},"./src/loader/date-range.ts":(e,t,i)=>{i.r(t),i.d(t,{DateRange:()=>d,DateRangeAttribute:()=>r});var r,s=i("./src/polyfills/number.ts"),a=i("./src/utils/attr-list.ts"),n=i("./src/utils/logger.ts");function o(){return(o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i,r=arguments[t];for(i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e}).apply(this,arguments)}function l(e,t){for(var i,r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,"symbol"==typeof(i=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);if(t=t.call(e,"string"),"object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(s.key))?i:String(i),s)}}(t=r=r||{}).ID="ID",t.CLASS="CLASS",t.START_DATE="START-DATE",t.DURATION="DURATION",t.END_DATE="END-DATE",t.END_ON_NEXT="END-ON-NEXT",t.PLANNED_DURATION="PLANNED-DURATION",t.SCTE35_OUT="SCTE35-OUT",t.SCTE35_IN="SCTE35-IN",l((i=h).prototype,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var e=this.duration;return null!==e?new Date(this._startDate.getTime()+1e3*e):null}},{key:"duration",get:function(){if(r.DURATION in this.attr){var e=this.attr.decimalFloatingPoint(r.DURATION);if((0,s.isFiniteNumber)(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return r.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(r.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(r.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&(0,s.isFiniteNumber)(this.startDate.getTime())&&(null===this.duration||0<=this.duration)&&(!this.endOnNext||!!this.class)}}]),Object.defineProperty(i,"prototype",{writable:!1});var d=h;function h(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){var i,l=t.attr;for(i in l)if(Object.prototype.hasOwnProperty.call(e,i)&&e[i]!==l[i]){n.logger.warn('DATERANGE tag attribute: "'+i+'" does not match for tags with ID: "'+e.ID+'"'),this._badValueForSameId=i;break}e=o(new a.AttrList({}),l,e)}this.attr=e,this._startDate=new Date(e[r.START_DATE]),r.END_DATE in this.attr&&(t=new Date(this.attr[r.END_DATE]),(0,s.isFiniteNumber)(t.getTime())&&(this._endDate=t))}},"./src/loader/fragment-loader.ts":(e,t,i)=>{i.r(t),i.d(t,{LoadError:()=>f,default:()=>h});var r=i("./src/polyfills/number.ts"),s=i("./src/errors.ts");function a(e){var t="function"==typeof Map?new Map:void 0;return(a=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return n(e,arguments,l(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),o(i,e)})(e)}function n(e,t,i){return(n=function(){if("undefined"!=typeof Reflect&&Reflect.construct&&!Reflect.construct.sham){if("function"==typeof Proxy)return 1;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),1}catch(e){return}}}()?Reflect.construct.bind():function(e,t,i){var r=[null];r.push.apply(r,t),t=new(Function.bind.apply(e,r));return i&&o(t,i.prototype),t}).apply(null,arguments)}function o(e,t){return(o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var d=Math.pow(2,17),h=((t=c.prototype).destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},t.abort=function(){this.loader&&this.loader.abort()},t.load=function(e,t){var i=this,r=e.url;if(!r)return Promise.reject(new f({type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,networkDetails:null},"Fragment does not have a "+(r?"part list":"url")));this.abort();var a=this.config,n=a.fLoader,o=a.loader;return new Promise((function(r,l){i.loader&&i.loader.destroy();var h=i.loader=e.loader=new(n||o)(a),c=u(e),p={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:"initSegment"===e.sn?1/0:d};e.stats=h.stats,h.load(c,p,{onSuccess:function(t,s,a,n){i.resetLoader(e,h),t=t.data,a.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(t.slice(0,16)),t=t.slice(16)),r({frag:e,part:null,payload:t,networkDetails:n})},onError:function(t,r,a){i.resetLoader(e,h),l(new f({type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:t,networkDetails:a}))},onAbort:function(t,r,a){i.resetLoader(e,h),l(new f({type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,networkDetails:a}))},onTimeout:function(t,r,a){i.resetLoader(e,h),l(new f({type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,networkDetails:a}))},onProgress:function(i,r,s,a){t&&t({frag:e,part:null,payload:s,networkDetails:a})}})}))},t.loadPart=function(e,t,i){var r=this,a=(this.abort(),this.config),n=a.fLoader,o=a.loader;return new Promise((function(l,h){r.loader&&r.loader.destroy();var c=r.loader=e.loader=new(n||o)(a),p=u(e,t),m={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:d};t.stats=c.stats,c.load(p,m,{onSuccess:function(s,a,n,o){r.resetLoader(e,c),r.updateStatsFromPart(e,t),s={frag:e,part:t,payload:s.data,networkDetails:o},i(s),l(s)},onError:function(i,a,n){r.resetLoader(e,c),h(new f({type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:i,networkDetails:n}))},onAbort:function(i,a,n){e.stats.aborted=t.stats.aborted,r.resetLoader(e,c),h(new f({type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,networkDetails:n}))},onTimeout:function(i,a,n){r.resetLoader(e,c),h(new f({type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,networkDetails:n}))}})}))},t.updateStatsFromPart=function(e,t){var i=e.stats,r=t.stats,s=r.total;i.loaded+=r.loaded,s?(s=((e=Math.round(e.duration/t.duration))-(t=Math.min(Math.round(i.loaded/s),e)))*Math.round(i.loaded/t),i.total=i.loaded+s):i.total=Math.max(i.loaded,i.total),e=i.loading,t=r.loading;e.start?e.first+=t.first-t.start:(e.start=t.start,e.first=t.first),e.end=t.end},t.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},c);function c(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}function u(e,t){var i,s,a=(t=void 0===t?null:t)||e,n=(t={frag:e,part:t,responseType:"arraybuffer",url:a.url,headers:{},rangeStart:0,rangeEnd:0},a.byteRangeStartOffset);a=a.byteRangeEndOffset;return(0,r.isFiniteNumber)(n)&&(0,r.isFiniteNumber)(a)&&(i=n,s=a,"initSegment"===e.sn&&"AES-128"===(null==(e=e.decryptdata)?void 0:e.method)&&((e=a-n)%16&&(s=a+(16-e%16)),0!==n&&(t.resetIV=!0,i=n-16)),t.rangeStart=i,t.rangeEnd=s),t}p=a(Error),i=p,(t=m).prototype=Object.create(i.prototype),o(t.prototype.constructor=t,i);var p,f=m;function m(e){for(var t,i=arguments.length,r=new Array(1<i?i-1:0),s=1;s<i;s++)r[s-1]=arguments[s];return(t=p.call.apply(p,[this].concat(r))||this).data=void 0,t.data=e,t}},"./src/loader/fragment.ts":(e,t,i)=>{i.r(t),i.d(t,{BaseSegment:()=>p,ElementaryStreamTypes:()=>r,Fragment:()=>f,Part:()=>m});var r,s=i("./src/polyfills/number.ts"),a=i("./node_modules/url-toolkit/src/url-toolkit.js"),n=i("./src/loader/load-stats.ts");function o(e,t){e.prototype=Object.create(t.prototype),l(e.prototype.constructor=e,t)}function l(e,t){return(l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function d(e,t){for(var i,r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,"symbol"==typeof(i=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);if(t=t.call(e,"string"),"object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(s.key))?i:String(i),s)}}function h(e,t,i){t&&d(e.prototype,t),i&&d(e,i),Object.defineProperty(e,"prototype",{writable:!1})}(t=r=r||{}).AUDIO="audio",t.VIDEO="video",t.AUDIOVIDEO="audiovideo",A.prototype.setByteRange=function(e,t){e=e.split("@",2);var i=[];1===e.length?i[0]=t?t.byteRangeEndOffset:0:i[0]=parseInt(e[1]),i[1]=parseInt(e[0])+i[0],this._byteRange=i},h(A,[{key:"byteRange",get:function(){return this._byteRange||[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=(0,a.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}}]);var c,u,p=A,f=(o(y,u=p),(i=y.prototype).setKeyFormat=function(e){this.levelkeys&&(e=this.levelkeys[e])&&!this._decryptdata&&(this._decryptdata=e.getDecryptData(this.sn))},i.abortRequests=function(){var e;null!=(e=this.loader)&&e.abort(),null!=(e=this.keyLoader)&&e.abort()},i.setElementaryStreamInfo=function(e,t,i,r,s,a){void 0===a&&(a=!1);var n=this.elementaryStreams,o=n[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,i),o.startDTS=Math.min(o.startDTS,r),o.endDTS=Math.max(o.endDTS,s)):n[e]={startPTS:t,endPTS:i,startDTS:r,endDTS:s,partial:a}},i.clearElementaryStreamInfo=function(){var e=this.elementaryStreams;e[r.AUDIO]=null,e[r.VIDEO]=null,e[r.AUDIOVIDEO]=null},h(y,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else if(e=Object.keys(this.levelkeys),1===e.length)return this._decryptdata=this.levelkeys[e[0]].getDecryptData(this.sn)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!(0,s.isFiniteNumber)(this.programDateTime))return null;var e=(0,s.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var e=Object.keys(this.levelkeys),t=e.length;if(1<t||1===t&&this.levelkeys[e[0]].encrypted)return!0}return!1}}]),y),m=(o(g,c=p),h(g,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),g);function g(e,t,i,r,s){return(i=c.call(this,i)||this).fragOffset=0,i.duration=0,i.gap=!1,i.independent=!1,i.relurl=void 0,i.fragment=void 0,i.index=void 0,i.stats=new n.LoadStats,i.duration=e.decimalFloatingPoint("DURATION"),i.gap=e.bool("GAP"),i.independent=e.bool("INDEPENDENT"),i.relurl=e.enumeratedString("URI"),i.fragment=t,i.index=r,t=e.enumeratedString("BYTERANGE"),t&&i.setByteRange(t,s),s&&(i.fragOffset=s.fragOffset+s.duration),i}function y(e,t){return(t=u.call(this,t)||this)._decryptdata=null,t.rawProgramDateTime=null,t.programDateTime=null,t.tagList=[],t.duration=0,t.sn=0,t.levelkeys=void 0,t.type=void 0,t.loader=null,t.keyLoader=null,t.level=-1,t.cc=0,t.startPTS=void 0,t.endPTS=void 0,t.appendedPTS=void 0,t.startDTS=void 0,t.endDTS=void 0,t.start=0,t.deltaPTS=void 0,t.maxStartPTS=void 0,t.minEndPTS=void 0,t.stats=new n.LoadStats,t.urlId=0,t.data=void 0,t.bitrateTest=!1,t.title=null,t.initSegment=null,t.endList=void 0,t.type=e,t}function A(e){var t;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((t={})[r.AUDIO]=null,t[r.VIDEO]=null,t[r.AUDIOVIDEO]=null,t),this.baseurl=e}},"./src/loader/key-loader.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>a});var r=i("./src/errors.ts"),s=i("./src/loader/fragment-loader.ts"),a=((t=n.prototype).abort=function(){for(var e in this.keyUriToKeyInfo)e=this.keyUriToKeyInfo[e].loader,e&&e.abort()},t.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},t.destroy=function(){for(var e in this.detach(),this.keyUriToKeyInfo)e=this.keyUriToKeyInfo[e].loader,e&&e.destroy();this.keyUriToKeyInfo={}},t.createKeyLoadError=function(e,t,i,a){return void 0===t&&(t=r.ErrorDetails.KEY_LOAD_ERROR),new s.LoadError({type:r.ErrorTypes.NETWORK_ERROR,details:t,fatal:!1,frag:e,networkDetails:i})},t.loadClear=function(e,t){var i=this;if(this.emeController&&this.config.emeEnabled)for(var r=e.sn,s=e.cc,a=0;a<t.length&&"break"!==function(e){var a=t[e];if(s<=a.cc&&("initSegment"===r||r<a.sn))return i.emeController.selectKeySystemFormat(a).then((function(e){a.setKeyFormat(e)})),"break"}(a);a++);},t.load=function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then((function(i){return t.loadInternal(e,i)})):this.loadInternal(e)},t.loadInternal=function(e,t){t&&e.setKeyFormat(t);var i=e.decryptdata;if(!i)return Promise.reject(this.createKeyLoadError(e,r.ErrorDetails.KEY_LOAD_ERROR,null,t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading"));if(t=i.uri,!t)return Promise.reject(this.createKeyLoadError(e,r.ErrorDetails.KEY_LOAD_ERROR,null,'Invalid key URI: "'+t+'"'));var s,a=this.keyUriToKeyInfo[t];if(null!=(s=a)&&s.decryptdata.key)return i.key=a.decryptdata.key,Promise.resolve({frag:e,keyInfo:a});if(null!=(s=a)&&s.keyLoadPromise)switch(null==(s=a.mediaKeySessionContext)?void 0:s.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return a.keyLoadPromise}switch(a=this.keyUriToKeyInfo[t]={decryptdata:i,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},i.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===i.keyFormat?this.loadKeyHTTP(a,e):this.loadKeyEME(a,e);case"AES-128":return this.loadKeyHTTP(a,e);default:return Promise.reject(this.createKeyLoadError(e,r.ErrorDetails.KEY_LOAD_ERROR,null,'Key supplied with unsupported METHOD: "'+i.method+'"'))}},t.loadKeyEME=function(e,t){var i={frag:t,keyInfo:e};return this.emeController&&this.config.emeEnabled&&(t=this.emeController.loadKey(i),t)?(e.keyLoadPromise=t.then((function(t){return e.mediaKeySessionContext=t,i}))).catch((function(t){throw e.keyLoadPromise=null,t})):Promise.resolve(i)},t.loadKeyHTTP=function(e,t){var i=this,s=this.config,a=new s.loader(s);return t.keyLoader=e.loader=a,e.keyLoadPromise=new Promise((function(n,o){var l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},d={timeout:s.fragLoadingTimeOut,maxRetry:0,retryDelay:s.fragLoadingRetryDelay,maxRetryDelay:s.fragLoadingMaxRetryTimeout,highWaterMark:0};a.load(l,d,{onSuccess:function(e,t,s,a){var l=s.frag,d=s.keyInfo;s=s.url;if(!l.decryptdata||d!==i.keyUriToKeyInfo[s])return o(i.createKeyLoadError(l,r.ErrorDetails.KEY_LOAD_ERROR,a,"after key load, decryptdata unset or changed"));d.decryptdata.key=l.decryptdata.key=new Uint8Array(e.data),l.keyLoader=null,d.loader=null,n({frag:l,keyInfo:d})},onError:function(e,s,a){i.resetLoader(s),o(i.createKeyLoadError(t,r.ErrorDetails.KEY_LOAD_ERROR,a))},onTimeout:function(e,s,a){i.resetLoader(s),o(i.createKeyLoadError(t,r.ErrorDetails.KEY_LOAD_TIMEOUT,a))},onAbort:function(e,s,a){i.resetLoader(s),o(i.createKeyLoadError(t,r.ErrorDetails.INTERNAL_ABORTED,a))}})}))},t.resetLoader=function(e){var t=e.frag,i=e.keyInfo,r=(e=e.url,i.loader);t.keyLoader===r&&(t.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[e],r&&r.destroy()},n);function n(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}},"./src/loader/level-details.ts":(e,t,i)=>{i.r(t),i.d(t,{LevelDetails:()=>a});var r=i("./src/polyfills/number.ts");function s(e,t){for(var i,r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,"symbol"==typeof(i=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);if(t=t.call(e,"string"),"object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(s.key))?i:String(i),s)}}n.prototype.reloaded=function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t,this.advanced=this.endSN>e.endSN||0<t||0==t&&0<i,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay},s((t=n).prototype,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&(0,r.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return 0<e?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),Object.defineProperty(t,"prototype",{writable:!1});var a=n;function n(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.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}},"./src/loader/level-key.ts":(e,t,i)=>{i.r(t),i.d(t,{LevelKey:()=>d});var r=i("./src/utils/keysystem-util.ts"),s=i("./src/utils/mediakeys-helper.ts"),a=i("./src/utils/mp4-tools.ts"),n=i("./src/utils/logger.ts"),o=i("./src/utils/numeric-encoding-utils.ts"),l={},d=(h.clearKeyUriToKeyIdMap=function(){l={}},(t=h.prototype).isSupported=function(){if(this.method){if("AES-128"===this.method||"NONE"===this.method)return!0;switch(this.keyFormat){case"identity":return"SAMPLE-AES"===this.method;case s.KeySystemFormats.FAIRPLAY:case s.KeySystemFormats.WIDEVINE:case s.KeySystemFormats.PLAYREADY:case s.KeySystemFormats.CLEARKEY:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1},t.getDecryptData=function(e){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv)return"number"!=typeof e&&("AES-128"!==this.method||this.iv||n.logger.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),e=0),e=function(e){for(var t=new Uint8Array(16),i=12;i<16;i++)t[i]=e>>8*(15-i)&255;return t}(e),new h(this.method,this.uri,"identity",this.keyFormatVersions,e);var t,i=(0,r.convertDataUriToArrayBytes)(this.uri);if(i)switch(this.keyFormat){case s.KeySystemFormats.WIDEVINE:22<=(this.pssh=i).length&&(this.keyId=i.subarray(i.length-22,i.length-6));break;case s.KeySystemFormats.PLAYREADY:var d=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);d=(this.pssh=(0,a.mp4pssh)(d,null,i),new Uint16Array(i.buffer,i.byteOffset,i.byteLength/2)),d=String.fromCharCode.apply(null,Array.from(d)),d=d.substring(d.indexOf("<"),d.length),d=(new DOMParser).parseFromString(d,"text/xml").getElementsByTagName("KID")[0];!d||(d=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE"))&&(d=(0,o.base64Decode)(d).subarray(0,16),(0,r.changeEndianness)(d),this.keyId=d);break;default:var c;d=i.subarray(0,16);16!==d.length&&((c=new Uint8Array(16)).set(d,16-d.length),d=c),this.keyId=d}return this.keyId&&16===this.keyId.byteLength||((e=l[this.uri])||(t=Object.keys(l).length%Number.MAX_SAFE_INTEGER,e=new Uint8Array(16),new DataView(e.buffer,12,4).setUint32(0,t),l[this.uri]=e),this.keyId=e),this},h);function h(e,t,i,r,s){void 0===r&&(r=[1]),void 0===s&&(s=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=r,this.iv=s,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&"AES-128"!==e}},"./src/loader/load-stats.ts":(e,t,i)=>{i.r(t),i.d(t,{LoadStats:()=>r});var r=function(){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}}},"./src/loader/m3u8-parser.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>y});var r=i("./src/polyfills/number.ts"),s=i("./node_modules/url-toolkit/src/url-toolkit.js"),a=i("./src/loader/date-range.ts"),n=i("./src/loader/fragment.ts"),o=i("./src/loader/level-details.ts"),l=i("./src/loader/level-key.ts"),d=i("./src/utils/attr-list.ts"),h=i("./src/utils/logger.ts"),c=i("./src/utils/codecs.ts");function u(){return(u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i,r=arguments[t];for(i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e}).apply(this,arguments)}var p=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+|#EXT-X-SESSION-KEY:([^\n\r]*)[\r\n]+/g,f=/#EXT-X-MEDIA:(.*)/g,m=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),g=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|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)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),y=(A.findGroup=function(e,t){for(var i=0;i<e.length;i++){var r=e[i];if(r.id===t)return r}},A.convertAVC1ToAVCOTI=function(e){var t,i=e.split(".");return 2<i.length?(t=i.shift()+".",(t+=parseInt(i.shift()).toString(16))+("000"+parseInt(i.shift()).toString(16)).slice(-4)):e},A.resolve=function(e,t){return(0,s.buildAbsoluteURL)(t,e,{alwaysNormalize:!0})},A.parseMasterPlaylist=function(e,t){var i,r,s,a,n=[],o=[],l={},u=[],f=!1;for(p.lastIndex=0;null!=(i=p.exec(e));)i[1]?(a={attrs:r=new d.AttrList(i[1]),bitrate:r.decimalInteger("AVERAGE-BANDWIDTH")||r.decimalInteger("BANDWIDTH"),name:r.NAME,url:A.resolve(i[2],t)},(s=r.decimalResolution("RESOLUTION"))&&(a.width=s.width,a.height=s.height),function(e,t){["video","audio","text"].forEach((function(i){var r,s=e.filter((function(e){return(0,c.isCodecType)(e,i)}));s.length&&(r=s.filter((function(e){return 0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0)})),t[i+"Codec"]=(0<r.length?r:s)[0],e=e.filter((function(e){return-1===s.indexOf(e)})))})),t.unknownCodecs=e}((r.CODECS||"").split(/[ ,]+/).filter((function(e){return e})),a),a.videoCodec&&-1!==a.videoCodec.indexOf("avc1")&&(a.videoCodec=A.convertAVC1ToAVCOTI(a.videoCodec)),null!=(s=a.unknownCodecs)&&s.length||o.push(a),n.push(a)):i[3]?(r=new d.AttrList(i[3]))["DATA-ID"]&&(f=!0,l[r["DATA-ID"]]=r):i[4]&&((a=b(s=i[4],t)).encrypted&&a.isSupported()?u.push(a):h.logger.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+s+'"'));return{levels:0<o.length&&o.length<n.length?o:n,sessionData:f?l:null,sessionKeys:u.length?u:null}},A.parseMasterPlaylistMedia=function(e,t,i,r){void 0===r&&(r=[]);var s=[],a=0;for(f.lastIndex=0;null!==(o=f.exec(e));){var n,o=new d.AttrList(o[1]);o.TYPE===i&&(o={attrs:o,bitrate:0,id:a++,groupId:o["GROUP-ID"],instreamId:o["INSTREAM-ID"],name:o.NAME||o.LANGUAGE||"",type:i,default:o.bool("DEFAULT"),autoselect:o.bool("AUTOSELECT"),forced:o.bool("FORCED"),lang:o.LANGUAGE,url:o.URI?A.resolve(o.URI,t):""},r.length&&(v(o,n=A.findGroup(r,o.groupId)||r[0],"audioCodec"),v(o,n,"textCodec")),s.push(o))}return s},A.parseLevelPlaylist=function(e,t,i,s,l){var c,p,f,y=new o.LevelDetails(t),A=y.fragments,v=null,S=0,E=0,T=0,k=0,x=null,C=new n.Fragment(s,t),L=-1,D=!1;for(m.lastIndex=0,y.m3u8=e;null!==(c=m.exec(e));){D&&(D=!1,(C=new n.Fragment(s,t)).start=T,C.sn=S,C.cc=k,C.level=i,v&&(C.initSegment=v,C.rawProgramDateTime=v.rawProgramDateTime,v.rawProgramDateTime=null));var R=c[1];if(R){C.duration=parseFloat(R);var I=(" "+c[2]).slice(1);C.title=I||null,C.tagList.push(I?["INF",R,I]:["INF",R])}else if(c[3])(0,r.isFiniteNumber)(C.duration)&&(C.start=T,f&&(C.levelkeys=f,I=y.encryptedFragments,!C.levelkeys||!Object.keys(C.levelkeys).some((function(e){return C.levelkeys[e].isCommonEncryption}))||I.length&&I[I.length-1].levelkeys===f||I.push(C)),C.sn=S,C.level=i,C.cc=k,C.urlId=l,A.push(C),C.relurl=(" "+c[3]).slice(1),_(C,x),T+=(x=C).duration,S++,D=!(E=0));else if(c[4])R=(" "+c[4]).slice(1),x?C.setByteRange(R,x):C.setByteRange(R);else if(c[5])C.rawProgramDateTime=(" "+c[5]).slice(1),C.tagList.push(["PROGRAM-DATE-TIME",C.rawProgramDateTime]),-1===L&&(L=A.length);else if(c=c[0].match(g)){for(p=1;p<c.length&&void 0===c[p];p++);var P=(" "+c[p]).slice(1),B=(" "+c[p+1]).slice(1),U=c[p+2]?(" "+c[p+2]).slice(1):"";switch(P){case"PLAYLIST-TYPE":y.type=B.toUpperCase();break;case"MEDIA-SEQUENCE":S=y.startSN=parseInt(B);break;case"SKIP":var F=new d.AttrList(B),M=F.decimalInteger("SKIPPED-SEGMENTS");if((0,r.isFiniteNumber)(M)){for(var O=y.skippedSegments=M;O--;)A.unshift(null);S+=M}M=F.enumeratedString("RECENTLY-REMOVED-DATERANGES"),M&&(y.recentlyRemovedDateranges=M.split("\t"));break;case"TARGETDURATION":y.targetduration=parseFloat(B);break;case"VERSION":y.version=parseInt(B);break;case"EXTM3U":break;case"ENDLIST":y.live=!1;break;case"#":(B||U)&&C.tagList.push(U?[B,U]:[B]);break;case"DISCONTINUITY":k++,C.tagList.push(["DIS"]);break;case"GAP":C.tagList.push([P]);break;case"BITRATE":C.tagList.push([P,B]);break;case"DATERANGE":F=new d.AttrList(B),M=new a.DateRange(F,y.dateRanges[F.ID]),M.isValid||y.skippedSegments?y.dateRanges[M.id]=M:h.logger.warn('Ignoring invalid DATERANGE tag: "'+B+'"'),C.tagList.push(["EXT-X-DATERANGE",B]);break;case"DISCONTINUITY-SEQUENCE":k=parseInt(B);break;case"KEY":var N=b(B,t);if(N.isSupported()){if("NONE"===N.method){f=void 0;break}(f=(f=f||{})[N.keyFormat]?u({},f):f)[N.keyFormat]=N}else h.logger.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+B+'"');break;case"START":N=new d.AttrList(B).decimalFloatingPoint("TIME-OFFSET"),(0,r.isFiniteNumber)(N)&&(y.startTimeOffset=N);break;case"MAP":var j=new d.AttrList(B);C.duration?(w(z=new n.Fragment(s,t),j,i,f),(C.initSegment=v=z).rawProgramDateTime&&!C.rawProgramDateTime&&(C.rawProgramDateTime=v.rawProgramDateTime)):(w(C,j,i,f),v=C,D=!0);break;case"SERVER-CONTROL":var z=new d.AttrList(B);y.canBlockReload=z.bool("CAN-BLOCK-RELOAD"),y.canSkipUntil=z.optionalFloat("CAN-SKIP-UNTIL",0),y.canSkipDateRanges=0<y.canSkipUntil&&z.bool("CAN-SKIP-DATERANGES"),y.partHoldBack=z.optionalFloat("PART-HOLD-BACK",0),y.holdBack=z.optionalFloat("HOLD-BACK",0);break;case"PART-INF":j=new d.AttrList(B),y.partTarget=j.decimalFloatingPoint("PART-TARGET");break;case"PART":var G=(G=y.partList)||(y.partList=[]),H=0<E?G[G.length-1]:void 0,W=E++;W=new n.Part(new d.AttrList(B),C,t,W,H);G.push(W),C.duration+=W.duration;break;case"PRELOAD-HINT":H=new d.AttrList(B),y.preloadHint=H;break;case"RENDITION-REPORT":G=new d.AttrList(B),y.renditionReports=y.renditionReports||[],y.renditionReports.push(G);break;default:h.logger.warn("line parsed but not handled: "+c)}}else h.logger.warn("No matches on slow regex match for level playlist!")}x&&!x.relurl?(A.pop(),T-=x.duration,y.partList&&(y.fragmentHint=x)):y.partList&&(_(C,x),C.cc=k,y.fragmentHint=C);var V=A.length,K=A[0],$=A[V-1];return 0<(T+=y.skippedSegments*y.targetduration)&&V&&$?(y.averagetargetduration=T/V,V=$.sn,y.endSN="initSegment"!==V?V:0,y.live||($.endList=!0),K&&(y.startCC=K.cc)):(y.endSN=0,y.startCC=0),y.fragmentHint&&(T+=y.fragmentHint.duration),y.totalduration=T,y.endCC=k,0<L&&function(e,t){for(var i=e[t],r=t;r--;){var s=e[r];if(!s)return;s.programDateTime=i.programDateTime-1e3*s.duration,i=s}}(A,L),y},A);function A(){}function b(e,t){e=new d.AttrList(e);var i=null!=(i=e.enumeratedString("METHOD"))?i:"",r=e.URI,s=e.hexadecimalInteger("IV"),a=e.enumeratedString("KEYFORMATVERSIONS"),n=null!=(n=e.enumeratedString("KEYFORMAT"))?n:"identity";r&&e.IV&&!s&&h.logger.error("Invalid IV: "+e.IV),e=r?y.resolve(r,t):"",r=(a||"1").split("/").map(Number).filter(Number.isFinite);return new l.LevelKey(i,e,n,r,s)}function v(e,t,i){t=t[i],t&&(e[i]=t)}function _(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),(0,r.isFiniteNumber)(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function w(e,t,i,r){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=i,e.sn="initSegment",r&&(e.levelkeys=r),e.initSegment=null}},"./src/loader/playlist-loader.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>u});var r=i("./src/polyfills/number.ts"),s=i("./src/events.ts"),a=i("./src/errors.ts"),n=i("./src/utils/logger.ts"),o=i("./src/loader/m3u8-parser.ts"),l=i("./src/types/loader.ts"),d=i("./src/utils/attr-list.ts");function h(e,t){return e=e.url,void 0!==e&&0!==e.indexOf("data:")?e:t.url}function c(e){this.hls=void 0,this.loaders=Object.create(null),this.hls=e,this.registerListeners()}(t=c.prototype).startLoad=function(e){},t.stopLoad=function(){this.destroyInternalLoaders()},t.registerListeners=function(){var e=this.hls;e.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(s.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(s.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(s.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.unregisterListeners=function(){var e=this.hls;e.off(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(s.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(s.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(s.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.createInternalLoader=function(e){var t=this.hls.config,i=t.pLoader,r=t.loader;i=new(i||r)(t);return e.loader=i,this.loaders[e.type]=i},t.getInternalLoader=function(e){return this.loaders[e.type]},t.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},t.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},t.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},t.onManifestLoading=function(e,t){t=t.url,this.load({id:null,groupId:null,level:0,responseType:"text",type:l.PlaylistContextType.MANIFEST,url:t,deliveryDirectives:null})},t.onLevelLoading=function(e,t){var i=t.id,r=t.level,s=t.url;t=t.deliveryDirectives;this.load({id:i,groupId:null,level:r,responseType:"text",type:l.PlaylistContextType.LEVEL,url:s,deliveryDirectives:t})},t.onAudioTrackLoading=function(e,t){var i=t.id,r=t.groupId,s=t.url;t=t.deliveryDirectives;this.load({id:i,groupId:r,level:null,responseType:"text",type:l.PlaylistContextType.AUDIO_TRACK,url:s,deliveryDirectives:t})},t.onSubtitleTrackLoading=function(e,t){var i=t.id,r=t.groupId,s=t.url;t=t.deliveryDirectives;this.load({id:i,groupId:r,level:null,responseType:"text",type:l.PlaylistContextType.SUBTITLE_TRACK,url:s,deliveryDirectives:t})},t.load=function(e){var t,i,r,s,a=this.hls.config;if(d=this.getInternalLoader(e)){var o=d.context;if(o&&o.url===e.url)return void n.logger.trace("[playlist-loader]: playlist request ongoing");n.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),d.abort()}switch(e.type){case l.PlaylistContextType.MANIFEST:t=a.manifestLoadingMaxRetry,i=a.manifestLoadingTimeOut,r=a.manifestLoadingRetryDelay,s=a.manifestLoadingMaxRetryTimeout;break;case l.PlaylistContextType.LEVEL:case l.PlaylistContextType.AUDIO_TRACK:case l.PlaylistContextType.SUBTITLE_TRACK:t=0,i=a.levelLoadingTimeOut;break;default:t=a.levelLoadingMaxRetry,i=a.levelLoadingTimeOut,r=a.levelLoadingRetryDelay,s=a.levelLoadingMaxRetryTimeout}var d=this.createInternalLoader(e),h=(o=(null!=(o=e.deliveryDirectives)&&o.part&&(e.type===l.PlaylistContextType.LEVEL&&null!==e.level?h=this.hls.levels[e.level].details:e.type===l.PlaylistContextType.AUDIO_TRACK&&null!==e.id?h=this.hls.audioTracks[e.id].details:e.type===l.PlaylistContextType.SUBTITLE_TRACK&&null!==e.id&&(h=this.hls.subtitleTracks[e.id].details),h)&&(o=h.partTarget,h=h.targetduration,o&&h&&(i=Math.min(1e3*Math.max(3*o,.8*h),i))),{timeout:i,maxRetry:t,retryDelay:r,maxRetryDelay:s,highWaterMark:0}),{onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)});d.load(e,o,h)},t.loadsuccess=function(e,t,i,r){void 0===r&&(r=null),this.resetInternalLoader(i.type);var s=e.data;0===s.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),0<s.indexOf("#EXTINF:")||0<s.indexOf("#EXT-X-TARGETDURATION:")?this.handleTrackOrLevelPlaylist(e,t,i,r):this.handleMasterPlaylist(e,t,i,r)):this.handleManifestParsingError(e,i,"no EXTM3U delimiter",r)},t.loaderror=function(e,t,i){this.handleNetworkError(t,i=void 0===i?null:i,!1,e)},t.loadtimeout=function(e,t,i){this.handleNetworkError(t,i=void 0===i?null:i,!0)},t.handleMasterPlaylist=function(e,t,i,r){var a,l,c=this.hls,u=e.data,p=h(e,i),f=o.default.parseMasterPlaylist(u,p),m=f.levels,g=f.sessionData;f=f.sessionKeys;m.length?(a=m.map((function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}})),l=m.map((function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}})),a=o.default.parseMasterPlaylistMedia(u,p,"AUDIO",a),l=o.default.parseMasterPlaylistMedia(u,p,"SUBTITLES",l),u=o.default.parseMasterPlaylistMedia(u,p,"CLOSED-CAPTIONS"),a.length&&!a.some((function(e){return!e.url}))&&m[0].audioCodec&&!m[0].attrs.AUDIO&&(n.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),a.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new d.AttrList({}),bitrate:0,url:""})),c.trigger(s.Events.MANIFEST_LOADED,{levels:m,audioTracks:a,subtitles:l,captions:u,url:p,stats:t,networkDetails:r,sessionData:g,sessionKeys:f})):this.handleManifestParsingError(e,i,"no level found in manifest",r)},t.handleTrackOrLevelPlaylist=function(e,t,i,n){var c=this.hls,u=i.id,p=i.level,f=i.type,m=h(e,i),g=(u=(0,r.isFiniteNumber)(u)?u:0,p=(0,r.isFiniteNumber)(p)?p:u,function(){switch(i.type){case l.PlaylistContextType.AUDIO_TRACK:return l.PlaylistLevelType.AUDIO;case l.PlaylistContextType.SUBTITLE_TRACK:return l.PlaylistLevelType.SUBTITLE;default:return l.PlaylistLevelType.MAIN}}());p=o.default.parseLevelPlaylist(e.data,m,p,g,u);p.fragments.length?(f===l.PlaylistContextType.MANIFEST&&(g={attrs:new d.AttrList({}),bitrate:0,details:p,name:"",url:m},c.trigger(s.Events.MANIFEST_LOADED,{levels:[g],audioTracks:[],url:m,stats:t,networkDetails:n,sessionData:null,sessionKeys:null})),t.parsing.end=performance.now(),i.levelDetails=p,this.handlePlaylistLoaded(e,t,i,n)):c.trigger(s.Events.ERROR,{type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:m,reason:"no fragments found in level",level:"number"==typeof i.level?i.level:void 0})},t.handleManifestParsingError=function(e,t,i,r){this.hls.trigger(s.Events.ERROR,{type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:t.type===l.PlaylistContextType.MANIFEST,url:e.url,reason:i,response:e,context:t,networkDetails:r})},t.handleNetworkError=function(e,t,i,r){n.logger.warn("[playlist-loader]: A network "+((i=void 0!==i&&i)?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var o=a.ErrorDetails.UNKNOWN,d=!1,h=this.getInternalLoader(e);switch(e.type){case l.PlaylistContextType.MANIFEST:o=i?a.ErrorDetails.MANIFEST_LOAD_TIMEOUT:a.ErrorDetails.MANIFEST_LOAD_ERROR,d=!0;break;case l.PlaylistContextType.LEVEL:o=i?a.ErrorDetails.LEVEL_LOAD_TIMEOUT:a.ErrorDetails.LEVEL_LOAD_ERROR,d=!1;break;case l.PlaylistContextType.AUDIO_TRACK:o=i?a.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:a.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case l.PlaylistContextType.SUBTITLE_TRACK:o=i?a.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:a.ErrorDetails.SUBTITLE_LOAD_ERROR,d=!1}h&&this.resetInternalLoader(e.type),h={type:a.ErrorTypes.NETWORK_ERROR,details:o,fatal:d,url:e.url,loader:h,context:e,networkDetails:t},r&&(h.response=r),this.hls.trigger(s.Events.ERROR,h)},t.handlePlaylistLoaded=function(e,t,i,r){var a=i.type,n=i.level,o=i.id,d=i.groupId,h=i.loader,c=i.levelDetails,u=i.deliveryDirectives;if(null!=c&&c.targetduration){if(h)switch(c.live&&(h.getCacheAge&&(c.ageHeader=h.getCacheAge()||0),h.getCacheAge&&!isNaN(c.ageHeader)||(c.ageHeader=0)),a){case l.PlaylistContextType.MANIFEST:case l.PlaylistContextType.LEVEL:this.hls.trigger(s.Events.LEVEL_LOADED,{details:c,level:n||0,id:o||0,stats:t,networkDetails:r,deliveryDirectives:u});break;case l.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(s.Events.AUDIO_TRACK_LOADED,{details:c,id:o||0,groupId:d||"",stats:t,networkDetails:r,deliveryDirectives:u});break;case l.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(s.Events.SUBTITLE_TRACK_LOADED,{details:c,id:o||0,groupId:d||"",stats:t,networkDetails:r,deliveryDirectives:u})}}else this.handleManifestParsingError(e,i,"invalid target duration",r)};const u=c},"./src/polyfills/number.ts":(e,t,i)=>{i.r(t),i.d(t,{MAX_SAFE_INTEGER:()=>s,isFiniteNumber:()=>r});var r=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},s=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>r}),s.getSilentFrame=function(e,t){return"mp4a.40.2"===e?1===t?new Uint8Array([0,200,0,128,35,128]):2===t?new Uint8Array([33,0,73,144,2,25,0,35,128]):3===t?new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]):4===t?new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]):5===t?new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]):6===t?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]):void 0:1===t?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]):2===t||3===t?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]):void 0};const r=s;function s(){}},"./src/remux/mp4-generator.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>a});var r=Math.pow(2,32)-1;s.init=function(){for(var e in s.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]})s.types.hasOwnProperty(e)&&(s.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);var 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]),r=(t=(s.HDLR_TYPES={video:t,audio:i},new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])),i=new Uint8Array([0,0,0,0,0,0,0,0]),i=(s.STTS=s.STSC=s.STCO=i,s.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),s.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),s.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),s.STSD=new Uint8Array([0,0,0,0,0,0,0,1]),new Uint8Array([105,115,111,109])),new Uint8Array([97,118,99,49])),a=new Uint8Array([0,0,0,1]);s.FTYP=s.box(s.types.ftyp,i,a,i,r),s.DINF=s.box(s.types.dinf,s.box(s.types.dref,t))},s.box=function(e){for(var t=8,i=arguments.length,r=new Array(1<i?i-1:0),s=1;s<i;s++)r[s-1]=arguments[s];for(var a=r.length,n=a;a--;)t+=r[a].byteLength;var o=new Uint8Array(t);for(o[0]=t>>24&255,o[1]=t>>16&255,o[2]=t>>8&255,o[3]=255&t,o.set(e,4),a=0,t=8;a<n;a++)o.set(r[a],t),t+=r[a].byteLength;return o},s.hdlr=function(e){return s.box(s.types.hdlr,s.HDLR_TYPES[e])},s.mdat=function(e){return s.box(s.types.mdat,e)},s.mdhd=function(e,t){t*=e;var i=Math.floor(t/(1+r));t=Math.floor(t%(1+r));return s.box(s.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,t>>24,t>>16&255,t>>8&255,255&t,85,196,0,0]))},s.mdia=function(e){return s.box(s.types.mdia,s.mdhd(e.timescale,e.duration),s.hdlr(e.type),s.minf(e))},s.mfhd=function(e){return s.box(s.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))},s.minf=function(e){return"audio"===e.type?s.box(s.types.minf,s.box(s.types.smhd,s.SMHD),s.DINF,s.stbl(e)):s.box(s.types.minf,s.box(s.types.vmhd,s.VMHD),s.DINF,s.stbl(e))},s.moof=function(e,t,i){return s.box(s.types.moof,s.mfhd(e),s.traf(i,t))},s.moov=function(e){for(var t=e.length,i=[];t--;)i[t]=s.trak(e[t]);return s.box.apply(null,[s.types.moov,s.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(s.mvex(e)))},s.mvex=function(e){for(var t=e.length,i=[];t--;)i[t]=s.trex(e[t]);return s.box.apply(null,[s.types.mvex].concat(i))},s.mvhd=function(e,t){t*=e;var i=Math.floor(t/(1+r));t=Math.floor(t%(1+r)),e=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,t>>24,t>>16&255,t>>8&255,255&t,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return s.box(s.types.mvhd,e)},s.sdtp=function(e){for(var t,i=e.samples||[],r=new Uint8Array(4+i.length),a=0;a<i.length;a++)t=i[a].flags,r[a+4]=t.dependsOn<<4|t.isDependedOn<<2|t.hasRedundancy;return s.box(s.types.sdtp,r)},s.stbl=function(e){return s.box(s.types.stbl,s.stsd(e),s.box(s.types.stts,s.STTS),s.box(s.types.stsc,s.STSC),s.box(s.types.stsz,s.STSZ),s.box(s.types.stco,s.STCO))},s.avc1=function(e){for(var t,i,r=[],a=[],n=0;n<e.sps.length;n++)i=(t=e.sps[n]).byteLength,r.push(i>>>8&255),r.push(255&i),r=r.concat(Array.prototype.slice.call(t));for(n=0;n<e.pps.length;n++)i=(t=e.pps[n]).byteLength,a.push(i>>>8&255),a.push(255&i),a=a.concat(Array.prototype.slice.call(t));var o=s.box(s.types.avcC,new Uint8Array([1,r[3],r[4],r[5],255,224|e.sps.length].concat(r).concat([e.pps.length]).concat(a))),l=e.width,d=e.height,h=e.pixelRatio[0],c=e.pixelRatio[1];return s.box(s.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,l>>8&255,255&l,d>>8&255,255&d,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,s.box(s.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),s.box(s.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,255&h,c>>24,c>>16&255,c>>8&255,255&c])))},s.esds=function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))},s.mp4a=function(e){var t=e.samplerate;return s.box(s.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]),s.box(s.types.esds,s.esds(e)))},s.mp3=function(e){var t=e.samplerate;return s.box(s.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]))},s.stsd=function(e){return"audio"===e.type?"mp3"===e.segmentCodec&&"mp3"===e.codec?s.box(s.types.stsd,s.STSD,s.mp3(e)):s.box(s.types.stsd,s.STSD,s.mp4a(e)):s.box(s.types.stsd,s.STSD,s.avc1(e))},s.tkhd=function(e){var t=e.id,i=e.duration*e.timescale,a=e.width,n=(e=e.height,Math.floor(i/(1+r)));i=Math.floor(i%(1+r));return s.box(s.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,i>>24,i>>16&255,i>>8&255,255&i,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,a>>8&255,255&a,0,0,e>>8&255,255&e,0,0]))},s.traf=function(e,t){var i=s.sdtp(e),a=e.id,n=Math.floor(t/(1+r));t=Math.floor(t%(1+r));return s.box(s.types.traf,s.box(s.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),s.box(s.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,t>>24,t>>16&255,t>>8&255,255&t])),s.trun(e,i.length+16+20+8+16+8+8),i)},s.trak=function(e){return e.duration=e.duration||4294967295,s.box(s.types.trak,s.tkhd(e),s.mdia(e))},s.trex=function(e){return e=e.id,s.box(s.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},s.trun=function(e,t){var i,r,a,n,o,l=e.samples||[],d=l.length,h=12+16*d,c=new Uint8Array(h);for(c.set(["video"===e.type?1:0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,(t+=8+h)>>>24&255,t>>>16&255,t>>>8&255,255&t],0),i=0;i<d;i++)r=(o=l[i]).duration,a=o.size,n=o.flags,o=o.cts,c.set([r>>>24&255,r>>>16&255,r>>>8&255,255&r,a>>>24&255,a>>>16&255,a>>>8&255,255&a,n.isLeading<<2|n.dependsOn,n.isDependedOn<<6|n.hasRedundancy<<4|n.paddingValue<<1|n.isNonSync,61440&n.degradPrio,15&n.degradPrio,o>>>24&255,o>>>16&255,o>>>8&255,255&o],12+16*i);return s.box(s.types.trun,c)},s.initSegment=function(e){s.types||s.init();e=s.moov(e);var t=new Uint8Array(s.FTYP.byteLength+e.byteLength);return t.set(s.FTYP),t.set(e,s.FTYP.byteLength),t},i=s;function s(){}i.types=void 0,i.HDLR_TYPES=void 0,i.STTS=void 0,i.STSC=void 0,i.STCO=void 0,i.STSZ=void 0,i.VMHD=void 0,i.SMHD=void 0,i.STSD=void 0,i.FTYP=void 0,i.DINF=void 0;const a=i},"./src/remux/mp4-remuxer.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>f,flushTextTrackMetadataCueSamples:()=>y,flushTextTrackUserdataCueSamples:()=>A,normalizePts:()=>g});var r=i("./src/polyfills/number.ts"),s=i("./src/remux/aac-helper.ts"),a=i("./src/remux/mp4-generator.ts"),n=i("./src/events.ts"),o=i("./src/errors.ts"),l=i("./src/utils/logger.ts"),d=i("./src/types/loader.ts"),h=i("./src/utils/timescale-conversion.ts");function c(){return(c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i,r=arguments[t];for(i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e}).apply(this,arguments)}var u=null,p=null,f=((t=m.prototype).destroy=function(){},t.resetTimeStamp=function(e){l.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},t.resetNextTimestamp=function(){l.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},t.resetInitSegment=function(){l.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},t.getVideoStartPts=function(e){var t=!1;e=e.reduce((function(e,i){var r=i.pts-e;return r<-4294967296?(t=!0,g(e,i.pts)):0<r?e:i.pts}),e[0].pts);return t&&l.logger.debug("PTS rollover detected"),e},t.remux=function(e,t,i,r,s,a,n,o){var h,c,u,p,f,m,b,v=s,_=s,w=-1<e.pid,S=-1<t.pid,E=t.samples.length,T=0<e.samples.length,k=n&&0<E||1<E;return(w&&!T||S&&!k)&&!this.ISGenerated&&!n||(this.ISGenerated||(u=this.generateIS(e,t,s)),w=this.isVideoContiguous,n=-1,k&&(n=function(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!w&&this.config.forceKeyFrameOnDiscontinuity)&&(m=!0,0<n?(l.logger.warn("[mp4-remuxer]: Dropped "+n+" out of "+E+" video samples due to a missing keyframe"),b=this.getVideoStartPts(t.samples),t.samples=t.samples.slice(n),t.dropped+=n,b=_+=(t.samples[0].pts-b)/t.inputTimeScale):-1===n&&(l.logger.warn("[mp4-remuxer]: No keyframe found out of "+E+" video samples"),m=!1)),this.ISGenerated&&(T&&k&&(E=this.getVideoStartPts(t.samples),E=(g(e.samples[0].pts,E)-E)/t.inputTimeScale,v+=Math.max(0,E),_+=Math.max(0,-E)),T?(e.samplerate||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),u=this.generateIS(e,t,s)),c=this.remuxAudio(e,v,this.isAudioContiguous,a,S||k||o===d.PlaylistLevelType.AUDIO?_:void 0),k&&(E=c?c.endPTS-c.startPTS:0,t.inputTimeScale||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),u=this.generateIS(e,t,s)),h=this.remuxVideo(t,_,w,E))):k&&(h=this.remuxVideo(t,_,w,0)),h&&(h.firstKeyFrame=n,h.independent=-1!==n,h.firstKeyFramePTS=b))),this.ISGenerated&&(i.samples.length&&(f=y(i,s,this._initPTS,this._initDTS)),r.samples.length&&(p=A(r,s,this._initPTS))),{audio:c,video:h,initSegment:u,independent:m,text:p,id3:f}},t.generateIS=function(e,t,i){var s,n,o,l=e.samples,d=t.samples,h=this.typeSupported,c={},u=!(0,r.isFiniteNumber)(this._initPTS),p="audio/mp4";if(u&&(o=n=1/0),e.config&&l.length&&(e.timescale=e.samplerate,"mp3"===e.segmentCodec&&(h.mpeg?(p="audio/mpeg",e.codec=""):h.mp3&&(e.codec="mp3")),c.audio={id:"audio",container:p,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&h.mpeg?new Uint8Array(0):a.default.initSegment([e]),metadata:{channelCount:e.channelCount}},u&&(s=e.inputTimeScale,o=n=l[0].pts-Math.round(s*i))),t.sps&&t.pps&&d.length&&(t.timescale=t.inputTimeScale,c.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:a.default.initSegment([t]),metadata:{width:t.width,height:t.height}},u)&&(s=t.inputTimeScale,p=this.getVideoStartPts(d),h=Math.round(s*i),n=Math.min(n,g(d[0].dts,p)-h),o=Math.min(o,p-h)),Object.keys(c).length)return this.ISGenerated=!0,u&&(this._initPTS=o,this._initDTS=n),{tracks:c,initPTS:o,timescale:s}},t.remuxVideo=function(e,t,i,r){var s=e.inputTimeScale,d=e.samples,f=[],m=d.length,y=this._initPTS,A=this.nextAvcDts,v=8,_=this.videoSampleDuration,w=Number.POSITIVE_INFINITY,S=Number.NEGATIVE_INFINITY,E=!1;i&&null!==A||(A=t*s-(d[0].pts-g(d[0].dts,d[0].pts)));for(var T=0;T<m;T++){var k=d[T];k.pts=g(k.pts-y,A),k.dts=g(k.dts-y,A),k.dts<d[0<T?T-1:T].dts&&(E=!0)}E&&d.sort((function(e,t){var i=e.dts-t.dts;e=e.pts-t.pts;return i||e})),x=d[0].dts;t=d[d.length-1].dts-x;var x,C=t?Math.round(t/(m-1)):_||e.inputTimeScale/30;i&&(i=(t=x-A)<-1,((O=C<t)||i)&&(O?l.logger.warn("AVC: "+(0,h.toMsFromMpegTsClock)(t,!0)+" ms ("+t+"dts) hole between fragments detected, filling it"):l.logger.warn("AVC: "+(0,h.toMsFromMpegTsClock)(-t,!0)+" ms ("+t+"dts) overlapping between fragments detected"),!i||A>d[0].pts)&&(x=A,O=d[0].pts-t,d[0].dts=x,d[0].pts=O,l.logger.log("Video: First PTS/DTS adjusted: "+(0,h.toMsFromMpegTsClock)(O,!0)+"/"+(0,h.toMsFromMpegTsClock)(x,!0)+", delta: "+(0,h.toMsFromMpegTsClock)(t,!0)+" ms"))),x=Math.max(0,x);for(var L=0,D=0,R=0;R<m;R++){for(var I=d[R],P=I.units,B=P.length,U=0,F=0;F<B;F++)U+=P[F].data.length;D+=U,L+=B,I.length=U,I.dts=Math.max(I.dts,x),w=Math.min(I.pts,w),S=Math.max(I.pts,S)}i=d[m-1].dts;var M,O=D+4*L+8;try{M=new Uint8Array(O)}catch(e){return void this.observer.emit(n.Events.ERROR,n.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:O,reason:"fail allocating video mdat "+O})}var N=new DataView(M.buffer);N.setUint32(0,O),M.set(a.default.types.mdat,4);for(var j=!1,z=Number.POSITIVE_INFINITY,G=Number.POSITIVE_INFINITY,H=Number.NEGATIVE_INFINITY,W=Number.NEGATIVE_INFINITY,V=0;V<m;V++){for(var K=d[V],$=K.units,Y=0,q=0,J=$.length;q<J;q++){var Q=$[q],X=Q.data;Q=Q.data.byteLength;N.setUint32(v,Q),v+=4,M.set(X,v),v+=Q,Y+=4+Q}var Z,ee=void 0,te=(V<m-1?(_=d[V+1].dts-K.dts,ee=d[V+1].pts-K.pts):(te=this.config,Z=0<V?K.dts-d[V-1].dts:C,ee=0<V?K.pts-d[V-1].pts:C,te.stretchShortVideoTrack&&null!==this.nextAudioPts&&Math.floor(te.maxBufferHole*s)<(te=(r?w+r*s:this.nextAudioPts)-K.pts)?((_=te-Z)<0?_=Z:j=!0,l.logger.log("[mp4-remuxer]: It is approximately "+te/90+" ms to the next segment; using duration "+_/90+" ms for the last video frame.")):_=Z),Math.round(K.pts-K.dts));z=Math.min(z,_),H=Math.max(H,_),G=Math.min(G,ee),W=Math.max(W,ee);f.push(new b(K.key,_,Y,te))}if(f.length)if(u)u<70&&((t=f[0].flags).dependsOn=2,t.isNonSync=0);else if(p&&W-G<H-z&&C/H<.025&&0===f[0].cts){l.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var ie=x,re=0,se=f.length;re<se;re++){var ae,ne=ie+f[re].duration,oe=ie+f[re].cts;re<se-1?(ae=ne+f[re+1].cts,f[re].duration=ae-oe):f[re].duration=re?f[re-1].duration:C,f[re].cts=0,ie=ne}}return console.assert(null!==_,"mp4SampleDuration must be computed"),this.nextAvcDts=A=i+(_=j||!_?C:_),this.videoSampleDuration=_,this.isVideoContiguous=!0,O={data1:a.default.moof(e.sequenceNumber++,x,c({},e,{samples:f})),data2:M,startPTS:w/s,endPTS:(S+_)/s,startDTS:x/s,endDTS:A/s,type:"video",hasAudio:!1,hasVideo:!0,nb:f.length,dropped:e.dropped},e.samples=[],e.dropped=0,console.assert(M.length,"MDAT length must not be zero"),O},t.remuxAudio=function(e,t,i,r,d){var h=e.inputTimeScale,u=h/(e.samplerate||h),p="aac"===e.segmentCodec?1024:1152,f=p*u,m=this._initPTS,y="mp3"===e.segmentCodec&&this.typeSupported.mpeg,A=[],v=void 0!==d,_=e.samples,w=y?0:8,S=this.nextAudioPts||-1,E=t*h;if(this.isAudioContiguous=i=i||_.length&&0<S&&(r&&Math.abs(E-S)<9e3||Math.abs(g(_[0].pts-m,E)-S)<20*f),_.forEach((function(e){e.pts=g(e.pts-m,E)})),!i||S<0){if(!(_=_.filter((function(e){return 0<=e.pts}))).length)return;S=0===d?0:r&&!v?Math.max(0,E):_[0].pts}if("aac"===e.segmentCodec)for(var T=this.config.maxAudioFramesDrift,k=0,x=S;k<_.length;k++){var C=_[k],L=C.pts,D=L-x,R=Math.abs(1e3*D/h);if(D<=-T*f&&v)0===k&&(l.logger.warn("Audio frame @ "+(L/h).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*D/h)+" ms."),this.nextAudioPts=S=x=L);else if(T*f<=D&&R<1e4&&v){var I=Math.round(D/f);(x=L-I*f)<0&&(I--,x+=f),0===k&&(this.nextAudioPts=S=x),l.logger.warn("[mp4-remuxer]: Injecting "+I+" audio frame @ "+(x/h).toFixed(3)+"s due to "+Math.round(1e3*D/h)+" ms gap.");for(var P=0;P<I;P++){var B=Math.max(x,0),U=s.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);U||(l.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),U=C.unit.subarray()),_.splice(k,0,{unit:U,pts:B}),x+=f,k++}}C.pts=x,x+=f}for(var F,M=null,O=null,N=0,j=_.length;j--;)N+=_[j].unit.byteLength;for(var z=0,G=_.length;z<G;z++){var H=_[z],W=H.unit;H=H.pts;if(null!==O)A[z-1].duration=Math.round((H-O)/u);else{if(M=H=i&&"aac"===e.segmentCodec?S:H,!(0<N))return;N+=w;try{F=new Uint8Array(N)}catch(e){return void this.observer.emit(n.Events.ERROR,n.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:N,reason:"fail allocating audio mdat "+N})}y||(new DataView(F.buffer).setUint32(0,N),F.set(a.default.types.mdat,4))}F.set(W,w),W=W.byteLength,w+=W,A.push(new b(!0,p,W,0)),O=H}if(t=A.length,t)return d=A[A.length-1],this.nextAudioPts=S=O+u*d.duration,r={data1:y?new Uint8Array(0):a.default.moof(e.sequenceNumber++,M/u,c({},e,{samples:A})),data2:F,startPTS:r=M/h,endPTS:d=S/h,startDTS:r,endDTS:d,type:"audio",hasAudio:!0,hasVideo:!(e.samples=[]),nb:t},this.isAudioContiguous=!0,console.assert(F.length,"MDAT length must not be zero"),r},t.remuxEmptyAudio=function(e,t,i,r){var a=e.inputTimeScale,n=a/(e.samplerate||a),o=this.nextAudioPts,d=(null!==o?o:r.startDTS*a)+this._initDTS,h=(o=r.endDTS*a+this._initDTS,1024*n),c=Math.ceil((o-d)/h),u=s.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(l.logger.warn("[mp4-remuxer]: remux empty Audio"),u){for(var p=[],f=0;f<c;f++){var m=d+f*h;p.push({unit:u,pts:m,dts:m})}return e.samples=p,this.remuxAudio(e,t,i,!1)}l.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},m);function m(e,t,i,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=e,this.config=t,this.typeSupported=i,this.ISGenerated=!1,null===u&&(e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i),u=e?parseInt(e[1]):0),null===p&&(t=navigator.userAgent.match(/Safari\/(\d+)/i),p=t?parseInt(t[1]):0)}function g(e,t){var i;if(null===t)return e;for(i=t<e?-8589934592:8589934592;4294967296<Math.abs(e-t);)e+=i;return e}function y(e,t,i,r){var s=e.samples.length;if(s){for(var a=e.inputTimeScale,n=0;n<s;n++){var o=e.samples[n];o.pts=g(o.pts-i,t*a)/a,o.dts=g(o.dts-r,t*a)/a}var l=e.samples;return e.samples=[],{samples:l}}}function A(e,t,i){var r=e.samples.length;if(r){for(var s=e.inputTimeScale,a=0;a<r;a++){var n=e.samples[a];n.pts=g(n.pts-i,t*s)/s}e.samples.sort((function(e,t){return e.pts-t.pts}));var o=e.samples;return e.samples=[],{samples:o}}}var b=function(e,t,i,r){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=i,this.cts=r,this.flags=new v(e)},v=function(e){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=e?2:1,this.isNonSync=e?0:1}},"./src/remux/passthrough-remuxer.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>d});var r=i("./src/polyfills/number.ts"),s=i("./src/remux/mp4-remuxer.ts"),a=i("./src/utils/mp4-tools.ts"),n=i("./src/loader/fragment.ts"),o=i("./src/utils/logger.ts");function l(e,t){return e=null==e?void 0:e.codec,e&&4<e.length?e:"hvc1"===e||"hev1"===e?"hvc1.1.c.L120.90":"av01"===e?"av01.0.04M.08":"avc1"===e||t===n.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}(t=h.prototype).destroy=function(){},t.resetTimeStamp=function(e){this.initPTS=e,this.lastEndTime=null},t.resetNextTimestamp=function(){this.lastEndTime=null},t.resetInitSegment=function(e,t,i,r){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment((0,a.patchEncyptionData)(e,r)),this.emitInitSegment=!0},t.generateInitSegment=function(e){var t=this.audioCodec,i=this.videoCodec;if(!e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var r=this.initData=(0,a.parseInitSegment)(e),s=(t=t||l(r.audio,n.ElementaryStreamTypes.AUDIO),i=i||l(r.video,n.ElementaryStreamTypes.VIDEO),{});r.audio&&r.video?s.audiovideo={container:"video/mp4",codec:t+","+i,initSegment:e,id:"main"}:r.audio?s.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:r.video?s.video={container:"video/mp4",codec:i,initSegment:e,id:"main"}:o.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=s},t.remux=function(e,t,i,n,l){var d=this.initPTS,h=this.lastEndTime,c={audio:void 0,video:void 0,text:n,id3:i,initSegment:void 0};(0,r.isFiniteNumber)(h)||(h=this.lastEndTime=l||0),t=t.samples;if(!t||!t.length)return c;var u={initPTS:void 0,timescale:1},p=this.initData;if(p&&p.length||(this.generateInitSegment(t),p=this.initData),!p||!p.length)return o.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(u.tracks=this.initTracks,this.emitInitSegment=!1);var f=(0,a.getStartDTS)(p,t),m=((0,r.isFiniteNumber)(d)||(this.initPTS=u.initPTS=d=f-l),(0,a.getDuration)(t,p));e=e?f-d:h,f=e+m,(0,a.offsetStartDTS)(p,t,d),0<m?this.lastEndTime=f:(o.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp()),h=!!p.audio,d=!!p.video,m="",h&&(m+="audio"),d&&(m+="video"),p={data1:t,startPTS:e,startDTS:e,endPTS:f,endDTS:f,type:m,hasAudio:h,hasVideo:d,nb:1,dropped:0},c.audio="audio"===p.type?p:void 0,c.video="audio"!==p.type?p:void 0,c.initSegment=u,e=null!=(t=this.initPTS)?t:0;return c.id3=(0,s.flushTextTrackMetadataCueSamples)(i,l,e,e),n.samples.length&&(c.text=(0,s.flushTextTrackUserdataCueSamples)(n,l,e)),c};const d=h;function h(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}},"./src/task-loop.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>r}),(i=s.prototype).destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},i.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},i.onHandlerDestroyed=function(){},i.hasInterval=function(){return!!this._tickInterval},i.hasNextTick=function(){return!!this._tickTimer},i.setInterval=function(e){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,e),!0)},i.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),!(this._tickInterval=null))},i.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),!(this._tickTimer=null))},i.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),1<this._tickCallCount&&this.tickImmediate(),this._tickCallCount=0)},i.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},i.doTick=function(){};var r=s;function s(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}},"./src/types/cmcd.ts":(e,t,i)=>{i.r(t),i.d(t,{CMCDObjectType:()=>r,CMCDStreamType:()=>a,CMCDStreamingFormat:()=>s,CMCDVersion:()=>n});var r,s,a,n=1;(i=r=r||{}).MANIFEST="m",i.AUDIO="a",i.VIDEO="v",i.MUXED="av",i.INIT="i",i.CAPTION="c",i.TIMED_TEXT="tt",i.KEY="k",i.OTHER="o",(t=s=s||{}).DASH="d",t.HLS="h",t.SMOOTH="s",t.OTHER="o",(i=a=a||{}).VOD="v",i.LIVE="l"},"./src/types/demuxer.ts":(e,t,i)=>{var r;i.r(t),i.d(t,{MetadataSchema:()=>r}),(i=r=r||{}).audioId3="org.id3",i.dateRange="com.apple.quicktime.HLS",i.emsg="https://aomedia.org/emsg/ID3"},"./src/types/level.ts":(e,t,i)=>{function r(e,t){for(var i,r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,"symbol"==typeof(i=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);if(t=t.call(e,"string"),"object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(s.key))?i:String(i),s)}}i.r(t),i.d(t,{HdcpLevels:()=>a,HlsSkip:()=>s,HlsUrlParameters:()=>n,Level:()=>o,getSkipValue:()=>function(e,t){var i=e.canSkipUntil,r=e.canSkipDateRanges;e=e.endSN;return i&&(void 0!==t?t-e:0)<i?r?s.v2:s.Yes:s.No}});var s,a=["NONE","TYPE-0","TYPE-1","TYPE-2",null];(i=s=s||{}).No="",i.Yes="YES",i.v2="v2",d.prototype.addDirectives=function(e){return e=new self.URL(e),void 0!==this.msn&&e.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href};var n=d,o=(r((t=l).prototype,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(e){e%=this.url.length,this._urlId!==e&&(this.details=void 0,this._urlId=e)}}]),Object.defineProperty(t,"prototype",{writable:!1}),l);function l(e){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=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.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.unknownCodecs=e.unknownCodecs,this.codecSet=[e.videoCodec,e.audioCodec].filter((function(e){return e})).join(",").replace(/\.[^.,]+/g,"")}function d(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i}},"./src/types/loader.ts":(e,t,i)=>{var r,s;i.r(t),i.d(t,{PlaylistContextType:()=>r,PlaylistLevelType:()=>s}),(i=r=r||{}).MANIFEST="manifest",i.LEVEL="level",i.AUDIO_TRACK="audioTrack",i.SUBTITLE_TRACK="subtitleTrack",(t=s=s||{}).MAIN="main",t.AUDIO="audio",t.SUBTITLE="subtitle"},"./src/types/transmuxer.ts":(e,t,i)=>{i.r(t),i.d(t,{ChunkMetadata:()=>r});var r=function(e,t,i,r,s,a){void 0===r&&(r=0),void 0===s&&(s=-1),void 0===a&&(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=r,this.part=s,this.partial=a}},"./src/utils/attr-list.ts":(e,t,i)=>{i.r(t),i.d(t,{AttrList:()=>a});var r=/^(\d+)x(\d+)$/,s=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,a=((i=n.prototype).decimalInteger=function(e){return e=parseInt(this[e],10),e>Number.MAX_SAFE_INTEGER?1/0:e},i.hexadecimalInteger=function(e){if(this[e]){for(var t=(1&(t=(this[e]||"0x").slice(2)).length?"0":"")+t,i=new Uint8Array(t.length/2),r=0;r<t.length/2;r++)i[r]=parseInt(t.slice(2*r,2*r+2),16);return i}return null},i.hexadecimalIntegerAsNumber=function(e){return e=parseInt(this[e],16),e>Number.MAX_SAFE_INTEGER?1/0:e},i.decimalFloatingPoint=function(e){return parseFloat(this[e])},i.optionalFloat=function(e,t){return e=this[e],e?parseFloat(e):t},i.enumeratedString=function(e){return this[e]},i.bool=function(e){return"YES"===this[e]},i.decimalResolution=function(e){if(e=r.exec(this[e]),null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},n.parseAttrList=function(e){var t,i={};for(s.lastIndex=0;null!==(t=s.exec(e));){var r=t[2];0===r.indexOf('"')&&r.lastIndexOf('"')===r.length-1&&(r=r.slice(1,-1)),i[t[1]]=r}return i},n);function n(e){for(var t in e="string"==typeof e?n.parseAttrList(e):e)e.hasOwnProperty(t)&&(this[t]=e[t])}},"./src/utils/binary-search.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>r});const r={search:function(e,t){for(var i,r,s=0,a=e.length-1;s<=a;){var n=t(r=e[i=(s+a)/2|0]);if(0<n)s=1+i;else{if(!(n<0))return r;a=i-1}}return null}}},"./src/utils/buffer-helper.ts":(e,t,i)=>{i.r(t),i.d(t,{BufferHelper:()=>a});var r=i("./src/utils/logger.ts"),s={length:0,start:function(){return 0},end:function(){return 0}},a=(n.isBuffered=function(e,t){try{if(e)for(var i=n.getBuffered(e),r=0;r<i.length;r++)if(t>=i.start(r)&&t<=i.end(r))return!0}catch(e){}return!1},n.bufferInfo=function(e,t,i){try{if(e){for(var r=n.getBuffered(e),s=[],a=0;a<r.length;a++)s.push({start:r.start(a),end:r.end(a)});return this.bufferedInfo(s,t,i)}}catch(e){}return{len:0,start:t,end:t,nextStart:void 0}},n.bufferedInfo=function(e,t,i){t=Math.max(0,t),e.sort((function(e,t){return e.start-t.start||t.end-e.end}));var r=[];if(i)for(var s=0;s<e.length;s++){var a,n=r.length;n?(a=r[n-1].end,e[s].start-a<i?e[s].end>a&&(r[n-1].end=e[s].end):r.push(e[s])):r.push(e[s])}else r=e;for(var o,l=0,d=t,h=t,c=0;c<r.length;c++){var u=r[c].start,p=r[c].end;if(u<=t+i&&t<p)d=u,l=(h=p)-t;else if(t+i<u){o=u;break}}return{len:l,start:d||0,end:h||0,nextStart:o}},n.getBuffered=function(e){try{return e.buffered}catch(e){return r.logger.log("failed to get media.buffered",e),s}},n);function n(){}},"./src/utils/cea-608-parser.ts":(e,t,i)=>{function r(e){var t=e;return o.hasOwnProperty(e)&&(t=o[e]),String.fromCharCode(t)}function s(e){for(var t=[],i=0;i<e.length;i++)t.push(e[i].toString(16));return t}i.r(t),i.d(t,{CaptionScreen:()=>b,Row:()=>A,default:()=>L});var a,n=i("./src/utils/logger.ts"),o={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},l=15,d=100,h={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},c={17:2,18:4,21:6,22:8,23:10,19:13,20:15},u={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},p={25:2,26:4,29:6,30:8,31:10,27:13,28:15},f=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],m=((t=a=a||{})[t.ERROR=0]="ERROR",t[t.TEXT=1]="TEXT",t[t.WARNING=2]="WARNING",t[t.INFO=2]="INFO",t[t.DEBUG=3]="DEBUG",t[t.DATA=3]="DATA",k.prototype.log=function(e,t){this.verboseLevel>=e&&(t="function"==typeof t?t():t,n.logger.log(this.time+" ["+e+"] "+t))},k),g=((i=T.prototype).reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},i.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],i=0;i<t.length;i++){var r=t[i];e.hasOwnProperty(r)&&(this[r]=e[r])}},i.isDefault=function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash},i.equals=function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash},i.copy=function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash},i.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},T),y=((t=E.prototype).reset=function(){this.uchar=" ",this.penState.reset()},t.setChar=function(e,t){this.uchar=e,this.penState.copy(t)},t.setPenState=function(e){this.penState.copy(e)},t.equals=function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)},t.copy=function(e){this.uchar=e.uchar,this.penState.copy(e.penState)},t.isEmpty=function(){return" "===this.uchar&&this.penState.isDefault()},E),A=((i=S.prototype).equals=function(e){for(var t=!0,i=0;i<d;i++)if(!this.chars[i].equals(e.chars[i])){t=!1;break}return t},i.copy=function(e){for(var t=0;t<d;t++)this.chars[t].copy(e.chars[t])},i.isEmpty=function(){for(var e=!0,t=0;t<d;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e},i.setCursor=function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(a.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>d&&(this.logger.log(a.DEBUG,"Too large cursor position "+this.pos),this.pos=d)},i.moveCursor=function(e){var t=this.pos+e;if(1<e)for(var i=this.pos+1;i<t+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(t)},i.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},i.insertChar=function(e){var t=this,i=(144<=e&&this.backSpace(),r(e));this.pos>=d?this.logger.log(a.ERROR,(function(){return"Cannot insert "+e.toString(16)+" ("+i+") at position "+t.pos+". Skipping it!"})):(this.chars[this.pos].setChar(i,this.currPenState),this.moveCursor(1))},i.clearFromPos=function(e){for(var t=e;t<d;t++)this.chars[t].reset()},i.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},i.clearToEndOfRow=function(){this.clearFromPos(this.pos)},i.getTextString=function(){for(var e=[],t=!0,i=0;i<d;i++){var r=this.chars[i].uchar;" "!==r&&(t=!1),e.push(r)}return t?"":e.join("")},i.setPenStyles=function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)},S),b=((t=w.prototype).reset=function(){for(var e=0;e<l;e++)this.rows[e].clear();this.currRow=14},t.equals=function(e){for(var t=!0,i=0;i<l;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t},t.copy=function(e){for(var t=0;t<l;t++)this.rows[t].copy(e.rows[t])},t.isEmpty=function(){for(var e=!0,t=0;t<l;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e},t.backSpace=function(){this.rows[this.currRow].backSpace()},t.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},t.insertChar=function(e){this.rows[this.currRow].insertChar(e)},t.setPen=function(e){this.rows[this.currRow].setPenStyles(e)},t.moveCursor=function(e){this.rows[this.currRow].moveCursor(e)},t.setCursor=function(e){this.logger.log(a.INFO,"setCursor: "+e),this.rows[this.currRow].setCursor(e)},t.setPAC=function(e){this.logger.log(a.INFO,(function(){return"pacData = "+JSON.stringify(e)}));var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var i=0;i<l;i++)this.rows[i].clear();var r=this.currRow+1-this.nrRollUpRows,s=this.lastOutputScreen;if(s){var n=s.rows[r].cueStartTime,o=this.logger.time;if(n&&null!==o&&n<o)for(var d=0;d<this.nrRollUpRows;d++)this.rows[t-this.nrRollUpRows+d+1].copy(s.rows[r+d])}}this.currRow=t,n=this.rows[this.currRow],null!==e.indent&&(o=e.indent,o=Math.max(o-1,0),n.setCursor(e.indent),e.color=n.chars[o].penState.foreground),n={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1},this.setPen(n)},t.setBkgData=function(e){this.logger.log(a.INFO,(function(){return"bkgData = "+JSON.stringify(e)})),this.backSpace(),this.setPen(e),this.insertChar(32)},t.setRollUpRows=function(e){this.nrRollUpRows=e},t.rollUp=function(){var e,t=this;null!==this.nrRollUpRows?(this.logger.log(a.TEXT,(function(){return t.getDisplayText()})),e=this.currRow+1-this.nrRollUpRows,(e=this.rows.splice(e,1)[0]).clear(),this.rows.splice(this.currRow,0,e),this.logger.log(a.INFO,"Rolling up")):this.logger.log(a.DEBUG,"roll_up but nrRollUpRows not set yet")},t.getDisplayText=function(e){e=e||!1;for(var t=[],i="",r=0;r<l;r++){var s=this.rows[r].getTextString();s&&(e?t.push("Row "+(r+1)+": '"+s+"'"):t.push(s.trim()))}return 0<t.length?e?"["+t.join(" | ")+"]":t.join("\n"):i},t.getTextAndFormat=function(){return this.rows},w),v=((i=_.prototype).reset=function(){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},i.getHandler=function(){return this.outputFilter},i.setHandler=function(e){this.outputFilter=e},i.setPAC=function(e){this.writeScreen.setPAC(e)},i.setBkgData=function(e){this.writeScreen.setBkgData(e)},i.setMode=function(e){e!==this.mode&&(this.mode=e,this.logger.log(a.INFO,(function(){return"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)},i.insertChars=function(e){for(var t=this,i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);var r=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(a.INFO,(function(){return r+": "+t.writeScreen.getDisplayText(!0)})),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(a.TEXT,(function(){return"DISPLAYED: "+t.displayedMemory.getDisplayText(!0)})),this.outputDataUpdate())},i.ccRCL=function(){this.logger.log(a.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},i.ccBS=function(){this.logger.log(a.INFO,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},i.ccAOF=function(){},i.ccAON=function(){},i.ccDER=function(){this.logger.log(a.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},i.ccRU=function(e){this.logger.log(a.INFO,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)},i.ccFON=function(){this.logger.log(a.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},i.ccRDC=function(){this.logger.log(a.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},i.ccTR=function(){this.logger.log(a.INFO,"TR"),this.setMode("MODE_TEXT")},i.ccRTD=function(){this.logger.log(a.INFO,"RTD"),this.setMode("MODE_TEXT")},i.ccEDM=function(){this.logger.log(a.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},i.ccCR=function(){this.logger.log(a.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},i.ccENM=function(){this.logger.log(a.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},i.ccEOC=function(){var e,t=this;this.logger.log(a.INFO,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode&&(e=this.displayedMemory,this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(a.TEXT,(function(){return"DISP: "+t.displayedMemory.getDisplayText()}))),this.outputDataUpdate(!0)},i.ccTO=function(e){this.logger.log(a.INFO,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)},i.ccMIDROW=function(e){var t={flash:!1};t.underline=e%2==1,t.italics=46<=e,t.italics?t.foreground="white":(e=Math.floor(e/2)-16,t.foreground=["white","green","blue","cyan","red","yellow","magenta"][e]),this.logger.log(a.INFO,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)},i.outputDataUpdate=function(e){void 0===e&&(e=!1);var 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))},i.cueSplitAtTime=function(e){!this.outputFilter||this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e)},_);function _(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 b(i),this.nonDisplayedMemory=new b(i),this.lastOutputScreen=new b(i),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}function w(e){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var t=0;t<l;t++)this.rows.push(new A(e));this.logger=e,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}function S(e){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var t=0;t<d;t++)this.chars.push(new y);this.logger=e,this.pos=0,this.currPenState=new g}function E(e,t,i,r,s,a){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new g(t,i,r,s,a)}function T(e,t,i,r,s){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=i||!1,this.background=r||"black",this.flash=s||!1}function k(){this.time=null,this.verboseLevel=a.ERROR}function x(e,t,i){i.a=e,i.b=t}function C(e,t,i){return i.a===e&&i.b===t}(t=D.prototype).getHandler=function(e){return this.channels[e].getHandler()},t.setHandler=function(e,t){this.channels[e].setHandler(t)},t.addData=function(e,t){var i,r=!1;this.logger.time=e;for(var n=0;n<t.length;n+=2){var o,l=127&t[n],d=127&t[n+1];0==l&&0==d||(this.logger.log(a.DATA,"["+s([t[n],t[n+1]])+"] -> ("+s([l,d])+")"),!(i=(i=(i=(i=this.parseCmd(l,d))?i:this.parseMidrow(l,d))||this.parsePAC(l,d))||this.parseBackgroundAttributes(l,d))&&(r=this.parseChars(l,d))&&((o=this.currentChannel)&&0<o?this.channels[o].insertChars(r):this.logger.log(a.WARNING,"No channel found yet. TEXT-MODE?")),i||r||this.logger.log(a.WARNING,"Couldn't parse cleaned data "+s([l,d])+" orig: "+s([t[n],t[n+1]])))}},t.parseCmd=function(e,t){var i=this.cmdHistory;if(!((20===e||28===e||21===e||29===e)&&32<=t&&t<=47||(23===e||31===e)&&33<=t&&t<=35))return!1;if(C(e,t,i))return x(null,null,i),this.logger.log(a.DEBUG,"Repeated command ("+s([e,t])+") is dropped"),!0;var r=20===e||21===e||23===e?1:2,n=this.channels[r];return 20===e||21===e||28===e||29===e?32===t?n.ccRCL():33===t?n.ccBS():34===t?n.ccAOF():35===t?n.ccAON():36===t?n.ccDER():37===t?n.ccRU(2):38===t?n.ccRU(3):39===t?n.ccRU(4):40===t?n.ccFON():41===t?n.ccRDC():42===t?n.ccTR():43===t?n.ccRTD():44===t?n.ccEDM():45===t?n.ccCR():46===t?n.ccENM():47===t&&n.ccEOC():n.ccTO(t-32),x(e,t,i),this.currentChannel=r,!0},t.parseMidrow=function(e,t){if((17===e||25===e)&&32<=t&&t<=47){if((i=17===e?1:2)!==this.currentChannel)return this.logger.log(a.ERROR,"Mismatch channel in midrow parsing"),!1;var i=this.channels[i];return!!i&&(i.ccMIDROW(t),this.logger.log(a.DEBUG,"MIDROW ("+s([e,t])+")"),!0)}return!1},t.parsePAC=function(e,t){var i=this.cmdHistory;if(!((17<=e&&e<=23||25<=e&&e<=31)&&64<=t&&t<=127||(16===e||24===e)&&64<=t&&t<=95))return!1;if(C(e,t,i))return x(null,null,i),!0;var r=e<=23?1:2,s=this.channels[r];return!!s&&(s.setPAC(this.interpretPAC((64<=t&&t<=95?1==r?h:u:1==r?c:p)[e],t)),x(e,t,i),this.currentChannel=r,!0)},t.interpretPAC=function(e,t){return e={color:null,italics:!1,indent:null,underline:!1,row:e},t=95<t?t-96:t-64,e.underline=1==(1&t),t<=13?e.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(t/2)]:t<=15?(e.italics=!0,e.color="white"):e.indent=4*Math.floor((t-16)/2),e},t.parseChars=function(e,t){var i,n=null,o=null;return 17<=(o=25<=e?(i=2,e-8):(i=1,e))&&o<=19?(this.logger.log(a.INFO,"Special char '"+r(o=17===o?t+80:18===o?t+112:t+144)+"' in channel "+i),n=[o]):32<=e&&e<=127&&(n=0===t?[e]:[e,t]),n&&(i=s(n),this.logger.log(a.DEBUG,"Char codes = "+i.join(",")),x(e,t,this.cmdHistory)),n},t.parseBackgroundAttributes=function(e,t){var i;if(!((16===e||24===e)&&32<=t&&t<=47||(23===e||31===e)&&45<=t&&t<=47))return!1;var r={};return 16===e||24===e?(i=Math.floor((t-32)/2),r.background=f[i],t%2==1&&(r.background=r.background+"_semi")):45===t?r.background="transparent":(r.foreground="black",47===t&&(r.underline=!0)),this.channels[e<=23?1:2].setBkgData(r),x(e,t,this.cmdHistory),!0},t.reset=function(){for(var e=0;e<Object.keys(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}this.cmdHistory={a:null,b:null}},t.cueSplitAtTime=function(e){for(var t=0;t<this.channels.length;t++){var i=this.channels[t];i&&i.cueSplitAtTime(e)}};const L=D;function D(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var r=new m;this.channels=[null,new v(e,t,r),new v(e+1,i,r)],this.cmdHistory={a:null,b:null},this.logger=r}},"./src/utils/codecs.ts":(e,t,i)=>{i.r(t),i.d(t,{isCodecSupportedInMp4:()=>function(e,t){return MediaSource.isTypeSupported((t||"video")+'/mp4;codecs="'+e+'"')},isCodecType:()=>function(e,t){return t=r[t],!!t&&!0===t[e.slice(0,4)]}});var r={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}}},"./src/utils/cues.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>o});var r=i("./src/utils/vttparser.ts"),s=i("./src/utils/webvtt-parser.ts"),a=i("./src/utils/texttrack-utils.ts"),n=/\s/;const o={newCue:function(e,t,i,o){for(var l,d,h,c,u=[],p=self.VTTCue||self.TextTrackCue,f=0;f<o.rows.length;f++)if(d=!0,h=0,c="",!(l=o.rows[f]).isEmpty()){for(var m=0;m<l.chars.length;m++)n.test(l.chars[m].uchar)&&d?h++:(c+=l.chars[m].uchar,d=!1);(l.cueStartTime=t)===i&&(i+=1e-4),16<=h?h--:h++;var g=(0,r.fixLineBreaks)(c.trim()),y=(0,s.generateCueId)(t,i,g);e&&e.cues&&e.cues.getCueById(y)||((g=new p(t,i,g)).id=y,g.line=f+1,g.align="left",g.position=10+Math.min(80,10*Math.floor(8*h/32)),u.push(g))}return e&&u.length&&(u.sort((function(e,t){return"auto"===e.line||"auto"===t.line?0:8<e.line&&8<t.line?t.line-e.line:e.line-t.line})),u.forEach((function(t){return(0,a.addCueToTrack)(e,t)}))),u}}},"./src/utils/discontinuities.ts":(e,t,i)=>{i.r(t),i.d(t,{adjustSlidingStart:()=>h,alignMediaPlaylistByPDT:()=>function(e,t){var i,r,s;e.hasProgramDateTime&&t.hasProgramDateTime&&(i=e.fragments,t=t.fragments,i.length&&t.length&&(t=t[Math.round(t.length/2)-1],i=n(i,t.cc)||i[Math.round(i.length/2)-1],r=t.programDateTime,s=i.programDateTime,null!==r&&null!==s&&h((s-r)/1e3-(i.start-t.start),e)))},alignPDT:()=>c,alignStream:()=>function(e,t,i){var n;t&&(o(e,e=t,n=i)&&(e=l(e.details,n))&&(0,r.isFiniteNumber)(e.start)&&(s.logger.log("Adjusting PTS using last level due to CC increase within current level "+n.url),h(e.start,n)),!i.alignedSliding&&t.details&&c(i,t.details),i.alignedSliding||!t.details||i.skippedSegments||(0,a.adjustSliding)(t.details,i))},findDiscontinuousReferenceFrag:()=>l,findFirstFragWithCC:()=>n,shouldAlignOnDiscontinuities:()=>o});var r=i("./src/polyfills/number.ts"),s=i("./src/utils/logger.ts"),a=i("./src/controller/level-helper.ts");function n(e,t){for(var i=null,r=0,s=e.length;r<s;r++){var a=e[r];if(a&&a.cc===t){i=a;break}}return i}function o(e,t,i){return!(!t.details||!(i.endCC>i.startCC||e&&e.cc<i.startCC))}function l(e,t,i){if(e=e.fragments,t=t.fragments,t.length&&e.length){if(e=n(e,t[0].cc),e&&(!e||e.startPTS))return e;s.logger.log("No frag in previous level to align on")}else s.logger.log("No fragments to align")}function d(e,t){e&&(t=e.start+t,e.start=e.startPTS=t,e.endPTS=t+e.duration)}function h(e,t){for(var i=t.fragments,r=0,s=i.length;r<s;r++)d(i[r],e);t.fragmentHint&&d(t.fragmentHint,e),t.alignedSliding=!0}function c(e,t){var i,a;t.fragments.length&&e.hasProgramDateTime&&t.hasProgramDateTime&&(i=t.fragments[0].programDateTime,(t=((a=e.fragments[0].programDateTime)-i)/1e3+t.fragments[0].start)&&(0,r.isFiniteNumber)(t)&&(s.logger.log("Adjusting PTS using programDateTime delta "+(a-i)+"ms, sliding:"+t.toFixed(3)+" "+e.url+" "),h(t,e)))}},"./src/utils/ewma-bandwidth-estimator.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>s});var r=i("./src/utils/ewma.ts");(t=a.prototype).update=function(e,t){var i=this.slow_,s=this.fast_;this.slow_.halfLife!==e&&(this.slow_=new r.default(e,i.getEstimate(),i.getTotalWeight())),this.fast_.halfLife!==t&&(this.fast_=new r.default(t,s.getEstimate(),s.getTotalWeight()))},t.sample=function(e,t){e=(e=Math.max(e,this.minDelayMs_))/1e3,t=8*t/e,this.fast_.sample(e,t),this.slow_.sample(e,t)},t.canEstimate=function(){var e=this.fast_;return e&&e.getTotalWeight()>=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.destroy=function(){};const s=a;function a(e,t,i){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new r.default(e),this.fast_=new r.default(t)}},"./src/utils/ewma.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>r}),(i=s.prototype).sample=function(e,t){var i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e},i.getTotalWeight=function(){return this.totalWeight_},i.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_};const r=s;function s(e,t,i){void 0===t&&(t=0),void 0===i&&(i=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=i}},"./src/utils/fetch-loader.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>y,fetchSupported:()=>function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}});var r=i("./src/polyfills/number.ts"),s=i("./src/loader/load-stats.ts"),a=i("./src/demux/chunk-cache.ts");function n(e){var t="function"==typeof Map?new Map:void 0;return(n=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return o(e,arguments,d(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),l(i,e)})(e)}function o(e,t,i){return(o=function(){if("undefined"!=typeof Reflect&&Reflect.construct&&!Reflect.construct.sham){if("function"==typeof Proxy)return 1;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),1}catch(e){return}}}()?Reflect.construct.bind():function(e,t,i){var r=[null];r.push.apply(r,t),t=new(Function.bind.apply(e,r));return i&&l(t,i.prototype),t}).apply(null,arguments)}function l(e,t){return(l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(){return(h=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i,r=arguments[t];for(i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e}).apply(this,arguments)}function c(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||u,this.controller=new self.AbortController,this.stats=new s.LoadStats}function u(e,t){return new self.Request(e.url,t)}(t=c.prototype).destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},t.abortInternal=function(){var e=this.response;e&&e.ok||(this.stats.aborted=!0,this.controller.abort())},t.abort=function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},t.load=function(e,t,i){var s=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var n=function(e,t){return t={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(h({},e.headers))},e.rangeEnd&&t.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),t}(e,this.controller.signal),o=i.onProgress,l="arraybuffer"===e.responseType,d=l?"byteLength":"length";this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout((function(){s.abortInternal(),i.onTimeout(a,e,s.response)}),t.timeout),self.fetch(this.request).then((function(i){var n,d;if((s.response=s.loader=i).ok)return a.loading.first=Math.max(self.performance.now(),a.loading.start),a.total=parseInt(i.headers.get("Content-Length")||"0"),o&&(0,r.isFiniteNumber)(t.highWaterMark)?s.loadProgressively(i,a,e,t.highWaterMark,o):l?i.arrayBuffer():i.text();throw n=i.status,d=i.statusText,new m(d||"fetch, bad network response",n,i)})).then((function(n){var l=s.response,h=(self.clearTimeout(s.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first),n[d]);h&&(a.loaded=a.total=h),h={url:l.url,data:n};o&&!(0,r.isFiniteNumber)(t.highWaterMark)&&o(a,e,n,l),i.onSuccess(h,a,e,l)})).catch((function(t){var r,n;self.clearTimeout(s.requestTimeout),a.aborted||(r=t&&t.code||0,n=t?t.message:null,i.onError({code:r,text:n},e,t?t.details:null))}))},t.getCacheAge=function(){var e,t=null;return this.response?(e=this.response.headers.get("age"))?parseFloat(e):null:t},t.loadProgressively=function(e,t,i,r,s){void 0===r&&(r=0);var n=new a.default,o=e.body.getReader();return function a(){return o.read().then((function(o){if(o.done)return n.dataLength&&s(t,i,n.flush(),e),Promise.resolve(new ArrayBuffer(0));o=o.value;var l=o.length;return t.loaded+=l,l<r||n.dataLength?(n.push(o),n.dataLength>=r&&s(t,i,n.flush(),e)):s(t,i,o,e),a()})).catch((function(){return Promise.reject()}))}()},i=c,p=n(Error),t=p,(f=g).prototype=Object.create(t.prototype),l(f.prototype.constructor=f,t);var p,f,m=g;function g(e,t,i){return(e=p.call(this,e)||this).code=void 0,e.details=void 0,e.code=t,e.details=i,e}const y=i},"./src/utils/hex.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>r});const r={hexDump:function(e){for(var t="",i=0;i<e.length;i++){var r=e[i].toString(16);t+=r=r.length<2?"0"+r:r}return t}}},"./src/utils/imsc1-ttml-parser.ts":(e,t,i)=>{i.r(t),i.d(t,{IMSC1_CODEC:()=>h,parseIMSC1:()=>function(e,t,i,s,h){var c=(0,r.findBox)(new Uint8Array(e),["mdat"]);if(0!==c.length){c=c.map((function(e){return(0,n.utf8ArrayToStr)(e)}));var u=(0,o.toTimescaleFromScale)(t,1,i);try{c.forEach((function(e){return s(function(e,t){var i=(new DOMParser).parseFromString(e,"text/xml").getElementsByTagName("tt")[0];if(!i)throw new Error("Invalid ttml");var r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},s=Object.keys(r).reduce((function(e,t){return e[t]=i.getAttribute("ttp:"+t)||r[t],e}),{}),n="preserve"!==i.getAttribute("xml:space"),o=m(f(i,"styling","style")),h=m(f(i,"layout","region"));e=f(i,"body","[begin]");return[].map.call(e,(function(e){var i=function e(t,i){return[].slice.call(t.childNodes).reduce((function(t,r,s){return"br"===r.nodeName&&s?t+"\n":null!=(s=r.childNodes)&&s.length?e(r,i):i?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent}),"")}(e,n);if(!i||!e.hasAttribute("begin"))return null;var r=A(e.getAttribute("begin"),s),c=A(e.getAttribute("dur"),s),u=A(e.getAttribute("end"),s);if(null===r)throw y(e);if(null===u){if(null===c)throw y(e);u=r+c}var f,m,b,v;c=new a.default(r-t,u-t,i),c.id=(0,l.generateCueId)(c.startTime,c.endTime,c.text),f=h[e.getAttribute("region")],m=o[e.getAttribute("style")],r=o,b="http://www.w3.org/ns/ttml#styling",(u=(v=null)!=f&&f.hasAttribute("style")?f.getAttribute("style"):null)&&r.hasOwnProperty(u)&&(v=r[u]),i=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((function(e,t){var i=g(m,b,t)||g(f,b,t)||g(v,b,t);return i&&(e[t]=i),e}),{}),e=i.textAlign;return e&&((r=p[e])&&(c.lineAlign=r),c.align=e),d(c,i),c})).filter((function(e){return null!==e}))}(e,u))}))}catch(e){h(e)}}else h(new Error("Could not parse IMSC1 mdat"))}});var r=i("./src/utils/mp4-tools.ts"),s=i("./src/utils/vttparser.ts"),a=i("./src/utils/vttcue.ts"),n=i("./src/demux/id3.ts"),o=i("./src/utils/timescale-conversion.ts"),l=i("./src/utils/webvtt-parser.ts");function d(){return(d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i,r=arguments[t];for(i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e}).apply(this,arguments)}var h="stpp.ttml.im1t",c=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,u=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,p={left:"start",center:"center",right:"end",start:"start",end:"end"};function f(e,t,i){return e=e.getElementsByTagName(t)[0],e?[].slice.call(e.querySelectorAll(i)):[]}function m(e){return e.reduce((function(e,t){var i=t.getAttribute("xml:id");return i&&(e[i]=t),e}),{})}function g(e,t,i){return e&&e.hasAttributeNS(t,i)?e.getAttributeNS(t,i):null}function y(e){return new Error("Could not parse ttml timestamp "+e)}function A(e,t){if(!e)return null;var i,r,a,n=(0,s.parseTimeStamp)(e);return null===n&&(c.test(e)?(i=t,r=c.exec(e),a=(0|r[4])+(0|r[5])/i.subFrameRate,n=3600*(0|r[1])+60*(0|r[2])+(0|r[3])+a/i.frameRate):u.test(e)&&(n=function(t){var i=u.exec(e),r=Number(i[1]);switch(i[2]){case"h":return 3600*r;case"m":return 60*r;case"ms":return 1e3*r;case"f":return r/t.frameRate;case"t":return r/t.tickRate}return r}(t))),n}},"./src/utils/keysystem-util.ts":(e,t,i)=>{i.r(t),i.d(t,{changeEndianness:()=>function(e){function t(e,t,i){var r=e[t];e[t]=e[i],e[i]=r}t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)},convertDataUriToArrayBytes:()=>function(e){e=e.split(":");var t,i,a=null;return"data"===e[0]&&2===e.length&&(e=e[1].split(";"),2===(i=e[e.length-1].split(",")).length&&(t="base64"===i[0],i=i[1],a=t?(e.splice(-1,1),(0,r.base64Decode)(i)):(t=s(i).subarray(0,16),(e=new Uint8Array(16)).set(t,16-t.length),e))),a},strToUtf8array:()=>s});var r=i("./src/utils/numeric-encoding-utils.ts");function s(e){return Uint8Array.from(unescape(encodeURIComponent(e)),(function(e){return e.charCodeAt(0)}))}},"./src/utils/logger.ts":(e,t,i)=>{function r(){}i.r(t),i.d(t,{enableLogs:()=>function(e,t){if(self.console&&!0===e||"object"==typeof e){!function(e){for(var t=arguments.length,i=new Array(1<t?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];i.forEach((function(t){var i;a[t]=e[t]?e[t].bind(e):(t=t,(i=self.console[t])?i.bind(self.console,"["+t+"] >"):r)}))}(e,"debug","log","info","warn","error");try{a.log('Debug logs enabled for "'+t+'"')}catch(e){a=s}}else a=s},logger:()=>n});var s={trace:r,debug:r,log:r,warn:r,info:r,error:r},a=s,n=s},"./src/utils/mediakeys-helper.ts":(e,t,i)=>{var r,s,a;i.r(t),i.d(t,{KeySystemFormats:()=>s,KeySystemIds:()=>a,KeySystems:()=>r,getKeySystemsForConfig:()=>function(e){var t=e.drmSystems,i=(e=e.widevineLicenseUrl,t?[r.FAIRPLAY,r.WIDEVINE,r.PLAYREADY,r.CLEARKEY].filter((function(e){return!!t[e]})):[]);return!i[r.WIDEVINE]&&e&&i.push(r.WIDEVINE),i},getSupportedMediaKeySystemConfigurations:()=>function(e,t,i,s){var a;switch(e){case r.FAIRPLAY:a=["cenc","sinf"];break;case r.WIDEVINE:case r.PLAYREADY:a=["cenc"];break;case r.CLEARKEY:a=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+e)}var n=s;return[{initDataTypes:a,persistentState:n.persistentState||"not-allowed",distinctiveIdentifier:n.distinctiveIdentifier||"not-allowed",sessionTypes:n.sessionTypes||[n.sessionType||"temporary"],audioCapabilities:t.map((function(e){return{contentType:'audio/mp4; codecs="'+e+'"',robustness:n.audioRobustness||"",encryptionScheme:n.audioEncryptionScheme||null}})),videoCapabilities:i.map((function(e){return{contentType:'video/mp4; codecs="'+e+'"',robustness:n.videoRobustness||"",encryptionScheme:n.videoEncryptionScheme||null}}))}]},keySystemDomainToKeySystemFormat:()=>function(e){switch(e){case r.FAIRPLAY:return s.FAIRPLAY;case r.PLAYREADY:return s.PLAYREADY;case r.WIDEVINE:return s.WIDEVINE;case r.CLEARKEY:return s.CLEARKEY}},keySystemFormatToKeySystemDomain:()=>function(e){switch(e){case s.FAIRPLAY:return r.FAIRPLAY;case s.PLAYREADY:return r.PLAYREADY;case s.WIDEVINE:return r.WIDEVINE;case s.CLEARKEY:return r.CLEARKEY}},keySystemIdToKeySystemDomain:()=>function(e){if(e===a.WIDEVINE)return r.WIDEVINE},requestMediaKeySystemAccess:()=>n}),(i=r=r||{}).CLEARKEY="org.w3.clearkey",i.FAIRPLAY="com.apple.fps",i.PLAYREADY="com.microsoft.playready",i.WIDEVINE="com.widevine.alpha",(t=s=s||{}).CLEARKEY="org.w3.clearkey",t.FAIRPLAY="com.apple.streamingkeydelivery",t.PLAYREADY="com.microsoft.playready",t.WIDEVINE="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",(a=a||{}).WIDEVINE="edef8ba979d64acea3c827dcd51d21ed";var n="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null},"./src/utils/mediasource-helper.ts":(e,t,i)=>{i.r(t),i.d(t,{getMediaSource:()=>function(){return self.MediaSource||self.WebKitMediaSource}})},"./src/utils/mp4-tools.ts":(e,t,i)=>{i.r(t),i.d(t,{RemuxerTrackIdConfig:()=>h,appendUint8Array:()=>function(e,t){var i=new Uint8Array(e.length+t.length);return i.set(e),i.set(t,e.length),i},bin2str:()=>c,computeRawDurationFromSamples:()=>b,discardEPB:()=>_,findBox:()=>g,getDuration:()=>function(e,t){for(var i=0,s=0,a=0,n=g(e,["moof","traf"]),o=0;o<n.length;o++){var l=n[o],d=g(l,["tfhd"])[0],h=t[p(d,4)];if(h){var c=h.default,u=p(d,0)|(null==c?void 0:c.flags),f=null==c?void 0:c.duration;8&u&&(f=p(d,2&u?12:8));for(var m=h.timescale||9e4,A=g(l,["trun"]),v=0;v<A.length;v++)!(i=b(A[v]))&&f&&(i=f*p(A[v],4)),h.type===r.ElementaryStreamTypes.VIDEO?s+=i/m:h.type===r.ElementaryStreamTypes.AUDIO&&(a+=i/m)}}if(0!==s||0!==a)return s||a;for(var _=0,w=g(e,["sidx"]),S=0;S<w.length;S++){var E=y(w[S]);null!=E&&E.references&&(_+=E.references.reduce((function(e,t){return e+t.info.duration||0}),0))}return _},getStartDTS:()=>function(e,t){return g(t,["moof","traf"]).reduce((function(t,i){var r=g(i,["tfdt"])[0],s=r[0];i=g(i,["tfhd"]).reduce((function(t,i){if(i=p(i,4),i=e[i],i){var a=p(r,4);a=(a=1===s?(a*=Math.pow(2,32))+p(r,8):a)/(i.timescale||9e4);if(isFinite(a)&&(null===t||a<t))return a}return t}),null);return null!==i&&isFinite(i)&&(null===t||i<t)?i:t}),null)||0},mp4Box:()=>w,mp4pssh:()=>function(e,t,i){if(16!==e.byteLength)throw new RangeError("Invalid system id");var r,s,a;if(t){r=1,s=new Uint8Array(16*t.length);for(var n=0;n<t.length;n++){var o=t[n];if(16!==o.byteLength)throw new RangeError("Invalid key");s.set(o,16*n)}}else r=0,s=new Uint8Array;0<r?(a=new Uint8Array(4),0<t.length&&new DataView(a.buffer).setUint32(0,t.length,!1)):a=new Uint8Array;var l=new Uint8Array(4);return i&&0<i.byteLength&&new DataView(l.buffer).setUint32(0,i.byteLength,!1),w([112,115,115,104],new Uint8Array([r,0,0,0]),e,a,s,l,i||new Uint8Array)},offsetStartDTS:()=>function(e,t,i){g(t,["moof","traf"]).forEach((function(t){g(t,["tfhd"]).forEach((function(r){var s;r=p(r,4),r=e[r];r&&(s=r.timescale||9e4,g(t,["tfdt"]).forEach((function(e){var t=e[0],r=p(e,4);0===t?(r-=i*s,m(e,4,r=Math.max(r,0))):(r=(r=(r*=Math.pow(2,32))+p(e,8))-i*s,r=Math.max(r,0),t=Math.floor(r/(l+1)),r=Math.floor(r%(l+1)),m(e,4,t),m(e,8,r))})))}))}))},parseEmsg:()=>function(e){var t=e[0],i="",r="",s=0,a=0,n=0,o=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));)r+=c(e.subarray(d,d+1)),d+=1;r+=c(e.subarray(d,d+1)),d+=1,s=p(e,12),a=p(e,16),o=p(e,20),l=p(e,24),d=28}else if(1===t){s=p(e,d+=4);t=p(e,d+=4);var h=p(e,d+=4);for(d+=4,n=Math.pow(2,32)*t+h,Number.isSafeInteger(n)||(n=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=p(e,d),l=p(e,d+=4),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));)r+=c(e.subarray(d,d+1)),d+=1;r+=c(e.subarray(d,d+1)),d+=1}return{schemeIdUri:i,value:r,timeScale:s,presentationTime:n,presentationTimeDelta:a,eventDuration:o,id:l,payload:e.subarray(d,e.byteLength)}},parseInitSegment:()=>function(e){for(var t=[],i=g(e,["moov","trak"]),s=0;s<i.length;s++){var a,n,o,l=i[s],d=g(l,["tkhd"])[0];d&&(n=d[0],d=p(d,0===n?12:20),(a=g(l,["mdia","mdhd"])[0])&&(a=p(a,0===(n=a[0])?12:20),(n=g(l,["mdia","hdlr"])[0])&&(n=c(n.subarray(8,12)),(n={soun:r.ElementaryStreamTypes.AUDIO,vide:r.ElementaryStreamTypes.VIDEO}[n])&&(l=g(l,["mdia","minf","stbl","stsd"])[0],o=void 0,l&&(o=c(l.subarray(12,16))),t[d]={timescale:a,type:n},t[n]={timescale:a,id:d,codec:o}))))}return g(e,["moov","mvex","trex"]).forEach((function(e){var i=p(e,4);i=t[i];i&&(i.default={duration:p(e,12),flags:p(e,20)})})),t},parsePssh:()=>function(e){if(!(e instanceof ArrayBuffer)||e.byteLength<32)return null;var t={version:0,systemId:"",kids:null,data:null},i=new DataView(e),r=i.getUint32(0);if(e.byteLength!==r&&44<r)return null;if(1886614376!==i.getUint32(4))return null;if(t.version=i.getUint32(8)>>>24,1<t.version)return null;t.systemId=o.default.hexDump(new Uint8Array(e,12,16));var s=i.getUint32(28);if(0===t.version){if(r-32<s)return null;t.data=new Uint8Array(e,32,s)}else if(1===t.version){t.kids=[];for(var a=0;a<s;a++)t.kids.push(new Uint8Array(e,32+16*a,16))}return t},parseSEIMessageFromNALu:()=>v,parseSamples:()=>function(e,t){var i=[],s=t.samples,a=t.timescale,n=t.id,o=!1;return g(s,["moof"]).map((function(l){var d=l.byteOffset-8;g(l,["traf"]).map((function(l){var h=g(l,["tfdt"]).map((function(e){var t=e[0],i=p(e,4);return(i=1===t?(i*=Math.pow(2,32))+p(e,8):i)/a}))[0];return void 0!==h&&(e=h),g(l,["tfhd"]).map((function(h){var c=p(h,4),u=16777215&p(h,0),m=0,y=0,A=8;c===n&&(0!=(1&u)&&(A+=8),0!=(2&u)&&(A+=4),0!=(8&u)&&(m=p(h,A),A+=4),0!=(16&u)&&(y=p(h,A),A+=4),0!=(32&u)&&(A+=4),"video"===t.type&&(o=function(e){if(!e)return!1;var t=e.indexOf(".");e=t<0?e:e.substring(0,t);return"hvc1"===e||"hev1"===e||"dvh1"===e||"dvhe"===e}(t.codec)),g(l,["trun"]).map((function(n){var l=n[0],h=16777215&p(n,0),c=0,u=0!=(256&h),g=0,A=0!=(512&h),b=0,_=0!=(1024&h),w=0!=(2048&h),S=0,E=p(n,4),T=8;0!=(1&h)&&(c=p(n,T),T+=4),0!=(4&h)&&(T+=4);for(var k=c+d,x=0;x<E;x++){if(u?(g=p(n,T),T+=4):g=m,A?(b=p(n,T),T+=4):b=y,_&&(T+=4),w&&(S=(0===l?p:f)(n,T),T+=4),t.type===r.ElementaryStreamTypes.VIDEO)for(var C=0;C<b;){var L=p(s,k);!function(e,t){return e?39==(e=t>>1&63)||40==e:6==(31&t)}(o,s[k+=4])||v(s.subarray(k,k+L),o?2:1,e+S/a,i),k+=L,C+=L+4}e+=g/a}})))}))}))})),i},parseSegmentIndex:()=>y,parseSinf:()=>A,patchEncyptionData:()=>function(e,t){if(!e||!t)return e;var i=t.keyId;return i&&t.isCommonEncryption&&g(e,["moov","trak"]).forEach((function(e){e=g(e,["mdia","minf","stbl","stsd"])[0].subarray(8);var t=g(e,["enca"]),r=0<t.length;(t=r?t:g(e,["encv"])).forEach((function(e){g(r?e.subarray(28):e.subarray(78),["sinf"]).forEach((function(e){var t;e=A(e);e&&!(t=e.subarray(8,24)).some((function(e){return 0!==e}))&&(n.logger.log("[eme] Patching keyId in 'enc"+(r?"a":"v")+">sinf>>tenc' box: "+o.default.hexDump(t)+" -> "+o.default.hexDump(i)),e.set(i,8))}))}))})),e},readSint32:()=>f,readUint16:()=>u,readUint32:()=>p,segmentValidRange:()=>function(e){var t={valid:null,remainder:null},i=g(e,["moof"]);return i?i.length<2?(t.remainder=e,t):(i=i[i.length-1],t.valid=(0,s.sliceUint8)(e,0,i.byteOffset-8),t.remainder=(0,s.sliceUint8)(e,i.byteOffset-8),t):t},writeUint32:()=>m});var r=i("./src/loader/fragment.ts"),s=i("./src/utils/typed-array.ts"),a=i("./src/demux/id3.ts"),n=i("./src/utils/logger.ts"),o=i("./src/utils/hex.ts"),l=Math.pow(2,32)-1,d=[].push,h={video:1,audio:2,id3:3,text:4};function c(e){return String.fromCharCode.apply(null,e)}function u(e,t){return e=e[t]<<8|e[t+1],e<0?65536+e:e}function p(e,t){return e=f(e,t),e<0?4294967296+e:e}function f(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function m(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 g(e,t){var i=[];if(!t.length)return i;for(var r=e.byteLength,s=0;s<r;){var a,n=p(e,s);n=1<n?s+n:r;c(e.subarray(s+4,s+8))===t[0]&&(1===t.length?i.push(e.subarray(s+8,n)):(a=g(e.subarray(s+8,n),t.slice(1))).length&&d.apply(i,a)),s=n}return i}function y(e){var t=[],i=e[0],r=8,s=p(e,r),a=e.length+0,n=u(e,r=(r+=4)+(0===i?8:16)+2);r+=2;for(var o=0;o<n;o++){var l=r,d=p(e,l),h=(l+=4,2147483647&d);if(1==(2147483648&d)>>>31)return console.warn("SIDX has hierarchical references (not supported)"),null;d=p(e,l),l+=4,t.push({referenceSize:h,subsegmentDuration:d,info:{duration:d/s,start:a,end:a+h-1}}),a+=h,r=l+=4}return{earliestPresentationTime:0,timescale:s,version:i,referencesCount:n,references:t}}function A(e){var t=g(e,["schm"])[0];return t&&(t=c(t.subarray(4,8)),"cbcs"===t||"cenc"===t)?g(e,["schi","tenc"])[0]:(n.logger.error("[eme] missing 'schm' box"),null)}function b(e){var t=p(e,0),i=8;1&t&&(i+=4),4&t&&(i+=4);for(var r=0,s=p(e,4),a=0;a<s;a++)256&t&&(r+=p(e,i),i+=4),512&t&&(i+=4),1024&t&&(i+=4),2048&t&&(i+=4);return r}function v(e,t,i,r){var s=_(e),n=0;n+=t;for(var o=0,l=0,d=!1,h=0;n<s.length;){for(o=0;!(n>=s.length)&&(o+=h=s[n++],255===h););for(l=0;!(n>=s.length)&&(l+=h=s[n++],255===h););var c=s.length-n;if(!d&&4===o&&n<s.length){if(d=!0,181===s[n++]){var f=u(s,n);if(n+=2,49===f&&(f=p(s,n),n+=4,1195456820===f&&(f=s[n++],3===f))){var m=s[n++],g=64&m,y=g?2+3*(31&m):0,A=new Uint8Array(y);if(g){A[0]=m;for(var b=1;b<y;b++)A[b]=s[n++]}r.push({type:f,payloadType:o,pts:i,bytes:A})}}}else if(5===o&&l<c){if(d=!0,16<l){for(var v=[],w=0;w<16;w++){var S=s[n++].toString(16);v.push(1==S.length?"0"+S:S),3!==w&&5!==w&&7!==w&&9!==w||v.push("-")}for(var E=l-16,T=new Uint8Array(E),k=0;k<E;k++)T[k]=s[n++];r.push({payloadType:o,pts:i,uuid:v.join(""),userData:(0,a.utf8ArrayToStr)(T),userDataBytes:T})}}else if(l<c)n+=l;else if(c<l)break}}function _(e){for(var t=e.byteLength,i=[],r=1;r<t-2;)0===e[r]&&0===e[r+1]&&3===e[r+2]?(i.push(r+2),r+=2):r++;if(0===i.length)return e;var s=t-i.length,a=new Uint8Array(s),n=0;for(r=0;r<s;n++,r++)n===i[0]&&(n++,i.shift()),a[r]=e[n];return a}function w(e){for(var t=arguments.length,i=new Array(1<t?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];for(var s=i.length,a=8,n=s;n--;)a+=i[n].byteLength;var o=new Uint8Array(a);for(o[0]=a>>24&255,o[1]=a>>16&255,o[2]=a>>8&255,o[3]=255&a,o.set(e,4),n=0,a=8;n<s;n++)o.set(i[n],a),a+=i[n].byteLength;return o}},"./src/utils/numeric-encoding-utils.ts":(e,t,i)=>{function r(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function s(e){return btoa(String.fromCharCode.apply(String,e))}i.r(t),i.d(t,{base64Decode:()=>function(e){return Uint8Array.from(atob(e),(function(e){return e.charCodeAt(0)}))},base64DecodeToStr:()=>function(e){return atob(e)},base64Encode:()=>s,base64ToBase64Url:()=>r,base64UrlEncode:()=>function(e){return r(s(e))},strToBase64Encode:()=>function(e){return btoa(e)}})},"./src/utils/output-filter.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>r}),(i=s.prototype).dispatchCue=function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},i.newCue=function(e,t,i){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)},i.reset=function(){this.cueRanges=[],this.startTime=null};var r=s;function s(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}},"./src/utils/texttrack-utils.ts":(e,t,i)=>{i.r(t),i.d(t,{addCueToTrack:()=>function(e,t){var i=e.mode;if("disabled"===i&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error("addCue is failed for: "+t)}catch(i){r.logger.debug("[texttrack-utils]: "+i);var s=new self.TextTrackCue(t.startTime,t.endTime,t.text);s.id=t.id,e.addCue(s)}"disabled"===i&&(e.mode=i)},clearCurrentCues:()=>function(e){var t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(var i=e.cues.length;i--;)e.removeCue(e.cues[i]);"disabled"===t&&(e.mode=t)},getCuesInRange:()=>s,removeCuesInRange:()=>function(e,t,i,r){var a=e.mode;if("disabled"===a&&(e.mode="hidden"),e.cues&&0<e.cues.length)for(var n=s(e.cues,t,i),o=0;o<n.length;o++)r&&!r(n[o])||e.removeCue(n[o]);"disabled"===a&&(e.mode=a)},sendAddTrackEvent:()=>function(e,t){var i;try{i=new Event("addtrack")}catch(e){(i=document.createEvent("Event")).initEvent("addtrack",!1,!1)}i.track=e,t.dispatchEvent(i)}});var r=i("./src/utils/logger.ts");function s(e,t,i){var r=[],s=function(e,t){if(t<e[0].startTime)return 0;var i=e.length-1;if(t>e[i].endTime)return-1;for(var r=0,s=i;r<=s;){var a=Math.floor((s+r)/2);if(t<e[a].startTime)s=a-1;else{if(!(t>e[a].startTime&&r<i))return a;r=a+1}}return e[r].startTime-t<t-e[s].startTime?r:s}(e,t);if(-1<s)for(var a=s,n=e.length;a<n;a++){var o=e[a];if(o.startTime>=t&&o.endTime<=i)r.push(o);else if(o.startTime>i)return r}return r}},"./src/utils/time-ranges.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>r});const r={toString:function(e){for(var t="",i=e.length,r=0;r<i;r++)t+="["+e.start(r).toFixed(3)+"-"+e.end(r).toFixed(3)+"]";return t}}},"./src/utils/timescale-conversion.ts":(e,t,i)=>{function r(e,t,i,r){return e=e*t*(i=void 0===i?1:i),(r=void 0!==r&&r)?Math.round(e):e}i.r(t),i.d(t,{toMpegTsClockFromTimescale:()=>function(e,t){return r(e,9e4,1/(t=void 0===t?1:t))},toMsFromMpegTsClock:()=>function(e,t){return r(e,1e3,1/9e4,t=void 0!==t&&t)},toTimescaleFromBase:()=>r,toTimescaleFromScale:()=>function(e,t,i,s){return r(e,t,1/(i=void 0===i?1:i),s=void 0!==s&&s)}})},"./src/utils/typed-array.ts":(e,t,i)=>{i.r(t),i.d(t,{sliceUint8:()=>function(e,t,i){return Uint8Array.prototype.slice?e.slice(t,i):new Uint8Array(Array.prototype.slice.call(e,t,i))}})},"./src/utils/vttcue.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>r});const r=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;var e=["","lr","rl"],t=["start","middle","end","left","right"];function i(e,t){return"string"==typeof t&&(!!Array.isArray(e)&&(t=t.toLowerCase(),!!~e.indexOf(t)&&t))}function r(e){return i(t,e)}function s(e){for(var t=arguments.length,i=new Array(1<t?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];for(var s=1;s<arguments.length;s++){var a,n=arguments[s];for(a in n)e[a]=n[a]}return e}function a(t,a,n){var o=this,l={enumerable:!0},d=(o.hasBeenReset=!1,""),h=!1,c=t,u=a,p=n,f=null,m="",g=!0,y="auto",A="start",b=50,v="middle",_=50,w="middle";Object.defineProperty(o,"id",s({},l,{get:function(){return d},set:function(e){d=""+e}})),Object.defineProperty(o,"pauseOnExit",s({},l,{get:function(){return h},set:function(e){h=!!e}})),Object.defineProperty(o,"startTime",s({},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(o,"endTime",s({},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(o,"text",s({},l,{get:function(){return p},set:function(e){p=""+e,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",s({},l,{get:function(){return f},set:function(e){f=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",s({},l,{get:function(){return m},set:function(t){if(t=i(e,t),!1===t)throw new SyntaxError("An invalid or illegal string was specified.");m=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",s({},l,{get:function(){return g},set:function(e){g=!!e,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",s({},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(o,"lineAlign",s({},l,{get:function(){return A},set:function(e){if(e=r(e),!e)throw new SyntaxError("An invalid or illegal string was specified.");A=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",s({},l,{get:function(){return b},set:function(e){if(e<0||100<e)throw new Error("Position must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",s({},l,{get:function(){return v},set:function(e){if(e=r(e),!e)throw new SyntaxError("An invalid or illegal string was specified.");v=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",s({},l,{get:function(){return _},set:function(e){if(e<0||100<e)throw new Error("Size must be between 0 and 100.");_=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",s({},l,{get:function(){return w},set:function(e){if(e=r(e),!e)throw new SyntaxError("An invalid or illegal string was specified.");w=e,this.hasBeenReset=!0}})),o.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}()},"./src/utils/vttparser.ts":(e,t,i)=>{i.r(t),i.d(t,{VTTParser:()=>p,fixLineBreaks:()=>u,parseTimeStamp:()=>n});var r=i("./src/utils/vttcue.ts"),s=(a.prototype.decode=function(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))},a);function a(){}function n(e){function t(e,t,i,r){return 3600*(0|e)+60*(0|t)+(0|i)+parseFloat(r||0)}return e=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/),e?59<parseFloat(e[2])?t(e[2],e[3],0,e[4]):t(e[1],e[2],e[3],e[4]):null}(t=l.prototype).set=function(e,t){this.get(e)||""===t||(this.values[e]=t)},t.get=function(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t},t.has=function(e){return e in this.values},t.alt=function(e,t,i){for(var r=0;r<i.length;++r)if(t===i[r]){this.set(e,t);break}},t.integer=function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))},t.percent=function(e,t){return!!(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)&&(t=parseFloat(t),0<=t&&t<=100))&&(this.set(e,t),!0)};var o=l;function l(){this.values=Object.create(null)}function d(e,t,i,r){var s,a,n=r?e.split(r):[e];for(s in n)"string"!=typeof n[s]||2===(a=n[s].split(i)).length&&t(a[0],a[1])}var h=new r.default(0,0,""),c="middle"===h.align?"middle":"center";function u(e){return e.replace(/<br(?: \/)?>/gi,"\n")}(i=f.prototype).parse=function(e){var t=this;function i(){for(var e=0,i=u(i=t.buffer);e<i.length&&"\r"!==i[e]&&"\n"!==i[e];)++e;var r=i.slice(0,e);return"\r"===i[e]&&++e,"\n"===i[e]&&++e,t.buffer=i.slice(e),r}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var s="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;var a=(s=i()).match(/^()?WEBVTT([ \t].*)?$/);if(!a||!a[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var l=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(l?l=!1:s=i(),t.state){case"HEADER":/:/.test(s)?d(s,(function(e,t){}),/:/):s||(t.state="ID");continue;case"NOTE":s||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(s)){t.state="NOTE";break}if(!s)continue;if(t.cue=new r.default(0,0,""),t.state="CUE",-1===s.indexOf("--\x3e")){t.cue.id=s;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{!function(e,t,i){var r,s,a=e;function l(){var t=n(e);if(null===t)throw new Error("Malformed timestamp: "+a);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function u(){e=e.replace(/^\s+/,"")}if(u(),t.startTime=l(),u(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+a);e=e.slice(3),u(),t.endTime=l(),u(),r=e,t=t,s=new o,d(r,(function(e,t){var r;switch(e){case"region":for(var a=i.length-1;0<=a;a--)if(i[a].id===t){s.set(e,i[a].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",c,"end"]);break;case"position":r=t.split(","),s.percent(e,r[0]),2===r.length&&s.alt("positionAlign",r[1],["start",c,"end","line-left","line-right","auto"]);break;case"size":s.percent(e,t);break;case"align":s.alt(e,t,["start",c,"end","left","right"])}}),/:/,/\s/),t.region=s.get("region",null),t.vertical=s.get("vertical",""),"auto"===(r=s.get("line","auto"))&&-1===h.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",c),"auto"===(r=s.get("position","auto"))&&50===h.position&&(r="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=r}(s,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var p=-1!==s.indexOf("--\x3e");if(!s||p&&(l=!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+=s;continue;case"BADCUE":s||(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},i.flush=function(){var t=this;try{if(!t.cue&&"HEADER"!==t.state||(t.buffer+="\n\n",t.parse()),"INITIAL"===t.state||"BADWEBVTT"===t.state)throw new Error("Malformed WebVTT signature.")}catch(e){t.onparsingerror&&t.onparsingerror(e)}return t.onflush&&t.onflush(),this};var p=f;function f(){this.state="INITIAL",this.buffer="",this.decoder=new s,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}},"./src/utils/webvtt-parser.ts":(e,t,i)=>{i.r(t),i.d(t,{generateCueId:()=>c,parseWebVTT:()=>function(e,t,i,h,u,p,f,m){var g,y=new s.VTTParser,A=(e=(0,a.utf8ArrayToStr)(new Uint8Array(e)).trim().replace(l,"\n").split("\n"),[]),b=(0,n.toMpegTsClockFromTimescale)(t,i),v="00:00.000",_=0,w=0,S=!0;y.oncue=function(e){var t=h[u],i=h.ccOffset,r=(_-b)/9e4;null!=t&&t.new&&(void 0!==w?i=h.ccOffset=t.start:function(e,t){var i,r=e[u],s=e[r.prevCC];if(!s||!s.new&&r.new)return e.ccOffset=e.presentationOffset=r.start,r.new=!1;for(;null!=(i=s)&&i.new;)e.ccOffset+=r.start-s.start,r.new=!1,s=e[(r=s).prevCC];e.presentationOffset=t}(h,r)),r&&(i=r-h.presentationOffset),t=e.endTime-e.startTime,r=(0,o.normalizePts)(9e4*(e.startTime+i-w),9e4*p)/9e4,e.startTime=Math.max(r,0),e.endTime=Math.max(r+t,0),i=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(i)),e.id||(e.id=c(e.startTime,e.endTime,i)),0<e.endTime&&A.push(e)},y.onparsingerror=function(e){g=e},y.onflush=function(){g?m(g):f(A)},e.forEach((function(e){if(S){if(d(e,"X-TIMESTAMP-MAP=")){S=!1,e.slice(16).split(",").forEach((function(e){d(e,"LOCAL:")?v=e.slice(6):d(e,"MPEGTS:")&&(_=parseInt(e.slice(7)))}));try{w=function(e){var t=parseInt(e.slice(-3)),i=parseInt(e.slice(-6,-4)),s=parseInt(e.slice(-9,-7)),a=9<e.length?parseInt(e.substring(0,e.indexOf(":"))):0;if((0,r.isFiniteNumber)(t)&&(0,r.isFiniteNumber)(i)&&(0,r.isFiniteNumber)(s)&&(0,r.isFiniteNumber)(a))return t+1e3*i+6e4*s+36e5*a;throw Error("Malformed X-TIMESTAMP-MAP: Local:"+e)}(v)/1e3}catch(e){g=e}return}""===e&&(S=!1)}y.parse(e+"\n")})),y.flush()}});var r=i("./src/polyfills/number.ts"),s=i("./src/utils/vttparser.ts"),a=i("./src/demux/id3.ts"),n=i("./src/utils/timescale-conversion.ts"),o=i("./src/remux/mp4-remuxer.ts"),l=/\r\n|\n\r|\n|\r/g,d=function(e,t,i){return e.slice(i=void 0===i?0:i,i+t.length)===t},h=function(e){for(var t=5381,i=e.length;i;)t=33*t^e.charCodeAt(--i);return(t>>>0).toString()};function c(e,t,i){return h(e.toString())+h(t.toString())+h(i)}},"./src/utils/xhr-loader.ts":(e,t,i)=>{i.r(t),i.d(t,{default:()=>n});var r=i("./src/utils/logger.ts"),s=i("./src/loader/load-stats.ts"),a=/^age:\s*[\d.]+\s*$/m;(t=o.prototype).destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},t.abortInternal=function(){var 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()))},t.abort=function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},t.load=function(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.retryDelay=t.retryDelay,this.loadInternal()},t.loadInternal=function(){var e=this.config,t=this.context;if(e){var i=this.loader=new self.XMLHttpRequest,r=this.stats;r=(r.loading.first=0,r.loaded=0,this.xhrSetup);try{if(r)try{r(i,t.url)}catch(e){i.open("GET",t.url,!0),r(i,t.url)}i.readyState||i.open("GET",t.url,!0);var s=this.context.headers;if(s)for(var a in s)i.setRequestHeader(a,s[a])}catch(e){return void this.callbacks.onError({code:i.status,text:e.message},t,i)}t.rangeEnd&&i.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),i.onreadystatechange=this.readystatechange.bind(this),i.onprogress=this.loadprogress.bind(this),i.responseType=t.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),e.timeout),i.send()}},t.readystatechange=function(){var e,t,i,s,a=this.context,n=this.loader,o=this.stats;a&&n&&(t=n.readyState,e=this.config,!o.aborted&&2<=t&&(self.clearTimeout(this.requestTimeout),0===o.loading.first&&(o.loading.first=Math.max(self.performance.now(),o.loading.start)),4===t?(n.onreadystatechange=null,n.onprogress=null,t=n.status,s="arraybuffer"===n.responseType,200<=t&&t<300&&(s&&n.response||null!==n.responseText)?(o.loading.end=Math.max(self.performance.now(),o.loading.first),s=s?(i=n.response).byteLength:(i=n.responseText).length,o.loaded=o.total=s,this.callbacks&&((s=this.callbacks.onProgress)&&s(o,a,i,n),this.callbacks&&(s={url:n.responseURL,data:i},this.callbacks.onSuccess(s,o,a,n)))):o.retry>=e.maxRetry||400<=t&&t<499?(r.logger.error(t+" while loading "+a.url),this.callbacks.onError({code:t,text:n.statusText},a,n)):(r.logger.warn(t+" while loading "+a.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,e.maxRetryDelay),o.retry++)):(self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),e.timeout))))},t.loadtimeout=function(){r.logger.warn("timeout while loading "+this.context.url);var e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))},t.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},t.getCacheAge=function(){var e,t=null;return this.loader&&a.test(this.loader.getAllResponseHeaders())?(e=this.loader.getResponseHeader("age"))?parseFloat(e):null:t};const n=o;function o(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=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=e?e.xhrSetup:null,this.stats=new s.LoadStats,this.retryDelay=0}},"./node_modules/eventemitter3/index.js":e=>{var t=Object.prototype.hasOwnProperty,i="~";function r(){}function s(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function a(e,t,r,a,n){if("function"!=typeof r)throw new TypeError("The listener must be a function");return r=new s(r,a||e,n),a=i?i+t:t,e._events[a]?e._events[a].fn?e._events[a]=[e._events[a],r]:e._events[a].push(r):(e._events[a]=r,e._eventsCount++),e}function n(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function o(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(i=!1)),o.prototype.eventNames=function(){var e,r,s=[];if(0===this._eventsCount)return s;for(r in e=this._events)t.call(e,r)&&s.push(i?r.slice(1):r);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(e)):s},o.prototype.listeners=function(e){e=i?i+e:e;var t=this._events[e];if(!t)return[];if(t.fn)return[t.fn];for(var r=0,s=t.length,a=new Array(s);r<s;r++)a[r]=t[r].fn;return a},o.prototype.listenerCount=function(e){return e=i?i+e:e,e=this._events[e],e?e.fn?1:e.length:0},o.prototype.emit=function(e,t,r,s,a,n){var o=i?i+e:e;if(!this._events[o])return!1;var l,d=this._events[o],h=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),h){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,r),!0;case 4:return d.fn.call(d.context,t,r,s),!0;case 5:return d.fn.call(d.context,t,r,s,a),!0;case 6:return d.fn.call(d.context,t,r,s,a,n),!0}for(p=1,l=new Array(h-1);p<h;p++)l[p-1]=arguments[p];d.fn.apply(d.context,l)}else for(var c,u=d.length,p=0;p<u;p++)switch(d[p].once&&this.removeListener(e,d[p].fn,void 0,!0),h){case 1:d[p].fn.call(d[p].context);break;case 2:d[p].fn.call(d[p].context,t);break;case 3:d[p].fn.call(d[p].context,t,r);break;case 4:d[p].fn.call(d[p].context,t,r,s);break;default:if(!l)for(c=1,l=new Array(h-1);c<h;c++)l[c-1]=arguments[c];d[p].fn.apply(d[p].context,l)}return!0},o.prototype.on=function(e,t,i){return a(this,e,t,i,!1)},o.prototype.once=function(e,t,i){return a(this,e,t,i,!0)},o.prototype.removeListener=function(e,t,r,s){if(e=i?i+e:e,!this._events[e])return this;if(!t)return n(this,e),this;var a=this._events[e];if(a.fn)a.fn!==t||s&&!a.once||r&&a.context!==r||n(this,e);else{for(var o=0,l=[],d=a.length;o<d;o++)(a[o].fn!==t||s&&!a[o].once||r&&a[o].context!==r)&&l.push(a[o]);l.length?this._events[e]=1===l.length?l[0]:l:n(this,e)}return this},o.prototype.removeAllListeners=function(e){return e?(e=i?i+e:e,this._events[e]&&n(this,e)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=i,e.exports=o.EventEmitter=o},"./node_modules/url-toolkit/src/url-toolkit.js":function(e){var t=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,i=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,s=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var s=a.parseURL(e);if(s)return s.path=a.normalizePath(s.path),a.buildURLFromParts(s);throw new Error("Error trying to parse base URL.")}if(s=a.parseURL(t),!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return r.alwaysNormalize?(s.path=a.normalizePath(s.path),a.buildURLFromParts(s)):t;if(t=a.parseURL(e),!t)throw new Error("Error trying to parse base URL.");!t.netLoc&&t.path&&"/"!==t.path[0]&&(e=i.exec(t.path),t.netLoc=e[1],t.path=e[2]),t.netLoc&&!t.path&&(t.path="/");var n;e={scheme:t.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};return s.netLoc||(e.netLoc=t.netLoc,"/"===s.path[0])||(s.path?(n=(n=t.path).substring(0,n.lastIndexOf("/")+1)+s.path,e.path=a.normalizePath(n)):(e.path=t.path,s.params||(e.params=t.params,s.query||(e.query=t.query)))),null===e.path&&(e.path=r.alwaysNormalize?a.normalizePath(s.path):s.path),a.buildURLFromParts(e)},parseURL:function(e){return e=t.exec(e),e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(r,"");e.length!==(e=e.replace(s,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};e.exports=a}},t={};function i(r){var s=t[r];return void 0!==s||(s=t[r]={exports:{}},e[r].call(s.exports,s,s.exports,i)),s.exports}i.m=e,i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r=i("./src/hls.ts");return r.default})())})));class sa extends r{constructor(e){super(),(this.player=e)._opt,this.canVideoPlay=!1,this.$videoElement=null,this.canvasRenderInterval=null,this.bandwidthEstimateInterval=null,this.fpsInterval=null,this.hlsFps=0,this.hlsPrevFrams=0,this.isInitInfo=!1,this.eventsDestroy=[],Ut()?(this.$videoElement=this.player.video.$videoElement,this.canVideoPlay=!0):ra.isSupported()?(this.$videoElement=this.player.video.$videoElement,this.hls=new ra({}),this._initHls(),this._bindEvents()):this.player.debug.error("HlsDecoder","init hls error ,not support "),this.player.debug.log("HlsDecoder","init")}destroy(){return new Promise((e,t)=>{this.hls&&(this.hls.destroy(),this.hls=null),this.eventsDestroy.length&&(this.eventsDestroy.forEach(e=>e()),this.eventsDestroy=[]),this.isInitInfo=!1,this._stopCanvasRender(),this._stopBandwidthEstimateInterval(),this._stopFpsInterval(),this.$videoElement=null,this.hlsFps=0,this.player.debug.log("HlsDecoder","destroy"),setTimeout(()=>{e()},0)})}checkHlsBufferedDelay(){var e=this.$videoElement;let t=0;const i=e.buffered,r=i.length?i.end(i.length-1):0;return(t=r-e.currentTime)<0&&(this.player.debug.warn("HlsDecoder","checkHlsBufferedDelay result < 0",t,r,e.currentTime),t=0),t}getFps(){return this.hlsFps}_startCanvasRender(){this._stopCanvasRender(),this.canvasRenderInterval=setInterval(()=>{this.player.video.render({$video:this.$videoElement,ts:0})},40)}_stopCanvasRender(){this.canvasRenderInterval&&(clearInterval(this.canvasRenderInterval),this.canvasRenderInterval=null)}_startBandwidthEstimateInterval(){this._stopBandwidthEstimateInterval(),this.bandwidthEstimateInterval=setInterval(()=>{let e=0;this.hls.bandwidthEstimate&&(e=this.hls.bandwidthEstimate),this.player.emit(U.kBps,(e/1024/8/10).toFixed(2))},1e3)}_stopBandwidthEstimateInterval(){this.bandwidthEstimateInterval&&(clearInterval(this.bandwidthEstimateInterval),this.bandwidthEstimateInterval=null)}_startFpsInterval(){this._stopCanvasRender(),this.fpsInterval=setInterval(()=>{var e=this.$videoElement.getVideoPlaybackQuality();this.hlsFps=e.totalVideoFrames-this.hlsPrevFrams,this.hlsPrevFrams=e.totalVideoFrames},1e3)}_stopFpsInterval(){this.fpsInterval&&(clearInterval(this.fpsInterval),this.fpsInterval=null)}_initHls(){this.player._opt.useCanvasRender&&(this.$videoElement=document.createElement("video"),this.$videoElement.muted=!0,ot()&&(this.$videoElement.style.position="absolute"),this.initVideoEvents()),this.hls.attachMedia(this.$videoElement)}_bindEvents(){const e=this.player,t=this.player.events["proxy"];this.hls;var i=t(this.$videoElement,_e,t=>{this.hls&&(t=parseInt(t.timeStamp,10),e.handleRender(),e.updateStats({ts:t,dts:t,fps:!0}),e.emit(U.videoTimeUpdate,t))});this.eventsDestroy.push(i),this._startBandwidthEstimateInterval(),this._startFpsInterval(),this.hls.on(ra.Events.ERROR,(e,t)=>{if(t.fatal)switch(t.type){case ra.ErrorTypes.NETWORK_ERROR:this.player.debug.warn("HlsDecoder","fatal network error encountered, try to recover"),this.hls.startLoad();break;case ra.ErrorTypes.MEDIA_ERROR:this.player.debug.warn("HlsDecoder","fatal media error encountered, try to recover"),this.hls.recoverMediaError()}}),this.hls.on(ra.Events.MEDIA_ATTACHING,()=>{}),this.hls.on(ra.Events.MEDIA_ATTACHED,()=>{}),this.hls.on(ra.Events.MEDIA_DETACHING,()=>{}),this.hls.on(ra.Events.MEDIA_DETACHED,()=>{}),this.hls.on(ra.Events.BUFFER_RESET,()=>{}),this.hls.on(ra.Events.BUFFER_CODECS,()=>{}),this.hls.on(ra.Events.BUFFER_CREATED,()=>{}),this.hls.on(ra.Events.BUFFER_APPENDING,(e,t)=>{this.player.debug.log("HlsDecoder","BUFFER_APPENDING",t)}),this.hls.on(ra.Events.BUFFER_APPENDED,()=>{}),this.hls.on(ra.Events.BUFFER_EOS,()=>{}),this.hls.on(ra.Events.BUFFER_FLUSHING,()=>{}),this.hls.on(ra.Events.BUFFER_FLUSHED,()=>{}),this.hls.on(ra.Events.MANIFEST_LOADING,()=>{this.player.debug.log("HlsDecoder","MANIFEST_LOADING 开始加载playlist m3u8资源")}),this.hls.on(ra.Events.MANIFEST_LOADED,(e,t)=>{this.player.debug.log("HlsDecoder","MANIFEST_LOADED playlist m3u8文件加载完成",t)}),this.hls.on(ra.Events.MANIFEST_PARSED,()=>{this.player.debug.log("HlsDecoder","MANIFEST_PARSED playlist m3u8解析完成"),e._times.demuxStart||(e._times.demuxStart=qe())}),this.hls.on(ra.Events.LEVEL_LOADING,()=>{}),this.hls.on(ra.Events.LEVEL_LOADED,(e,t)=>{}),this.hls.on(ra.Events.FRAG_LOADING,()=>{}),this.hls.on(ra.Events.FRAG_LOADED,(t,i)=>{e._times.decodeStart||(e._times.decodeStart=qe())}),this.hls.on(ra.Events.BUFFER_APPENDING,()=>{e._times.videoStart||(e._times.videoStart=qe(),e.handlePlayToRenderTimes())}),this.hls.on(ra.Events.FRAG_DECRYPTED,()=>{}),this.hls.on(ra.Events.KEY_LOADING,()=>{}),this.hls.on(ra.Events.KEY_LOADING,()=>{}),this.hls.on(ra.Events.FPS_DROP,e=>{}),this.hls.on(ra.Events.FPS_DROP_LEVEL_CAPPING,e=>{}),this.hls.on(ra.Events.FRAG_PARSING_INIT_SEGMENT,(e,t)=>{this.player.debug.log("HlsDecoder","FRAG_PARSING_INIT_SEGMENT",t);const i=!!(t&&t.tracks&&t.tracks.audio),r=!!(t&&t.tracks&&t.tracks.video);if(i&&t.tracks.audio){var s=t.tracks.audio;const e=s.metadata&&s.metadata.channelCount?s.metadata.channelCount:0,i=s.codec;this.player.audio&&this.player.audio.updateAudioInfo({encType:i,channels:e,sampleRate:44100})}if(r&&t.tracks.video){let e=t.tracks.video,i=e.codec,r=e.metadata&&e.metadata.width?e.metadata.width:0,s=e.metadata&&e.metadata.height?e.metadata.height:0;this.player.video&&this.player.video.updateVideoInfo({encTypeCode:-1!==i.indexOf("avc")?7:12,width:r,height:s})}})}initVideoPlay(e){this.player._opt.useCanvasRender&&(this.$videoElement=document.createElement("video"),this.initVideoEvents()),this.$videoElement.muted=!0,this.$videoElement.src=e}initRenderSize(){this.isInitInfo||(this.player.video.updateVideoInfo({width:this.$videoElement.videoWidth,height:this.$videoElement.videoHeight}),this.player.video.initCanvasViewSize(),this.isInitInfo=!0)}initVideoEvents(){const e=this.player.events["proxy"],t=e(this.$videoElement,be,()=>{this.player.debug.log("HlsDecoder","video canplay"),this.$videoElement.play().then(()=>{this.player.debug.log("HlsDecoder","video play"),this._startCanvasRender(),this.initRenderSize()}).catch(e=>{this.player.debug.warn("HlsDecoder","video play error ",e)})}),i=e(this.$videoElement,ve,()=>{this.player.debug.log("HlsDecoder","video waiting")}),r=e(this.$videoElement,_e,e=>{e=parseInt(e.timeStamp,10),this.player.handleRender(),this.player.updateStats({ts:e}),this.player.emit(U.videoTimeUpdate,e),this.$videoElement.paused&&(this.player.debug.warn("HlsDecoder","video is paused and next try to replay"),this.$videoElement.play().then(()=>{this.player.debug.log("HlsDecoder","video is paused and replay success")}).catch(e=>{this.player.debug.warn("HlsDecoder","video is paused and replay error ",e)}))}),s=e(this.$videoElement,we,()=>{this.player.debug.log("HlsDecoder","video playback Rate change",this.$videoElement&&this.$videoElement.playbackRate)});this.eventsDestroy.push(t,i,r,s)}loadSource(e){return new Promise((t,i)=>{this.canVideoPlay?(this.initVideoPlay(e),t()):this.hls.on(ra.Events.MEDIA_ATTACHED,()=>{this.hls.loadSource(e),t()})})}_handleUpdatePlaybackRate(){if(this.$videoElement){const r=this.$videoElement;var e=(this.player._opt.videoBuffer+this.player._opt.videoBufferDelay)/1e3;const s=r.buffered;s.length&&s.start(0);var t=s.length?s.end(s.length-1):0;let a=r.currentTime;var i=t-a;e=Math.max(5,3+e),e=(e<i?(this.player.debug.warn("HlsDecoder",`handleUpdatePlaybackRate and delay buffer is more than ${e} is ${i} and new time is ${t} `),r.currentTime=t,a=r.currentTime):i<0&&this.player.debug.warn("HlsDecoder",`handleUpdatePlaybackRate and delay buffer is less than 0 is ${i} and new time is `+t),this._getPlaybackRate(t-a));r.playbackRate!==e&&(r.playbackRate=e)}}_getPlaybackRate(e){var t=this.$videoElement,i=this.player._opt.videoBuffer,r=i+this.player._opt.videoBufferDelay;return e*=1e3,1===t.playbackRate?r<e?1.2:1:e<=i?1:t.playbackRate}getDecodePlaybackRate(){let e=0;var t=this.$videoElement;return t?t.playbackRate:e}}const aa="fetch",na="arraybuffer",oa="real_time_speed",la=Object.prototype.toString;function da(e){if("[object Object]"===la.call(e))return e=Object.getPrototypeOf(e),null===e||e===Object.prototype}function ha(e){if(e&&null!==e[0]&&void 0!==e[0]&&(0!==e[0]||null!==e[1]&&void 0!==e[1])){let t="bytes="+e[0]+"-";return e[1]&&(t+=e[1]),t}}function ca(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function ua(e,t){if(e){if(!t)return e;let r;var i=Object.keys(t).map(e=>{if(null!=(r=t[e]))return Array.isArray(r)?e+="[]":r=[r],r.map(t=>{var i=t;return"[object Date]"===la.call(i)?t=t.toISOString():null!==t&&"object"==typeof t&&(t=JSON.stringify(t)),ca(e)+"="+ca(t)}).join("&")}).filter(Boolean).join("&");if(i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}}function pa(e,t,i,r,s,a,n,o,l,d,h){return s=null!=s?parseFloat(s):null,r=parseInt(r||"0",10),{data:e,done:t,option:{range:l,vid:d,index:o,contentLength:r=Number.isNaN(r)?0:r,age:s,startTime:a,firstByteTime:n,endTime:Date.now(),priOptions:h},response:i}}function fa(e,t){return Math.round(8*e*1e3/t/1024)}class ma extends Error{constructor(e,t,i,r){super(r),Ds(this,"retryCount",0),Ds(this,"isTimeout",!1),Ds(this,"loaderType",aa),Ds(this,"startTime",0),Ds(this,"endTime",0),Ds(this,"options",{}),this.url=e,this.request=t,this.response=i}}class ga extends r{constructor(e){super(),Ds(this,"_abortController",null),Ds(this,"_timeoutTimer",null),Ds(this,"_reader",null),Ds(this,"_response",null),Ds(this,"_aborted",!1),Ds(this,"_index",-1),Ds(this,"_range",null),Ds(this,"_receivedLength",0),Ds(this,"_running",!1),Ds(this,"_logger",null),Ds(this,"_vid",""),Ds(this,"_onProcessMinLen",0),Ds(this,"_onCancel",null),Ds(this,"_priOptions",null),Ds(this,"TAG_NAME","FetchLoader"),this.player=e}load(e){let{url:t,vid:i,timeout:r,responseType:s,onProgress:a,index:n,onTimeout:o,onCancel:l,range:d,transformResponse:h,request:c,params:u,method:p,headers:f,body:m,mode:g,credentials:y,cache:A,redirect:b,referrer:v,referrerPolicy:_,onProcessMinLen:w,priOptions:S}=e;this._aborted=!1,this._onProcessMinLen=w,this._onCancel=l,this._abortController="undefined"!=typeof AbortController&&new AbortController,this._running=!0,this._index=n,this._range=d||[0,0],this._vid=i||t,this._priOptions=S||{};const E={method:p,headers:f,body:m,mode:g,credentials:y,cache:A,redirect:b,referrer:v,referrerPolicy:_,signal:null==(e=this._abortController)?void 0:e.signal};let T=!1;clearTimeout(this._timeoutTimer),t=ua(t,u),e=ha(d),e&&(f=c?c.headers:E.headers=E.headers||(Headers?new Headers:{}),Headers&&f instanceof Headers?f.append("Range",e):f.Range=e),r&&(this._timeoutTimer=setTimeout(()=>{if(T=!0,this.cancel(),o){const e=new ma(t,E,null,"timeout");e.isTimeout=!0,o(e,{index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions})}},r));const k=Date.now();return(_t(n)||_t(d))&&this.player.debug.log(this.TAG_NAME,"[fetch load start], index,",n,",range,",d),new Promise((e,i)=>{fetch(c||t,c?void 0:E).then(async r=>{if(clearTimeout(this._timeoutTimer),this._response=r,!this._aborted&&this._running){if(!(r=h&&h(r,t)||r).ok)throw new ma(t,E,r,"bad network response");var o=Date.now();let l;if("text"===s)l=await r.text(),this._running=!1;else if("json"===s)l=await r.json(),this._running=!1;else{if(a)return this.resolve=e,this.reject=i,void this._loadChunk(r,a,k,o);{l=await r.arrayBuffer(),l=new Uint8Array(l),this._running=!1;const e=Date.now()-k,t=fa(l.byteLength,e);this.emit(oa,{speed:t,len:l.byteLength,time:e,vid:this._vid,index:this._index,range:this._range,priOptions:this._priOptions})}}(_t(n)||_t(d))&&this.player.debug.log(this.TAG_NAME,"[fetch load end], index,",n,",range,",d),e(pa(l,!0,r,r.headers.get("Content-Length"),r.headers.get("age"),k,o,n,d,this._vid,this._priOptions))}}).catch(e=>{var r;clearTimeout(this._timeoutTimer),this._running=!1,this._aborted&&!T||((e=e instanceof ma?e:new ma(t,E,null,null==(r=e)?void 0:r.message)).startTime=k,e.endTime=Date.now(),e.isTimeout=T,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(r){}this._response=this._reader=null}if(this._abortController){try{this._abortController.abort()}catch(r){}this._abortController=null}this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions})}}_loadChunk(e,t,i,r){if(!e.body||!e.body.getReader){this._running=!1;const t=new ma(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)}0<this._onProcessMinLen&&(this._cache=new Uint8Array(2097152),this._writeIdx=0);const s=this._reader=e.body.getReader();let a,n,o;const l=async()=>{n=Date.now();try{a=await s.read(),o=Date.now()}catch(d){return o=Date.now(),void(this._aborted||(this._running=!1,d.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this.reject(d)))}var d=0<(null==(d=this._range)?void 0:d.length)?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:n,endTime:o,st:i,firstByteTime:r,priOptions:this._priOptions},e);var 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),0<this._onProcessMinLen){if(this._writeIdx+c>=this._onProcessMinLen||a.done)(u=new Uint8Array(this._writeIdx+c)).set(this._cache.slice(0,this._writeIdx),0),0<c&&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(0<c&&this._writeIdx+c<2097152)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(0<c){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),0<c&&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&&0<u.byteLength||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:n,endTime:o,st:i,firstByteTime:r,priOptions:this._priOptions},e),a.done){const t=Date.now()-i,s=fa(this._receivedLength,t);this.emit(oa,{speed:s,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(pa(a,!0,e,e.headers.get("Content-Length"),e.headers.get("age"),i,r,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 ya{constructor(e,t,i){Ds(this,"TAG_NAME","Task"),this.promise=function(){let e,t;const i=new Promise((i,r)=>{e=i,t=r});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=new(e===aa&&window.fetch?ga:Aa)(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,...a}=this._config,n=async()=>{try{const e=await this._loader.load(a);this.promise.resolve(e)}catch(r){if(this._loader.running=!1,this.player.debug.log(this.TAG_NAME,"[task request catch err]",r),this._canceled)return;r.loaderType=this._loaderType,r.retryCount=this._retryCount;let l=r,d=(s&&(l=s(l)||l),i&&0<this._retryCount&&i(l,this._retryCount,{index:a.index,vid:a.vid,range:a.range,priOptions:a.priOptions}),this._retryCount++,!0);if((d=this._retryCheckFunc?this._retryCheckFunc(r):d)&&this._retryCount<=e)return clearTimeout(this._retryTimer),this.player.debug.log(this.TAG_NAME,"[task request setTimeout],retry",this._retryCount,",retry range,",a.range),void(this._retryTimer=setTimeout(n,t));this.promise.reject(l)}};return n(),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 Aa extends r{constructor(e){super(),Ds(this,"_xhr",null),Ds(this,"_aborted",!1),Ds(this,"_timeoutTimer",null),Ds(this,"_range",null),Ds(this,"_receivedLength",0),Ds(this,"_url",null),Ds(this,"_onProgress",null),Ds(this,"_index",-1),Ds(this,"_headers",null),Ds(this,"_currentChunkSizeKB",384),Ds(this,"_timeout",null),Ds(this,"_xhr",null),Ds(this,"_withCredentials",null),Ds(this,"_startTime",-1),Ds(this,"_loadCompleteResolve",null),Ds(this,"_loadCompleteReject",null),Ds(this,"_runing",!1),Ds(this,"_logger",!1),Ds(this,"_vid",""),Ds(this,"_responseType",void 0),Ds(this,"_credentials",void 0),Ds(this,"_method",void 0),Ds(this,"_transformResponse",void 0),Ds(this,"_firstRtt",void 0),Ds(this,"_onCancel",null),Ds(this,"_priOptions",null),Ds(this,"TAG_NAME","XhrLoader"),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=ua(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 ma?e:new ma(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===na&&this._range&&1<this._range.length)if(this._onProgress){this._firstRtt=-1;var t=1024*this._currentChunkSizeKB,i=this._range[0]+this._receivedLength;let r=this._range[1];t<this._range[1]-i&&(r=i+t),e=[i,r],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,i=(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=>{var t;this._running=!1;const i=new ma(this._url,this._request,null==e||null==(t=e.currentTarget)?void 0:t.response,"xhr.onerror.status:"+(null==e||null==(t=e.currentTarget)?void 0:t.status)+",statusText,"+(null==e||null==(t=e.currentTarget)?void 0:t.statusText));i.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(i)},t.ontimeout=e=>{this.cancel();const t=new ma(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)},this._headers||{}),r=ha(e);r&&(i.Range=r),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(r){r.options={index:this._index,range:e,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(r)}}_onReadyStatechange(e){2===e.target.readyState&&this._firstRtt<0&&(this._firstRtt=Date.now())}_onLoad(e){var t;const i=e.target.status;if(i<200||299<i){const t=new ma(this._url,null,{...e.target.response,status:i},"bad response,status:"+i);return t.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(t)}let r,s=null,a=!1;var n,o=0<(null==(t=this._range)?void 0:t.length)?this._range[0]:0;if(this._responseType===na){const t=new Uint8Array(e.target.response);if(r=o+this._receivedLength,t&&0<t.byteLength){this._receivedLength+=t.byteLength;const e=Date.now()-this._startTime,i=fa(this._receivedLength,e);this.emit(oa,{speed:i,len:this._receivedLength,time:e,vid:this._vid,index:this._index,range:[r,o+this._receivedLength],priOptions:this._priOptions})}s=t,a=!(1<(null==(n=this._range)?void 0:n.length)&&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",r,"end ",o+this._receivedLength,",dataLen,",t?t.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",a)}else a=!0,s=e.target.response;let l={ok:200<=i&&i<300,status:i,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(l=this._transformResponse(l,this._url)||l),this._onProgress&&this._onProgress(s,a,{index:this._index,vid:this._vid,range:[r,o+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},l),a?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(pa(this._onProgress?null:s,a,l,l.headers["content-length"],l.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 r of t){const e=r.split(": ");i[e[0].toLowerCase()]=e.slice(1).join(": ")}return i}}class ba extends r{constructor(e,t){super(),Ds(this,"type",aa),Ds(this,"_queue",[]),Ds(this,"_alive",[]),Ds(this,"_currentTask",null),Ds(this,"_config",void 0),this.player=t,this._config=(t=e,{loaderType:aa,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:"text",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,...t}),"xhr"!==this._config.loaderType&&ga.isSupported()||(this.type="xhr")}destroy(){this._queue=[],this._alive=[],this._currentTask=null}isFetch(){return this.type===aa}static isFetchSupport(){return ga.isSupported()}load(e){let t=1<arguments.length&&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)).params&&(t.params=Object.assign({},t.params)),t.headers&&da(t.headers)&&(t.headers=Object.assign({},t.headers)),t.body&&da(t.body)&&(t.body=Object.assign({},t.body)),t.transformRequest&&(t=t.transformRequest(t)||t);const i=new ya(this.type,t,this.player);return i.loader.on(oa,e=>{this.emit(oa,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(e){let t=0<arguments.length&&void 0!==e?e:0;return new Promise(e=>setTimeout(e,t))}()}_processTask(){if(this._currentTask=this._queue.shift(),this._currentTask){this._currentTask.alive&&this._alive.push(this._currentTask);const e=this._currentTask.exec().catch(e=>{});e&&"function"==typeof e.finally&&e.finally(()=>{var e;null!=(e=this._currentTask)&&e.alive&&0<(null==(e=this._alive)?void 0:e.length)&&(this._alive=this._alive.filter(e=>e&&e!==this._currentTask)),this._processTask()})}}}const va="network",_a="network_timeout",wa="other";class Sa extends Error{constructor(e,t,i,r,s){super(s||(null==i?void 0:i.message)),this.errorType=e===_a?va:e,this.originError=i,this.ext=r,this.errorMessage=this.message}static create(e,t,i,r,s){return e instanceof Sa?e:(e instanceof Error&&(i=e,e=""),e=e||wa,new Sa(e,t,i,r,s))}static network(e){return new Sa(null!=e&&e.isTimeout?_a:va,null,e instanceof Error?e:null,{url:null==e?void 0:e.url,response:null==e?void 0:e.response,httpCode:null==e||null==(e=e.response)?void 0:e.status})}}const Ea=/^#(EXT[^:]*)(?::(.*))?$/,Ta=/([^=]+)=(?:"([^"]*)"|([^",]*))(?:,|$)/g,ka=/^(?:[a-zA-Z0-9+\-.]+:)?\/\//,xa=/^((?:[a-zA-Z0-9+\-.]+:)?\/\/[^/?#]*)?([^?#]*\/)?/;function Ca(e){const t=e.match(Ea);if(t&&t[1])return[t[1].replace("EXT-X-",""),t[2]]}function La(e){const t={};let i=Ta.exec(e);for(;i;)t[i[1]]=i[2]||i[3],i=Ta.exec(e);return t}function Da(e,t){return t&&e&&!ka.test(e)?(t=xa.exec(t),t?"/"===e[0]?t[1]+e:t[1]+t[2]+e:e):e}const Ra={audio:[/^mp4a/,/^vorbis$/,/^opus$/,/^flac$/,/^[ae]c-3$/],video:[/^avc/,/^hev/,/^hvc/,/^vp0?[89]/,/^av1$/],text:[/^vtt$/,/^wvtt/,/^stpp/]};function Ia(e,t){const i=Ra[e];if(i&&t&&t.length)for(let r=0;r<i.length;r++)for(let e=0;e<t.length;e++)if(i[r].test(t[e]))return t[e]}class Pa{constructor(){Ds(this,"version",0),Ds(this,"streams",[]),Ds(this,"isMaster",!0)}}class Ba{constructor(){Ds(this,"id",0),Ds(this,"url",""),Ds(this,"default",!1),Ds(this,"autoSelect",!1),Ds(this,"forced",!1),Ds(this,"group",""),Ds(this,"name",""),Ds(this,"lang",""),Ds(this,"segments",[]),Ds(this,"endSN",0)}}class Ua extends Ba{constructor(){super(...arguments),Ds(this,"mediaType","AUDIO"),Ds(this,"channels",0)}}class Fa extends Ba{constructor(){super(...arguments),Ds(this,"mediaType","SUBTITLE")}}class Ma{constructor(){Ds(this,"id",0),Ds(this,"bitrate",0),Ds(this,"width",0),Ds(this,"height",0),Ds(this,"name",""),Ds(this,"url",""),Ds(this,"audioCodec",""),Ds(this,"videoCodec",""),Ds(this,"textCodec",""),Ds(this,"audioGroup",""),Ds(this,"audioStreams",[]),Ds(this,"subtitleStreams",[]),Ds(this,"closedCaptionsStream",[])}}class Oa{constructor(){Ds(this,"version",0),Ds(this,"url",""),Ds(this,"type",""),Ds(this,"startCC",0),Ds(this,"endCC",0),Ds(this,"startSN",0),Ds(this,"endSN",0),Ds(this,"totalDuration",0),Ds(this,"targetDuration",0),Ds(this,"live",!0),Ds(this,"segments",[])}}class Na{constructor(){Ds(this,"sn",0),Ds(this,"cc",0),Ds(this,"url",""),Ds(this,"title",""),Ds(this,"start",0),Ds(this,"duration",0),Ds(this,"key",null),Ds(this,"byteRange",null),Ds(this,"isInitSegment",!1),Ds(this,"initSegment",null),Ds(this,"isLast",!1),Ds(this,"hasAudio",!1),Ds(this,"hasVideo",!1)}get end(){return this.start+this.duration}setTrackExist(e,t){this.hasVideo=e,this.hasAudio=t}setByteRange(e,t){this.byteRange=[0],e=e.split("@"),1===e.length&&t&&t.byteRange?(this.byteRange[0]=t.byteRange[1]||0,this.byteRange[0]&&(this.byteRange[0]+=1)):this.byteRange[0]=parseInt(e[1]),this.byteRange[1]=this.byteRange[0]+parseInt(e[0])-1}}class ja{constructor(e){Ds(this,"method",""),Ds(this,"url",""),Ds(this,"iv",null),Ds(this,"keyFormat",""),Ds(this,"keyFormatVersions",""),e instanceof ja&&(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 ja(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 za{static parse(){let e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",t=1<arguments.length?arguments[1]:void 0;if(!e.includes("#EXTM3U"))throw new Error("Invalid m3u8 file");var i=e.split(/[\r\n]/).map(e=>e.trim()).filter(Boolean);return(za.isMediaPlaylist(e)?function(e,t){const i=new Oa;i.url=t;let r,s=new Na,a=null,n=null,o=0,l=0,d=0,h=0,c=!1;for(;(r=e[h++])&&!c;)if("#"!==r[0])s.sn=l,s.cc=d,s.url=Da(r,t),n&&(s.key=n.clone(l)),a&&(s.initSegment=a),i.segments.push(s),s=new Na,l++;else{const e=Ca(r);if(e){const[r,h]=e;switch(r){case"VERSION":i.version=parseInt(h);break;case"PLAYLIST-TYPE":i.type=null==h?void 0:h.toUpperCase();break;case"TARGETDURATION":i.targetDuration=parseFloat(h);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(h);break;case"DISCONTINUITY-SEQUENCE":d=i.startCC=parseInt(h);break;case"DISCONTINUITY":d++;break;case"BYTERANGE":s.setByteRange(h,i.segments[i.segments.length-1]);break;case"EXTINF":{const[e,t]=h.split(",");s.start=o,s.duration=parseFloat(e),o+=s.duration,s.title=t}break;case"KEY":{const e=La(h);if("NONE"===e.METHOD){n=null;break}if("AES-128"!==e.METHOD)throw new Error(`encrypt ${e.METHOD}/${e.KEYFORMAT} is not supported`);if((n=new ja).method=e.METHOD,n.url=/^blob:/.test(e.URI)?e.URI:Da(e.URI,t),n.keyFormat=e.KEYFORMAT||"identity",n.keyFormatVersions=e.KEYFORMATVERSIONS,e.IV){let t=e.IV.slice(2);t=(1&t.length?"0":"")+t,n.iv=new Uint8Array(t.length/2);for(let e=0,i=t.length/2;e<i;e++)n.iv[e]=parseInt(t.slice(2*e,2*e+2),16)}}break;case"MAP":{const e=La(h);s.url=Da(e.URI,t),e.BYTERANGE&&s.setByteRange(e.BYTERANGE),s.isInitSegment=!0,s.sn=0,n&&(s.key=n.clone(0)),a=s,s=new Na}}}}const u=i.segments[i.segments.length-1];return u&&(i.endSN=u.sn),i.totalDuration=o,i.endCC=d,i}:function(e,t){const i=new Pa;let r,s=0;const a=[],n=[];for(;r=e[s++];){var o=Ca(r);if(o){var[o,l]=o;if("VERSION"===o)i.version=parseInt(l);else if("MEDIA"===o&&l){const e=La(l);let i;switch(e.TYPE){case"AUDIO":i=new Ua;break;case"SUBTITLES":i=new Fa;break;default:i=new Ba}i.url=Da(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&&n.push(i)}else if("STREAM-INF"===o&&l){const r=new Ma,a=La(l);if(r.bitrate=parseInt(a["AVERAGE-BANDWIDTH"]||a.BANDWIDTH),r.name=a.NAME,r.url=Da(e[s++],t),a.RESOLUTION){const[e,t]=a.RESOLUTION.split("x");r.width=parseInt(e),r.height=parseInt(t)}if(a.CODECS){const e=a.CODECS.split(/[ ,]+/).filter(Boolean);r.videoCodec=Ia("video",e),r.audioCodec=Ia("audio",e),r.textCodec=Ia("text",e)}r.audioGroup=a.AUDIO,r.subtitleGroup=a.SUBTITLES,i.streams.push(r)}}}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))})),n.length&&(n.forEach((e,t)=>{e.id=t}),i.streams.forEach(e=>{e.subtitleGroup&&(e.subtitleStreams=n.filter(t=>t.group===e.subtitleGroup))})),i})(i,t)}static isMediaPlaylist(e){return e.includes("#EXTINF:")||e.includes("#EXT-X-TARGETDURATION:")}}class Ga{constructor(e){Ds(this,"_onLoaderRetry",(e,t)=>{this.hls.emit(Be,{error:Sa.network(e),retryTime:t})}),this.hls=e,this.player=e.player,this.TAG_NAME="HlsManifestLoader",this._timer=null;var{retryCount:e,retryDelay:t,loadTimeout:i,fetchOptions:r}=this.hls.config;this._loader=new ba({...r,responseType:"text",retry:e,retryDelay:t,timeout:i,onRetryError:this._onLoaderRetry},this.player),this._audioLoader=new ba({...r,responseType:"text",retry:e,retryDelay:t,timeout:i,onRetryError:this._onLoaderRetry},this.player),this._subtitleLoader=new ba({...r,responseType:"text",retry:e,retryDelay:t,timeout:i,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 r=[this._loader.load(e)];let s,a,n,o,l,d;t&&r.push(this._audioLoader.load(t)),i&&r.push(this._subtitleLoader.load(i));try{const[e,i,o]=await Promise.all(r);if(!e)return[];s=e.data,n=t?(a=null==i?void 0:i.data,null==o?void 0:o.data):null==i?void 0:i.data}catch(e){throw Sa.network(e)}try{var h;if(!1===(null==(h=o=za.parse(s,e))?void 0:h.live)&&o.segments&&!o.segments.length)throw new Error("empty segments list");a&&(l=za.parse(a,t)),n&&(d=za.parse(n,i))}catch(e){throw new Sa("manifest","hls",e)}return o&&(o.isMaster?this.hls.emit("hls-manifest-loaded",{playlist:o}):this.hls.emit("hls-level-loaded",{playlist:o})),[o,l,d]}poll(e,t,i,r,s,a){clearTimeout(this._timer),a=a||3e3;let n=this.hls.config.pollRetryCount;const o=async()=>{clearTimeout(this._timer);try{const s=await this.load(e,t,i);if(!s[0])return;n=this.hls.config.pollRetryCount,r(s[0],s[1],s[2])}catch(e){--n<=0&&s(e)}this._timer=setTimeout(o,a)};this._timer=setTimeout(o,a)}stopPoll(){return clearTimeout(this._timer),this.cancel()}cancel(){return Promise.all([this._loader.cancel(),this._audioLoader.cancel()])}}class Ha{constructor(){Ds(this,"_chunkSpeeds",[]),Ds(this,"_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 Wa{constructor(e){Ds(this,"_emitOnLoaded",(e,t)=>{var{data:e,response:i,option:r}=e,{firstByteTime:r,startTime:s,endTime:a,contentLength:n}=r||{},a=a-s;this._bandwidthService.addRecord(n||e.byteLength,a),this.hls.emit("speed",{time:a,byteLength:n,url:t}),this.hls.emit("load-complete",{url:t,elapsed:a||0}),this.hls.emit("ttfb",{url:t,responseUrl:i.url,elapsed:r-s}),this.hls.emit("load-response-headers",{headers:i.headers})}),Ds(this,"_onLoaderRetry",(e,t)=>{this.hls.emit(Be,{error:Sa.network(e),retryTime:t})}),this.hls=e,this.player=e.player,this._bandwidthService=new Ha;var{retryCount:e,retryDelay:t,loadTimeout:i,fetchOptions:r}=this.hls.config;this._segmentLoader=new ba({...r,responseType:"arraybuffer",retry:e,retryDelay:t,timeout:i,onRetryError:this._onLoaderRetry},this.player),this._audioSegmentLoader=new ba({...r,responseType:"arraybuffer",retry:e,retryDelay:t,timeout:i,onRetryError:this._onLoaderRetry},this.player),this._keyLoader=new ba({...r,responseType:"arraybuffer",retry:e,retryDelay:t,timeout:i,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()}}load(e,t,i){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:i;const s=[];return e&&(s[0]=this.loadVideoSegment(e,i)),t&&(s[1]=this.loadAudioSegment(t,r)),Promise.all(s)}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){var r;let s,a,n,o,l;const d=[];if(this.hls.emit(Ue,{url:t.url}),d[0]=e.load(t.url),i&&t.initSegment){const i=t.initSegment.url,r=((s=this._mapCache[i])||(this.hls.emit(Ue,{url:i}),d[1]=e.load(i).then(e=>{e&&(30<Object.keys(this._mapCache)&&(this._mapCache={}),s=this._mapCache[i]=e.data,this._emitOnLoaded(e,i))})),null==(e=t.initSegment.key)?void 0:e.url);r&&(l=t.initSegment.key.iv,(o=this._keyCache[r])||(this.hls.emit(Ue,{url:r}),d[2]=this._keyLoader.load(r).then(e=>{e&&(o=this._keyCache[r]=e.data,this._emitOnLoaded(e,r))})))}const h=null==(r=t.key)?void 0:r.url;h&&(n=t.key.iv,(a=this._keyCache[h])||(this.hls.emit(Ue,{url:h}),d[3]=this._keyLoader.load(h).then(e=>{e&&(a=this._keyCache[h]=e.data,this._emitOnLoaded(e,h))})));var[i]=await Promise.all(d);if(i)return e=i.data,this._emitOnLoaded(i,t.url),{data:e,map:s,key:a,mapKey:o,keyIv:n,mapKeyIv:l}}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()])}}class Va{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(){var e;return this.targetDuration||(null==(e=this.segments[0])?void 0:e.duration)||0}get liveEdge(){return this.endTime}get endTime(){var e;return(null==(e=this.lastSegment)?void 0:e.end)||0}get currentSubtitleEndSn(){var e;return(null==(e=this.currentSubtitleStream)?void 0:e.endSN)||0}clearOldSegment(e,t){return this._clearSegments(e,t)}getAudioSegment(e){if(e&&this.currentAudioStream){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)){const t=this._updateSegments(e,this.currentSubtitleStream),i=this.currentSubtitleStream.segments;return 100<i.length&&(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;var r=this.segments;for(let s=0,a=r.length;s<a;s++)if(r[s].end>=e){i=s;break}return(i=i>t?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 r=i[i.length-1],s=(null==r?void 0:r.sn)||-1;if(s<e.endSN&&e.segments.length){const a=e.segments.findIndex(e=>e.sn===s),n=a<0?e.segments:e.segments.slice(a+1);if(i.length&&n.length){let e=r.end;n.forEach(t=>{t.start=e,e=t.end});const t=(null==r?void 0:r.cc)||-1;t>n[0].cc&&n.forEach(e=>e.cc+=t)}return t.endSN=e.endSN,t.segments=i.concat(n),n}}else t.segments=e.segments}}class Ka{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(){var e;return null==(e=this.currentStream)?void 0:e.lastSegment}get currentSegment(){var e;return null==(e=this.currentSegments)?void 0:e[this._segmentPointer]}get nextSegment(){var e;return null==(e=this.currentSegments)?void 0:e[this._segmentPointer+1]}get currentSegments(){var e;return null==(e=this.currentStream)?void 0:e.segments}get currentSubtitleEndSn(){var e;return null==(e=this.currentStream)?void 0:e.currentSubtitleEndSn}get liveEdge(){var e;return null==(e=this.currentStream)?void 0:e.liveEdge}get totalDuration(){var e;return(null==(e=this.currentStream)?void 0:e.totalDuration)||0}get seekRange(){var e=this.currentSegments;if(e&&e.length)return[e[0].start,e[e.length-1].end]}get isEmpty(){var e;return!(null!=(e=this.currentSegments)&&e.length)}get isLive(){var e;return null==(e=this.currentStream)?void 0:e.live}get hasSubtitle(){var e;return!(null==(e=this.currentStream)||!e.currentSubtitleStream)}getAudioSegment(e){var t;return null==(t=this.currentStream)?void 0:t.getAudioSegment(e)}moveSegmentPointer(e){var t;null==e&&(e=this._segmentPointer+1),this._segmentPointer=Je(e,-1,null==(t=this.currentSegments)?void 0:t.length),this.player.debug.log(this.TAG_NAME,"moveSegmentPointer()",e,this._segmentPointer)}reset(){this.streams=[],this.currentStream=null,this.dvrWindow=0,this._segmentPointer=-1}getSegmentByIndex(e){var t;return null==(t=this.currentSegments)?void 0:t[e]}setNextSegmentByIndex(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;this._segmentPointer=e-1,this.player.debug.log(this.TAG_NAME,"setNextSegmentByIndex()",e,this._segmentPointer)}findSegmentIndexByTime(e){var t=this.currentSegments;if(t){for(let i,r=0,s=t.length;r<s;r++)if(e>=(i=t[r]).start&&e<i.end)return r;var i=t[t.length-1];if(Math.abs(e-i.end)<.2)return t.length-1}}upsertPlaylist(e,t,i){if(e){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 Va(e)}),this.currentStream=this.streams[0];else if(Array.isArray(e.segments)){const s=this.currentStream;var r;s?(s.update(e,t,i),(r=s.updateSubtitle(i))&&this.hls.emit("subtitle-segments",{list:r})):(this.reset(),this.currentStream=this.streams[0]=new Va(e,t,i))}this.currentStream&&this.hls.isLive&&!this.dvrWindow&&(this.dvrWindow=this.currentSegments.reduce((e,t)=>e+t.duration,0))}else this.player.debug.warn(this.TAG_NAME,"upsertPlaylist() playlist is null")}switchSubtitle(e){var t;null!=(t=this.currentStream)&&t.switchSubtitle(e)}clearOldSegment(){var e,t,i=0<arguments.length&&void 0!==arguments[0]?arguments[0]:50;const r=this.currentStream;this.dvrWindow&&r&&((e=r.endTime-this.dvrWindow)<=0?this.player.debug.log(this.TAG_NAME,`clearOldSegment() stream.endTime:${r.endTime}, this.dvrWindow:${this.dvrWindow} startTime <= 0`):(t=r.segments).length<=i?this.player.debug.log(this.TAG_NAME,`clearOldSegment() segments.length:${t.length} <= maxPlaylistSize:`+i):(t=this._segmentPointer,this._segmentPointer=r.clearOldSegment(e,t),this.player.debug.log(this.TAG_NAME,"clearOldSegment() update _segmentPointer:",t,this._segmentPointer),this.player.debug.log(this.TAG_NAME,"currentSegments",this.currentSegments)))}checkSegmentTrackChange(e,t){var i=this.findSegmentIndexByTime(e),r=this.getSegmentByIndex(i);if(r&&(r.hasAudio||r.hasVideo))return 2!==t&&r.hasAudio&&r.hasVideo?r:.3<r.end-e||!(t=this.getSegmentByIndex(i+1))||!t.hasAudio&&!t.hasVideo||t.hasAudio===r.hasAudio&&t.hasVideo===r.hasVideo?void 0:t}}function $a(){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 r=new Uint8Array(t.reduce((e,t)=>e+t.byteLength,0));let s=0;return t.forEach(e=>{r.set(e,s),s+=e.byteLength}),r}class Ya{constructor(){var e=window.crypto||window.msCrypto;this.subtle=e&&(e.subtle||e.webkitSubtle),this.externalDecryptor=null}decrypt(e,t){if(e||t){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?$a(e.map,t):t}async _decryptData(e,t,i){if(this.externalDecryptor)return this.externalDecryptor.decrypt(e,t,i);if(!this.subtle)throw new Error("crypto is not defined");return t=await this.subtle.importKey("raw",t,{name:"AES-CBC"},!1,["encrypt","decrypt"]),new Uint8Array(await this.subtle.decrypt({name:"AES-CBC",iv:i},t,e))}}class qa extends cr{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=7,this._audioCodecType=10,this._vps=null,this._sps=null,this._pps=null,this.TAG_NAME="TsLoader",this.videoTrack=qa.initVideoTrack(),this.audioTrack=qa.initAudioTrack(),this._baseDts=-1,this._baseDtsInited=!1,this._basefps=25,this._baseFpsInterval=null,this._allSampleList=[],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.player.debug.log(this.TAG_NAME,"init")}destroy(){super.destroy(),this._stopDecodeLoopInterval(),this.videoTrack=null,this.audioTrack=null,this._baseDts=-1,this._baseDtsInited=!1,this._basefps=50,this._hasCalcFps=!1,this._allSampleList=[],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.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]}static _parsePES(e){var t=e[8];if(!(null==t||e.length<t+9)&&1==(e[0]<<16|e[1]<<8|e[2])){var i=(e[4]<<8)+e[5];if(!(i&&i>e.length-6)){let r,s;return i=e[7],192&i&&(r=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,64&i?(s=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2,54e5<r-s&&(r=s)):s=r),{data:e.subarray(9+t),pts:r,dts:s,originalPts:r,originalDts:s}}}}_demux(e){let t=1<arguments.length&&void 0!==arguments[1]&&arguments[1],i=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],r=(t&&(this._pmtId=-1,this.videoTrack=qa.initVideoTrack(),this.audioTrack=qa.initAudioTrack()),!i||t?(this._remainingPacketData=null,this._videoPesData=[],this._audioPesData=[]):(this.videoTrack.samples=[],this.audioTrack.samples=[],this._remainingPacketData&&(e=$a(this._remainingPacketData,e),this._remainingPacketData=null)),e.length);var s=r%188;s&&(this._remainingPacketData=e.subarray(r-s),r-=s);for(let a=0;a<r;a+=188){if(71!==e[a])throw new Error("TS packet did not start with 0x47");const t=!!(64&e[a+1]),i=((31&e[a+1])<<8)+e[a+2];let r;if(1<(48&e[a+3])>>4){if((r=a+5+e[a+4])===a+188)continue}else r=a+4;switch(i){case 0:t&&(r+=e[r]+1),this._pmtId=(31&e[r+10])<<8|e[r+11];break;case this._pmtId:{t&&(r+=e[r]+1);const i=r+3+((15&e[r+1])<<8|e[r+2])-4;for(r+=12+((15&e[r+10])<<8|e[r+11]);r<i;){const t=(31&e[r+1])<<8|e[r+2];switch(e[r]){case 15:this._audioPid=t,this._audioCodecType=10;break;case 27:this._videoPid=t,this._codecType=7;break;case 36:this._videoPid=t,this._codecType=12;break;default:console.warn(`Unsupported stream. type: ${e[r]}, pid: `+t)}r+=5+((15&e[r+3])<<8|e[r+4])}}break;case this._videoPid:t&&this._videoPesData.length&&this._parseVideoData(),this._videoPesData.push(e.subarray(r,a+188));break;case this._audioPid:t&&this._audioPesData.length&&this._parseAudioData(),this._audioPesData.push(e.subarray(r,a+188));break;case 17:case 8191:break;default:console.warn("Unknown pid: "+i)}}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,r){this.player._times.demuxStart||(this.player._times.demuxStart=qe()),this._demux(e,t,i,r),this._fix(r,t,i)}_parseVideoData(){var e,t;this._videoPesData.length?(e=qa._parsePES($a(...this._videoPesData)))?(this.player.updateStats({vbps:e.data.byteLength}),(t=function(e){var t=e.length;let i=2,r=0;for(;null!==e[i]&&void 0!==e[i]&&1!==e[i];)i++;if(i++,(r=i+2)>=t)return[];const s=[];for(;r<t;)switch(e[r]){case 0:if(0!==e[r-1]){r+=2;break}if(0!==e[r-2]){r++;break}for(i!==r-2&&s.push(e.subarray(i,r-2));1!==e[++r]&&r<t;);i=r+1,r=i+2;break;case 1:if(0!==e[r-1]||0!==e[r-2]){r+=3;break}i!==r-2&&s.push(e.subarray(i,r-2)),i=r+1,r=i+2;break;default:r+=3}return i<t&&s.push(e.subarray(i)),s}(e.data))?this._createVideoSample(t,e.pts,e.dts):this.player.debug.warn(this.TAG_NAME,"Cannot parse avc units",e),this._videoPesData=[]):console.warn("Cannot parse video pes",this._videoPesData):console.log("_parseVideoData","no video pes data")}_createVideoSample(e,t,i){if(e.length){const r=12===this._codecType,s={isIFrame:!1,type:2,isHevc:r,vps:null,sps:null,pps:null,pts:t,dts:i,payload:null};e.forEach(e=>{const t=r?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(!r&&5!==t||r&&5===t)break;s.isIFrame=!0,this._gopId++;break;case 6:case 39:case 40:if(!r&&6!==t||r&&6===t)break;{var a=function(e){const t=e.byteLength,i=[];let r=1;for(;r<t-2;)0===e[r]&&0===e[r+1]&&3===e[r+2]?(i.push(r+2),r+=2):r++;if(!i.length)return e;const s=t-i.length,a=new Uint8Array(s);let n=0;for(r=0;r<s;n++,r++)n===i[0]&&(n++,i.shift()),a[r]=e[n];return a}(e),n=r,o=a.length;let t=n?2:1,i=0,s=0,l="";for(;255===a[t];)i+=255,t++;for(i+=a[t++];255===a[t];)s+=255,t++;if(s+=a[t++],5===i&&o>t+16)for(let e=0;e<16;e++)l+=a[t].toString(16),t++;a.subarray(t)}return void(this.player._opt.isEmitSEI&&this.player.emit(U.videoSEI,{ts:i/90,data:e}));case 32:if(!r)break;s.vps||(s.vps=e);break;case 7:case 33:if(!r&&7!==t||r&&7===t)break;s.sps||(s.sps=e);break;case 8:case 34:if(!r&&8!==t||r&&8===t)break;s.pps||(s.pps=e)}if(r&&ir(t)||!r&&Ji(t)){const t=hr(e);if(s.payload){this.player.debug.log(this.TAG_NAME,"append nal unit to payload");const e=new Uint8Array(s.payload.byteLength+t.byteLength);e.set(s.payload,0),e.set(t,s.payload.byteLength),s.payload=e}else s.payload=t}});let a=null;r?s.sps&&s.vps&&s.pps&&(a=Zi({vps:s.vps,sps:s.sps,pps:s.pps})):s.sps&&s.pps&&(a=Ki({sps:s.sps,pps:s.pps})),a&&(this.player.debug.log(this.TAG_NAME,"_createVideoSample","seqHeader"),this._doDecodeByHls(a,2,s.pts,!0,0)),s.isIFrame&&this.calcIframeIntervalTimestamp(s.dts/90),this.videoTrack.samples=this.videoTrack.samples.concat(s)}}_parseAudioData(){if(this._audioPesData.length){const e=qa._parsePES($a(...this._audioPesData));if(e){if(this.player._opt.hasAudio){if(this.player.updateStats({abps:e.data.byteLength}),10===this._audioCodecType){const t=function(e,t){var i=e.length;let r=0;for(;r+2<i&&(255!==e[r]||240!=(246&e[r+1]));)r++;if(!(r>=i)){const o=r,l=[],d=(60&e[r+2])>>>2,h=Ge[d];if(!h)throw new Error("Invalid sampling index: "+d);var s=1+((192&e[r+2])>>>6),a=(1&e[r+2])<<2|(192&e[r+3])>>>6;let c,u,p=0;for(var n=We(h);r+7<i;)if(255===e[r]&&240==(246&e[r+1])){if(u=(3&e[r+3])<<11|e[r+4]<<3|(224&e[r+5])>>5,i-r<u)break;c=2*(1&~e[r+1]),l.push({pts:t+p*n,data:e.subarray(r+7+c,r+u)}),p++,r+=u}else r++;return{skip:o,remaining:r>=i?void 0:e.subarray(r),frames:l,samplingFrequencyIndex:d,sampleRate:h,objectType:s,channelCount:a,originCodec:"mp4a.40."+s}}}(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=ze({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,1,0,!1,0)}if(this._isSendAACSeqHeader){const e=[];t.frames.forEach(t=>{const i=t.pts,r=new Uint8Array(t.data.length+2);r.set([175,1],0),r.set(t.data,2),t={type:1,pts:i,dts:i,payload:r},e.push(t)}),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 console.warn("Cannot parse audio pes",this._audioPesData)}}_fix(){let e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,t=1<arguments.length&&void 0!==arguments[1]&&arguments[1],i=!(2<arguments.length&&void 0!==arguments[2])||arguments[2];e=Math.round(9e4*e);const r=this.videoTrack,s=this.audioTrack,a=r.samples,n=s.samples;if(a.length||n.length){var o=a[0],l=n[0];let d=0;if(a.length&&n.length&&(d=o.dts-l.pts),this._baseDtsInited||this._calculateBaseDts(),t&&(this._calculateBaseDts(),this._baseDts-=e),!i){this._videoNextDts=0<d?e+d:e,this._audioNextPts=0<d?e:e-d;const t=o?o.dts-this._baseDts-this._videoNextDts:0,i=l?l.pts-this._baseDts-this._audioNextPts:0;9e4<Math.abs(t||i)&&(this._calculateBaseDts(this.audioTrack,this.videoTrack),this._baseDts-=e)}this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(s),this._fixVideo(r);let h=r.samples.concat(s.samples);h=h.map(e=>(e.dts=e.dts/90,e.pts=e.pts/90,e.cts=e.pts-e.dts,e)).sort((e,t)=>e.dts-t.dts),this._allSampleList=this._allSampleList.concat(h),$t(this._hasCalcFps)&&(this._hasCalcFps=!0,this._calcDecodeFps(h))}}_calculateBaseDts(){const e=this.audioTrack,t=this.videoTrack,i=e.samples,r=t.samples;if(!i.length&&!r.length)return!1;let s=1/0,a=1/0;i.length&&(e.baseDts=s=i[0].pts),r.length&&(t.baseDts=a=r[0].dts),this._baseDts=Math.min(s,a);var n=a-s;return Number.isFinite(n)&&45e3<Math.abs(n)&&this.player.debug.warn(this.TAG_NAME,`large av first frame gap,\n video pts: ${a},\n audio pts: ${s},\n base dts: ${this._baseDts},\n detect is: `+n),this._baseDtsInited=!0}_resetBaseDtsWhenStreamBreaked(){this._baseDtsInited&&this._videoTimestampBreak&&this._audioTimestampBreak&&this._calculateBaseDts(this.audioTrack,this.videoTrack)&&(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){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 a=t.length;let n=0;const o=t[0],l=t[1],d=this._videoNextDts-o.dts;45e3<Math.abs(d)&&(o.dts+=d,o.pts+=d,this.player.debug.warn(this.TAG_NAME,`large video gap between chunk,\n next dts is ${this._videoNextDts},\n first dts is ${o.dts},\n next dts is ${l.dts},\n duration is `+d),l&&9e4<Math.abs(l.dts-o.dts)&&(this._videoTimestampBreak=!0,t.forEach((e,t)=>{0!==t&&(e.dts+=d,e.pts+=d)})));var i=e.samples[0],r=e.samples[a-1],s=1===a?9e3:Math.floor((r.dts-i.dts)/(a-1));for(let i=0;i<a;i++){const r=t[i].dts,o=t[i+1];if(9e4<(n=i<a-1?o.dts-r:t[i-1]?Math.min(r-t[i-1].dts,s):s)||n<0){this._videoTimestampBreak=!0,n=this._audioTimestampBreak?s:Math.max(n,2700);const a=this._audioNextPts||0;o&&o.dts>a&&(n=s),this.player.debug.warn(this.TAG_NAME,`large video gap between frames,\n time is ${r/e.timescale},\n dts is ${r},\n origin dts is ${t[i].originalDts},\n next dts is ${this._videoNextDts},\n sample Duration is ${n} ,\n ref Sample DurationInt is `+s)}t[i].duration=n,this._videoNextDts+=n}}}_doFixAudioInternal(e,t,i){e.sampleDuration||(e.sampleDuration=We(e.timescale,i));var r,s,a=e.sampleDuration;if(void 0===this._audioNextPts){const e=t[0];this._audioNextPts=e.pts}for(let o=0;o<t.length;o++){const i=this._audioNextPts,l=t[o],d=l.pts-i;if(!this._audioTimestampBreak&&3*a<=d&&d<=9e4&&!ot()){r=e.codec,s=e.channelCount,("mp4a.40.2"===r?1===s?new Uint8Array([0,200,0,128,35,128]):2===s?new Uint8Array([33,0,73,144,2,25,0,35,128]):3===s?new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]):4===s?new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]):5===s?new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]):6===s&&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]):1===s?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]):(2===s||3===s)&&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]))||t[0].data.subarray();var n=Math.floor(d/a);45e4<Math.abs(l.pts-this._lastAudioExceptionGapDot)&&(this._lastAudioExceptionGapDot=l.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 ${i},\n ref sample duration is `+a);for(let e=0;e<n;e++)this._audioNextPts+=a,o++;o--}else d<=-3*a&&-9e4<=d?(45e4<Math.abs(l.pts-this._lastAudioExceptionOverlapDot)&&(this._lastAudioExceptionOverlapDot=l.pts,this.player.debug.warn(this.TAG_NAME,`audio overlap detected,\n pts is ${l.pts},\n originPts is ${l.originalPts},\n nextPts is ${i},\n ref sample duration is `+a)),t.splice(o,1),o--):(9e4<=Math.abs(d)&&(this._audioTimestampBreak=!0,45e4<Math.abs(l.pts-this._lastAudioExceptionLargeGapDot)&&(this._lastAudioExceptionLargeGapDot=l.pts,this.player.debug.warn(this.TAG_NAME,`large audio gap detected,\n time is ${l.pts/1e3}\n pts is ${l.pts},\n originPts is ${l.originalPts},\n nextPts is ${i},\n sample duration is ${d}\n ref sample duration is `+a))),l.dts=l.pts=i,this._audioNextPts+=a)}}_calcDecodeFps(e){e=jt(e.map(e=>({ts:e.dts||e.pts,type:e.type})),2),e&&(this._basefps=e,this._startDecodeLoopInterval(),this.player.debug.log(this.TAG_NAME,`_calcDecodeFps() video fps is ${e}, update base fps is `+this._basefps))}_startDecodeLoopInterval(){this.player.debug.log(this.TAG_NAME,"_startDecodeLoopInterval()"),this._stopDecodeLoopInterval(),this._loop();var e=Math.ceil(1e3/this._basefps);this._baseFpsInterval=setInterval(()=>{var e=(new Date).getTime();this.preLoopTimestamp||(this.preLoopTimestamp=e),e-=this.preLoopTimestamp;e>2*this._basefps&&this.player.debug.warn(this.TAG_NAME,`hls loop demux diff time is ${e} and more than `+2*this._basefps),this._loop(),this.preLoopTimestamp=(new Date).getTime()},e)}_loop(){let e=null;if(this._allSampleList.length)if(2===(e=this._allSampleList.shift()).type){this._doDecodeVideo(e);let t=this._allSampleList[0];for(;t&&1===t.type;)e=this._allSampleList.shift(),this._doDecodeAudio(e),t=this._allSampleList[0]}else 1===e.type&&(this._doDecodeAudio(e),this._allSampleList.length&&2===this._allSampleList[0].type&&(e=this._allSampleList.shift(),this._doDecodeVideo(e)))}_doDecodeAudio(e){this._doDecodeByHls(e.payload,1,e.dts,!1,0)}_doDecodeVideo(e){var t=new Uint8Array(e.payload),i=(t=(e.isHevc?er:$i)(t,e.isIFrame),this.player.updateStats({dts:e.dts}),e.pts-e.dts);this._doDecodeByHls(t,2,e.dts,e.isIFrame,i)}_stopDecodeLoopInterval(){this._baseFpsInterval&&(clearInterval(this._baseFpsInterval),this._baseFpsInterval=null)}getBuferredDuration(){let e=0;return this._allSampleList&&this._allSampleList.forEach(t=>{t.duration&&2===t.type&&(e+=t.duration)}),e/90}getSampleListLength(){return this._allSampleList.length}getSampleAudioListLength(){return this._allSampleList.filter(e=>1===e.type).length}getSampleVideoListLength(){return this._allSampleList.filter(e=>2===e.type).length}}class Ja{constructor(e,t){this.hls=e,this.player=this.hls.player,this._initSegmentId="",this.TAG_NAME="HlsTransmuxer",this._demuxer=new qa(this.hls.player),t&&console.log("hls needRemux")}destroy(){this._demuxer&&(this._demuxer.destroy(),this._demuxer=null)}transmux(e,t,i,r,s,a){this.player.debug.log(this.TAG_NAME,`transmux videoChunk:${e&&e.byteLength}, audioChunk:${t&&t.byteLength}, discontinuity:${i}, contiguous:${r}, startTime:${s}, needInit:`+a);const n=this._demuxer;try{n.demuxAndFix($a(e,t),i,r,s)}catch(e){throw new Sa("demux","hls",e)}}}class Qa{constructor(e){this.hls=e,this.player=e.player,this._decryptor=new Ya,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(){var e;return null==(e=this._transmuxer)||null==(e=e._demuxer)?void 0:e._baseDts}get nbSb(){return 0}async updateDuration(e){this.player.debug.log(this.TAG_NAME,"updateDuration()",e)}getBuferredDuration(){var e;return null==(e=this._transmuxer)||null==(e=e._demuxer)?void 0:e.getBuferredDuration()}getBufferedSegments(){var e;return null==(e=this._transmuxer)||null==(e=e._demuxer)?void 0:e.getSampleListLength()}getBufferedAudioSegments(){var e;return null==(e=this._transmuxer)||null==(e=e._demuxer)?void 0:e.getSampleAudioListLength()}getBufferedVideoSegments(){var e;return null==(e=this._transmuxer)||null==(e=e._demuxer)?void 0:e.getSampleVideoListLength()}createSource(e,t,i,r){this._sourceCreated||(e=e||t)&&(qa.probe(e)?this._transmuxer||(this._transmuxer=new Ja(this.hls,!this._softVideo)):console.error("createSource error: chunk is not ts"))}async appendBuffer(e,t,i,r,s,a,n){if(null!=i&&i.length||null!=r&&r.length)return this._needInitSegment,this._transmuxer.transmux(i,r,s,a,n,this._needInitSegment||s),!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 Xa{constructor(e){this.emitter=e,this._seiSet=new Set,e.on("sei",e=>{e&&this._seiSet.add(e)})}throw(e){if(null!=e&&this._seiSet.size){const t=e-.2,i=e+.2,r=[];this._seiSet.forEach(e=>{e.time>=t&&e.time<=i&&r.push(e)}),r.forEach(e=>{this._seiSet.delete(e),this.emitter.emit("sei-in-time",e)})}}reset(){this._seiSet.clear()}}class Za{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){e=e["data"],e=null==e||null==(e=e.onMetaData)?void 0:e.framerate;e&&0<e&&e<100&&(this.fps=e)}setVideoMeta(e){this.width=e.width,this.height=e.height,this.videoCodec=e.codec,this.encodeType=e.codecType,e.fpsNum&&e.fpsDen&&0<(e=e.fpsNum/e.fpsDen)&&e<100&&(this.fps=e)}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){var t;(!this.fps||100<=this.fps)&&e.length&&(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),1e3<=this._bitsAccumulateDuration&&(this.bitrate=8*this._bitsAccumulateSize,this._bitsAccumulateDuration=0,this._bitsAccumulateSize=0)})}}class en{constructor(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1e3;Ds(this,"_core",null),Ds(this,"_samples",[]),this._core=e,this._timescale=t,this._stats=new Za(t),this._bindEvents()}getStats(){var e,t,{currentTime:i=0,decodeFps:r=0}=(null==(i=this._core)?void 0:i.media)||{};return{...this._stats.getStats(),downloadSpeed:(null==(e=this._core)||null==(t=e.speedInfo)?void 0:t.call(e).speed)||0,avgSpeed:(null==(t=this._core)||null==(e=t.speedInfo)?void 0:e.call(t).avgSpeed)||0,currentTime:i,bufferEnd:(null==(e=this._core)||null==(t=e.bufferInfo())?void 0:t.remaining)||0,decodeFps:r}}_bindEvents(){this._core.on("demuxed-track",e=>this._stats.updateBitrate(e.samples)),this._core.on("flv-script-data",e=>{this._stats.setFpsFromScriptData(e)}),this._core.on("metadata-parsed",e=>{"video"===e.type?this._stats.setVideoMeta(e.track):this._stats.setAudioMeta(e.track)}),this._core.on("ttfb",e=>{this._stats.setDomain(e.responseUrl)})}reset(){this._samples=[],this._stats=new Za(this._timescale)}}class tn extends r{constructor(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};super(),Ds(this,"_loadSegment",async()=>{var e,t;if(this.player.debug.log(this.TAG_NAME,"_loadSegment()","_segmentProcessing",this._segmentProcessing),!this._segmentProcessing)return e=this._playlist.currentSegment,t=this._playlist.nextSegment,this.player.debug.log(this.TAG_NAME,"_loadSegment()","curSeg",e,"nextSeg",t),t?this._loadSegmentDirect():void this.player.debug.log(this.TAG_NAME,"nextSeg is null and return");this.player.debug.warn("_loadSegment()","_segmentProcessing is ture and return")}),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={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,...t},this._manifestLoader=new Ga(this),this._segmentLoader=new Wa(this),this._playlist=new Ka(this),this._bufferService=new Qa(this),this._seiService=new Xa(this),this._stats=new en(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._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(){var e;return null==(e=this._bufferService)?void 0:e.baseDts}speedInfo(){return this._segmentLoader.speedInfo()}getStats(){return this._stats.getStats()}async loadSource(e){return this.player.debug.log(this.TAG_NAME,"loadSource() "+e),await this._reset(),await this._loadData(e),this._startTick(),!0}async _loadData(e){this.player.debug.log(this.TAG_NAME,"_loadData() "+e);try{e=e&&e.trim()}catch(e){}if(!e)throw this._emitError(new Sa(wa,wa,null,null,"m3u8 url is missing"));const t=await this._loadM3U8(e),i=this._playlist["currentStream"];if(this._urlSwitching){var r;0===i.bitrate&&null!=(r=this._switchUrlOpts)&&r.bitrate&&(i.bitrate=null==(r=this._switchUrlOpts)?void 0:r.bitrate);const e=this._getSeamlessSwitchPoint(),t=(this.config.startTime=e,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;this.player.debug.log(this.TAG_NAME,"load m3u8: "+e);try{[t]=await this._manifestLoader.load(e)}catch(e){throw this._emitError(Sa.create(e))}var i;if(t)return this._playlist.upsertPlaylist(t),t.isMaster?(null!=(i=this._playlist.currentStream.subtitleStreams)&&i.length&&this.emit("subtitle-playlist",{list:this._playlist.currentStream.subtitleStreams}),await this._refreshM3U8()):this.player.debug.warn(this.TAG_NAME,"_loadM3U8() is not master playlist"),this.emit("stream-parsed"),t;this.player.debug.warn(this.TAG_NAME,"_loadM3U8() playlist is empty")}_refreshM3U8(){this.player.debug.log(this.TAG_NAME,"_refreshM3U8()");var e,t=this._playlist.currentStream;if(!t||!t.url)throw this._emitError(Sa.create(null,null,new Error("m3u8 url is not defined")));const i=t.url,r=null==(e=t.currentAudioStream)?void 0:e.url,s=null==(e=t.currentSubtitleStream)?void 0:e.url;return this._manifestLoader.load(i,r,s).then(e=>{var[e,t,a]=e;e?(this._playlist.upsertPlaylist(e,t,a),this.isLive&&this._pollM3U8(i,r,s)):this.player.debug.warn(this.TAG_NAME,"_refreshM3U8() mediaPlaylist is empty")}).catch(e=>{throw this._emitError(Sa.create(e))})}_pollM3U8(e,t,i){let r=this._playlist.isEmpty;this._manifestLoader.poll(e,t,i,(e,t,i)=>{this._playlist.upsertPlaylist(e,t,i),this._playlist.clearOldSegment(),e&&r&&!this._playlist.isEmpty&&this._loadSegment(),r=r&&this._playlist.isEmpty},e=>{this._emitError(Sa.create(e))},1e3*((null==(e=this._playlist.lastSegment)?void 0:e.duration)||0))}async _loadSegmentDirect(){this.player.debug.log(this.TAG_NAME,"_loadSegmentDirect()");var e=this._playlist.nextSegment;if(e){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(Sa.create(i)):(t?(this._urlSwitching&&(this._urlSwitching=!1,this.emit("switch-url-success",{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)}this.player.debug.log(this.TAG_NAME,"_loadSegmentDirect() !seg")}async _reqAndBufferSegment(e,t){this.player.debug.log(this.TAG_NAME,"video seg",e&&e.url,"audio seg",t&&t.url);var i=(e||t).cc,r=this._prevSegCc!==i;let s=[];try{s=await this._segmentLoader.load(e,t,r)}catch(e){throw e.fatal=!1,this._segmentLoader.error=e}if(s[0]){var a,n,o,l=await this._bufferService.decryptBuffer(...s);if(l)return a=(e||t).sn,n=(e||t).start,o=this._playlist.currentStream,this._bufferService.createSource(l[0],l[1],null==o?void 0:o.videoCodec,null==o?void 0:o.audioCodec),await this._bufferService.appendBuffer(e,t,l[0],l[1],r,this._prevSegSn===a-1,n),this._prevSegCc=i,this._prevSegSn=a,!0;this.player.debug.log(this.TAG_NAME,"decryptBuffer return null")}}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(){var e=0<arguments.length&&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){var t,i=1<arguments.length&&void 0!==arguments[1]&&arguments[1];return!1===(null==(t=e.originError)?void 0:t.fatal)?console.warn(e):(console.table(e),console.error(e),console.error(null==(t=this.media)?void 0:t.error),this._stopTick(),this._urlSwitching&&(this._urlSwitching=!1,this.emit("switch-url-failed",e)),i&&this._end(),this._seiService.reset(),this.emit("error",e)),e}_getSeamlessSwitchPoint(){var e,t=this["media"];let i=t.currentTime;return t.paused||(t=this._playlist.findSegmentIndexByTime(t.currentTime),t=this._playlist.getSegmentByIndex(t),e=null==(e=this._stats)?void 0:e.getStats().downloadSpeed,i+=e&&t?t.duration*this._playlist.currentStream.bitrate/e+1:5),i}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 rn extends r{constructor(e){super(),Ds(this,"TAG_NAME","Hls256Decoder"),this.player=e,this.canVideoPlay=!1,this.$videoElement=this.player.video.$videoElement,this.hls=null,this.eventsDestroy=[],this.bandwidthEstimateInterval=null,Ut()?this.canVideoPlay=!0:(this.hls=new tn(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("error",e=>{this.player.emitError(O.hlsError,e)}),this._startBandwidthEstimateInterval()}_startBandwidthEstimateInterval(){this._stopBandwidthEstimateInterval(),this.bandwidthEstimateInterval=setInterval(()=>{var e=this.hls.speedInfo();this.player.emit(U.kBps,(e.avgSpeed/1024).toFixed(2))},1e3)}_stopBandwidthEstimateInterval(){this.bandwidthEstimateInterval&&(clearInterval(this.bandwidthEstimateInterval),this.bandwidthEstimateInterval=null)}initVideoPlay(e){this.$videoElement.muted=!0,this.$videoElement.src=e}async loadSource(e){return this.player.debug.log(this.TAG_NAME,"loadSource() "+e),this.url=e,this.canVideoPlay?this.initVideoPlay(e):await this.hls.loadSource(e),!0}checkHlsBufferedDelay(){let e=0;return this.hls?this.hls.getDemuxBuferredDuration():e}getDemuxBufferedListLength(){let e=0;return this.hls?this.hls.getDemuxBufferedListLength():e}getDemuxAudioBufferedListLength(){let e=0;return this.hls?this.hls.getDemuxAudioBufferedListLength():e}getDemuxVideoBufferedListLength(){let e=0;return this.hls?this.hls.getDemuxVideoBufferedListLength():e}}class sn extends r{constructor(e){super(),this.player=e,this.rtcPeerConnection=null,this.videoStream=null,this._initRtcPeerConnection(),this.player.isWebrtcH265()&&(this.streamRate=et(t=>{e.emit(U.kBps,(t/1024).toFixed(2))})),this.player.debug.log("WebrtcDecoder","init")}destroy(){this.stopStreamRateInterval(),this.rtcPeerConnectionDataChannel&&(this.rtcPeerConnectionDataChannel.onopen=Ve,this.rtcPeerConnectionDataChannel.onclose=Ve,this.rtcPeerConnectionDataChannel.onmessage=Ve,this.rtcPeerConnectionDataChannel.close(),this.rtcPeerConnectionDataChannel=null),this.rtcPeerConnection&&(this.rtcPeerConnection.onicecandidate=Ve,this.rtcPeerConnection.ontrack=Ve,this.rtcPeerConnection.onconnectionstatechange=Ve,this.rtcPeerConnection.ondatachannel=Ve,this.rtcPeerConnection.close(),this.rtcPeerConnection=null),this.player.isWebrtcH264()&&(this.videoStream=null,this.player.video.$videoElement.srcObject=null),this.player.debug.log("WebrtcDecoder","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("WebrtcDecoder","onsignalingstatechange",e)},e.oniceconnectionstatechange=t=>{this.player.debug.log("WebrtcDecoder","oniceconnectionstatechange",e.iceConnectionState)},e.onicecandidate=e=>{this.player.debug.log("WebrtcDecoder","onicecandidate",e)},e.ontrack=e=>{this.player.debug.log("WebrtcDecoder","ontrack",e);const i=t.video.$videoElement;"video"===e.track.kind&&t.isWebrtcH264()&&(e=e.streams[0],i.srcObject=e,this.videoStream=e)},e.onconnectionstatechange=i=>{switch(t.debug.log("WebrtcDecoder","sdp connect status "+e.connectionState),e.connectionState){case"connecting":case"connected":break;case"disconnected":t.emit(U.webrtcDisconnect);break;case"failed":t.emit(U.webrtcFailed);break;case"closed":t.emit(U.webrtcClosed)}},e.ondatachannel=e=>{const t=e.channel;this.player.debug.log("WebrtcDecoder","ondatachannel"),t.onopen=()=>{this.player.debug.log("WebrtcDecoder","ondatachannel and onopen")},t.onmessage=e=>{if(e=e.data,this.player.isWebrtcH264())return this.player.debug.warn("WebrtcDecoder","ondatachannel is H265 but decode is h264 so emit webrtcStreamH265 "),void this.player.emit(U.webrtcStreamH265);this.player.isDestroyed()?this.player.debug.warn("WebrtcDecoder","ondatachannel and player is destroyed"):(this.streamRate&&this.streamRate(e.byteLength),this.player.demux&&this.player.demux.dispatch(e))},t.onclose=()=>{this.player.debug.warn("WebrtcDecoder","ondatachannel and onclose")},this.rtcPeerConnectionDataChannel=t},e.createDataChannel("signal").onmessage=e=>{this.player.debug.log("WebrtcDecoder","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){return new Promise((t,i)=>{const r=this.rtcPeerConnection;r.createOffer().then(s=>{r.setLocalDescription(s),this.player.debug.log("WebrtcDecoder","getWebRtcRemoteSdp loadSource"),s=s.sdp,fetch(e,{method:"POST",mode:"cors",cache:"no-cache",credentials:"include",redirect:"follow",referrerPolicy:"no-referrer",headers:{"Content-Type":"application/sdp"},body:s}).then(e=>{e.text().then(e=>{this.player.debug.log("WebrtcDecoder","getWebRtcRemoteSdp response"),r.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:e})),this.player.isWebrtcH265()&&this.startStreamRateInterval(),t()}).catch(e=>{this.player.debug.error("WebrtcDecoder","loadSource response.text() error",e),i(e)})}).catch(e=>{this.player.debug.error("WebrtcDecoder","loadSource getWebRtcRemoteSdp response error",e),i(e)})}).catch(e=>{this.player.debug.error("WebrtcDecoder","loadSource rtcPeerConnection.createOffer() error",e),i(e)})})}}class an extends r{constructor(e){super(),this.tagName="WebrtcForZLMDecoder",this.player=e,this.rtcPeerConnection=null,this.videoStream=null,this._initRtcPeerConnection(),this.player.debug.log(this.tagName,"init")}destroy(){this.rtcPeerConnection&&(this.rtcPeerConnection.onicecandidate=Ve,this.rtcPeerConnection.ontrack=Ve,this.rtcPeerConnection.onconnectionstatechange=Ve,this.rtcPeerConnection.ondatachannel=Ve,this.rtcPeerConnection.close(),this.rtcPeerConnection=null),this.videoStream&&(this.videoStream.getTracks().forEach(e=>e.stop()),this.videoStream=null),this.videoStream=null,this.player.video.$videoElement.srcObject=null,this.player.debug.log(this.tagName,"destroy")}_initRtcPeerConnection(){const e=new RTCPeerConnection,t=this.player;e.addTransceiver("video",{direction:"recvonly"}),e.addTransceiver("audio",{direction:"recvonly"}),e.onsignalingstatechange=e=>{this.player.debug.log(this.tagName,"onsignalingstatechange",e)},e.oniceconnectionstatechange=t=>{this.player.debug.log(this.tagName,"oniceconnectionstatechange",e.iceConnectionState),this.player.emit(U.webrtcOnIceConnectionStateChange,e.iceConnectionState),e.iceConnectionState},e.onicecandidate=e=>{this.player.debug.log(this.tagName,"onicecandidate",e),e.candidate&&this.player.debug.log(this.tagName,"Remote ICE candidate: ",e.candidate.candidate)},e.ontrack=e=>{const i=t.video.$videoElement;this.player.debug.log(this.tagName,"ontrack",e),"video"===e.track.kind&&(this.player.debug.log(this.tagName,"ontrack video"),e=e.streams[0],i.srcObject=e,this.videoStream=e)},e.onicecandidateerror=e=>{this.player.debug.log(this.tagName,"onicecandidateerror",e),this.player.emitError(O.webrtcIceCandidateError,e)},e.onconnectionstatechange=t=>{this.player.debug.log(this.tagName,"onconnectionstatechange",t),this.player.emit(U.webrtcOnConnectionStateChange,e.connectionState),e.connectionState},this.rtcPeerConnection=e}loadSource(e){return new Promise((t,i)=>{const r=this.rtcPeerConnection;r.createOffer().then(s=>{r.setLocalDescription(s),this.player.debug.log(this.tagName,"getWebRtcRemoteSdp loadSource"),s=s.sdp,Cr({url:e,type:"POST",data:s,contentType:"text/plain;charset=utf-8",processData:!1,dataType:"json"}).then(e=>{if(this.player.debug.log(this.tagName,"getWebRtcRemoteSdp response and code is "+e.code),0!==e.code)return i(e.msg);r.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:e.sdp})),t()}).catch(e=>{this.player.debug.error(this.tagName,"loadSource getWebRtcRemoteSdp response error",e),i(e)})}).catch(e=>{this.player.debug.error(this.tagName,"loadSource rtcPeerConnection.createOffer() error",e),i(e)})})}}class nn extends r{constructor(e,t){super(),this.player=e,this.player.$container.classList.add("jessibuca-container-playback"),this._showPrecision=null,this._startTime=null,this._playStartTime=null,this._playingTimestamp=null,this._fps=parseInt(t.fps,10)||e._opt.playbackFps,this._isUseFpsRender=!!Kt(t.isUseFpsRender),this._rate=1,this._audioTimestamp=0,this._videoTimestamp=0,this._currentLocalTimestamp=0,this._localOneFrameTimestamp=t.localOneFrameTimestamp||40,this._localCalculateTimeInterval=null,this._isUseLocalCalculateTime=!!Kt(t.isUseLocalCalculateTime),this._isPlaybackPauseClearCache=!$t(t.isPlaybackPauseClearCache),this._isCacheBeforeDecodeForFpsRender=!!Kt(t.isCacheBeforeDecodeForFpsRender),this._startfpsTime=null,this._startFpsTimestamp=null,this._checkStatsInterval=null,this._playbackTs=0,this._renderFps=0,this._isUseLocalCalculateTime?this._startLocalCalculateTime():this._listen(),this.playbackList=[],this._totalDuration=0,this.initPlaybackList(t.playList),this.player.on(U.playbackPause,e=>{e?this.pause():this.resume()}),t={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(t))}destroy(){this._startTime=null,this._showPrecision=null,this._playStartTime=null,this._playingTimestamp=null,this._totalDuration=0,this._audioTimestamp=0,this._videoTimestamp=0,this._fps=null,this._isUseFpsRender=!1,this._rate=1,this.playbackList=[],this._localCalculateTimeInterval=null,this._currentLocalTimestamp=0,this._startfpsTime=null,this._startFpsTimestamp=null,this._renderFps=0,this._playbackTs=0,this._stopLocalCalculateTime(),this.clearStatsInterval(),this.player.$container&&this.player.$container.classList.remove("jessibuca-container-playback"),this.off(),this.player.debug.log("Playback","destroy")}_listen(){this.player.on(U.stats,e=>{e=e.ts,this._playStartTime||(this._playStartTime=e),e-=this._playStartTime,this.setPlayingTimestamp(e)})}pause(){this.clearStatsInterval()}resume(){this.startCheckStatsInterval()}updateStats(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t=(e=(this._startFpsTimestamp||(this._startFpsTimestamp=qe()),_t(e.ts)&&(this.player.updateStats({fps:!0,ts:e.ts}),this._playbackTs=e.ts,this._startfpsTime||(this._startfpsTime=e.ts),this._renderFps+=1),qe()),e-this._startFpsTimestamp);if(!(t<1e3)){let i=null;this._startfpsTime&&(i=this._playbackTs-this._startfpsTime),this.player.emit(U.playbackStats,{fps:this._renderFps,rate:this.rate,start:this._startfpsTime,end:this._playbackTs,timestamp:t,dataTimestamp:i,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=e}}updateLocalOneFrameTimestamp(e){this._localOneFrameTimestamp=e}_startLocalCalculateTime(){this._stopLocalCalculateTime(),this._localCalculateTimeInterval=setInterval(()=>{var e=this._currentLocalTimestamp;this._playStartTime||(this._playStartTime=e),e-=this._playStartTime;this.setPlayingTimestamp(e)},1e3)}startCheckStatsInterval(){this.clearStatsInterval(),this._checkStatsInterval=setInterval(()=>{this.updateStats()},1e3)}_stopLocalCalculateTime(){this._localCalculateTimeInterval&&(clearInterval(this._localCalculateTimeInterval),this._localCalculateTimeInterval=null)}clearStatsInterval(){this._checkStatsInterval&&(clearInterval(this._checkStatsInterval),this._checkStatsInterval=null)}increaseLocalTimestamp(){this._isUseLocalCalculateTime&&(this._currentLocalTimestamp+=this._localOneFrameTimestamp)}initPlaybackList(e){this.playbackList=e||[];let t=0;this.playbackList.forEach((e,i)=>{10===Ct(e.start)&&(e.startTimestamp=1e3*e.start,e.startTime=lt(e.startTimestamp)),10===Ct(e.end)&&(e.endTimestamp=1e3*e.end,e.endTime=lt(e.endTimestamp)),e.duration=e.end-e.start,t+=e.duration}),this._totalDuration=t,this.player.debug.log("Playback",this.playbackList),0<this.playbackList.length&&this.setStartTime(this.playbackList[0].startTimestamp),this.setShowPrecision(ie)}get startTime(){return this._startTime||0}setStartTime(e){this._startTime=e,this._playStartTime=null}setRate(e){this._rate=e,this.player.emit(U.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===ie}get is30Min(){return this.showPrecision===re}get is10Min(){return"tenMin"===this.showPrecision}get is5Min(){return this.showPrecision===se}get is1Min(){return this.showPrecision===se}get isPlaybackPauseClearCache(){return this._isPlaybackPauseClearCache}get isCacheBeforeDecodeForFpsRender(){return this._isCacheBeforeDecodeForFpsRender}setShowPrecision(e){this._showPrecision&&this._showPrecision===e||(this._showPrecision=e,this.player.emit(U.playbackPrecision,this._showPrecision,this.playbackList))}setPlayingTimestamp(e){e=this.startTime+e,this._playingTimestamp=e,this.player.emit(U.playbackTime,e);const t=new Date(e);this.player.emit(U.playbackTimestamp,{ts:e,hour:t.getHours(),min:t.getMinutes(),second:t.getSeconds()})}get playingTimestamp(){return this._playingTimestamp}narrowPrecision(){var e=ne.indexOf(this.showPrecision)-1;0<=e&&(e=ne[e],this.setShowPrecision(e))}expandPrecision(){var e=ne.indexOf(this.showPrecision)+1;e<=ne.length-1&&(e=ne[e],this.setShowPrecision(e))}seek(e){if(console.log(e),"true"===e.hasRecord){let t=e.time;"min"===e.type&&(t=60*e.time),this.player.emit(U.playbackSeek,function(e){let t={};return-1<e?{hour:Math.floor(e/60/60)%60,min:Math.floor(e/60)%60,second:e%60}:t}(t))}}}class on extends r{constructor(e){super(),this.player=e,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};const{proxy:t}=this.player["events"];this.player.on(U.zooming,e=>{if(e){this.player.$container.classList.add("jessibuca-zoom-control"),this._bindEvents();const e=this.player.video.$videoElement.style.transform;var t=this.player.video.$videoElement.style.left,i=this.player.video.$videoElement.style.top;t=parseFloat(t),i=parseFloat(i);t&&(this.videoPosition.left=t),i&&(this.videoPosition.top=i);let r=(this.prevVideoElementStyleTransform=e).match(/scale\([0-9., ]*\)/g);if(r&&r[0]){let e=r[0].replace("scale(","").replace(")","");this.prevVideoElementStyleScale=e.split(",")}}else this.player.$container.classList.remove("jessibuca-zoom-control"),this._unbindEvents(),this._resetVideoPosition(),this.player.$container.style.cursor="auto",this.player.video.$videoElement.style.transform=this.prevVideoElementStyleTransform,this.prevVideoElementStyleTransform=null,this.prevVideoElementStyleScale=null}),t(window,"mouseup",e=>{this.handleMouseUp(e)}),e.debug.log("zoom","init")}destroy(){this.bindEvents=[],this.isDragging=!1,this.currentZoom=1,this.prevVideoElementStyleTransform=null,this.prevVideoElementStyleScale=null,this.tempPosition={x:0,y:0},this.videoPosition={left:0,top:0},this.off(),this.player.debug.log("zoom","destroy")}_bindEvents(){const{proxy:e}=this.player["events"],t=e(this.player.$container,"mousemove",e=>{this.handleMouseMove(e)});this.bindEvents.push(t);var i=e(this.player.$container,"mousedown",e=>{this.handleMouseDown(e)});this.bindEvents.push(i)}_unbindEvents(){this.bindEvents.forEach(e=>{e&&e()})}handleMouseMove(e){var t,i,r;e.stopPropagation(),this.isDragging&&this.player.zooming&&(({posX:e,posY:t}=Bt(e)),i=this.tempPosition.x-e,r=this.tempPosition.y-t,this.videoPosition.left=this.videoPosition.left-i,this.videoPosition.top=this.videoPosition.top-r,this.tempPosition.x=e,this.tempPosition.y=t,this.updateVideoPosition())}handleMouseDown(e){e.stopPropagation();const t=It(e);if(this.player.zooming&&(t.matches("video")||t.matches("canvas"))){const{posX:t,posY:i}=Bt(e);this.player.$container.style.cursor="grabbing",this.tempPosition.x=t,this.tempPosition.y=i,this.isDragging=!0,this.player.debug.log("zoom","handleMouseDown is dragging true")}}handleMouseUp(e){e.stopPropagation(),this.isDragging&&this.player.zooming&&(this.tempPosition={x:0,y:0},this.isDragging=!1,this.player.$container.style.cursor="grab",this.player.debug.log("zoom","handleMouseUp is dragging false"))}updateVideoPosition(){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}narrowPrecision(){this.currentZoom<=1||(--this.currentZoom,this.updateVideoElementScale())}expandPrecision(){5<=this.currentZoom||(this.currentZoom+=1,this.updateVideoElementScale())}updateVideoElementScale(){const e=this.player.video.$videoElement;let t=e.style.transform,i=1,r=1;if(this.prevVideoElementStyleScale){const e=this.prevVideoElementStyleScale[0],t=(void 0!==e&&(i=e,r=e),this.prevVideoElementStyleScale[1]);void 0!==t&&(r=t)}r=ht(r);var s=.5*(i=ht(i))*(this.currentZoom-1)+i,a=.5*r*(this.currentZoom-1)+r,n=-1===t.indexOf("scale(")?t+` scale(${s},${a})`:t.replace(/scale\([0-9., ]*\)/,`scale(${s},${a})`);this.player.debug.log("zoom",`updateVideoElementScale end is ${s}, ${a} style is `+n),e.style.transform=n}}class ln extends r{constructor(e){super(),this.player=e,this.faceDetector=null,this.objectDetector=null,this.initFaceDetector(),this.initObjectDetector(),this.player.debug.log("AiLoader","init")}initFaceDetector(){if(this.player._opt.useFaceDetector&&window.JessibucaProFaceDetector){const e=new JessibucaProFaceDetector({detectWidth:this.player._opt.aiFaceDetectWidth});e.load().then(()=>{this.player.debug.log("AiLoader","init face detector success"),this.faceDetector=e})}}initObjectDetector(){if(this.player._opt.useObjectDetector&&window.JessibucaProObjectDetector){const e=new JessibucaProObjectDetector({detectWidth:this.player._opt.aiObjectDetectWidth});e.load().then(()=>{this.player.debug.log("AiLoader","init object detector success"),this.objectDetector=e,this.objectDetector.on("jessibuca-pro-object-detector-info",e=>{e&&0<e.length&&this.player.emit(U.aiObjectDetectorInfo,e)})})}}destroy(){this.faceDetector&&(this.faceDetector.destroy(),this.faceDetector=null),this.objectDetector&&(this.objectDetector.destroy(),this.objectDetector=null),this.off()}}class dn extends r{constructor(e){super(),this.player=e,this.LOG_NAME="Contextmenu",this.menuList=[],this.$contextmenus=e.control.$contextmenus,it()?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 this.player.$container.classList.contains("jessibuca-contextmenus-show")}show(){this.player.$container.classList.add("jessibuca-contextmenus-show")}hide(){this.player.$container.classList.remove("jessibuca-contextmenus-show")}init(){const{proxy:e}=this.player["events"];0<this.player._opt.contextmenuBtns.length&&this.player._opt.contextmenuBtns.forEach(e=>{this.addMenuItem(e)}),e(this.player.$container,"contextmenu",e=>{e.preventDefault(),this.show();var t=e.clientX,{height:i,width:r,left:s,top:a}=(e=e.clientY,this.player.$container.getBoundingClientRect()),{height:n,width:o}=this.$contextmenus.getBoundingClientRect();let l=t-s,d=e-a;s+r<t+o&&(l=r-o),a+i<e+n&&(d=i-n),Qe(this.$contextmenus,{left:l+"px",top:d+"px"})}),e(this.player.$container,"click",e=>{Js(e,this.$contextmenus)||this.hide()}),this.player.on(U.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=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};var t=Gt(Le);if(e=Object.assign({},t,e),this._validateMenuItem(e)){const i=this.player["events"]["proxy"],r=ct(),s=`\n <div class="jessibuca-contextmenu jessibuca-contextmenu-${r}">\n ${e.content}\n </div>\n `,a=Array.from(this.$contextmenus.children)[e.index];a?a.insertAdjacentHTML("beforebegin",s):Ys(this.$contextmenus,s),t=this.$contextmenus.querySelector(".jessibuca-contextmenu-"+r),e.click&&i(t,"click",t=>{t.preventDefault(),e.click.call(this.player,this,t),this.hide()}),this.menuList.push({uuid:r,$menuItem:t})}}}class hn extends r{constructor(e){let t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};super(),this._opt={},this.$container=e;var i;e=Wt();if(this._opt=Object.assign({},e,t),this.debug=new Fe(this),this._opt.forceNoOffscreen=!0,it()&&(this._opt.controlAutoHide=!1),this.isPlayback()&&(this._opt.useMSE=!1),this._opt.watermarkConfig={image:{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAS4AAABgCAYAAACjZZ/rAAAK4mlDQ1BJQ0MgUHJvZmlsZQAASImVlwdUU1kagO976SEhkIQISAm9SW8BpIQeivQqKiEJJJQQE4KCDZXBERwVRESwDOCoiIKjIyBjQSxYUWzYB2RQUNbBgg2VfcASZmbP7p7937nvfufPf/9yz705/wOAHMKVSDJhFQCyxDnSyABvZnxCIhP3DOAAA9CBA7Dm8mQSdnh4CEBkev6rvL8LoIn5luWEr3///b8KlS+Q8QCAkhBO4ct4WQi3I2OEJ5HmAIA6jOgNluRIJvg2wnQpkiDCgxOcNsVfJjhlktEqkzbRkT4IGwKAJ3G50jQASDaInpnLS0P8kMIRthHzRWKECxD24Am5fISRuGBOVlb2BA8jbIrYSwAg0xFmpfzJZ9pf/Kco/HO5aQqeqmtS8L4imSSTm/d/bs3/lqxM+XQMY2SQhNLASGRWR/bvXkZ2sILFKfPCplnEn7SfZKE8MGaaeTKfxGnmc32DFWsz54VMc6rIn6Pwk8OJnmaBzC9qmqXZkYpYqVIf9jRzpTNx5RkxCr1QwFH4zxdGx01zrih23jTLMqKCZ2x8FHqpPFKRv0Ac4D0T119Re5bsT/WKOIq1OcLoQEXt3Jn8BWL2jE9ZvCI3vsDXb8YmRmEvyfFWxJJkhivsBZkBCr0sN0qxNgc5nDNrwxV7mM4NCp9m4Av8QAjyMEEMsAPOwBawQAQIzREszZkoxidbkicVpQlzmGzkxgmYHDHPag7TzsbODoCJ+zt1JN5GTt5LiHFqRpe9BznK75E7UzqjSykHoKUICf1gRme4CwBKIQDNHTy5NHdKh554YQARUJB/Bg2gAwyAKbBE8nMCbsALyTgIhIFokAAWAh4QgiwgBUvAcrAaFIESsBlsBVVgN6gD+8EhcAS0gBPgDLgAroAb4A54CHrBAHgJRsB7MAZBEA4iQzRIA9KFjCALyA5iQR6QHxQCRUIJUDKUBokhObQcWguVQGVQFVQD1UM/Q8ehM9AlqBu6D/VBQ9Ab6DOMgkkwHdaGjWFrmAWz4WA4Gl4Ap8GL4Xy4EN4IV8K18EG4GT4DX4HvwL3wS3gUBVBKKAZKD2WJYqF8UGGoRFQqSopaiSpGVaBqUY2oNlQn6haqFzWM+oTGomloJtoS7YYORMegeejF6JXoDegq9H50M/oc+ha6Dz2C/oYhY7QwFhhXDAcTj0nDLMEUYSowezHHMOcxdzADmPdYLJaBNcE6YwOxCdh07DLsBuxObBO2HduN7ceO4nA4DZwFzh0XhuPicnBFuO24g7jTuJu4AdxHvBJeF2+H98cn4sX4NfgK/AH8KfxN/HP8GEGFYERwJYQR+IQ8wibCHkIb4TphgDBGVCWaEN2J0cR04mpiJbGReJ74iPhWSUlJX8lFKUJJpFSgVKl0WOmiUp/SJxKVZE7yISWR5KSNpH2kdtJ90lsymWxM9iInknPIG8n15LPkJ+SPyjRlK2WOMl95lXK1crPyTeVXFALFiMKmLKTkUyooRynXKcMqBBVjFR8VrspKlWqV4yo9KqOqNFVb1TDVLNUNqgdUL6kOUnFUY6oflU8tpNZRz1L7aSiaAc2HxqOtpe2hnacN0LF0EzqHnk4voR+id9FH1KhqDmqxakvVqtVOqvUyUAxjBoeRydjEOMK4y/g8S3sWe5Zg1vpZjbNuzvqgPlvdS12gXqzepH5H/bMGU8NPI0OjVKNF47EmWtNcM0JzieYuzfOaw7Pps91m82YXzz4y+4EWrGWuFam1TKtO66rWqLaOdoC2RHu79lntYR2GjpdOuk65zimdIV2aroeuSLdc97TuC6Yak83MZFYyzzFH9LT0AvXkejV6XXpj+ib6Mfpr9Jv0HxsQDVgGqQblBh0GI4a6hqGGyw0bDB8YEYxYRkKjbUadRh+MTYzjjNcZtxgPmqibcEzyTRpMHpmSTT1NF5vWmt42w5qxzDLMdprdMIfNHc2F5tXm1y1gCycLkcVOi+45mDkuc8Rzauf0WJIs2Za5lg2WfVYMqxCrNVYtVq+sDa0TrUutO62/2TjaZNrssXloS7UNsl1j22b7xs7cjmdXbXfbnmzvb7/KvtX+tYOFg8Bhl8M9R5pjqOM6xw7Hr07OTlKnRqchZ0PnZOcdzj0sOiuctYF10QXj4u2yyuWEyydXJ9cc1yOuf7hZumW4HXAbnGsyVzB3z9x+d313rnuNe68H0yPZ40ePXk89T65nredTLwMvvtder+dsM3Y6+yD7lbeNt9T7mPcHH1efFT7tvijfAN9i3y4/ql+MX5XfE399/zT/Bv+RAMeAZQHtgZjA4MDSwB6ONofHqeeMBDkHrQg6F0wKjgquCn4aYh4iDWkLhUODQreEPppnNE88ryUMhHHCtoQ9DjcJXxz+awQ2IjyiOuJZpG3k8sjOKFrUoqgDUe+jvaM3RT+MMY2Rx3TEUmKTYutjP8T5xpXF9cZbx6+Iv5KgmSBKaE3EJcYm7k0cne83f+v8gSTHpKKkuwtMFixdcGmh5sLMhScXURZxFx1NxiTHJR9I/sIN49ZyR1M4KTtSRng+vG28l3wvfjl/SOAuKBM8T3VPLUsdTHNP25I2JPQUVgiHRT6iKtHr9MD03ekfMsIy9mWMZ8ZlNmXhs5Kzjoup4gzxuWyd7KXZ3RILSZGkd7Hr4q2LR6TB0r0ySLZA1ppDRxqlq3JT+XfyvlyP3Orcj0tilxxdqrpUvPRqnnne+rzn+f75Py1DL+Mt61iut3z18r4V7BU1K6GVKSs7VhmsKlw1UBBQsH81cXXG6mtrbNaUrXm3Nm5tW6F2YUFh/3cB3zUUKRdJi3rWua3b/T36e9H3Xevt129f/62YX3y5xKakouTLBt6Gyz/Y/lD5w/jG1I1dm5w27dqM3SzefLfUs3R/mWpZfln/ltAtzeXM8uLyd1sXbb1U4VCxextxm3xbb2VIZet2w+2bt3+pElbdqfaubtqhtWP9jg87+Ttv7vLa1bhbe3fJ7s8/in68VxNQ01xrXFtRh63LrXu2J3ZP50+sn+r3au4t2ft1n3hf7/7I/efqnevrD2gd2NQAN8gbhg4mHbxxyPdQa6NlY00To6nkMDgsP/zi5+Sf7x4JPtJxlHW08RejX3Ycox0rboaa85pHWoQtva0Jrd3Hg453tLm1HfvV6td9J/ROVJ9UO7npFPFU4anx0/mnR9sl7cNn0s70dyzqeHg2/uztcxHnus4Hn794wf/C2U525+mL7hdPXHK9dPwy63LLFacrzVcdrx675njtWJdTV/N15+utN1xutHXP7T510/PmmVu+ty7c5ty+cmfene67MXfv9ST19N7j3xu8n3n/9YPcB2MPCx5hHhU/Vnlc8UTrSe1vZr819Tr1nuzz7bv6NOrpw35e/8vfZb9/GSh8Rn5W8Vz3ef2g3eCJIf+hGy/mvxh4KXk5Nlz0D9V/7Hhl+uqXP7z+uDoSPzLwWvp6/M2Gtxpv971zeNcxGj765H3W+7EPxR81Pu7/xPrU+Tnu8/OxJV9wXyq/mn1t+xb87dF41vi4hCvlTrYCKGTAqakAvNmH9McJANBuAECcP9VfTwo09U0wSeA/8VQPPilOANT1ABC9DICQawBsr0JaWsQ/BfkuCKcgejcA29srxr9ElmpvN+WL5Im0Jo/Hx9+aAoArBeBr6fj4WN34+Nc6JNmHALTnTfX1E6JyEIAacxtH+5D7VPMC8DeZ6vn/VOPfZzCRgQP4+/xPeFgcU9phDh8AAABsZVhJZk1NACoAAAAIAAQBGgAFAAAAAQAAAD4BGwAFAAAAAQAAAEYBKAADAAAAAQACAACHaQAEAAAAAQAAAE4AAAAAAAAAkAAAAAEAAACQAAAAAQACoAIABAAAAAEAAAEuoAMABAAAAAEAAABgAAAAADApncsAAAAJcEhZcwAAFiUAABYlAUlSJPAAAB1BSURBVHgB7V0HeBTVFj6b3fRCAgSQ3qSKIuoDRESx8OzloaIIiqhYUIEHiIJIU6QpVkRRwMaTp4INBBsoRZQiIFhACL1DQtpusuWdf8IsM7Ozu0nYDQzvnO/bzMyd2+a/N/+ce+65d2w+FhIRBAQBQcBCCMRYqK5SVUFAEBAEFASEuKQjCAKCgOUQEOKyXJNJhQUBQUCIS/qAICAIWA4BIS7LNZlUWBAQBIS4pA8IAoKA5RAQ4rJck0mFBQFBQIhL+oAgIAhYDgEhLss1mVRYEBAEhLikDwgCgoDlEBDislyTSYUFAUFAiEv6gCAgCFgOASEuyzWZVFgQEASEuKQPCAKCgOUQEOKyXJNJhQUBQUCIS/qAICAIWA4BIS7LNZlUWBAQBIS4pA8IAoKA5RAQ4rJck0mFBQFBQIhL+oAgIAhYDgEhLss1mVRYEBAEhLikDwgCgoDlEBDislyTSYUFAUFAiEv6gCAgCFgOASEuyzWZVFgQEASEuKQPCAKCgOUQEOKyXJNJhQUBQcBxqkDgK8gmT+5+Ik8RuTYvJtefC6l430YiO9fQxj+mWHvluhTX4GJKaNKFYhLSKSaRf8nV+L7w76nSjlIPQaAiELD5WCqioGBlFGetJOfGb8nNJFW07RciX3EJUamEpR7BTfgdIzGcO6o1pbja7Siu1gUU37BLsCIkXBAQBE4zBE4qcR2adDV5cnYxVxWUkJKWnFTCUo/ae+r5saMtLoHsabUordMzFFvjvNOsieRxBAFBwIhAhROXz5VPBd+/SfmLppHP42LC8lGMzcOjPS/5mIhsdi+H8bmdL2LwYyUsxkY+W2yJtqXRuBQNjO9rNbHElt0piX+O9DONzyrX/0cIbNuxm5yuImrcoA7Z7Xj7iZxOCFQocRVvX0f5C14h18bvFdtVrLeQSctNNlsx2RwgK4bWwSNXPvrY+uaz8zkfvUxiIC6fL5a8nqQSolIJSz1qCM2eXo/SLhxJcTU7nE5tJc9SCgQKCp3Ub9hztHzlWiV2g7q16OWxQ6le7TN0qQ8dyaZNW7bpwtIrpVGzxg10YXJxaiJQYcTlWruQjr4/mLxF+WRnO1a8O5e1K59CVipBBSMukBgnUjQyctjI40xnEovTE5iGuFRNLLXdcEpqdicnxk1ryr4Dh2jjn3/rKp+YGE/tzjtHFyYXJQhMmjKTZvxnrg6O885pSTNeGqMLm//tEho8apIu7KK2bWjK+Kd0YXJxaiIASoi6OFfNY9J6nMhdSHFuF8V62KYFzapc4iN78mHyulOYBJM5h+CklLvqObaf5VByy/uZ5JjoLCi/rPmNnnhmsq7mdWrWoHmzpujC5KIEgdXreCbaIGs3/MEvOh9r9sH7iiGJXJ7iCGCgFVVxrf2ajr43hMhVQPGF+RTHx0iILSGPbMk5nFUIAmTXivyNb5Nrz5JIFCl5WACB2mdUD6hlzerVhLQCULF2QFSJy5t7iPK/eZt8RYUU73KSw10UHi28FRPSKCa1JtmrNKH4s3tRUscxFN+sO9krNWK/rZqsrSUq+djinGRLyg2Zp68ol7IX9yFPwb6Q8eTm6YHAQ/fcThlsq1IlNtZBg/r2Ui/leJogENWhYt6ciVS8eSVrWYUUW+xSDO6hcLMlVaa49veQo3FnctRtx1FNVHufh1xbPqaiXQvIuX022RLz2XDP1nwnho3B5ch3d1LGJdPInlIveCS5Y3kEYISfM/NFgg3LxbOKl3S4gBrVr2P555IH0CMQNeJy78uiwmUfM2k5FW1L8YDXl627sjfqRAk3jCM7O5WGFCap+Ea3Uly9aym+8W2Us+QORevyFUELC65AevK2k2vvckpqLMQVEt/T4GaVjHS6s+u1p8GTyCMEQyD4f3qwFKUI97F2dWRsV7J5veQoYk/4MGKvfS4l3zc3PGlp8rE5ktjd4UpKa/8G2eIqkS0t21RB8yfxeSl39Qj2HSv0B8mJICAIWBOBqGhczhWfk4+N8Ha3mxzF7pBDxNhzb6aEnm+WG734OjdTWoydcpb3YNsX29A8IWYPeZiZt34SpbYeVu7yrJgwNy+fdu7ZR3v2HqD8wkKqnlmFzqieSbVqVGMf3/K/u5xOF/35dxYdPpJD2UdzKSU5iapkVKKGPDRLT0stF1TRyLNcFTmWyOv10a69+2jrtl38fIlUu2Z1yqxS+ZQ29hcVF9PuPftp74GDtO/AYUpMiKeqVTKobq0zqGrl9HLDgZnZv7N2cL6H6Eh2DhtybFSZ27ta1crKcLwiZ20jTlw+1mzcO34nn7uY7EXukCDFZDaiuC7sJmFmywqZUn8zvtYNlNZ2KuUsGsTEpb9nvCrY9M7/BXGhky395Vea9cmXtGTFasI/oFHQ4bped6Xyy+SOXVpZ+vMaev/jL+nn1evIZaJRx/BKh3NaNqV/XXMFXdflUiZHE1ulobBI5Tn70wU04bXputxv/GdnGtqfXWLKIAcPZ9Pz7BO2cPEyxVamTVqtahXqeet1Cm7JSSUTRdr76vnAERNp8fKV6qVyHDnoIbr68ot1YcaLT7/6nsa8MFUXfPnF7Wjs0H66MOPF739toY++WEhffv0D5RcEjixALGiXa6/sRF2vvaLUKwqwCmHa+5/QDz+tVF5SxnJxDUK8pMM/6L4eXakmvxSjLREnLu/BXeRa841S74RCNsiHWG1hb345xVSPzNIcR/q55Khcm9x7DoXBzEcuNuzH1zp9F2VDw8I/zTImrlCy/+Bhem36f2j6rLk0dthjdFlHTIgEF/wzPDFmMn2/9OfgkfgOSHLN+j+U3wdz5tGLY4ZQjWpVTdNEOk+3x03Q2rQCDaQsMu+bH2j081MpL9/cdWf/wUM08bUZCnm/OWkE1avDM90mgnKNdXF7wrxZOR83j1SM6YpMXhBqkR7OE/V576Mv1CDTI15mv/72h/L7+POv6ZknH6UzGwa3+SL+5Knv0szZnxHKCCUg+o8+X0hffL2YBjxwF91+01Whop/wvfKPE4IU7XPmk+fwbnavCnzDG5PEXTvUGFTua0dqM3LUaFmq9M6d80oVz4qRdu87QN0ffDwsaWmfrdDppP5PjVcITBuuPcc/0oODR4UlLW0anMPrv9djwwgd2yjRyNNYRlmvUd+nnnslKGlp89vDWPfo+wRt3rpdG1yh52i7ewc8HZa0jJX6fdMWuvvRYbRl207jLf/10GdfordnzQlLWv4EfII2fXbyGzRn3rfa4IifR5y4irPWK5W0u0MztK1SDbIlpET0gRJq3liq/HxerhsPaU83gaYzZPTztHX7roBHgy0Lw4TrrrzEVJVX3q5vvENmnufIDENDaFFGObdVM+rT8xYa9XhfuvWGLooNyBhn5+59/OZ+xxgclTwDCilDAJZXDXh6Amk1NIfDTkmJCUFzOZJ9lIaPe0XxzA8aKYo3oGmt/HWDaQkYsrVt04qan9nQ9BmO5ubRg4NGBWh3yOyr75bQ5wsXmeabkZ5Gl/KwsGO786iWicMvEo1hjRW2z2hJxIeKzqVzlLrGeEITQ8Jdr0f8meKqdipVnl7nAfK6DvFmhNEfi5eqQhGK9P7HX5iSC1T3rtddQakpx33dtu3cw8O+F2j975v8pYP4ho19mT6ZPpkS2KCrlZkffqq9VM773d+Dene/2R9+09WXKeewVz02dKzO/oV/gn59euqMw9HI01+ZcpxoF11f0am9Yq9p2qi+MoFx4NAR+viLr9nW83GAzQsYQsO4+ZrLy1Fq+ZMAZ9j0jAIj/MjBD9P5rY+PQGCLfO+/n9Or02dRMU+YqQINfdac+dTrdv1Lf8qMD9Uo/iPyGzHwId3QGC+8+Uxyw8a+pMsX5D/7swX0wF23+tNH8iTiGlfR5jVK/Xj1dsh62ng300iLLfa4x3SovD1528hbwMPZ00jcrOFOfWd2wBPdc/tNSqfUkhYiwVHzpWefVGYXtYl27N5L3/64QhtEsIUdyTmqC8Nb9+5uN+jC1IsO/ziXut10tXqpHEGK6zb86Q+LRp7+zE/wpHPHtvT8qMGKpqLOumLyAv+ETw14wDR3aKQVLW+xwdwo8XGxSt21pIU4CMdL5ul/P2hMEjDMhA3POITETPSkEYN0pIWMYPC/+rKOdH+PWwLyXbP+94CwSAVEXOMiNo7C2dQTbg8kdmE4WQJty+M6gh1zThv5iWf4co7m6Z4HuyL069NDF6a9wEzQ+OEDqMfDT2iDlWHCNVccn/mCsd8oCfHxIWelHul9R4ATaFrqcdNANPI01rE81yD0Z554NGjSG/55KWu1vyvalzbSX+wWsnf/waCTENq4kTiHzXDVug0BWQ3u25uaNq4fEK4G3HBVZ8KEiXbHERDVLnaXUYd9aSkpitatpsERbg/4BRO8rF59e5bu9q69+3XXkbyI2v+u1xFGmeMF0CKRQ2DBd0sDMmt//jlh/Y3ObsHrQfltrHVrWPrLGmU4FB9f4hPXoG5tZZipJRsYpqfOnE19ggwFkDbYTCIqGo08AwAoR0D/B3oq/mihkg55pDfNnf9dgNH6x59W0S3XV8xs9XesFUOL1QrWaMLOGE7688sMu45oRTt8hJkg1GyjNp16Dtcao+Tlmc/KGuOV5zpqxOUL49joO/A3UbVG5amzpDFBQGufUW9XYY0KQ7JwUomdRbXx0In38VsYthII/LBghP9h+SpdVq/wG/YLdh3AUAFvXBiBsai5NBKNPEtTbrg4zZuE75P4x67PLhBwxtQK7IYVJVk7Aidg4PhbGsFebpHaz83Lq2NymaCgsVWklK6XlaFGtvgEdj51Kim8TF687Z9p6sKZD1PK+OOGYdNIUQq0J9XkLwRVj1LuJydbGI+NMnLCa8agUl8f5PxU4kKi3nfczG/pDYTpd61k8QwmfMHwi4uNpeZNGlLrs5oRtL3zW5+laHPa+NrzaOSpzb+s5/D8L63zZOMGdQOICzOMFSUHDwe2d+NSEldZ64jZ1kXLfqE/N2cpBIVrkFVePm/DzjvOngyJOHHFt76MnCtLDJXO5ARKLAi0jygPmn+IvHk8s5dSpcKf255Sl0Bep4tgyICtiCMpRr+rNme3oNcnPMW+XKODdlbMJK1lAzx+mDGEVzlm2u7t/i9T+0g08jwRDJqEcMY05ouh1ILv9cPzwxFuA2OZ2muzF1Wkd8GAFj/+len006q12qJPifMwhqiy1zGxY1d/IuwVD60rmLhm3hfsVlTDbXEZvCFqcENjVAuPSua8rXWE/dLMPLxBNLOmTqDu/7pGt+dVsEeCV/y7PAUP4z+m3c0kGnmalVOaMFuIvmpMb7YuT29xMqaI7HWMybdEuRdErBD4cXXtPeCUJC08ZMQ1rpi0qn7wPA4HudlIG1tsrk569/5F3m0rKabe+f40FXFi1ukqotxolYEp+8rplQK808fxjKF2U72ylB/MONuwXm0a8ui9NPChXgRjNNbiQcPasm1HgLFYLW/7rj10V98n6d1Xx5oa7KORp1p2WY5mdsJg6Tdv3RZwC21QUWK2WNpocytvXTb8uVnZLhz2K63AGfcCHv5Ds8N6zdTUZEpj30C42hTw4v1+w8Zpo0f1POLEZUvJ4E0AW/BC641KxV1syAxGXL4c/oTU7AGUNHARO4QE18zCIVC46UNKPPO2cNFO+n34WsFhTyvhjNlGmxLSqrN92nyqVs4IIC6QFmxN0RB04ksv+ofyQ/5Y17du419swF9J8775McDvC64CXy9eTj1uuS5odaKRZ9DCTG7AkxyuAfinDCebtmwPiBLKXUCNXGhYR6mGa4+wL4YT7PZglL+zdhqDynX9xrsf8XpJvW0as88TRwwM8PtTC4DdqyKl/GwRpJb2jOq8zXJ7/13MLuamp8NTzR+mPfHs/o2ODqrC2zuXferUx9vU5K8ZzYurW2mzLMW5eV1KkfCEolx9x4PU5vJbdD/1M1rBMsZyGaOY7eRQnz/DZRSsR6sogWH7wgtaK9rYlx+8xt8zDHQwXrW25GVW2jpFI89wZf+xKStcFMV1xGxWTzuZgUxiecRhFLiRhJOsneGdo/HZNaNsMcxyGu+r1/DhwioA7U9br+W/BNq04O+HrZCCSUWv14w4ceHB4pq3I1usZn0Xk1ZBcjJvsRy8uIIpXaj41w+D4RIQ7snfRQVrx1LeL7wdcxmX7sSwjetkSKvmZwYUiy1nQskqk6/WmPnMYImKUcw6oDEOrjGVjc6MIcJvf2xWlgFp/XqghYBAtT/tej5jnhg6GJeQIM4fm7f6o0YjT3/mJ3DyAq+pNNNytVlOfHV6gEaC+x3btdFGU/Ym0wXwBfANJfCVW/JT6D6B9J0vaqssRdLmhdUNHzEhhRI822P83ckRPOOs/akjAcyMGp8fLxDVOTVY3kZXmWDxIhUe+EqIQM5xZ3WimPRM8hw67uficcRSoT2VkgpzTEvw7PmNCub2I8eqt3nf+YcotsX1HC9QM/J53VS4bhK5smZT0W72UcL3Fcso3uLcMqaITHQscl64aJkus8947yWs8TPTUDC0gv3IKDBoG+ViXvCamJCg63SYDXp52vv0yL3djdH91/A9uvXeAbqZQnTSeR9M8ceZ8OoMxZveH8AnqDMWVgcTh4m2gWUjqkQjTzXvEzlCcxgx/jWCfdBM5n37I/1n7vyAW/BWN2okZkPOFavWKS8Gs5cYMkV7YVPGcIJh6QW8dnDF6vW6qM+9NI1acz8z60+I+PqM2YqHvzYRXEBq8qaSELMF5TADYCiobT9tetgG5zMuFSnBVaATqQVrWFXGLOQPWRxf4oHsvLwMKD8lnWca7ea5sxHfvX0FFXx0F2U/m0HZL9Sm/C96UQFvEJg793o6PK0m/ypTwc/jqWgH2wE85eRd/iDtyZDzeQmOUdBJ7+3/NH224HtF84FrA4zZr7NXuvGDpUgLL/crL7nQmI2yKNpsn3XYK/CBVLO9pRYvW0n38ZYoRl+cbjf+U3E6VQvBDgNGwaJi7FtlJujkM3iPL6PATqJKNPJU8z7RI8gJ37KEsVvVRNBO2OIFpGYmd9x8TUBw+wvM7YsPsUsJXmCq1oo2x44ejzzxrLLgOSCjIAH3sG+dUfCBkP7Dx+sWzyMO9tPC0PCd/35mTEK333x8XSnsp2YE9eQzL5rODGPPt5488WJcyxpQSIQDovol6/yveDO2TyeWfMMCFIkflCibj2J9Lr4sIrutmDcbZIM1c1C4L1l7KY47Ujx/DDaR8+KMjuWZefcy/mxZyfh73zQejqllqeWBJ1HusfCEuldTpbYvckDFC9RzdKBgYmdyD7VpG1wRMKtnJhjedesziLBuziiYeWzBzqFnt2hKBw4dpr/4LYmdLY2CGb73p4zTLXvBP8P1PfqadlzEx0zTua2a01Ee5sDOgs3kjEQJb/P5s1737w4RjTzxLB/wjq9jX5ymeyz4kmG3BK2YfckadsI8fgatDxv+kRP4Z1wHqs0L2hMwM5utvur2B5Qhtja+eo42qVkjkw4dztFpylgvafTCx8tq0shBalL/ceTEKcoGfv4AzQnapk6tGtwWhUyMO023mYGW+Pl7r+ochaH14YVnJphRbNvmbEUDw6aEqv8gNDXjCxAfLVk0d7pZNiccVk6VpXTlJl12FxX9vZKKNi7SJ2CNrNjONjBbPE8m8pepyUUOG4zz+hk3JPL52Pe+OJGN9/yDjQxGfhCQRpxbF1DSWXcqITZHPG+15dLcPbVOBz3ci31j1gVdIhGKtJo0qk/9eYuaYIIZShhR+wwcqXQsbTxMbcO+EsrGgjft1IlP60gLeeCfd9SQR+jhIWMCtnTBLgL4ffjpV9ridOf4B8WWxdop/GjkqSu0HBf4mOw9d9ykaMCqKwAIFr9ggplbDJnNSAtphva7X3HaNUuPMoyTLxfx0qnL2F5Z2lUP6E94Waw22YlBbRuzshEGW+Rr44bpSAvhPW69XlnepbVJIhwCLdTodoF8Xhj9OOM2vCRSBfw1UEBkS4SBPr33CxRbu3mQjG1MVTHkjkkkZ0wV/lUlJ2WS05tJLk8mq9LVeI+fTNawUpjAVLUpMKvcJaPBcMqNytfPCYxgCPHk7yRvYeBsnSFaVC7hTY6tjEOt4DcrGPaxV58bGtDJjHHxRvzwzYnUhjWgsgjWrr31wihTPyvkg6Hd1AnDlQ8jlCVf2GKeHzXIdJ/1aORZlrqZxYX2CI02nJsK0oLoZ77ybFB7EuJc1LYN9eWdMoIRG+KoglnJ0bwzBQYHpRVoOm9NHl2qxdXaPNFP0N5mtjB86GTGy89Q2/PO1iYxPUf5aF+s3axIsY9giWaBNkccxbfqTO79W8hzMKtkyIaWCfcDpSKOegwZn7W2lBoUm9mS1yBWJnf2ZvLk8OyNmsaQh6/oIMVV73DSPg4LzQMfqUjntzXUbdXWwU8bIDCcwpaBoY52W5iAiJoAdKbru1xC0NDgm7SLv/hiJvCbAiGOYW3qwV63cX1SzaL5w2DA7XbjVcpSHgynDmebT7QgAYYp3XjfcWiAzRo38OdhPIl0ntjUzzhTi/WT2LFTKzDCY/JDK3V5iHbtFZ0IQ7+reOH4Tt6bDPuTGVzveLYwnfef6kpjmGTM7EHaPHEO22bLpo2V/Mz8nbDGEx+ZGDf834pDJz56gbWBWgHRdLm0gzbIfw6NtlP78xV3FGhxWWwCCKa544V592030Ghu8+rVjk+W+DM7doI6XdW5IzlZ29zOEzhOl34Ug76DPjyZX8JNGtZXPs7xDu9NrxX0w7u73agNith5VG1c2lrCT+vIy3dS8Q6eBQGRqGSinmuPIBxVwVKP6n3cU881x7ha7Sjj2rf5XizPNi6hnMX9yFvM/1javNT4HJbSaiAlN+2jreJJOcce3TDMlqj1O9gB8oiyrg++Wi2aNqJzecFyad7WoSoPOwSGJHACzWYjM8gQH3jA58lgUyuvYEcJzChl5+QqBJnMn++C9zhIS52lKmve0cizrHXQxsd2P7APwR4It4DaNWsouOEftzyCfLbyzg77+bNhldJSFKzQFiCKSAlsTdvYFwztDTwT4uKUz5PVq13TdGvtcOWCBGETRZ29vLSsfp1aVIdxKC8G4corzf0KIy61MtnT+1LRX0vJV5x3XKNSCUU9asmmlMQFgko6525KbT9UKSp/w9uU9+vzPJXJb4ogeWRes5xi4o8vUVLrKEdBQBA4tRGocOLyuYuoOGsN5cz6N3mPsp1JJSvtsZzEFZOUQZk9f/Yj7tr5PeWtnUzunI16kkT+XF5c9Qspo8NMf3w5EQQEAWsgUOHEpYXFufozyp03lrzObDauu4+TWFmIi4c6MUmVKK5+Z6rUaTQTVOBEac6ygeTau5iLYMc+G6/BOkZccKlIOrMXpbYYzGHlU/21zyPngoAgUDEInFTiUh6RPxVWsGIWf4sxi4p3r6finatLiEUd3qlHVSM7Rjr2Kg0pvkEnsqeeQYln3c58pVliZIKdj73lC7d+wiS5l5z8QVhP4Q6FKG3xaZTS7BFKanC3SSoJEgQEgVMRgZNPXCoqbPTz5rPxL++gEuIpOMhLhrbwcHKXsqNqTEZtcmQ24ZnAkp1LbfGpZE/DFCyYrGwCdwifO4/c/LWfgi1v8Ycz9lHm5YvLlonEFgQEgZOGwKlDXCcNAilYEBAErIYABmAigoAgIAhYCgEhLks1l1RWEBAEgIAQl/QDQUAQsBwCQlyWazKpsCAgCAhxSR8QBAQByyEgxGW5JpMKCwKCgBCX9AFBQBCwHAJCXJZrMqmwICAICHFJHxAEBAHLISDEZbkmkwoLAoKAEJf0AUFAELAcAkJclmsyqbAgIAgIcUkfEAQEAcshIMRluSaTCgsCgoAQl/QBQUAQsBwCQlyWazKpsCAgCAhxSR8QBAQByyEgxGW5JpMKCwKCgBCX9AFBQBCwHAJCXJZrMqmwICAICHFJHxAEBAHLISDEZbkmkwoLAoKAEJf0AUFAELAcAkJclmsyqbAgIAgIcUkfEAQEAcshIMRluSaTCgsCgsD/AFt/MVAlcetCAAAAAElFTkSuQmCC",width:75,height:24},opacity:.1,right:10,top:10},this._opt.forceNoOffscreen||("undefined"==typeof OffscreenCanvas?(this._opt.forceNoOffscreen=!0,this._opt.useOffscreen=!1):this._opt.useOffscreen=!0),this._opt.isMpeg4&&(this._opt.useWCS=!1,this._opt.useMSE=!1,this._opt.isNakedFlow=!1,this._opt.useSIMD=!1,this._opt.isFmp4=!1),(this.isOldHls()||this.isWebrtcH264())&&(this._opt.useWCS=!1,this._opt.useMSE=!1,this._opt.isNakedFlow=!1),this._opt.isNakedFlow,!this.isOldHls()&&!this.isWebrtcH264()){if(this._opt.useWCS){const e="VideoEncoder"in window,t=gt();this._opt.useWCS=e,this._opt.useWCS&&this._opt.isH265&&(this._opt.useWCS=t),this._opt.useWCS||this.debug.warn("Player",`\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=yt()&&At(),this._opt.wcsUseVideoRender||this.debug.warn("Player","wcsUseVideoRender is true, but not support so set wcsUseVideoRender false")))}if(this._opt.useMSE){const e=function(){let e=!1;return!(!("MediaSource"in window)||!window.MediaSource.isTypeSupported(ee))||e}(),t=mt();this._opt.useMSE=e,this._opt.useMSE&&this._opt.isH265&&(this._opt.useMSE=t),this._opt.useMSE||this.debug.warn("Player",`\n useMSE is true,\n and supportMSE is ${e}, supportHevcMSE is ${t} , _opt.isH265 is ${this._opt.isH265}\n so set useMSE false`)}}if(this._opt.useMSE?(this._opt.useWCS&&this.debug.warn("Player","useMSE is true and useWCS is true then useWCS set true->false"),this._opt.forceNoOffscreen||this.debug.warn("Player","useMSE is true and forceNoOffscreen is false then forceNoOffscreen set false->true"),this._opt.useWCS=!1,this._opt.forceNoOffscreen=!0):this._opt.useWCS,this._opt.useSIMD||-1!==this._opt.decoder.indexOf("-simd")){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=/iphone/i.test(navigator.userAgent);this._opt.useSIMD=e&&$t(t),this._opt.useSIMD||this.debug.warn("Player",`useSIMD is true, but not support(isSupportSimd is ${e} ,isIphone is ${t}) so set useSIMD false`)}this._opt.useSIMD?-1===this._opt.decoder.indexOf("-simd")&&(this._opt.decoder=this._opt.decoder.replace("./hzPlayer/decoder-pro","./hzPlayer/decoder-pro-simd")):-1!==this._opt.decoder.indexOf("-simd")&&(this._opt.decoder=this._opt.decoder.replace("./hzPlayer/decoder-pro-simd","./hzPlayer/decoder-pro")),-1!==this._opt.decoder.indexOf("-simd")?this._opt.decoderAudio=this._opt.decoder.replace("./hzPlayer/decoder-pro-simd","./hzPlayer/decoder-pro-audio"):this._opt.decoderAudio=this._opt.decoder.replace("./hzPlayer/decoder-pro","./hzPlayer/decoder-pro-audio"),$t(this._opt.hasAudio)&&(this._opt.operateBtns.audio=!1),$t(this._opt.hasVideo)&&(this._opt.operateBtns.fullscreen=!1,this._opt.operateBtns.screenshot=!1,this._opt.operateBtns.record=!1,this._opt.operateBtns.ptz=!1,this._opt.operateBtns.quality=!1,this._opt.operateBtns.zoom=!1),this._opt.qualityConfig&&0===this._opt.qualityConfig.length&&this._opt.operateBtns.quality&&(this._opt.operateBtns.quality=!1,this.debug.warn("Player","_opt.qualityConfig is empty, so set operateBtns.quality false")),Kt(this._opt.useWebGPU)&&(this._opt.useWebGPU=function(){let e=!1;return"gpu"in navigator||e}(),$t(this._opt.useWebGPU)&&this.debug.warn("Player","useWebGPU is true, but not support so set useWebGPU false")),this._opt.hasControl=this._hasControl(),this._loading=!1,this._playing=!1,this._playbackPause=!1,this._hasLoaded=!1,this._zooming=!1,this._destroyed=!1,this._checkHeartTimeout=null,this._checkLoadingTimeout=null,this._checkStatsInterval=null,this._checkVisibleHiddenTimeout=null,this._startBpsTime=null,this._isPlayingBeforePageHidden=!1,this._stats={buf:0,netBuf:0,fps:0,maxFps:0,dfps:0,abps:0,vbps:0,ts:0,mseTs:0,pTs:0,dts:0},this._allStatsData={},this._faceDetectActive=!1,this._objectDetectActive=!1,this._times={playInitStart:"",playStart:"",streamStart:"",streamResponse:"",demuxStart:"",decodeStart:"",videoStart:"",playTimestamp:"",streamTimestamp:"",streamResponseTimestamp:"",demuxTimestamp:"",decodeTimestamp:"",videoTimestamp:"",allTimestamp:""},this._videoTimestamp=0,this._audioTimestamp=0,this._videoIframeIntervalTs=0,this._streamQuality=this._opt.defaultStreamQuality||"",this._visibility=!0,this._lastestVisibilityChangeTimestamp=null,this._tempWorkerStats=null,this._historyFpsList=[],this._tempStreamList=[],this._tempInnerPlayBgBase64="",$t(this._opt.useMSE)&&$t(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._opt.useWasm&&(this._opt.useOffscreen?this._opt.wasmUseVideoRender=!1:this._opt.wasmUseVideoRender&&(this._opt.wasmUseVideoRender=dt()&&yt()&&At(),this._opt.wasmUseVideoRender||this.debug.warn("Player","use wasm video render, but not support so set wasmUseVideoRender false")),this._opt.useSIMD?this.debug.log("Player","use simd wasm"):this.debug.log("Player","use wasm")),this._opt.useWasm&&(this._opt.useFaceDetector&&window.JessibucaProFaceDetector||this._opt.useObjectDetector&&window.JessibucaProObjectDetector)?(this.ai=new ln(this),this._opt.useFaceDetector&&window.JessibucaProFaceDetector||(this._opt.operateBtns.aiFace=!1),this._opt.useObjectDetector&&window.JessibucaProObjectDetector||(this._opt.operateBtns.aiObject=!1)):(this._opt.operateBtns.aiObject=!1,this._opt.operateBtns.aiFace=!1),!this._opt.useFaceDetector||this._opt.useWasm&&window.JessibucaProFaceDetector||this.debug.warn("Player",`use face detector, useWasm is ${this._opt.useWasm} and window.JessibucaProFaceDetector is `+!!window.JessibucaProFaceDetector),!this._opt.useObjectDetector||this._opt.useWasm&&window.JessibucaProObjectDetector||this.debug.warn("Player",`use object detector, useWasm is ${this._opt.useWasm} and window.JessibucaProObjectDetector is `+!!window.JessibucaProObjectDetector),this._opt.useVideoRender&&(this._opt.useWasm&&!this._opt.useOffscreen?(this._opt.wasmUseVideoRender=dt()&&yt()&&At(),this._opt.wasmUseVideoRender||this.debug.warn("Player","use wasm video render, but not support so set wasmUseVideoRender false")):this._opt.useWCS&&!this._opt.useOffscreen&&(this._opt.wcsUseVideoRender=yt()&&At(),this._opt.wcsUseVideoRender||this.debug.warn("Player","use wcs video render, but not support so set wcsUseVideoRender false"))),this._opt.useCanvasRender&&(this._opt.useMSE&&(this._opt.mseUseCanvasRender=!0),this._opt.useWasm&&(this._opt.wasmUseVideoRender=!1),this._opt.useWCS&&(this._opt.wcsUseVideoRender=!1),this.isOldHls()&&!ot()&&(this._opt.hlsUseCanvasRender=!0)),this._opt.useVideoRender=!1,this._opt.useCanvasRender=!1,this._opt.useWasm?this._opt.wasmUseVideoRender?this._opt.useVideoRender=!0:this._opt.useCanvasRender=!0:this._opt.useWCS?this._opt.wcsUseVideoRender?this._opt.useVideoRender=!0:this._opt.useCanvasRender=!0:this._opt.useMSE?this._opt.mseUseCanvasRender?this._opt.useCanvasRender=!0:this._opt.useVideoRender=!0:this.isOldHls()?this._opt.hlsUseCanvasRender?this._opt.useCanvasRender=!0:this._opt.useVideoRender=!0:this.isWebrtcH264()&&(this._opt.useVideoRender=!0),i=this,Object.defineProperty(i,"rect",{get:()=>{const e=i.$container.getBoundingClientRect();return e.width=Math.max(e.width,i.$container.clientWidth),e.height=Math.max(e.height,i.$container.clientHeight),e}}),["bottom","height","left","right","top","width"].forEach(e=>{Object.defineProperty(i,e,{get:()=>i.rect[e]})}),this.events=new qt(this),this._opt.hasVideo&&(this.video=new gi(this),this.recorder=new lr(this)),this.isOldHls()?(this.hlsDecoder=new sa(this),this.loaded=!0):this.isWebrtcH264()?(this._opt.isWebrtcForZLM?this.webrtc=new an(this):this.webrtc=new sn(this),this.loaded=!0):(this.isUseHls265()&&(this.hlsDecoder=new rn(this)),this.isWebrtcH265()&&(this.webrtc=new sn(this)),Ft(this._opt)?this.loaded=!0:this.decoderWorker=new dr(this)),this._opt.hasAudio&&(this.audio=new Pi(this)),this.stream=null,this.demux=null,this._lastVolume=null,this._isInZoom=!1,this._playingStartTimestamp=null,this._opt.useWCS&&(this.webcodecsDecoder=new js(this),this._opt.hasAudio||(this.loaded=!0)),this._opt.useMSE&&(this.mseDecoder=new ea(this),this._opt.hasAudio||(this.loaded=!0)),this.control=new Xs(this),0<this._opt.contextmenuBtns.length&&(this.contextmenu=new dn(this)),this.isPlayback()&&(this.playback=new nn(this,this._opt.playbackConfig)),this._opt.operateBtns.zoom&&(this.zoom=new on(this)),/(iphone|ipad|ipod|ios|android)/i.test(window.navigator.userAgent.toLowerCase())&&$t(this._opt.supportLockScreenPlayAudio&&nt())&&(this.keepScreenOn=new ia(this));var r=this;try{const e=e=>{It(e)===r.$container&&(r.emit(F.fullscreen,r.fullscreen),r.fullscreen&&!r._opt.useMSE||r.resize())};je.on("change",e),r.events.destroys.push(()=>{je.off("change",e)})}catch(r){}if(r.on(U.decoderWorkerInit,()=>{r.debug.log("player","listen decoderWorkerInit and set loaded true"),r.loaded=!0}),r.on(U.play,()=>{r.loading=!1}),r.on(U.fullscreen,e=>{if(e)try{je.request(r.$container).then(()=>{}).catch(e=>{r.debug.error("player","fullscreen request error",e),it()&&r._opt.useWebFullScreen&&(r.webFullscreen=!0)})}catch(e){it()&&r._opt.useWebFullScreen&&(r.webFullscreen=!0)}else try{je.exit().then(()=>{r.webFullscreen&&(r.webFullscreen=!1)}).catch(e=>{r.debug.error("player","fullscreen exit error",e),r.webFullscreen&&(r.webFullscreen=!1)})}catch(e){r.webFullscreen&&(r.webFullscreen=!1)}}),it()&&r.on(U.webFullscreen,e=>{e?r.$container.classList.add("jessibuca-fullscreen-web"):r.$container.classList.remove("jessibuca-fullscreen-web"),r.emit(F.fullscreen,r.fullscreen)}),r.on(U.resize,()=>{r.video&&r.video.resize()}),r._opt.debug){const e=[U.timeUpdate],t=[U.stats,U.playbackStats,U.playbackTimestamp];Object.keys(U).forEach(i=>{r.on(U[i],s=>{e.includes(i)||(t.includes(i)&&(s=JSON.stringify(s)),r.debug.log("player events",U[i],s))})}),Object.keys(O).forEach(e=>{r.on(O[e],t=>{r.debug.warn("player event error",O[e],t)})})}{var s=this;const{_opt:e,debug:t,events:{proxy:i}}=s;if(e.supportDblclickFullscreen&&i(s.$container,"dblclick",e=>{e=It(e).nodeName.toLowerCase(),"canvas"!==e&&"video"!==e||(s.fullscreen=!s.fullscreen)}),i(document,"visibilitychange",()=>{s.visibility="visible"===document.visibilityState,t.log("visibilitychange",document.visibilityState),e.hiddenAutoPause&&(t.log("visibilitychange","hiddenAutoPause is true ",document.visibilityState,s._isPlayingBeforePageHidden),"visible"===document.visibilityState?s._isPlayingBeforePageHidden&&s.play():(s._isPlayingBeforePageHidden=s.playing,s.playing&&s.pause()))}),i(document,["click","contextmenu"],e=>{Js(e,s.$container)?(s.isInput="INPUT"===e.target.tagName,s.isFocus=!0,s.emit(U.focus)):(s.isInput=!1,s.isFocus=!1,s.emit(U.blur))}),e.autoResize){const e=ut(()=>{s.resize()},500);i(window,["resize","orientationchange"],()=>{e()}),screen&&screen.orientation&&screen.orientation.onchange&&i(screen.orientation,"change",()=>{e()})}}this.singleWatermark=new pi(this),this._opt.watermarkConfig&&this.updateWatermark(this._opt.watermarkConfig),this._opt.useWCS&&this.debug.log("Player","use WCS"),this._opt.useMSE&&this.debug.log("Player","use MSE"),this._opt.useOffscreen&&this.debug.log("Player","use offscreen"),this._opt.isHls&&(this._opt.supportHls265?this.debug.log("Player","use hls 265"):this.debug.log("Player","use hls")),this._opt.isWebrtc&&(this._opt.isWebrtcH265?this.debug.log("Player","use webrtc h265"):this._opt.isWebrtcForZLM?this.debug.log("Player","use webrtc for ZLM"):this.debug.log("Player","use webrtc")),this._opt.isFmp4&&this.debug.log("Player","use fmp4"),this._opt.isMpeg4&&this.debug.log("Player","use mpeg4"),this.isPlayback()&&this.debug.log("Player","use playback"),this._opt.hasVideo&&(0===this.width&&this.debug.warn("Player","container width is 0, please check the container width"),0===this.height&&this.debug.warn("Player","container height is 0, please check the container height")),this.debug.log("Player options",JSON.stringify(this._opt))}async destroy(){this._destroyed=!0,this.emit("destroy"),this.off(),this.events&&(this.events.destroy(),this.events=null),this.clearCheckHeartTimeout(),this.clearCheckLoadingTimeout(),this.clearStatsInterval(),this.clearVisibilityHiddenTimeout(),this.decoderWorker&&(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._zooming=!1,this._faceDetectActive=!1,this._objectDetectActive=!1,this._times={playInitStart:"",playStart:"",streamStart:"",streamResponse:"",demuxStart:"",decodeStart:"",videoStart:"",playTimestamp:"",streamTimestamp:"",streamResponseTimestamp:"",demuxTimestamp:"",decodeTimestamp:"",videoTimestamp:"",allTimestamp:""},this.singleWatermark&&(this.singleWatermark.destroy(),this.singleWatermark=null),this.stream&&(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.video&&(this.video.destroy(),this.video=null),this.audio&&(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._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._tempInnerPlayBgBase64="",this.debug.log("play","destroy end"),this._opt=Wt(),this.$container=null}set fullscreen(e){it()&&this._opt.useWebFullScreen?(this.emit(U.webFullscreen,e),setTimeout(()=>{this.updateOption({rotate:e?270:0}),this.resize()},10)):this.emit(U.fullscreen,e)}get fullscreen(){return je.isFullscreen||this.webFullscreen}set webFullscreen(e){this.emit(U.webFullscreen,e)}get webFullscreen(){return this.$container.classList.contains("jessibuca-fullscreen-web")}set loaded(e){this._hasLoaded=e}get loaded(){return this._hasLoaded||this.isOldHls()||this.isWebrtcH264()||this._opt.useMSE&&!this._opt.hasAudio||this._opt.useWCS&&!this._opt.hasAudio}set playing(e){e&&(this.loading=!1),this.playing!==e&&(this._playing=e,this.emit(U.playing,e),this.emit(U.volumechange,this.volume),e?this.emit(U.play):this.emit(U.pause))}get playing(){return this._playing}get volume(){return this.audio&&this.audio.volume||0}set volume(e){e!==this.volume&&(this.audio?(this.audio.setVolume(e),this._lastVolume=this.volume):this.debug.warn("Player","set volume error, audio is null"))}get lastVolume(){return this._lastVolume}set loading(e){this.loading!==e&&(this._loading=e,this.emit(U.loading,this._loading))}get loading(){return this._loading}set zooming(e){this.zooming!==e&&(this.zoom||(this.zoom=new on(this)),this._zooming=e,this.emit(U.zooming,this.zooming))}get zooming(){return this._zooming}set recording(e){e?this.playing&&!this.recording&&(this.recorder&&this.recorder.startRecord(),this._opt.useWasm&&this.decoderWorker.updateWorkConfig({key:"isRecording",value:!0})):this.recording&&(this._opt.useWasm&&this.decoderWorker.updateWorkConfig({key:"isRecording",value:!1}),this.recorder&&this.recorder.stopRecordAndSave().then(()=>{}).catch(e=>{}))}get recording(){return!!this.recorder&&this.recorder.isRecording}set audioTimestamp(e){null!==e&&(this._audioTimestamp=e)}get audioTimestamp(){return this._audioTimestamp}set videoTimestamp(e){null!==e&&(this._videoTimestamp=e,this._opt.useWCS||this._opt.useMSE||this.audioTimestamp&&this.videoTimestamp&&this.audio&&this.audio.emit(U.videoSyncAudio,{audioTimestamp:this.audioTimestamp,videoTimestamp:this.videoTimestamp,diff:this.audioTimestamp-this.videoTimestamp}))}set streamQuality(e){this.streamQuality!==e&&(this._streamQuality=e,this.emit(U.streamQualityChange,e))}get streamQuality(){return this._streamQuality}get videoTimestamp(){return this._videoTimestamp}get isDebug(){return Kt(this._opt.debug)}get scaleType(){var e=this._opt,t=e.isResize;e=e.isFullResize;let i=0;return $t(e)&&$t(t)?i=0:$t(e)&&Kt(t)?i=1:Kt(e)&&Kt(t)&&(i=2),i}set visibility(e){this._visibility!==e&&(this._visibility=e,this.emit(U.visibilityChange,e),this._lastestVisibilityChangeTimestamp=qe(),e?this.clearVisibilityHiddenTimeout():this.startVisibilityHiddenTimeout())}get visibility(){return this._visibility}set playbackPause(e){this._playbackPause!==e&&(this._playbackPause=e,this.emit(U.playbackPause,e),this.emit(U.playbackPauseOrResume,e))}get playbackPause(){return this._playbackPause}set videoIframeIntervalTs(e){this._videoIframeIntervalTs=e}get videoIframeIntervalTs(){return this._videoIframeIntervalTs}set faceDetectActive(e){this._faceDetectActive!==e&&(this._faceDetectActive=e,this.emit(U.faceDetectActive,e))}get faceDetectActive(){return this._faceDetectActive}set objectDetectActive(e){this._objectDetectActive!==e&&(this._objectDetectActive=e,this.emit(U.objectDetectActive,e))}get objectDetectActive(){return this._objectDetectActive}get isUseWorkerDemuxAndDecode(){return this.stream&&this.stream.getStreamType()===n}isDestroyed(){return this._destroyed}updateOption(e){var t=1<arguments.length&&void 0!==arguments[1]&&arguments[1];this._opt=Object.assign({},this._opt,e),Kt(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 gi(this)),this.audio||this._opt.hasAudio&&(this.audio=new Pi(this)),this.stream||(this.stream=new ji(this)),this.isOldHls()?(this.hlsDecoder||(this.hlsDecoder=new sa(this),this.loaded=!0),e()):this.isWebrtcH264()?(this.webrtc||(this._opt.isWebrtcForZLM?this.webrtc=new an(this):this.webrtc=new sn(this),this.loaded=!0),e()):(this.demux||this._opt.hasVideo&&!this.isUseWorkerDemuxAndDecode&&(this.demux=new Ns(this)),this._opt.useWCS&&!this.webcodecsDecoder&&(this.webcodecsDecoder=new js(this)),this._opt.useMSE&&!this.mseDecoder&&(this.mseDecoder=new ea(this)),this.isUseHls265()&&!this.hlsDecoder&&(this.hlsDecoder=new rn(this)),this.isWebrtcH265()&&!this.webrtc&&(this.webrtc=new sn(this)),this.decoderWorker?this.loaded?e():this.once(U.decoderWorkerInit,()=>{this.loaded=!0,e()}):Ft(this._opt)?e():(this.decoderWorker=new dr(this),this.once(U.decoderWorkerInit,()=>{this.loaded=!0,e()})))})}play(e){let t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return new Promise((i,r)=>{if(!e&&!this._opt.url)return r("url is empty");this.loading=!0,this.playing=!1,this._times.playInitStart=qe(),e=e||this._opt.url,this._opt.url=e,this.clearCheckHeartTimeout(),this.control&&(this.control.initLoadingBackground(),this._opt.loadingBackground=""),this.init().then(()=>{this._times.playStart=qe(),this._opt.isNotMute&&this.mute(!1),this.webcodecsDecoder&&this.webcodecsDecoder.once(O.webcodecsH265NotSupport,()=>{this.emitError(O.webcodecsH265NotSupport)}),this.mseDecoder&&(this.mseDecoder.once(O.mediaSourceH265NotSupport,()=>{this.emitError(O.mediaSourceH265NotSupport)}),this.mseDecoder.once(O.mediaSourceFull,()=>{this.emitError(O.mediaSourceFull)}),this.mseDecoder.once(O.mediaSourceAppendBufferError,()=>{this.emitError(O.mediaSourceAppendBufferError)}),this.mseDecoder.once(O.mediaSourceBufferListLarge,()=>{this.emitError(O.mediaSourceBufferListLarge)}),this.mseDecoder.once(O.mediaSourceAppendBufferEndTimeout,()=>{this.emitError(O.mediaSourceAppendBufferEndTimeout)}),this.mseDecoder.once(O.mediaSourceDecoderConfigurationError,()=>{this.emitError(O.mediaSourceDecoderConfigurationError)}),this.mseDecoder.once(O.mediaSourceTsIsMaxDiff,()=>{this.emitError(O.mediaSourceTsIsMaxDiff)})),this.enableWakeLock(),this.checkLoadingTimeout(),this.stream?(this.stream.once(O.fetchError,e=>{this.emitError(O.fetchError,e)}),this.stream.once(O.websocketError,e=>{this.emitError(O.websocketError,e)}),this.stream.once(U.streamEnd,()=>{this.emit(U.streamEnd)}),this.stream.once(O.hlsError,e=>{this.emitError(O.hlsError,e)}),this.stream.once(O.webrtcError,e=>{this.emitError(O.webrtcError,e)}),this.stream.once(U.streamSuccess,()=>{i(),this._times.streamResponse=qe(),this.video&&this.video.play(),this.checkStatsInterval(),this.isPlayback()&&this.playback&&this.playback.startCheckStatsInterval();Number("1")}),this.stream.fetchStream(e,t)):this.debug.warn("player","play() this.stream is null")}).catch(e=>{r(e)})})}playForControl(){return new Promise((e,t)=>{this.debug.log("player","playForControl() and pauseAndNextPlayUseLastFrameShow is "+this._opt.pauseAndNextPlayUseLastFrameShow),this._opt.pauseAndNextPlayUseLastFrameShow&&this._tempInnerPlayBgBase64&&this.updateOption({loadingBackground:this._tempInnerPlayBgBase64}),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&&(this.volume=this.lastVolume)}_close(){return new Promise((e,t)=>{const i=()=>{this.stream&&(this.stream.destroy(),this.stream=null),this.demux&&(this.demux.destroy(),this.demux=null),this.webcodecsDecoder&&(this.webcodecsDecoder.destroy(),this.webcodecsDecoder=null),this.mseDecoder&&(this.mseDecoder.destroy(),this.mseDecoder=null),this.hlsDecoder&&(this.hlsDecoder.destroy(),this.hlsDecoder=null),this.webrtc&&(this.webrtc.destroy(),this.webrtc=null),this.audio&&(this.audio.destroy(),this.audio=null),this.clearCheckHeartTimeout(),this.clearCheckLoadingTimeout(),this.clearStatsInterval(),this.isPlayback()&&this.playback&&this.playback.clearStatsInterval(),this.loading=!1,this.recording=!1,this.zooming=!1,this.playing=!1,this.video&&(this.video.resetInit(),this.video.pause(!0)),this.releaseWakeLock(),this.resetStats(),this._audioTimestamp=0,this._videoTimestamp=0,this._times={playInitStart:"",playStart:"",streamStart:"",streamResponse:"",demuxStart:"",decodeStart:"",videoStart:"",playTimestamp:"",streamTimestamp:"",streamResponseTimestamp:"",demuxTimestamp:"",decodeTimestamp:"",videoTimestamp:"",allTimestamp:""}};this.decoderWorker?this.decoderWorker.destroy().then(()=>{this.decoderWorker=null,i(),setTimeout(()=>{e()},0)}).catch(e=>{this.debug&&this.debug.error("player","close() decoderWorker.destroy() error",e),t()}):(i(),setTimeout(()=>{e()},0))})}pause(){let e=0<arguments.length&&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("player","_pauseInner()"),this._opt.pauseAndNextPlayUseLastFrameShow&&this.video){const e=this.video.screenshot("","png",.92,"base64");e&&(this._tempInnerPlayBgBase64=e)}this.pause().then(t=>{e(t)}).catch(e=>{t(e)})})}isAudioMute(){let e=!0;return this.audio?this.audio.isMute:e}isAudioNotMute(){return!this.isAudioMute()}mute(e){this.audio&&this.audio.mute(e)}resize(){this.video&&this.video.resize()}startRecord(e,t){this.recording||(this.recorder.setFileName(e,t),this.recording=!0)}stopRecordAndSave(e,t){return new Promise((i,r)=>{this.recorder||r("recorder is null"),this.recording?(this._opt.useWasm&&this.decoderWorker.updateWorkConfig({key:"isRecording",value:!0}),this.recorder.stopRecordAndSave(e,t).then(e=>{i(e)}).catch(e=>{r(e)})):r("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.isPlayback()||!this._opt.playbackConfig.showControl)||e}useWasmDecode(){return $t(this._opt.useMSE)&&$t(this._opt.useWCS)}canVideoTrackWritter(){var e=this._opt;return!this.isOldHls()&&!this.isWebrtcH264()&&$t(e.useMSE)&&(e.useWCS&&$t(e.useOffscreen)&&e.wcsUseVideoRender||this.useWasmDecode())}checkHeart(){this.clearCheckHeartTimeout(),this.checkHeartTimeout()}checkHeartTimeout(){this._checkHeartTimeout=setTimeout(()=>{$t(this.playbackPause)&&this.playing?this.isDestroyed()?this.debug&&this.debug.warn("player","checkHeartTimeout but player is destroyed"):0!==this._stats.fps?this.debug&&this.debug.warn("player","checkHeartTimeout but fps is "+this._stats.fps):$t(this.visibility)&&0!==this._stats.vbps?this.debug&&this.debug.warn("player","checkHeartTimeout but page is not visibility and vbps is "+this._stats.vbps):(this.debug.warn("player",`checkHeartTimeout and\n pause and emit delayTimeout event and\n current vbps is ${this._stats.vbps} and\n current fps is ${this._stats.fps} and\n current visibility is ${this.visibility} and`),this.emit(U.timeout,U.delayTimeout),this.emit(U.delayTimeout)):this.debug.warn("player",`playbackPause is ${this.playbackPause}, playing is `+this.playing)},1e3*this._opt.heartTimeout)}checkHeartTimeout$2(){var e;$t(this.playbackPause)&&this.playing?this.isDestroyed()?this.debug&&this.debug.warn("player","checkHeartTimeout$2 but player is destroyed"):$t(this.isHistoryFpsListAllZero())?this.debug&&this.debug.warn("player","checkHeartTimeout$2 but fps is not all zero"):0!==this._stats.fps?this.debug&&this.debug.warn("player","checkHeartTimeout$2 but fps is "+this._stats.fps):$t(this.visibility)&&0!==this._stats.vbps?this.debug&&this.debug.warn("player","checkHeartTimeout$2 but page is not visibility and vbps is "+this._stats.vbps):(e=this._historyFpsList.join(","),this.debug.warn("player",`checkHeartTimeout$2 and\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(U.timeout,U.delayTimeout),this.emit(U.delayTimeout)):this.debug.log("player",`checkHeartTimeout$2 playbackPause is ${this.playbackPause}, playing is `+this.playing)}checkStatsInterval(){this._checkStatsInterval=setInterval(()=>{this.updateStats()},1e3)}clearCheckHeartTimeout(){this._checkHeartTimeout&&(clearTimeout(this._checkHeartTimeout),this._checkHeartTimeout=null)}checkLoadingTimeout(){this._checkLoadingTimeout=setTimeout(()=>{this.playing?this.debug.warn("player",`checkLoadingTimeout but loading is ${this.loading} and playing is `+this.playing):this.isDestroyed()?this.debug&&this.debug.warn("player","checkLoadingTimeout but player is destroyed"):(this.debug.warn("player","checkLoadingTimeout and pause and emit loadingTimeout event"),this.emit(U.timeout,U.loadingTimeout),this.emit(U.loadingTimeout))},1e3*this._opt.loadingTimeout)}clearCheckLoadingTimeout(){this._checkLoadingTimeout&&(this.debug.log("player","clearCheckLoadingTimeout"),clearTimeout(this._checkLoadingTimeout),this._checkLoadingTimeout=null)}clearStatsInterval(){this._checkStatsInterval&&(clearInterval(this._checkStatsInterval),this._checkStatsInterval=null)}handleRender(){this.isDestroyed()?this.debug&&this.debug.warn("player","handleRender but player is destroyed"):(this.loading&&(this.clearCheckLoadingTimeout(),this.loading=!1,this.emit(U.start)),this.playing||(this.playing=!0))}updateStats(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};this._startBpsTime||(this._startBpsTime=qe()),_t(e.ts)&&(this._stats.ts=e.ts,null===this._playingStartTimestamp&&0<e.ts&&(this._playingStartTimestamp=e.ts)),_t(e.dts)&&(this._stats.dts=e.dts),_t(e.mseTs)&&(this._stats.mseTs=e.mseTs),_t(e.buf)&&(this._stats.buf=e.buf),_t(e.netBuf)&&(this._stats.netBuf=e.netBuf),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);const t=qe();if(!(t-this._startBpsTime<1e3)){null!==this._playingStartTimestamp&&0<this._stats.fps&&(this._stats.pTs+=1);let r=0,s=0,a=0,n=(this._opt.useMSE&&this.mseDecoder&&(r=this.mseDecoder.checkSourceBufferDelay(),r=parseInt(1e3*r,10),s=this.mseDecoder.getDecodeDiffTimes(),a=this.mseDecoder.getDecodePlaybackRate()),this._opt.useWCS&&this.webcodecsDecoder&&(s=this.webcodecsDecoder.getDecodeDiffTimes()),this.isOldHls()&&this.hlsDecoder&&(r=this.hlsDecoder.checkHlsBufferedDelay(),r=parseInt(1e3*r,10),a=this.hlsDecoder.getDecodePlaybackRate()),0),o=0,l=0,d=(this.isUseHls265()&&this.hlsDecoder&&(r=(r=this.hlsDecoder.checkHlsBufferedDelay()).toFixed(2),n=this.hlsDecoder.getDemuxBufferedListLength(),l=this.hlsDecoder.getDemuxVideoBufferedListLength(),o=this.hlsDecoder.getDemuxAudioBufferedListLength()),0),h=0,c=0,u=!1,p=!1,f=0,m=(this.demux&&(u=this.demux.isDropping()),this._opt.useWasm?this._tempWorkerStats&&(h=this._tempWorkerStats.demuxBufferDelay,c=this._tempWorkerStats.audioDemuxBufferDelay,d=this._tempWorkerStats.flvBufferByteLength,this._stats.netBuf=this._tempWorkerStats.netBuf,u=this._tempWorkerStats.isDropping,f=this._tempWorkerStats.pushLatestDelay,p=this._tempWorkerStats.isStreamTsMoreThanLocal):this.demux&&(d=this.demux.getInputByteLength(),f=this.demux.getPushLatestDelay(),p=this.demux.getIsStreamTsMoreThanLocal(),this.demux.bufferList&&(h=this.demux.bufferList.length)),0),g=0,y=(this.audio&&this.audio.bufferList&&(m=this.audio.bufferList.length,g=m*this.audio.oneBufferDuration),0),A=0;if(this.isPlayback()&&this.video){this._opt.playbackConfig.isUseFpsRender&&(y=this.video.bufferList&&this.video.bufferList.length||0),e=this.video.getStreamFps();const t=0<e?1e3/e:0;A=parseInt(t*y+t*h,10)}e=this._stats.dts-this._stats.ts;var i=e+this._stats.netBuf;this.isOldHls()&&(this._stats.fps=this.hlsDecoder.getFps()),this._stats.fps>this._stats.maxFps&&(this._stats.maxFps=this._stats.fps),this._allStatsData=Object.assign(this._stats,{audioBuffer:m,audioBufferDelayTs:g,audioTs:this.audioTimestamp,playbackVideoBuffer:y,playbackVideoWaitingBuffer:0,playbackAudioWaitingBuffer:0,playbackCacheDataDuration:A,demuxBuffer:h,pushLatestDelay:f,audioDemuxBuffer:c,flvBuffer:d,mseDelay:r,mseDecodeDiffTimes:s,mseDecodePlaybackRate:a,wcsDecodeDiffTimes:s,hlsDelay:r,hlsDemuxLength:n,hlsDemuxAudioLength:o,hlsDemuxVideoLength:l,hlsDecodePlaybackRate:a,delayTs:e,totalDelayTs:i,isDropping:u,isStreamTsMoreThanLocal:p}),this.emit(U.stats,this._allStatsData),1048576<this._allStatsData.flvBuffer&&this.emit(O.flvDemuxBufferSizeTooLarge,this._allStatsData.flvBuffer),this.updateHistoryFpsList(this._stats.fps),this._opt.hasVideo&&this.isPlayer()&&(this.emit(U.performance,function(e){let t=0;return 24<=e?t=2:15<=e&&(t=1),t}(this._stats.fps)),this.emit(U.videoSmooth,this.checkVideoSmooth(this._stats))),this._stats.fps=0,this._stats.dfps=0,this._stats.abps=0,this._stats.vbps=0,this._startBpsTime=t}}resetStats(){this._startBpsTime=null,this._playingStartTimestamp=null,this._historyFpsList=[],this._stats={buf:0,netBuf:0,fps:0,maxFps:0,dfps:0,abps:0,vbps:0,ts:0,mseTs:0,pTs:0,dts:0},this._allStatsData={}}checkVideoSmooth(e){let t=!0;const i=this._opt.videoBuffer+this._opt.videoBufferDelay;if((t=!((t=!((t=!((t=(!(t=0!==e.vbps&&t)||!e.isDropping)&&t)&&e.pushLatestDelay>i)&&t)&&e.netBuf>this._opt.networkDelay)&&t)&&e.delayTs>i)&&t)&&this.visibility&&this._historyFpsList.length>=this._opt.heartTimeout){const i=this._historyFpsList.reduce((e,t)=>e+t,0)/this._historyFpsList.length;e.fps<i&&(t=!1)}return t}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(U.beforeDestroy)}handlePlayToRenderTimes(){var e=this.getPlayToRenderTimes();this.emit(U.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,e.demuxTimestamp=0<e.demuxStart-e.streamResponse?e.demuxStart-e.streamResponse:0,e.decodeTimestamp=0<e.decodeStart-e.demuxStart?e.decodeStart-e.demuxStart:0,e.videoTimestamp=e.videoStart-e.decodeStart,e.allTimestamp=e.videoStart-e.playInitStart,e}getOption(){return this._opt}isPlayer(){return this._opt.playType===o}isPlayback(){return this._opt.playType===d}isDemuxSetCodecInit(){let e=!0,t=this._opt;return t.useWCS&&!t.useOffscreen?e=this.webcodecsDecoder.hasInit:t.useMSE&&(e=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?this.audio.isPlaybackRateSpeed():e}getPlayingTimestamp(){return this._stats.pTs}getRecordingType(){let e=null;return this.recorder?this.recorder.getType():e}getRecordingByteLength(){let e=0;return this.recording?this.recorder.getToTalByteLength():e}getRecordingDuration(){let e=0;return this.recording?this.recorder.getTotalDuration():e}getDecodeType(){let e="";var t=this.getOption();return t.useMSE&&(e+="mse "),t.useWCS&&(e+="wcs "),t.useWasm&&(e+="wasm ",t.useSIMD&&(e+="simd ")),t.useOffscreen&&(e+="offscreen "),e}getDemuxType(){return this.getOption().demuxType}getRenderType(){let e="";return this.video?this.video.getType():e}getCanvasRenderType(){let e="";return this.video?this.video.getCanvasType():e}getAudioEngineType(){let e="";return this.audio?this.audio.getEngineType():e}getStreamType(){let e="";return this.stream?this.stream.getStreamType():e}getAllStatsData(){return this._allStatsData}togglePerformancePanel(e){this.updateOption({showPerformance:e}),this.emit(U.togglePerformancePanel,e)}setScaleMode(e){let t={isFullResize:!1,isResize:!1};switch(e=Number(e)){case 0:t.isFullResize=!1,t.isResize=!1;break;case 1:t.isFullResize=!1,t.isResize=!0;break;case 2:t.isFullResize=!0,t.isResize=!0}this.updateOption(t),this.resize(),this.emit(U.viewResizeChange,e)}startVisibilityHiddenTimeout(){this.clearVisibilityHiddenTimeout(),0<this._opt.pageVisibilityHiddenTimeout&&(this.visibilityHiddenTimeout=setTimeout(()=>{this.emit(U.visibilityHiddenTimeout)},1e3*this._opt.pageVisibilityHiddenTimeout))}clearVisibilityHiddenTimeout(){this._checkVisibleHiddenTimeout&&(clearTimeout(this._checkVisibleHiddenTimeout),this._checkVisibleHiddenTimeout=null)}faceDetect(e){this.faceDetectActive=e}objectDetect(e){this.objectDetectActive=e}downloadNakedFlowFile(){this.demux&&this.demux.downloadNakedFlowFile&&this.demux.downloadNakedFlowFile()}downloadFmp4File(){this.demux&&this.demux.downloadFmp4File&&this.demux.downloadFmp4File()}downloadMpeg4File(){var 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(){var e=this.videoIframeIntervalTs,t=this._allStatsData.demuxBuffer,i=this._allStatsData.maxFps;let r=!!(e&&t&&i)&&e<1e3/i*t;return r}addContentToCanvas(){this.video&&this.video.addContentToCanvas(0<arguments.length&&void 0!==arguments[0]?arguments[0]:[])}sendWebsocketMessage(e){var t=this.getStreamType();t===a||t===n+" "+a?this.stream.sendMessage(e):this.debug.warn("player","sendWebsocketMessage: stream type is not websocket, current stream type is "+this.getStreamType())}checkIsInRender(){var e=this._stats;return 0<e.vbps&&0<e.fps}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?this.video.getVideoInfo():e}getAudioInfo(){let e=null;return this.audio?this.audio.getAudioInfo():e}getVideoPlaybackQuality(){let e=null;return this.video?this.video.getPlaybackQuality():e}emitError(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";this.emit(U.error,e,t),this.emit(e,t)}updateHistoryFpsList(e){this._historyFpsList.length>this._opt.heartTimeout&&this._historyFpsList.shift(),this._historyFpsList.push(e),this.isHistoryFpsListAllZero()&&this.checkHeartTimeout$2()}isHistoryFpsListAllZero(){let e=!0;if(e=!(this._historyFpsList.length<this._opt.heartTimeout)&&e)for(let t=0;t<this._historyFpsList.length;t++)if(0<this._historyFpsList[t]){e=!1;break}return e}isUseHls265(){return Kt(this._opt.isHls)&&Kt(this._opt.supportHls265)}isOldHls(){return Kt(this._opt.isHls)&&$t(this._opt.supportHls265)}isWebrtcH264(){return Kt(this._opt.isWebrtc)&&$t(this._opt.isWebrtcH265)}isWebrtcH265(){return Kt(this._opt.isWebrtc)&&Kt(this._opt.isWebrtcH265)}isPlaybackCacheBeforeDecodeForFpsRender(){return Kt(this.isPlayback())&&Kt(this._opt.playbackConfig.isCacheBeforeDecodeForFpsRender)&&this._opt.useWCS}isPlaybackUseWCS(){return Kt(this.isPlayback())&&this._opt.useWCS}getPlaybackRate(){let e=1;return Kt(this.isPlayback())&&this.playback?this.playback.rate:e}isPlaybackOnlyDecodeIFrame(){return Kt(this.isPlayback())&&this.getPlaybackRate()>=this._opt.playbackForwardMaxRateDecodeIFrame}pushTempStream(e){e=new Uint8Array(e),this._tempStreamList.push(e)}updateLoadingText(e){this.loading&&this.control&&this.control.updateLoadingText(e)}}class cn{constructor(e){var{fromSampleRate:e,toSampleRate:t,channels:i,inputBufferSize:r}=e;if(!e||!t||!i)throw new Error("Invalid settings specified for the resampler.");this.resampler=null,this.fromSampleRate=e,this.toSampleRate=t,this.channels=i||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(r){try{return this.outputBuffer.length=e,this.outputBuffer}catch(r){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(r){this.outputBuffer=[],this.lastOutput=[]}}linearInterpolation(){this.resampler=e=>{let t,i,r,s,a,n,o,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,r=this.lastWeight,s=0,a=0,n=0,o=0,l=this.outputBuffer;r<1;r+=i)for(a=r%1,s=1-a,this.lastWeight=r%1,d=0;d<this.channels;++d)l[o++]=this.lastOutput[d]*s+e[d]*a;for(--r,h-=c,n=Math.floor(r)*c;o<t&&n<h;){for(a=r%1,s=1-a,d=0;d<this.channels;++d)l[o++]=e[n+(0<d?d:0)]*s+e[n+(c+d)]*a;r+=i,n=Math.floor(r)*c}for(d=0;d<c;++d)this.lastOutput[d]=e[n++];return this.bufferSlice(o)}}multiTap(){this.resampler=e=>{let t,i,r,s,a,n,o,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=[],r=this.ratioWeight,s=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(s=r,a=0;a<p;++a)i[a]=0;else{for(s=this.lastWeight,a=0;a<p;++a)i[a]=this.lastOutput[a];l=!0}for(;0<s&&n<u;){if(o=1+n-c,!(s>=o)){for(a=0;a<p;++a)i[a]+=e[n+(0<a?a:0)]*s;c+=s,s=0;break}for(a=0;a<p;++a)i[a]+=e[n++]*o;c=n,s-=o}if(0!==s){for(this.lastWeight=s,a=0;a<p;++a)this.lastOutput[a]=i[a];this.tailExists=!0;break}for(a=0;a<p;++a)d[h++]=i[a]/r}while(n<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 un=[255,511,1023,2047,4095,8191,16383,32767];function pn(e,t,i){for(let r=0;r<i;r++)if(e<=t[r])return r;return i}class fn extends r{constructor(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};super(),e&&(this.player=e),this.tag="talk",e=Gt(Ee);this._opt=Object.assign({},e,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=N,this.mediaStreamSource=null,this.heartInterval=null,this.checkGetUserMediaTimeout=null,this.wsUrl=null,this.startTimestamp=0,this.sequenceId=0,this.tempTimestamp=null,this.tempRtpBufferList=[],this.events=new qt(this),this._initTalk(),this.player||(this.debug=new Fe(this)),this._opt.encType!==ge&&this._opt.encType!==ye||8e3===this._opt.sampleRate&&16===this._opt.sampleBitsWidth||this.warn(this.tag,`\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,"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===j&&this._sendClose(),this.socket.close(),this.socket=null),this._stopHeartInterval(),this._stopCheckGetUserMediaTimeout(),this.audioContext=null,this.gainNode=null,this.recorder=null,this.audioBufferList=[],this.sequenceId=0,this.wsUrl=null,this.tempTimestamp=null,this.tempRtpBufferList=[],this.startTimestamp=0,this.log("talk","destroy")}addRtpToBuffer(e){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}downloadRtpFile(){var 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)}}calcAudioBufferLength(){var e=this._opt["sampleRate"];return 8*e*.02/8}get socketStatusOpen(){return this.socketStatus===j}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(1<t?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];(this.player?this.player.debug:this.debug||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(U.talkStreamStart),i(this.socket,"open",()=>{this.socketStatus=j,this.log(this.tag,"websocket open -> do talk"),this.emit(U.talkStreamOpen),e(),this._doTalk()}),i(this.socket,"message",e=>{this.log(this.tag,"websocket message",e.data)}),i(this.socket,"close",e=>{this.socketStatus="close",this.warn(this.tag,"websocket close -> reject",e),this.emit(U.talkStreamClose),t(e)}),i(this.socket,"error",e=>{this.socketStatus="error",this.error(this.tag,"websocket error -> reject",e),this.emit(U.talkStreamError,e),t(e)})})}_sendClose(){}_initTalk(){this._initMethods(),this._opt.engine===Se?this._initWorklet():"script"===this._opt.engine&&this._initScriptProcessor(),this.log(this.tag,"audioContext samplerate",this.audioContext.sampleRate)}_initMethods(){this.audioContext=new(window.AudioContext||window.webkitAudioContext)({sampleRate:48e3}),this.gainNode=this.audioContext.createGain(),this.gainNode.gain.value=1,this.biquadFilter=this.audioContext.createBiquadFilter(),this.biquadFilter.type="lowpass",this.biquadFilter.frequency.value=3e3,this.resampler=new cn({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=Mt((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 r=0;r<e[0][0].length;r++)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][r];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},E)}_onaudioprocess(e){e=e.inputBuffer.getChannelData(0),this._encodeAudioData(new Float32Array(e))}_encodeAudioData(e){if(0===e[0]&&0===e[1])this.log(this.tag,"empty audio data");else{const i=this.resampler.resample(e);let r=i;if(16===this._opt.sampleBitsWidth?r=function(e){let t=e.length,i=new Int16Array(t);for(;t--;){var r=Math.max(-1,Math.min(1,e[t]));i[t]=r<0?32768*r:32767*r}return i}(i):8===this._opt.sampleBitsWidth&&(r=function(e){let t=e.length,i=new Int8Array(t);for(;t--;){var r=Math.max(-1,Math.min(1,e[t]));i[t]=parseInt(255/(65535/(32768+(r<0?32768*r:32767*r))),10)}return i}(i)),null!==r.buffer){let e=null;this._opt.encType===ge?e=function(e){const t=[];return Array.prototype.slice.call(e).forEach((e,i)=>{t[i]=function(e){let t,i,r;return 0<=e?t=213:(t=85,(e=-e-1)<0&&(e=32767)),8<=(i=pn(e,un,8))?127^t:(r=i<<4,(r|=i<2?e>>4&15:e>>i+3&15)^t)}(e)}),t}(r):this._opt.encType===ye?e=function(e){const t=[];return Array.prototype.slice.call(e).forEach((e,i)=>{t[i]=function(e){let t=0;t=e<0?(e=132-e,127):(e+=132,255);var i=pn(e,un,8);return 8<=i?127^t:(i<<4|e>>i+3&15)^t}(e)}),t}(r):"pcm"===this._opt.encType&&(e=r);const i=new Uint8Array(e);for(let r=0;r<i.length;r++){var t=this.audioBufferList.length;this.audioBufferList[+t]=i[r],this.audioBufferList.length===this._opt.audioBufferLength&&(this._sendTalkMsg(new Uint8Array(this.audioBufferList)),this.audioBufferList=[])}}}}_parseAudioMsg(e){let t=null;return"rtp"!==this._opt.packetType||this._opt.encType!==ge&&this._opt.encType!==ye?"empty"===this._opt.packetType&&(t=e):t=this.rtpPacket(e),t}rtpPacket(e){const t=[];let i,r,s=0;var a=this._opt.rtpSsrc,n=e.length;this._opt.encType===ge?s=8:this._opt.encType===ye?s=0:"opus"===this._opt.encType&&(s=98),this.startTimestamp||(this.startTimestamp=qe()),r=qe()-this.startTimestamp,i=this._getSequenceId(),n+=12;t[0]=255&n>>8,t[1]=255&n>>0,t[2]=128,t[3]=128+s,t[4]=i/256,t[5]=i%256,t[6]=r/65536/256,t[7]=r/65536%256,t[8]=r%65536/256,t[9]=r%65536%256,t[10]=a/65536/256,t[11]=a/65536%256,t[12]=a%65536/256,t[13]=a%65536%256;let o=t.concat([...e]),l=new Uint8Array(o.length);for(let d=0;d<o.length;d++)l[d]=o[d];return l}opusPacket(e){return e}_sendTalkMsg(e){null===this.tempTimestamp&&(this.tempTimestamp=qe());var t=qe(),i=t-this.tempTimestamp,r=this._parseAudioMsg(e);this.log(this.tag,`'send talk msg and diff is ${i} and byteLength is ${r.byteLength} and length is ${r.length}, and g711 length is `+e.length),Kt(this._opt.saveRtpToFile)&&"rtp"===this._opt.packetType&&this.addRtpToBuffer(r),r&&(this.socketStatusOpen?this.socket.send(r.buffer):this.emit(O.tallWebsocketClosedByError)),this.tempTimestamp=t}_doTalk(){this._getUserMedia()}_getUserMedia(){this.log(this.tag,"getUserMedia"),void 0===window.navigator.mediaDevices&&(window.navigator.mediaDevices={}),void 0===window.navigator.mediaDevices.getUserMedia&&(this.log(this.tag,"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,r){t.call(navigator,e,i,r)})):Promise.reject(new Error("getUserMedia is not implemented in this browser"))}),this._opt.checkGetUserMediaTimeout&&this._startCheckGetUserMediaTimeout(),window.navigator.mediaDevices.getUserMedia({audio:{latency:!0,noiseSuppression:!!rt(),autoGainControl:!0,echoCancellation:!!rt(),sampleRate:48e3,channelCount:1},video:!1}).then(e=>{this.log(this.tag,"getUserMedia success"),this.userMediaStream=e,this.mediaStreamSource=this.audioContext.createMediaStreamSource(e),this.mediaStreamSource.connect(this.biquadFilter),this.recorder?(this.biquadFilter.connect(this.recorder),this.recorder.connect(this.gainNode)):this.workletRecorder&&(this.biquadFilter.connect(this.workletRecorder),this.workletRecorder.connect(this.gainNode)),this.gainNode.connect(this.audioContext.destination),this.emit(U.talkGetUserMediaSuccess),null===e.oninactive&&(e.oninactive=e=>{this._handleStreamInactive(e)})}).catch(e=>{this.error(this.tag,"getUserMedia error",e.toString()),this.emit(U.talkGetUserMediaFail,e.toString())}).finally(()=>{this.log(this.tag,"getUserMedia finally"),this._stopCheckGetUserMediaTimeout()})}_getUserMedia2(){this.log(this.tag,"getUserMedia"),navigator.mediaDevices?navigator.mediaDevices.getUserMedia({audio:!0}).then(e=>{this.log(this.tag,"getUserMedia2 success")}):navigator.getUserMedia({audio:!0},this.log(this.tag,"getUserMedia2 success"),this.log(this.tag,"getUserMedia2 fail"))}async _getUserMedia3(){this.log(this.tag,"getUserMedia3");try{var e=await navigator.mediaDevices.getUserMedia({audio:{latency:!0,noiseSuppression:!0,autoGainControl:!0,echoCancellation:!0,sampleRate:48e3,channelCount:1},video:!1});console.log("getUserMedia() got stream:",e),this.log(this.tag,"getUserMedia3 success")}catch(e){this.log(this.tag,"getUserMedia3 fail")}}_handleStreamInactive(e){this.userMediaStream&&(this.warn(this.tag,"stream oninactive",e),this.emit(U.talkStreamInactive))}_startCheckGetUserMediaTimeout(){this._stopCheckGetUserMediaTimeout(),this.checkGetUserMediaTimeout=setTimeout(()=>{this.log(this.tag,"check getUserMedia timeout"),this.emit(U.talkGetUserMediaTimeout)},this._opt.getUserMediaTimeout)}_stopCheckGetUserMediaTimeout(){this.checkGetUserMediaTimeout&&(this.log(this.tag,"stop checkGetUserMediaTimeout"),clearTimeout(this.checkGetUserMediaTimeout),this.checkGetUserMediaTimeout=null)}_startHeartInterval(){this.heartInterval=setInterval(()=>{this.log(this.tag,"heart interval");var e=[35,36,0,0,0,0,0,0];e=new Uint8Array(e);this.socket.send(e.buffer)},15e3)}_stopHeartInterval(){this.heartInterval&&(this.log(this.tag,"stop heart interval"),clearInterval(this.heartInterval),this.heartInterval=null)}startTalk(e){return new Promise((t,i)=>{if(!function(){let e=!1;var t=window.navigator;return t?(e=!(!t.mediaDevices||!t.mediaDevices.getUserMedia))||!!(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(U.talkGetUserMediaFail,()=>{i("getUserMedia fail")}),this.once(U.talkGetUserMediaSuccess,()=>{t()})})}setVolume(e){e=parseFloat(e).toFixed(2),isNaN(e)||(e=Je(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 mn{constructor(e){this.player=e,this.globalSetting=null,e=ct(),this.defaultSettings={watermark_id:"JessibucaPro_"+e,watermark_prefix:"JessibucaPro_mask_"+e,watermark_txt:"",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:0,watermark_width:150,watermark_height:100,watermark_angle:15,watermark_parent_width:0,watermark_parent_height:0,watermark_parent_node:null},this.player.debug.log("Watermark","int")}destroy(){this._removeMark(),this.globalSetting=null,this.defaultSettings={watermark_id:"",watermark_prefix:"",watermark_txt:"",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:0,watermark_width:150,watermark_height:100,watermark_angle:15,watermark_parent_width:0,watermark_parent_height:0,watermark_parent_node:null},this.player.debug.log("Watermark","destroy")}remove(){this._removeMark()}load(e){this.globalSetting=e,this._loadMark(e)}resize(){this.globalSetting&&this._loadMark(this.globalSetting)}_loadMark(){let e=this.defaultSettings;if(1===arguments.length&&"object"==typeof arguments[0]){var t,i=arguments[0]||{};for(t in i)i[t]&&e[t]&&i[t]===e[t]||!i[t]&&0!==i[t]||(e[t]=i[t])}var r=document.getElementById(e.watermark_id),s=(r&&r.parentNode&&r.parentNode.removeChild(r),"string"==typeof e.watermark_parent_node?document.getElementById(e.watermark_parent_node):e.watermark_parent_node),a=(r=s||document.body,r.getBoundingClientRect()),n=Math.max(r.scrollWidth,r.clientWidth,a.width),o=Math.max(r.scrollHeight,r.clientHeight,a.height),l=(a=arguments[0]||{},a=((a.watermark_parent_width||a.watermark_parent_height)&&r&&(e.watermark_x=e.watermark_x+0,e.watermark_y=e.watermark_y+0),document.getElementById(e.watermark_id)),null);a?a.shadowRoot&&(l=a.shadowRoot):((a=document.createElement("div")).id=e.watermark_id,a.setAttribute("style","pointer-events: none !important; display: block !important"),l="function"==typeof a.attachShadow?a.attachShadow({mode:"open"}):a,(h=r.children)[c=Math.floor(Math.random()*(h.length-1))]?r.insertBefore(a,h[c]):r.appendChild(a)),e.watermark_cols=parseInt((n-e.watermark_x)/(e.watermark_width+e.watermark_x_space));var d,h=parseInt((n-e.watermark_x-e.watermark_width*e.watermark_cols)/e.watermark_cols);e.watermark_x_space=h&&e.watermark_x_space,e.watermark_rows=parseInt((o-e.watermark_y)/(e.watermark_height+e.watermark_y_space));var c=parseInt((o-e.watermark_y-e.watermark_height*e.watermark_rows)/e.watermark_rows);e.watermark_y_space=c&&e.watermark_y_space;for(var u=s?(d=e.watermark_x+e.watermark_width*e.watermark_cols+e.watermark_x_space*(e.watermark_cols-1),e.watermark_y+e.watermark_height*e.watermark_rows+e.watermark_y_space*(e.watermark_rows-1)):(d=0+e.watermark_x+e.watermark_width*e.watermark_cols+e.watermark_x_space*(e.watermark_cols-1),0+e.watermark_y+e.watermark_height*e.watermark_rows+e.watermark_y_space*(e.watermark_rows-1)),p=0;p<e.watermark_rows;p++)for(var f=s?0+e.watermark_y+(o-u)/2+(e.watermark_y_space+e.watermark_height)*p:e.watermark_y+(o-u)/2+(e.watermark_y_space+e.watermark_height)*p,m=0;m<e.watermark_cols;m++){var g=s?0+e.watermark_x+(n-d)/2+(e.watermark_width+e.watermark_x_space)*m:e.watermark_x+(n-d)/2+(e.watermark_width+e.watermark_x_space)*m,y=document.createElement("div"),A=document.createTextNode(e.watermark_txt);y.appendChild(A),y.id=e.watermark_prefix+p+m,y.style.webkitTransform="rotate(-"+e.watermark_angle+"deg)",y.style.MozTransform="rotate(-"+e.watermark_angle+"deg)",y.style.msTransform="rotate(-"+e.watermark_angle+"deg)",y.style.OTransform="rotate(-"+e.watermark_angle+"deg)",y.style.transform="rotate(-"+e.watermark_angle+"deg)",y.style.visibility="",y.style.position="absolute",y.style.left=g+"px",y.style.top=f+"px",y.style.overflow="hidden",y.style.zIndex="9999999",y.style.opacity=e.watermark_alpha,y.style.fontSize=e.watermark_fontsize,y.style.fontFamily=e.watermark_font,y.style.color=e.watermark_color,y.style.textAlign="center",y.style.width=e.watermark_width+"px",y.style.height=e.watermark_height+"px",y.style.display="block",y.style["-ms-user-select"]="none",l.appendChild(y)}}_removeMark(){var e,t=this.defaultSettings;t=document.getElementById(t.watermark_id);t&&(e=t.parentNode)&&e.removeChild(t)}}class gn extends r{constructor(){let e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};super(),this._opt={},Object.keys(e).forEach(t=>{if(void 0===e[t])throw new Error(`JbPro option "${t}" can not be undefined`)}),this.originalOptions=e;var t,i=Ht();let r=Object.assign({},i,e),s=(r.url="",r.isMulti&&(r.debugUuid="xxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))),this.debug=new Fe(this),e.container);if(!(s="string"==typeof e.container?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("CANVAS"===s.nodeName||"VIDEO"===s.nodeName)throw this.debug.error("JbPro",`JbPro container type can not be ${s.nodeName} type`),new Error(`JbPro container type can not be ${s.nodeName} type`);if(r.videoBuffer>=r.heartTimeout)throw this.debug.error("JbPro",`JbPro videoBuffer ${r.videoBuffer}s must be less than heartTimeout ${r.heartTimeout}s`),new Error(`JbPro videoBuffer ${r.videoBuffer}s must be less than heartTimeout ${r.heartTimeout}s`);if(s.classList.add("jessibuca-container"),i=s,t=ct(),i&&(i.dataset?i.dataset.jbprov=t:i.setAttribute("data-jbprov",t)),$t(r.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=r)}delete r.container,_t(r.videoBuffer)&&(r.videoBuffer=1e3*Number(r.videoBuffer)),_t(r.videoBufferDelay)&&(r.videoBufferDelay=1e3*Number(r.videoBufferDelay)),_t(r.networkDelay)&&(r.networkDelay=1e3*Number(r.networkDelay)),_t(r.timeout)&&(bt(r.loadingTimeout)&&(r.loadingTimeout=r.timeout),bt(r.heartTimeout)&&(r.heartTimeout=r.timeout)),this._opt=r,this._destroyed=!1,this.$container=s,this._tempPlayBgBase64="",this._loadingTimeoutReplayTimes=0,this._heartTimeoutReplayTimes=0,this.events=new qt(this),this.watermark=new mn(this),this._initPlayer(s,r),this._initWatermark(),this.debug.log("JbPro",'init success and version is "7-18-2023"'),console.log('JbPro version is "7-18-2023"')}destroy(){return new Promise((e,t)=>{this.debug.log("JbPro","destroy()"),this._destroyed=!0,this.off(),this.$videoElement&&(this.$videoElement.pause(),this.$videoElement.currentTime=0,this.$videoElement.srcObject&&(this.$videoElement.srcObject=null,this.$videoElement.removeAttribute("srcObject")),this.$videoElement.src&&(this.$videoElement.src="",this.$videoElement.removeAttribute("src")),this.$container.removeChild(this.$videoElement),this.$videoElement=null),this.player?this.player.destroy().then(()=>{this.player=null,this._destroy(),setTimeout(()=>{e()},0)}).catch(()=>{t()}):(this._destroy(),setTimeout(()=>{e()},0))})}_destroy(){var e;this.events&&(this.events.destroy(),this.events=null),this.talk&&(this.talk.destroy(),this.talk=null),this.watermark&&(this.watermark.destroy(),this.watermark=null),this.$container&&(this.$container.classList.remove("jessibuca-container"),e=this.$container,e&&(e.dataset?delete e.dataset.jbprov:e.removeAttribute("data-jbprov")),this.$container=null),this.debug&&this.debug.log("JbPro","destroy end"),this._resetOpt(),this._tempPlayBgBase64="",this._loadingTimeoutReplayTimes=0,this._heartTimeoutReplayTimes=0}_resetOpt(){this._opt=Ht()}_initPlayer(e,t){this.player=new hn(e,t),this.debug.log("JbPro","_initPlayer",this.player.getOption()),this._bindEvents()}_initTalk(){let e=0<arguments.length&&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 fn(this.player,e),this.debug.log("JbPro","_initTalk",this.talk.getOption()),this._bindTalkEvents()}_resetPlayer(){let e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return new Promise((t,i)=>{const r=()=>{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,r(),setTimeout(()=>{t()},0)}):(r(),setTimeout(()=>{t()},0))})}_bindEvents(){var e=this;Object.keys(F).forEach(t=>{this.player.on(F[t],(function(){for(var i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];e.emit(t,...r)}))}),this.player.once(U.beforeDestroy,()=>{this.emit(U.close),this.destroy().then(()=>{}).catch(e=>{})}),this.player.on(U.resize,()=>{this.watermark&&this.watermark.resize(),this.player.singleWatermark&&this.player.singleWatermark.resize()}),this.player.on(U.fullscreen,()=>{this.watermark&&this.watermark.resize(),this.player.singleWatermark&&this.player.singleWatermark.resize()}),this.player.on(U.videoInfo,()=>{this.player.singleWatermark&&this.player.singleWatermark.resize()})}_bindTalkEvents(){Object.keys(M).forEach(e=>{this.player.on(M[e],t=>{this.emit(e,t)})})}_initWatermark(){var e;this._opt.fullscreenWatermarkConfig.text=decodeURIComponent("JessibucaPro%20%E4%BD%93%E9%AA%8C"),this._opt.fullscreenWatermarkConfig.color="white",Lt(this._opt.fullscreenWatermarkConfig)&&((e=St(this.$container,this._opt.fullscreenWatermarkConfig)).watermark_txt?this.watermark.load(e):this.debug.warn("JbPro","fullscreenWatermarkConfig text is empty"))}_checkHasCreated(e){return!!e&&(e=e,!(!e||!(e.dataset?e.dataset.jbprov:e.getAttribute("data-jbprov"))))}isDestroyed(){return this._destroyed}getOption(){return this.player?this.player.getOption():{}}setDebug(e){this.debug.log("JbPro","setDebug() "+e),this._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?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=0<arguments.length&&void 0!==arguments[0]&&arguments[0];return new Promise((t,i)=>{if(this.debug.log("JbPro","pause() "+e),this._opt.pauseAndNextPlayUseLastFrameShow){const e=this.screenshot("","png",.92,"base64");e&&(this._tempPlayBgBase64=e)}this._pause(e).then(e=>{t(e)}).catch(e=>{i(e)})})}_pause(){let e=0<arguments.length&&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.player?this.player.pause(e).then(e=>{t(e)}).catch(e=>{i(e)}):i("player is null")})}close(){return new Promise((e,t)=>{this.debug.log("JbPro","close()"),this._opt.url="",this._loadingTimeoutReplayTimes=0,this._heartTimeoutReplayTimes=0,this.player?this.player.close().then(()=>{e()}).catch(e=>{t(e)}):t("player is null")})}clearView(){this.debug.log("JbPro","clearView()"),this.player&&this.player.video?this.getRenderType()===A?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=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return new Promise((i,r)=>{if(this.debug.log("JbPro","play() "+e),!e&&!this._opt.url)return this.emit(U.error,O.playError),void r("url is null and this._opt.url is null");if(e=e&&(""+e).trim(),$t(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.isCrypto){var s,a=t.cryptoKey||this._opt.playOptions.cryptoKey,n=t.cryptoIV||this._opt.playOptions.cryptoIV;if(!a||!n)return s=e||this._opt.url,void this._cryptoPlay(s).then(s=>{var{cryptoIV:s,cryptoKey:a}=s;this._opt.playOptions.cryptoKey=a,this._opt.playOptions.cryptoIV=s,t.cryptoIV=s,t.cryptoKey=a,this._playBefore(e,t).then(()=>{i()}).catch(e=>{r(e)})}).catch(e=>{r(e)});this._opt.playOptions.cryptoKey=a,this._opt.playOptions.cryptoIV=n,t.cryptoIV=n,t.cryptoKey=a}this._playBefore(e,t).then(()=>{i()}).catch(e=>{r(e)})})}_playBefore(e,t){return new Promise((i,r)=>{var s;this.player?e?this._opt.url?e===this._opt.url?this.player.playing?(this.debug.log("JbPro","_playBefore","playing and resolve()"),i()):(this.debug.log("JbPro","_playBefore","this._opt.url === url and pause -> play"),s=this._opt.playOptions,this._opt.pauseAndNextPlayUseLastFrameShow&&this._tempPlayBgBase64&&this.player.updateOption({loadingBackground:this._tempPlayBgBase64}),this.player.play(this._opt.url,s).then(()=>{i(),this.player.resumeAudioAfterPause()}).catch(e=>{this.debug.error("JbPro","_playBefore this.player.play error",e),this.emit(U.crashLog,this.getCrashLog("this.player.play 1",e)),this.player.pause().then(()=>{r(e)})})):(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`),this._pause().then(()=>{this._resetPlayer().then(()=>{this._play(e,t).then(()=>{i()}).catch(e=>{this.debug.error("JbPro","_play error",e),this.emit(U.crashLog,this.getCrashLog("this.player.play 2",e)),r(e)})}).catch(()=>{})}).catch(e=>{this.debug.error("JbPro","this.player.pause error",e),r(e)})):this._play(e,t).then(()=>{i()}).catch(e=>{this.debug.error("JbPro","_play error",e),this.emit(U.crashLog,this.getCrashLog("this.player.play 3",e)),r(e)}):this.player.play(this._opt.url,this._opt.playOptions).then(()=>{i(),this.player.resumeAudioAfterPause()}).catch(e=>{this.debug.error("JbPro","this.player.play error",e),this.emit(U.crashLog,this.getCrashLog("this.player.play 4",e)),this.player.pause().then(()=>{r(e)})}):e?this._play(e,t).then(()=>{i()}).catch(e=>{this.debug.error("JbPro","_play error",e),this.emit(U.crashLog,this.getCrashLog("this.player.play 5",e)),r(e)}):this._play(this._opt.url,this._opt.playOptions).then(()=>{i()}).catch(e=>{this.debug.error("JbPro","_play error",e),this.emit(U.crashLog,this.getCrashLog("this.player.play 6",e)),r(e)})})}_cryptoPlay(e){return new Promise((t,i)=>{var r,s=function(){const t=(e||document.location.toString()).split("//"),i=t[1].indexOf("/");let r=t[1].substring(i);return-1!=r.indexOf("?")?r.split("?")[0]:r}();let a=this._opt.cryptoKeyUrl,n="";if(a)n=a;else{const t=function(e){const t=/(msie|trident)/i.test(navigator.userAgent),i=document.createElement("a");let r=e;return t&&(i.setAttribute("href",r),r=i.href),i.setAttribute("href",r),{origin:i.origin,href:i.href,protocol:i.protocol?i.protocol.replace(/:$/,""):"",host:i.host,search:i.search?i.search.replace(/^\?/,""):"",hash:i.hash?i.hash.replace(/^#/,""):"",hostname:i.hostname,port:i.port,pathname:"/"===i.pathname.charAt(0)?i.pathname:"/"+i.pathname}}(e);a=t.origin+"/crypto/",n=a+"?stream="+s}r=n,new Promise((e,t)=>{Cr.get(r).then(t=>{e(t)}).catch(e=>{t(e)})}).then(e=>{if(e){const r=e.split("."),s=zt(r[0]),a=zt(r[1]);a&&s?t({cryptoIV:a,cryptoKey:s}):i("get cryptoIV or cryptoKey error")}else i(`cryptoKeyUrl: getM7SCryptoStreamKey ${n} res is null`)}).catch(e=>{i(e)})})}playback(e){let t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return new Promise((i,r)=>{if(this.debug.log("JbPro","playback() "+e),$t(this._opt.isLive))return r("this._opt.isLive is false, can not playback");const s=Wt(),a=Object.assign({},s.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")),this._resetPlayer({videoBuffer:0,playbackConfig:a,playType:d,openWebglAlignment:!0,useMSE:!1,useWCS:a.useWCS,useSIMD:!0}).then(()=>{this.play(e).then(()=>{i()}).catch(e=>{r(e)})}).catch(e=>{r(e)})})}playbackPause(){let e=0<arguments.length&&void 0!==arguments[0]&&arguments[0];return this.debug.log("JbPro","playbackPause() "+e),this._opt.playType===o?Promise.reject("playType is player, can not call playbackPause method"):new Promise((t,i)=>{if(!this.player)return i("player is null");Kt(e)?this._pause().then(()=>{t()}).catch(e=>{i(e)}):(this.player.playbackPause=!0,t())})}playbackResume(){return this.debug.log("JbPro","playbackResume()"),this._opt.playType===o?Promise.reject("playType is player, can not call playbackResume method"):new Promise((e,t)=>{if(!this.player)return t();this.player.playbackPause=!1,e()})}forward(e){return this.debug.log("JbPro","forward() "+e),$t(this._opt.isLive)||this._opt.playType===o?Promise.reject("forward() method only just for playback type"):ft(Number(e))?new Promise((t,i)=>{this.player?(e=Je(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.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=Je(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);var t=Ct(e);this.player?this.player.isPlayback()?t<10&&0!==e?this.debug.warn("JbPro",`timestamp: ${e} is not valid`):this.player.playing&&(10===t&&(e*=1e3),this.player.playback.setStartTime(e),this.playbackClearCacheBuffer()):this.debug.warn("JbPro","playType is not playback"):this.debug.warn("JbPro","player is null")}playbackClearCacheBuffer(){this.debug.log("JbPro","playbackClearCacheBuffer()"),this.player?this.player.isPlayback()?(this.player.video&&this.player.video.clear(),this.player.audio&&this.player.audio.clear(),this.player.decoderWorker.clearWorkBuffer(!0)):this.debug.warn("JbPro","playType is not playback"):this.debug.warn("JbPro","player is null")}getPlaybackCurrentRate(){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){this.debug.log("JbPro","setStreamQuality() "+e),this.player?this.player._opt.operateBtns.quality?(this.player._opt.qualityConfig||[]).includes(e)?this.player.streamQuality=e:this.debug.warn("JbPro",`quality: ${e} is not in qualityList`):this.debug.warn("JbPro","player._opt.operateBtns.quality is false"):this.debug.warn("JbPro","player is null")}_play(){let e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return new Promise((i,r)=>{if(!this.player)return r("player is null");let s=!1;this._opt.url&&this._opt.url!==e&&(s=!0),this._opt.url=e,this._opt.playOptions=t;var a=0===e.indexOf("http"),n=0===e.indexOf("webrtc"),o=0===e.indexOf("wt"),l=!n&&-1!==e.indexOf(".m3u8"),d=!n&&-1!==e.indexOf(".flv"),h=!n&&-1!==e.indexOf(".fmp4")||!n&&-1!==e.indexOf(".mp4"),c=!n&&-1!==e.indexOf(".mpeg4"),y=!n&&-1!==e.indexOf(".h264")||!n&&-1!==e.indexOf(".h265");if(this._opt.isWebrtcForZLM=!1,this._opt.isWebrtc=!1,this._opt.isFmp4=!1,this._opt.isMpeg4=!1,this._opt.isNakedFlow=!1,this._opt.isHls=!1,n&&-1!==e.indexOf("/index/api/webrtc")&&(this._opt.isWebrtcForZLM=!0),d&&!this._opt.isFlv&&(this._opt.isFlv=!0),h&&!this._opt.isFmp4&&(this._opt.isFmp4=!0),c&&!this._opt.isMpeg4&&(this._opt.isMpeg4=!0),y&&!this._opt.isNakedFlow&&(this._opt.isNakedFlow=!0),h=a?l?3:2:o?5:n?4:1,y=this._opt.isNakedFlow?f:this._opt.isFmp4?m:this._opt.isMpeg4?g:a&&!l||d||this._opt.isFlv?u:l?"hls":n?"webrtc":o?p:"m7s",!h||!y)return r(`play protocol is ${h}, demuxType is `+y);const A=()=>{this.player.once(O.webglAlignmentError,e=>{this.emit(U.crashLog,this.getCrashLog(O.webglAlignmentError,e)),this._pause().then(()=>{if(this.player&&this.player._opt.webglAlignmentErrorReplay){this.debug.log("JbPro","webglAlignmentError");const e=this._opt.url;this._resetPlayer({openWebglAlignment:!0}).then(()=>{this.play(e).then(()=>{this.debug.log("JbPro","webglAlignmentError and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.webglAlignmentError),this.debug.error("JbPro","webglAlignmentError and play error",e)})}).catch(e=>{this.debug.error("JbPro","webglAlignmentError and _resetPlayer error",e)})}else this.emit(U.playFailedAndPaused,O.webglAlignmentError),this.debug.log("JbPro","webglAlignmentError and webglAlignmentErrorReplay is false")}).catch(e=>{this.debug.error("JbPro","webglAlignmentError and pause error",e)})}),this.player.once(O.webglContextLostError,e=>{this.emit(U.crashLog,this.getCrashLog(O.webglContextLostError,e)),this._pause().then(()=>{if(this.player&&this.player._opt.webglContextLostErrorReplay){this.debug.log("JbPro","webglContextLostError");const t=this._opt.url,i={};var e;this.player._opt.replayUseLastFrameShow&&(e=this.screenshot("","png",.92,"base64"),i.loadingBackground=e),this._resetPlayer(i).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","webglContextLostError and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.webglContextLostError),this.debug.error("JbPro","webglContextLostError and play error",e)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.webglContextLostError),this.debug.error("JbPro","webglContextLostError and _resetPlayer error",e)})}else this.emit(U.playFailedAndPaused,O.webglContextLostError),this.debug.log("JbPro","webglContextLostError and webglContextLostErrorReplay is false")}).catch(e=>{this.emit(U.playFailedAndPaused,O.webglContextLostError),this.debug.error("JbPro","webglAlignmentError and pause error",e)})}),this.player.once(O.mediaSourceH265NotSupport,e=>{this.emit(U.crashLog,this.getCrashLog(O.mediaSourceH265NotSupport,e)),this._pause().then(()=>{if(this.player&&this.player._opt.autoWasm){this.debug.log("JbPro","mediaSourceH265NotSupport auto wasm [mse-> wasm] reset player and play");const e=this._opt.url;this._resetPlayer({useMSE:!1,useWCS:!1}).then(()=>{this.play(e).then(()=>{this.debug.log("JbPro","mediaSourceH265NotSupport auto wasm [mse-> wasm] reset player and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.mediaSourceH265NotSupport),this.debug.error("JbPro","mediaSourceH265NotSupport auto wasm [mse-> wasm] reset player and play error",e)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.mediaSourceH265NotSupport),this.debug.error("JbPro","mediaSourceH265NotSupport auto wasm [mse-> wasm] _resetPlayer error",e)})}else this.emit(U.playFailedAndPaused,O.mediaSourceH265NotSupport),this.debug.log("JbPro","mediaSourceH265NotSupport and autoWasm is false")}).catch(e=>{this.emit(U.playFailedAndPaused,O.mediaSourceH265NotSupport),this.debug.error("JbPro","mediaSourceH265NotSupport and pause error",e)})}),this.player.once(O.mediaSourceFull,e=>{this.emit(U.crashLog,this.getCrashLog(O.mediaSourceFull,e)),this._pause().then(()=>{if(this.player&&this.player._opt.mseDecodeErrorReplay){const t=this._opt.url;let i={};var e;this.player._opt.autoWasm&&(i={useMSE:!1,useWCS:!1}),this.debug.log("JbPro",`mediaSourceFull and auto wasm [mse-> ${this.player._opt.autoWasm?"wasm":"mse"}] reset player and play`),this.player._opt.replayUseLastFrameShow&&(e=this.screenshot("","png",.92,"base64"),i.loadingBackground=e),this._resetPlayer(i).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","mediaSourceFull and reset player and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.mediaSourceFull),this.debug.error("JbPro","mediaSourceFull and reset player and play error",e)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.mediaSourceFull),this.debug.error("JbPro","mediaSourceFull and _resetPlayer error",e)})}else this.emit(U.playFailedAndPaused,O.mediaSourceFull),this.debug.log("JbPro","mediaSourceFull and autoWasm is false")}).catch(e=>{this.emit(U.playFailedAndPaused,O.mediaSourceFull),this.debug.error("JbPro","mediaSourceFull and pause error",e)})}),this.player.once(O.mediaSourceAppendBufferError,e=>{this.emit(U.crashLog,this.getCrashLog(O.mediaSourceAppendBufferError,e)),this._pause().then(()=>{if(this.player&&this.player._opt.mseDecodeErrorReplay){const t=this._opt.url;let i={};var e;this.player._opt.autoWasm&&(i={useMSE:!1,useWCS:!1}),this.debug.log("JbPro",`mediaSourceAppendBufferError and auto wasm [mse-> ${this.player._opt.autoWasm?"wasm":"mse"}] reset player and play`),this.player._opt.replayUseLastFrameShow&&(e=this.screenshot("","png",.92,"base64"),i.loadingBackground=e),this._resetPlayer(i).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","mediaSourceAppendBufferError and reset player and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.mediaSourceAppendBufferError),this.debug.error("JbPro","mediaSourceAppendBufferError and reset player and play error",e)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.mediaSourceAppendBufferError),this.debug.error("JbPro","mediaSourceAppendBufferError and _resetPlayer error",e)})}else this.emit(U.playFailedAndPaused,O.mediaSourceAppendBufferError),this.debug.log("JbPro","mediaSourceAppendBufferError and autoWasm is false")}).catch(e=>{this.emit(U.playFailedAndPaused,O.mediaSourceAppendBufferError),this.debug.error("JbPro","mediaSourceAppendBufferError and pause error",e)})}),this.player.once(O.mediaSourceBufferListLarge,e=>{this.emit(U.crashLog,this.getCrashLog(O.mediaSourceBufferListLarge,e)),this._pause().then(()=>{if(this.player&&this.player._opt.mseDecodeErrorReplay){const t=this._opt.url;let i={};var e;this.player._opt.autoWasm&&(i={useMSE:!1,useWCS:!1}),this.debug.log("JbPro",`media source buffer list large and auto wasm [mse-> ${this.player._opt.autoWasm?"wasm":"mse"}] reset player and play`),this.player._opt.replayUseLastFrameShow&&(e=this.screenshot("","png",.92,"base64"),i.loadingBackground=e),this._resetPlayer(i).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","media source buffer list large and reset player and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.mediaSourceBufferListLarge),this.debug.error("JbPro","media source buffer list large and reset player and play error",e)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.mediaSourceBufferListLarge),this.debug.error("JbPro","media source buffer list large and _resetPlayer error",e)})}else this.emit(U.playFailedAndPaused,O.mediaSourceBufferListLarge),this.debug.log("JbPro","media source buffer list large and autoWasm is false")}).catch(e=>{this.emit(U.playFailedAndPaused,O.mediaSourceBufferListLarge),this.debug.error("JbPro","media source buffer list large and pause error",e)})}),this.player.once(O.mediaSourceAppendBufferEndTimeout,e=>{this.emit(U.crashLog,this.getCrashLog(O.mediaSourceAppendBufferEndTimeout,e)),this._pause().then(()=>{if(this.player&&this.player._opt.mseDecodeErrorReplay){const t=this._opt.url;let i={};var e;this.player._opt.autoWasm&&(i={useMSE:!1,useWCS:!1}),this.debug.log("JbPro",`media source append buffer end timeout and auto wasm [mse-> ${this.player._opt.autoWasm?"wasm":"mse"}] reset player and play`),this.player._opt.replayUseLastFrameShow&&(e=this.screenshot("","png",.92,"base64"),i.loadingBackground=e),this._resetPlayer(i).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","media source append buffer end timeout and reset player and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.mediaSourceAppendBufferEndTimeout),this.debug.error("JbPro","media source append buffer end timeout and reset player and play error",e)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.mediaSourceAppendBufferEndTimeout),this.debug.error("JbPro","media source append buffer end timeout and _resetPlayer error",e)})}else this.emit(U.playFailedAndPaused,O.mediaSourceAppendBufferEndTimeout),this.debug.log("JbPro","media source append buffer end timeout and autoWasm is false")}).catch(e=>{this.emit(U.playFailedAndPaused,O.mediaSourceAppendBufferEndTimeout),this.debug.error("JbPro","media source append buffer end timeout and pause error",e)})}),this.player.once(O.mseSourceBufferError,e=>{this.emit(U.crashLog,this.getCrashLog(O.mseSourceBufferError,e)),this._pause().then(()=>{if(this.player&&this.player._opt.mseDecodeErrorReplay){const t=this._opt.url;let i={};var e;this.player._opt.autoWasm&&(i={useMSE:!1,useWCS:!1}),this.debug.log("JbPro",`mseSourceBufferError auto wasm [mse-> ${this.player._opt.autoWasm?"wasm":"mse"}] reset player and play`),this.player._opt.replayUseLastFrameShow&&(e=this.screenshot("","png",.92,"base64"),i.loadingBackground=e),this._resetPlayer(i).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","mseSourceBufferError auto wasm [mse-> wasm] reset player and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.mseSourceBufferError),this.debug.error("JbPro","mseSourceBufferError auto wasm [mse-> wasm] reset player and play error",e)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.mseSourceBufferError),this.debug.error("JbPro","mseSourceBufferError auto wasm [mse-> wasm] _resetPlayer and play error",e)})}else this.emit(U.playFailedAndPaused,O.mseSourceBufferError),this.debug.log("JbPro","mseSourceBufferError and autoWasm is false")}).catch(e=>{this.debug.error("JbPro","mseSourceBufferError and pause error:",e)})}),this.player.once(O.mseAddSourceBufferError,e=>{this.emit(U.crashLog,this.getCrashLog(O.mseAddSourceBufferError,e)),this._pause().then(()=>{if(this.player&&this.player._opt.autoWasm){this.debug.log("JbPro","mseAddSourceBufferError auto wasm [mse-> wasm] reset player and play");const e=this._opt.url;this._resetPlayer({useMSE:!1,useWCS:!1}).then(()=>{this.play(e).then(()=>{this.debug.log("JbPro","mseAddSourceBufferError auto wasm [mse-> wasm] reset player and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.mseAddSourceBufferError),this.debug.error("JbPro","mseAddSourceBufferError auto wasm [mse-> wasm] reset player and play error",e)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.mseAddSourceBufferError),this.debug.error("JbPro","mseAddSourceBufferError auto wasm [mse-> wasm] _resetPlayer and play error",e)})}else this.emit(U.playFailedAndPaused,O.mseAddSourceBufferError),this.debug.log("JbPro","mseAddSourceBufferError and autoWasm is false")}).catch(e=>{this.emit(U.playFailedAndPaused,O.mseAddSourceBufferError),this.debug.error("JbPro","mseAddSourceBufferError and pause error",e)})}),this.player.once(O.mediaSourceDecoderConfigurationError,e=>{this.emit(U.crashLog,this.getCrashLog(O.mediaSourceDecoderConfigurationError,e)),this._pause().then(()=>{if(this.player&&this.player._opt.autoWasm){this.debug.log("JbPro","mediaSourceDecoderConfigurationError auto wasm [mse-> wasm] reset player and play");const e=this._opt.url;this._resetPlayer({useMSE:!1,useWCS:!1}).then(()=>{this.play(e).then(()=>{this.debug.log("JbPro","mediaSourceDecoderConfigurationError auto wasm [mse-> wasm] reset player and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.mediaSourceDecoderConfigurationError),this.debug.error("JbPro","mediaSourceDecoderConfigurationError auto wasm [mse-> wasm] reset player and play error",e)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.mediaSourceDecoderConfigurationError),this.debug.error("JbPro","mediaSourceDecoderConfigurationError auto wasm [mse-> wasm] _resetPlayer and play error",e)})}else this.emit(U.playFailedAndPaused,O.mediaSourceDecoderConfigurationError),this.debug.log("JbPro","mediaSourceDecoderConfigurationError and autoWasm is false")}).catch(e=>{this.emit(U.playFailedAndPaused,O.mediaSourceDecoderConfigurationError),this.debug.error("JbPro","mediaSourceDecoderConfigurationError and pause error",e)})}),this.player.once(O.mediaSourceTsIsMaxDiff,e=>{this.emit(U.crashLog,this.getCrashLog(O.mediaSourceTsIsMaxDiff,e)),this._pause().then(()=>{if(this.player&&this.player._opt.mediaSourceTsIsMaxDiffReplay){this.debug.log("JbPro","mediaSourceTsIsMaxDiff reset player and play");const e=this._opt.url,t={};t.loadingBackground=this.screenshot("","png",.92,"base64"),this._resetPlayer(t).then(()=>{this.play(e).then(()=>{this.debug.log("JbPro","mediaSourceTsIsMaxDiff replay success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.mediaSourceTsIsMaxDiff),this.debug.error("JbPro","mediaSourceTsIsMaxDiff replay error",e)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.mediaSourceTsIsMaxDiff),this.debug.error("JbPro","mediaSourceTsIsMaxDiff _resetPlayer error",e)})}else this.emit(U.playFailedAndPaused,O.mediaSourceTsIsMaxDiff),this.debug.log("JbPro","mediaSourceTsIsMaxDiff and replay is false")}).catch(e=>{this.debug.error("JbPro","mediaSourceTsIsMaxDiff and pause error",e)})}),this.player.once(O.mseWidthOrHeightChange,e=>{this.emit(U.crashLog,this.getCrashLog(O.mseWidthOrHeightChange,e)),this.debug.log("JbPro","mseWidthOrHeightChange and reset player and play");const t=this._opt.url,i=this.screenshot("","png",.92,"base64");this._resetPlayer({loadingBackground:i}).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","mseWidthOrHeightChange and reset player and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.mseWidthOrHeightChange),this.debug.error("JbPro","mseWidthOrHeightChange and reset player and play error",e)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.mseWidthOrHeightChange),this.debug.error("JbPro","mseWidthOrHeightChange and _resetPlayer error",e)})}),this.player.once(O.mediaSourceUseCanvasRenderPlayFailed,e=>{this.emit(U.crashLog,this.getCrashLog(O.mediaSourceUseCanvasRenderPlayFailed,e)),this.debug.log("JbPro","mediaSourceUseCanvasRenderPlayFailed and reset player"),this._pause().then(()=>{this._resetPlayer().then(()=>{this.debug.log("JbPro","mediaSourceUseCanvasRenderPlayFailed and reset player success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.mediaSourceUseCanvasRenderPlayFailed),this.debug.error("JbPro","mediaSourceUseCanvasRenderPlayFailed and reset player error",e)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.mediaSourceUseCanvasRenderPlayFailed),this.debug.error("JbPro","mediaSourceUseCanvasRenderPlayFailed and pause",e)})}),this.player.once(O.webcodecsH265NotSupport,e=>{this.emit(U.crashLog,this.getCrashLog(O.webcodecsH265NotSupport,e)),this._pause().then(()=>{if(this.player&&this.player._opt.autoWasm){this.debug.log("JbPro","webcodecsH265NotSupport auto wasm [wcs-> wasm] reset player and play");const e=this._opt.url;this._resetPlayer({useMSE:!1,useWCS:!1}).then(()=>{this.play(e).then(()=>{this.debug.log("JbPro","webcodecsH265NotSupport auto wasm [wcs-> wasm] reset player and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.webcodecsH265NotSupport),this.debug.error("JbPro","webcodecsH265NotSupport auto wasm [wcs-> wasm] reset player and play error",e)})}).catch(e=>{this.debug.error("JbPro","webcodecsH265NotSupport auto wasm [wcs-> wasm] _resetPlayer and play error",e)})}else this.emit(U.playFailedAndPaused,O.webcodecsH265NotSupport),this.debug.log("JbPro","webcodecsH265NotSupport and autoWasm is false")}).catch(e=>{this.emit(U.playFailedAndPaused,O.webcodecsH265NotSupport),this.debug.error("JbPro","webcodecsH265NotSupport and pause error",e)})}),this.player.once(O.webcodecsUnsupportedConfigurationError,e=>{this.emit(U.crashLog,this.getCrashLog(O.webcodecsUnsupportedConfigurationError,e)),this._pause().then(()=>{if(this.player&&this.player._opt.autoWasm){this.debug.log("Jessibuca","webcodecsUnsupportedConfigurationError auto wasm [wcs-> wasm] reset player and play");const e=this._opt.url;this._resetPlayer({useMSE:!1,useWCS:!1}).then(()=>{this.play(e).then(()=>{this.debug.log("Jessibuca","webcodecsUnsupportedConfigurationError auto wasm [wcs-> wasm] reset player and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.webcodecsUnsupportedConfigurationError),this.debug.error("Jessibuca","webcodecsUnsupportedConfigurationError auto wasm [wcs-> wasm] reset player and play error",e)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.webcodecsUnsupportedConfigurationError),this.debug.error("Jessibuca","webcodecsUnsupportedConfigurationError auto wasm [wcs-> wasm] _resetPlayer and play error",e)})}else this.emit(U.playFailedAndPaused,O.webcodecsUnsupportedConfigurationError),this.debug.log("Jessibuca","webcodecsUnsupportedConfigurationError and autoWasm is false")}).catch(e=>{this.emit(U.playFailedAndPaused,O.webcodecsUnsupportedConfigurationError),this.debug.error("Jessibuca","webcodecsUnsupportedConfigurationError and pause error",e)})}),this.player.once(O.webcodecsDecodeError,e=>{this.emit(U.crashLog,this.getCrashLog(O.webcodecsDecodeError,e)),this._pause().then(()=>{if(this.player&&this.player._opt.wcsDecodeErrorReplay){const t=this._opt.url;let i={};var e;this.player._opt.autoWasm&&(i={useMSE:!1,useWCS:!1}),this.debug.log("JbPro",`webcodecs decode error autoWasm [wcs-> ${this.player._opt.autoWasm?"wasm":"wcs"}] reset player and play`),this.player._opt.replayUseLastFrameShow&&(e=this.screenshot("","png",.92,"base64"),i.loadingBackground=e),this._resetPlayer(i).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","webcodecs decode error reset player and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.webcodecsDecodeError),this.debug.error("JbPro","webcodecs decode error reset player and play error",e)})}).catch(()=>{this.emit(U.playFailedAndPaused,O.webcodecsDecodeError),this.debug.error("JbPro","webcodecs decode error _resetPlayer error")})}else this.emit(U.playFailedAndPaused,O.webcodecsDecodeError),this.debug.log("JbPro","webcodecs decode error and autoWasm is false")}).catch(e=>{this.debug.error("JbPro","webcodecs decode error and pause error",e)})}),this.player.once(O.wcsWidthOrHeightChange,e=>{this.emit(U.crashLog,this.getCrashLog(O.wcsWidthOrHeightChange,e)),this.debug.log("JbPro","wcsWidthOrHeightChange and reset player and play");const t=this._opt.url,i=this.screenshot("","png",.92,"base64");this._resetPlayer({loadingBackground:i}).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","wcsWidthOrHeightChange and reset player and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.wcsWidthOrHeightChange),this.debug.error("JbPro","wcsWidthOrHeightChange and reset player and play error",e)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.wcsWidthOrHeightChange),this.debug.error("JbPro","wcsWidthOrHeightChange and _resetPlayer error",e)})}),this.player.once(O.wasmDecodeError,e=>{this.emit(U.crashLog,this.getCrashLog(O.wasmDecodeError,e)),this._pause().then(()=>{if(this.player&&this.player._opt.wasmDecodeErrorReplay){this.debug.log("JbPro","wasm decode error and reset player and play");const t=this._opt.url,i={};var e;this.player._opt.replayUseLastFrameShow&&(e=this.screenshot("","png",.92,"base64"),i.loadingBackground=e),this._resetPlayer(i).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","wasm decode error and reset player and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.wasmDecodeError),this.debug.error("JbPro","wasm decode error and reset player and play error",e)})}).catch(()=>{this.emit(U.playFailedAndPaused,O.wasmDecodeError),this.debug.error("JbPro","wasm decode error and _resetPlayer error")})}else this.emit(U.playFailedAndPaused,O.wasmDecodeError),this.debug.log("JbPro","wasm decode error and wasmDecodeErrorReplay is false")}).catch(e=>{this.emit(U.playFailedAndPaused,O.wasmDecodeError),this.debug.error("JbPro","wasm decode error and pause error",e)})}),this.player.once(O.simdDecodeError,e=>{this.emit(U.crashLog,this.getCrashLog(O.simdDecodeError,e)),this.debug.log("JbPro","simdDecodeError error and reset player and play");const t=this._opt.url,i=this.screenshot("","png",.92,"base64");this._resetPlayer({loadingBackground:i}).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","simdDecodeError and reset player and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.simdDecodeError),this.debug.error("JbPro","simdDecodeError and reset player and play error",e)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.simdDecodeError),this.debug.error("JbPro","simdDecodeError and _resetPlayer error",e)})}),this.player.once(O.wasmWidthOrHeightChange,e=>{this.emit(U.crashLog,this.getCrashLog(O.wasmWidthOrHeightChange,e)),this.debug.log("JbPro","wasmWidthOrHeightChange and reset player and play");const t=this._opt.url,i=this.screenshot("","png",.92,"base64");this._resetPlayer({loadingBackground:i}).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","wasmWidthOrHeightChange and reset player and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.wasmWidthOrHeightChange),this.debug.error("JbPro","wasmWidthOrHeightChange and reset player and play error",e)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.wasmWidthOrHeightChange),this.debug.error("JbPro","wasmWidthOrHeightChange and _resetPlayer error",e)})}),this.player.once(O.wasmUseVideoRenderError,e=>{this.emit(U.crashLog,this.getCrashLog(O.wasmUseVideoRenderError,e)),this.debug.log("JbPro","wasmUseVideoRenderError and reset player and play");const t=this._opt.url;this._resetPlayer({useVideoRender:!1,useCanvasRender:!0}).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","wasmUseVideoRenderError and reset player and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.wasmUseVideoRenderError),this.debug.error("JbPro","wasmUseVideoRenderError and reset player and play error",e)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.wasmUseVideoRenderError),this.debug.error("JbPro","wasmUseVideoRenderError and _resetPlayer error",e)})}),this.player.once(O.videoElementPlayingFailed,e=>{this.emit(U.crashLog,this.getCrashLog(O.videoElementPlayingFailed,e)),this.debug.log("JbPro","videoElementPlayingFailed and reset player and play");const t=this._opt.url;this._resetPlayer({useVideoRender:!1,useCanvasRender:!0}).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","videoElementPlayingFailed and reset player and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.videoElementPlayingFailed),this.debug.error("JbPro","videoElementPlayingFailed and reset player and play error",e)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.videoElementPlayingFailed),this.debug.error("JbPro","videoElementPlayingFailed and _resetPlayer error",e)})}),this.player.once(O.simdH264DecodeVideoWidthIsTooLarge,e=>{this.emit(U.crashLog,this.getCrashLog(O.simdH264DecodeVideoWidthIsTooLarge,e)),this._pause().then(()=>{this.debug.log("JbPro","simdH264DecodeVideoWidthIsTooLarge and reset player and play");const e=this._opt.url;this._resetPlayer({useSIMD:!1}).then(()=>{this.play(e).then(()=>{this.debug.log("JbPro","simdH264DecodeVideoWidthIsTooLarge and reset player and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,O.simdH264DecodeVideoWidthIsTooLarge),this.debug.error("JbPro","simdH264DecodeVideoWidthIsTooLarge and reset player and play error",e)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.simdH264DecodeVideoWidthIsTooLarge),this.debug.error("JbPro","simdH264DecodeVideoWidthIsTooLarge and _resetPlayer error",e)})}).catch(e=>{this.debug.error("JbPro","simdH264DecodeVideoWidthIsTooLarge and pause error",e)})}),this.player.once(U.networkDelayTimeout,e=>{if(this.player._opt.networkDelayTimeoutReplay){this.emit(U.crashLog,this.getCrashLog(U.networkDelayTimeout,e)),this.debug.log("JbPro","network delay time out and reset player and play");const t=this._opt.url,i={};if(this.player&&this.player._opt.replayUseLastFrameShow){const e=this.screenshot("","png",.92,"base64");i.loadingBackground=e}this._resetPlayer(i).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","wasm decode error and reset player and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,U.networkDelayTimeout),this.debug.error("JbPro","wasm decode error and reset player and play error",e)})}).catch(()=>{this.emit(U.playFailedAndPaused,U.networkDelayTimeout),this.debug.error("JbPro","wasm decode error and _resetPlayer error")})}}),this.player.once(O.fetchError,e=>{this.emit(U.crashLog,this.getCrashLog(O.fetchError,e)),this.debug.log("JbPro","fetch error and reset player"),this._pause().then(()=>{this._resetPlayer().then(()=>{this.emit(U.playFailedAndPaused,O.fetchError)}).catch(()=>{this.emit(U.playFailedAndPaused,O.fetchError)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.fetchError),this.debug.error("JbPro","fetch error and pause",e)})}),this.player.once(U.streamEnd,e=>{this.emit(U.crashLog,this.getCrashLog(U.streamEnd,e)),this.debug.log("JbPro","streamEnd reset player"),this._pause().then(()=>{this._resetPlayer().then(()=>{this.emit(U.playFailedAndPaused,U.streamEnd)}).catch(()=>{this.emit(U.playFailedAndPaused,U.streamEnd)})}).catch(e=>{this.emit(U.playFailedAndPaused,U.streamEnd),this.debug.error("JbPro","streamEnd pause",e)})}),this.player.once(O.websocketError,e=>{this.emit(U.crashLog,this.getCrashLog(O.websocketError,e)),this.debug.log("JbPro","websocketError and reset player"),this._pause().then(()=>{this._resetPlayer().then(()=>{this.emit(U.playFailedAndPaused,O.websocketError)}).catch(()=>{this.emit(U.playFailedAndPaused,O.websocketError)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.websocketError),this.debug.error("JbPro","websocketError and pause",e)})}),this.player.once(O.webrtcError,e=>{this.emit(U.crashLog,this.getCrashLog(O.webrtcError,e)),this.debug.log("JbPro","webrtcError and reset player"),this._pause().then(()=>{this._resetPlayer().then(()=>{this.emit(U.playFailedAndPaused,O.webrtcError)}).catch(()=>{this.emit(U.playFailedAndPaused,O.webrtcError)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.webrtcError),this.debug.error("JbPro","webrtcError and pause",e)})}),this.player.once(O.hlsError,e=>{this.emit(U.crashLog,this.getCrashLog(O.hlsError,e)),this.debug.log("JbPro","hlsError and reset player"),this._pause().then(()=>{this._resetPlayer().then(()=>{this.emit(U.playFailedAndPaused,O.hlsError)}).catch(()=>{this.emit(U.playFailedAndPaused,O.hlsError)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.hlsError),this.debug.error("JbPro","hlsError and pause",e)})}),this.player.once(O.videoElementPlayingFailedForWebrtc,e=>{this.emit(U.crashLog,this.getCrashLog(O.videoElementPlayingFailedForWebrtc,e)),this.debug.log("JbPro","videoElementPlayingFailedForWebrtc and reset player"),this._pause().then(()=>{this._resetPlayer().then(()=>{this.emit(U.playFailedAndPaused,O.videoElementPlayingFailedForWebrtc)}).catch(()=>{this.emit(U.playFailedAndPaused,O.videoElementPlayingFailedForWebrtc)})}).catch(e=>{this.emit(U.playFailedAndPaused,O.videoElementPlayingFailedForWebrtc),this.debug.error("JbPro","videoElementPlayingFailedForWebrtc and pause",e)})}),this.player.once(U.webrtcStreamH265,e=>{this.debug.log("JbPro","webrtcStreamH265 and reset player and play");const t=this._opt.url;this._resetPlayer({isWebrtcH265:!0}).then(()=>{this.play(t).then(()=>{this.debug.log("JbPro","webrtcStreamH265 and reset player and play success")}).catch(e=>{this.emit(U.playFailedAndPaused,U.webrtcStreamH265),this.debug.error("JbPro","webrtcStreamH265 and reset player and play error",e)})}).catch(()=>{this.emit(U.playFailedAndPaused,U.webrtcStreamH265),this.debug.error("JbPro","webrtcStreamH265 and _resetPlayer error")})}),this.player.on(U.delayTimeout,e=>{this.emit(U.crashLog,this.getCrashLog(U.delayTimeout,e)),this.isDestroyed()?this.debug.log("JbPro","delay timeout but player is destroyed"):this._pause().then(()=>{if(this.player&&this.player._opt.heartTimeoutReplay&&(this._heartTimeoutReplayTimes<this.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())this.debug&&this.debug.warn("JbPro","delay timeout replay but player is destroyed");else{this._heartTimeoutReplayTimes+=1;const e=this._opt.url,t={};(this.player._opt.heartTimeoutReplayUseLastFrameShow||this.player._opt.replayUseLastFrameShow)&&(t.loadingBackground=this.screenshot("","png",.92,"base64")),this._resetPlayer(t).then(()=>{this.play(e).then(()=>{}).catch(e=>{this.emit(U.playFailedAndPaused,U.delayTimeout),this.debug.error("JbPro","delay timeout replay error",e)})}).catch(e=>{this.emit(U.playFailedAndPaused,U.delayTimeout),this.debug.error("JbPro","delay timeout _resetPlayer error",e)})}else this.emit(U.playFailedAndPaused,U.delayTimeout),this.player&&this.player.emit(U.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(e=>{this.emit(U.playFailedAndPaused,U.delayTimeout),this.debug.error("JbPro","delay timeout and pause error",e)})}),this.player.on(U.loadingTimeout,e=>{this.emit(U.crashLog,this.getCrashLog(U.loadingTimeout,e)),this.isDestroyed()?this.debug.log("JbPro","loading timeout but player is destroyed"):this._pause().then(()=>{if(this.player&&this.player._opt.loadingTimeoutReplay&&(this._loadingTimeoutReplayTimes<this.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())this.debug&&this.debug.warn("JbPro","delay timeout replay but player is destroyed");else{this._loadingTimeoutReplayTimes+=1;const e=this._opt.url;this._resetPlayer().then(()=>{this.play(e).then(()=>{}).catch(e=>{this.emit(U.playFailedAndPaused,U.loadingTimeout),this.debug.error("JbPro","loading timeout replay error",e)})}).catch(e=>{this.emit(U.playFailedAndPaused,U.loadingTimeout),this.debug.error("JbPro","loading timeout _resetPlayer error",e)})}else this.emit(U.playFailedAndPaused,U.loadingTimeout),this.player&&this.player.emit(U.loadingTimeoutRetryEnd),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(e=>{this.emit(U.playFailedAndPaused,U.loadingTimeout),this.debug.error("JbPro","loading timeout and pause error",e)})}),this._hasLoaded()?this.player.play(e,t).then(()=>{i()}).catch(e=>{this.debug.error("JbPro","_hasLoaded() and play error",e),this.emit(U.crashLog,this.getCrashLog("_hasLoaded() and play error",e)),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(U.decoderWorkerInit,()=>{this.player.play(e,t).then(()=>{i()}).catch(e=>{this.debug.error("JbPro","decoderWorkerInit and play error",e),this.emit(U.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)})})})};l&&$t(this._opt.supportHls265)||n&&$t(this._opt.isWebrtcH265)||s||c?(this.debug.log("JbPro","need reset player"),this._resetPlayer({protocol:h,demuxType:y,isHls:l,isWebrtc:n,url:e}).then(()=>{A()}).catch(e=>{r("reset player error")})):(this.player.updateOption({protocol:h,demuxType:y,isHls:l,isWebrtc:n,isFlv:this._opt.isFlv,isFmp4:this._opt.isFmp4,isMpeg4:this._opt.isMpeg4,isNakedFlow:this._opt.isNakedFlow,cryptoKey:t.cryptoKey||"",cryptoIV:t.cryptoIV||""}),t.cryptoKey&&t.cryptoIV&&(this.player.decoderWorker&&this.player.decoderWorker.updateWorkConfig({key:"cryptoKey",value:t.cryptoKey}),this.player.decoderWorker&&this.player.decoderWorker.updateWorkConfig({key:"cryptoIV",value:t.cryptoIV})),A())})}resize(){this.debug.log("JbPro","resize()"),this.player&&this.player.resize()}setBufferTime(e){this.debug.log("JbPro","setBufferTime() "+e),10<(e=Number(e))&&this.debug.warn("JbPro",`setBufferTime() buffer time is ${e} second, is too large, video will show blank screen until cache ${e} second buffer data`),e*=1e3,this._opt.videoBuffer=e,this.player?this.player.updateOption({videoBuffer:e},!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`),e=1e3*(e=Je(e,.2,100)),this._opt.videoBufferDelay=e,this.player?this.player.updateOption({videoBufferDelay:e},!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),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)}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),e=!!e,this.player?this.player.fullscreen!==e&&(this.player.fullscreen=e):this.debug.warn("JbPro","setFullscreen() player is not ready")}screenshot(e,t,i,r){return this.debug.log("JbPro",`screenshot() ${e} ${t} ${i} `+r),this.player&&this.player.video?this.player.video.screenshot(e,t,i,r):(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,r)=>{if(this.debug.log("JbPro",`startRecord() ${e} `+t),!this.player)return this.debug.warn("JbPro","startRecord() player is not ready"),r("player is not ready");this.player.playing?(this.player.startRecord(e,t),i()):(this.debug.warn("JbPro","startRecord() player is not playing"),r("not playing"))})}stopRecordAndSave(e,t){return new Promise((i,r)=>{this.debug.log("JbPro",`stopRecordAndSave() ${e} `+t),this.player&&this.player.recording?this.player.stopRecordAndSave(e,t).then(e=>{i(e)}).catch(e=>{r(e)}):r("not recording")})}isPlaying(){let e=!1;return this.player&&(this._opt.playType===o?e=this.player.playing:this._opt.playType===d&&(e=$t(this.player.playbackPause)&&this.player.playing)),e}isLoading(){return!!this.player&&this.player.loading}isPause(){let e=!1;return this._opt.playType===o?e=!this.isPlaying()&&!this.isLoading():this._opt.playType===d&&this.player&&(e=this.player.playbackPause),e}isPaused(){return this.isPause()}isPlaybackPause(){let e=!1;return this._opt.playType===d&&this.player?this.player.playbackPause:e}isMute(){let e=!0;return this.player?this.player.isAudioMute():e}isRecording(){return this.player&&this.player.recorder&&this.player.recorder.recording||!1}clearBufferDelay(){this.debug.log("JbPro","clearBufferDelay()"),this.player?this.player.clearBufferDelay():this.debug.warn("JbPro","clearBufferDelay() player is not init")}setNetworkDelayTime(e){this.debug.log("JbPro","setNetworkDelayTime() "+e),(e=Number(e))<1&&this.debug.warn("JbPro",`setNetworkDelayTime() network delay is ${e} second, is too small`),e=1e3*(e=Je(e,1,100)),this._opt.networkDelay=e,this.player?this.player.updateOption({networkDelay:e},!0):this.debug.warn("JbPro","setNetworkDelayTime() player is null")}getDecodeType(){let e="";return this.player?this.player.getDecodeType():e}getRenderType(){let e="";return this.player?this.player.getRenderType():e}getAudioEngineType(){let e="";return this.player?this.player.getAudioEngineType():e}getPlayingTimestamp(){let e=0;return this.player?this.player.getPlayingTimestamp():e}getStatus(){let e="destroy";return this.player?this.player.loading?"loading":this.player.playing?"playing":"paused":e}getPlayType(){return this.player?this.player._opt.playType:o}togglePerformancePanel(e){this.debug.log("JbPro","togglePerformancePanel() "+e);var t=this.player._opt.showPerformance;let i=!t;(i=vt(e)?e:i)!==t?this.player?this.player.togglePerformancePanel(i):this.debug.warn("JbPro","togglePerformancePanel() failed, this.player is not init"):this.debug.warn("JbPro",`togglePerformancePanel() failed, showPerformance is prev: ${t} === now: `+i)}openZoom(){this.debug.log("JbPro","openZoom()"),this.player?this.player.zooming=!0:this.debug.warn("JbPro","openZoom() failed, this.player is not init")}closeZoom(){this.debug.log("JbPro","closeZoom()"),this.player?this.player.zooming=!1:this.debug.warn("JbPro","closeZoom() failed, this.player is not init")}isZoomOpen(){let e=!1;return this.player?this.player.zooming:e}expandZoom(){this.debug.log("JbPro","expandZoom()"),this.player&&this.player.zoom&&this.player.zooming?this.player.zoom.expandPrecision():this.debug.warn("JbPro","expandZoom() failed, zoom is not open or not init")}narrowZoom(){this.debug.log("JbPro","narrowZoom()"),this.player&&this.player.zoom&&this.player.zooming?this.player.zoom.narrowPrecision():this.debug.warn("JbPro","narrowZoom failed, zoom is not open or not init")}getCurrentZoomIndex(){let e=1;return this.player&&this.player.zoom?this.player.zoom.currentZoom:e}startTalk(e){let t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return new Promise((i,r)=>{this.debug.log("JbPro","startTalk()",e,t),this._initTalk(t),this.talk.startTalk(e).then(()=>{i(),this.talk.once(U.talkStreamClose,()=>{this.debug.warn("JbPro","talk stream close"),this.stopTalk().catch(e=>{})}),this.talk.once(U.talkStreamError,e=>{this.debug.warn("JbPro","talk stream error",e),this.stopTalk().catch(e=>{})}),this.talk.once(U.talkStreamInactive,()=>{this.debug.warn("JbPro","talk stream inactive"),this.stopTalk().catch(e=>{})})}).catch(e=>{r(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),bt(e))return i("setNakedFlowFps() fps is empty");i=Je(Number(e),1,100),this._opt.nakedFlowFps=i,this.player?this.player.updateOption({nakedFlowFps:i}):this.debug.warn("JbPro","setNakedFlowFps() player is null"),t()})}getCrashLog(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";if(this.player){const i=this.player.getAllStatsData(),r=this.player;let s={url:this._opt.url,playType:r.isPlayback()?"playback":"live",demuxType:r.getDemuxType(),decoderType:r.getDecodeType(),renderType:r.getRenderType(),videoInfo:{encType:"",width:"",height:""},audioInfo:{encType:"",sampleRate:"",channels:""},audioEngine:r.getAudioEngineType(),allTimes:i.pTs,timestamp:qe(),type:e,error:function(e){const t=Object.prototype.toString;return function(e){switch(t.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return 1;default:try{return e instanceof Error}catch(e){return}}}(e)?e.message:null==e?"":"object"==typeof e?JSON.stringify(e,null,2):String(e)}(t)||e};if(r.video){const e=r.video.videoInfo||{};s.videoInfo={encType:e.encType||"",width:e.width||"",height:e.height||""}}if(r.audio){const e=r.audio.audioInfo||{};s.audioInfo={encType:e.encType||"",sampleRate:e.sampleRate||"",channels:e.channels||""}}return s}}updateDebugLevel(e){this.debug.log("JbPro","updateDebugLevel()",e),e===v||e===_?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){var t;this.debug.log("JbPro","updateFullscreenWatermark()",e),Lt(e)?(this._opt.fullscreenWatermarkConfig=e,(t=St(this.$container,e)).watermark_txt?this.watermark.load(t):this.debug.warn("JbPro","fullscreenWatermarkConfig text is empty")):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()",e),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")}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?this.player.getVideoInfo():e}getAudioInfo(){let e=null;return this.player?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`)}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")}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")})}}gn.ERROR=O,gn.EVENTS=F,window.JessibucaPro=gn,window.WebPlayerPro=gn;class yn extends r{constructor(){let e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};super(),this._opt={},Object.keys(e).forEach(t=>{if(void 0===e[t])throw new Error(`Jessibuca-pro-multi option "${t}" can not be undefined`)});var t=Gt(De);this._opt=Object.assign({},t,e),this.LOG_TAG="jessibucaProMulti";let i=e.container;if(!(i="string"==typeof e.container?document.querySelector(e.container):i))throw new Error("Jessibuca-pro-multi need container option");if("CANVAS"===i.nodeName||"VIDEO"===i.nodeName)throw new Error(`Jessibuca-pro-multi container type can not be ${i.nodeName} type`);i.classList.add("jessibuca-multi-container"),this.maxWindowSize=this._opt.maxSplit*this._opt.maxSplit,this.currentWindowIndex=-1,this.specialLayoutType=null,this.windowList=[],this.$container=i,this.debug=new Fe(this),this.events=new qt(this),this._initWindows(),this._initEvents(),this._handleWindowSelect(0),this._listenFullscreenChange()}destroy(){return new Promise((e,t)=>{if(this.debug.log(this.LOG_TAG,"destroy()"),this.off(),this.events&&(this.events.destroy(),this.events=null),this.specialLayoutType=null,this.windowList){const i=[];this.windowList.forEach(e=>{e.$playerContainerEvents.forEach(e=>{e()}),e.player&&i.push(e.player.destroy())}),Promise.all(i).then(()=>{this.windowList.forEach(e=>{e.player=null}),this.windowList=[],e()}).catch(e=>{t(e)})}else e();this.debug&&this.debug.log(this.LOG_TAG,"destroy")})}_createPlayer(e){const t=this._findWindowItemIndex(e),i=this._opt,r=(i.supportDblclickContainerFullscreen&&(i.supportDblclickFullscreen=!1),new gn({...i,isMulti:!0,container:e.$player}));return Object.keys(F).forEach(e=>{r.on(F[e],i=>{this.emit(e,t,i)})}),r.on(U.close,()=>{this.emit(U.close,t),e.player=null}),r}_initWindows(){const e=this._getContainerRect(),t=e.width,i=e.height;let r="";var s,a,n,o,l=this._opt.split,d=t%l,h=i%l,c=(t-d-2*l)/l,u=(i-h-2*l)/l,p=(t-d)/l,f=(i-h)/l;for(let y=0;y<this.maxWindowSize;y++)s=c+(y%l==l-1?d:0),a=u+(y+l>=Math.pow(l,2)?h:0),n=p+(y%l==l-1?d:0),o=f+(y+l>=Math.pow(l,2)?h:0),r+=`\n <div class="jessibuca-multi-player" wid="${y}" style='float: left;position:relative;overflow: hidden; background-color:${this._opt.style.background};width: ${n+"px"};height: ${o+"px"}'>\n <div class="jessibuca-multi-player-draw-window" wid="${y}" style='position:absolute; z-index: 1; width:${s+"px"}; height:${a+"px"};border: 1px solid ${this._opt.style.border}'></div>\n <div class="jessibuca-multi-player-video-window" wid="${y}" style='position:absolute;left: 1px;top:1px; z-index: 2; width:${s+"px"}; height:${a+"px"};'></div>\n </div>\n `;var m=`<div class="jessibuca-multi-player-container" style="overflow: hidden;width:100%; height:100%; position: relative;">${r}</div>`,g=(this.$container.innerHTML=m,this.$container.querySelectorAll(".jessibuca-multi-player"));for(let y=0;y<this.maxWindowSize;y++){const e=g[y],t=e.querySelector(".jessibuca-multi-player-draw-window"),i=e.querySelector(".jessibuca-multi-player-video-window");this.windowList[y]={uuid:ct(),isContainerFullscreen:!1,$playerContainer:e,$playerBorder:t,$player:i,$playerContainerEvents:[],player:null}}for(let y=this._getCurrentMaxSplit();y<this.maxWindowSize;y++){const e=this.windowList[y];e.$player.style.display="none",e.$playerBorder.style.display="none",e.$playerContainer.style.width="0",e.$playerContainer.style.height="0"}}_initEvents(){const e=this.events["proxy"];this.windowList.forEach((t,i)=>{var r=t.$playerContainer,s=e(r,"click",()=>{this.emit(Re.selected,i),this.getSelectedWindowIndex()===i&&this.windowList[i].isContainerFullscreen||1!==this._opt.split&&this._handleWindowSelect(i)}),a=e(r,"dblclick",()=>{this.emit(Re.dblSelected,i),this._opt.supportDblclickContainerFullscreen&&1!==this._opt.split&&this._handleWindowContainerFullscreen(i)}),n=e(r,"mouseup",()=>{this.emit(Re.mouseUp,i)}),o=e(r,"mouseover",()=>{this.emit(Re.mouseOver,i)});r=e(r,"mouseout",()=>{this.emit(Re.mouseOut,i)});t.$playerContainerEvents=[s,n,o,r,a]})}_getContainerRect(){var e=this.$container.getBoundingClientRect();return{width:Math.max(e.width,this.$container.clientWidth),height:Math.max(e.height,this.$container.clientHeight)}}_updateWindows(){const e=this._getContainerRect(),t=e.width,i=e.height,r=this._opt.split,s=t%r,a=i%r,n=(t-s-2*r)/r,o=(i-a-2*r)/r,l=(t-s)/r,d=(i-a)/r;let h=this._getCurrentMaxSplit();for(let c=0;c<h;c++){const e=this.windowList[c],t=(e.isContainerFullscreen=!1,e.$playerContainer),i=(t.style.position="relative",t.style.left="auto",t.style.top="auto",t.style.zIndex="auto",e.$playerBorder),h=e.$player,u=n+(c%r==r-1?s:0),p=o+(c+r>=Math.pow(r,2)?a:0),f=l+(c%r==r-1?s:0),m=d+(c+r>=Math.pow(r,2)?a:0);t.style.width=f+"px",t.style.height=m+"px",t.style.display="block",h.style.width=u+"px",h.style.height=p+"px",h.style.display="block",i.style.width=u+"px",i.style.height=p+"px",i.style.display="block",e.player&&e.player.resize()}if(this.specialLayoutType){const e=this.windowList[0],t=e.$playerContainer,i=e.$player,r=e.$playerBorder,s=t.style.width.replace("px",""),a=t.style.height.replace("px",""),n=i.style.width.replace("px",""),o=i.style.height.replace("px","");let l,d,c,u;this.specialLayoutType===Ie?(l=2*s,d=2*a,c=2*n+2,u=2*o+2):this.specialLayoutType===Pe&&(l=3*s,d=3*a,c=3*n+4,u=3*o+4),t.style.width=l+"px",t.style.height=d+"px",i.style.width=c+"px",i.style.height=u+"px",r.style.width=c+"px",r.style.height=u+"px",e.player&&e.player.resize(),h=this._getSpecialMaxSplit()}for(let c=h;c<this.maxWindowSize;c++){const e=this.windowList[c];e.player&&(e.player.destroy(),e.player=null),e.$playerContainer.style.display="none",e.$playerContainer.style.width="0",e.$playerContainer.style.height="0",e.$player.style.display="none",e.$playerBorder.style.display="none"}1===this._opt.split&&(this.windowList[0].$playerBorder.style.display="none")}_handleWindowSelect(e){const t=this.windowList[e];t?(this.currentWindowIndex=e,1<this.windowList.length&&(this.windowList.forEach(e=>{t.$playerBorder.style.display="block",e.$playerBorder.style.border="1px solid "+this._opt.style.border}),t.$playerBorder.style.border="1px solid "+this._opt.style.borderSelect)):this.debug.warn(this.LOG_TAG,`_handleWindowSelect() ${e} is not exist`),1===this._opt.split&&(t.$playerBorder.style.display="none")}_handleWindowContainerFullscreen(e){const t=this.windowList[e];if(t){if(t.isContainerFullscreen)t.$playerContainer.style.position="relative",t.$playerContainer.style.left="auto",t.$playerContainer.style.top="auto",t.$playerContainer.style.zIndex="auto",t.$playerContainer.style.width=t.prevInfo.playerContainerWidth,t.$playerContainer.style.height=t.prevInfo.playerContainerHeight,t.$player.style.width=t.prevInfo.playerWidth,t.$player.style.height=t.prevInfo.playerHeight,this.getSelectedWindowIndex()===e&&(t.$playerBorder.style.display="block");else{const e=this._getContainerRect(),i=e.width,r=e.height;t.prevInfo={playerContainerWidth:t.$playerContainer.style.width,playerContainerHeight:t.$playerContainer.style.height,playerWidth:t.$player.style.width,playerHeight:t.$player.style.height},t.$playerContainer.style.position="absolute",t.$playerContainer.style.top="0",t.$playerContainer.style.left="0",t.$playerContainer.style.zIndex="10",t.$playerContainer.style.width=i+"px",t.$playerContainer.style.height=r+"px",t.$player.style.width=i+"px",t.$player.style.height=r+"px",t.$playerBorder.style.display="none"}t.isContainerFullscreen=!t.isContainerFullscreen,t.player&&t.player.resize()}else this.debug.warn(this.LOG_TAG,`handleWindowContainerFullscreen() ${e} is not exist`)}_handleFullscreenResize(){let e=this._getContainerRect(),t=0;const i=setInterval(()=>{var r=this._getContainerRect();if(r.width===e.width&&r.height===e.height&&4<t)return this.resize(),void clearInterval(i);e=r,t++},300)}_listenFullscreenChange(){try{const e=e=>{It(e)===this.$container&&(this.emit(F.fullscreen,je.isFullscreen),je.isFullscreen?this._handleFullscreenResize():this.resize())};je.on("change",e),this.events.destroys.push(()=>{je.off("change",e)})}catch(r){}}play(e,t,i){return new Promise((r,s)=>{ft(t)&&(i=t,t={});const a=()=>{const i=this._createPlayer(o);(o.player=i).play(e,t).then(()=>{r()}).catch(e=>{s(e)})};var n=ft(i)?i:this.currentWindowIndex;const o=this.windowList[n];o?o.player?o.player.destroy().then(()=>{o.player=null,a()}).catch(()=>{}):a():s(`play() windowIndex ${n} is not exist`)})}getOption(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];return t&&t.player?t.player.getOption():(this.debug.warn(this.LOG_TAG,`getOption() windowIndex ${e} is not exist`),{})}setDebug(e,t){t=ft(t)?t:this.currentWindowIndex;const i=this.windowList[t];i&&i.player?i.player.setDebug(e):this.debug.warn(this.LOG_TAG,`setDebug() windowIndex ${t} is not exist`)}mute(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];t&&t.player?t.player.mute():this.debug.warn(this.LOG_TAG,`mute() windowIndex ${e} is not exist`)}cancelMute(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];t&&t.player?t.player.cancelMute():this.debug.warn(this.LOG_TAG,`cancelMute() windowIndex ${e} is not exist`)}setVolume(e,t){t=ft(t)?t:this.currentWindowIndex;const i=this.windowList[t];i&&i.player?i.player.setVolume(e):this.debug.warn(this.LOG_TAG,`setVolume() windowIndex ${t} is not exist`)}audioResume(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];t&&t.player?t.player.audioResume():this.debug.warn(this.LOG_TAG,`audioResume() windowIndex ${e} is not exist`)}setTimeout(e,t){t=ft(t)?t:this.currentWindowIndex;const i=this.windowList[t];i&&i.player?i.player.setTimeout(e):this.debug.warn(this.LOG_TAG,`setTimeout() windowIndex ${t} is not exist`)}setScaleMode(e,t){t=ft(t)?t:this.currentWindowIndex;const i=this.windowList[t];i&&i.player?i.player.setScaleMode(e):this.debug.warn(this.LOG_TAG,`setScaleMode() windowIndex ${t} is not exist`)}pause(){let e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],t=1<arguments.length?arguments[1]:void 0;return new Promise((i,r)=>{t=ft(t)?t:this.currentWindowIndex;const s=this.windowList[t];s&&s.player?s.player.pause(e).then(()=>{i()}).catch(e=>{r(e)}):r(`pause() windowIndex ${t} is not exist`)})}close(e){return new Promise((t,i)=>{e=ft(e)?e:this.currentWindowIndex;const r=this.windowList[e];r&&r.player?r.player.close().then(()=>{t()}).catch(e=>{i(e)}):i(`close() windowIndex ${e} is not exist`)})}clearView(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];t&&t.player?t.player.clearView():this.debug.warn(this.LOG_TAG,`clearView() windowIndex ${e} is not exist`)}setStreamQuality(e,t){t=ft(t)?t:this.currentWindowIndex;const i=this.windowList[t];i&&i.player?i.player.setStreamQuality(e):this.debug.warn(this.LOG_TAG,`setStreamQuality() windowIndex ${t} is not exist`)}resize(){this._updateWindows()}setBufferTime(e,t){t=ft(t)?t:this.currentWindowIndex;const i=this.windowList[t];i&&i.player?i.player.setBufferTime(e):this.debug.warn(this.LOG_TAG,`setBufferTime() windowIndex ${t} is not exist`)}setBufferDelayTime(e,t){t=ft(t)?t:this.currentWindowIndex;const i=this.windowList[t];i&&i.player?i.player.setBufferDelayTime(e):this.debug.warn(this.LOG_TAG,`setBufferDelayTime() windowIndex ${t} is not exist`)}setRotate(e,t){t=ft(t)?t:this.currentWindowIndex;const i=this.windowList[t];i&&i.player?i.player.setRotate(e):this.debug.warn(this.LOG_TAG,`setRotate() windowIndex ${t} is not exist`)}setMirrorRotate(e,t){t=ft(t)?t:this.currentWindowIndex;const i=this.windowList[t];i&&i.player?i.player.setMirrorRotate(e):this.debug.warn(this.LOG_TAG,`setMirrorRotate() windowIndex ${t} is not exist`)}hasLoaded(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];return!(!t||!t.player)&&t.player.hasLoaded()}setKeepScreenOn(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];t&&t.player?t.player.setKeepScreenOn():this.debug.warn(this.LOG_TAG,`setKeepScreenOn() windowIndex ${e} is not exist`)}setFullscreen(e,t){t=ft(t)?t:this.currentWindowIndex;const i=this.windowList[t];i&&i.player?i.player.setFullscreen(e):this.debug.warn(this.LOG_TAG,`setFullscreen() windowIndex ${t} is not exist`)}screenshot(e,t){t=ft(t)?t:this.currentWindowIndex;const i=this.windowList[t];return i&&i.player?i.player.screenshot(e.filename,e.format,e.quality,e.type):null}screenshotWatermark(e,t){t=ft(t)?t:this.currentWindowIndex;const i=this.windowList[t];return i&&i.player?i.player.screenshotWatermark(e):null}startRecord(e,t,i){return new Promise((r,s)=>{i=ft(i)?i:this.currentWindowIndex;const a=this.windowList[i];a&&a.player?a.player.startRecord(e,t).then(()=>{r()}).catch(e=>{s(e)}):(this.debug.warn(this.LOG_TAG,`startRecord() windowIndex ${i} is not exist`),s(`windowIndex ${i} is not exist`))})}stopRecordAndSave(e,t,i){return new Promise((r,s)=>{i=ft(i)?i:this.currentWindowIndex;const a=this.windowList[i];a&&a.player?a.player.stopRecordAndSave(e,t).then(e=>{r(e)}).catch(e=>{s(e)}):(this.debug.warn(this.LOG_TAG,`stopRecordAndSave() windowIndex ${i} is not exist`),s(`windowIndex ${i} is not exist`))})}isPlaying(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];return t&&t.player?t.player.isPlaying():(this.debug.warn(this.LOG_TAG,`isPlaying() windowIndex ${e} is not exist`),!1)}isLoading(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];return t&&t.player?t.player.isLoading():(this.debug.warn(this.LOG_TAG,`isLoading() windowIndex ${e} is not exist`),!1)}isPaused(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];return t&&t.player?t.player.isPaused():(this.debug.warn(this.LOG_TAG,`windowIndex ${e} is not exist`),!1)}isMute(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];return t&&t.player?t.player.isMute():(this.debug.warn(this.LOG_TAG,`isMute() windowIndex ${e} is not exist`),!1)}isRecording(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];return t&&t.player?t.player.isRecording():(this.debug.warn(this.LOG_TAG,`isRecording() windowIndex ${e} is not exist`),!1)}clearBufferDelay(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];t&&t.player?t.player.clearBufferDelay():this.debug.warn(this.LOG_TAG,`clearBufferDelay() windowIndex ${e} is not exist`)}setNetworkDelayTime(e,t){t=ft(t)?t:this.currentWindowIndex;const i=this.windowList[t];i&&i.player?i.player.setNetworkDelayTime(e):this.debug.warn(this.LOG_TAG,`setNetworkDelayTime() windowIndex ${t} is not exist`)}getDecodeType(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];return t&&t.player?t.player.getDecodeType():(this.debug.warn(this.LOG_TAG,`getDecodeType() windowIndex ${e} is not exist`),null)}getRenderType(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];return t&&t.player?t.player.getRenderType():(this.debug.warn(this.LOG_TAG,`windowIndex ${e} is not exist`),null)}getAudioEngineType(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];return t&&t.player?t.player.getAudioEngineType():(this.debug.warn(this.LOG_TAG,`windowIndex ${e} is not exist`),null)}getPlayingTimestamp(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];return t&&t.player?t.player.getPlayingTimestamp():(this.debug.warn(this.LOG_TAG,`windowIndex ${e} is not exist`),null)}getStatus(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];return t&&t.player?t.player.getStatus():(this.debug.warn(this.LOG_TAG,`getStatus() windowIndex ${e} is not exist`),null)}getPlayType(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];return t&&t.player?t.player.getPlayType():(this.debug.warn(this.LOG_TAG,`getPlayType() windowIndex ${e} is not exist`),null)}togglePerformancePanel(e,t){t=ft(t)?t:this.currentWindowIndex;const i=this.windowList[t];i&&i.player?i.player.togglePerformancePanel(e):this.debug.warn(this.LOG_TAG,`togglePerformancePanel() windowIndex ${t} is not exist`)}openZoom(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];t&&t.player?t.player.openZoom():this.debug.warn(this.LOG_TAG,`openZoom() windowIndex ${e} is not exist`)}closeZoom(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];t&&t.player?t.player.closeZoom():this.debug.warn(this.LOG_TAG,`closeZoom() windowIndex ${e} is not exist`)}isZoomOpen(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];return t&&t.player?t.player.isZoomOpen():(this.debug.warn(this.LOG_TAG,`isZoomOpen() windowIndex ${e} is not exist`),!1)}expandZoom(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];t&&t.player?t.player.expandZoom():this.debug.warn(this.LOG_TAG,`expandZoom() windowIndex ${e} is not exist`)}narrowZoom(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];t&&t.player?t.player.narrowZoom():this.debug.warn(this.LOG_TAG,`narrowZoom() windowIndex ${e} is not exist`)}getCurrentZoomIndex(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];return t&&t.player?t.player.getCurrentZoomIndex():(this.debug.warn(this.LOG_TAG,`getCurrentZoomIndex() windowIndex ${e} is not exist`),0)}setNakedFlowFps(e,t){t=ft(t)?t:this.currentWindowIndex;const i=this.windowList[t];i&&i.player?i.player.setNakedFlowFps(e):this.debug.warn(this.LOG_TAG,`setNakedFlowFps() windowIndex ${t} is not exist`)}updateDebugLevel(e,t){t=ft(t)?t:this.currentWindowIndex;const i=this.windowList[t];i&&i.player?i.player.updateDebugLevel(e):this.debug.warn(this.LOG_TAG,`updateDebugLevel() windowIndex ${t} is not exist`)}updateWatermark(e,t){t=ft(t)?t:this.currentWindowIndex;const i=this.windowList[t];i&&i.player?i.player.updateWatermark(e):this.debug.warn(this.LOG_TAG,`updateWatermark() windowIndex ${t} is not exist`)}removeWatermark(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];t&&t.player?t.player.removeWatermark():this.debug.warn(this.LOG_TAG,`removeWatermark() windowIndex ${e} is not exist`)}updateFullscreenWatermark(e,t){t=ft(t)?t:this.currentWindowIndex;const i=this.windowList[t];i&&i.player?i.player.updateFullscreenWatermark(e):this.debug.warn(this.LOG_TAG,`updateFullscreenWatermark() windowIndex ${t} is not exist`)}removeFullscreenWatermark(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];t&&t.player?t.player.removeFullscreenWatermark():this.debug.warn(this.LOG_TAG,`removeFullscreenWatermark() windowIndex ${e} is not exist`)}faceDetectOpen(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];t&&t.player?t.player.faceDetectOpen():this.debug.warn(this.LOG_TAG,`faceDetectOpen() windowIndex ${e} is not exist`)}faceDetectClose(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];t&&t.player?t.player.faceDetectClose():this.debug.warn(this.LOG_TAG,`faceDetectClose() windowIndex ${e} is not exist`)}objectDetectOpen(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];t&&t.player?t.player.objectDetectOpen():this.debug.warn(this.LOG_TAG,`objectDetectOpen() windowIndex ${e} is not exist`)}objectDetectClose(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];t&&t.player?t.player.objectDetectClose():this.debug.warn(this.LOG_TAG,`objectDetectClose() windowIndex ${e} is not exist`)}sendWebsocketMessage(e,t){t=ft(t)?t:this.currentWindowIndex;const i=this.windowList[t];i&&i.player?i.player.sendWebsocketMessage(e):this.debug.warn(this.LOG_TAG,`sendWebsocketMessage() windowIndex ${t} is not exist`)}addContentToCanvas(e,t){t=ft(t)?t:this.currentWindowIndex;const i=this.windowList[t];i&&i.player?i.player.addContentToCanvas(e):this.debug.warn(this.LOG_TAG,`addContentToCanvas() windowIndex ${t} is not exist`)}clearContentToCanvas(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];t&&t.player?t.player.clearContentToCanvas():this.debug.warn(this.LOG_TAG,`clearContentToCanvas() windowIndex ${e} is not exist`)}setControlHtml(e,t){t=ft(t)?t:this.currentWindowIndex;const i=this.windowList[t];i&&i.player?i.player.setControlHtml(e):this.debug.warn(this.LOG_TAG,`setControlHtml() windowIndex ${t} is not exist`)}clearControlHtml(e){e=ft(e)?e:this.currentWindowIndex;const t=this.windowList[e];t&&t.player?t.player.clearControlHtml():this.debug.warn(this.LOG_TAG,`clearControlHtml() windowIndex ${e} is not exist`)}destroySingle(e){return new Promise((t,i)=>{e=ft(e)?e:this.currentWindowIndex;const r=this.windowList[e];r?r.player&&r.player.destroy().then(()=>{r.player=null,t()}).catch(e=>{i(e)}):(i("windowIndex is not exist"),this.debug.warn(this.LOG_TAG,`destroySingle() windowIndex ${e} is not exist`))})}setFullscreenMulti(e){return new Promise((t,i)=>{if(this.debug.log(this.LOG_TAG,"setFullscreenMulti",e),e)try{je.request(this.$container).then(()=>{t()}).catch(e=>{this.debug.error(this.LOG_TAG,"fullscreen request inner error",e),i(e)})}catch(t){this.debug.error(this.LOG_TAG,"fullscreen request error",t),i(t)}else try{je.exit().then(()=>{t()}).catch(e=>{this.debug.error(this.LOG_TAG,"fullscreen exit inner error",e),i(e)})}catch(t){this.debug.error(this.LOG_TAG,"fullscreen exit error",t),i(t)}})}selectWindow(e){this.debug.log(this.LOG_TAG,"selectWindow",e),this._handleWindowSelect(e)}arrangeWindow(e){this.debug.log(this.LOG_TAG,"arrangeWindow",e),e?[Ie,Pe].includes(e)?this._arrangeSpecialWindow(e):this._opt.split===e&&null===this.specialLayoutType?this.debug.warn(this.LOG_TAG,`arrangeWindow() split ${e} is not changed`):(this.specialLayoutType=null,this._arrangeWindow(e)):this.debug.warn(this.LOG_TAG,`arrangeWindow() split ${e} is not valid`)}_arrangeWindow(e){(e=ht(e))<1||!ft(e)?this.debug.warn(this.LOG_TAG,`arrangeWindow() split ${e} is not valid`):(e>this._opt.maxSplit&&(e=this._opt.maxSplit),this._opt.split=e,this.currentWindowIndex=0,this._updateWindows(),this._handleWindowSelect(this.currentWindowIndex))}_arrangeSpecialWindow(e){this._opt.maxSplit<=3&&e===Pe||this._opt.maxSplit<=2&&e===Ie?this.debug.warn(this.LOG_TAG,`_arrangeSpecialWindow() type ${e} is not valid because maxSplit is `+this._opt.maxSplit):this.specialLayoutType&&this.specialLayoutType===e?this.debug.warn(this.LOG_TAG,`_arrangeSpecialWindow() type ${e} is not changed`):(this.specialLayoutType=e)===Ie?this._arrangeWindow(3):e===Pe?this._arrangeWindow(4):this.debug.warn(this.LOG_TAG,`_arrangeSpecialWindow() type ${e} is not valid`)}getCurrentSplit(){return this.specialLayoutType||this._opt.split}_getCurrentMaxSplit(){if(this.specialLayoutType){let e=0;return this.specialLayoutType===Ie?e=9:this.specialLayoutType===Pe&&(e=16),e}return this._opt.split*this._opt.split}_getSpecialMaxSplit(){let e=0;return this.specialLayoutType===Ie?e=6:this.specialLayoutType===Pe&&(e=8),e}getSelectedWindowIndex(){return this.currentWindowIndex}_findWindowItemIndex(e){return this.windowList.findIndex(t=>t.uuid===e.uuid)}}yn.MULTI_EVENTS=Re,yn.EVENTS=U,yn.ERROR=O,window.JessibucaProMulti=yn,window.WebPlayerProMulti=yn,t["a"]=gn}).call(this,i("c8ba"),i("4362"))}}]);