NodePlayer.min.js
194 KB
var Module=typeof Module!=="undefined"?Module:{};null;var LOG_TYPES={NP_TYPE_NONE:0,NP_TYPE_ERROR:1,NP_TYPE_NORMAL:2,NP_TYPE_DEBUG:3};var logType=LOG_TYPES.NP_TYPE_NORMAL;var logTime=function logTime(){var nowDate=new Date;return nowDate.toLocaleDateString()+" "+nowDate.toLocaleTimeString([],{hour12:false})};var NP_LOG=function NP_LOG(){var _console;for(var _len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}if(logType<LOG_TYPES.NP_TYPE_NORMAL)return;(_console=console).log.apply(_console,[logTime(),"[INFO]"].concat(args))};var NP_ERROR=function NP_ERROR(){var _console2;for(var _len2=arguments.length,args=Array(_len2),_key2=0;_key2<_len2;_key2++){args[_key2]=arguments[_key2]}if(logType<LOG_TYPES.NP_TYPE_ERROR)return;(_console2=console).error.apply(_console2,[logTime(),"[ERROR]"].concat(args))};var NP_DEBUG=function NP_DEBUG(){var _console3;for(var _len3=arguments.length,args=Array(_len3),_key3=0;_key3<_len3;_key3++){args[_key3]=arguments[_key3]}if(logType<LOG_TYPES.NP_TYPE_DEBUG)return;(_console3=console).log.apply(_console3,[logTime(),"[DEBUG]"].concat(args))};Module.print=NP_LOG;Module.printErr=NP_ERROR;var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var arguments_=[];var thisProgram="./this.program";var quit_=function(status,toThrow){throw toThrow};var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string";ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;var nodeFS;var nodePath;if(ENVIRONMENT_IS_NODE){if(ENVIRONMENT_IS_WORKER){scriptDirectory=require("path").dirname(scriptDirectory)+"/"}else{scriptDirectory=__dirname+"/"}read_=function shell_read(filename,binary){if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);return nodeFS["readFileSync"](filename,binary?null:"utf8")};readBinary=function readBinary(filename){var ret=read_(filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};if(process["argv"].length>1){thisProgram=process["argv"][1].replace(/\\/g,"/")}arguments_=process["argv"].slice(2);if(typeof module!=="undefined"){module["exports"]=Module}process["on"]("uncaughtException",function(ex){if(!(ex instanceof ExitStatus)){throw ex}});process["on"]("unhandledRejection",abort);quit_=function(status){process["exit"](status)};Module["inspect"]=function(){return"[Emscripten Module object]"}}else if(ENVIRONMENT_IS_SHELL){if(typeof read!="undefined"){read_=function shell_read(f){return read(f)}}readBinary=function readBinary(f){var data;if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){arguments_=scriptArgs}else if(typeof arguments!="undefined"){arguments_=arguments}if(typeof quit==="function"){quit_=function(status){quit(status)}}if(typeof print!=="undefined"){if(typeof console==="undefined")console={};console.log=print;console.warn=console.error=typeof printErr!=="undefined"?printErr:print}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(document.currentScript){scriptDirectory=document.currentScript.src}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=function shell_read(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=function readBinary(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=function readAsync(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function xhr_onload(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=function(title){document.title=title}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];function dynCall(sig,ptr,args){if(args&&args.length){return Module["dynCall_"+sig].apply(null,[ptr].concat(args))}else{return Module["dynCall_"+sig].call(null,ptr)}}var tempRet0=0;var setTempRet0=function(value){tempRet0=value};var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime;if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(typeof WebAssembly!=="object"){abort("no native wasm support detected")}var wasmMemory;var wasmTable=new WebAssembly.Table({"initial":1426,"maximum":1426+0,"element":"anyfunc"});var ABORT=false;var EXITSTATUS=0;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}function getCFunc(ident){var func=Module["_"+ident];assert(func,"Cannot call unknown function "+ident+", make sure it is exported");return func}function ccall(ident,returnType,argTypes,args,opts){var toC={"string":function(str){var ret=0;if(str!==null&&str!==undefined&&str!==0){var len=(str.length<<2)+1;ret=stackAlloc(len);stringToUTF8(str,ret,len)}return ret},"array":function(arr){var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string")return UTF8ToString(ret);if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i<args.length;i++){var converter=toC[argTypes[i]];if(converter){if(stack===0)stack=stackSave();cArgs[i]=converter(args[i])}else{cArgs[i]=args[i]}}}var ret=func.apply(null,cArgs);ret=convertReturnValue(ret);if(stack!==0)stackRestore(stack);return ret}function cwrap(ident,returnType,argTypes,opts){argTypes=argTypes||[];var numericArgs=argTypes.every(function(type){return type==="number"});var numericRet=returnType!=="string";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return function(){return ccall(ident,returnType,argTypes,arguments,opts)}}var UTF8Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(heap,idx,maxBytesToRead){var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heap[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heap.subarray&&UTF8Decoder){return UTF8Decoder.decode(heap.subarray(idx,endPtr))}else{var str="";while(idx<endPtr){var u0=heap[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heap[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heap[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heap[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,heap,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function lengthBytesUTF8(str){var len=0;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127)++len;else if(u<=2047)len+=2;else if(u<=65535)len+=3;else len+=4}return len}function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i<str.length;++i){HEAP8[buffer++>>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}var WASM_PAGE_SIZE=65536;function alignUp(x,multiple){if(x%multiple>0){x+=multiple-x%multiple}return x}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBufferAndViews(buf){buffer=buf;Module["HEAP8"]=HEAP8=new Int8Array(buf);Module["HEAP16"]=HEAP16=new Int16Array(buf);Module["HEAP32"]=HEAP32=new Int32Array(buf);Module["HEAPU8"]=HEAPU8=new Uint8Array(buf);Module["HEAPU16"]=HEAPU16=new Uint16Array(buf);Module["HEAPU32"]=HEAPU32=new Uint32Array(buf);Module["HEAPF32"]=HEAPF32=new Float32Array(buf);Module["HEAPF64"]=HEAPF64=new Float64Array(buf)}var DYNAMIC_BASE=6338400,DYNAMICTOP_PTR=1095360;var INITIAL_INITIAL_MEMORY=Module["INITIAL_MEMORY"]||16777216;if(Module["wasmMemory"]){wasmMemory=Module["wasmMemory"]}else{wasmMemory=new WebAssembly.Memory({"initial":INITIAL_INITIAL_MEMORY/WASM_PAGE_SIZE,"maximum":2147483648/WASM_PAGE_SIZE})}if(wasmMemory){buffer=wasmMemory.buffer}INITIAL_INITIAL_MEMORY=buffer.byteLength;updateGlobalBufferAndViews(buffer);HEAP32[DYNAMICTOP_PTR>>2]=DYNAMIC_BASE;function callRuntimeCallbacks(callbacks){while(callbacks.length>0){var callback=callbacks.shift();if(typeof callback=="function"){callback(Module);continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){Module["dynCall_v"](func)}else{Module["dynCall_vi"](func,callback.arg)}}else{func(callback.arg===undefined?null:callback.arg)}}}var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATEXIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var Math_ceil=Math.ceil;var Math_floor=Math.floor;var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["preloadedImages"]={};Module["preloadedAudios"]={};function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}what+="";err(what);ABORT=true;EXITSTATUS=1;what="abort("+what+"). Build with -s ASSERTIONS=1 for more info.";var e=new WebAssembly.RuntimeError(what);throw e}function hasPrefix(str,prefix){return String.prototype.startsWith?str.startsWith(prefix):str.indexOf(prefix)===0}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return hasPrefix(filename,dataURIPrefix)}var fileURIPrefix="file://";function isFileURI(filename){return hasPrefix(filename,fileURIPrefix)}var wasmBinaryFile="NodePlayer.min.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}function getBinary(){try{if(wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(wasmBinaryFile)}else{throw"both async and sync fetching of the wasm failed"}}catch(err){abort(err)}}function getBinaryPromise(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)&&typeof fetch==="function"&&!isFileURI(wasmBinaryFile)){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+wasmBinaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary()})}return new Promise(function(resolve,reject){resolve(getBinary())})}function createWasm(){var info={"a":asmLibraryArg};function receiveInstance(instance,module){var exports=instance.exports;Module["asm"]=exports;removeRunDependency("wasm-instantiate")}addRunDependency("wasm-instantiate");function receiveInstantiatedSource(output){receiveInstance(output["instance"])}function instantiateArrayBuffer(receiver){return getBinaryPromise().then(function(binary){return WebAssembly.instantiate(binary,info)}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(){if(!wasmBinary&&typeof WebAssembly.instantiateStreaming==="function"&&!isDataURI(wasmBinaryFile)&&!isFileURI(wasmBinaryFile)&&typeof fetch==="function"){fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,info);return result.then(receiveInstantiatedSource,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(receiveInstantiatedSource)})})}else{return instantiateArrayBuffer(receiveInstantiatedSource)}}if(Module["instantiateWasm"]){try{var exports=Module["instantiateWasm"](info,receiveInstance);return exports}catch(e){err("Module.instantiateWasm callback failed with error: "+e);return false}}instantiateAsync();return{}}var ASM_CONSTS={1363:function($0){var self=SL[$0];if(self&&self.audioContext&&self.audioContext.state=="suspended"){self.audioContext.resume()}},1723:function($0){NP[$0]={}},1740:function($0){var self=NP[$0];if(self&&self.ve&&self.ve.getContext("webgl")&&self.ve.getContext("webgl").getExtension("WEBGL_lose_context")){self.ve.getContext("webgl").getExtension("WEBGL_lose_context").loseContext()}},1963:function($0){var self=NP[$0];var ret=self.emit("buffer","empty")},2120:function(){NP={};if(typeof npAllReady=="function"){npAllReady()}window.npAllReadyFlag=true},2219:function($0){var self=NP[$0];var ret=self.emit("buffer","buffering")},2286:function($0){var self=NP[$0];var ret=self.emit("buffer","full")},2368:function($0,$1,$2,$3){var self=NP[$0];var ret=self.emit("videoSei",new Uint8Array(Module.HEAPU8.buffer,$1,$2),$3)},2474:function($0){var self=SL[$0];return self&&self.audioContext&&self.audioContext.state=="suspended"},2634:function($0,$1,$2,$3){var self=NP[$0];var ret=self.emit("audioInfo",$1,$2,UTF8ToString($3))},2766:function($0,$1,$2,$3){var self=NP[$0];var ret=self.emit("videoInfo",$1,$2,UTF8ToString($3))},2849:function($0,$1){var self=NP[$0];var ret=self.emit("videoFrame",$1)},2911:function($0,$1,$2,$3,$4,$5,$6){var self=NP[$0];var ret=self.emit("stats",{"buf":$1,"fps":$2,"abps":$3,"vbps":$4,"abuf":$5,"ts":$6})},4734:function($0){if(typeof SL=="undefined"){SL={}}SL[$0]={}},4795:function($0){if(typeof SL[$0]=="object"){delete SL[$0]}},4850:function($0){var self=SL[$0];if(typeof AudioContext!="undefined"){self.audioContext=new AudioContext}else if(typeof webkitAudioContext!="undefined"){self.audioContext=new webkitAudioContext}return self.audioContext==undefined?-1:0},5108:function($0){return SL[$0].audioContext.sampleRate},5151:function($0,$1,$2,$3){var self=SL[$3];self.scriptProcessorNode=self.audioContext["createScriptProcessor"]($1,0,$0);self.scriptProcessorNode["onaudioprocess"]=function(e){self.currentOutputBuffer=e["outputBuffer"];dynCall("vi",$2,[$3])};self.scriptProcessorNode["connect"](self.audioContext["destination"]);self.audioContext.resume()},5525:function($0){var self=SL[$0];if(self.scriptProcessorNode!=undefined){self.scriptProcessorNode.disconnect();self.scriptProcessorNode=undefined}if(self.audioContext!=undefined){self.audioContext.close();self.audioContext=undefined}if(self.currentOutputBuffer!=undefined){self.currentOutputBuffer=undefined}return 0},5864:function($0,$1,$2,$3,$4){var self=SL[$0];if(self&&self.currentOutputBuffer){var channelData=self.currentOutputBuffer.getChannelData(0);if($3==$2){for(var i=0;i<$2;i++){channelData[i]=HEAPF32[$1+(i<<2)>>2]*$4}}else{channelData.fill(0)}}}};function _emscripten_asm_const_iii(code,sigPtr,argbuf){var args=readAsmConstArgs(sigPtr,argbuf);return ASM_CONSTS[code].apply(null,args)}function get_do_str(){var jsString=document.domain;var lengthBytes=lengthBytesUTF8(jsString)+1;var stringOnWasmHeap=_malloc(lengthBytes);stringToUTF8(jsString,stringOnWasmHeap,lengthBytes+1);return stringOnWasmHeap}__ATINIT__.push({func:function(){___wasm_call_ctors()}});function setErrNo(value){HEAP32[___errno_location()>>2]=value;return value}var PATH={splitPath:function(filename){var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return splitPathRe.exec(filename).slice(1)},normalizeArray:function(parts,allowAboveRoot){var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up;up--){parts.unshift("..")}}return parts},normalize:function(path){var isAbsolute=path.charAt(0)==="/",trailingSlash=path.substr(-1)==="/";path=PATH.normalizeArray(path.split("/").filter(function(p){return!!p}),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path},dirname:function(path){var result=PATH.splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return"."}if(dir){dir=dir.substr(0,dir.length-1)}return root+dir},basename:function(path){if(path==="/")return"/";var lastSlash=path.lastIndexOf("/");if(lastSlash===-1)return path;return path.substr(lastSlash+1)},extname:function(path){return PATH.splitPath(path)[3]},join:function(){var paths=Array.prototype.slice.call(arguments,0);return PATH.normalize(paths.join("/"))},join2:function(l,r){return PATH.normalize(l+"/"+r)}};var SYSCALLS={mappings:{},buffers:[null,[],[]],printChar:function(stream,curr){var buffer=SYSCALLS.buffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer,0));buffer.length=0}else{buffer.push(curr)}},varargs:undefined,get:function(){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret},getStr:function(ptr){var ret=UTF8ToString(ptr);return ret},get64:function(low,high){return low}};function ___sys_fcntl64(fd,cmd,varargs){SYSCALLS.varargs=varargs;return 0}function ___sys_open(path,flags,varargs){SYSCALLS.varargs=varargs}function ___sys_read(fd,buf,count){}function _abort(){abort()}function _clock(){if(_clock.start===undefined)_clock.start=Date.now();return(Date.now()-_clock.start)*(1e6/1e3)|0}function _emscripten_clear_interval(id){clearInterval(id)}var JSEvents={inEventHandler:0,removeAllEventListeners:function(){for(var i=JSEvents.eventHandlers.length-1;i>=0;--i){JSEvents._removeHandler(i)}JSEvents.eventHandlers=[];JSEvents.deferredCalls=[]},registerRemoveEventListeners:function(){if(!JSEvents.removeEventListenersRegistered){__ATEXIT__.push(JSEvents.removeAllEventListeners);JSEvents.removeEventListenersRegistered=true}},deferredCalls:[],deferCall:function(targetFunction,precedence,argsList){function arraysHaveEqualContent(arrA,arrB){if(arrA.length!=arrB.length)return false;for(var i in arrA){if(arrA[i]!=arrB[i])return false}return true}for(var i in JSEvents.deferredCalls){var call=JSEvents.deferredCalls[i];if(call.targetFunction==targetFunction&&arraysHaveEqualContent(call.argsList,argsList)){return}}JSEvents.deferredCalls.push({targetFunction:targetFunction,precedence:precedence,argsList:argsList});JSEvents.deferredCalls.sort(function(x,y){return x.precedence<y.precedence})},removeDeferredCalls:function(targetFunction){for(var i=0;i<JSEvents.deferredCalls.length;++i){if(JSEvents.deferredCalls[i].targetFunction==targetFunction){JSEvents.deferredCalls.splice(i,1);--i}}},canPerformEventHandlerRequests:function(){return JSEvents.inEventHandler&&JSEvents.currentEventHandler.allowsDeferredCalls},runDeferredCalls:function(){if(!JSEvents.canPerformEventHandlerRequests()){return}for(var i=0;i<JSEvents.deferredCalls.length;++i){var call=JSEvents.deferredCalls[i];JSEvents.deferredCalls.splice(i,1);--i;call.targetFunction.apply(null,call.argsList)}},eventHandlers:[],removeAllHandlersOnTarget:function(target,eventTypeString){for(var i=0;i<JSEvents.eventHandlers.length;++i){if(JSEvents.eventHandlers[i].target==target&&(!eventTypeString||eventTypeString==JSEvents.eventHandlers[i].eventTypeString)){JSEvents._removeHandler(i--)}}},_removeHandler:function(i){var h=JSEvents.eventHandlers[i];h.target.removeEventListener(h.eventTypeString,h.eventListenerFunc,h.useCapture);JSEvents.eventHandlers.splice(i,1)},registerOrRemoveHandler:function(eventHandler){var jsEventHandler=function jsEventHandler(event){++JSEvents.inEventHandler;JSEvents.currentEventHandler=eventHandler;JSEvents.runDeferredCalls();eventHandler.handlerFunc(event);JSEvents.runDeferredCalls();--JSEvents.inEventHandler};if(eventHandler.callbackfunc){eventHandler.eventListenerFunc=jsEventHandler;eventHandler.target.addEventListener(eventHandler.eventTypeString,jsEventHandler,eventHandler.useCapture);JSEvents.eventHandlers.push(eventHandler);JSEvents.registerRemoveEventListeners()}else{for(var i=0;i<JSEvents.eventHandlers.length;++i){if(JSEvents.eventHandlers[i].target==eventHandler.target&&JSEvents.eventHandlers[i].eventTypeString==eventHandler.eventTypeString){JSEvents._removeHandler(i--)}}}},getNodeNameForTarget:function(target){if(!target)return"";if(target==window)return"#window";if(target==screen)return"#screen";return target&&target.nodeName?target.nodeName:""},fullscreenEnabled:function(){return document.fullscreenEnabled||document.webkitFullscreenEnabled}};function maybeCStringToJsString(cString){return cString>2?UTF8ToString(cString):cString}var specialHTMLTargets=[0,typeof document!=="undefined"?document:0,typeof window!=="undefined"?window:0];function findEventTarget(target){target=maybeCStringToJsString(target);var domElement=specialHTMLTargets[target]||(typeof document!=="undefined"?document.querySelector(target):undefined);return domElement}function findCanvasEventTarget(target){return findEventTarget(target)}function _emscripten_get_canvas_element_size(target,width,height){var canvas=findCanvasEventTarget(target);if(!canvas)return-4;HEAP32[width>>2]=canvas.width;HEAP32[height>>2]=canvas.height}function __getBoundingClientRect(e){return specialHTMLTargets.indexOf(e)<0?e.getBoundingClientRect():{"left":0,"top":0}}function _emscripten_get_element_css_size(target,width,height){target=findEventTarget(target);if(!target)return-4;var rect=__getBoundingClientRect(target);HEAPF64[width>>3]=rect.width;HEAPF64[height>>3]=rect.height;return 0}function _emscripten_memcpy_big(dest,src,num){HEAPU8.copyWithin(dest,src,src+num)}function _emscripten_get_heap_size(){return HEAPU8.length}function emscripten_realloc_buffer(size){try{wasmMemory.grow(size-buffer.byteLength+65535>>>16);updateGlobalBufferAndViews(wasmMemory.buffer);return 1}catch(e){}}function _emscripten_resize_heap(requestedSize){requestedSize=requestedSize>>>0;var oldSize=_emscripten_get_heap_size();var PAGE_MULTIPLE=65536;var maxHeapSize=2147483648;if(requestedSize>maxHeapSize){return false}var minHeapSize=16777216;for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignUp(Math.max(minHeapSize,requestedSize,overGrownHeapSize),PAGE_MULTIPLE));var replacement=emscripten_realloc_buffer(newSize);if(replacement){return true}}return false}function _emscripten_set_canvas_element_size(target,width,height){var canvas=findCanvasEventTarget(target);if(!canvas)return-4;canvas.width=width;canvas.height=height;return 0}function _emscripten_set_element_css_size(target,width,height){target=findEventTarget(target);if(!target)return-4;target.style.width=width+"px";target.style.height=height+"px";return 0}function _emscripten_set_interval(cb,msecs,userData){return setInterval(function(){dynCall_vi(cb,userData)},msecs)}function __registerKeyEventCallback(target,userData,useCapture,callbackfunc,eventTypeId,eventTypeString,targetThread){if(!JSEvents.keyEvent)JSEvents.keyEvent=_malloc(164);var keyEventHandlerFunc=function(e){var keyEventData=JSEvents.keyEvent;var idx=keyEventData>>2;HEAP32[idx+0]=e.location;HEAP32[idx+1]=e.ctrlKey;HEAP32[idx+2]=e.shiftKey;HEAP32[idx+3]=e.altKey;HEAP32[idx+4]=e.metaKey;HEAP32[idx+5]=e.repeat;HEAP32[idx+6]=e.charCode;HEAP32[idx+7]=e.keyCode;HEAP32[idx+8]=e.which;stringToUTF8(e.key||"",keyEventData+36,32);stringToUTF8(e.code||"",keyEventData+68,32);stringToUTF8(e.char||"",keyEventData+100,32);stringToUTF8(e.locale||"",keyEventData+132,32);if(dynCall_iiii(callbackfunc,eventTypeId,keyEventData,userData))e.preventDefault()};var eventHandler={target:findEventTarget(target),allowsDeferredCalls:true,eventTypeString:eventTypeString,callbackfunc:callbackfunc,handlerFunc:keyEventHandlerFunc,useCapture:useCapture};JSEvents.registerOrRemoveHandler(eventHandler)}function _emscripten_set_keydown_callback_on_thread(target,userData,useCapture,callbackfunc,targetThread){__registerKeyEventCallback(target,userData,useCapture,callbackfunc,2,"keydown",targetThread);return 0}function __fillMouseEventData(eventStruct,e,target){var idx=eventStruct>>2;HEAP32[idx+0]=e.screenX;HEAP32[idx+1]=e.screenY;HEAP32[idx+2]=e.clientX;HEAP32[idx+3]=e.clientY;HEAP32[idx+4]=e.ctrlKey;HEAP32[idx+5]=e.shiftKey;HEAP32[idx+6]=e.altKey;HEAP32[idx+7]=e.metaKey;HEAP16[idx*2+16]=e.button;HEAP16[idx*2+17]=e.buttons;HEAP32[idx+9]=e["movementX"];HEAP32[idx+10]=e["movementY"];var rect=__getBoundingClientRect(target);HEAP32[idx+11]=e.clientX-rect.left;HEAP32[idx+12]=e.clientY-rect.top}function __registerMouseEventCallback(target,userData,useCapture,callbackfunc,eventTypeId,eventTypeString,targetThread){if(!JSEvents.mouseEvent)JSEvents.mouseEvent=_malloc(64);target=findEventTarget(target);var mouseEventHandlerFunc=function(ev){var e=ev||event;__fillMouseEventData(JSEvents.mouseEvent,e,target);if(dynCall_iiii(callbackfunc,eventTypeId,JSEvents.mouseEvent,userData))e.preventDefault()};var eventHandler={target:target,allowsDeferredCalls:eventTypeString!="mousemove"&&eventTypeString!="mouseenter"&&eventTypeString!="mouseleave",eventTypeString:eventTypeString,callbackfunc:callbackfunc,handlerFunc:mouseEventHandlerFunc,useCapture:useCapture};JSEvents.registerOrRemoveHandler(eventHandler)}function _emscripten_set_mousedown_callback_on_thread(target,userData,useCapture,callbackfunc,targetThread){__registerMouseEventCallback(target,userData,useCapture,callbackfunc,5,"mousedown",targetThread);return 0}function __registerTouchEventCallback(target,userData,useCapture,callbackfunc,eventTypeId,eventTypeString,targetThread){if(!JSEvents.touchEvent)JSEvents.touchEvent=_malloc(1684);target=findEventTarget(target);var touchEventHandlerFunc=function(e){var touches={};var et=e.touches;for(var i=0;i<et.length;++i){var touch=et[i];touches[touch.identifier]=touch}et=e.changedTouches;for(var i=0;i<et.length;++i){var touch=et[i];touch.isChanged=1;touches[touch.identifier]=touch}et=e.targetTouches;for(var i=0;i<et.length;++i){touches[et[i].identifier].onTarget=1}var touchEvent=JSEvents.touchEvent;var idx=touchEvent>>2;HEAP32[idx+1]=e.ctrlKey;HEAP32[idx+2]=e.shiftKey;HEAP32[idx+3]=e.altKey;HEAP32[idx+4]=e.metaKey;idx+=5;var targetRect=__getBoundingClientRect(target);var numTouches=0;for(var i in touches){var t=touches[i];HEAP32[idx+0]=t.identifier;HEAP32[idx+1]=t.screenX;HEAP32[idx+2]=t.screenY;HEAP32[idx+3]=t.clientX;HEAP32[idx+4]=t.clientY;HEAP32[idx+5]=t.pageX;HEAP32[idx+6]=t.pageY;HEAP32[idx+7]=t.isChanged;HEAP32[idx+8]=t.onTarget;HEAP32[idx+9]=t.clientX-targetRect.left;HEAP32[idx+10]=t.clientY-targetRect.top;idx+=13;if(++numTouches>31){break}}HEAP32[touchEvent>>2]=numTouches;if(dynCall_iiii(callbackfunc,eventTypeId,touchEvent,userData))e.preventDefault()};var eventHandler={target:target,allowsDeferredCalls:eventTypeString=="touchstart"||eventTypeString=="touchend",eventTypeString:eventTypeString,callbackfunc:callbackfunc,handlerFunc:touchEventHandlerFunc,useCapture:useCapture};JSEvents.registerOrRemoveHandler(eventHandler)}function _emscripten_set_touchstart_callback_on_thread(target,userData,useCapture,callbackfunc,targetThread){__registerTouchEventCallback(target,userData,useCapture,callbackfunc,22,"touchstart",targetThread);return 0}function __webgl_enable_ANGLE_instanced_arrays(ctx){var ext=ctx.getExtension("ANGLE_instanced_arrays");if(ext){ctx["vertexAttribDivisor"]=function(index,divisor){ext["vertexAttribDivisorANGLE"](index,divisor)};ctx["drawArraysInstanced"]=function(mode,first,count,primcount){ext["drawArraysInstancedANGLE"](mode,first,count,primcount)};ctx["drawElementsInstanced"]=function(mode,count,type,indices,primcount){ext["drawElementsInstancedANGLE"](mode,count,type,indices,primcount)};return 1}}function __webgl_enable_OES_vertex_array_object(ctx){var ext=ctx.getExtension("OES_vertex_array_object");if(ext){ctx["createVertexArray"]=function(){return ext["createVertexArrayOES"]()};ctx["deleteVertexArray"]=function(vao){ext["deleteVertexArrayOES"](vao)};ctx["bindVertexArray"]=function(vao){ext["bindVertexArrayOES"](vao)};ctx["isVertexArray"]=function(vao){return ext["isVertexArrayOES"](vao)};return 1}}function __webgl_enable_WEBGL_draw_buffers(ctx){var ext=ctx.getExtension("WEBGL_draw_buffers");if(ext){ctx["drawBuffers"]=function(n,bufs){ext["drawBuffersWEBGL"](n,bufs)};return 1}}var GL={counter:1,buffers:[],programs:[],framebuffers:[],renderbuffers:[],textures:[],uniforms:[],shaders:[],vaos:[],contexts:[],offscreenCanvases:{},timerQueriesEXT:[],programInfos:{},stringCache:{},unpackAlignment:4,recordError:function recordError(errorCode){if(!GL.lastError){GL.lastError=errorCode}},getNewId:function(table){var ret=GL.counter++;for(var i=table.length;i<ret;i++){table[i]=null}return ret},getSource:function(shader,count,string,length){var source="";for(var i=0;i<count;++i){var len=length?HEAP32[length+i*4>>2]:-1;source+=UTF8ToString(HEAP32[string+i*4>>2],len<0?undefined:len)}return source},createContext:function(canvas,webGLContextAttributes){var ctx=canvas.getContext("webgl",webGLContextAttributes);if(!ctx)return 0;var handle=GL.registerContext(ctx,webGLContextAttributes);return handle},registerContext:function(ctx,webGLContextAttributes){var handle=GL.getNewId(GL.contexts);var context={handle:handle,attributes:webGLContextAttributes,version:webGLContextAttributes.majorVersion,GLctx:ctx};if(ctx.canvas)ctx.canvas.GLctxObject=context;GL.contexts[handle]=context;if(typeof webGLContextAttributes.enableExtensionsByDefault==="undefined"||webGLContextAttributes.enableExtensionsByDefault){GL.initExtensions(context)}return handle},makeContextCurrent:function(contextHandle){GL.currentContext=GL.contexts[contextHandle];Module.ctx=GLctx=GL.currentContext&&GL.currentContext.GLctx;return!(contextHandle&&!GLctx)},getContext:function(contextHandle){return GL.contexts[contextHandle]},deleteContext:function(contextHandle){if(GL.currentContext===GL.contexts[contextHandle])GL.currentContext=null;if(typeof JSEvents==="object")JSEvents.removeAllHandlersOnTarget(GL.contexts[contextHandle].GLctx.canvas);if(GL.contexts[contextHandle]&&GL.contexts[contextHandle].GLctx.canvas)GL.contexts[contextHandle].GLctx.canvas.GLctxObject=undefined;GL.contexts[contextHandle]=null},initExtensions:function(context){if(!context)context=GL.currentContext;if(context.initExtensionsDone)return;context.initExtensionsDone=true;var GLctx=context.GLctx;__webgl_enable_ANGLE_instanced_arrays(GLctx);__webgl_enable_OES_vertex_array_object(GLctx);__webgl_enable_WEBGL_draw_buffers(GLctx);GLctx.disjointTimerQueryExt=GLctx.getExtension("EXT_disjoint_timer_query");var automaticallyEnabledExtensions=["OES_texture_float","OES_texture_half_float","OES_standard_derivatives","OES_vertex_array_object","WEBGL_compressed_texture_s3tc","WEBGL_depth_texture","OES_element_index_uint","EXT_texture_filter_anisotropic","EXT_frag_depth","WEBGL_draw_buffers","ANGLE_instanced_arrays","OES_texture_float_linear","OES_texture_half_float_linear","EXT_blend_minmax","EXT_shader_texture_lod","EXT_texture_norm16","WEBGL_compressed_texture_pvrtc","EXT_color_buffer_half_float","WEBGL_color_buffer_float","EXT_sRGB","WEBGL_compressed_texture_etc1","EXT_disjoint_timer_query","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_astc","EXT_color_buffer_float","WEBGL_compressed_texture_s3tc_srgb","EXT_disjoint_timer_query_webgl2","WEBKIT_WEBGL_compressed_texture_pvrtc"];var exts=GLctx.getSupportedExtensions()||[];exts.forEach(function(ext){if(automaticallyEnabledExtensions.indexOf(ext)!=-1){GLctx.getExtension(ext)}})},populateUniformTable:function(program){var p=GL.programs[program];var ptable=GL.programInfos[program]={uniforms:{},maxUniformLength:0,maxAttributeLength:-1,maxUniformBlockNameLength:-1};var utable=ptable.uniforms;var numUniforms=GLctx.getProgramParameter(p,35718);for(var i=0;i<numUniforms;++i){var u=GLctx.getActiveUniform(p,i);var name=u.name;ptable.maxUniformLength=Math.max(ptable.maxUniformLength,name.length+1);if(name.slice(-1)=="]"){name=name.slice(0,name.lastIndexOf("["))}var loc=GLctx.getUniformLocation(p,name);if(loc){var id=GL.getNewId(GL.uniforms);utable[name]=[u.size,id];GL.uniforms[id]=loc;for(var j=1;j<u.size;++j){var n=name+"["+j+"]";loc=GLctx.getUniformLocation(p,n);id=GL.getNewId(GL.uniforms);GL.uniforms[id]=loc}}}}};var __emscripten_webgl_power_preferences=["default","low-power","high-performance"];function _emscripten_webgl_do_create_context(target,attributes){var contextAttributes={};var a=attributes>>2;contextAttributes["alpha"]=!!HEAP32[a+(0>>2)];contextAttributes["depth"]=!!HEAP32[a+(4>>2)];contextAttributes["stencil"]=!!HEAP32[a+(8>>2)];contextAttributes["antialias"]=!!HEAP32[a+(12>>2)];contextAttributes["premultipliedAlpha"]=!!HEAP32[a+(16>>2)];contextAttributes["preserveDrawingBuffer"]=!!HEAP32[a+(20>>2)];var powerPreference=HEAP32[a+(24>>2)];contextAttributes["powerPreference"]=__emscripten_webgl_power_preferences[powerPreference];contextAttributes["failIfMajorPerformanceCaveat"]=!!HEAP32[a+(28>>2)];contextAttributes.majorVersion=HEAP32[a+(32>>2)];contextAttributes.minorVersion=HEAP32[a+(36>>2)];contextAttributes.enableExtensionsByDefault=HEAP32[a+(40>>2)];contextAttributes.explicitSwapControl=HEAP32[a+(44>>2)];contextAttributes.proxyContextToMainThread=HEAP32[a+(48>>2)];contextAttributes.renderViaOffscreenBackBuffer=HEAP32[a+(52>>2)];var canvas=findCanvasEventTarget(target);if(!canvas){return-4}if(contextAttributes.explicitSwapControl){return-1}var contextHandle=GL.createContext(canvas,contextAttributes);return contextHandle}function _emscripten_webgl_create_context(a0,a1){return _emscripten_webgl_do_create_context(a0,a1)}function _emscripten_webgl_do_get_current_context(){return GL.currentContext?GL.currentContext.handle:0}function _emscripten_webgl_get_current_context(){return _emscripten_webgl_do_get_current_context()}Module["_emscripten_webgl_get_current_context"]=_emscripten_webgl_get_current_context;function _emscripten_webgl_make_context_current(contextHandle){var success=GL.makeContextCurrent(contextHandle);return success?0:-5}Module["_emscripten_webgl_make_context_current"]=_emscripten_webgl_make_context_current;function _emscripten_webgl_destroy_context(contextHandle){if(GL.currentContext==contextHandle)GL.currentContext=0;GL.deleteContext(contextHandle)}function _emscripten_webgl_init_context_attributes(attributes){var a=attributes>>2;for(var i=0;i<56>>2;++i){HEAP32[a+i]=0}HEAP32[a+(0>>2)]=HEAP32[a+(4>>2)]=HEAP32[a+(12>>2)]=HEAP32[a+(16>>2)]=HEAP32[a+(32>>2)]=HEAP32[a+(40>>2)]=1}var ENV={};function getExecutableName(){return thisProgram||"./this.program"}function getEnvStrings(){if(!getEnvStrings.strings){var lang=(typeof navigator==="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8";var env={"USER":"web_user","LOGNAME":"web_user","PATH":"/","PWD":"/","HOME":"/home/web_user","LANG":lang,"_":getExecutableName()};for(var x in ENV){env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(x+"="+env[x])}getEnvStrings.strings=strings}return getEnvStrings.strings}function _environ_get(__environ,environ_buf){var bufSize=0;getEnvStrings().forEach(function(string,i){var ptr=environ_buf+bufSize;HEAP32[__environ+i*4>>2]=ptr;writeAsciiToMemory(string,ptr);bufSize+=string.length+1});return 0}function _environ_sizes_get(penviron_count,penviron_buf_size){var strings=getEnvStrings();HEAP32[penviron_count>>2]=strings.length;var bufSize=0;strings.forEach(function(string){bufSize+=string.length+1});HEAP32[penviron_buf_size>>2]=bufSize;return 0}function _fd_close(fd){return 0}function _fd_fdstat_get(fd,pbuf){var type=fd==1||fd==2?2:abort();HEAP8[pbuf>>0]=type;return 0}function _fd_seek(fd,offset_low,offset_high,whence,newOffset){}function _fd_write(fd,iov,iovcnt,pnum){var num=0;for(var i=0;i<iovcnt;i++){var ptr=HEAP32[iov+i*8>>2];var len=HEAP32[iov+(i*8+4)>>2];for(var j=0;j<len;j++){SYSCALLS.printChar(fd,HEAPU8[ptr+j])}num+=len}HEAP32[pnum>>2]=num;return 0}function _gettimeofday(ptr){var now=Date.now();HEAP32[ptr>>2]=now/1e3|0;HEAP32[ptr+4>>2]=now%1e3*1e3|0;return 0}function _glActiveTexture(x0){GLctx["activeTexture"](x0)}function _glAttachShader(program,shader){GLctx.attachShader(GL.programs[program],GL.shaders[shader])}function _glBindBuffer(target,buffer){GLctx.bindBuffer(target,GL.buffers[buffer])}function _glBindTexture(target,texture){GLctx.bindTexture(target,GL.textures[texture])}function _glBufferData(target,size,data,usage){GLctx.bufferData(target,data?HEAPU8.subarray(data,data+size):size,usage)}function _glClear(x0){GLctx["clear"](x0)}function _glClearColor(x0,x1,x2,x3){GLctx["clearColor"](x0,x1,x2,x3)}function _glCompileShader(shader){GLctx.compileShader(GL.shaders[shader])}function _glCreateProgram(){var id=GL.getNewId(GL.programs);var program=GLctx.createProgram();program.name=id;GL.programs[id]=program;return id}function _glCreateShader(shaderType){var id=GL.getNewId(GL.shaders);GL.shaders[id]=GLctx.createShader(shaderType);return id}function _glDeleteProgram(id){if(!id)return;var program=GL.programs[id];if(!program){GL.recordError(1281);return}GLctx.deleteProgram(program);program.name=0;GL.programs[id]=null;GL.programInfos[id]=null}function _glDeleteShader(id){if(!id)return;var shader=GL.shaders[id];if(!shader){GL.recordError(1281);return}GLctx.deleteShader(shader);GL.shaders[id]=null}function _glDeleteTextures(n,textures){for(var i=0;i<n;i++){var id=HEAP32[textures+i*4>>2];var texture=GL.textures[id];if(!texture)continue;GLctx.deleteTexture(texture);texture.name=0;GL.textures[id]=null}}function _glDrawArrays(mode,first,count){GLctx.drawArrays(mode,first,count)}function _glEnableVertexAttribArray(index){GLctx.enableVertexAttribArray(index)}function __glGenObject(n,buffers,createFunction,objectTable){for(var i=0;i<n;i++){var buffer=GLctx[createFunction]();var id=buffer&&GL.getNewId(objectTable);if(buffer){buffer.name=id;objectTable[id]=buffer}else{GL.recordError(1282)}HEAP32[buffers+i*4>>2]=id}}function _glGenBuffers(n,buffers){__glGenObject(n,buffers,"createBuffer",GL.buffers)}function _glGenTextures(n,textures){__glGenObject(n,textures,"createTexture",GL.textures)}function _glGetAttribLocation(program,name){return GLctx.getAttribLocation(GL.programs[program],UTF8ToString(name))}function _glGetError(){var error=GLctx.getError()||GL.lastError;GL.lastError=0;return error}function _glGetProgramInfoLog(program,maxLength,length,infoLog){var log=GLctx.getProgramInfoLog(GL.programs[program]);if(log===null)log="(unknown error)";var numBytesWrittenExclNull=maxLength>0&&infoLog?stringToUTF8(log,infoLog,maxLength):0;if(length)HEAP32[length>>2]=numBytesWrittenExclNull}function _glGetProgramiv(program,pname,p){if(!p){GL.recordError(1281);return}if(program>=GL.counter){GL.recordError(1281);return}var ptable=GL.programInfos[program];if(!ptable){GL.recordError(1282);return}if(pname==35716){var log=GLctx.getProgramInfoLog(GL.programs[program]);if(log===null)log="(unknown error)";HEAP32[p>>2]=log.length+1}else if(pname==35719){HEAP32[p>>2]=ptable.maxUniformLength}else if(pname==35722){if(ptable.maxAttributeLength==-1){program=GL.programs[program];var numAttribs=GLctx.getProgramParameter(program,35721);ptable.maxAttributeLength=0;for(var i=0;i<numAttribs;++i){var activeAttrib=GLctx.getActiveAttrib(program,i);ptable.maxAttributeLength=Math.max(ptable.maxAttributeLength,activeAttrib.name.length+1)}}HEAP32[p>>2]=ptable.maxAttributeLength}else if(pname==35381){if(ptable.maxUniformBlockNameLength==-1){program=GL.programs[program];var numBlocks=GLctx.getProgramParameter(program,35382);ptable.maxUniformBlockNameLength=0;for(var i=0;i<numBlocks;++i){var activeBlockName=GLctx.getActiveUniformBlockName(program,i);ptable.maxUniformBlockNameLength=Math.max(ptable.maxUniformBlockNameLength,activeBlockName.length+1)}}HEAP32[p>>2]=ptable.maxUniformBlockNameLength}else{HEAP32[p>>2]=GLctx.getProgramParameter(GL.programs[program],pname)}}function _glGetShaderInfoLog(shader,maxLength,length,infoLog){var log=GLctx.getShaderInfoLog(GL.shaders[shader]);if(log===null)log="(unknown error)";var numBytesWrittenExclNull=maxLength>0&&infoLog?stringToUTF8(log,infoLog,maxLength):0;if(length)HEAP32[length>>2]=numBytesWrittenExclNull}function _glGetShaderiv(shader,pname,p){if(!p){GL.recordError(1281);return}if(pname==35716){var log=GLctx.getShaderInfoLog(GL.shaders[shader]);if(log===null)log="(unknown error)";var logLength=log?log.length+1:0;HEAP32[p>>2]=logLength}else if(pname==35720){var source=GLctx.getShaderSource(GL.shaders[shader]);var sourceLength=source?source.length+1:0;HEAP32[p>>2]=sourceLength}else{HEAP32[p>>2]=GLctx.getShaderParameter(GL.shaders[shader],pname)}}function jstoi_q(str){return parseInt(str)}function _glGetUniformLocation(program,name){name=UTF8ToString(name);var arrayIndex=0;if(name[name.length-1]=="]"){var leftBrace=name.lastIndexOf("[");arrayIndex=name[leftBrace+1]!="]"?jstoi_q(name.slice(leftBrace+1)):0;name=name.slice(0,leftBrace)}var uniformInfo=GL.programInfos[program]&&GL.programInfos[program].uniforms[name];if(uniformInfo&&arrayIndex>=0&&arrayIndex<uniformInfo[0]){return uniformInfo[1]+arrayIndex}else{return-1}}function _glLinkProgram(program){GLctx.linkProgram(GL.programs[program]);GL.populateUniformTable(program)}function _glPixelStorei(pname,param){if(pname==3317){GL.unpackAlignment=param}GLctx.pixelStorei(pname,param)}function _glShaderSource(shader,count,string,length){var source=GL.getSource(shader,count,string,length);GLctx.shaderSource(GL.shaders[shader],source)}function computeUnpackAlignedImageSize(width,height,sizePerPixel,alignment){function roundedToNextMultipleOf(x,y){return x+y-1&-y}var plainRowSize=width*sizePerPixel;var alignedRowSize=roundedToNextMultipleOf(plainRowSize,alignment);return height*alignedRowSize}function __colorChannelsInGlTextureFormat(format){var colorChannels={5:3,6:4,8:2,29502:3,29504:4};return colorChannels[format-6402]||1}function heapObjectForWebGLType(type){type-=5120;if(type==1)return HEAPU8;if(type==4)return HEAP32;if(type==6)return HEAPF32;if(type==5||type==28922)return HEAPU32;return HEAPU16}function heapAccessShiftForWebGLHeap(heap){return 31-Math.clz32(heap.BYTES_PER_ELEMENT)}function emscriptenWebGLGetTexPixelData(type,format,width,height,pixels,internalFormat){var heap=heapObjectForWebGLType(type);var shift=heapAccessShiftForWebGLHeap(heap);var byteSize=1<<shift;var sizePerPixel=__colorChannelsInGlTextureFormat(format)*byteSize;var bytes=computeUnpackAlignedImageSize(width,height,sizePerPixel,GL.unpackAlignment);return heap.subarray(pixels>>shift,pixels+bytes>>shift)}function _glTexImage2D(target,level,internalFormat,width,height,border,format,type,pixels){GLctx.texImage2D(target,level,internalFormat,width,height,border,format,type,pixels?emscriptenWebGLGetTexPixelData(type,format,width,height,pixels,internalFormat):null)}function _glTexParameterf(x0,x1,x2){GLctx["texParameterf"](x0,x1,x2)}function _glUniform1i(location,v0){GLctx.uniform1i(GL.uniforms[location],v0)}function _glUseProgram(program){GLctx.useProgram(GL.programs[program])}function _glVertexAttribPointer(index,size,type,normalized,stride,ptr){GLctx.vertexAttribPointer(index,size,type,!!normalized,stride,ptr)}function _glViewport(x0,x1,x2,x3){GLctx["viewport"](x0,x1,x2,x3)}var ___tm_timezone=(stringToUTF8("GMT",1095424,4),1095424);function _pthread_create(){return 6}function _pthread_join(){}function _round(d){d=+d;return d>=+0?+Math_floor(d+ +.5):+Math_ceil(d-+.5)}function _setTempRet0($i){setTempRet0($i|0)}function _sysconf(name){switch(name){case 30:return 16384;case 85:var maxHeapSize=2147483648;return maxHeapSize/16384;case 132:case 133:case 12:case 137:case 138:case 15:case 235:case 16:case 17:case 18:case 19:case 20:case 149:case 13:case 10:case 236:case 153:case 9:case 21:case 22:case 159:case 154:case 14:case 77:case 78:case 139:case 80:case 81:case 82:case 68:case 67:case 164:case 11:case 29:case 47:case 48:case 95:case 52:case 51:case 46:case 79:return 200809;case 27:case 246:case 127:case 128:case 23:case 24:case 160:case 161:case 181:case 182:case 242:case 183:case 184:case 243:case 244:case 245:case 165:case 178:case 179:case 49:case 50:case 168:case 169:case 175:case 170:case 171:case 172:case 97:case 76:case 32:case 173:case 35:return-1;case 176:case 177:case 7:case 155:case 8:case 157:case 125:case 126:case 92:case 93:case 129:case 130:case 131:case 94:case 91:return 1;case 74:case 60:case 69:case 70:case 4:return 1024;case 31:case 42:case 72:return 32;case 87:case 26:case 33:return 2147483647;case 34:case 1:return 47839;case 38:case 36:return 99;case 43:case 37:return 2048;case 0:return 2097152;case 3:return 65536;case 28:return 32768;case 44:return 32767;case 75:return 16384;case 39:return 1e3;case 89:return 700;case 71:return 256;case 40:return 255;case 2:return 100;case 180:return 64;case 25:return 20;case 5:return 16;case 6:return 6;case 73:return 4;case 84:{if(typeof navigator==="object")return navigator["hardwareConcurrency"]||1;return 1}}setErrNo(28);return-1}var readAsmConstArgsArray=[];function readAsmConstArgs(sigPtr,buf){readAsmConstArgsArray.length=0;var ch;buf>>=2;while(ch=HEAPU8[sigPtr++]){var double=ch<105;if(double&&buf&1)buf++;readAsmConstArgsArray.push(double?HEAPF64[buf++>>1]:HEAP32[buf]);++buf}return readAsmConstArgsArray}var GLctx;var asmLibraryArg={"Q":___sys_fcntl64,"P":___sys_open,"N":___sys_read,"a":_abort,"S":_clock,"b":_emscripten_asm_const_iii,"m":_emscripten_clear_interval,"C":_emscripten_get_canvas_element_size,"F":_emscripten_get_element_css_size,"J":_emscripten_memcpy_big,"K":_emscripten_resize_heap,"g":_emscripten_set_canvas_element_size,"ja":_emscripten_set_element_css_size,"n":_emscripten_set_interval,"H":_emscripten_set_keydown_callback_on_thread,"G":_emscripten_set_mousedown_callback_on_thread,"ma":_emscripten_set_touchstart_callback_on_thread,"ka":_emscripten_webgl_create_context,"s":_emscripten_webgl_destroy_context,"la":_emscripten_webgl_init_context_attributes,"c":_emscripten_webgl_make_context_current,"L":_environ_get,"M":_environ_sizes_get,"p":_fd_close,"O":_fd_fdstat_get,"I":_fd_seek,"o":_fd_write,"ca":get_do_str,"U":_gettimeofday,"f":_glActiveTexture,"u":_glAttachShader,"y":_glBindBuffer,"e":_glBindTexture,"x":_glBufferData,"D":_glClear,"E":_glClearColor,"fa":_glCompileShader,"Y":_glCreateProgram,"ha":_glCreateShader,"V":_glDeleteProgram,"l":_glDeleteShader,"ba":_glDeleteTextures,"$":_glDrawArrays,"v":_glEnableVertexAttribArray,"da":_glGenBuffers,"_":_glGenTextures,"z":_glGetAttribLocation,"ia":_glGetError,"W":_glGetProgramInfoLog,"t":_glGetProgramiv,"ea":_glGetShaderInfoLog,"B":_glGetShaderiv,"k":_glGetUniformLocation,"X":_glLinkProgram,"Z":_glPixelStorei,"ga":_glShaderSource,"i":_glTexImage2D,"d":_glTexParameterf,"j":_glUniform1i,"A":_glUseProgram,"w":_glVertexAttribPointer,"aa":_glViewport,"memory":wasmMemory,"q":_pthread_create,"r":_pthread_join,"T":_round,"h":_setTempRet0,"R":_sysconf,"table":wasmTable};var asm=createWasm();var ___wasm_call_ctors=Module["___wasm_call_ctors"]=function(){return(___wasm_call_ctors=Module["___wasm_call_ctors"]=Module["asm"]["na"]).apply(null,arguments)};var _nor=Module["_nor"]=function(){return(_nor=Module["_nor"]=Module["asm"]["oa"]).apply(null,arguments)};var ___em_js__get_do_str=Module["___em_js__get_do_str"]=function(){return(___em_js__get_do_str=Module["___em_js__get_do_str"]=Module["asm"]["pa"]).apply(null,arguments)};var _ng=Module["_ng"]=function(){return(_ng=Module["_ng"]=Module["asm"]["qa"]).apply(null,arguments)};var _nc=Module["_nc"]=function(){return(_nc=Module["_nc"]=Module["asm"]["ra"]).apply(null,arguments)};var _nd=Module["_nd"]=function(){return(_nd=Module["_nd"]=Module["asm"]["sa"]).apply(null,arguments)};var _ns=Module["_ns"]=function(){return(_ns=Module["_ns"]=Module["asm"]["ta"]).apply(null,arguments)};var _np=Module["_np"]=function(){return(_np=Module["_np"]=Module["asm"]["ua"]).apply(null,arguments)};var _nv=Module["_nv"]=function(){return(_nv=Module["_nv"]=Module["asm"]["va"]).apply(null,arguments)};var _nr=Module["_nr"]=function(){return(_nr=Module["_nr"]=Module["asm"]["wa"]).apply(null,arguments)};var _ni=Module["_ni"]=function(){return(_ni=Module["_ni"]=Module["asm"]["xa"]).apply(null,arguments)};var _nm=Module["_nm"]=function(){return(_nm=Module["_nm"]=Module["asm"]["ya"]).apply(null,arguments)};var _nb=Module["_nb"]=function(){return(_nb=Module["_nb"]=Module["asm"]["za"]).apply(null,arguments)};var _nk=Module["_nk"]=function(){return(_nk=Module["_nk"]=Module["asm"]["Aa"]).apply(null,arguments)};var _ne=Module["_ne"]=function(){return(_ne=Module["_ne"]=Module["asm"]["Ba"]).apply(null,arguments)};var _ny=Module["_ny"]=function(){return(_ny=Module["_ny"]=Module["asm"]["Ca"]).apply(null,arguments)};var _nar=Module["_nar"]=function(){return(_nar=Module["_nar"]=Module["asm"]["Da"]).apply(null,arguments)};var _nse=Module["_nse"]=function(){return(_nse=Module["_nse"]=Module["asm"]["Ea"]).apply(null,arguments)};var _ncv=Module["_ncv"]=function(){return(_ncv=Module["_ncv"]=Module["asm"]["Fa"]).apply(null,arguments)};var _main=Module["_main"]=function(){return(_main=Module["_main"]=Module["asm"]["Ga"]).apply(null,arguments)};var _malloc=Module["_malloc"]=function(){return(_malloc=Module["_malloc"]=Module["asm"]["Ha"]).apply(null,arguments)};var ___errno_location=Module["___errno_location"]=function(){return(___errno_location=Module["___errno_location"]=Module["asm"]["Ia"]).apply(null,arguments)};var stackSave=Module["stackSave"]=function(){return(stackSave=Module["stackSave"]=Module["asm"]["Ja"]).apply(null,arguments)};var stackRestore=Module["stackRestore"]=function(){return(stackRestore=Module["stackRestore"]=Module["asm"]["Ka"]).apply(null,arguments)};var stackAlloc=Module["stackAlloc"]=function(){return(stackAlloc=Module["stackAlloc"]=Module["asm"]["La"]).apply(null,arguments)};var dynCall_iiiiiiii=Module["dynCall_iiiiiiii"]=function(){return(dynCall_iiiiiiii=Module["dynCall_iiiiiiii"]=Module["asm"]["Ma"]).apply(null,arguments)};var dynCall_iiii=Module["dynCall_iiii"]=function(){return(dynCall_iiii=Module["dynCall_iiii"]=Module["asm"]["Na"]).apply(null,arguments)};var dynCall_vi=Module["dynCall_vi"]=function(){return(dynCall_vi=Module["dynCall_vi"]=Module["asm"]["Oa"]).apply(null,arguments)};var dynCall_vii=Module["dynCall_vii"]=function(){return(dynCall_vii=Module["dynCall_vii"]=Module["asm"]["Pa"]).apply(null,arguments)};var dynCall_ii=Module["dynCall_ii"]=function(){return(dynCall_ii=Module["dynCall_ii"]=Module["asm"]["Qa"]).apply(null,arguments)};var dynCall_viiiiii=Module["dynCall_viiiiii"]=function(){return(dynCall_viiiiii=Module["dynCall_viiiiii"]=Module["asm"]["Ra"]).apply(null,arguments)};var dynCall_viiii=Module["dynCall_viiii"]=function(){return(dynCall_viiii=Module["dynCall_viiii"]=Module["asm"]["Sa"]).apply(null,arguments)};var dynCall_v=Module["dynCall_v"]=function(){return(dynCall_v=Module["dynCall_v"]=Module["asm"]["Ta"]).apply(null,arguments)};var dynCall_dd=Module["dynCall_dd"]=function(){return(dynCall_dd=Module["dynCall_dd"]=Module["asm"]["Ua"]).apply(null,arguments)};var dynCall_iii=Module["dynCall_iii"]=function(){return(dynCall_iii=Module["dynCall_iii"]=Module["asm"]["Va"]).apply(null,arguments)};var dynCall_iiiiii=Module["dynCall_iiiiii"]=function(){return(dynCall_iiiiii=Module["dynCall_iiiiii"]=Module["asm"]["Wa"]).apply(null,arguments)};var dynCall_iiiiiii=Module["dynCall_iiiiiii"]=function(){return(dynCall_iiiiiii=Module["dynCall_iiiiiii"]=Module["asm"]["Xa"]).apply(null,arguments)};var dynCall_viiiii=Module["dynCall_viiiii"]=function(){return(dynCall_viiiii=Module["dynCall_viiiii"]=Module["asm"]["Ya"]).apply(null,arguments)};var dynCall_viii=Module["dynCall_viii"]=function(){return(dynCall_viii=Module["dynCall_viii"]=Module["asm"]["Za"]).apply(null,arguments)};var dynCall_viifi=Module["dynCall_viifi"]=function(){return(dynCall_viifi=Module["dynCall_viifi"]=Module["asm"]["_a"]).apply(null,arguments)};var dynCall_fiii=Module["dynCall_fiii"]=function(){return(dynCall_fiii=Module["dynCall_fiii"]=Module["asm"]["$a"]).apply(null,arguments)};var dynCall_viidi=Module["dynCall_viidi"]=function(){return(dynCall_viidi=Module["dynCall_viidi"]=Module["asm"]["ab"]).apply(null,arguments)};var dynCall_iiiii=Module["dynCall_iiiii"]=function(){return(dynCall_iiiii=Module["dynCall_iiiii"]=Module["asm"]["bb"]).apply(null,arguments)};var dynCall_viiiifii=Module["dynCall_viiiifii"]=function(){return(dynCall_viiiifii=Module["dynCall_viiiifii"]=Module["asm"]["cb"]).apply(null,arguments)};var dynCall_fii=Module["dynCall_fii"]=function(){return(dynCall_fii=Module["dynCall_fii"]=Module["asm"]["db"]).apply(null,arguments)};var dynCall_viiiiiifi=Module["dynCall_viiiiiifi"]=function(){return(dynCall_viiiiiifi=Module["dynCall_viiiiiifi"]=Module["asm"]["eb"]).apply(null,arguments)};var dynCall_viiiiiiiii=Module["dynCall_viiiiiiiii"]=function(){return(dynCall_viiiiiiiii=Module["dynCall_viiiiiiiii"]=Module["asm"]["fb"]).apply(null,arguments)};var dynCall_viiiiiiiiii=Module["dynCall_viiiiiiiiii"]=function(){return(dynCall_viiiiiiiiii=Module["dynCall_viiiiiiiiii"]=Module["asm"]["gb"]).apply(null,arguments)};var dynCall_viiiiiiii=Module["dynCall_viiiiiiii"]=function(){return(dynCall_viiiiiiii=Module["dynCall_viiiiiiii"]=Module["asm"]["hb"]).apply(null,arguments)};var dynCall_viiiiiii=Module["dynCall_viiiiiii"]=function(){return(dynCall_viiiiiii=Module["dynCall_viiiiiii"]=Module["asm"]["ib"]).apply(null,arguments)};var dynCall_viiijj=Module["dynCall_viiijj"]=function(){return(dynCall_viiijj=Module["dynCall_viiijj"]=Module["asm"]["jb"]).apply(null,arguments)};var dynCall_iiiiiiidiiddii=Module["dynCall_iiiiiiidiiddii"]=function(){return(dynCall_iiiiiiidiiddii=Module["dynCall_iiiiiiidiiddii"]=Module["asm"]["kb"]).apply(null,arguments)};var dynCall_jij=Module["dynCall_jij"]=function(){return(dynCall_jij=Module["dynCall_jij"]=Module["asm"]["lb"]).apply(null,arguments)};var dynCall_jii=Module["dynCall_jii"]=function(){return(dynCall_jii=Module["dynCall_jii"]=Module["asm"]["mb"]).apply(null,arguments)};var dynCall_jiji=Module["dynCall_jiji"]=function(){return(dynCall_jiji=Module["dynCall_jiji"]=Module["asm"]["za"]).apply(null,arguments)};var dynCall_iidiiii=Module["dynCall_iidiiii"]=function(){return(dynCall_iidiiii=Module["dynCall_iidiiii"]=Module["asm"]["ob"]).apply(null,arguments)};Module["_ff_h264_cabac_tables"]=156414;var calledRun;function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}var calledMain=false;dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function callMain(args){var entryFunction=Module["_main"];var argc=0;var argv=0;try{var ret=entryFunction(argc,argv);exit(ret,true)}catch(e){if(e instanceof ExitStatus){return}else if(e=="unwind"){noExitRuntime=true;return}else{var toLog=e;if(e&&typeof e==="object"&&e.stack){toLog=[e,e.stack]}err("exception thrown: "+toLog);quit_(1,e)}}finally{calledMain=true}}function run(args){args=args||arguments_;if(runDependencies>0){return}preRun();if(runDependencies>0)return;function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();preMain();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();if(shouldRunNow)callMain(args);postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}Module["run"]=run;function exit(status,implicit){if(implicit&&noExitRuntime&&status===0){return}if(noExitRuntime){}else{ABORT=true;EXITSTATUS=status;exitRuntime();if(Module["onExit"])Module["onExit"](status)}quit_(status,new ExitStatus(status))}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}var shouldRunNow=true;if(Module["noInitialRun"])shouldRunNow=false;noExitRuntime=true;run();var NodePlayer=function(){null;var c=Math.abs,g=Math.ceil,f=Math.min,p=Math.floor,E=String.fromCharCode;function e(){let e=new class{constructor(){this.inBytes=0,this.outBytes=0,this.reader=null,this.chunkSize=1048576,this.fetchAbortController=new AbortController,this.requestAbort=!1}pull(){this.reader.read().then(({done:e,value:t})=>{if(e)self.postMessage({func:"stop"});else{if(this.requestAbort)return this.requestAbort=!1,void this.reader.cancel();this.inBytes+=t.length,self.postMessage({func:"data",arg:t}),this.pull()}}).catch(t=>this.requestAbort?(this.requestAbort=!1,void this.postMessage({func:"stop"})):void self.postMessage({func:"error",arg:{code:-3,msg:t.message}}))}start(e){this.url=e,fetch(this.url,{signal:this.fetchAbortController.signal}).then(e=>{e.ok&&200<=e.status&&299>=e.status?(this.reader=e.body.getReader(),self.postMessage({func:"start"}),this.pull()):self.postMessage({func:"error",arg:{code:e.status,msg:e.statusText}})}).catch(t=>this.requestAbort?(this.requestAbort=!1,void self.postMessage({func:"stop"})):void self.postMessage({func:"error",arg:{code:-2,msg:t.message}}))}stop(){this.inBytes=0,this.requestAbort=!0,this.fetchAbortController.abort()}send(){}};onmessage=(t=>{const{func:A,arg:n}=t.data;"start"===A?e.start(n.url,n.isVod):"stop"===A?e.stop():"send"===A?e.send(n.data):void 0})}function t(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function A(e){return"function"==typeof e}function a(e){return"number"==typeof e}function r(e){return"object"==typeof e&&null!==e}function d(e){return void 0===e}function o(){return Object.assign({},q)}function s(e,t,A){let n=e;if(t+A<n.length){for(;A--;)if(128!=(192&n[++t]))return!1;return!0}return!1}function _(e){let t=[],A=e,n=0,a=e.length;for(;n<a;){if(128>A[n]){t.push(E(A[n])),++n;continue}else if(192>A[n]);else if(224>A[n]){if(s(A,n,1)){let e=(31&A[n])<<6|63&A[n+1];if(128<=e){t.push(E(65535&e)),n+=2;continue}}}else if(240>A[n]){if(s(A,n,2)){let e=(15&A[n])<<12|(63&A[n+1])<<6|63&A[n+2];if(2048<=e&&55296!=(63488&e)){t.push(E(65535&e)),n+=3;continue}}}else if(248>A[n]&&s(A,n,3)){let e=(7&A[n])<<18|(63&A[n+1])<<12|(63&A[n+2])<<6|63&A[n+3];if(65536<e&&1114112>e){e-=65536,t.push(E(55296|e>>>10)),t.push(E(56320|1023&e)),n+=4;continue}}t.push(E(65533)),++n}return t.join("")}function u(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function m(e,t){let A=e;if(null==A||"object"!=typeof A)throw new T("MediaDataSource must be an javascript object!");if(!A.hasOwnProperty("type"))throw new T("MediaDataSource must has type field to indicate video file type!");switch(A.type){case"flv":return new me(A,t);default:return new le(A,t)}}function l(){return H.supportMSEH264Playback()}const S={nc:cwrap("nc","number",["number"]),nd:cwrap("nd","number",["number"]),ns:cwrap("ns","number",["number","string"]),np:cwrap("np","number",["number"]),ni:cwrap("ni","number",["number","array","number"]),ng:cwrap("ng","string"),nv:cwrap("nv","number",["number","string","number"]),nm:cwrap("nm","number",["number","number"]),nb:cwrap("nb","number",["number","number"]),nk:cwrap("nk","number",["number","number"]),ne:cwrap("ne","number",["number","number"]),nr:cwrap("nr","number",["number","number","number","number"]),ny:cwrap("ny","number",["number","string"]),nor:cwrap("nor","number",["number","number"]),nar:cwrap("nar","number",["number"]),nse:cwrap("nse","number",["number","number"]),ncv:cwrap("ncv","number",["number"])};document.addEventListener("fullscreenchange",e=>{e.target.ctx&&(document.fullscreenElement?0<e.target.offsetHeight&&0<e.target.offsetHeight&&S.nr(e.target.ctx,e.target.offsetWidth,e.target.offsetHeight,1):S.nr(e.target.ctx,e.target.tw,e.target.th,1))});class B extends t{constructor(){super(),this.wakeLock=new L,this.isMobile=/(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent)?1:0,this.isLegacyQQ="function"==typeof window.ReadableStream&&"function"==typeof window.Response&&!Object.prototype.hasOwnProperty.call(window.Response.prototype,"body"),this.ctx=S.nc(this.isMobile),this.dpr=window.devicePixelRatio||1,this.rpr=screen.width/document.documentElement.clientWidth*this.dpr,this.version=S.ng(),this.isStart=!1,this.isMSE=!1,this.hasAudio=!0,this.volume=1,this.eventFlags=0,this.screenCount=0,this.connTimeout=0,this.connTimer=null,this.screenshotImage1=null,this.screenshotImage2=null,this.loader=this.isLegacyQQ?new I:new V,this.loader.on("data",e=>{let t=new Uint8Array(e);0<S.ni(this.ctx,t,t.length)&&this.stop()}),this.loader.on("start",()=>{this.emit("start")}),this.loader.on("close",()=>{this.stop()}),this.loader.on("error",t=>{this.emit("error",t),this.stop()}),NP[this.ctx].emit=this.emit.bind(this),this.on("buffer",e=>{0<this.connTimeout&&(this._clearTimeout(),"empty"===e&&(this.connTimer=setTimeout(()=>{this.emit("timeout")},1e3*this.connTimeout)))})}on(e,t){super.on(e,t),"videoSei"===e?this.eventFlags|=1:"videoFrame"==e&&(this.eventFlags|=2),S.nse(this.ctx,this.eventFlags)}setTimeout(e){0<e?this.connTimeout=e:this._clearTimeout()}_clearTimeout(){null!=this.connTimer&&(clearTimeout(this.connTimer),this.connTimer=null)}setView(e){if(this.isMSE){let t=document.getElementById(e),A=document.createElement("video"),n=t.parentNode;A.id=e,300!=t.width&&150!=t.height&&(A.width=t.width,A.height=t.height),A.style.cssText=t.style.cssText,n.replaceChild(A,t),this.ve=A}else return this.ve=document.getElementById(e),this.ve.ctx=this.ctx,NP[this.ctx].ve=this.ve,S.nv(this.ctx,"#"+e,this.dpr,this.rpr)}resizeView(e,t){this.isMSE||S.nr(this.ctx,e,t,0)}setKeepScreenOn(){this.wakeLock.keepOn=!0}setScaleMode(e){return S.nm(this.ctx,e)}setBufferTime(e){return S.nb(this.ctx,e)}skipLoopFilter(e){return S.nk(this.ctx,e)}setVolume(e){this.volume=e,this.isMSE?this.flvPlayer&&(this.flvPlayer.volume=e):S.ne(this.ctx,e)}setCryptoKey(e){S.ny(this.ctx,e)}enableAudio(e){this.hasAudio=e,e||(this.volume=0)}audioResume(){S.nar(this.ctx)}launchIntoFullscreen(e){e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen()}fullscreen(){this.ve.tw=this.ve.width,this.ve.th=this.ve.height,this.launchIntoFullscreen(this.ve)}fullWebview(e){this.ve.tmpcss=this.ve.style.cssText,this.ve.style.cssText="width:100%;height:100%;position:absolute;top: 0;left: 0;z-index: -1;",S.nor(this.ctx,e)}exitFullWebview(){void 0===this.ve.tmpcss||""===this.ve.tmpcss||(this.ve.style.cssText=this.ve.tmpcss,S.nor(this.ctx,0))}onResize(e){S.nor(this.ctx,e)}screenshot(e,t,A){if(this.isStart&&10>this.screenCount++){if(null==this.screenshotImage1)return this.screenshotImage1=this.ve.toDataURL("image/"+t,A),void setTimeout(()=>{this.screenshot(e,t,A)},100);if(null==this.screenshotImage2&&(this.screenshotImage2=this.ve.toDataURL("image/"+t,A)),this.screenshotImage1.length===this.screenshotImage2.length)return this.screenshotImage2=null,void setTimeout(()=>{this.screenshot(e,t,A)},100);var n=document.createElement("a");n.href=this.screenshotImage1.length>this.screenshotImage2.length?this.screenshotImage1:this.screenshotImage2,n.download=e,n.click(),this.screenCount=0,this.screenshotImage1=null,this.screenshotImage2=null}else this.screenCount=0,this.screenshotImage1=null,this.screenshotImage2=null,this.emit("error","screenshot error")}start(e){if(this.isMSE){if(this.flvPlayer)return;let t={type:"flv",url:e};this.hasAudio||(t.hasAudio=!1),this.flvPlayer=m(t),this.flvPlayer.attachMediaElement(this.ve),this.flvPlayer.on(W.ERROR,e=>{this.emit("error",e),this.stop()}),this.flvPlayer.on(W.LOADING_COMPLETE,()=>{this.stop()}),this.flvPlayer.on(W.MEDIA_INFO,()=>{this.isStart||(this.isStart=!0,this.emit("start"))}),this.flvPlayer.load(),this.flvPlayer.play().catch(()=>{})}else{if("string"!=typeof e)return void NP_ERROR("url invalid parameter");if(this.isStart)return void NP_DEBUG("The instance has started, ignore it");NP_LOG("call start play url:",e),this.url=e,this.wakeLock.enable(),0==S.ns(this.ctx,e)&&(this.setVolume(this.volume),this._createHtmlAudio(),this.loader.start(e),this.isStart=!0)}}stop(){if(this.isMSE)this.flvPlayer&&(this.flvPlayer.detachMediaElement(),this.flvPlayer.unload(),this.flvPlayer.destroy(),this.flvPlayer=null,this.emit("stop"),this.isStart=!1);else{if(!this.isStart)return void NP_DEBUG("The instance has not started yet, ignore it");NP_LOG("call stop play url:",this.url),this.wakeLock.disable(),this.isStart=!1,this.loader.stop(),this._clearTimeout(),this._releaseHtmlAudio(),S.np(this.ctx),this.emit("stop")}}_releaseHtmlAudio(){this.htmlAudio&&(this.htmlAudio.pause(),this.htmlAudio.removeAttribute("src"),this.htmlAudio=null)}_createHtmlAudio(){const e=window.webkitAudioContext,t=/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)&&null!=e;if(t){const t=(new e).sampleRate;let A=document.createElement("audio"),n=this._createSilentAudioFile(t);A.setAttribute("x-webkit-airplay","deny"),A.preload="auto",A.src=n,A.load(),A.play(),this.htmlAudio=A}}_createSilentAudioFile(e){const t=new ArrayBuffer(10),A=new DataView(t);A.setUint32(0,e,!0),A.setUint32(4,e,!0),A.setUint16(8,1,!0);const n=window.btoa(E(...new Uint8Array(t))).slice(0,13);return`data:audio/wav;base64,UklGRisAAABXQVZFZm10IBAAAAABAAEA${n}AgAZGF0YQcAAACAgICAgICAAAA=`}clearView(){S.ncv(this.ctx)}release(e){this.isMSE||(this.stop(),S.nd(this.ctx,e)),delete NP[this.ctx],this.ctx=null,this.loader=null,this.wakeLock=null}useMSE(){this.isMSE=l(),NP_LOG("use MSE:",this.isMSE?"YES":"NO"),this.isMSE&&(this.flvPlayer=null,K.enableAll=!1,K.addLogListener(function(e,t){NP_LOG(e+t)}))}static debug(e){logType=e?LOG_TYPES.NP_TYPE_NORMAL:LOG_TYPES.NP_TYPE_NONE}static load(e){window.npAllReadyFlag?e():setTimeout(B.load.bind(this,e),100)}static asyncLoad(){return new Promise(e=>{B.load(()=>{e()})})}}class R{constructor(){this.inBytes=0,this.outBytes=0,this.socket=null}start(e){this.socket=new WebSocket(e),this.socket.binaryType="arraybuffer",this.socket.onopen=(()=>{this.emit("start")}),this.socket.onclose=(()=>{this.emit("stop")}),this.socket.onerror=(e=>{this.emit("error",e)}),this.socket.onmessage=(e=>{try{let t=new Uint8Array(e.data);this.inBytes+=t.length,this.emit("data",t)}catch(t){this.emit("error",{code:-3,msg:t.message})}})}postMessage(){}stop(){this.inBytes=0,this.outBytes=0,this.socket.close(),this.socket=null}send(e){this.outBytes+=e.byteLength,this.socket.send(e)}}class I extends t{constructor(e){super(),this.loader=null,this.opt=e,this.isVod=!1}getFuncBody(e){return e.trim().match(/^function\s*\w*\s*\([\w\s,]*\)\s*{([\w\W]*?)}$/)[1]}start(t){if(null!=this.loader)this.emit("error",{code:-1,msg:"WebLoader has started."});else if(/^ws{1,2}:|^rtmp:|^rtsp:/i.test(t))this.loader=new R,this.loader.emit=this.emit.bind(this),this.loader.terminate=this.loader.stop,this.loader.start(t);else{const A=this.getFuncBody(e.toString()),n=new Blob([A],{type:"text/javascript"});this.workerURL=URL.createObjectURL(n),this.loader=new Worker(this.workerURL),this.loader.onmessage=(e=>{const{func:t,arg:A}=e.data;this.emit(t,A)}),this.loader.postMessage({func:"start",arg:{url:t}})}}stop(){null==this.loader?this.emit("error",{code:-1,msg:"Webloader has not been started yet."}):(this.loader.postMessage({func:"stop"}),this.loader.terminate(),this.loader=null)}send(e){this.loader.send(e)}}class L{constructor(){this.keepOn=!1,this.needRun=!0,this.wakeLockVideo=document.createElement("video"),this.wakeLockVideo.setAttribute("muted",""),this.wakeLockVideo.setAttribute("preload","auto"),this.wakeLockVideo.setAttribute("title","No Sleep"),this.wakeLockVideo.setAttribute("playsinline","");let e=this._getMobileOperatingSystem();"iOS"===e||"WX"===e||"QQ"===e?(this._addSourceToVideo(this.wakeLockVideo,"mp4","data:video/mp4;base64,AAAAIGZ0eXBtcDQyAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAACKBtZGF0AAAC8wYF///v3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE0MiByMjQ3OSBkZDc5YTYxIC0gSC4yNjQvTVBFRy00IEFWQyBjb2RlYyAtIENvcHlsZWZ0IDIwMDMtMjAxNCAtIGh0dHA6Ly93d3cudml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AAAAADNlc2RzAAAAAAOAgIAiAAIABICAgBRAFQAAAAADDUAAAAAABYCAgAISEAaAgIABAgAAABhzdHRzAAAAAAAAAAEAAABYAAAEAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAQAAAAEAAAAUc3RzegAAAAAAAAAGAAAAWAAAAXBzdGNvAAAAAAAAAFgAAAOBAAADhwAAA5oAAAOtAAADswAAA8oAAAPfAAAD5QAAA/gAAAQLAAAEEQAABCgAAAQ9AAAEUAAABFYAAARpAAAEgAAABIYAAASbAAAErgAABLQAAATHAAAE3gAABPMAAAT5AAAFDAAABR8AAAUlAAAFPAAABVEAAAVXAAAFagAABX0AAAWDAAAFmgAABa8AAAXCAAAFyAAABdsAAAXyAAAF+AAABg0AAAYgAAAGJgAABjkAAAZQAAAGZQAABmsAAAZ+AAAGkQAABpcAAAauAAAGwwAABskAAAbcAAAG7wAABwYAAAcMAAAHIQAABzQAAAc6AAAHTQAAB2QAAAdqAAAHfwAAB5IAAAeYAAAHqwAAB8IAAAfXAAAH3QAAB/AAAAgDAAAICQAACCAAAAg1AAAIOwAACE4AAAhhAAAIeAAACH4AAAiRAAAIpAAACKoAAAiwAAAItgAACLwAAAjCAAAAFnVkdGEAAAAObmFtZVN0ZXJlbwAAAHB1ZHRhAAAAaG1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAAO2lsc3QAAAAzqXRvbwAAACtkYXRhAAAAAQAAAABIYW5kQnJha2UgMC4xMC4yIDIwMTUwNjExMDA="),this.wakeLockVideo.addEventListener("loadedmetadata",()=>{}),this.wakeLockVideo.addEventListener("timeupdate",()=>{1.5<this.wakeLockVideo.currentTime&&(this.wakeLockVideo.currentTime=.2)})):"Android"===e?(this._addSourceToVideo(this.wakeLockVideo,"webm","data:video/webm;base64,GkXfowEAAAAAAAAfQoaBAUL3gQFC8oEEQvOBCEKChHdlYm1Ch4EEQoWBAhhTgGcBAAAAAAATGxFNm3RAO027i1OrhBVJq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AAARu4+zgQO3iveBAfGCA+HwgRk="),this.wakeLockVideo.addEventListener("loadedmetadata",()=>{this.wakeLockVideo.setAttribute("loop","")}),this.wakeLockVideo.addEventListener("timeupdate",()=>{})):this.needRun=!1}_addSourceToVideo(e,t,A){var n=document.createElement("source");n.src=A,n.type=`video/${t}`,e.appendChild(n)}_getMobileOperatingSystem(){var e=navigator.userAgent||navigator.vendor||window.opera;return/MicroMessenger/i.test(e)?"WX":/QQ/i.test(e)?"QQ":/android/i.test(e)?"Android":/iPad|iPhone|iPod/.test(e)&&!window.MSStream?"iOS":"unknown"}enable(){this.needRun&&this.keepOn&&this.wakeLockVideo.play()}disable(){this.needRun&&this.keepOn&&this.wakeLockVideo.pause()}}t.EventEmitter=t,t.prototype._events=void 0,t.prototype._maxListeners=void 0,t.defaultMaxListeners=10,t.prototype.setMaxListeners=function(e){if(!a(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},t.prototype.emit=function(e){var t,n,a,o,s,_;if(this._events||(this._events={}),"error"===e&&(!this._events.error||r(this._events.error)&&!this._events.error.length))if(t=arguments[1],t instanceof Error)throw t;else{var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}if(n=this._events[e],d(n))return!1;if(A(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:o=Array.prototype.slice.call(arguments,1),n.apply(this,o)}else if(r(n))for(o=Array.prototype.slice.call(arguments,1),_=n.slice(),a=_.length,s=0;s<a;s++)_[s].apply(this,o);return!0},t.prototype.addListener=function(e,n){var a;if(!A(n))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,A(n.listener)?n.listener:n),this._events[e]?r(this._events[e])?this._events[e].push(n):this._events[e]=[this._events[e],n]:this._events[e]=n,r(this._events[e])&&!this._events[e].warned&&(a=d(this._maxListeners)?t.defaultMaxListeners:this._maxListeners,a&&0<a&&this._events[e].length>a&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},t.prototype.on=t.prototype.addListener,t.prototype.once=function(e,t){function n(){this.removeListener(e,n),a||(a=!0,t.apply(this,arguments))}if(!A(t))throw TypeError("listener must be a function");var a=!1;return n.listener=t,this.on(e,n),this},t.prototype.removeListener=function(e,t){var n,a,d,o;if(!A(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],d=n.length,a=-1,n===t||A(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(r(n)){for(o=d;0<o--;)if(n[o]===t||n[o].listener&&n[o].listener===t){a=o;break}if(0>a)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(a,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},t.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],A(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},t.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?A(this._events[e])?[this._events[e]]:this._events[e].slice():[],t},t.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(A(t))return 1;if(t)return t.length}return 0},t.listenerCount=function(e,t){return e.listenerCount(t)};class C{static install(){Object.setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Object.assign=Object.assign||function(e){if(void 0===e||null===e)throw new TypeError("Cannot convert undefined or null to object");let t=Object(e);for(let A,n=1;n<arguments.length;n++)if(A=arguments[n],void 0!==A&&null!==A)for(let e in A)A.hasOwnProperty(e)&&(t[e]=A[e]);return t},"function"!=typeof self.Promise&&require("es6-promise").polyfill()}}C.install();class y{static e(e,t){(!e||y.FORCE_GLOBAL_TAG)&&(e=y.GLOBAL_TAG);let A=`[${e}] > ${t}`;y.ENABLE_CALLBACK&&y.emitter.emit("log","error",A),y.ENABLE_ERROR&&(console.error?console.error(A):console.warn?console.warn(A):console.log(A))}static i(e,t){(!e||y.FORCE_GLOBAL_TAG)&&(e=y.GLOBAL_TAG);let A=`[${e}] > ${t}`;y.ENABLE_CALLBACK&&y.emitter.emit("log","info",A),y.ENABLE_INFO&&(console.info?console.info(A):console.log(A))}static w(e,t){(!e||y.FORCE_GLOBAL_TAG)&&(e=y.GLOBAL_TAG);let A=`[${e}] > ${t}`;y.ENABLE_CALLBACK&&y.emitter.emit("log","warn",A),y.ENABLE_WARN&&(console.warn?console.warn(A):console.log(A))}static d(e,t){(!e||y.FORCE_GLOBAL_TAG)&&(e=y.GLOBAL_TAG);let A=`[${e}] > ${t}`;y.ENABLE_CALLBACK&&y.emitter.emit("log","debug",A),y.ENABLE_DEBUG&&(console.debug?console.debug(A):console.log(A))}static v(e,t){(!e||y.FORCE_GLOBAL_TAG)&&(e=y.GLOBAL_TAG);let A=`[${e}] > ${t}`;y.ENABLE_CALLBACK&&y.emitter.emit("log","verbose",A),y.ENABLE_VERBOSE&&console.log(A)}}y.GLOBAL_TAG="flv.js",y.FORCE_GLOBAL_TAG=!1,y.ENABLE_ERROR=!0,y.ENABLE_INFO=!0,y.ENABLE_WARN=!0,y.ENABLE_DEBUG=!0,y.ENABLE_VERBOSE=!0,y.ENABLE_CALLBACK=!1,y.emitter=new t;class v{constructor(){this._firstCheckpoint=0,this._lastCheckpoint=0,this._intervalBytes=0,this._totalBytes=0,this._lastSecondBytes=0,this._now=self.performance&&self.performance.now?self.performance.now.bind(self.performance):Date.now}reset(){this._firstCheckpoint=this._lastCheckpoint=0,this._totalBytes=this._intervalBytes=0,this._lastSecondBytes=0}addBytes(e){0===this._firstCheckpoint?(this._firstCheckpoint=this._now(),this._lastCheckpoint=this._firstCheckpoint,this._intervalBytes+=e,this._totalBytes+=e):1e3>this._now()-this._lastCheckpoint?(this._intervalBytes+=e,this._totalBytes+=e):(this._lastSecondBytes=this._intervalBytes,this._intervalBytes=e,this._totalBytes+=e,this._lastCheckpoint=this._now())}get currentKBps(){this.addBytes(0);let e=(this._now()-this._lastCheckpoint)/1e3;return 0==e&&(e=1),this._intervalBytes/e/1024}get lastSecondKBps(){return this.addBytes(0),0===this._lastSecondBytes?500<=this._now()-this._lastCheckpoint?this.currentKBps:0:this._lastSecondBytes/1024}get averageKBps(){let e=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/e/1024}}class b{constructor(e){this._message=e}get name(){return"RuntimeException"}get message(){return this._message}toString(){return this.name+": "+this.message}}class D extends b{constructor(e){super(e)}get name(){return"IllegalStateException"}}class T extends b{constructor(e){super(e)}get name(){return"InvalidArgumentException"}}class k extends b{constructor(e){super(e)}get name(){return"NotImplementedException"}}const O={kIdle:0,kConnecting:1,kBuffering:2,kError:3,kComplete:4},w={OK:"OK",EXCEPTION:"Exception",HTTP_STATUS_CODE_INVALID:"HttpStatusCodeInvalid",CONNECTING_TIMEOUT:"ConnectingTimeout",EARLY_EOF:"EarlyEof",UNRECOVERABLE_EARLY_EOF:"UnrecoverableEarlyEof"};class x{constructor(e){this._type=e||"undefined",this._status=O.kIdle,this._needStash=!1,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}destroy(){this._status=O.kIdle,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}isWorking(){return this._status===O.kConnecting||this._status===O.kBuffering}get type(){return this._type}get status(){return this._status}get needStashBuffer(){return this._needStash}get onContentLengthKnown(){return this._onContentLengthKnown}set onContentLengthKnown(e){this._onContentLengthKnown=e}get onURLRedirect(){return this._onURLRedirect}set onURLRedirect(e){this._onURLRedirect=e}get onDataArrival(){return this._onDataArrival}set onDataArrival(e){this._onDataArrival=e}get onError(){return this._onError}set onError(e){this._onError=e}get onComplete(){return this._onComplete}set onComplete(e){this._onComplete=e}open(){throw new k("Unimplemented abstract function!")}abort(){throw new k("Unimplemented abstract function!")}}let G={};(function(){let e=self.navigator.userAgent.toLowerCase(),t=/(edge)\/([\w.]+)/.exec(e)||/(opr)[\/]([\w.]+)/.exec(e)||/(chrome)[ \/]([\w.]+)/.exec(e)||/(iemobile)[\/]([\w.]+)/.exec(e)||/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||0<=e.indexOf("trident")&&/(rv)(?::| )([\w.]+)/.exec(e)||0>e.indexOf("compatible")&&/(firefox)[ \/]([\w.]+)/.exec(e)||[],A=/(ipad)/.exec(e)||/(ipod)/.exec(e)||/(windows phone)/.exec(e)||/(iphone)/.exec(e)||/(kindle)/.exec(e)||/(android)/.exec(e)||/(windows)/.exec(e)||/(mac)/.exec(e)||/(linux)/.exec(e)||/(cros)/.exec(e)||[],n={browser:t[5]||t[3]||t[1]||"",version:t[2]||t[4]||"0",majorVersion:t[4]||t[2]||"0",platform:A[0]||""},a={};if(n.browser){a[n.browser]=!0;let e=n.majorVersion.split(".");a.version={major:parseInt(n.majorVersion,10),string:n.version},1<e.length&&(a.version.minor=parseInt(e[1],10)),2<e.length&&(a.version.build=parseInt(e[2],10))}if(n.platform&&(a[n.platform]=!0),(a.chrome||a.opr||a.safari)&&(a.webkit=!0),a.rv||a.iemobile){a.rv&&delete a.rv;n.browser="msie",a.msie=!0}if(a.edge){delete a.edge;n.browser="msedge",a.msedge=!0}if(a.opr){n.browser="opera",a.opera=!0}if(a.safari&&a.android){n.browser="android",a.android=!0}for(let e in a.name=n.browser,a.platform=n.platform,G)G.hasOwnProperty(e)&&delete G[e];Object.assign(G,a)})();class M extends x{static isSupported(){try{let e=G.msedge&&15048<=G.version.minor,t=!G.msedge||e;return self.fetch&&self.ReadableStream&&t}catch(t){return!1}}constructor(e,t){super("fetch-stream-loader"),this.TAG="FetchStreamLoader",this._seekHandler=e,this._config=t,this._needStash=!0,this._requestAbort=!1,this._contentLength=null,this._receivedLength=0,this._reader=null}destroy(){this.isWorking()&&this.abort(),super.destroy()}open(e,t){let A=null;if(self.AbortController){let e=new self.AbortController;A=e.signal,this._fetchAbortController=e}this._dataSource=e,this._range=t;let n=e.url;this._config.reuseRedirectedURL&&null!=e.redirectedURL&&(n=e.redirectedURL);let a=this._seekHandler.getConfig(n,t),r=new self.Headers;if("object"==typeof a.headers){let e=a.headers;for(let t in e)e.hasOwnProperty(t)&&r.append(t,e[t])}let i={method:"GET",headers:r,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade",signal:A};if("object"==typeof this._config.headers)for(let e in this._config.headers)r.append(e,this._config.headers[e]);!1===e.cors&&(i.mode="same-origin"),e.withCredentials&&(i.credentials="include"),e.referrerPolicy&&(i.referrerPolicy=e.referrerPolicy),this._status=O.kConnecting,self.fetch(a.url,i).then(e=>{if(this._requestAbort)return this._requestAbort=!1,void(this._status=O.kIdle);if(e.ok&&200<=e.status&&299>=e.status){if(e.url!==a.url&&this._onURLRedirect){let t=this._seekHandler.removeURLParameters(e.url);this._onURLRedirect(t)}let t=e.headers.get("Content-Length");return null!=t&&(this._contentLength=parseInt(t),0!==this._contentLength&&this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)),this._pump.call(this,e.body.getReader())}if(this._status=O.kError,this._onError)this._onError(w.HTTP_STATUS_CODE_INVALID,{code:e.status,msg:e.statusText});else throw new b("FetchStreamLoader: Http code invalid, "+e.status+" "+e.statusText)}).catch(t=>{if(this._requestAbort)return void(this._requestAbort=!1);if(this._status=O.kError,this._onError)this._onError(w.EXCEPTION,{code:-1,msg:t.message});else throw t})}abort(){this._requestAbort=!0,this._fetchAbortController&&this._fetchAbortController.abort()}_pump(e){return e.read().then(t=>{if(!t.done){if(!0===this._requestAbort)return this._requestAbort=!1,this._status=O.kComplete,e.cancel();this._status=O.kBuffering;let A=t.value.buffer,n=this._range.from+this._receivedLength;this._receivedLength+=A.byteLength,this._onDataArrival&&this._onDataArrival(A,n,this._receivedLength),this._pump(e)}else if(null!==this._contentLength&&this._receivedLength<this._contentLength){this._status=O.kError;let e=w.EARLY_EOF,t={code:-1,msg:"Fetch stream meet Early-EOF"};if(this._onError)this._onError(e,t);else throw new b(t.msg)}else this._status=O.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1)}).catch(t=>{if(this._requestAbort)return void(this._requestAbort=!1);if(11===t.code&&G.msedge)return;this._status=O.kError;let e=0,A=null;if((19===t.code||"network error"===t.message)&&(null===this._contentLength||null!==this._contentLength&&this._receivedLength<this._contentLength)?(e=w.EARLY_EOF,A={code:t.code,msg:"Fetch stream meet Early-EOF"}):(e=w.EXCEPTION,A={code:t.code,msg:t.message}),this._onError)this._onError(e,A);else throw new b(A.msg)})}}class Q extends x{static isSupported(){try{let e=new XMLHttpRequest;return e.open("GET","https://example.com",!0),e.responseType="moz-chunked-arraybuffer","moz-chunked-arraybuffer"===e.responseType}catch(t){return y.w("MozChunkedLoader",t.message),!1}}constructor(e,t){super("xhr-moz-chunked-loader"),this.TAG="MozChunkedLoader",this._seekHandler=e,this._config=t,this._needStash=!0,this._xhr=null,this._requestAbort=!1,this._contentLength=null,this._receivedLength=0}destroy(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onloadend=null,this._xhr.onerror=null,this._xhr=null),super.destroy()}open(e,t){this._dataSource=e,this._range=t;let A=e.url;this._config.reuseRedirectedURL&&null!=e.redirectedURL&&(A=e.redirectedURL);let n=this._seekHandler.getConfig(A,t);this._requestURL=n.url;let a=this._xhr=new XMLHttpRequest;if(a.open("GET",n.url,!0),a.responseType="moz-chunked-arraybuffer",a.onreadystatechange=this._onReadyStateChange.bind(this),a.onprogress=this._onProgress.bind(this),a.onloadend=this._onLoadEnd.bind(this),a.onerror=this._onXhrError.bind(this),e.withCredentials&&(a.withCredentials=!0),"object"==typeof n.headers){let e=n.headers;for(let t in e)e.hasOwnProperty(t)&&a.setRequestHeader(t,e[t])}if("object"==typeof this._config.headers){let e=this._config.headers;for(let t in e)e.hasOwnProperty(t)&&a.setRequestHeader(t,e[t])}this._status=O.kConnecting,a.send()}abort(){this._requestAbort=!0,this._xhr&&this._xhr.abort(),this._status=O.kComplete}_onReadyStateChange(t){let e=t.target;if(2===e.readyState){if(null!=e.responseURL&&e.responseURL!==this._requestURL&&this._onURLRedirect){let t=this._seekHandler.removeURLParameters(e.responseURL);this._onURLRedirect(t)}if(!(0!==e.status&&(200>e.status||299<e.status)))this._status=O.kBuffering;else if(this._status=O.kError,this._onError)this._onError(w.HTTP_STATUS_CODE_INVALID,{code:e.status,msg:e.statusText});else throw new b("MozChunkedLoader: Http code invalid, "+e.status+" "+e.statusText)}}_onProgress(t){if(this._status!==O.kError){null===this._contentLength&&null!==t.total&&0!==t.total&&(this._contentLength=t.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));let e=t.target.response,A=this._range.from+this._receivedLength;this._receivedLength+=e.byteLength,this._onDataArrival&&this._onDataArrival(e,A,this._receivedLength)}}_onLoadEnd(){return!0===this._requestAbort?void(this._requestAbort=!1):void(this._status===O.kError||(this._status=O.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1)))}_onXhrError(t){this._status=O.kError;let e=0,A=null;if(this._contentLength&&t.loaded<this._contentLength?(e=w.EARLY_EOF,A={code:-1,msg:"Moz-Chunked stream meet Early-Eof"}):(e=w.EXCEPTION,A={code:-1,msg:t.constructor.name+" "+t.type}),this._onError)this._onError(e,A);else throw new b(A.msg)}}class N extends x{static isSupported(){try{let e=new XMLHttpRequest;return e.open("GET","https://example.com",!0),e.responseType="arraybuffer","arraybuffer"===e.responseType}catch(t){return y.w("RangeLoader",t.message),!1}}constructor(e,t){super("xhr-range-loader"),this.TAG="RangeLoader",this._seekHandler=e,this._config=t,this._needStash=!1,this._chunkSizeKBList=[128,256,384,512,768,1024,1536,2048,3072,4096,5120,6144,7168,8192],this._currentChunkSizeKB=384,this._currentSpeedNormalized=0,this._zeroSpeedChunkCount=0,this._xhr=null,this._speedSampler=new v,this._requestAbort=!1,this._waitForTotalLength=!1,this._totalLengthReceived=!1,this._currentRequestURL=null,this._currentRedirectedURL=null,this._currentRequestRange=null,this._totalLength=null,this._contentLength=null,this._receivedLength=0,this._lastTimeLoaded=0}destroy(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr=null),super.destroy()}get currentSpeed(){return this._speedSampler.lastSecondKBps}open(e,t){this._dataSource=e,this._range=t,this._status=O.kConnecting;let A=!1;null!=this._dataSource.filesize&&0!==this._dataSource.filesize&&(A=!0,this._totalLength=this._dataSource.filesize),this._totalLengthReceived||A?this._openSubRange():(this._waitForTotalLength=!0,this._internalOpen(this._dataSource,{from:0,to:-1}))}_openSubRange(){let e=1024*this._currentChunkSizeKB,t=this._range.from+this._receivedLength,A=t+e;null!=this._contentLength&&A-this._range.from>=this._contentLength&&(A=this._range.from+this._contentLength-1),this._currentRequestRange={from:t,to:A},this._internalOpen(this._dataSource,this._currentRequestRange)}_internalOpen(e,t){this._lastTimeLoaded=0;let A=e.url;this._config.reuseRedirectedURL&&(null==this._currentRedirectedURL?null!=e.redirectedURL&&(A=e.redirectedURL):A=this._currentRedirectedURL);let n=this._seekHandler.getConfig(A,t);this._currentRequestURL=n.url;let a=this._xhr=new XMLHttpRequest;if(a.open("GET",n.url,!0),a.responseType="arraybuffer",a.onreadystatechange=this._onReadyStateChange.bind(this),a.onprogress=this._onProgress.bind(this),a.onload=this._onLoad.bind(this),a.onerror=this._onXhrError.bind(this),e.withCredentials&&(a.withCredentials=!0),"object"==typeof n.headers){let e=n.headers;for(let t in e)e.hasOwnProperty(t)&&a.setRequestHeader(t,e[t])}if("object"==typeof this._config.headers){let e=this._config.headers;for(let t in e)e.hasOwnProperty(t)&&a.setRequestHeader(t,e[t])}a.send()}abort(){this._requestAbort=!0,this._internalAbort(),this._status=O.kComplete}_internalAbort(){this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr.abort(),this._xhr=null)}_onReadyStateChange(t){let e=t.target;if(2===e.readyState){if(null!=e.responseURL){let t=this._seekHandler.removeURLParameters(e.responseURL);e.responseURL!==this._currentRequestURL&&t!==this._currentRedirectedURL&&(this._currentRedirectedURL=t,this._onURLRedirect&&this._onURLRedirect(t))}if(200<=e.status&&299>=e.status){if(this._waitForTotalLength)return;this._status=O.kBuffering}else if(this._status=O.kError,this._onError)this._onError(w.HTTP_STATUS_CODE_INVALID,{code:e.status,msg:e.statusText});else throw new b("RangeLoader: Http code invalid, "+e.status+" "+e.statusText)}}_onProgress(t){if(this._status!==O.kError){if(null===this._contentLength){let e=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,e=!0;let A=t.total;this._internalAbort(),null!=A&0!==A&&(this._totalLength=A)}if(this._contentLength=-1===this._range.to?this._totalLength-this._range.from:this._range.to-this._range.from+1,e)return void this._openSubRange();this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)}let e=t.loaded-this._lastTimeLoaded;this._lastTimeLoaded=t.loaded,this._speedSampler.addBytes(e)}}_normalizeSpeed(e){let t=this._chunkSizeKBList,A=t.length-1,n=0,a=0,r=A;if(e<t[0])return t[0];for(;a<=r;){if(n=a+p((r-a)/2),n==A||e>=t[n]&&e<t[n+1])return t[n];t[n]<e?a=n+1:r=n-1}}_onLoad(t){if(this._status===O.kError)return;if(this._waitForTotalLength)return void(this._waitForTotalLength=!1);this._lastTimeLoaded=0;let e=this._speedSampler.lastSecondKBps;if(0===e&&(this._zeroSpeedChunkCount++,3<=this._zeroSpeedChunkCount&&(e=this._speedSampler.currentKBps)),0!==e){let t=this._normalizeSpeed(e);this._currentSpeedNormalized!==t&&(this._currentSpeedNormalized=t,this._currentChunkSizeKB=t)}let A=t.target.response,n=this._range.from+this._receivedLength;this._receivedLength+=A.byteLength;let a=!1;null!=this._contentLength&&this._receivedLength<this._contentLength?this._openSubRange():a=!0,this._onDataArrival&&this._onDataArrival(A,n,this._receivedLength),a&&(this._status=O.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1))}_onXhrError(t){this._status=O.kError;let e=0,A=null;if(this._contentLength&&0<this._receivedLength&&this._receivedLength<this._contentLength?(e=w.EARLY_EOF,A={code:-1,msg:"RangeLoader meet Early-Eof"}):(e=w.EXCEPTION,A={code:-1,msg:t.constructor.name+" "+t.type}),this._onError)this._onError(e,A);else throw new b(A.msg)}}class U extends x{static isSupported(){try{return"undefined"!=typeof self.WebSocket}catch(t){return!1}}constructor(){super("websocket-loader"),this.TAG="WebSocketLoader",this._needStash=!0,this._ws=null,this._requestAbort=!1,this._receivedLength=0}destroy(){this._ws&&this.abort(),super.destroy()}open(e){try{let t=this._ws=new self.WebSocket(e.url);t.binaryType="arraybuffer",t.onopen=this._onWebSocketOpen.bind(this),t.onclose=this._onWebSocketClose.bind(this),t.onmessage=this._onWebSocketMessage.bind(this),t.onerror=this._onWebSocketError.bind(this),this._status=O.kConnecting}catch(t){this._status=O.kError;let e={code:t.code,msg:t.message};if(this._onError)this._onError(w.EXCEPTION,e);else throw new b(e.msg)}}abort(){let e=this._ws;e&&(0===e.readyState||1===e.readyState)&&(this._requestAbort=!0,e.close()),this._ws=null,this._status=O.kComplete}_onWebSocketOpen(){this._status=O.kBuffering}_onWebSocketClose(){return!0===this._requestAbort?void(this._requestAbort=!1):void(this._status=O.kComplete,this._onComplete&&this._onComplete(0,this._receivedLength-1))}_onWebSocketMessage(t){if(t.data instanceof ArrayBuffer)this._dispatchArrayBuffer(t.data);else if(t.data instanceof Blob){let e=new FileReader;e.onload=(()=>{this._dispatchArrayBuffer(e.result)}),e.readAsArrayBuffer(t.data)}else{this._status=O.kError;let e={code:-1,msg:"Unsupported WebSocket message type: "+t.data.constructor.name};if(this._onError)this._onError(w.EXCEPTION,e);else throw new b(e.msg)}}_dispatchArrayBuffer(e){let t=e,A=this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,A,this._receivedLength)}_onWebSocketError(t){this._status=O.kError;let e={code:t.code,msg:t.message};if(this._onError)this._onError(w.EXCEPTION,e);else throw new b(e.msg)}}class F{constructor(e){this._zeroStart=e||!1}getConfig(e,t){let A={};if(0!==t.from||-1!==t.to){let e;e=-1===t.to?`bytes=${t.from.toString()}-`:`bytes=${t.from.toString()}-${t.to.toString()}`,A.Range=e}else this._zeroStart&&(A.Range="bytes=0-");return{url:e,headers:A}}removeURLParameters(e){return e}}class P{constructor(e,t){this._startName=e,this._endName=t}getConfig(e,t){let A=e;if(0!==t.from||-1!==t.to){let e=!0;-1===A.indexOf("?")&&(A+="?",e=!1),e&&(A+="&"),A+=`${this._startName}=${t.from.toString()}`,-1!==t.to&&(A+=`&${this._endName}=${t.to.toString()}`)}return{url:A,headers:{}}}removeURLParameters(e){let t,A=e.split("?")[0],n=e.indexOf("?");-1!==n&&(t=e.substring(n+1));let a="";if(null!=t&&0<t.length){let e=t.split("&");for(let t=0;t<e.length;t++){let A=e[t].split("="),n=0<t;A[0]!==this._startName&&A[0]!==this._endName&&(n&&(a+="&"),a+=e[t])}}return 0===a.length?A:A+"?"+a}}class Y{constructor(e,t,A){this.TAG="IOController",this._config=t,this._extraData=A,this._stashInitialSize=393216,null!=t.stashInitialSize&&0<t.stashInitialSize&&(this._stashInitialSize=t.stashInitialSize),this._stashUsed=0,this._stashSize=this._stashInitialSize,this._bufferSize=3145728,this._stashBuffer=new ArrayBuffer(this._bufferSize),this._stashByteStart=0,this._enableStash=!0,!1===t.enableStashBuffer&&(this._enableStash=!1),this._loader=null,this._loaderClass=null,this._seekHandler=null,this._dataSource=e,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(e.url),this._refTotalLength=e.filesize?e.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new v,this._speedNormalizeList=[64,128,256,384,512,768,1024,1536,2048,3072,4096],this._isEarlyEofReconnecting=!1,this._paused=!1,this._resumeFrom=0,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._selectSeekHandler(),this._selectLoader(),this._createLoader()}destroy(){this._loader.isWorking()&&this._loader.abort(),this._loader.destroy(),this._loader=null,this._loaderClass=null,this._dataSource=null,this._stashBuffer=null,this._stashUsed=this._stashSize=this._bufferSize=this._stashByteStart=0,this._currentRange=null,this._speedSampler=null,this._isEarlyEofReconnecting=!1,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._extraData=null}isWorking(){return this._loader&&this._loader.isWorking()&&!this._paused}isPaused(){return this._paused}get status(){return this._loader.status}get extraData(){return this._extraData}set extraData(e){this._extraData=e}get onDataArrival(){return this._onDataArrival}set onDataArrival(e){this._onDataArrival=e}get onSeeked(){return this._onSeeked}set onSeeked(e){this._onSeeked=e}get onError(){return this._onError}set onError(e){this._onError=e}get onComplete(){return this._onComplete}set onComplete(e){this._onComplete=e}get onRedirect(){return this._onRedirect}set onRedirect(e){this._onRedirect=e}get onRecoveredEarlyEof(){return this._onRecoveredEarlyEof}set onRecoveredEarlyEof(e){this._onRecoveredEarlyEof=e}get currentURL(){return this._dataSource.url}get hasRedirect(){return null!=this._redirectedURL||null!=this._dataSource.redirectedURL}get currentRedirectedURL(){return this._redirectedURL||this._dataSource.redirectedURL}get currentSpeed(){return this._loaderClass===N?this._loader.currentSpeed:this._speedSampler.lastSecondKBps}get loaderType(){return this._loader.type}_selectSeekHandler(){let e=this._config;if("range"===e.seekType)this._seekHandler=new F(this._config.rangeLoadZeroStart);else if("param"===e.seekType){let t=e.seekParamStart||"bstart",A=e.seekParamEnd||"bend";this._seekHandler=new P(t,A)}else if("custom"===e.seekType){if("function"!=typeof e.customSeekHandler)throw new T("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new e.customSeekHandler}else throw new T(`Invalid seekType in config: ${e.seekType}`)}_selectLoader(){if(null!=this._config.customLoader)this._loaderClass=this._config.customLoader;else if(this._isWebSocketURL)this._loaderClass=U;else if(M.isSupported())this._loaderClass=M;else if(Q.isSupported())this._loaderClass=Q;else if(N.isSupported())this._loaderClass=N;else throw new b("Your browser doesn't support xhr with arraybuffer responseType!")}_createLoader(){this._loader=new this._loaderClass(this._seekHandler,this._config),!1===this._loader.needStashBuffer&&(this._enableStash=!1),this._loader.onContentLengthKnown=this._onContentLengthKnown.bind(this),this._loader.onURLRedirect=this._onURLRedirect.bind(this),this._loader.onDataArrival=this._onLoaderChunkArrival.bind(this),this._loader.onComplete=this._onLoaderComplete.bind(this),this._loader.onError=this._onLoaderError.bind(this)}open(e){this._currentRange={from:0,to:-1},e&&(this._currentRange.from=e),this._speedSampler.reset(),e||(this._fullRequestFlag=!0),this._loader.open(this._dataSource,Object.assign({},this._currentRange))}abort(){this._loader.abort(),this._paused&&(this._paused=!1,this._resumeFrom=0)}pause(){this.isWorking()&&(this._loader.abort(),0===this._stashUsed?this._resumeFrom=this._currentRange.to+1:(this._resumeFrom=this._stashByteStart,this._currentRange.to=this._stashByteStart-1),this._stashUsed=0,this._stashByteStart=0,this._paused=!0)}resume(){if(this._paused){this._paused=!1;let e=this._resumeFrom;this._resumeFrom=0,this._internalSeek(e,!0)}}seek(e){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(e,!0)}_internalSeek(e,t){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(t),this._loader.destroy(),this._loader=null;let A={from:e,to:-1};this._currentRange={from:A.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,A),this._onSeeked&&this._onSeeked()}updateUrl(e){if(!e||"string"!=typeof e||0===e.length)throw new T("Url must be a non-empty string!");this._dataSource.url=e}_expandBuffer(e){let t=this._stashSize;for(;t+1048576<e;)t*=2;if(t+=1048576,t!==this._bufferSize){let e=new ArrayBuffer(t);if(0<this._stashUsed){let A=new Uint8Array(this._stashBuffer,0,this._stashUsed),n=new Uint8Array(e,0,t);n.set(A,0)}this._stashBuffer=e,this._bufferSize=t}}_normalizeSpeed(e){let t=this._speedNormalizeList,A=t.length-1,n=0,a=0,r=A;if(e<t[0])return t[0];for(;a<=r;){if(n=a+p((r-a)/2),n==A||e>=t[n]&&e<t[n+1])return t[n];t[n]<e?a=n+1:r=n-1}}_adjustStashSize(e){let t=0;t=this._config.isLive?e:512>e?e:512<=e&&1024>=e?p(1.5*e):2*e,8192<t&&(t=8192);let A=1024*t+1048576;this._bufferSize<A&&this._expandBuffer(A),this._stashSize=1024*t}_dispatchChunks(e,t){return this._currentRange.to=t+e.byteLength-1,this._onDataArrival(e,t)}_onURLRedirect(e){this._redirectedURL=e,this._onRedirect&&this._onRedirect(e)}_onContentLengthKnown(e){e&&this._fullRequestFlag&&(this._totalLength=e,this._fullRequestFlag=!1)}_onLoaderChunkArrival(e,t){if(!this._onDataArrival)throw new D("IOController: No existing consumer (onDataArrival) callback!");if(!this._paused){this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,this._onRecoveredEarlyEof&&this._onRecoveredEarlyEof()),this._speedSampler.addBytes(e.byteLength);let A=this._speedSampler.lastSecondKBps;if(0!==A){let e=this._normalizeSpeed(A);this._speedNormalized!==e&&(this._speedNormalized=e,this._adjustStashSize(e))}if(!this._enableStash){if(0===this._stashUsed){let A=this._dispatchChunks(e,t);if(A<e.byteLength){let n=e.byteLength-A;n>this._bufferSize&&this._expandBuffer(n);let a=new Uint8Array(this._stashBuffer,0,this._bufferSize);a.set(new Uint8Array(e,A),0),this._stashUsed+=n,this._stashByteStart=t+A}}else{this._stashUsed+e.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+e.byteLength);let t=new Uint8Array(this._stashBuffer,0,this._bufferSize);t.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength;let A=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart);if(A<this._stashUsed&&0<A){let e=new Uint8Array(this._stashBuffer,A);t.set(e,0)}this._stashUsed-=A,this._stashByteStart+=A}}else if(0===this._stashUsed&&0===this._stashByteStart&&(this._stashByteStart=t),this._stashUsed+e.byteLength<=this._stashSize){let t=new Uint8Array(this._stashBuffer,0,this._stashSize);t.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else{let A=new Uint8Array(this._stashBuffer,0,this._bufferSize);if(0<this._stashUsed){let t=this._stashBuffer.slice(0,this._stashUsed),n=this._dispatchChunks(t,this._stashByteStart);if(!(n<t.byteLength))this._stashUsed=0,this._stashByteStart+=n;else if(0<n){let e=new Uint8Array(t,n);A.set(e,0),this._stashUsed=e.byteLength,this._stashByteStart+=n}this._stashUsed+e.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+e.byteLength),A=new Uint8Array(this._stashBuffer,0,this._bufferSize)),A.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else{let n=this._dispatchChunks(e,t);if(n<e.byteLength){let a=e.byteLength-n;a>this._bufferSize&&(this._expandBuffer(a),A=new Uint8Array(this._stashBuffer,0,this._bufferSize)),A.set(new Uint8Array(e,n),0),this._stashUsed+=a,this._stashByteStart=t+n}}}}}_flushStashBuffer(e){if(0<this._stashUsed){let t=this._stashBuffer.slice(0,this._stashUsed),A=this._dispatchChunks(t,this._stashByteStart),n=t.byteLength-A;if(A<t.byteLength)if(e)y.w(this.TAG,`${n} bytes unconsumed data remain when flush buffer, dropped`);else{if(0<A){let e=new Uint8Array(this._stashBuffer,0,this._bufferSize),n=new Uint8Array(t,A);e.set(n,0),this._stashUsed=n.byteLength,this._stashByteStart+=A}return 0}return this._stashUsed=0,this._stashByteStart=0,n}return 0}_onLoaderComplete(){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)}_onLoaderError(e,t){switch(y.e(this.TAG,`Loader error, code = ${t.code}, msg = ${t.msg}`),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,e=w.UNRECOVERABLE_EARLY_EOF),e){case w.EARLY_EOF:{if(!this._config.isLive&&this._totalLength){let e=this._currentRange.to+1;return void(e<this._totalLength&&(y.w(this.TAG,"Connection lost, trying reconnect..."),this._isEarlyEofReconnecting=!0,this._internalSeek(e,!1)))}e=w.UNRECOVERABLE_EARLY_EOF;break}}if(this._onError)this._onError(e,t);else throw new b("IOException: "+t.msg)}}const q={enableWorker:!1,enableStashBuffer:!0,stashInitialSize:void 0,isLive:!1,lazyLoad:!0,lazyLoadMaxDuration:180,lazyLoadRecoverDuration:30,deferLoadAfterSourceOpen:!0,autoCleanupMaxBackwardDuration:180,autoCleanupMinBackwardDuration:120,statisticsInfoReportInterval:600,fixAudioTimestampGap:!0,accurateSeek:!1,seekType:"range",seekParamStart:"bstart",seekParamEnd:"bend",rangeLoadZeroStart:!1,customSeekHandler:void 0,reuseRedirectedURL:!1,headers:void 0,customLoader:void 0};class H{static supportMSEH264Playback(){return window.MediaSource&&window.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')}static supportNetworkStreamIO(){let e=new Y({},o()),t=e.loaderType;return e.destroy(),"fetch-stream-loader"==t||"xhr-moz-chunked-loader"==t}static getNetworkLoaderTypeName(){let e=new Y({},o()),t=e.loaderType;return e.destroy(),t}static supportNativeMediaPlayback(e){null==H.videoElement&&(H.videoElement=window.document.createElement("video"));let t=H.videoElement.canPlayType(e);return"probably"===t||"maybe"==t}static getFeatureList(){let e={mseFlvPlayback:!1,mseLiveFlvPlayback:!1,networkStreamIO:!1,networkLoaderName:"",nativeMP4H264Playback:!1,nativeWebmVP8Playback:!1,nativeWebmVP9Playback:!1};return e.mseFlvPlayback=H.supportMSEH264Playback(),e.networkStreamIO=H.supportNetworkStreamIO(),e.networkLoaderName=H.getNetworkLoaderTypeName(),e.mseLiveFlvPlayback=e.mseFlvPlayback&&e.networkStreamIO,e.nativeMP4H264Playback=H.supportNativeMediaPlayback('video/mp4; codecs="avc1.42001E, mp4a.40.2"'),e.nativeWebmVP8Playback=H.supportNativeMediaPlayback('video/webm; codecs="vp8.0, vorbis"'),e.nativeWebmVP9Playback=H.supportNativeMediaPlayback('video/webm; codecs="vp9"'),e}}class V extends t{constructor(){super(),this.TAG="WebLoader",this._config=o(),this._loader=null,this._loaderClass=null,this._seekHandler=null,this._isStart=!1,this._isFirst=!0}start(e){if(this._isStart)throw"isStart";else this._isWebSocketURL=/wss?:\/\/(.+?)/.test(e),this._currentRange={from:0,to:-1},this._selectSeekHandler(),this._selectLoader(),this._createLoader(),this._loader.open({url:e},Object.assign({},this._currentRange)),this._isStart=!0,this._isFirst=!0}stop(){this._isStart&&(this._loader.abort(),this._isStart=!1)}_selectSeekHandler(){let e=this._config;if("range"===e.seekType)this._seekHandler=new F(this._config.rangeLoadZeroStart);else if("param"===e.seekType){let t=e.seekParamStart||"bstart",A=e.seekParamEnd||"bend";this._seekHandler=new P(t,A)}else if("custom"===e.seekType){if("function"!=typeof e.customSeekHandler)throw new T("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new e.customSeekHandler}else throw new T(`Invalid seekType in config: ${e.seekType}`)}_selectLoader(){if(this._isWebSocketURL)this._loaderClass=U;else if(M.isSupported())this._loaderClass=M;else if(Q.isSupported())this._loaderClass=Q;else if(N.isSupported())this._loaderClass=N;else throw new b("Your browser doesn't support xhr with arraybuffer responseType!")}_createLoader(){this._loader=new this._loaderClass(this._seekHandler,this._config),this._loader.onContentLength=this._onContentLength.bind(this),this._loader.onURLRedirect=this._onURLRedirect.bind(this),this._loader.onDataArrival=this._onLoaderChunkArrival.bind(this),this._loader.onComplete=this._onLoaderComplete.bind(this),this._loader.onError=this._onLoaderError.bind(this)}_onURLRedirect(){}_onContentLength(){}_onLoaderChunkArrival(e){this._isFirst&&(this.emit("start"),this._isFirst=!1),this.emit("data",e)}_onLoaderComplete(){this.emit("close"),this._isFirst=!0}_onLoaderError(e,t){this.emit("error",t),this._isFirst=!0}}const W={ERROR:"error",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info"};class K{static get forceGlobalTag(){return y.FORCE_GLOBAL_TAG}static set forceGlobalTag(e){y.FORCE_GLOBAL_TAG=e,K._notifyChange()}static get globalTag(){return y.GLOBAL_TAG}static set globalTag(e){y.GLOBAL_TAG=e,K._notifyChange()}static get enableAll(){return y.ENABLE_VERBOSE&&y.ENABLE_DEBUG&&y.ENABLE_INFO&&y.ENABLE_WARN&&y.ENABLE_ERROR}static set enableAll(e){y.ENABLE_VERBOSE=e,y.ENABLE_DEBUG=e,y.ENABLE_INFO=e,y.ENABLE_WARN=e,y.ENABLE_ERROR=e,K._notifyChange()}static get enableDebug(){return y.ENABLE_DEBUG}static set enableDebug(e){y.ENABLE_DEBUG=e,K._notifyChange()}static get enableVerbose(){return y.ENABLE_VERBOSE}static set enableVerbose(e){y.ENABLE_VERBOSE=e,K._notifyChange()}static get enableInfo(){return y.ENABLE_INFO}static set enableInfo(e){y.ENABLE_INFO=e,K._notifyChange()}static get enableWarn(){return y.ENABLE_WARN}static set enableWarn(e){y.ENABLE_WARN=e,K._notifyChange()}static get enableError(){return y.ENABLE_ERROR}static set enableError(e){y.ENABLE_ERROR=e,K._notifyChange()}static getConfig(){return{globalTag:y.GLOBAL_TAG,forceGlobalTag:y.FORCE_GLOBAL_TAG,enableVerbose:y.ENABLE_VERBOSE,enableDebug:y.ENABLE_DEBUG,enableInfo:y.ENABLE_INFO,enableWarn:y.ENABLE_WARN,enableError:y.ENABLE_ERROR,enableCallback:y.ENABLE_CALLBACK}}static applyConfig(e){y.GLOBAL_TAG=e.globalTag,y.FORCE_GLOBAL_TAG=e.forceGlobalTag,y.ENABLE_VERBOSE=e.enableVerbose,y.ENABLE_DEBUG=e.enableDebug,y.ENABLE_INFO=e.enableInfo,y.ENABLE_WARN=e.enableWarn,y.ENABLE_ERROR=e.enableError,y.ENABLE_CALLBACK=e.enableCallback}static _notifyChange(){let e=K.emitter;if(0<e.listenerCount("change")){let t=K.getConfig();e.emit("change",t)}}static registerListener(e){K.emitter.addListener("change",e)}static removeListener(e){K.emitter.removeListener("change",e)}static addLogListener(e){y.emitter.addListener("log",e),0<y.emitter.listenerCount("log")&&(y.ENABLE_CALLBACK=!0,K._notifyChange())}static removeLogListener(e){y.emitter.removeListener("log",e),0===y.emitter.listenerCount("log")&&(y.ENABLE_CALLBACK=!1,K._notifyChange())}}K.emitter=new t;class j{constructor(){this.mimeType=null,this.duration=null,this.hasAudio=null,this.hasVideo=null,this.audioCodec=null,this.videoCodec=null,this.audioDataRate=null,this.videoDataRate=null,this.audioSampleRate=null,this.audioChannelCount=null,this.width=null,this.height=null,this.fps=null,this.profile=null,this.level=null,this.refFrames=null,this.chromaFormat=null,this.sarNum=null,this.sarDen=null,this.metadata=null,this.segments=null,this.segmentCount=null,this.hasKeyframesIndex=null,this.keyframesIndex=null}isComplete(){let e=!1===this.hasAudio||!0===this.hasAudio&&null!=this.audioCodec&&null!=this.audioSampleRate&&null!=this.audioChannelCount,t=!1===this.hasVideo||!0===this.hasVideo&&null!=this.videoCodec&&null!=this.width&&null!=this.height&&null!=this.fps&&null!=this.profile&&null!=this.level&&null!=this.refFrames&&null!=this.chromaFormat&&null!=this.sarNum&&null!=this.sarDen;return null!=this.mimeType&&null!=this.duration&&null!=this.metadata&&null!=this.hasKeyframesIndex&&e&&t}isSeekable(){return!0===this.hasKeyframesIndex}getNearestKeyframe(e){if(null==this.keyframesIndex)return null;let t=this.keyframesIndex,A=this._search(t.times,e);return{index:A,milliseconds:t.times[A],fileposition:t.filepositions[A]}}_search(e,t){let A=0,n=e.length-1,a=0,r=0,i=n;for(t<e[0]&&(A=0,r=i+1);r<=i;)if(a=r+p((i-r)/2),a==n||t>=e[a]&&t<e[a+1]){A=a;break}else e[a]<t?r=a+1:i=a-1;return A}}let z=function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}();class n{static parseScriptData(e,t,A){let a={};try{let r=n.parseValue(e,t,A),i=n.parseValue(e,t+r.size,A-r.size);a[r.data]=i.data}catch(t){y.e("AMF",t.toString())}return a}static parseObject(e,t,A){if(3>A)throw new D("Data not enough when parse ScriptDataObject");let a=n.parseString(e,t,A),r=n.parseValue(e,t+a.size,A-a.size),i=r.objectEnd;return{data:{name:a.data,value:r.data},size:a.size+r.size,objectEnd:i}}static parseVariable(e,t,A){return n.parseObject(e,t,A)}static parseString(e,t,A){if(2>A)throw new D("Data not enough when parse String");let n,a=new DataView(e,t,A),r=a.getUint16(0,!z);return n=0<r?_(new Uint8Array(e,t+2,r)):"",{data:n,size:2+r}}static parseLongString(e,t,A){if(4>A)throw new D("Data not enough when parse LongString");let n,a=new DataView(e,t,A),r=a.getUint32(0,!z);return n=0<r?_(new Uint8Array(e,t+4,r)):"",{data:n,size:4+r}}static parseDate(e,t,A){if(10>A)throw new D("Data size invalid when parse Date");let n=new DataView(e,t,A),a=n.getFloat64(0,!z),r=n.getInt16(8,!z);return a+=1e3*(60*r),{data:new Date(a),size:10}}static parseValue(e,t,A){if(1>A)throw new D("Data not enough when parse Value");let a,r=new DataView(e,t,A),d=1,o=r.getUint8(0),s=!1;try{switch(o){case 0:a=r.getFloat64(1,!z),d+=8;break;case 1:{let e=r.getUint8(1);a=!!e,d+=1;break}case 2:{let r=n.parseString(e,t+1,A-1);a=r.data,d+=r.size;break}case 3:{a={};let i=0;for(9==(16777215&r.getUint32(A-4,!z))&&(i=3);d<A-4;){let r=n.parseObject(e,t+d,A-d-i);if(r.objectEnd)break;a[r.data.name]=r.data.value,d+=r.size}if(d<=A-3){let e=16777215&r.getUint32(d-1,!z);9==e&&(d+=3)}break}case 8:{a={},d+=4;let i=0;for(9==(16777215&r.getUint32(A-4,!z))&&(i=3);d<A-8;){let r=n.parseVariable(e,t+d,A-d-i);if(r.objectEnd)break;a[r.data.name]=r.data.value,d+=r.size}if(d<=A-3){let e=16777215&r.getUint32(d-1,!z);9==e&&(d+=3)}break}case 9:a=void 0,d=1,s=!0;break;case 10:{a=[];let o=r.getUint32(1,!z);d+=4;for(let r,s=0;s<o;s++)r=n.parseValue(e,t+d,A-d),a.push(r.data),d+=r.size;break}case 11:{let r=n.parseDate(e,t+1,A-1);a=r.data,d+=r.size;break}case 12:{let r=n.parseString(e,t+1,A-1);a=r.data,d+=r.size;break}default:d=A,y.w("AMF","Unsupported AMF value type "+o)}}catch(t){y.e("AMF",t.toString())}return{data:a,size:d,objectEnd:s}}}class i{constructor(e){this.TAG="ExpGolomb",this._buffer=e,this._buffer_index=0,this._total_bytes=e.byteLength,this._total_bits=8*e.byteLength,this._current_word=0,this._current_word_bits_left=0}destroy(){this._buffer=null}_fillCurrentWord(){let e=this._total_bytes-this._buffer_index;if(0>=e)throw new D("ExpGolomb: _fillCurrentWord() but no bytes available");let t=f(4,e),A=new Uint8Array(4);A.set(this._buffer.subarray(this._buffer_index,this._buffer_index+t)),this._current_word=new DataView(A.buffer).getUint32(0,!1),this._buffer_index+=t,this._current_word_bits_left=8*t}readBits(e){if(32<e)throw new T("ExpGolomb: readBits() bits exceeded max 32bits!");if(e<=this._current_word_bits_left){let t=this._current_word>>>32-e;return this._current_word<<=e,this._current_word_bits_left-=e,t}let t=this._current_word_bits_left?this._current_word:0;t>>>=32-this._current_word_bits_left;let A=e-this._current_word_bits_left;this._fillCurrentWord();let n=f(A,this._current_word_bits_left),a=this._current_word>>>32-n;return this._current_word<<=n,this._current_word_bits_left-=n,t=t<<n|a,t}readBool(){return 1===this.readBits(1)}readByte(){return this.readBits(8)}_skipLeadingZero(){let e;for(e=0;e<this._current_word_bits_left;e++)if(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(){let e=this._skipLeadingZero();return this.readBits(e+1)-1}readSEG(){let e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)}}class h{static _ebsp2rbsp(e){let t=e,A=t.byteLength,n=new Uint8Array(A),a=0;for(let r=0;r<A;r++)2<=r&&3===t[r]&&0===t[r-1]&&0===t[r-2]||(n[a]=t[r],a++);return new Uint8Array(n.buffer,0,a)}static parseSPS(e){let t=h._ebsp2rbsp(e),A=new i(t);A.readByte();let n=A.readByte();A.readByte();let a=A.readByte();A.readUEG();let r=h.getProfileString(n),d=h.getLevelString(a),o=1,s=420,_=8;if((100===n||110===n||122===n||244===n||44===n||83===n||86===n||118===n||128===n||138===n||144===n)&&(o=A.readUEG(),3===o&&A.readBits(1),3>=o&&(s=[0,420,422,444][o]),_=A.readUEG()+8,A.readUEG(),A.readBits(1),A.readBool())){let e=3===o?12:8;for(let t=0;t<e;t++)A.readBool()&&(6>t?h._skipScalingList(A,16):h._skipScalingList(A,64))}A.readUEG();let u=A.readUEG();if(0===u)A.readUEG();else if(1===u){A.readBits(1),A.readSEG(),A.readSEG();let e=A.readUEG();for(let t=0;t<e;t++)A.readSEG()}let m=A.readUEG();A.readBits(1);let l=A.readUEG(),c=A.readUEG(),f=A.readBits(1);0===f&&A.readBits(1),A.readBits(1);let p=0,E=0,S=0,B=0,R=A.readBool();R&&(p=A.readUEG(),E=A.readUEG(),S=A.readUEG(),B=A.readUEG());let I=1,L=1,C=0,y=!0,v=0,b=0,D=A.readBool();if(D){if(A.readBool()){let e=A.readByte();0<e&&16>e?(I=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][e-1],L=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][e-1]):255===e&&(I=A.readByte()<<8|A.readByte(),L=A.readByte()<<8|A.readByte())}if(A.readBool()&&A.readBool(),A.readBool()&&(A.readBits(4),A.readBool()&&A.readBits(24)),A.readBool()&&(A.readUEG(),A.readUEG()),A.readBool()){let e=A.readBits(32),t=A.readBits(32);y=A.readBool(),v=t,b=2*e,C=v/b}}let T=1;(1!==I||1!==L)&&(T=I/L);let k=0,O=0;if(0===o)k=1,O=2-f;else{let e=3===o?1:2,t=1===o?2:1;k=e,O=t*(2-f)}let w=16*(l+1),x=(2-f)*(16*(c+1));w-=(p+E)*k,x-=(S+B)*O;let G=g(w*T);return A.destroy(),A=null,{profile_string:r,level_string:d,bit_depth:_,ref_frames:m,chroma_format:s,chroma_format_string:h.getChromaFormatString(s),frame_rate:{fixed:y,fps:C,fps_den:b,fps_num:v},sar_ratio:{width:I,height:L},codec_size:{width:w,height:x},present_size:{width:G,height:x}}}static _skipScalingList(e,t){let A=8,n=8,a=0;for(let r=0;r<t;r++)0!=n&&(a=e.readSEG(),n=(A+a+256)%256),A=0==n?A:n}static getProfileString(e){return 66===e?"Baseline":77===e?"Main":88===e?"Extended":100===e?"High":110===e?"High10":122===e?"High422":244===e?"High444":"Unknown"}static getLevelString(e){return(e/10).toFixed(1)}static getChromaFormatString(e){return 420===e?"4:2:0":422===e?"4:2:2":444===e?"4:4:4":"Unknown"}}const Z={OK:"OK",FORMAT_ERROR:"FormatError",FORMAT_UNSUPPORTED:"FormatUnsupported",CODEC_UNSUPPORTED:"CodecUnsupported"};class X{constructor(e,t){this.TAG="FLVDemuxer",this._config=t,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null,this._dataOffset=e.dataOffset,this._firstParse=!0,this._dispatch=!1,this._hasAudio=e.hasAudioTrack,this._hasVideo=e.hasVideoTrack,this._hasAudioFlagOverrided=!1,this._hasVideoFlagOverrided=!1,this._audioInitialMetadataDispatched=!1,this._videoInitialMetadataDispatched=!1,this._mediaInfo=new j,this._mediaInfo.hasAudio=this._hasAudio,this._mediaInfo.hasVideo=this._hasVideo,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._naluLengthSize=4,this._timestampBase=0,this._timescale=1e3,this._duration=0,this._durationOverrided=!1,this._referenceFrameRate={fixed:!0,fps:23.976,fps_num:23976,fps_den:1e3},this._flvSoundRateTable=[5500,11025,22050,44100,48e3],this._mpegSamplingRates=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],this._mpegAudioV10SampleRateTable=[44100,48e3,32e3,0],this._mpegAudioV20SampleRateTable=[22050,24e3,16e3,0],this._mpegAudioV25SampleRateTable=[11025,12e3,8e3,0],this._mpegAudioL1BitRateTable=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],this._mpegAudioL2BitRateTable=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],this._mpegAudioL3BitRateTable=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],this._videoTrack={type:"video",id:1,sequenceNumber:0,samples:[],length:0},this._audioTrack={type:"audio",id:2,sequenceNumber:0,samples:[],length:0},this._littleEndian=function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}()}destroy(){this._mediaInfo=null,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._videoTrack=null,this._audioTrack=null,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null}static probe(e){let t=new Uint8Array(e),A={match:!1};if(70!==t[0]||76!==t[1]||86!==t[2]||1!==t[3])return A;let n=0!=(4&t[4])>>>2,a=0!=(1&t[4]),r=u(t,5);return 9>r?A:{match:!0,consumed:r,dataOffset:r,hasAudioTrack:n,hasVideoTrack:a}}bindDataSource(e){return e.onDataArrival=this.parseChunks.bind(this),this}get onTrackMetadata(){return this._onTrackMetadata}set onTrackMetadata(e){this._onTrackMetadata=e}get onMediaInfo(){return this._onMediaInfo}set onMediaInfo(e){this._onMediaInfo=e}get onMetaDataArrived(){return this._onMetaDataArrived}set onMetaDataArrived(e){this._onMetaDataArrived=e}get onScriptDataArrived(){return this._onScriptDataArrived}set onScriptDataArrived(e){this._onScriptDataArrived=e}get onError(){return this._onError}set onError(e){this._onError=e}get onDataAvailable(){return this._onDataAvailable}set onDataAvailable(e){this._onDataAvailable=e}get timestampBase(){return this._timestampBase}set timestampBase(e){this._timestampBase=e}get overridedDuration(){return this._duration}set overridedDuration(e){this._durationOverrided=!0,this._duration=e,this._mediaInfo.duration=e}set overridedHasAudio(e){this._hasAudioFlagOverrided=!0,this._hasAudio=e,this._mediaInfo.hasAudio=e}set overridedHasVideo(e){this._hasVideoFlagOverrided=!0,this._hasVideo=e,this._mediaInfo.hasVideo=e}resetMediaInfo(){this._mediaInfo=new j}_isInitialMetadataDispatched(){return this._hasAudio&&this._hasVideo?this._audioInitialMetadataDispatched&&this._videoInitialMetadataDispatched:this._hasAudio&&!this._hasVideo?this._audioInitialMetadataDispatched:!this._hasAudio&&this._hasVideo&&this._videoInitialMetadataDispatched}parseChunks(e,t){if(!this._onError||!this._onMediaInfo||!this._onTrackMetadata||!this._onDataAvailable)throw new D("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");let A=0,n=this._littleEndian;if(0===t)if(13<e.byteLength){let t=X.probe(e);A=t.dataOffset}else return 0;if(this._firstParse){this._firstParse=!1,t+A!==this._dataOffset&&y.w(this.TAG,"First time parsing but chunk byteStart invalid!");let a=new DataView(e,A),r=a.getUint32(0,!n);0!==r&&y.w(this.TAG,"PrevTagSize0 !== 0 !!!"),A+=4}for(;A<e.byteLength;){this._dispatch=!0;let a=new DataView(e,A);if(A+11+4>e.byteLength)break;let r=a.getUint8(0),i=16777215&a.getUint32(0,!n);if(A+11+i+4>e.byteLength)break;if(8!==r&&9!==r&&18!==r){y.w(this.TAG,`Unsupported tag type ${r}, skipped`),A+=11+i+4;continue}let d=a.getUint8(4),o=a.getUint8(5),s=a.getUint8(6),_=a.getUint8(7),u=s|o<<8|d<<16|_<<24,m=16777215&a.getUint32(7,!n);0!=m&&y.w(this.TAG,"Meet tag which has StreamID != 0!");let l=A+11;8===r?this._parseAudioData(e,l,i,u):9===r?this._parseVideoData(e,l,i,u,t+A):18===r?this._parseScriptData(e,l,i):void 0;let c=a.getUint32(11+i,!n);c!==11+i&&y.w(this.TAG,`Invalid PrevTagSize ${c}`),A+=11+i+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),A}_parseScriptData(e,t,A){let a=n.parseScriptData(e,t,A);if(a.hasOwnProperty("onMetaData")){if(null==a.onMetaData||"object"!=typeof a.onMetaData)return void y.w(this.TAG,"Invalid onMetaData structure!");this._metadata&&y.w(this.TAG,"Found another onMetaData tag!"),this._metadata=a;let e=this._metadata.onMetaData;if(this._onMetaDataArrived&&this._onMetaDataArrived(Object.assign({},e)),"boolean"==typeof e.hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=e.hasAudio,this._mediaInfo.hasAudio=this._hasAudio),"boolean"==typeof e.hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=e.hasVideo,this._mediaInfo.hasVideo=this._hasVideo),"number"==typeof e.audiodatarate&&(this._mediaInfo.audioDataRate=e.audiodatarate),"number"==typeof e.videodatarate&&(this._mediaInfo.videoDataRate=e.videodatarate),"number"==typeof e.width&&(this._mediaInfo.width=e.width),"number"==typeof e.height&&(this._mediaInfo.height=e.height),"number"!=typeof e.duration)this._mediaInfo.duration=0;else if(!this._durationOverrided){let t=p(e.duration*this._timescale);this._duration=t,this._mediaInfo.duration=t}if("number"==typeof e.framerate){let t=p(1e3*e.framerate);if(0<t){let e=t/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=e,this._referenceFrameRate.fps_num=t,this._referenceFrameRate.fps_den=1e3,this._mediaInfo.fps=e}}if("object"==typeof e.keyframes){this._mediaInfo.hasKeyframesIndex=!0;let t=e.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(t),e.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;this._dispatch=!1,this._mediaInfo.metadata=e,y.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}0<Object.keys(a).length&&this._onScriptDataArrived&&this._onScriptDataArrived(Object.assign({},a))}_parseKeyframesIndex(e){let t=[],A=[];for(let n,a=1;a<e.times.length;a++)n=this._timestampBase+p(1e3*e.times[a]),t.push(n),A.push(e.filepositions[a]);return{times:t,filepositions:A}}_parseAudioData(e,t,A,n){if(1>=A)return void y.w(this.TAG,"Flv: Invalid audio packet, missing SoundData payload!");if(!0===this._hasAudioFlagOverrided&&!1===this._hasAudio)return;let a=this._littleEndian,r=new DataView(e,t,A),i=r.getUint8(0),d=i>>>4;if(2!=d&&10!=d)return void this._onError(Z.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+d);let o=0,s=(12&i)>>>2;if(0<=s&&4>=s)o=this._flvSoundRateTable[s];else return void this._onError(Z.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+s);let _=this._audioMetadata,u=this._audioTrack;if(_||(!1===this._hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),_=this._audioMetadata={},_.type="audio",_.id=u.id,_.timescale=this._timescale,_.duration=this._duration,_.audioSampleRate=o,_.channelCount=0==(1&i)?1:2),10==d){let a=this._parseAACAudioData(e,t+1,A-1);if(null==a)return;if(0===a.packetType){_.config&&y.w(this.TAG,"Found another AudioSpecificConfig!");let e=a.data;_.audioSampleRate=e.samplingRate,_.channelCount=e.channelCount,_.codec=e.codec,_.originalCodec=e.originalCodec,_.config=e.config,_.refSampleDuration=1024/_.audioSampleRate*_.timescale,y.v(this.TAG,"Parsed AudioSpecificConfig"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._audioInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("audio",_);let t=this._mediaInfo;t.audioCodec=_.originalCodec,t.audioSampleRate=_.audioSampleRate,t.audioChannelCount=_.channelCount,t.hasVideo?null!=t.videoCodec&&(t.mimeType='video/x-flv; codecs="'+t.videoCodec+","+t.audioCodec+'"'):t.mimeType='video/x-flv; codecs="'+t.audioCodec+'"',t.isComplete()&&this._onMediaInfo(t)}else if(1===a.packetType){let e=this._timestampBase+n,t={unit:a.data,length:a.data.byteLength,dts:e,pts:e};u.samples.push(t),u.length+=a.data.length}else y.e(this.TAG,`Flv: Unsupported AAC data type ${a.packetType}`)}else if(2==d){if(!_.codec){let n=this._parseMP3AudioData(e,t+1,A-1,!0);if(null==n)return;_.audioSampleRate=n.samplingRate,_.channelCount=n.channelCount,_.codec=n.codec,_.originalCodec=n.originalCodec,_.refSampleDuration=1152/_.audioSampleRate*_.timescale,y.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",_);let a=this._mediaInfo;a.audioCodec=_.codec,a.audioSampleRate=_.audioSampleRate,a.audioChannelCount=_.channelCount,a.audioDataRate=n.bitRate,a.hasVideo?null!=a.videoCodec&&(a.mimeType='video/x-flv; codecs="'+a.videoCodec+","+a.audioCodec+'"'):a.mimeType='video/x-flv; codecs="'+a.audioCodec+'"',a.isComplete()&&this._onMediaInfo(a)}let a=this._parseMP3AudioData(e,t+1,A-1,!1);if(null==a)return;let r=this._timestampBase+n,i={unit:a,length:a.byteLength,dts:r,pts:r};u.samples.push(i),u.length+=a.length}}_parseAACAudioData(e,t,A){if(1>=A)return void y.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!");let n={},a=new Uint8Array(e,t,A);return n.packetType=a[0],n.data=0===a[0]?this._parseAACAudioSpecificConfig(e,t+1,A-1):a.subarray(1),n}_parseAACAudioSpecificConfig(e,t,A){let n=new Uint8Array(e,t,A),a=null,r=0,i=0,d=0,o=null;if(r=i=n[0]>>>3,d=(7&n[0])<<1|n[1]>>>7,0>d||d>=this._mpegSamplingRates.length)return void this._onError(Z.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");let s=this._mpegSamplingRates[d],_=(120&n[1])>>>3;if(0>_||8<=_)return void this._onError(Z.FORMAT_ERROR,"Flv: AAC invalid channel configuration");5==r&&(o=(7&n[1])<<1|n[2]>>>7);let u=self.navigator.userAgent.toLowerCase();return-1===u.indexOf("firefox")?-1===u.indexOf("android")?(r=5,o=d,a=[,,,,],6<=d?o=d-3:1==_&&(r=2,a=[,,],o=d)):(r=2,a=[,,],o=d):6<=d?(r=5,a=[,,,,],o=d-3):(r=2,a=[,,],o=d),a[0]=r<<3,a[0]|=(15&d)>>>1,a[1]=(15&d)<<7,a[1]|=(15&_)<<3,5==r&&(a[1]|=(15&o)>>>1,a[2]=(1&o)<<7,a[2]|=8,a[3]=0),{config:a,samplingRate:s,channelCount:_,codec:"mp4a.40."+r,originalCodec:"mp4a.40."+i}}_parseMP3AudioData(e,t,A,n){if(4>A)return void y.w(this.TAG,"Flv: Invalid MP3 packet, header missing!");let a=this._littleEndian,r=new Uint8Array(e,t,A),i=null;if(n){if(255!==r[0])return;let e=3&r[1]>>>3,t=(6&r[1])>>1,A=(240&r[2])>>>4,n=(12&r[2])>>>2,a=3&r[3]>>>6,d=3===a?1:2,o=0,s=0;0==e?o=this._mpegAudioV25SampleRateTable[n]:2==e?o=this._mpegAudioV20SampleRateTable[n]:3==e?o=this._mpegAudioV10SampleRateTable[n]:void 0,1==t?A<this._mpegAudioL3BitRateTable.length&&(s=this._mpegAudioL3BitRateTable[A]):2==t?A<this._mpegAudioL2BitRateTable.length&&(s=this._mpegAudioL2BitRateTable[A]):3==t?A<this._mpegAudioL1BitRateTable.length&&(s=this._mpegAudioL1BitRateTable[A]):void 0,i={bitRate:s,samplingRate:o,channelCount:d,codec:"mp3",originalCodec:"mp3"}}else i=r;return i}_parseVideoData(e,t,A,n,a){if(1>=A)return void y.w(this.TAG,"Flv: Invalid video packet, missing VideoData payload!");if(!0!==this._hasVideoFlagOverrided||!1!==this._hasVideo){let r=new Uint8Array(e,t,A)[0],i=15&r;return 7==i?void this._parseAVCVideoPacket(e,t+1,A-1,n,a,(240&r)>>>4):void this._onError(Z.CODEC_UNSUPPORTED,`Flv: Unsupported codec in video frame: ${i}`)}}_parseAVCVideoPacket(e,t,A,n,a,r){if(4>A)return void y.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");let i=this._littleEndian,d=new DataView(e,t,A),o=d.getUint8(0),s=16777215&d.getUint32(0,!i);if(0===o)this._parseAVCDecoderConfigurationRecord(e,t+4,A-4);else if(1===o)this._parseAVCVideoData(e,t+4,A-4,n,a,r,s<<8>>8);else if(2===o);else return void this._onError(Z.FORMAT_ERROR,`Flv: Invalid video packet type ${o}`)}_parseAVCDecoderConfigurationRecord(e,t,A){if(7>A)return void y.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");let n=this._videoMetadata,a=this._videoTrack,r=this._littleEndian,d=new DataView(e,t,A);n?"undefined"!=typeof n.avcc&&y.w(this.TAG,"Found another AVCDecoderConfigurationRecord!"):(!1===this._hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),n=this._videoMetadata={},n.type="video",n.id=a.id,n.timescale=this._timescale,n.duration=this._duration);let i=d.getUint8(0),o=d.getUint8(1),s=d.getUint8(2),_=d.getUint8(3);if(1!==i||0===o)return void this._onError(Z.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord");if(this._naluLengthSize=(3&d.getUint8(4))+1,3!==this._naluLengthSize&&4!==this._naluLengthSize)return void this._onError(Z.FORMAT_ERROR,`Flv: Strange NaluLengthSizeMinusOne: ${this._naluLengthSize-1}`);let u=31&d.getUint8(5);if(0==u)return void this._onError(Z.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No SPS");1<u&&y.w(this.TAG,`Flv: Strange AVCDecoderConfigurationRecord: SPS Count = ${u}`);let m=6;for(let a,o=0;o<u;o++){if(a=d.getUint16(m,!r),m+=2,0===a)continue;let A=new Uint8Array(e,t+m,a);m+=a;let i=h.parseSPS(A);if(0!==o)continue;n.codecWidth=i.codec_size.width,n.codecHeight=i.codec_size.height,n.presentWidth=i.present_size.width,n.presentHeight=i.present_size.height,n.profile=i.profile_string,n.level=i.level_string,n.bitDepth=i.bit_depth,n.chromaFormat=i.chroma_format,n.sarRatio=i.sar_ratio,n.frameRate=i.frame_rate,(!1===i.frame_rate.fixed||0===i.frame_rate.fps_num||0===i.frame_rate.fps_den)&&(n.frameRate=this._referenceFrameRate);let s=n.frameRate.fps_den,_=n.frameRate.fps_num;n.refSampleDuration=n.timescale*(s/_);let u=A.subarray(1,4),l="avc1.";for(let e,t=0;3>t;t++)e=u[t].toString(16),2>e.length&&(e="0"+e),l+=e;n.codec=l;let c=this._mediaInfo;c.width=n.codecWidth,c.height=n.codecHeight,c.fps=n.frameRate.fps,c.profile=n.profile,c.level=n.level,c.refFrames=i.ref_frames,c.chromaFormat=i.chroma_format_string,c.sarNum=n.sarRatio.width,c.sarDen=n.sarRatio.height,c.videoCodec=l,c.hasAudio?null!=c.audioCodec&&(c.mimeType='video/x-flv; codecs="'+c.videoCodec+","+c.audioCodec+'"'):c.mimeType='video/x-flv; codecs="'+c.videoCodec+'"',c.isComplete()&&this._onMediaInfo(c)}let l=d.getUint8(m);if(0===l)return void this._onError(Z.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No PPS");1<l&&y.w(this.TAG,`Flv: Strange AVCDecoderConfigurationRecord: PPS Count = ${l}`),m++;for(let n,a=0;a<l;a++)(n=d.getUint16(m,!r),m+=2,0!==n)&&(m+=n);n.avcc=new Uint8Array(A),n.avcc.set(new Uint8Array(e,t,A),0),y.v(this.TAG,"Parsed AVCDecoderConfigurationRecord"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._videoInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("video",n)}_parseAVCVideoData(e,t,A,n,a,r,i){let d=this._littleEndian,o=new DataView(e,t,A),s=[],_=0,u=0;const m=this._naluLengthSize;let l=this._timestampBase+n,c=1===r;for(;u<A;){if(u+4>=A){y.w(this.TAG,`Malformed Nalu near timestamp ${l}, offset = ${u}, dataSize = ${A}`);break}let n=o.getUint32(u,!d);if(3===m&&(n>>>=8),n>A-m)return void y.w(this.TAG,`Malformed Nalus near timestamp ${l}, NaluSize > DataSize!`);let a=31&o.getUint8(u+m);5==a&&(c=!0);let r=new Uint8Array(e,t+u,m+n);s.push({type:a,data:r}),_+=r.byteLength,u+=m+n}if(s.length){let e=this._videoTrack,t={units:s,length:_,isKeyframe:c,dts:l,cts:i,pts:l+i};c&&(t.fileposition=a),e.samples.push(t),e.length+=_}}}class J{static init(){for(let e in J.types={avc1:[],avcC:[],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":[]},J.types)J.types.hasOwnProperty(e)&&(J.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let e=J.constants={};e.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),e.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),e.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSC=e.STCO=e.STTS,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.HDLR_VIDEO=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),e.HDLR_AUDIO=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),e.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}static box(e){let t=8,A=null,n=Array.prototype.slice.call(arguments,1),a=n.length;for(let A=0;A<a;A++)t+=n[A].byteLength;A=new Uint8Array(t),A[0]=255&t>>>24,A[1]=255&t>>>16,A[2]=255&t>>>8,A[3]=255&t,A.set(e,4);let r=8;for(let t=0;t<a;t++)A.set(n[t],r),r+=n[t].byteLength;return A}static generateInitSegment(e){let t=J.box(J.types.ftyp,J.constants.FTYP),A=J.moov(e),n=new Uint8Array(t.byteLength+A.byteLength);return n.set(t,0),n.set(A,t.byteLength),n}static moov(e){let t=J.mvhd(e.timescale,e.duration),A=J.trak(e),n=J.mvex(e);return J.box(J.types.moov,t,A,n)}static mvhd(e,t){return J.box(J.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,255&e>>>24,255&e>>>16,255&e>>>8,255&e,255&t>>>24,255&t>>>16,255&t>>>8,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 J.box(J.types.trak,J.tkhd(e),J.mdia(e))}static tkhd(e){let t=e.id,A=e.duration,n=e.presentWidth,a=e.presentHeight;return J.box(J.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,255&t>>>24,255&t>>>16,255&t>>>8,255&t,0,0,0,0,255&A>>>24,255&A>>>16,255&A>>>8,255&A,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,255&n>>>8,255&n,0,0,255&a>>>8,255&a,0,0]))}static mdia(e){return J.box(J.types.mdia,J.mdhd(e),J.hdlr(e),J.minf(e))}static mdhd(e){let t=e.timescale,A=e.duration;return J.box(J.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,255&t>>>24,255&t>>>16,255&t>>>8,255&t,255&A>>>24,255&A>>>16,255&A>>>8,255&A,85,196,0,0]))}static hdlr(e){let t=null;return t="audio"===e.type?J.constants.HDLR_AUDIO:J.constants.HDLR_VIDEO,J.box(J.types.hdlr,t)}static minf(e){let t=null;return t="audio"===e.type?J.box(J.types.smhd,J.constants.SMHD):J.box(J.types.vmhd,J.constants.VMHD),J.box(J.types.minf,t,J.dinf(),J.stbl(e))}static dinf(){let e=J.box(J.types.dinf,J.box(J.types.dref,J.constants.DREF));return e}static stbl(e){let t=J.box(J.types.stbl,J.stsd(e),J.box(J.types.stts,J.constants.STTS),J.box(J.types.stsc,J.constants.STSC),J.box(J.types.stsz,J.constants.STSZ),J.box(J.types.stco,J.constants.STCO));return t}static stsd(e){return"audio"===e.type?"mp3"===e.codec?J.box(J.types.stsd,J.constants.STSD_PREFIX,J.mp3(e)):J.box(J.types.stsd,J.constants.STSD_PREFIX,J.mp4a(e)):J.box(J.types.stsd,J.constants.STSD_PREFIX,J.avc1(e))}static mp3(e){let t=e.channelCount,A=e.audioSampleRate,n=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,255&A>>>8,255&A,0,0]);return J.box(J.types[".mp3"],n)}static mp4a(e){let t=e.channelCount,A=e.audioSampleRate,n=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,255&A>>>8,255&A,0,0]);return J.box(J.types.mp4a,n,J.esds(e))}static esds(e){let t=e.config||[],A=t.length,n=new Uint8Array([0,0,0,0,3,23+A,0,1,0,4,15+A,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([A]).concat(t).concat([6,1,2]));return J.box(J.types.esds,n)}static avc1(e){let t=e.avcc,A=e.codecWidth,n=e.codecHeight,a=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,255&A>>>8,255&A,255&n>>>8,255&n,0,72,0,0,0,72,0,0,0,0,0,0,0,1,10,120,113,113,47,102,108,118,46,106,115,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 J.box(J.types.avc1,a,J.box(J.types.avcC,t))}static mvex(e){return J.box(J.types.mvex,J.trex(e))}static trex(e){let t=e.id,A=new Uint8Array([0,0,0,0,255&t>>>24,255&t>>>16,255&t>>>8,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return J.box(J.types.trex,A)}static moof(e,t){return J.box(J.types.moof,J.mfhd(e.sequenceNumber),J.traf(e,t))}static mfhd(e){let t=new Uint8Array([0,0,0,0,255&e>>>24,255&e>>>16,255&e>>>8,255&e]);return J.box(J.types.mfhd,t)}static traf(e,t){let A=e.id,n=J.box(J.types.tfhd,new Uint8Array([0,0,0,0,255&A>>>24,255&A>>>16,255&A>>>8,255&A])),a=J.box(J.types.tfdt,new Uint8Array([0,0,0,0,255&t>>>24,255&t>>>16,255&t>>>8,255&t])),r=J.sdtp(e),i=J.trun(e,r.byteLength+16+16+8+16+8+8);return J.box(J.types.traf,n,a,i,r)}static sdtp(e){let t=e.samples||[],A=t.length,n=new Uint8Array(4+A);for(let a,r=0;r<A;r++)a=t[r].flags,n[r+4]=a.isLeading<<6|a.dependsOn<<4|a.isDependedOn<<2|a.hasRedundancy;return J.box(J.types.sdtp,n)}static trun(e,t){let A=e.samples||[],n=A.length,a=12+16*n,r=new Uint8Array(a);t+=8+a,r.set([0,0,15,1,255&n>>>24,255&n>>>16,255&n>>>8,255&n,255&t>>>24,255&t>>>16,255&t>>>8,255&t],0);for(let a=0;a<n;a++){let e=A[a].duration,t=A[a].size,n=A[a].flags,i=A[a].cts;r.set([255&e>>>24,255&e>>>16,255&e>>>8,255&e,255&t>>>24,255&t>>>16,255&t>>>8,255&t,n.isLeading<<2|n.dependsOn,n.isDependedOn<<6|n.hasRedundancy<<4|n.isNonSync,0,0,255&i>>>24,255&i>>>16,255&i>>>8,255&i],12+16*a)}return J.box(J.types.trun,r)}static mdat(e){return J.box(J.types.mdat,e)}}J.init();class ${static getSilentFrame(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}return null}}class ee{constructor(e,t,A,n,a){this.dts=e,this.pts=t,this.duration=A,this.originalDts=n,this.isSyncPoint=a,this.fileposition=null}}class te{constructor(){this.beginDts=0,this.endDts=0,this.beginPts=0,this.endPts=0,this.originalBeginDts=0,this.originalEndDts=0,this.syncPoints=[],this.firstSample=null,this.lastSample=null}appendSyncPoint(e){e.isSyncPoint=!0,this.syncPoints.push(e)}}class Ae{constructor(){this._list=[]}clear(){this._list=[]}appendArray(e){let t=this._list;0===e.length||(0<t.length&&e[0].originalDts<t[t.length-1].originalDts&&this.clear(),Array.prototype.push.apply(t,e))}getLastSyncPointBeforeDts(e){if(0==this._list.length)return null;let t=this._list,A=0,n=t.length-1,a=0,r=0,i=n;for(e<t[0].dts&&(A=0,r=i+1);r<=i;)if(a=r+p((i-r)/2),a==n||e>=t[a].dts&&e<t[a+1].dts){A=a;break}else t[a].dts<e?r=a+1:i=a-1;return this._list[A]}}class ne{constructor(e){this._type=e,this._list=[],this._lastAppendLocation=-1}get type(){return this._type}get length(){return this._list.length}isEmpty(){return 0===this._list.length}clear(){this._list=[],this._lastAppendLocation=-1}_searchNearestSegmentBefore(e){let t=this._list;if(0===t.length)return-2;let A=t.length-1,n=0,a=0,r=A,i=0;if(e<t[0].originalBeginDts)return i=-1,i;for(;a<=r;)if(n=a+p((r-a)/2),n==A||e>t[n].lastSample.originalDts&&e<t[n+1].originalBeginDts){i=n;break}else t[n].originalBeginDts<e?a=n+1:r=n-1;return i}_searchNearestSegmentAfter(e){return this._searchNearestSegmentBefore(e)+1}append(e){let t=this._list,A=e,n=this._lastAppendLocation,a=0;-1!==n&&n<t.length&&A.originalBeginDts>=t[n].lastSample.originalDts&&(n===t.length-1||n<t.length-1&&A.originalBeginDts<t[n+1].originalBeginDts)?a=n+1:0<t.length&&(a=this._searchNearestSegmentBefore(A.originalBeginDts)+1),this._lastAppendLocation=a,this._list.splice(a,0,A)}getLastSegmentBefore(e){let t=this._searchNearestSegmentBefore(e);return 0<=t?this._list[t]:null}getLastSampleBefore(e){let t=this.getLastSegmentBefore(e);return null==t?null:t.lastSample}getLastSyncPointBefore(e){let t=this._searchNearestSegmentBefore(e),A=this._list[t].syncPoints;for(;0===A.length&&0<t;)t--,A=this._list[t].syncPoints;return 0<A.length?A[A.length-1]:null}}class ae{constructor(e){this.TAG="MP4Remuxer",this._config=e,this._isLive=!0===e.isLive,this._dtsBase=-1,this._dtsBaseInited=!1,this._audioDtsBase=1/0,this._videoDtsBase=1/0,this._audioNextDts=void 0,this._videoNextDts=void 0,this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList=new ne("audio"),this._videoSegmentInfoList=new ne("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!!(G.chrome&&(50>G.version.major||50===G.version.major&&2661>G.version.build)),this._fillSilentAfterSeek=G.msedge||G.msie,this._mp3UseMpegAudio=!G.firefox,this._fillAudioTimestampGap=this._config.fixAudioTimestampGap}destroy(){this._dtsBase=-1,this._dtsBaseInited=!1,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList.clear(),this._audioSegmentInfoList=null,this._videoSegmentInfoList.clear(),this._videoSegmentInfoList=null,this._onInitSegment=null,this._onMediaSegment=null}bindDataSource(e){return e.onDataAvailable=this.remux.bind(this),e.onTrackMetadata=this._onTrackMetadataReceived.bind(this),this}get onInitSegment(){return this._onInitSegment}set onInitSegment(e){this._onInitSegment=e}get onMediaSegment(){return this._onMediaSegment}set onMediaSegment(e){this._onMediaSegment=e}insertDiscontinuity(){this._audioNextDts=this._videoNextDts=void 0}seek(){this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._videoSegmentInfoList.clear(),this._audioSegmentInfoList.clear()}remux(e,t){if(!this._onMediaSegment)throw new D("MP4Remuxer: onMediaSegment callback must be specificed!");this._dtsBaseInited||this._calculateDtsBase(e,t),this._remuxVideo(t),this._remuxAudio(e)}_onTrackMetadataReceived(e,t){let A=null,n="mp4",a=t.codec;if("audio"===e)this._audioMeta=t,"mp3"===t.codec&&this._mp3UseMpegAudio?(n="mpeg",a="",A=new Uint8Array):A=J.generateInitSegment(t);else if("video"===e)this._videoMeta=t,A=J.generateInitSegment(t);else return;if(!this._onInitSegment)throw new D("MP4Remuxer: onInitSegment callback must be specified!");this._onInitSegment(e,{type:e,data:A.buffer,codec:a,container:`${e}/${n}`,mediaDuration:t.duration})}_calculateDtsBase(e,t){this._dtsBaseInited||(e.samples&&e.samples.length&&(this._audioDtsBase=e.samples[0].dts),t.samples&&t.samples.length&&(this._videoDtsBase=t.samples[0].dts),this._dtsBase=f(this._audioDtsBase,this._videoDtsBase),this._dtsBaseInited=!0)}flushStashedSamples(){let e=this._videoStashedLastSample,t=this._audioStashedLastSample,A={type:"video",id:1,sequenceNumber:0,samples:[],length:0};null!=e&&(A.samples.push(e),A.length=e.length);let n={type:"audio",id:2,sequenceNumber:0,samples:[],length:0};null!=t&&(n.samples.push(t),n.length=t.length),this._videoStashedLastSample=null,this._audioStashedLastSample=null,this._remuxVideo(A,!0),this._remuxAudio(n,!0)}_remuxAudio(e,t){var A=Math.round;if(null==this._audioMeta)return;let n,a=e,r=a.samples,d=-1,o=-1,s=this._audioMeta.refSampleDuration,_="mp3"===this._audioMeta.codec&&this._mp3UseMpegAudio,u=this._dtsBaseInited&&void 0===this._audioNextDts,m=!1;if(!r||0===r.length)return;if(1===r.length&&!t)return;let l=0,f=null,E=0;_?(l=0,E=a.length):(l=8,E=8+a.length);let h=null;if(1<r.length&&(h=r.pop(),E-=h.length),null!=this._audioStashedLastSample){let e=this._audioStashedLastSample;this._audioStashedLastSample=null,r.unshift(e),E+=e.length}null!=h&&(this._audioStashedLastSample=h);let S=r[0].dts-this._dtsBase;if(this._audioNextDts)n=S-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())n=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&"mp3"!==this._audioMeta.originalCodec&&(m=!0);else{let e=this._audioSegmentInfoList.getLastSampleBefore(S);if(null!=e){let t=S-(e.originalDts+e.duration);3>=t&&(t=0);let A=e.dts+e.duration+t;n=S-A}else n=0}if(m){let e=S-n,t=this._videoSegmentInfoList.getLastSegmentBefore(S);if(null!=t&&t.beginDts<e){let A=$.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);if(A){let n=t.beginDts,a=e-t.beginDts;y.v(this.TAG,`InsertPrefixSilentAudio: dts: ${n}, duration: ${a}`),r.unshift({unit:A,dts:n,pts:n}),E+=A.byteLength}}else m=!1}let B=[];for(let a=0;a<r.length;a++){let e=r[a],t=e.unit,i=e.dts-this._dtsBase,o=i-n;-1===d&&(d=o);let _=0;if(a!==r.length-1){let e=r[a+1].dts-this._dtsBase-n;_=e-o}else if(null!=h){let e=h.dts-this._dtsBase-n;_=e-o}else _=1<=B.length?B[B.length-1].duration:p(s);let u=!1,m=null;if(_>1.5*s&&"mp3"!==this._audioMeta.codec&&this._fillAudioTimestampGap&&!G.safari){u=!0;let e=c(_-s),n=g(e/s),a=o+s;y.w(this.TAG,"Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.\n"+`dts: ${o+_} ms, expected: ${o+A(s)} ms, `+`delta: ${A(e)} ms, generate: ${n} frames`);let r=$.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);null==r&&(y.w(this.TAG,"Unable to generate silent frame for "+`${this._audioMeta.originalCodec} with ${this._audioMeta.channelCount} channels, repeat last frame`),r=t),m=[];for(let e,t=0;t<n;t++){if(e=A(a),0<m.length){let t=m[m.length-1];t.duration=e-t.dts}let t={dts:e,pts:e,cts:0,unit:r,size:r.byteLength,duration:0,originalDts:i,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};m.push(t),E+=t.size,a+=s}let d=m[m.length-1];d.duration=o+_-d.dts,_=A(s)}B.push({dts:o,pts:o,cts:0,unit:e.unit,size:e.unit.byteLength,duration:_,originalDts:i,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),u&&B.push.apply(B,m)}_?f=new Uint8Array(E):(f=new Uint8Array(E),f[0]=255&E>>>24,f[1]=255&E>>>16,f[2]=255&E>>>8,f[3]=255&E,f.set(J.types.mdat,4));for(let A,n=0;n<B.length;n++)A=B[n].unit,f.set(A,l),l+=A.byteLength;let R=B[B.length-1];o=R.dts+R.duration,this._audioNextDts=o;let I=new te;I.beginDts=d,I.endDts=o,I.beginPts=d,I.endPts=o,I.originalBeginDts=B[0].originalDts,I.originalEndDts=R.originalDts+R.duration,I.firstSample=new ee(B[0].dts,B[0].pts,B[0].duration,B[0].originalDts,!1),I.lastSample=new ee(R.dts,R.pts,R.duration,R.originalDts,!1),this._isLive||this._audioSegmentInfoList.append(I),a.samples=B,a.sequenceNumber++;let L=null;L=_?new Uint8Array:J.moof(a,d),a.samples=[],a.length=0;let C={type:"audio",data:this._mergeBoxes(L,f).buffer,sampleCount:B.length,info:I};_&&u&&(C.timestampOffset=d),this._onMediaSegment("audio",C)}_remuxVideo(e,t){if(null==this._videoMeta)return;let A,n=e,a=n.samples,r=-1,i=-1,d=-1,o=-1;if(!a||0===a.length)return;if(1===a.length&&!t)return;let s=8,_=null,u=8+e.length,m=null;if(1<a.length&&(m=a.pop(),u-=m.length),null!=this._videoStashedLastSample){let e=this._videoStashedLastSample;this._videoStashedLastSample=null,a.unshift(e),u+=e.length}null!=m&&(this._videoStashedLastSample=m);let l=a[0].dts-this._dtsBase;if(this._videoNextDts)A=l-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())A=0;else{let e=this._videoSegmentInfoList.getLastSampleBefore(l);if(null!=e){let t=l-(e.originalDts+e.duration);3>=t&&(t=0);let n=e.dts+e.duration+t;A=l-n}else A=0}let c=new te,g=[];for(let n=0;n<a.length;n++){let e=a[n],t=e.dts-this._dtsBase,i=e.isKeyframe,o=t-A,s=e.cts,_=o+s;-1===r&&(r=o,d=_);let u=0;if(n!==a.length-1){let e=a[n+1].dts-this._dtsBase-A;u=e-o}else if(null!=m){let e=m.dts-this._dtsBase-A;u=e-o}else u=1<=g.length?g[g.length-1].duration:p(this._videoMeta.refSampleDuration);if(i){let t=new ee(o,_,u,e.dts,!0);t.fileposition=e.fileposition,c.appendSyncPoint(t)}g.push({dts:o,pts:_,cts:s,units:e.units,size:e.length,isKeyframe:i,duration:u,originalDts:t,flags:{isLeading:0,dependsOn:i?2:1,isDependedOn:i?1:0,hasRedundancy:0,isNonSync:i?0:1}})}_=new Uint8Array(u),_[0]=255&u>>>24,_[1]=255&u>>>16,_[2]=255&u>>>8,_[3]=255&u,_.set(J.types.mdat,4);for(let A,n=0;n<g.length;n++)for(A=g[n].units;A.length;){let e=A.shift(),t=e.data;_.set(t,s),s+=t.byteLength}let f=g[g.length-1];if(i=f.dts+f.duration,o=f.pts+f.duration,this._videoNextDts=i,c.beginDts=r,c.endDts=i,c.beginPts=d,c.endPts=o,c.originalBeginDts=g[0].originalDts,c.originalEndDts=f.originalDts+f.duration,c.firstSample=new ee(g[0].dts,g[0].pts,g[0].duration,g[0].originalDts,g[0].isKeyframe),c.lastSample=new ee(f.dts,f.pts,f.duration,f.originalDts,f.isKeyframe),this._isLive||this._videoSegmentInfoList.append(c),n.samples=g,n.sequenceNumber++,this._forceFirstIDR){let e=g[0].flags;e.dependsOn=2,e.isNonSync=0}let E=J.moof(n,r);n.samples=[],n.length=0,this._onMediaSegment("video",{type:"video",data:this._mergeBoxes(E,_).buffer,sampleCount:g.length,info:c})}_mergeBoxes(e,t){let A=new Uint8Array(e.byteLength+t.byteLength);return A.set(e,0),A.set(t,e.byteLength),A}}const re={IO_ERROR:"io_error",DEMUX_ERROR:"demux_error",INIT_SEGMENT:"init_segment",MEDIA_SEGMENT:"media_segment",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info",RECOMMEND_SEEKPOINT:"recommend_seekpoint"};class ie{constructor(e,A){this.TAG="TransmuxingController",this._emitter=new t,this._config=A,e.segments||(e.segments=[{duration:e.duration,filesize:e.filesize,url:e.url}]),"boolean"!=typeof e.cors&&(e.cors=!0),"boolean"!=typeof e.withCredentials&&(e.withCredentials=!1),this._mediaDataSource=e,this._currentSegmentIndex=0;let n=0;this._mediaDataSource.segments.forEach(t=>{t.timestampBase=n,n+=t.duration,t.cors=e.cors,t.withCredentials=e.withCredentials,A.referrerPolicy&&(t.referrerPolicy=A.referrerPolicy)}),isNaN(n)||this._mediaDataSource.duration===n||(this._mediaDataSource.duration=n),this._mediaInfo=null,this._demuxer=null,this._remuxer=null,this._ioctl=null,this._pendingSeekTime=null,this._pendingResolveSeekPoint=null,this._statisticsReporter=null}destroy(){this._mediaInfo=null,this._mediaDataSource=null,this._statisticsReporter&&this._disableStatisticsReporter(),this._ioctl&&(this._ioctl.destroy(),this._ioctl=null),this._demuxer&&(this._demuxer.destroy(),this._demuxer=null),this._remuxer&&(this._remuxer.destroy(),this._remuxer=null),this._emitter.removeAllListeners(),this._emitter=null}on(e,t){this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}start(){this._loadSegment(0),this._enableStatisticsReporter()}_loadSegment(e,t){this._currentSegmentIndex=e;let A=this._mediaDataSource.segments[e],n=this._ioctl=new Y(A,this._config,e);n.onError=this._onIOException.bind(this),n.onSeeked=this._onIOSeeked.bind(this),n.onComplete=this._onIOComplete.bind(this),n.onRedirect=this._onIORedirect.bind(this),n.onRecoveredEarlyEof=this._onIORecoveredEarlyEof.bind(this),t?this._demuxer.bindDataSource(this._ioctl):n.onDataArrival=this._onInitChunkArrival.bind(this),n.open(t)}stop(){this._internalAbort(),this._disableStatisticsReporter()}_internalAbort(){this._ioctl&&(this._ioctl.destroy(),this._ioctl=null)}pause(){this._ioctl&&this._ioctl.isWorking()&&(this._ioctl.pause(),this._disableStatisticsReporter())}resume(){this._ioctl&&this._ioctl.isPaused()&&(this._ioctl.resume(),this._enableStatisticsReporter())}seek(e){if(null!=this._mediaInfo&&this._mediaInfo.isSeekable()){let t=this._searchSegmentIndexContains(e);if(t===this._currentSegmentIndex){let A=this._mediaInfo.segments[t];if(null==A)this._pendingSeekTime=e;else{let t=A.getNearestKeyframe(e);this._remuxer.seek(t.milliseconds),this._ioctl.seek(t.fileposition),this._pendingResolveSeekPoint=t.milliseconds}}else{let A=this._mediaInfo.segments[t];if(null==A)this._pendingSeekTime=e,this._internalAbort(),this._remuxer.seek(),this._remuxer.insertDiscontinuity(),this._loadSegment(t);else{let n=A.getNearestKeyframe(e);this._internalAbort(),this._remuxer.seek(e),this._remuxer.insertDiscontinuity(),this._demuxer.resetMediaInfo(),this._demuxer.timestampBase=this._mediaDataSource.segments[t].timestampBase,this._loadSegment(t,n.fileposition),this._pendingResolveSeekPoint=n.milliseconds,this._reportSegmentMediaInfo(t)}}this._enableStatisticsReporter()}}_searchSegmentIndexContains(e){let t=this._mediaDataSource.segments,A=t.length-1;for(let n=0;n<t.length;n++)if(e<t[n].timestampBase){A=n-1;break}return A}_onInitChunkArrival(e,t){let A=null,n=0;if(0<t)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,n=this._demuxer.parseChunks(e,t);else if((A=X.probe(e)).match){this._demuxer=new X(A,this._config),this._remuxer||(this._remuxer=new ae(this._config));let a=this._mediaDataSource;null==a.duration||isNaN(a.duration)||(this._demuxer.overridedDuration=a.duration),"boolean"==typeof a.hasAudio&&(this._demuxer.overridedHasAudio=a.hasAudio),"boolean"==typeof a.hasVideo&&(this._demuxer.overridedHasVideo=a.hasVideo),this._demuxer.timestampBase=a.segments[this._currentSegmentIndex].timestampBase,this._demuxer.onError=this._onDemuxException.bind(this),this._demuxer.onMediaInfo=this._onMediaInfo.bind(this),this._demuxer.onMetaDataArrived=this._onMetaDataArrived.bind(this),this._demuxer.onScriptDataArrived=this._onScriptDataArrived.bind(this),this._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this),n=this._demuxer.parseChunks(e,t)}else A=null,y.e(this.TAG,"Non-FLV, Unsupported media type!"),Promise.resolve().then(()=>{this._internalAbort()}),this._emitter.emit(re.DEMUX_ERROR,Z.FORMAT_UNSUPPORTED,"Non-FLV, Unsupported media type"),n=0;return n}_onMediaInfo(e){null==this._mediaInfo&&(this._mediaInfo=Object.assign({},e),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=this._mediaDataSource.segments.length,Object.setPrototypeOf(this._mediaInfo,j.prototype));let t=Object.assign({},e);Object.setPrototypeOf(t,j.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=t,this._reportSegmentMediaInfo(this._currentSegmentIndex),null!=this._pendingSeekTime&&Promise.resolve().then(()=>{let e=this._pendingSeekTime;this._pendingSeekTime=null,this.seek(e)})}_onMetaDataArrived(e){this._emitter.emit(re.METADATA_ARRIVED,e)}_onScriptDataArrived(e){this._emitter.emit(re.SCRIPTDATA_ARRIVED,e)}_onIOSeeked(){this._remuxer.insertDiscontinuity()}_onIOComplete(e){let t=e+1;t<this._mediaDataSource.segments.length?(this._internalAbort(),this._remuxer.flushStashedSamples(),this._loadSegment(t)):(this._remuxer.flushStashedSamples(),this._emitter.emit(re.LOADING_COMPLETE),this._disableStatisticsReporter())}_onIORedirect(e){let t=this._ioctl.extraData;this._mediaDataSource.segments[t].redirectedURL=e}_onIORecoveredEarlyEof(){this._emitter.emit(re.RECOVERED_EARLY_EOF)}_onIOException(e,t){y.e(this.TAG,`IOException: type = ${e}, code = ${t.code}, msg = ${t.msg}`),this._emitter.emit(re.IO_ERROR,e,t),this._disableStatisticsReporter()}_onDemuxException(e,t){y.e(this.TAG,`DemuxException: type = ${e}, info = ${t}`),this._emitter.emit(re.DEMUX_ERROR,e,t)}_onRemuxerInitSegmentArrival(e,t){this._emitter.emit(re.INIT_SEGMENT,e,t)}_onRemuxerMediaSegmentArrival(e,t){if(null==this._pendingSeekTime&&(this._emitter.emit(re.MEDIA_SEGMENT,e,t),null!=this._pendingResolveSeekPoint&&"video"===e)){let e=t.info.syncPoints,A=this._pendingResolveSeekPoint;this._pendingResolveSeekPoint=null,G.safari&&0<e.length&&e[0].originalDts===A&&(A=e[0].pts),this._emitter.emit(re.RECOMMEND_SEEKPOINT,A)}}_enableStatisticsReporter(){null==this._statisticsReporter&&(this._statisticsReporter=self.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval))}_disableStatisticsReporter(){this._statisticsReporter&&(self.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}_reportSegmentMediaInfo(e){let t=this._mediaInfo.segments[e],A=Object.assign({},t);A.duration=this._mediaInfo.duration,A.segmentCount=this._mediaInfo.segmentCount,delete A.segments,delete A.keyframesIndex,this._emitter.emit(re.MEDIA_INFO,A)}_reportStatisticsInfo(){let e={};e.url=this._ioctl.currentURL,e.hasRedirect=this._ioctl.hasRedirect,e.hasRedirect&&(e.redirectedURL=this._ioctl.currentRedirectedURL),e.speed=this._ioctl.currentSpeed,e.loaderType=this._ioctl.loaderType,e.currentSegmentIndex=this._currentSegmentIndex,e.totalSegmentCount=this._mediaDataSource.segments.length,this._emitter.emit(re.STATISTICS_INFO,e)}}class de{constructor(e,A){if(this.TAG="Transmuxer",this._emitter=new t,this._controller=new ie(e,A),this._controller){let e=this._controller;e.on(re.IO_ERROR,this._onIOError.bind(this)),e.on(re.DEMUX_ERROR,this._onDemuxError.bind(this)),e.on(re.INIT_SEGMENT,this._onInitSegment.bind(this)),e.on(re.MEDIA_SEGMENT,this._onMediaSegment.bind(this)),e.on(re.LOADING_COMPLETE,this._onLoadingComplete.bind(this)),e.on(re.RECOVERED_EARLY_EOF,this._onRecoveredEarlyEof.bind(this)),e.on(re.MEDIA_INFO,this._onMediaInfo.bind(this)),e.on(re.METADATA_ARRIVED,this._onMetaDataArrived.bind(this)),e.on(re.SCRIPTDATA_ARRIVED,this._onScriptDataArrived.bind(this)),e.on(re.STATISTICS_INFO,this._onStatisticsInfo.bind(this)),e.on(re.RECOMMEND_SEEKPOINT,this._onRecommendSeekpoint.bind(this))}}destroy(){this._controller.destroy(),this._controller=null,this._emitter.removeAllListeners(),this._emitter=null}on(e,t){this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}hasWorker(){return null!=this._worker}open(){this._controller.start()}close(){this._controller.stop()}seek(e){this._controller.seek(e)}pause(){this._controller.pause()}resume(){this._controller.resume()}_onInitSegment(e,t){Promise.resolve().then(()=>{this._emitter.emit(re.INIT_SEGMENT,e,t)})}_onMediaSegment(e,t){Promise.resolve().then(()=>{this._emitter.emit(re.MEDIA_SEGMENT,e,t)})}_onLoadingComplete(){Promise.resolve().then(()=>{this._emitter.emit(re.LOADING_COMPLETE)})}_onRecoveredEarlyEof(){Promise.resolve().then(()=>{this._emitter.emit(re.RECOVERED_EARLY_EOF)})}_onMediaInfo(e){Promise.resolve().then(()=>{this._emitter.emit(re.MEDIA_INFO,e)})}_onMetaDataArrived(e){Promise.resolve().then(()=>{this._emitter.emit(re.METADATA_ARRIVED,e)})}_onScriptDataArrived(e){Promise.resolve().then(()=>{this._emitter.emit(re.SCRIPTDATA_ARRIVED,e)})}_onStatisticsInfo(e){Promise.resolve().then(()=>{this._emitter.emit(re.STATISTICS_INFO,e)})}_onIOError(e,t){Promise.resolve().then(()=>{this._emitter.emit(re.IO_ERROR,e,t)})}_onDemuxError(e,t){Promise.resolve().then(()=>{this._emitter.emit(re.DEMUX_ERROR,e,t)})}_onRecommendSeekpoint(e){Promise.resolve().then(()=>{this._emitter.emit(re.RECOMMEND_SEEKPOINT,e)})}}const oe={ERROR:"error",SOURCE_OPEN:"source_open",UPDATE_END:"update_end",BUFFER_FULL:"buffer_full"};class se{constructor(e){this.TAG="MSEController",this._config=e,this._emitter=new t,this._config.isLive&&null==this._config.autoCleanupSourceBuffer&&(this._config.autoCleanupSourceBuffer=!0),this.e={onSourceOpen:this._onSourceOpen.bind(this),onSourceEnded:this._onSourceEnded.bind(this),onSourceClose:this._onSourceClose.bind(this),onSourceBufferError:this._onSourceBufferError.bind(this),onSourceBufferUpdateEnd:this._onSourceBufferUpdateEnd.bind(this)},this._mediaSource=null,this._mediaSourceObjectURL=null,this._mediaElement=null,this._isBufferFull=!1,this._hasPendingEos=!1,this._requireSetMediaDuration=!1,this._pendingMediaDuration=0,this._pendingSourceBufferInit=[],this._mimeTypes={video:null,audio:null},this._sourceBuffers={video:null,audio:null},this._lastInitSegments={video:null,audio:null},this._pendingSegments={video:[],audio:[]},this._pendingRemoveRanges={video:[],audio:[]},this._idrList=new Ae}destroy(){(this._mediaElement||this._mediaSource)&&this.detachMediaElement(),this.e=null,this._emitter.removeAllListeners(),this._emitter=null}on(e,t){this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}attachMediaElement(e){if(this._mediaSource)throw new D("MediaSource has been attached to an HTMLMediaElement!");let t=this._mediaSource=new window.MediaSource;t.addEventListener("sourceopen",this.e.onSourceOpen),t.addEventListener("sourceended",this.e.onSourceEnded),t.addEventListener("sourceclose",this.e.onSourceClose),this._mediaElement=e,this._mediaSourceObjectURL=window.URL.createObjectURL(this._mediaSource),e.src=this._mediaSourceObjectURL}detachMediaElement(){if(this._mediaSource){let e=this._mediaSource;for(let t in this._sourceBuffers){let A=this._pendingSegments[t];A.splice(0,A.length),this._pendingSegments[t]=null,this._pendingRemoveRanges[t]=null,this._lastInitSegments[t]=null;let n=this._sourceBuffers[t];if(n){if("closed"!==e.readyState){try{e.removeSourceBuffer(n)}catch(e){y.e(this.TAG,e.message)}n.removeEventListener("error",this.e.onSourceBufferError),n.removeEventListener("updateend",this.e.onSourceBufferUpdateEnd)}this._mimeTypes[t]=null,this._sourceBuffers[t]=null}}if("open"===e.readyState)try{e.endOfStream()}catch(e){y.e(this.TAG,e.message)}e.removeEventListener("sourceopen",this.e.onSourceOpen),e.removeEventListener("sourceended",this.e.onSourceEnded),e.removeEventListener("sourceclose",this.e.onSourceClose),this._pendingSourceBufferInit=[],this._isBufferFull=!1,this._idrList.clear(),this._mediaSource=null}this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement=null),this._mediaSourceObjectURL&&(window.URL.revokeObjectURL(this._mediaSourceObjectURL),this._mediaSourceObjectURL=null)}appendInitSegment(e,t){if(!this._mediaSource||"open"!==this._mediaSource.readyState)return this._pendingSourceBufferInit.push(e),void this._pendingSegments[e.type].push(e);let A=e,n=`${A.container}`;A.codec&&0<A.codec.length&&(n+=`;codecs=${A.codec}`);let a=!1;if(y.v(this.TAG,"Received Initialization Segment, mimeType: "+n),this._lastInitSegments[A.type]=A,n!==this._mimeTypes[A.type]){if(!this._mimeTypes[A.type]){a=!0;try{let e=this._sourceBuffers[A.type]=this._mediaSource.addSourceBuffer(n);e.addEventListener("error",this.e.onSourceBufferError),e.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(e){return y.e(this.TAG,e.message),void this._emitter.emit(oe.ERROR,{code:e.code,msg:e.message})}}else y.v(this.TAG,`Notice: ${A.type} mimeType changed, origin: ${this._mimeTypes[A.type]}, target: ${n}`);this._mimeTypes[A.type]=n}t||this._pendingSegments[A.type].push(A),a||!this._sourceBuffers[A.type]||this._sourceBuffers[A.type].updating||this._doAppendSegments(),G.safari&&"audio/mpeg"===A.container&&0<A.mediaDuration&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=A.mediaDuration/1e3,this._updateMediaSourceDuration())}appendMediaSegment(e){let t=e;this._pendingSegments[t.type].push(t),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();let A=this._sourceBuffers[t.type];!A||A.updating||this._hasPendingRemoveRanges()||this._doAppendSegments()}seek(){for(let e in this._sourceBuffers){if(!this._sourceBuffers[e])continue;let t=this._sourceBuffers[e];if("open"===this._mediaSource.readyState)try{t.abort()}catch(e){y.e(this.TAG,e.message)}this._idrList.clear();let A=this._pendingSegments[e];if(A.splice(0,A.length),"closed"!==this._mediaSource.readyState){for(let A=0;A<t.buffered.length;A++){let n=t.buffered.start(A),a=t.buffered.end(A);this._pendingRemoveRanges[e].push({start:n,end:a})}if(t.updating||this._doRemoveRanges(),G.safari){let A=this._lastInitSegments[e];A&&(this._pendingSegments[e].push(A),!t.updating&&this._doAppendSegments())}}}}endOfStream(){let e=this._mediaSource,t=this._sourceBuffers;return e&&"open"===e.readyState?void(t.video&&t.video.updating||t.audio&&t.audio.updating?this._hasPendingEos=!0:(this._hasPendingEos=!1,e.endOfStream())):void(e&&"closed"===e.readyState&&this._hasPendingSegments()&&(this._hasPendingEos=!0))}getNearestKeyframe(e){return this._idrList.getLastSyncPointBeforeDts(e)}_needCleanupSourceBuffer(){if(!this._config.autoCleanupSourceBuffer)return!1;let e=this._mediaElement.currentTime;for(let t in this._sourceBuffers){let A=this._sourceBuffers[t];if(A){let t=A.buffered;if(1<=t.length&&e-t.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1}_doCleanupSourceBuffer(){let e=this._mediaElement.currentTime;for(let t in this._sourceBuffers){let A=this._sourceBuffers[t];if(A){let n=A.buffered,a=!1;for(let A=0;A<n.length;A++){let r=n.start(A),i=n.end(A);if(!(r<=e&&e<i+3))i<e&&(a=!0,this._pendingRemoveRanges[t].push({start:r,end:i}));else if(e-r>=this._config.autoCleanupMaxBackwardDuration){a=!0;let A=e-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[t].push({start:r,end:A})}}a&&!A.updating&&this._doRemoveRanges()}}}_updateMediaSourceDuration(){let e=this._sourceBuffers;if(0!==this._mediaElement.readyState&&"open"===this._mediaSource.readyState&&!(e.video&&e.video.updating||e.audio&&e.audio.updating)){let e=this._mediaSource.duration,t=this._pendingMediaDuration;0<t&&(isNaN(e)||t>e)&&(y.v(this.TAG,`Update MediaSource duration from ${e} to ${t}`),this._mediaSource.duration=t),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}}_doRemoveRanges(){for(let e in this._pendingRemoveRanges)if(this._sourceBuffers[e]&&!this._sourceBuffers[e].updating)for(let t,A=this._sourceBuffers[e],n=this._pendingRemoveRanges[e];n.length&&!A.updating;)t=n.shift(),A.remove(t.start,t.end)}_doAppendSegments(){let e=this._pendingSegments;for(let t in e)if(this._sourceBuffers[t]&&!this._sourceBuffers[t].updating&&0<e[t].length){let A=e[t].shift();if(A.timestampOffset){let e=this._sourceBuffers[t].timestampOffset,n=A.timestampOffset/1e3,a=c(e-n);.1<a&&(y.v(this.TAG,`Update MPEG audio timestampOffset from ${e} to ${n}`),this._sourceBuffers[t].timestampOffset=n),delete A.timestampOffset}if(!A.data||0===A.data.byteLength)continue;try{this._sourceBuffers[t].appendBuffer(A.data),this._isBufferFull=!1,"video"==t&&A.hasOwnProperty("info")&&this._idrList.appendArray(A.info.syncPoints)}catch(e){this._pendingSegments[t].unshift(A),22===e.code?(!this._isBufferFull&&this._emitter.emit(oe.BUFFER_FULL),this._isBufferFull=!0):(y.e(this.TAG,e.message),this._emitter.emit(oe.ERROR,{code:e.code,msg:e.message}))}}}_onSourceOpen(){if(y.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),0<this._pendingSourceBufferInit.length)for(let e,t=this._pendingSourceBufferInit;t.length;)e=t.shift(),this.appendInitSegment(e,!0);this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(oe.SOURCE_OPEN)}_onSourceEnded(){y.v(this.TAG,"MediaSource onSourceEnded")}_onSourceClose(){y.v(this.TAG,"MediaSource onSourceClose"),this._mediaSource&&null!=this.e&&(this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._mediaSource.removeEventListener("sourceended",this.e.onSourceEnded),this._mediaSource.removeEventListener("sourceclose",this.e.onSourceClose))}_hasPendingSegments(){let e=this._pendingSegments;return 0<e.video.length||0<e.audio.length}_hasPendingRemoveRanges(){let e=this._pendingRemoveRanges;return 0<e.video.length||0<e.audio.length}_onSourceBufferUpdateEnd(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(oe.UPDATE_END)}_onSourceBufferError(t){y.e(this.TAG,`SourceBuffer Error: ${t}`)}}const _e={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},ue={NETWORK_EXCEPTION:w.EXCEPTION,NETWORK_STATUS_CODE_INVALID:w.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:w.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:w.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:Z.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:Z.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:Z.CODEC_UNSUPPORTED};class me{constructor(e,A){if(this.TAG="FlvPlayer",this._type="FlvPlayer",this._emitter=new t,this._config=o(),"object"==typeof A&&Object.assign(this._config,A),"flv"!==e.type.toLowerCase())throw new T("FlvPlayer requires an flv MediaDataSource input!");!0===e.isLive&&(this._config.isLive=!0),this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this),onvSeeking:this._onvSeeking.bind(this),onvCanPlay:this._onvCanPlay.bind(this),onvStalled:this._onvStalled.bind(this),onvProgress:this._onvProgress.bind(this)},this._now=self.performance&&self.performance.now?self.performance.now.bind(self.performance):Date.now,this._pendingSeekTime=null,this._requestSetTime=!1,this._seekpointRecord=null,this._progressChecker=null,this._mediaDataSource=e,this._mediaElement=null,this._msectl=null,this._transmuxer=null,this._mseSourceOpened=!1,this._hasPendingLoad=!1,this._receivedCanPlay=!1,this._mediaInfo=null,this._statisticsInfo=null;let n=G.chrome&&(50>G.version.major||50===G.version.major&&2661>G.version.build);this._alwaysSeekKeyframe=!!(n||G.msedge||G.msie),this._alwaysSeekKeyframe&&(this._config.accurateSeek=!1)}destroy(){null!=this._progressChecker&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._transmuxer&&this.unload(),this._mediaElement&&this.detachMediaElement(),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null}on(e,t){e===W.MEDIA_INFO?null!=this._mediaInfo&&Promise.resolve().then(()=>{this._emitter.emit(W.MEDIA_INFO,this.mediaInfo)}):e===W.STATISTICS_INFO&&null!=this._statisticsInfo&&Promise.resolve().then(()=>{this._emitter.emit(W.STATISTICS_INFO,this.statisticsInfo)}),this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}attachMediaElement(e){if(this._mediaElement=e,e.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),e.addEventListener("seeking",this.e.onvSeeking),e.addEventListener("canplay",this.e.onvCanPlay),e.addEventListener("stalled",this.e.onvStalled),e.addEventListener("progress",this.e.onvProgress),this._msectl=new se(this._config),this._msectl.on(oe.UPDATE_END,this._onmseUpdateEnd.bind(this)),this._msectl.on(oe.BUFFER_FULL,this._onmseBufferFull.bind(this)),this._msectl.on(oe.SOURCE_OPEN,()=>{this._mseSourceOpened=!0,this._hasPendingLoad&&(this._hasPendingLoad=!1,this.load())}),this._msectl.on(oe.ERROR,e=>{this._emitter.emit(W.ERROR,_e.MEDIA_ERROR,ue.MEDIA_MSE_ERROR,e)}),this._msectl.attachMediaElement(e),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(t){}}detachMediaElement(){this._mediaElement&&(this._msectl.detachMediaElement(),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement.removeEventListener("seeking",this.e.onvSeeking),this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay),this._mediaElement.removeEventListener("stalled",this.e.onvStalled),this._mediaElement.removeEventListener("progress",this.e.onvProgress),this._mediaElement=null),this._msectl&&(this._msectl.destroy(),this._msectl=null)}load(){if(!this._mediaElement)throw new D("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new D("FlvPlayer.load() has been called, please call unload() first!");return this._hasPendingLoad?void 0:this._config.deferLoadAfterSourceOpen&&!1===this._mseSourceOpened?void(this._hasPendingLoad=!0):void(0<this._mediaElement.readyState&&(this._requestSetTime=!0,this._mediaElement.currentTime=0),this._transmuxer=new de(this._mediaDataSource,this._config),this._transmuxer.on(re.INIT_SEGMENT,(e,t)=>{this._msectl.appendInitSegment(t)}),this._transmuxer.on(re.MEDIA_SEGMENT,(e,t)=>{if(this._msectl.appendMediaSegment(t),this._config.lazyLoad&&!this._config.isLive){let e=this._mediaElement.currentTime;t.info.endDts>=1e3*(e+this._config.lazyLoadMaxDuration)&&null==this._progressChecker&&(y.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}}),this._transmuxer.on(re.LOADING_COMPLETE,()=>{this._msectl.endOfStream(),this._emitter.emit(W.LOADING_COMPLETE)}),this._transmuxer.on(re.RECOVERED_EARLY_EOF,()=>{this._emitter.emit(W.RECOVERED_EARLY_EOF)}),this._transmuxer.on(re.IO_ERROR,(e,t)=>{this._emitter.emit(W.ERROR,_e.NETWORK_ERROR,e,t)}),this._transmuxer.on(re.DEMUX_ERROR,(e,t)=>{this._emitter.emit(W.ERROR,_e.MEDIA_ERROR,e,{code:-1,msg:t})}),this._transmuxer.on(re.MEDIA_INFO,e=>{this._mediaInfo=e,this._emitter.emit(W.MEDIA_INFO,Object.assign({},e))}),this._transmuxer.on(re.METADATA_ARRIVED,e=>{this._emitter.emit(W.METADATA_ARRIVED,e)}),this._transmuxer.on(re.SCRIPTDATA_ARRIVED,e=>{this._emitter.emit(W.SCRIPTDATA_ARRIVED,e)}),this._transmuxer.on(re.STATISTICS_INFO,e=>{this._statisticsInfo=this._fillStatisticsInfo(e),this._emitter.emit(W.STATISTICS_INFO,Object.assign({},this._statisticsInfo))}),this._transmuxer.on(re.RECOMMEND_SEEKPOINT,e=>{this._mediaElement&&!this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=e/1e3)}),this._transmuxer.open())}unload(){this._mediaElement&&this._mediaElement.pause(),this._msectl&&this._msectl.seek(0),this._transmuxer&&(this._transmuxer.close(),this._transmuxer.destroy(),this._transmuxer=null)}play(){return this._mediaElement.play()}pause(){this._mediaElement.pause()}get type(){return this._type}get buffered(){return this._mediaElement.buffered}get duration(){return this._mediaElement.duration}get volume(){return this._mediaElement.volume}set volume(e){this._mediaElement.volume=e}get muted(){return this._mediaElement.muted}set muted(e){this._mediaElement.muted=e}get currentTime(){return this._mediaElement?this._mediaElement.currentTime:0}set currentTime(e){this._mediaElement?this._internalSeek(e):this._pendingSeekTime=e}get mediaInfo(){return Object.assign({},this._mediaInfo)}get statisticsInfo(){return null==this._statisticsInfo&&(this._statisticsInfo={}),this._statisticsInfo=this._fillStatisticsInfo(this._statisticsInfo),Object.assign({},this._statisticsInfo)}_fillStatisticsInfo(e){if(e.playerType=this._type,!(this._mediaElement instanceof HTMLVideoElement))return e;let t=!0,A=0,n=0;if(this._mediaElement.getVideoPlaybackQuality){let e=this._mediaElement.getVideoPlaybackQuality();A=e.totalVideoFrames,n=e.droppedVideoFrames}else null==this._mediaElement.webkitDecodedFrameCount?t=!1:(A=this._mediaElement.webkitDecodedFrameCount,n=this._mediaElement.webkitDroppedFrameCount);return t&&(e.decodedFrames=A,e.droppedFrames=n),e}_onmseUpdateEnd(){if(!this._config.lazyLoad||this._config.isLive)return;let e=this._mediaElement.buffered,t=this._mediaElement.currentTime,A=0;for(let n=0;n<e.length;n++){let a=e.start(n),r=e.end(n);if(a<=t&&t<r){A=r;break}}A>=t+this._config.lazyLoadMaxDuration&&null==this._progressChecker&&(y.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}_onmseBufferFull(){y.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),null==this._progressChecker&&this._suspendTransmuxer()}_suspendTransmuxer(){this._transmuxer&&(this._transmuxer.pause(),null==this._progressChecker&&(this._progressChecker=window.setInterval(this._checkProgressAndResume.bind(this),1e3)))}_checkProgressAndResume(){let e=this._mediaElement.currentTime,t=this._mediaElement.buffered,A=!1;for(let n=0;n<t.length;n++){let a=t.start(n),r=t.end(n);if(e>=a&&e<r){e>=r-this._config.lazyLoadRecoverDuration&&(A=!0);break}}A&&(window.clearInterval(this._progressChecker),this._progressChecker=null,A&&(y.v(this.TAG,"Continue loading from paused position"),this._transmuxer.resume()))}_isTimepointBuffered(e){let t=this._mediaElement.buffered;for(let A=0;A<t.length;A++){let n=t.start(A),a=t.end(A);if(e>=n&&e<a)return!0}return!1}_internalSeek(e){let t=this._isTimepointBuffered(e),A=!1,n=0;if(1>e&&0<this._mediaElement.buffered.length){let t=this._mediaElement.buffered.start(0);(1>t&&e<t||G.safari)&&(A=!0,n=G.safari?.1:t)}if(A)this._requestSetTime=!0,this._mediaElement.currentTime=n;else if(t){if(!this._alwaysSeekKeyframe)this._requestSetTime=!0,this._mediaElement.currentTime=e;else{let t=this._msectl.getNearestKeyframe(p(1e3*e));this._requestSetTime=!0,this._mediaElement.currentTime=null==t?e:t.dts/1e3}null!=this._progressChecker&&this._checkProgressAndResume()}else null!=this._progressChecker&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._msectl.seek(e),this._transmuxer.seek(p(1e3*e)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=e)}_checkAndApplyUnbufferedSeekpoint(){if(this._seekpointRecord)if(this._seekpointRecord.recordTime<=this._now()-100){let e=this._mediaElement.currentTime;this._seekpointRecord=null,this._isTimepointBuffered(e)||(null!=this._progressChecker&&(window.clearTimeout(this._progressChecker),this._progressChecker=null),this._msectl.seek(e),this._transmuxer.seek(p(1e3*e)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=e))}else window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)}_checkAndResumeStuckPlayback(e){let t=this._mediaElement;if(e||!this._receivedCanPlay||2>t.readyState){let e=t.buffered;0<e.length&&t.currentTime<e.start(0)&&(y.w(this.TAG,`Playback seems stuck at ${t.currentTime}, seek to ${e.start(0)}`),this._requestSetTime=!0,this._mediaElement.currentTime=e.start(0),this._mediaElement.removeEventListener("progress",this.e.onvProgress))}else this._mediaElement.removeEventListener("progress",this.e.onvProgress)}_onvLoadedMetadata(){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null)}_onvSeeking(){let e=this._mediaElement.currentTime,t=this._mediaElement.buffered;if(this._requestSetTime)return void(this._requestSetTime=!1);if(1>e&&0<t.length){let A=t.start(0);if(1>A&&e<A||G.safari)return this._requestSetTime=!0,void(this._mediaElement.currentTime=G.safari?.1:A)}if(this._isTimepointBuffered(e)){if(this._alwaysSeekKeyframe){let t=this._msectl.getNearestKeyframe(p(1e3*e));null!=t&&(this._requestSetTime=!0,this._mediaElement.currentTime=t.dts/1e3)}return void(null!=this._progressChecker&&this._checkProgressAndResume())}this._seekpointRecord={seekPoint:e,recordTime:this._now()},window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)}_onvCanPlay(){this._receivedCanPlay=!0,this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay)}_onvStalled(){this._checkAndResumeStuckPlayback(!0)}_onvProgress(){this._checkAndResumeStuckPlayback()}}class le{constructor(e,A){if(this.TAG="NativePlayer",this._type="NativePlayer",this._emitter=new t,this._config=o(),"object"==typeof A&&Object.assign(this._config,A),"flv"===e.type.toLowerCase())throw new T("NativePlayer does't support flv MediaDataSource input!");if(e.hasOwnProperty("segments"))throw new T(`NativePlayer(${e.type}) doesn't support multipart playback!`);this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this)},this._pendingSeekTime=null,this._statisticsReporter=null,this._mediaDataSource=e,this._mediaElement=null}destroy(){this._mediaElement&&(this.unload(),this.detachMediaElement()),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null}on(e,t){e===W.MEDIA_INFO?null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then(()=>{this._emitter.emit(W.MEDIA_INFO,this.mediaInfo)}):e===W.STATISTICS_INFO&&null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then(()=>{this._emitter.emit(W.STATISTICS_INFO,this.statisticsInfo)}),this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}attachMediaElement(e){if(this._mediaElement=e,e.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(t){}}detachMediaElement(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement=null),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}load(){if(!this._mediaElement)throw new D("HTMLMediaElement must be attached before load()!");this._mediaElement.src=this._mediaDataSource.url,0<this._mediaElement.readyState&&(this._mediaElement.currentTime=0),this._mediaElement.preload="auto",this._mediaElement.load(),this._statisticsReporter=window.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval)}unload(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src")),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}play(){return this._mediaElement.play()}pause(){this._mediaElement.pause()}get type(){return this._type}get buffered(){return this._mediaElement.buffered}get duration(){return this._mediaElement.duration}get volume(){return this._mediaElement.volume}set volume(e){this._mediaElement.volume=e}get muted(){return this._mediaElement.muted}set muted(e){this._mediaElement.muted=e}get currentTime(){return this._mediaElement?this._mediaElement.currentTime:0}set currentTime(e){this._mediaElement?this._mediaElement.currentTime=e:this._pendingSeekTime=e}get mediaInfo(){let e=this._mediaElement instanceof HTMLAudioElement?"audio/":"video/",t={mimeType:e+this._mediaDataSource.type};return this._mediaElement&&(t.duration=p(1e3*this._mediaElement.duration),this._mediaElement instanceof HTMLVideoElement&&(t.width=this._mediaElement.videoWidth,t.height=this._mediaElement.videoHeight)),t}get statisticsInfo(){let e={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return e;let t=!0,A=0,n=0;if(this._mediaElement.getVideoPlaybackQuality){let e=this._mediaElement.getVideoPlaybackQuality();A=e.totalVideoFrames,n=e.droppedVideoFrames}else null==this._mediaElement.webkitDecodedFrameCount?t=!1:(A=this._mediaElement.webkitDecodedFrameCount,n=this._mediaElement.webkitDroppedFrameCount);return t&&(e.decodedFrames=A,e.droppedFrames=n),e}_onvLoadedMetadata(){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(W.MEDIA_INFO,this.mediaInfo)}_reportStatisticsInfo(){this._emitter.emit(W.STATISTICS_INFO,this.statisticsInfo)}}return C.install(),B}();"undefined"==typeof exports?Module.NodePlayer=NodePlayer:("undefined"!=typeof module&&module.exports&&(exports=module.exports=NodePlayer),exports.NodePlayer=NodePlayer),"function"==typeof define&&define.amd&&define([],function(){return NodePlayer});