decoder-pro-mt.js 419 KB

1
  1. !function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";var e,t=(e="undefined"==typeof document&&"undefined"==typeof location?new(require("url").URL)("file:"+__filename).href:"undefined"==typeof document?location.href:document.currentScript&&document.currentScript.src||new URL("decoder-pro-mt.js",document.baseURI).href,async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var r,i,n;(n=t).ready=new Promise(((e,t)=>{r=e,i=t})),(n=void 0!==n?n:{}).locateFile=function(e){return"decoder-pro-mt-worker.wasm"==e&&"undefined"!=typeof JESSIBUCA_PRO_MT_WORKER_WASM_URL&&""!=JESSIBUCA_PRO_MT_WORKER_WASM_URL?JESSIBUCA_PRO_MT_WORKER_WASM_URL:e};var s,o,a,l=Object.assign({},n),d="./this.program",u=(e,t)=>{throw t},h="object"==typeof window,c="function"==typeof importScripts,f="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,p=n.ENVIRONMENT_IS_PTHREAD||!1,m="";function _(e){return n.locateFile?n.locateFile(e,m):m+e}if(f){const{createRequire:e}=await import("module");var g=e("undefined"==typeof document&&"undefined"==typeof location?new(require("url").URL)("file:"+__filename).href:"undefined"==typeof document?location.href:document.currentScript&&document.currentScript.src||new URL("decoder-pro-mt.js",document.baseURI).href),y=g("fs"),v=g("path");let t;m=c?v.dirname(m)+"/":g("url").fileURLToPath(new URL("./","undefined"==typeof document&&"undefined"==typeof location?new(require("url").URL)("file:"+__filename).href:"undefined"==typeof document?location.href:document.currentScript&&document.currentScript.src||new URL("decoder-pro-mt.js",document.baseURI).href)),s=(e,t)=>(e=le(e)?new URL(e):v.normalize(e),y.readFileSync(e,t?void 0:"utf8")),a=e=>{var t=s(e,!0);return t.buffer||(t=new Uint8Array(t)),t},o=function(e,t,r){let i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];e=le(e)?new URL(e):v.normalize(e),y.readFile(e,i?void 0:"utf8",((e,n)=>{e?r(e):t(i?n.buffer:n)}))},!n.thisProgram&&process.argv.length>1&&(d=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),u=(e,t)=>{throw process.exitCode=e,t},n.inspect=()=>"[Emscripten Module object]";try{t=g("worker_threads")}catch(e){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),e}global.Worker=t.Worker}else(h||c)&&(c?m=self.location.href:"undefined"!=typeof document&&document.currentScript&&(m=document.currentScript.src),e&&(m=e),m=0!==m.indexOf("blob:")?m.substr(0,m.replace(/[?#].*/,"").lastIndexOf("/")+1):"",f||(s=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},c&&(a=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),o=(e,t,r)=>{var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=()=>{200==i.status||0==i.status&&i.response?t(i.response):r()},i.onerror=r,i.send(null)}));f&&"undefined"==typeof performance&&(global.performance=g("perf_hooks").performance);var b=console.log.bind(console),w=console.error.bind(console);f&&(b=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return y.writeSync(1,t.join(" ")+"\n")},w=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return y.writeSync(2,t.join(" ")+"\n")});var E,S=n.print||b,U=n.printErr||w;Object.assign(n,l),l=null,n.arguments&&n.arguments,n.thisProgram&&(d=n.thisProgram),n.quit&&(u=n.quit),n.wasmBinary&&(E=n.wasmBinary);var x,k,A=n.noExitRuntime||!0;"object"!=typeof WebAssembly&&re("no native wasm support detected");var T,C,B,F,P,D,I,L,R,z=!1;function M(e,t){e||re(t)}function O(){var e=x.buffer;n.HEAP8=C=new Int8Array(e),n.HEAP16=F=new Int16Array(e),n.HEAPU8=B=new Uint8Array(e),n.HEAPU16=P=new Uint16Array(e),n.HEAP32=D=new Int32Array(e),n.HEAPU32=I=new Uint32Array(e),n.HEAPF32=L=new Float32Array(e),n.HEAPF64=R=new Float64Array(e)}var N=n.INITIAL_MEMORY||268435456;if(M(N>=65536,"INITIAL_MEMORY should be larger than STACK_SIZE, was "+N+"! (STACK_SIZE=65536)"),p)x=n.wasmMemory;else if(n.wasmMemory)x=n.wasmMemory;else if(!((x=new WebAssembly.Memory({initial:N/65536,maximum:N/65536,shared:!0})).buffer instanceof SharedArrayBuffer))throw U("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),f&&U("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and/or recent version)"),Error("bad memory");O(),N=x.buffer.byteLength;var $=[],G=[],H=[],V=0;function W(){return A||V>0}function j(){if(n.preRun)for("function"==typeof n.preRun&&(n.preRun=[n.preRun]);n.preRun.length;)K(n.preRun.shift());Ke($)}function Y(){p||(n.noFSInit||$e.init.initialized||$e.init(),$e.ignorePermissions=!1,Ke(G))}function q(){if(!p){if(n.postRun)for("function"==typeof n.postRun&&(n.postRun=[n.postRun]);n.postRun.length;)Z(n.postRun.shift());Ke(H)}}function K(e){$.unshift(e)}function X(e){G.unshift(e)}function Z(e){H.unshift(e)}var J=0,Q=null;function ee(e){J++,n.monitorRunDependencies&&n.monitorRunDependencies(J)}function te(e){if(J--,n.monitorRunDependencies&&n.monitorRunDependencies(J),0==J&&Q){var t=Q;Q=null,t()}}function re(e){n.onAbort&&n.onAbort(e),U(e="Aborted("+e+")"),z=!0,T=1,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw i(t),t}var ie,ne,se,oe="data:application/octet-stream;base64,";function ae(e){return e.startsWith(oe)}function le(e){return e.startsWith("file://")}function de(e){if(e==ie&&E)return new Uint8Array(E);if(a)return a(e);throw"both async and sync fetching of the wasm failed"}function ue(e){if(!E&&(h||c)){if("function"==typeof fetch&&!le(e))return fetch(e,{credentials:"same-origin"}).then((t=>{if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()})).catch((()=>de(e)));if(o)return new Promise(((t,r)=>{o(e,(e=>t(new Uint8Array(e))),r)}))}return Promise.resolve().then((()=>de(e)))}function he(e,t,r){return ue(e).then((e=>WebAssembly.instantiate(e,t))).then((e=>e)).then(r,(e=>{U(`failed to asynchronously prepare wasm: ${e}`),re(e)}))}function ce(e,t,r,i){return e||"function"!=typeof WebAssembly.instantiateStreaming||ae(t)||le(t)||f||"function"!=typeof fetch?he(t,r,i):fetch(t,{credentials:"same-origin"}).then((e=>WebAssembly.instantiateStreaming(e,r).then(i,(function(e){return U(`wasm streaming compile failed: ${e}`),U("falling back to ArrayBuffer instantiation"),he(t,r,i)}))))}function fe(){var e={a:Yi};function t(e,t){return qi=e.exports,rt(qi.V),Je=qi.T,X(qi.Q),k=t,te(),qi}if(ee(),n.instantiateWasm)try{return n.instantiateWasm(e,t)}catch(e){U(`Module.instantiateWasm callback failed with error: ${e}`),i(e)}return ce(E,ie,e,(function(e){t(e.instance,e.module)})).catch(i),{}}function pe(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e}n.locateFile?ae(ie="decoder-pro-mt-worker.wasm")||(ie=_(ie)):ie=new URL("decoder-pro-mt-worker.wasm","undefined"==typeof document&&"undefined"==typeof location?new(require("url").URL)("file:"+__filename).href:"undefined"==typeof document?location.href:document.currentScript&&document.currentScript.src||new URL("decoder-pro-mt.js",document.baseURI).href).href;var me=e=>{e.terminate(),e.onmessage=e=>{}},_e=e=>{var t=qe.pthreads[e];delete qe.pthreads[e],me(t),nn(e),qe.runningWorkers.splice(qe.runningWorkers.indexOf(t),1),t.pthread_ptr=0},ge=e=>{qe.pthreads[e].postMessage({cmd:"cancel"})},ye=e=>{var t=qe.pthreads[e];M(t),qe.returnWorkerToPool(t)},ve=e=>{var t=qe.getNewWorker();if(!t)return 6;qe.runningWorkers.push(t),qe.pthreads[e.pthread_ptr]=t,t.pthread_ptr=e.pthread_ptr;var r={cmd:"run",start_routine:e.startRoutine,arg:e.arg,pthread_ptr:e.pthread_ptr};return f&&t.unref(),t.postMessage(r,e.transferList),0},be={isAbs:e=>"/"===e.charAt(0),splitPath:e=>/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1),normalizeArray:(e,t)=>{for(var r=0,i=e.length-1;i>=0;i--){var n=e[i];"."===n?e.splice(i,1):".."===n?(e.splice(i,1),r++):r&&(e.splice(i,1),r--)}if(t)for(;r;r--)e.unshift("..");return e},normalize:e=>{var t=be.isAbs(e),r="/"===e.substr(-1);return(e=be.normalizeArray(e.split("/").filter((e=>!!e)),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e},dirname:e=>{var t=be.splitPath(e),r=t[0],i=t[1];return r||i?(i&&(i=i.substr(0,i.length-1)),r+i):"."},basename:e=>{if("/"===e)return"/";var t=(e=(e=be.normalize(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===t?e:e.substr(t+1)},join:function(){var e=Array.prototype.slice.call(arguments);return be.normalize(e.join("/"))},join2:(e,t)=>be.normalize(e+"/"+t)},we=()=>{if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues)return e=>(e.set(crypto.getRandomValues(new Uint8Array(e.byteLength))),e);if(f)try{var e=g("crypto");if(e.randomFillSync)return t=>e.randomFillSync(t);var t=e.randomBytes;return e=>(e.set(t(e.byteLength)),e)}catch(e){}re("initRandomDevice")},Ee=e=>(Ee=we())(e),Se={resolve:function(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var i=r>=0?arguments[r]:$e.cwd();if("string"!=typeof i)throw new TypeError("Arguments to path.resolve must be strings");if(!i)return"";e=i+"/"+e,t=be.isAbs(i)}return(t?"/":"")+(e=be.normalizeArray(e.split("/").filter((e=>!!e)),!t).join("/"))||"."},relative:(e,t)=>{function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var r=e.length-1;r>=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=Se.resolve(e).substr(1),t=Se.resolve(t).substr(1);for(var i=r(e.split("/")),n=r(t.split("/")),s=Math.min(i.length,n.length),o=s,a=0;a<s;a++)if(i[a]!==n[a]){o=a;break}var l=[];for(a=o;a<i.length;a++)l.push("..");return(l=l.concat(n.slice(o))).join("/")}},Ue="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,xe=(e,t,r)=>{for(var i=t+r,n=t;e[n]&&!(n>=i);)++n;if(n-t>16&&e.buffer&&Ue)return Ue.decode(e.buffer instanceof SharedArrayBuffer?e.slice(t,n):e.subarray(t,n));for(var s="";t<n;){var o=e[t++];if(128&o){var a=63&e[t++];if(192!=(224&o)){var l=63&e[t++];if((o=224==(240&o)?(15&o)<<12|a<<6|l:(7&o)<<18|a<<12|l<<6|63&e[t++])<65536)s+=String.fromCharCode(o);else{var d=o-65536;s+=String.fromCharCode(55296|d>>10,56320|1023&d)}}else s+=String.fromCharCode((31&o)<<6|a)}else s+=String.fromCharCode(o)}return s},ke=[],Ae=e=>{for(var t=0,r=0;r<e.length;++r){var i=e.charCodeAt(r);i<=127?t++:i<=2047?t+=2:i>=55296&&i<=57343?(t+=4,++r):t+=3}return t},Te=(e,t,r,i)=>{if(!(i>0))return 0;for(var n=r,s=r+i-1,o=0;o<e.length;++o){var a=e.charCodeAt(o);if(a>=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&e.charCodeAt(++o)),a<=127){if(r>=s)break;t[r++]=a}else if(a<=2047){if(r+1>=s)break;t[r++]=192|a>>6,t[r++]=128|63&a}else if(a<=65535){if(r+2>=s)break;t[r++]=224|a>>12,t[r++]=128|a>>6&63,t[r++]=128|63&a}else{if(r+3>=s)break;t[r++]=240|a>>18,t[r++]=128|a>>12&63,t[r++]=128|a>>6&63,t[r++]=128|63&a}}return t[r]=0,r-n};function Ce(e,t,r){var i=r>0?r:Ae(e)+1,n=new Array(i),s=Te(e,n,0,n.length);return t&&(n.length=s),n}var Be=()=>{if(!ke.length){var e=null;if(f){var t=Buffer.alloc(256),r=0,i=process.stdin.fd;try{r=y.readSync(i,t)}catch(e){if(!e.toString().includes("EOF"))throw e;r=0}e=r>0?t.slice(0,r).toString("utf-8"):null}else"undefined"!=typeof window&&"function"==typeof window.prompt?null!==(e=window.prompt("Input: "))&&(e+="\n"):"function"==typeof readline&&null!==(e=readline())&&(e+="\n");if(!e)return null;ke=Ce(e,!0)}return ke.shift()},Fe={ttys:[],init(){},shutdown(){},register(e,t){Fe.ttys[e]={input:[],output:[],ops:t},$e.registerDevice(e,Fe.stream_ops)},stream_ops:{open(e){var t=Fe.ttys[e.node.rdev];if(!t)throw new $e.ErrnoError(43);e.tty=t,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,t,r,i,n){if(!e.tty||!e.tty.ops.get_char)throw new $e.ErrnoError(60);for(var s=0,o=0;o<i;o++){var a;try{a=e.tty.ops.get_char(e.tty)}catch(e){throw new $e.ErrnoError(29)}if(void 0===a&&0===s)throw new $e.ErrnoError(6);if(null==a)break;s++,t[r+o]=a}return s&&(e.node.timestamp=Date.now()),s},write(e,t,r,i,n){if(!e.tty||!e.tty.ops.put_char)throw new $e.ErrnoError(60);try{for(var s=0;s<i;s++)e.tty.ops.put_char(e.tty,t[r+s])}catch(e){throw new $e.ErrnoError(29)}return i&&(e.node.timestamp=Date.now()),s}},default_tty_ops:{get_char:e=>Be(),put_char(e,t){null===t||10===t?(S(xe(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync(e){e.output&&e.output.length>0&&(S(xe(e.output,0)),e.output=[])},ioctl_tcgets:e=>({c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}),ioctl_tcsets:(e,t,r)=>0,ioctl_tiocgwinsz:e=>[24,80]},default_tty1_ops:{put_char(e,t){null===t||10===t?(U(xe(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync(e){e.output&&e.output.length>0&&(U(xe(e.output,0)),e.output=[])}}},Pe=e=>{re()},De={ops_table:null,mount:e=>De.createNode(null,"/",16895,0),createNode(e,t,r,i){if($e.isBlkdev(r)||$e.isFIFO(r))throw new $e.ErrnoError(63);De.ops_table||(De.ops_table={dir:{node:{getattr:De.node_ops.getattr,setattr:De.node_ops.setattr,lookup:De.node_ops.lookup,mknod:De.node_ops.mknod,rename:De.node_ops.rename,unlink:De.node_ops.unlink,rmdir:De.node_ops.rmdir,readdir:De.node_ops.readdir,symlink:De.node_ops.symlink},stream:{llseek:De.stream_ops.llseek}},file:{node:{getattr:De.node_ops.getattr,setattr:De.node_ops.setattr},stream:{llseek:De.stream_ops.llseek,read:De.stream_ops.read,write:De.stream_ops.write,allocate:De.stream_ops.allocate,mmap:De.stream_ops.mmap,msync:De.stream_ops.msync}},link:{node:{getattr:De.node_ops.getattr,setattr:De.node_ops.setattr,readlink:De.node_ops.readlink},stream:{}},chrdev:{node:{getattr:De.node_ops.getattr,setattr:De.node_ops.setattr},stream:$e.chrdev_stream_ops}});var n=$e.createNode(e,t,r,i);return $e.isDir(n.mode)?(n.node_ops=De.ops_table.dir.node,n.stream_ops=De.ops_table.dir.stream,n.contents={}):$e.isFile(n.mode)?(n.node_ops=De.ops_table.file.node,n.stream_ops=De.ops_table.file.stream,n.usedBytes=0,n.contents=null):$e.isLink(n.mode)?(n.node_ops=De.ops_table.link.node,n.stream_ops=De.ops_table.link.stream):$e.isChrdev(n.mode)&&(n.node_ops=De.ops_table.chrdev.node,n.stream_ops=De.ops_table.chrdev.stream),n.timestamp=Date.now(),e&&(e.contents[t]=n,e.timestamp=n.timestamp),n},getFileDataAsTypedArray:e=>e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0),expandFileStorage(e,t){var r=e.contents?e.contents.length:0;if(!(r>=t)){t=Math.max(t,r*(r<1048576?2:1.125)>>>0),0!=r&&(t=Math.max(t,256));var i=e.contents;e.contents=new Uint8Array(t),e.usedBytes>0&&e.contents.set(i.subarray(0,e.usedBytes),0)}},resizeFileStorage(e,t){if(e.usedBytes!=t)if(0==t)e.contents=null,e.usedBytes=0;else{var r=e.contents;e.contents=new Uint8Array(t),r&&e.contents.set(r.subarray(0,Math.min(t,e.usedBytes))),e.usedBytes=t}},node_ops:{getattr(e){var t={};return t.dev=$e.isChrdev(e.mode)?e.id:1,t.ino=e.id,t.mode=e.mode,t.nlink=1,t.uid=0,t.gid=0,t.rdev=e.rdev,$e.isDir(e.mode)?t.size=4096:$e.isFile(e.mode)?t.size=e.usedBytes:$e.isLink(e.mode)?t.size=e.link.length:t.size=0,t.atime=new Date(e.timestamp),t.mtime=new Date(e.timestamp),t.ctime=new Date(e.timestamp),t.blksize=4096,t.blocks=Math.ceil(t.size/t.blksize),t},setattr(e,t){void 0!==t.mode&&(e.mode=t.mode),void 0!==t.timestamp&&(e.timestamp=t.timestamp),void 0!==t.size&&De.resizeFileStorage(e,t.size)},lookup(e,t){throw $e.genericErrors[44]},mknod:(e,t,r,i)=>De.createNode(e,t,r,i),rename(e,t,r){if($e.isDir(e.mode)){var i;try{i=$e.lookupNode(t,r)}catch(e){}if(i)for(var n in i.contents)throw new $e.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=r,t.contents[r]=e,t.timestamp=e.parent.timestamp,e.parent=t},unlink(e,t){delete e.contents[t],e.timestamp=Date.now()},rmdir(e,t){var r=$e.lookupNode(e,t);for(var i in r.contents)throw new $e.ErrnoError(55);delete e.contents[t],e.timestamp=Date.now()},readdir(e){var t=[".",".."];for(var r in e.contents)e.contents.hasOwnProperty(r)&&t.push(r);return t},symlink(e,t,r){var i=De.createNode(e,t,41471,0);return i.link=r,i},readlink(e){if(!$e.isLink(e.mode))throw new $e.ErrnoError(28);return e.link}},stream_ops:{read(e,t,r,i,n){var s=e.node.contents;if(n>=e.node.usedBytes)return 0;var o=Math.min(e.node.usedBytes-n,i);if(o>8&&s.subarray)t.set(s.subarray(n,n+o),r);else for(var a=0;a<o;a++)t[r+a]=s[n+a];return o},write(e,t,r,i,n,s){if(!i)return 0;var o=e.node;if(o.timestamp=Date.now(),t.subarray&&(!o.contents||o.contents.subarray)){if(s)return o.contents=t.subarray(r,r+i),o.usedBytes=i,i;if(0===o.usedBytes&&0===n)return o.contents=t.slice(r,r+i),o.usedBytes=i,i;if(n+i<=o.usedBytes)return o.contents.set(t.subarray(r,r+i),n),i}if(De.expandFileStorage(o,n+i),o.contents.subarray&&t.subarray)o.contents.set(t.subarray(r,r+i),n);else for(var a=0;a<i;a++)o.contents[n+a]=t[r+a];return o.usedBytes=Math.max(o.usedBytes,n+i),i},llseek(e,t,r){var i=t;if(1===r?i+=e.position:2===r&&$e.isFile(e.node.mode)&&(i+=e.node.usedBytes),i<0)throw new $e.ErrnoError(28);return i},allocate(e,t,r){De.expandFileStorage(e.node,t+r),e.node.usedBytes=Math.max(e.node.usedBytes,t+r)},mmap(e,t,r,i,n){if(!$e.isFile(e.node.mode))throw new $e.ErrnoError(43);var s,o,a=e.node.contents;if(2&n||a.buffer!==C.buffer){if((r>0||r+t<a.length)&&(a=a.subarray?a.subarray(r,r+t):Array.prototype.slice.call(a,r,r+t)),o=!0,!(s=Pe()))throw new $e.ErrnoError(48);C.set(a,s)}else o=!1,s=a.byteOffset;return{ptr:s,allocated:o}},msync:(e,t,r,i,n)=>(De.stream_ops.write(e,t,0,i,r,!1),0)}},Ie=(e,t,r,i)=>{var n=i?"":`al ${e}`;o(e,(r=>{M(r,`Loading data file "${e}" failed (no arrayBuffer).`),t(new Uint8Array(r)),n&&te()}),(t=>{if(!r)throw`Loading data file "${e}" failed.`;r()})),n&&ee()},Le=(e,t,r,i,n,s)=>$e.createDataFile(e,t,r,i,n,s),Re=n.preloadPlugins||[],ze=(e,t,r,i)=>{"undefined"!=typeof Browser&&Browser.init();var n=!1;return Re.forEach((s=>{n||s.canHandle(t)&&(s.handle(e,t,r,i),n=!0)})),n},Me=(e,t,r,i,n,s,o,a,l,d)=>{var u=t?Se.resolve(be.join2(e,t)):e;function h(r){function h(r){d&&d(),a||Le(e,t,r,i,n,l),s&&s(),te()}ze(r,u,h,(()=>{o&&o(),te()}))||h(r)}ee(),"string"==typeof r?Ie(r,(e=>h(e)),o):h(r)},Oe=e=>{var t={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[e];if(void 0===t)throw new Error(`Unknown file open mode: ${e}`);return t},Ne=(e,t)=>{var r=0;return e&&(r|=365),t&&(r|=146),r},$e={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(e=Se.resolve(e)))return{path:"",node:null};if(t=Object.assign({follow_mount:!0,recurse_count:0},t),t.recurse_count>8)throw new $e.ErrnoError(32);for(var r=e.split("/").filter((e=>!!e)),i=$e.root,n="/",s=0;s<r.length;s++){var o=s===r.length-1;if(o&&t.parent)break;if(i=$e.lookupNode(i,r[s]),n=be.join2(n,r[s]),$e.isMountpoint(i)&&(!o||o&&t.follow_mount)&&(i=i.mounted.root),!o||t.follow)for(var a=0;$e.isLink(i.mode);){var l=$e.readlink(n);if(n=Se.resolve(be.dirname(n),l),i=$e.lookupPath(n,{recurse_count:t.recurse_count+1}).node,a++>40)throw new $e.ErrnoError(32)}}return{path:n,node:i}},getPath(e){for(var t;;){if($e.isRoot(e)){var r=e.mount.mountpoint;return t?"/"!==r[r.length-1]?`${r}/${t}`:r+t:r}t=t?`${e.name}/${t}`:e.name,e=e.parent}},hashName(e,t){for(var r=0,i=0;i<t.length;i++)r=(r<<5)-r+t.charCodeAt(i)|0;return(e+r>>>0)%$e.nameTable.length},hashAddNode(e){var t=$e.hashName(e.parent.id,e.name);e.name_next=$e.nameTable[t],$e.nameTable[t]=e},hashRemoveNode(e){var t=$e.hashName(e.parent.id,e.name);if($e.nameTable[t]===e)$e.nameTable[t]=e.name_next;else for(var r=$e.nameTable[t];r;){if(r.name_next===e){r.name_next=e.name_next;break}r=r.name_next}},lookupNode(e,t){var r=$e.mayLookup(e);if(r)throw new $e.ErrnoError(r,e);for(var i=$e.hashName(e.id,t),n=$e.nameTable[i];n;n=n.name_next){var s=n.name;if(n.parent.id===e.id&&s===t)return n}return $e.lookup(e,t)},createNode(e,t,r,i){var n=new $e.FSNode(e,t,r,i);return $e.hashAddNode(n),n},destroyNode(e){$e.hashRemoveNode(e)},isRoot:e=>e===e.parent,isMountpoint:e=>!!e.mounted,isFile:e=>32768==(61440&e),isDir:e=>16384==(61440&e),isLink:e=>40960==(61440&e),isChrdev:e=>8192==(61440&e),isBlkdev:e=>24576==(61440&e),isFIFO:e=>4096==(61440&e),isSocket:e=>49152==(49152&e),flagsToPermissionString(e){var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},nodePermissions:(e,t)=>$e.ignorePermissions||(!t.includes("r")||292&e.mode)&&(!t.includes("w")||146&e.mode)&&(!t.includes("x")||73&e.mode)?0:2,mayLookup(e){var t=$e.nodePermissions(e,"x");return t||(e.node_ops.lookup?0:2)},mayCreate(e,t){try{return $e.lookupNode(e,t),20}catch(e){}return $e.nodePermissions(e,"wx")},mayDelete(e,t,r){var i;try{i=$e.lookupNode(e,t)}catch(e){return e.errno}var n=$e.nodePermissions(e,"wx");if(n)return n;if(r){if(!$e.isDir(i.mode))return 54;if($e.isRoot(i)||$e.getPath(i)===$e.cwd())return 10}else if($e.isDir(i.mode))return 31;return 0},mayOpen:(e,t)=>e?$e.isLink(e.mode)?32:$e.isDir(e.mode)&&("r"!==$e.flagsToPermissionString(t)||512&t)?31:$e.nodePermissions(e,$e.flagsToPermissionString(t)):44,MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=$e.MAX_OPEN_FDS;e++)if(!$e.streams[e])return e;throw new $e.ErrnoError(33)},getStreamChecked(e){var t=$e.getStream(e);if(!t)throw new $e.ErrnoError(8);return t},getStream:e=>$e.streams[e],createStream(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return $e.FSStream||($e.FSStream=function(){this.shared={}},$e.FSStream.prototype={},Object.defineProperties($e.FSStream.prototype,{object:{get(){return this.node},set(e){this.node=e}},isRead:{get(){return 1!=(2097155&this.flags)}},isWrite:{get(){return 0!=(2097155&this.flags)}},isAppend:{get(){return 1024&this.flags}},flags:{get(){return this.shared.flags},set(e){this.shared.flags=e}},position:{get(){return this.shared.position},set(e){this.shared.position=e}}})),e=Object.assign(new $e.FSStream,e),-1==t&&(t=$e.nextfd()),e.fd=t,$e.streams[t]=e,e},closeStream(e){$e.streams[e]=null},chrdev_stream_ops:{open(e){var t=$e.getDevice(e.node.rdev);e.stream_ops=t.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek(){throw new $e.ErrnoError(70)}},major:e=>e>>8,minor:e=>255&e,makedev:(e,t)=>e<<8|t,registerDevice(e,t){$e.devices[e]={stream_ops:t}},getDevice:e=>$e.devices[e],getMounts(e){for(var t=[],r=[e];r.length;){var i=r.pop();t.push(i),r.push.apply(r,i.mounts)}return t},syncfs(e,t){"function"==typeof e&&(t=e,e=!1),$e.syncFSRequests++,$e.syncFSRequests>1&&U(`warning: ${$e.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var r=$e.getMounts($e.root.mount),i=0;function n(e){return $e.syncFSRequests--,t(e)}function s(e){if(e)return s.errored?void 0:(s.errored=!0,n(e));++i>=r.length&&n(null)}r.forEach((t=>{if(!t.type.syncfs)return s(null);t.type.syncfs(t,e,s)}))},mount(e,t,r){var i,n="/"===r,s=!r;if(n&&$e.root)throw new $e.ErrnoError(10);if(!n&&!s){var o=$e.lookupPath(r,{follow_mount:!1});if(r=o.path,i=o.node,$e.isMountpoint(i))throw new $e.ErrnoError(10);if(!$e.isDir(i.mode))throw new $e.ErrnoError(54)}var a={type:e,opts:t,mountpoint:r,mounts:[]},l=e.mount(a);return l.mount=a,a.root=l,n?$e.root=l:i&&(i.mounted=a,i.mount&&i.mount.mounts.push(a)),l},unmount(e){var t=$e.lookupPath(e,{follow_mount:!1});if(!$e.isMountpoint(t.node))throw new $e.ErrnoError(28);var r=t.node,i=r.mounted,n=$e.getMounts(i);Object.keys($e.nameTable).forEach((e=>{for(var t=$e.nameTable[e];t;){var r=t.name_next;n.includes(t.mount)&&$e.destroyNode(t),t=r}})),r.mounted=null;var s=r.mount.mounts.indexOf(i);r.mount.mounts.splice(s,1)},lookup:(e,t)=>e.node_ops.lookup(e,t),mknod(e,t,r){var i=$e.lookupPath(e,{parent:!0}).node,n=be.basename(e);if(!n||"."===n||".."===n)throw new $e.ErrnoError(28);var s=$e.mayCreate(i,n);if(s)throw new $e.ErrnoError(s);if(!i.node_ops.mknod)throw new $e.ErrnoError(63);return i.node_ops.mknod(i,n,t,r)},create:(e,t)=>(t=void 0!==t?t:438,t&=4095,t|=32768,$e.mknod(e,t,0)),mkdir:(e,t)=>(t=void 0!==t?t:511,t&=1023,t|=16384,$e.mknod(e,t,0)),mkdirTree(e,t){for(var r=e.split("/"),i="",n=0;n<r.length;++n)if(r[n]){i+="/"+r[n];try{$e.mkdir(i,t)}catch(e){if(20!=e.errno)throw e}}},mkdev:(e,t,r)=>(void 0===r&&(r=t,t=438),t|=8192,$e.mknod(e,t,r)),symlink(e,t){if(!Se.resolve(e))throw new $e.ErrnoError(44);var r=$e.lookupPath(t,{parent:!0}).node;if(!r)throw new $e.ErrnoError(44);var i=be.basename(t),n=$e.mayCreate(r,i);if(n)throw new $e.ErrnoError(n);if(!r.node_ops.symlink)throw new $e.ErrnoError(63);return r.node_ops.symlink(r,i,e)},rename(e,t){var r,i,n=be.dirname(e),s=be.dirname(t),o=be.basename(e),a=be.basename(t);if(r=$e.lookupPath(e,{parent:!0}).node,i=$e.lookupPath(t,{parent:!0}).node,!r||!i)throw new $e.ErrnoError(44);if(r.mount!==i.mount)throw new $e.ErrnoError(75);var l,d=$e.lookupNode(r,o),u=Se.relative(e,s);if("."!==u.charAt(0))throw new $e.ErrnoError(28);if("."!==(u=Se.relative(t,n)).charAt(0))throw new $e.ErrnoError(55);try{l=$e.lookupNode(i,a)}catch(e){}if(d!==l){var h=$e.isDir(d.mode),c=$e.mayDelete(r,o,h);if(c)throw new $e.ErrnoError(c);if(c=l?$e.mayDelete(i,a,h):$e.mayCreate(i,a))throw new $e.ErrnoError(c);if(!r.node_ops.rename)throw new $e.ErrnoError(63);if($e.isMountpoint(d)||l&&$e.isMountpoint(l))throw new $e.ErrnoError(10);if(i!==r&&(c=$e.nodePermissions(r,"w")))throw new $e.ErrnoError(c);$e.hashRemoveNode(d);try{r.node_ops.rename(d,i,a)}catch(e){throw e}finally{$e.hashAddNode(d)}}},rmdir(e){var t=$e.lookupPath(e,{parent:!0}).node,r=be.basename(e),i=$e.lookupNode(t,r),n=$e.mayDelete(t,r,!0);if(n)throw new $e.ErrnoError(n);if(!t.node_ops.rmdir)throw new $e.ErrnoError(63);if($e.isMountpoint(i))throw new $e.ErrnoError(10);t.node_ops.rmdir(t,r),$e.destroyNode(i)},readdir(e){var t=$e.lookupPath(e,{follow:!0}).node;if(!t.node_ops.readdir)throw new $e.ErrnoError(54);return t.node_ops.readdir(t)},unlink(e){var t=$e.lookupPath(e,{parent:!0}).node;if(!t)throw new $e.ErrnoError(44);var r=be.basename(e),i=$e.lookupNode(t,r),n=$e.mayDelete(t,r,!1);if(n)throw new $e.ErrnoError(n);if(!t.node_ops.unlink)throw new $e.ErrnoError(63);if($e.isMountpoint(i))throw new $e.ErrnoError(10);t.node_ops.unlink(t,r),$e.destroyNode(i)},readlink(e){var t=$e.lookupPath(e).node;if(!t)throw new $e.ErrnoError(44);if(!t.node_ops.readlink)throw new $e.ErrnoError(28);return Se.resolve($e.getPath(t.parent),t.node_ops.readlink(t))},stat(e,t){var r=$e.lookupPath(e,{follow:!t}).node;if(!r)throw new $e.ErrnoError(44);if(!r.node_ops.getattr)throw new $e.ErrnoError(63);return r.node_ops.getattr(r)},lstat:e=>$e.stat(e,!0),chmod(e,t,r){var i;if(!(i="string"==typeof e?$e.lookupPath(e,{follow:!r}).node:e).node_ops.setattr)throw new $e.ErrnoError(63);i.node_ops.setattr(i,{mode:4095&t|-4096&i.mode,timestamp:Date.now()})},lchmod(e,t){$e.chmod(e,t,!0)},fchmod(e,t){var r=$e.getStreamChecked(e);$e.chmod(r.node,t)},chown(e,t,r,i){var n;if(!(n="string"==typeof e?$e.lookupPath(e,{follow:!i}).node:e).node_ops.setattr)throw new $e.ErrnoError(63);n.node_ops.setattr(n,{timestamp:Date.now()})},lchown(e,t,r){$e.chown(e,t,r,!0)},fchown(e,t,r){var i=$e.getStreamChecked(e);$e.chown(i.node,t,r)},truncate(e,t){if(t<0)throw new $e.ErrnoError(28);var r;if(!(r="string"==typeof e?$e.lookupPath(e,{follow:!0}).node:e).node_ops.setattr)throw new $e.ErrnoError(63);if($e.isDir(r.mode))throw new $e.ErrnoError(31);if(!$e.isFile(r.mode))throw new $e.ErrnoError(28);var i=$e.nodePermissions(r,"w");if(i)throw new $e.ErrnoError(i);r.node_ops.setattr(r,{size:t,timestamp:Date.now()})},ftruncate(e,t){var r=$e.getStreamChecked(e);if(0==(2097155&r.flags))throw new $e.ErrnoError(28);$e.truncate(r.node,t)},utime(e,t,r){var i=$e.lookupPath(e,{follow:!0}).node;i.node_ops.setattr(i,{timestamp:Math.max(t,r)})},open(e,t,r){if(""===e)throw new $e.ErrnoError(44);var i;if(r=void 0===r?438:r,r=64&(t="string"==typeof t?Oe(t):t)?4095&r|32768:0,"object"==typeof e)i=e;else{e=be.normalize(e);try{i=$e.lookupPath(e,{follow:!(131072&t)}).node}catch(e){}}var s=!1;if(64&t)if(i){if(128&t)throw new $e.ErrnoError(20)}else i=$e.mknod(e,r,0),s=!0;if(!i)throw new $e.ErrnoError(44);if($e.isChrdev(i.mode)&&(t&=-513),65536&t&&!$e.isDir(i.mode))throw new $e.ErrnoError(54);if(!s){var o=$e.mayOpen(i,t);if(o)throw new $e.ErrnoError(o)}512&t&&!s&&$e.truncate(i,0),t&=-131713;var a=$e.createStream({node:i,path:$e.getPath(i),flags:t,seekable:!0,position:0,stream_ops:i.stream_ops,ungotten:[],error:!1});return a.stream_ops.open&&a.stream_ops.open(a),!n.logReadFiles||1&t||($e.readFiles||($e.readFiles={}),e in $e.readFiles||($e.readFiles[e]=1)),a},close(e){if($e.isClosed(e))throw new $e.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{$e.closeStream(e.fd)}e.fd=null},isClosed:e=>null===e.fd,llseek(e,t,r){if($e.isClosed(e))throw new $e.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new $e.ErrnoError(70);if(0!=r&&1!=r&&2!=r)throw new $e.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,r),e.ungotten=[],e.position},read(e,t,r,i,n){if(i<0||n<0)throw new $e.ErrnoError(28);if($e.isClosed(e))throw new $e.ErrnoError(8);if(1==(2097155&e.flags))throw new $e.ErrnoError(8);if($e.isDir(e.node.mode))throw new $e.ErrnoError(31);if(!e.stream_ops.read)throw new $e.ErrnoError(28);var s=void 0!==n;if(s){if(!e.seekable)throw new $e.ErrnoError(70)}else n=e.position;var o=e.stream_ops.read(e,t,r,i,n);return s||(e.position+=o),o},write(e,t,r,i,n,s){if(i<0||n<0)throw new $e.ErrnoError(28);if($e.isClosed(e))throw new $e.ErrnoError(8);if(0==(2097155&e.flags))throw new $e.ErrnoError(8);if($e.isDir(e.node.mode))throw new $e.ErrnoError(31);if(!e.stream_ops.write)throw new $e.ErrnoError(28);e.seekable&&1024&e.flags&&$e.llseek(e,0,2);var o=void 0!==n;if(o){if(!e.seekable)throw new $e.ErrnoError(70)}else n=e.position;var a=e.stream_ops.write(e,t,r,i,n,s);return o||(e.position+=a),a},allocate(e,t,r){if($e.isClosed(e))throw new $e.ErrnoError(8);if(t<0||r<=0)throw new $e.ErrnoError(28);if(0==(2097155&e.flags))throw new $e.ErrnoError(8);if(!$e.isFile(e.node.mode)&&!$e.isDir(e.node.mode))throw new $e.ErrnoError(43);if(!e.stream_ops.allocate)throw new $e.ErrnoError(138);e.stream_ops.allocate(e,t,r)},mmap(e,t,r,i,n){if(0!=(2&i)&&0==(2&n)&&2!=(2097155&e.flags))throw new $e.ErrnoError(2);if(1==(2097155&e.flags))throw new $e.ErrnoError(2);if(!e.stream_ops.mmap)throw new $e.ErrnoError(43);return e.stream_ops.mmap(e,t,r,i,n)},msync:(e,t,r,i,n)=>e.stream_ops.msync?e.stream_ops.msync(e,t,r,i,n):0,munmap:e=>0,ioctl(e,t,r){if(!e.stream_ops.ioctl)throw new $e.ErrnoError(59);return e.stream_ops.ioctl(e,t,r)},readFile(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t.flags=t.flags||0,t.encoding=t.encoding||"binary","utf8"!==t.encoding&&"binary"!==t.encoding)throw new Error(`Invalid encoding type "${t.encoding}"`);var r,i=$e.open(e,t.flags),n=$e.stat(e).size,s=new Uint8Array(n);return $e.read(i,s,0,n,0),"utf8"===t.encoding?r=xe(s,0):"binary"===t.encoding&&(r=s),$e.close(i),r},writeFile(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};r.flags=r.flags||577;var i=$e.open(e,r.flags,r.mode);if("string"==typeof t){var n=new Uint8Array(Ae(t)+1),s=Te(t,n,0,n.length);$e.write(i,n,0,s,void 0,r.canOwn)}else{if(!ArrayBuffer.isView(t))throw new Error("Unsupported data type");$e.write(i,t,0,t.byteLength,void 0,r.canOwn)}$e.close(i)},cwd:()=>$e.currentPath,chdir(e){var t=$e.lookupPath(e,{follow:!0});if(null===t.node)throw new $e.ErrnoError(44);if(!$e.isDir(t.node.mode))throw new $e.ErrnoError(54);var r=$e.nodePermissions(t.node,"x");if(r)throw new $e.ErrnoError(r);$e.currentPath=t.path},createDefaultDirectories(){$e.mkdir("/tmp"),$e.mkdir("/home"),$e.mkdir("/home/web_user")},createDefaultDevices(){$e.mkdir("/dev"),$e.registerDevice($e.makedev(1,3),{read:()=>0,write:(e,t,r,i,n)=>i}),$e.mkdev("/dev/null",$e.makedev(1,3)),Fe.register($e.makedev(5,0),Fe.default_tty_ops),Fe.register($e.makedev(6,0),Fe.default_tty1_ops),$e.mkdev("/dev/tty",$e.makedev(5,0)),$e.mkdev("/dev/tty1",$e.makedev(6,0));var e=new Uint8Array(1024),t=0,r=()=>(0===t&&(t=Ee(e).byteLength),e[--t]);$e.createDevice("/dev","random",r),$e.createDevice("/dev","urandom",r),$e.mkdir("/dev/shm"),$e.mkdir("/dev/shm/tmp")},createSpecialDirectories(){$e.mkdir("/proc");var e=$e.mkdir("/proc/self");$e.mkdir("/proc/self/fd"),$e.mount({mount(){var t=$e.createNode(e,"fd",16895,73);return t.node_ops={lookup(e,t){var r=+t,i=$e.getStreamChecked(r),n={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>i.path}};return n.parent=n,n}},t}},{},"/proc/self/fd")},createStandardStreams(){n.stdin?$e.createDevice("/dev","stdin",n.stdin):$e.symlink("/dev/tty","/dev/stdin"),n.stdout?$e.createDevice("/dev","stdout",null,n.stdout):$e.symlink("/dev/tty","/dev/stdout"),n.stderr?$e.createDevice("/dev","stderr",null,n.stderr):$e.symlink("/dev/tty1","/dev/stderr"),$e.open("/dev/stdin",0),$e.open("/dev/stdout",1),$e.open("/dev/stderr",1)},ensureErrnoError(){$e.ErrnoError||($e.ErrnoError=function(e,t){this.name="ErrnoError",this.node=t,this.setErrno=function(e){this.errno=e},this.setErrno(e),this.message="FS error"},$e.ErrnoError.prototype=new Error,$e.ErrnoError.prototype.constructor=$e.ErrnoError,[44].forEach((e=>{$e.genericErrors[e]=new $e.ErrnoError(e),$e.genericErrors[e].stack="<generic error, no stack>"})))},staticInit(){$e.ensureErrnoError(),$e.nameTable=new Array(4096),$e.mount(De,{},"/"),$e.createDefaultDirectories(),$e.createDefaultDevices(),$e.createSpecialDirectories(),$e.filesystems={MEMFS:De}},init(e,t,r){$e.init.initialized=!0,$e.ensureErrnoError(),n.stdin=e||n.stdin,n.stdout=t||n.stdout,n.stderr=r||n.stderr,$e.createStandardStreams()},quit(){$e.init.initialized=!1;for(var e=0;e<$e.streams.length;e++){var t=$e.streams[e];t&&$e.close(t)}},findObject(e,t){var r=$e.analyzePath(e,t);return r.exists?r.object:null},analyzePath(e,t){try{e=(i=$e.lookupPath(e,{follow:!t})).path}catch(e){}var r={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var i=$e.lookupPath(e,{parent:!0});r.parentExists=!0,r.parentPath=i.path,r.parentObject=i.node,r.name=be.basename(e),i=$e.lookupPath(e,{follow:!t}),r.exists=!0,r.path=i.path,r.object=i.node,r.name=i.node.name,r.isRoot="/"===i.path}catch(e){r.error=e.errno}return r},createPath(e,t,r,i){e="string"==typeof e?e:$e.getPath(e);for(var n=t.split("/").reverse();n.length;){var s=n.pop();if(s){var o=be.join2(e,s);try{$e.mkdir(o)}catch(e){}e=o}}return o},createFile(e,t,r,i,n){var s=be.join2("string"==typeof e?e:$e.getPath(e),t),o=Ne(i,n);return $e.create(s,o)},createDataFile(e,t,r,i,n,s){var o=t;e&&(e="string"==typeof e?e:$e.getPath(e),o=t?be.join2(e,t):e);var a=Ne(i,n),l=$e.create(o,a);if(r){if("string"==typeof r){for(var d=new Array(r.length),u=0,h=r.length;u<h;++u)d[u]=r.charCodeAt(u);r=d}$e.chmod(l,146|a);var c=$e.open(l,577);$e.write(c,r,0,r.length,0,s),$e.close(c),$e.chmod(l,a)}return l},createDevice(e,t,r,i){var n=be.join2("string"==typeof e?e:$e.getPath(e),t),s=Ne(!!r,!!i);$e.createDevice.major||($e.createDevice.major=64);var o=$e.makedev($e.createDevice.major++,0);return $e.registerDevice(o,{open(e){e.seekable=!1},close(e){i&&i.buffer&&i.buffer.length&&i(10)},read(e,t,i,n,s){for(var o=0,a=0;a<n;a++){var l;try{l=r()}catch(e){throw new $e.ErrnoError(29)}if(void 0===l&&0===o)throw new $e.ErrnoError(6);if(null==l)break;o++,t[i+a]=l}return o&&(e.node.timestamp=Date.now()),o},write(e,t,r,n,s){for(var o=0;o<n;o++)try{i(t[r+o])}catch(e){throw new $e.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),o}}),$e.mkdev(n,s,o)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if("undefined"!=typeof XMLHttpRequest)throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(!s)throw new Error("Cannot load without read() or XMLHttpRequest.");try{e.contents=Ce(s(e.url),!0),e.usedBytes=e.contents.length}catch(e){throw new $e.ErrnoError(29)}},createLazyFile(e,t,r,i,n){function s(){this.lengthKnown=!1,this.chunks=[]}if(s.prototype.get=function(e){if(!(e>this.length-1||e<0)){var t=e%this.chunkSize,r=e/this.chunkSize|0;return this.getter(r)[t]}},s.prototype.setDataGetter=function(e){this.getter=e},s.prototype.cacheLength=function(){var e=new XMLHttpRequest;if(e.open("HEAD",r,!1),e.send(null),!(e.status>=200&&e.status<300||304===e.status))throw new Error("Couldn't load "+r+". Status: "+e.status);var t,i=Number(e.getResponseHeader("Content-length")),n=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t,s=(t=e.getResponseHeader("Content-Encoding"))&&"gzip"===t,o=1048576;n||(o=i);var a=this;a.setDataGetter((e=>{var t=e*o,n=(e+1)*o-1;if(n=Math.min(n,i-1),void 0===a.chunks[e]&&(a.chunks[e]=((e,t)=>{if(e>t)throw new Error("invalid range ("+e+", "+t+") or no bytes requested!");if(t>i-1)throw new Error("only "+i+" bytes available! programmer error!");var n=new XMLHttpRequest;if(n.open("GET",r,!1),i!==o&&n.setRequestHeader("Range","bytes="+e+"-"+t),n.responseType="arraybuffer",n.overrideMimeType&&n.overrideMimeType("text/plain; charset=x-user-defined"),n.send(null),!(n.status>=200&&n.status<300||304===n.status))throw new Error("Couldn't load "+r+". Status: "+n.status);return void 0!==n.response?new Uint8Array(n.response||[]):Ce(n.responseText||"",!0)})(t,n)),void 0===a.chunks[e])throw new Error("doXHR failed!");return a.chunks[e]})),!s&&i||(o=i=1,i=this.getter(0).length,o=i,S("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=i,this._chunkSize=o,this.lengthKnown=!0},"undefined"!=typeof XMLHttpRequest){if(!c)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var o=new s;Object.defineProperties(o,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var a={isDevice:!1,contents:o}}else a={isDevice:!1,url:r};var l=$e.createFile(e,t,a,i,n);a.contents?l.contents=a.contents:a.url&&(l.contents=null,l.url=a.url),Object.defineProperties(l,{usedBytes:{get:function(){return this.contents.length}}});var d={};function u(e,t,r,i,n){var s=e.node.contents;if(n>=s.length)return 0;var o=Math.min(s.length-n,i);if(s.slice)for(var a=0;a<o;a++)t[r+a]=s[n+a];else for(a=0;a<o;a++)t[r+a]=s.get(n+a);return o}return Object.keys(l.stream_ops).forEach((e=>{var t=l.stream_ops[e];d[e]=function(){return $e.forceLoadFile(l),t.apply(null,arguments)}})),d.read=(e,t,r,i,n)=>($e.forceLoadFile(l),u(e,t,r,i,n)),d.mmap=(e,t,r,i,n)=>{$e.forceLoadFile(l);var s=Pe();if(!s)throw new $e.ErrnoError(48);return u(e,C,s,t,r),{ptr:s,allocated:!0}},l.stream_ops=d,l}},Ge=(e,t)=>e?xe(B,e,t):"",He={DEFAULT_POLLMASK:5,calculateAt(e,t,r){if(be.isAbs(t))return t;var i;if(i=-100===e?$e.cwd():He.getStreamFromFD(e).path,0==t.length){if(!r)throw new $e.ErrnoError(44);return i}return be.join2(i,t)},doStat(e,t,r){try{var i=e(t)}catch(e){if(e&&e.node&&be.normalize(t)!==be.normalize($e.getPath(e.node)))return-54;throw e}D[r>>2]=i.dev,D[r+4>>2]=i.mode,I[r+8>>2]=i.nlink,D[r+12>>2]=i.uid,D[r+16>>2]=i.gid,D[r+20>>2]=i.rdev,se=[i.size>>>0,(ne=i.size,+Math.abs(ne)>=1?ne>0?+Math.floor(ne/4294967296)>>>0:~~+Math.ceil((ne-+(~~ne>>>0))/4294967296)>>>0:0)],D[r+24>>2]=se[0],D[r+28>>2]=se[1],D[r+32>>2]=4096,D[r+36>>2]=i.blocks;var n=i.atime.getTime(),s=i.mtime.getTime(),o=i.ctime.getTime();return se=[Math.floor(n/1e3)>>>0,(ne=Math.floor(n/1e3),+Math.abs(ne)>=1?ne>0?+Math.floor(ne/4294967296)>>>0:~~+Math.ceil((ne-+(~~ne>>>0))/4294967296)>>>0:0)],D[r+40>>2]=se[0],D[r+44>>2]=se[1],I[r+48>>2]=n%1e3*1e3,se=[Math.floor(s/1e3)>>>0,(ne=Math.floor(s/1e3),+Math.abs(ne)>=1?ne>0?+Math.floor(ne/4294967296)>>>0:~~+Math.ceil((ne-+(~~ne>>>0))/4294967296)>>>0:0)],D[r+56>>2]=se[0],D[r+60>>2]=se[1],I[r+64>>2]=s%1e3*1e3,se=[Math.floor(o/1e3)>>>0,(ne=Math.floor(o/1e3),+Math.abs(ne)>=1?ne>0?+Math.floor(ne/4294967296)>>>0:~~+Math.ceil((ne-+(~~ne>>>0))/4294967296)>>>0:0)],D[r+72>>2]=se[0],D[r+76>>2]=se[1],I[r+80>>2]=o%1e3*1e3,se=[i.ino>>>0,(ne=i.ino,+Math.abs(ne)>=1?ne>0?+Math.floor(ne/4294967296)>>>0:~~+Math.ceil((ne-+(~~ne>>>0))/4294967296)>>>0:0)],D[r+88>>2]=se[0],D[r+92>>2]=se[1],0},doMsync(e,t,r,i,n){if(!$e.isFile(t.node.mode))throw new $e.ErrnoError(43);if(2&i)return 0;var s=B.slice(e,e+r);$e.msync(t,s,n,r,i)},varargs:void 0,get(){var e=D[+He.varargs>>2];return He.varargs+=4,e},getp:()=>He.get(),getStr:e=>Ge(e),getStreamFromFD:e=>$e.getStreamChecked(e)};function Ve(e){if(p)return oi(0,1,e);T=e,W()||(qe.terminateAllThreads(),n.onExit&&n.onExit(e),z=!0),u(e,new pe(e))}var We=(e,t)=>{if(T=e,p)throw Ze(e),"unwind";Ve(e)},je=We,Ye=e=>{if(e instanceof pe||"unwind"==e)return T;u(1,e)},qe={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],pthreads:{},init(){p?qe.initWorker():qe.initMainThread()},initMainThread(){K((()=>{ee(),qe.loadWasmModuleToAllWorkers((()=>te()))}))},initWorker(){A=!1},setExitStatus:e=>{T=e},terminateAllThreads__deps:["$terminateWorker"],terminateAllThreads:()=>{for(var e of qe.runningWorkers)me(e);for(var e of qe.unusedWorkers)me(e);qe.unusedWorkers=[],qe.runningWorkers=[],qe.pthreads=[]},returnWorkerToPool:e=>{var t=e.pthread_ptr;delete qe.pthreads[t],qe.unusedWorkers.push(e),qe.runningWorkers.splice(qe.runningWorkers.indexOf(e),1),e.pthread_ptr=0,nn(t)},receiveObjectTransfer(e){},threadInitTLS(){qe.tlsInitFunctions.forEach((e=>e()))},loadWasmModuleToWorker:e=>new Promise((t=>{e.onmessage=r=>{var i=r.data,s=i.cmd;if(i.targetThread&&i.targetThread!=Ji()){var o=qe.pthreads[i.targetThread];o?o.postMessage(i,i.transferList):U(`Internal error! Worker sent a message "${s}" to target pthread ${i.targetThread}, but that thread no longer exists!`)}else"checkMailbox"===s?ri():"spawnThread"===s?ve(i):"cleanupThread"===s?ye(i.thread):"killThread"===s?_e(i.thread):"cancelThread"===s?ge(i.thread):"loaded"===s?(e.loaded=!0,t(e)):"alert"===s?alert(`Thread ${i.threadId}: ${i.text}`):"setimmediate"===i.target?e.postMessage(i):"callHandler"===s?n[i.handler](...i.args):s&&U(`worker sent an unknown command ${s}`)},e.onerror=e=>{throw U(`worker sent an error! ${e.filename}:${e.lineno}: ${e.message}`),e},f&&(e.on("message",(t=>e.onmessage({data:t}))),e.on("error",(t=>e.onerror(t))));var r=[];for(var i of["onExit","onAbort","print","printErr"])n.hasOwnProperty(i)&&r.push(i);e.postMessage({cmd:"load",handlers:r,urlOrBlob:n.mainScriptUrlOrBlob,wasmMemory:x,wasmModule:k})})),loadWasmModuleToAllWorkers(e){e()},allocateUnusedWorker(){var e;if(n.locateFile){var t=_("decoder-pro-mt-worker.worker.js");e=new Worker(t)}else e=new Worker(new URL("decoder-pro-mt-worker.worker.js","undefined"==typeof document&&"undefined"==typeof location?new(require("url").URL)("file:"+__filename).href:"undefined"==typeof document?location.href:document.currentScript&&document.currentScript.src||new URL("decoder-pro-mt.js",document.baseURI).href));qe.unusedWorkers.push(e)},getNewWorker:()=>(0==qe.unusedWorkers.length&&(qe.allocateUnusedWorker(),qe.loadWasmModuleToWorker(qe.unusedWorkers[0])),qe.unusedWorkers.pop())};n.PThread=qe;var Ke=e=>{for(;e.length>0;)e.shift()(n)},Xe=()=>{var e=Ji(),t=I[e+52>>2],r=I[e+56>>2];an(t,t-r),dn(t)};function Ze(e){if(p)return oi(1,0,e);je(e)}n.establishStackSpace=Xe;var Je,Qe=[],et=e=>{var t=Qe[e];return t||(e>=Qe.length&&(Qe.length=e+1),Qe[e]=t=Je.get(e)),t},tt=(e,t)=>{!function(e){W()?qe.setExitStatus(e):sn(e)}(et(e)(t))};n.invokeEntryPoint=tt;var rt=e=>{qe.tlsInitFunctions.push(e)};function it(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(e){I[this.ptr+4>>2]=e},this.get_type=function(){return I[this.ptr+4>>2]},this.set_destructor=function(e){I[this.ptr+8>>2]=e},this.get_destructor=function(){return I[this.ptr+8>>2]},this.set_caught=function(e){e=e?1:0,C[this.ptr+12>>0]=e},this.get_caught=function(){return 0!=C[this.ptr+12>>0]},this.set_rethrown=function(e){e=e?1:0,C[this.ptr+13>>0]=e},this.get_rethrown=function(){return 0!=C[this.ptr+13>>0]},this.init=function(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t)},this.set_adjusted_ptr=function(e){I[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return I[this.ptr+16>>2]},this.get_exception_ptr=function(){if(hn(this.get_type()))return I[this.excPtr>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}var nt=(e,t,r)=>{throw new it(e).init(t,r),e},st=e=>{en(e,!c,1,!h,65536,!1),qe.threadInitTLS()},ot=e=>{p?postMessage({cmd:"cleanupThread",thread:e}):ye(e)};function at(e,t,r,i){return p?oi(2,1,e,t,r,i):lt(e,t,r,i)}var lt=(e,t,r,i)=>{if("undefined"==typeof SharedArrayBuffer)return U("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var n=[];if(p&&0===n.length)return at(e,t,r,i);var s={startRoutine:r,pthread_ptr:e,arg:i,transferList:n};return p?(s.cmd="spawnThread",postMessage(s,n),0):ve(s)},dt=e=>(D[Zi()>>2]=e,e);function ut(e,t,r){if(p)return oi(3,1,e,t,r);He.varargs=r;try{var i=He.getStreamFromFD(e);switch(t){case 0:if((n=He.get())<0)return-28;for(;$e.streams[n];)n++;return $e.createStream(i,n).fd;case 1:case 2:case 6:case 7:return 0;case 3:return i.flags;case 4:var n=He.get();return i.flags|=n,0;case 5:return n=He.getp(),F[n+0>>1]=2,0;case 16:case 8:default:return-28;case 9:return dt(28),-1}}catch(e){if(void 0===$e||"ErrnoError"!==e.name)throw e;return-e.errno}}function ht(e,t,r,i){if(p)return oi(4,1,e,t,r,i);He.varargs=i;try{t=He.getStr(t),t=He.calculateAt(e,t);var n=i?He.get():0;return $e.open(t,r,n).fd}catch(e){if(void 0===$e||"ErrnoError"!==e.name)throw e;return-e.errno}}var ct,ft,pt,mt=(e,t,r,i,n)=>{},_t=()=>{for(var e=new Array(256),t=0;t<256;++t)e[t]=String.fromCharCode(t);ct=e},gt=e=>{for(var t="",r=e;B[r];)t+=ct[B[r++]];return t},yt={},vt={},bt={},wt=e=>{throw new ft(e)},Et=e=>{throw new pt(e)},St=(e,t,r)=>{function i(t){var i=r(t);i.length!==e.length&&Et("Mismatched type converter count");for(var n=0;n<e.length;++n)xt(e[n],i[n])}e.forEach((function(e){bt[e]=t}));var n=new Array(t.length),s=[],o=0;t.forEach(((e,t)=>{vt.hasOwnProperty(e)?n[t]=vt[e]:(s.push(e),yt.hasOwnProperty(e)||(yt[e]=[]),yt[e].push((()=>{n[t]=vt[e],++o===s.length&&i(n)})))})),0===s.length&&i(n)};function Ut(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var i=t.name;if(e||wt(`type "${i}" must have a positive integer typeid pointer`),vt.hasOwnProperty(e)){if(r.ignoreDuplicateRegistrations)return;wt(`Cannot register type '${i}' twice`)}if(vt[e]=t,delete bt[e],yt.hasOwnProperty(e)){var n=yt[e];delete yt[e],n.forEach((e=>e()))}}function xt(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");return Ut(e,t,r)}var kt,At=8,Tt=(e,t,r,i)=>{xt(e,{name:t=gt(t),fromWireType:function(e){return!!e},toWireType:function(e,t){return t?r:i},argPackAdvance:At,readValueFromPointer:function(e){return this.fromWireType(B[e])},destructorFunction:null})},Ct=e=>({count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}),Bt=e=>{wt(e.$$.ptrType.registeredClass.name+" instance already deleted")},Ft=!1,Pt=e=>{},Dt=e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)},It=e=>{e.count.value-=1,0===e.count.value&&Dt(e)},Lt=(e,t,r)=>{if(t===r)return e;if(void 0===r.baseClass)return null;var i=Lt(e,t,r.baseClass);return null===i?null:r.downcast(i)},Rt={},zt=()=>Object.keys(Ht).length,Mt=()=>{var e=[];for(var t in Ht)Ht.hasOwnProperty(t)&&e.push(Ht[t]);return e},Ot=[],Nt=()=>{for(;Ot.length;){var e=Ot.pop();e.$$.deleteScheduled=!1,e.delete()}},$t=e=>{kt=e,Ot.length&&kt&&kt(Nt)},Gt=()=>{n.getInheritedInstanceCount=zt,n.getLiveInheritedInstances=Mt,n.flushPendingDeletes=Nt,n.setDelayFunction=$t},Ht={},Vt=(e,t)=>{for(void 0===t&&wt("ptr should not be undefined");e.baseClass;)t=e.upcast(t),e=e.baseClass;return t},Wt=(e,t)=>(t=Vt(e,t),Ht[t]),jt=(e,t)=>(t.ptrType&&t.ptr||Et("makeClassHandle requires ptr and ptrType"),!!t.smartPtrType!=!!t.smartPtr&&Et("Both smartPtrType and smartPtr must be specified"),t.count={value:1},qt(Object.create(e,{$$:{value:t}})));function Yt(e){var t=this.getPointee(e);if(!t)return this.destructor(e),null;var r=Wt(this.registeredClass,t);if(void 0!==r){if(0===r.$$.count.value)return r.$$.ptr=t,r.$$.smartPtr=e,r.clone();var i=r.clone();return this.destructor(e),i}function n(){return this.isSmartPointer?jt(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:t,smartPtrType:this,smartPtr:e}):jt(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var s,o=this.registeredClass.getActualType(t),a=Rt[o];if(!a)return n.call(this);s=this.isConst?a.constPointerType:a.pointerType;var l=Lt(t,this.registeredClass,s.registeredClass);return null===l?n.call(this):this.isSmartPointer?jt(s.registeredClass.instancePrototype,{ptrType:s,ptr:l,smartPtrType:this,smartPtr:e}):jt(s.registeredClass.instancePrototype,{ptrType:s,ptr:l})}var qt=e=>"undefined"==typeof FinalizationRegistry?(qt=e=>e,e):(Ft=new FinalizationRegistry((e=>{It(e.$$)})),qt=e=>{var t=e.$$;if(t.smartPtr){var r={$$:t};Ft.register(e,r,e)}return e},Pt=e=>Ft.unregister(e),qt(e)),Kt=()=>{Object.assign(Xt.prototype,{isAliasOf(e){if(!(this instanceof Xt))return!1;if(!(e instanceof Xt))return!1;var t=this.$$.ptrType.registeredClass,r=this.$$.ptr;e.$$=e.$$;for(var i=e.$$.ptrType.registeredClass,n=e.$$.ptr;t.baseClass;)r=t.upcast(r),t=t.baseClass;for(;i.baseClass;)n=i.upcast(n),i=i.baseClass;return t===i&&r===n},clone(){if(this.$$.ptr||Bt(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=qt(Object.create(Object.getPrototypeOf(this),{$$:{value:Ct(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=!1,e},delete(){this.$$.ptr||Bt(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&wt("Object already scheduled for deletion"),Pt(this),It(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||Bt(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&wt("Object already scheduled for deletion"),Ot.push(this),1===Ot.length&&kt&&kt(Nt),this.$$.deleteScheduled=!0,this}})};function Xt(){}var Zt=48,Jt=57,Qt=e=>{if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return t>=Zt&&t<=Jt?`_${e}`:e};function er(e,t){return{[e=Qt(e)]:function(){return t.apply(this,arguments)}}[e]}var tr=(e,t,r)=>{if(void 0===e[t].overloadTable){var i=e[t];e[t]=function(){return e[t].overloadTable.hasOwnProperty(arguments.length)||wt(`Function '${r}' called with an invalid number of arguments (${arguments.length}) - expects one of (${e[t].overloadTable})!`),e[t].overloadTable[arguments.length].apply(this,arguments)},e[t].overloadTable=[],e[t].overloadTable[i.argCount]=i}},rr=(e,t,r)=>{n.hasOwnProperty(e)?((void 0===r||void 0!==n[e].overloadTable&&void 0!==n[e].overloadTable[r])&&wt(`Cannot register public name '${e}' twice`),tr(n,e,e),n.hasOwnProperty(r)&&wt(`Cannot register multiple overloads of a function with the same number of arguments (${r})!`),n[e].overloadTable[r]=t):(n[e]=t,void 0!==r&&(n[e].numArguments=r))};function ir(e,t,r,i,n,s,o,a){this.name=e,this.constructor=t,this.instancePrototype=r,this.rawDestructor=i,this.baseClass=n,this.getActualType=s,this.upcast=o,this.downcast=a,this.pureVirtualFunctions=[]}var nr=(e,t,r)=>{for(;t!==r;)t.upcast||wt(`Expected null or instance of ${r.name}, got an instance of ${t.name}`),e=t.upcast(e),t=t.baseClass;return e};function sr(e,t){if(null===t)return this.isReference&&wt(`null is not a valid ${this.name}`),0;t.$$||wt(`Cannot pass "${Rr(t)}" as a ${this.name}`),t.$$.ptr||wt(`Cannot pass deleted object as a pointer of type ${this.name}`);var r=t.$$.ptrType.registeredClass;return nr(t.$$.ptr,r,this.registeredClass)}function or(e,t){var r;if(null===t)return this.isReference&&wt(`null is not a valid ${this.name}`),this.isSmartPointer?(r=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,r),r):0;t.$$||wt(`Cannot pass "${Rr(t)}" as a ${this.name}`),t.$$.ptr||wt(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&t.$$.ptrType.isConst&&wt(`Cannot convert argument of type ${t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name} to parameter type ${this.name}`);var i=t.$$.ptrType.registeredClass;if(r=nr(t.$$.ptr,i,this.registeredClass),this.isSmartPointer)switch(void 0===t.$$.smartPtr&&wt("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:t.$$.smartPtrType===this?r=t.$$.smartPtr:wt(`Cannot convert argument of type ${t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:r=t.$$.smartPtr;break;case 2:if(t.$$.smartPtrType===this)r=t.$$.smartPtr;else{var n=t.clone();r=this.rawShare(r,Dr.toHandle((()=>n.delete()))),null!==e&&e.push(this.rawDestructor,r)}break;default:wt("Unsupporting sharing policy")}return r}function ar(e,t){if(null===t)return this.isReference&&wt(`null is not a valid ${this.name}`),0;t.$$||wt(`Cannot pass "${Rr(t)}" as a ${this.name}`),t.$$.ptr||wt(`Cannot pass deleted object as a pointer of type ${this.name}`),t.$$.ptrType.isConst&&wt(`Cannot convert argument of type ${t.$$.ptrType.name} to parameter type ${this.name}`);var r=t.$$.ptrType.registeredClass;return nr(t.$$.ptr,r,this.registeredClass)}function lr(e){return this.fromWireType(I[e>>2])}var dr=()=>{Object.assign(ur.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){this.rawDestructor&&this.rawDestructor(e)},argPackAdvance:At,readValueFromPointer:lr,deleteObject(e){null!==e&&e.delete()},fromWireType:Yt})};function ur(e,t,r,i,n,s,o,a,l,d,u){this.name=e,this.registeredClass=t,this.isReference=r,this.isConst=i,this.isSmartPointer=n,this.pointeeType=s,this.sharingPolicy=o,this.rawGetPointee=a,this.rawConstructor=l,this.rawShare=d,this.rawDestructor=u,n||void 0!==t.baseClass?this.toWireType=or:i?(this.toWireType=sr,this.destructorFunction=null):(this.toWireType=ar,this.destructorFunction=null)}var hr,cr=(e,t,r)=>{n.hasOwnProperty(e)||Et("Replacing nonexistant public symbol"),void 0!==n[e].overloadTable&&void 0!==r?n[e].overloadTable[r]=t:(n[e]=t,n[e].argCount=r)},fr=(e,t,r)=>{var i=n["dynCall_"+e];return r&&r.length?i.apply(null,[t].concat(r)):i.call(null,t)},pr=(e,t,r)=>e.includes("j")?fr(e,t,r):et(t).apply(null,r),mr=(e,t)=>{var r=[];return function(){return r.length=0,Object.assign(r,arguments),pr(e,t,r)}},_r=(e,t)=>{var r=(e=gt(e)).includes("j")?mr(e,t):et(t);return"function"!=typeof r&&wt(`unknown function pointer with signature ${e}: ${t}`),r},gr=(e,t)=>{var r=er(t,(function(e){this.name=t,this.message=e;var r=new Error(e).stack;void 0!==r&&(this.stack=this.toString()+"\n"+r.replace(/^Error(:[^\n]*)?\n/,""))}));return r.prototype=Object.create(e.prototype),r.prototype.constructor=r,r.prototype.toString=function(){return void 0===this.message?this.name:`${this.name}: ${this.message}`},r},yr=e=>{var t=Qi(e),r=gt(t);return Ki(t),r},vr=(e,t)=>{var r=[],i={};throw t.forEach((function e(t){i[t]||vt[t]||(bt[t]?bt[t].forEach(e):(r.push(t),i[t]=!0))})),new hr(`${e}: `+r.map(yr).join([", "]))},br=(e,t,r,i,n,s,o,a,l,d,u,h,c)=>{u=gt(u),s=_r(n,s),a&&(a=_r(o,a)),d&&(d=_r(l,d)),c=_r(h,c);var f=Qt(u);rr(f,(function(){vr(`Cannot construct ${u} due to unbound types`,[i])})),St([e,t,r],i?[i]:[],(function(t){var r,n;t=t[0],n=i?(r=t.registeredClass).instancePrototype:Xt.prototype;var o=er(f,(function(){if(Object.getPrototypeOf(this)!==l)throw new ft("Use 'new' to construct "+u);if(void 0===h.constructor_body)throw new ft(u+" has no accessible constructor");var e=h.constructor_body[arguments.length];if(void 0===e)throw new ft(`Tried to invoke ctor of ${u} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(h.constructor_body).toString()}) parameters instead!`);return e.apply(this,arguments)})),l=Object.create(n,{constructor:{value:o}});o.prototype=l;var h=new ir(u,o,l,c,r,s,a,d);h.baseClass&&(void 0===h.baseClass.__derivedClasses&&(h.baseClass.__derivedClasses=[]),h.baseClass.__derivedClasses.push(h));var p=new ur(u,h,!0,!1,!1),m=new ur(u+"*",h,!1,!1,!1),_=new ur(u+" const*",h,!1,!0,!1);return Rt[e]={pointerType:m,constPointerType:_},cr(f,o),[p,m,_]}))},wr=(e,t)=>{for(var r=[],i=0;i<e;i++)r.push(I[t+4*i>>2]);return r},Er=e=>{for(;e.length;){var t=e.pop();e.pop()(t)}};function Sr(e,t){if(!(e instanceof Function))throw new TypeError(`new_ called with constructor type ${typeof e} which is not a function`);var r=er(e.name||"unknownFunctionName",(function(){}));r.prototype=e.prototype;var i=new r,n=e.apply(i,t);return n instanceof Object?n:i}function Ur(e,t,r,i,n,s){var o=t.length;o<2&&wt("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var a=null!==t[1]&&null!==r,l=!1,d=1;d<t.length;++d)if(null!==t[d]&&void 0===t[d].destructorFunction){l=!0;break}var u="void"!==t[0].name,h="",c="";for(d=0;d<o-2;++d)h+=(0!==d?", ":"")+"arg"+d,c+=(0!==d?", ":"")+"arg"+d+"Wired";var f=`\n return function ${Qt(e)}(${h}) {\n if (arguments.length !== ${o-2}) {\n throwBindingError('function ${e} called with ' + arguments.length + ' arguments, expected ${o-2}');\n }`;l&&(f+="var destructors = [];\n");var p=l?"destructors":"null",m=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],_=[wt,i,n,Er,t[0],t[1]];for(a&&(f+="var thisWired = classParam.toWireType("+p+", this);\n"),d=0;d<o-2;++d)f+="var arg"+d+"Wired = argType"+d+".toWireType("+p+", arg"+d+"); // "+t[d+2].name+"\n",m.push("argType"+d),_.push(t[d+2]);if(a&&(c="thisWired"+(c.length>0?", ":"")+c),f+=(u||s?"var rv = ":"")+"invoker(fn"+(c.length>0?", ":"")+c+");\n",l)f+="runDestructors(destructors);\n";else for(d=a?1:2;d<t.length;++d){var g=1===d?"thisWired":"arg"+(d-2)+"Wired";null!==t[d].destructorFunction&&(f+=g+"_dtor("+g+"); // "+t[d].name+"\n",m.push(g+"_dtor"),_.push(t[d].destructorFunction))}return u&&(f+="var ret = retType.fromWireType(rv);\nreturn ret;\n"),f+="}\n",m.push(f),Sr(Function,m).apply(null,_)}var xr=(e,t,r,i,n,s)=>{var o=wr(t,r);n=_r(i,n),St([],[e],(function(e){var r=`constructor ${(e=e[0]).name}`;if(void 0===e.registeredClass.constructor_body&&(e.registeredClass.constructor_body=[]),void 0!==e.registeredClass.constructor_body[t-1])throw new ft(`Cannot register multiple constructors with identical number of parameters (${t-1}) for class '${e.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return e.registeredClass.constructor_body[t-1]=()=>{vr(`Cannot construct ${e.name} due to unbound types`,o)},St([],o,(i=>(i.splice(1,0,null),e.registeredClass.constructor_body[t-1]=Ur(r,i,null,n,s),[]))),[]}))},kr=(e,t,r,i,n,s,o,a,l)=>{var d=wr(r,i);t=gt(t),s=_r(n,s),St([],[e],(function(e){var i=`${(e=e[0]).name}.${t}`;function n(){vr(`Cannot call ${i} due to unbound types`,d)}t.startsWith("@@")&&(t=Symbol[t.substring(2)]),a&&e.registeredClass.pureVirtualFunctions.push(t);var u=e.registeredClass.instancePrototype,h=u[t];return void 0===h||void 0===h.overloadTable&&h.className!==e.name&&h.argCount===r-2?(n.argCount=r-2,n.className=e.name,u[t]=n):(tr(u,t,i),u[t].overloadTable[r-2]=n),St([],d,(function(n){var a=Ur(i,n,e,s,o,l);return void 0===u[t].overloadTable?(a.argCount=r-2,u[t]=a):u[t].overloadTable[r-2]=a,[]})),[]}))};function Ar(){Object.assign(Tr.prototype,{get(e){return this.allocated[e]},has(e){return void 0!==this.allocated[e]},allocate(e){var t=this.freelist.pop()||this.allocated.length;return this.allocated[t]=e,t},free(e){this.allocated[e]=void 0,this.freelist.push(e)}})}function Tr(){this.allocated=[void 0],this.freelist=[]}var Cr=new Tr,Br=e=>{e>=Cr.reserved&&0==--Cr.get(e).refcount&&Cr.free(e)},Fr=()=>{for(var e=0,t=Cr.reserved;t<Cr.allocated.length;++t)void 0!==Cr.allocated[t]&&++e;return e},Pr=()=>{Cr.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),Cr.reserved=Cr.allocated.length,n.count_emval_handles=Fr},Dr={toValue:e=>(e||wt("Cannot use deleted val. handle = "+e),Cr.get(e).value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return Cr.allocate({refcount:1,value:e})}}};function Ir(e){return this.fromWireType(D[e>>2])}var Lr=(e,t)=>{xt(e,{name:t=gt(t),fromWireType:e=>{var t=Dr.toValue(e);return Br(e),t},toWireType:(e,t)=>Dr.toHandle(t),argPackAdvance:At,readValueFromPointer:Ir,destructorFunction:null})},Rr=e=>{if(null===e)return"null";var t=typeof e;return"object"===t||"array"===t||"function"===t?e.toString():""+e},zr=(e,t)=>{switch(t){case 4:return function(e){return this.fromWireType(L[e>>2])};case 8:return function(e){return this.fromWireType(R[e>>3])};default:throw new TypeError(`invalid float width (${t}): ${e}`)}},Mr=(e,t,r)=>{xt(e,{name:t=gt(t),fromWireType:e=>e,toWireType:(e,t)=>t,argPackAdvance:At,readValueFromPointer:zr(t,r),destructorFunction:null})},Or=(e,t,r)=>{switch(t){case 1:return r?e=>C[e>>0]:e=>B[e>>0];case 2:return r?e=>F[e>>1]:e=>P[e>>1];case 4:return r?e=>D[e>>2]:e=>I[e>>2];default:throw new TypeError(`invalid integer width (${t}): ${e}`)}},Nr=(e,t,r,i,n)=>{t=gt(t);var s=e=>e;if(0===i){var o=32-8*r;s=e=>e<<o>>>o}var a=t.includes("unsigned");xt(e,{name:t,fromWireType:s,toWireType:a?function(e,t){return this.name,t>>>0}:function(e,t){return this.name,t},argPackAdvance:At,readValueFromPointer:Or(t,r,0!==i),destructorFunction:null})},$r=(e,t,r)=>{var i=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];function n(e){var t=I[e>>2],r=I[e+4>>2];return new i(C.buffer,r,t)}xt(e,{name:r=gt(r),fromWireType:n,argPackAdvance:At,readValueFromPointer:n},{ignoreDuplicateRegistrations:!0})},Gr=(e,t,r)=>Te(e,B,t,r),Hr=(e,t)=>{var r="std::string"===(t=gt(t));xt(e,{name:t,fromWireType(e){var t,i=I[e>>2],n=e+4;if(r)for(var s=n,o=0;o<=i;++o){var a=n+o;if(o==i||0==B[a]){var l=Ge(s,a-s);void 0===t?t=l:(t+=String.fromCharCode(0),t+=l),s=a+1}}else{var d=new Array(i);for(o=0;o<i;++o)d[o]=String.fromCharCode(B[n+o]);t=d.join("")}return Ki(e),t},toWireType(e,t){var i;t instanceof ArrayBuffer&&(t=new Uint8Array(t));var n="string"==typeof t;n||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||wt("Cannot pass non-string to std::string"),i=r&&n?Ae(t):t.length;var s=Xi(4+i+1),o=s+4;if(I[s>>2]=i,r&&n)Gr(t,o,i+1);else if(n)for(var a=0;a<i;++a){var l=t.charCodeAt(a);l>255&&(Ki(o),wt("String has UTF-16 code units that do not fit in 8 bits")),B[o+a]=l}else for(a=0;a<i;++a)B[o+a]=t[a];return null!==e&&e.push(Ki,s),s},argPackAdvance:At,readValueFromPointer:lr,destructorFunction(e){Ki(e)}})},Vr="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,Wr=(e,t)=>{for(var r=e,i=r>>1,n=i+t/2;!(i>=n)&&P[i];)++i;if((r=i<<1)-e>32&&Vr)return Vr.decode(B.slice(e,r));for(var s="",o=0;!(o>=t/2);++o){var a=F[e+2*o>>1];if(0==a)break;s+=String.fromCharCode(a)}return s},jr=(e,t,r)=>{if(void 0===r&&(r=2147483647),r<2)return 0;for(var i=t,n=(r-=2)<2*e.length?r/2:e.length,s=0;s<n;++s){var o=e.charCodeAt(s);F[t>>1]=o,t+=2}return F[t>>1]=0,t-i},Yr=e=>2*e.length,qr=(e,t)=>{for(var r=0,i="";!(r>=t/4);){var n=D[e+4*r>>2];if(0==n)break;if(++r,n>=65536){var s=n-65536;i+=String.fromCharCode(55296|s>>10,56320|1023&s)}else i+=String.fromCharCode(n)}return i},Kr=(e,t,r)=>{if(void 0===r&&(r=2147483647),r<4)return 0;for(var i=t,n=i+r-4,s=0;s<e.length;++s){var o=e.charCodeAt(s);if(o>=55296&&o<=57343&&(o=65536+((1023&o)<<10)|1023&e.charCodeAt(++s)),D[t>>2]=o,(t+=4)+4>n)break}return D[t>>2]=0,t-i},Xr=e=>{for(var t=0,r=0;r<e.length;++r){var i=e.charCodeAt(r);i>=55296&&i<=57343&&++r,t+=4}return t},Zr=(e,t,r)=>{var i,n,s,o,a;r=gt(r),2===t?(i=Wr,n=jr,o=Yr,s=()=>P,a=1):4===t&&(i=qr,n=Kr,o=Xr,s=()=>I,a=2),xt(e,{name:r,fromWireType:e=>{for(var r,n=I[e>>2],o=s(),l=e+4,d=0;d<=n;++d){var u=e+4+d*t;if(d==n||0==o[u>>a]){var h=i(l,u-l);void 0===r?r=h:(r+=String.fromCharCode(0),r+=h),l=u+t}}return Ki(e),r},toWireType:(e,i)=>{"string"!=typeof i&&wt(`Cannot pass non-string to C++ string type ${r}`);var s=o(i),l=Xi(4+s+t);return I[l>>2]=s>>a,n(i,l+4,s+t),null!==e&&e.push(Ki,l),l},argPackAdvance:At,readValueFromPointer:Ir,destructorFunction(e){Ki(e)}})},Jr=(e,t)=>{xt(e,{isVoid:!0,name:t=gt(t),argPackAdvance:0,fromWireType:()=>{},toWireType:(e,t)=>{}})},Qr=()=>{if(!W())try{p?sn(T):je(T)}catch(e){Ye(e)}},ei=e=>{if(!z)try{e(),Qr()}catch(e){Ye(e)}},ti=e=>{if("function"==typeof Atomics.waitAsync){Atomics.waitAsync(D,e>>2,e).value.then(ri);var t=e+128;Atomics.store(D,t>>2,1)}};n.__emscripten_thread_mailbox_await=ti;var ri=()=>{var e=Ji();e&&(ti(e),ei((()=>on())))};n.checkMailbox=ri;var ii,ni=(e,t,r)=>{if(e==t)setTimeout((()=>ri()));else if(p)postMessage({targetThread:e,cmd:"checkMailbox"});else{var i=qe.pthreads[e];if(!i)return;i.postMessage({cmd:"checkMailbox"})}},si=e=>{var t=ln(),r=e();return dn(t),r},oi=function(e,t){var r=arguments.length-2,i=arguments;return si((()=>{for(var n=r,s=un(8*n),o=s>>3,a=0;a<r;a++){var l=i[2+a];R[o+a]=l}return rn(e,n,s,t)}))},ai=[],li=(e,t,r,i)=>{ai.length=r;for(var n=i>>3,s=0;s<r;s++)ai[s]=R[n+s];var o=ji[e];qe.currentProxiedOperationCallerThread=t;var a=o.apply(null,ai);return qe.currentProxiedOperationCallerThread=0,a},di=e=>{f&&qe.pthreads[e].ref()},ui={},hi=e=>{var t=ui[e];return void 0===t?gt(e):t},ci=[],fi=(e,t,r,i)=>{(e=ci[e])(t=Dr.toValue(t),r=hi(r),null,i)},pi=e=>{var t=ci.length;return ci.push(e),t},mi=(e,t)=>{var r=vt[e];return void 0===r&&wt(t+" has unknown type "+yr(e)),r},_i=(e,t)=>{for(var r=new Array(e),i=0;i<e;++i)r[i]=mi(I[t+4*i>>2],"parameter "+i);return r},gi={},yi=(e,t)=>{var r=_i(e,t),i=r[0],n=i.name+"_$"+r.slice(1).map((function(e){return e.name})).join("_")+"$",s=gi[n];if(void 0!==s)return s;for(var o=["retType"],a=[i],l="",d=0;d<e-1;++d)l+=(0!==d?", ":"")+"arg"+d,o.push("argType"+d),a.push(r[1+d]);var u="return function "+Qt("methodCaller_"+n)+"(handle, name, destructors, args) {\n",h=0;for(d=0;d<e-1;++d)u+=" var arg"+d+" = argType"+d+".readValueFromPointer(args"+(h?"+"+h:"")+");\n",h+=r[d+1].argPackAdvance;for(u+=" var rv = handle[name]("+l+");\n",d=0;d<e-1;++d)r[d+1].deleteObject&&(u+=" argType"+d+".deleteObject(arg"+d+");\n");i.isVoid||(u+=" return retType.toWireType(destructors, rv);\n"),u+="};\n",o.push(u);var c=Sr(Function,o).apply(null,a);return s=pi(c),gi[n]=s,s},vi=()=>{re("")},bi=()=>{},wi=()=>Date.now(),Ei=()=>{V+=1},Si=()=>{throw Ei(),"unwind"},Ui=()=>B.length,xi=()=>Ui();ii=()=>performance.timeOrigin+performance.now();var ki=()=>f?g("os").cpus().length:navigator.hardwareConcurrency,Ai=e=>{re("OOM")},Ti=e=>{B.length,Ai()},Ci={},Bi=()=>d||"./this.program",Fi=()=>{if(!Fi.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:Bi()};for(var t in Ci)void 0===Ci[t]?delete e[t]:e[t]=Ci[t];var r=[];for(var t in e)r.push(`${t}=${e[t]}`);Fi.strings=r}return Fi.strings},Pi=(e,t)=>{for(var r=0;r<e.length;++r)C[t++>>0]=e.charCodeAt(r);C[t>>0]=0},Di=function(e,t){if(p)return oi(5,1,e,t);var r=0;return Fi().forEach(((i,n)=>{var s=t+r;I[e+4*n>>2]=s,Pi(i,s),r+=i.length+1})),0},Ii=function(e,t){if(p)return oi(6,1,e,t);var r=Fi();I[e>>2]=r.length;var i=0;return r.forEach((e=>i+=e.length+1)),I[t>>2]=i,0};function Li(e){if(p)return oi(7,1,e);try{var t=He.getStreamFromFD(e);return $e.close(t),0}catch(e){if(void 0===$e||"ErrnoError"!==e.name)throw e;return e.errno}}function Ri(e,t){if(p)return oi(8,1,e,t);try{var r=He.getStreamFromFD(e),i=r.tty?2:$e.isDir(r.mode)?3:$e.isLink(r.mode)?7:4;return C[t>>0]=i,F[t+2>>1]=0,se=[0,(ne=0,+Math.abs(ne)>=1?ne>0?+Math.floor(ne/4294967296)>>>0:~~+Math.ceil((ne-+(~~ne>>>0))/4294967296)>>>0:0)],D[t+8>>2]=se[0],D[t+12>>2]=se[1],se=[0,(ne=0,+Math.abs(ne)>=1?ne>0?+Math.floor(ne/4294967296)>>>0:~~+Math.ceil((ne-+(~~ne>>>0))/4294967296)>>>0:0)],D[t+16>>2]=se[0],D[t+20>>2]=se[1],0}catch(e){if(void 0===$e||"ErrnoError"!==e.name)throw e;return e.errno}}var zi=(e,t,r,i)=>{for(var n=0,s=0;s<r;s++){var o=I[t>>2],a=I[t+4>>2];t+=8;var l=$e.read(e,C,o,a,i);if(l<0)return-1;if(n+=l,l<a)break;void 0!==i&&(i+=l)}return n};function Mi(e,t,r,i){if(p)return oi(9,1,e,t,r,i);try{var n=He.getStreamFromFD(e),s=zi(n,t,r);return I[i>>2]=s,0}catch(e){if(void 0===$e||"ErrnoError"!==e.name)throw e;return e.errno}}var Oi=(e,t)=>t+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*t:NaN;function Ni(e,t,r,i,n){if(p)return oi(10,1,e,t,r,i,n);var s=Oi(t,r);try{if(isNaN(s))return 61;var o=He.getStreamFromFD(e);return $e.llseek(o,s,i),se=[o.position>>>0,(ne=o.position,+Math.abs(ne)>=1?ne>0?+Math.floor(ne/4294967296)>>>0:~~+Math.ceil((ne-+(~~ne>>>0))/4294967296)>>>0:0)],D[n>>2]=se[0],D[n+4>>2]=se[1],o.getdents&&0===s&&0===i&&(o.getdents=null),0}catch(e){if(void 0===$e||"ErrnoError"!==e.name)throw e;return e.errno}}var $i=(e,t,r,i)=>{for(var n=0,s=0;s<r;s++){var o=I[t>>2],a=I[t+4>>2];t+=8;var l=$e.write(e,C,o,a,i);if(l<0)return-1;n+=l,void 0!==i&&(i+=l)}return n};function Gi(e,t,r,i){if(p)return oi(11,1,e,t,r,i);try{var n=He.getStreamFromFD(e),s=$i(n,t,r);return I[i>>2]=s,0}catch(e){if(void 0===$e||"ErrnoError"!==e.name)throw e;return e.errno}}qe.init();var Hi=function(e,t,r,i){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=$e.nextInode++,this.name=t,this.mode=r,this.node_ops={},this.stream_ops={},this.rdev=i},Vi=365,Wi=146;Object.defineProperties(Hi.prototype,{read:{get:function(){return(this.mode&Vi)===Vi},set:function(e){e?this.mode|=Vi:this.mode&=~Vi}},write:{get:function(){return(this.mode&Wi)===Wi},set:function(e){e?this.mode|=Wi:this.mode&=~Wi}},isFolder:{get:function(){return $e.isDir(this.mode)}},isDevice:{get:function(){return $e.isChrdev(this.mode)}}}),$e.FSNode=Hi,$e.createPreloadedFile=Me,$e.staticInit(),_t(),ft=n.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},pt=n.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}},Kt(),Gt(),dr(),hr=n.UnboundTypeError=gr(Error,"UnboundTypeError"),Ar(),Pr();var ji=[Ve,Ze,at,ut,ht,Di,Ii,Li,Ri,Mi,Ni,Gi],Yi={t:nt,H:st,l:ot,C:lt,O:ut,F:ht,w:mt,r:Tt,E:br,v:xr,f:kr,P:Lr,q:Mr,d:Nr,c:$r,p:Hr,i:Zr,s:Jr,y:ni,D:li,G:ti,M:di,h:fi,k:Br,j:yi,b:vi,m:bi,g:wi,L:Si,z:xi,e:ii,A:ki,x:Ti,J:Di,K:Ii,B:je,o:Li,I:Ri,N:Mi,u:Ni,n:Gi,a:x||n.wasmMemory},qi=fe(),Ki=e=>(Ki=qi.R)(e),Xi=e=>(Xi=qi.S)(e),Zi=()=>(Zi=qi.U)();n.__emscripten_tls_init=()=>(n.__emscripten_tls_init=qi.V)();var Ji=n._pthread_self=()=>(Ji=n._pthread_self=qi.W)(),Qi=e=>(Qi=qi.X)(e);n.__embind_initialize_bindings=()=>(n.__embind_initialize_bindings=qi.Y)();var en=n.__emscripten_thread_init=(e,t,r,i,s,o)=>(en=n.__emscripten_thread_init=qi.Z)(e,t,r,i,s,o);n.__emscripten_thread_crashed=()=>(n.__emscripten_thread_crashed=qi._)();var tn,rn=(e,t,r,i)=>(rn=qi.$)(e,t,r,i),nn=e=>(nn=qi.aa)(e),sn=n.__emscripten_thread_exit=e=>(sn=n.__emscripten_thread_exit=qi.ba)(e),on=n.__emscripten_check_mailbox=()=>(on=n.__emscripten_check_mailbox=qi.ca)(),an=(e,t)=>(an=qi.da)(e,t),ln=()=>(ln=qi.ea)(),dn=e=>(dn=qi.fa)(e),un=e=>(un=qi.ga)(e),hn=e=>(hn=qi.ha)(e);function cn(){if(!(J>0)){if(p)return r(n),Y(),void startWorker(n);j(),J>0||(n.setStatus?(n.setStatus("Running..."),setTimeout((function(){setTimeout((function(){n.setStatus("")}),1),e()}),1)):e())}function e(){tn||(tn=!0,n.calledRun=!0,z||(Y(),r(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),q()))}}if(n.dynCall_jiji=(e,t,r,i,s)=>(n.dynCall_jiji=qi.ia)(e,t,r,i,s),n._ff_h264_cabac_tables=111845,n.keepRuntimeAlive=W,n.wasmMemory=x,n.ExitStatus=pe,n.PThread=qe,Q=function e(){tn||cn(),tn||(Q=e)},n.preInit)for("function"==typeof n.preInit&&(n.preInit=[n.preInit]);n.preInit.length>0;)n.preInit.pop()();return cn(),t.ready}),r=(()=>{var e="undefined"==typeof document&&"undefined"==typeof location?new(require("url").URL)("file:"+__filename).href:"undefined"==typeof document?location.href:document.currentScript&&document.currentScript.src||new URL("decoder-pro-mt.js",document.baseURI).href;return async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var r,i,n;(n=t).ready=new Promise(((e,t)=>{r=e,i=t})),(n=void 0!==n?n:{}).locateFile=function(e){return"decoder-pro-audio.wasm"==e&&"undefined"!=typeof JESSIBUCA_PRO_AUDIO_WASM_URL&&""!=JESSIBUCA_PRO_AUDIO_WASM_URL?JESSIBUCA_PRO_AUDIO_WASM_URL:e};var s,o,a,l=Object.assign({},n),d="./this.program",u="object"==typeof window,h="function"==typeof importScripts,c="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,f="";function p(e){return n.locateFile?n.locateFile(e,f):f+e}if(c){const{createRequire:e}=await import("module");var m=e("undefined"==typeof document&&"undefined"==typeof location?new(require("url").URL)("file:"+__filename).href:"undefined"==typeof document?location.href:document.currentScript&&document.currentScript.src||new URL("decoder-pro-mt.js",document.baseURI).href),_=m("fs"),g=m("path");f=h?g.dirname(f)+"/":m("url").fileURLToPath(new URL("./","undefined"==typeof document&&"undefined"==typeof location?new(require("url").URL)("file:"+__filename).href:"undefined"==typeof document?location.href:document.currentScript&&document.currentScript.src||new URL("decoder-pro-mt.js",document.baseURI).href)),s=(e,t)=>(e=J(e)?new URL(e):g.normalize(e),_.readFileSync(e,t?void 0:"utf8")),a=e=>{var t=s(e,!0);return t.buffer||(t=new Uint8Array(t)),t},o=function(e,t,r){let i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];e=J(e)?new URL(e):g.normalize(e),_.readFile(e,i?void 0:"utf8",((e,n)=>{e?r(e):t(i?n.buffer:n)}))},!n.thisProgram&&process.argv.length>1&&(d=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),n.inspect=()=>"[Emscripten Module object]"}else(u||h)&&(h?f=self.location.href:"undefined"!=typeof document&&document.currentScript&&(f=document.currentScript.src),e&&(f=e),f=0!==f.indexOf("blob:")?f.substr(0,f.replace(/[?#].*/,"").lastIndexOf("/")+1):"",s=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},h&&(a=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),o=(e,t,r)=>{var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=()=>{200==i.status||0==i.status&&i.response?t(i.response):r()},i.onerror=r,i.send(null)});var y,v,b=n.print||console.log.bind(console),w=n.printErr||console.error.bind(console);Object.assign(n,l),l=null,n.arguments&&n.arguments,n.thisProgram&&(d=n.thisProgram),n.quit&&n.quit,n.wasmBinary&&(y=n.wasmBinary),n.noExitRuntime,"object"!=typeof WebAssembly&&j("no native wasm support detected");var E,S,U,x,k,A,T,C,B=!1;function F(e,t){e||j(t)}function P(){var e=v.buffer;n.HEAP8=E=new Int8Array(e),n.HEAP16=U=new Int16Array(e),n.HEAPU8=S=new Uint8Array(e),n.HEAPU16=x=new Uint16Array(e),n.HEAP32=k=new Int32Array(e),n.HEAPU32=A=new Uint32Array(e),n.HEAPF32=T=new Float32Array(e),n.HEAPF64=C=new Float64Array(e)}var D=[],I=[],L=[];function R(){if(n.preRun)for("function"==typeof n.preRun&&(n.preRun=[n.preRun]);n.preRun.length;)O(n.preRun.shift());ne(D)}function z(){n.noFSInit||Ce.init.initialized||Ce.init(),Ce.ignorePermissions=!1,ne(I)}function M(){if(n.postRun)for("function"==typeof n.postRun&&(n.postRun=[n.postRun]);n.postRun.length;)$(n.postRun.shift());ne(L)}function O(e){D.unshift(e)}function N(e){I.unshift(e)}function $(e){L.unshift(e)}var G=0,H=null;function V(e){G++,n.monitorRunDependencies&&n.monitorRunDependencies(G)}function W(e){if(G--,n.monitorRunDependencies&&n.monitorRunDependencies(G),0==G&&H){var t=H;H=null,t()}}function j(e){n.onAbort&&n.onAbort(e),w(e="Aborted("+e+")"),B=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw i(t),t}var Y,q,K,X="data:application/octet-stream;base64,";function Z(e){return e.startsWith(X)}function J(e){return e.startsWith("file://")}function Q(e){if(e==Y&&y)return new Uint8Array(y);if(a)return a(e);throw"both async and sync fetching of the wasm failed"}function ee(e){if(!y&&(u||h)){if("function"==typeof fetch&&!J(e))return fetch(e,{credentials:"same-origin"}).then((t=>{if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()})).catch((()=>Q(e)));if(o)return new Promise(((t,r)=>{o(e,(e=>t(new Uint8Array(e))),r)}))}return Promise.resolve().then((()=>Q(e)))}function te(e,t,r){return ee(e).then((e=>WebAssembly.instantiate(e,t))).then((e=>e)).then(r,(e=>{w(`failed to asynchronously prepare wasm: ${e}`),j(e)}))}function re(e,t,r,i){return e||"function"!=typeof WebAssembly.instantiateStreaming||Z(t)||J(t)||c||"function"!=typeof fetch?te(t,r,i):fetch(t,{credentials:"same-origin"}).then((e=>WebAssembly.instantiateStreaming(e,r).then(i,(function(e){return w(`wasm streaming compile failed: ${e}`),w("falling back to ArrayBuffer instantiation"),te(t,r,i)}))))}function ie(){var e={a:ti};function t(e,t){return ri=e.exports,v=ri.D,P(),Dt=ri.G,N(ri.E),W(),ri}if(V(),n.instantiateWasm)try{return n.instantiateWasm(e,t)}catch(e){w(`Module.instantiateWasm callback failed with error: ${e}`),i(e)}return re(y,Y,e,(function(e){t(e.instance)})).catch(i),{}}n.locateFile?Z(Y="decoder-pro-audio.wasm")||(Y=p(Y)):Y=new URL("decoder-pro-audio.wasm","undefined"==typeof document&&"undefined"==typeof location?new(require("url").URL)("file:"+__filename).href:"undefined"==typeof document?location.href:document.currentScript&&document.currentScript.src||new URL("decoder-pro-mt.js",document.baseURI).href).href;var ne=e=>{for(;e.length>0;)e.shift()(n)};function se(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(e){A[this.ptr+4>>2]=e},this.get_type=function(){return A[this.ptr+4>>2]},this.set_destructor=function(e){A[this.ptr+8>>2]=e},this.get_destructor=function(){return A[this.ptr+8>>2]},this.set_caught=function(e){e=e?1:0,E[this.ptr+12>>0]=e},this.get_caught=function(){return 0!=E[this.ptr+12>>0]},this.set_rethrown=function(e){e=e?1:0,E[this.ptr+13>>0]=e},this.get_rethrown=function(){return 0!=E[this.ptr+13>>0]},this.init=function(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t)},this.set_adjusted_ptr=function(e){A[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return A[this.ptr+16>>2]},this.get_exception_ptr=function(){if(li(this.get_type()))return A[this.excPtr>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}var oe=(e,t,r)=>{throw new se(e).init(t,r),e},ae=e=>(k[ni()>>2]=e,e),le={isAbs:e=>"/"===e.charAt(0),splitPath:e=>/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1),normalizeArray:(e,t)=>{for(var r=0,i=e.length-1;i>=0;i--){var n=e[i];"."===n?e.splice(i,1):".."===n?(e.splice(i,1),r++):r&&(e.splice(i,1),r--)}if(t)for(;r;r--)e.unshift("..");return e},normalize:e=>{var t=le.isAbs(e),r="/"===e.substr(-1);return(e=le.normalizeArray(e.split("/").filter((e=>!!e)),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e},dirname:e=>{var t=le.splitPath(e),r=t[0],i=t[1];return r||i?(i&&(i=i.substr(0,i.length-1)),r+i):"."},basename:e=>{if("/"===e)return"/";var t=(e=(e=le.normalize(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===t?e:e.substr(t+1)},join:function(){var e=Array.prototype.slice.call(arguments);return le.normalize(e.join("/"))},join2:(e,t)=>le.normalize(e+"/"+t)},de=()=>{if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues)return e=>crypto.getRandomValues(e);if(c)try{var e=m("crypto");if(e.randomFillSync)return t=>e.randomFillSync(t);var t=e.randomBytes;return e=>(e.set(t(e.byteLength)),e)}catch(e){}j("initRandomDevice")},ue=e=>(ue=de())(e),he={resolve:function(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var i=r>=0?arguments[r]:Ce.cwd();if("string"!=typeof i)throw new TypeError("Arguments to path.resolve must be strings");if(!i)return"";e=i+"/"+e,t=le.isAbs(i)}return(t?"/":"")+(e=le.normalizeArray(e.split("/").filter((e=>!!e)),!t).join("/"))||"."},relative:(e,t)=>{function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var r=e.length-1;r>=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=he.resolve(e).substr(1),t=he.resolve(t).substr(1);for(var i=r(e.split("/")),n=r(t.split("/")),s=Math.min(i.length,n.length),o=s,a=0;a<s;a++)if(i[a]!==n[a]){o=a;break}var l=[];for(a=o;a<i.length;a++)l.push("..");return(l=l.concat(n.slice(o))).join("/")}},ce="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,fe=(e,t,r)=>{for(var i=t+r,n=t;e[n]&&!(n>=i);)++n;if(n-t>16&&e.buffer&&ce)return ce.decode(e.subarray(t,n));for(var s="";t<n;){var o=e[t++];if(128&o){var a=63&e[t++];if(192!=(224&o)){var l=63&e[t++];if((o=224==(240&o)?(15&o)<<12|a<<6|l:(7&o)<<18|a<<12|l<<6|63&e[t++])<65536)s+=String.fromCharCode(o);else{var d=o-65536;s+=String.fromCharCode(55296|d>>10,56320|1023&d)}}else s+=String.fromCharCode((31&o)<<6|a)}else s+=String.fromCharCode(o)}return s},pe=[],me=e=>{for(var t=0,r=0;r<e.length;++r){var i=e.charCodeAt(r);i<=127?t++:i<=2047?t+=2:i>=55296&&i<=57343?(t+=4,++r):t+=3}return t},_e=(e,t,r,i)=>{if(!(i>0))return 0;for(var n=r,s=r+i-1,o=0;o<e.length;++o){var a=e.charCodeAt(o);if(a>=55296&&a<=57343)a=65536+((1023&a)<<10)|1023&e.charCodeAt(++o);if(a<=127){if(r>=s)break;t[r++]=a}else if(a<=2047){if(r+1>=s)break;t[r++]=192|a>>6,t[r++]=128|63&a}else if(a<=65535){if(r+2>=s)break;t[r++]=224|a>>12,t[r++]=128|a>>6&63,t[r++]=128|63&a}else{if(r+3>=s)break;t[r++]=240|a>>18,t[r++]=128|a>>12&63,t[r++]=128|a>>6&63,t[r++]=128|63&a}}return t[r]=0,r-n};function ge(e,t,r){var i=r>0?r:me(e)+1,n=new Array(i),s=_e(e,n,0,n.length);return t&&(n.length=s),n}var ye=()=>{if(!pe.length){var e=null;if(c){var t=Buffer.alloc(256),r=0,i=process.stdin.fd;try{r=_.readSync(i,t)}catch(e){if(!e.toString().includes("EOF"))throw e;r=0}e=r>0?t.slice(0,r).toString("utf-8"):null}else"undefined"!=typeof window&&"function"==typeof window.prompt?null!==(e=window.prompt("Input: "))&&(e+="\n"):"function"==typeof readline&&null!==(e=readline())&&(e+="\n");if(!e)return null;pe=ge(e,!0)}return pe.shift()},ve={ttys:[],init(){},shutdown(){},register(e,t){ve.ttys[e]={input:[],output:[],ops:t},Ce.registerDevice(e,ve.stream_ops)},stream_ops:{open(e){var t=ve.ttys[e.node.rdev];if(!t)throw new Ce.ErrnoError(43);e.tty=t,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,t,r,i,n){if(!e.tty||!e.tty.ops.get_char)throw new Ce.ErrnoError(60);for(var s=0,o=0;o<i;o++){var a;try{a=e.tty.ops.get_char(e.tty)}catch(e){throw new Ce.ErrnoError(29)}if(void 0===a&&0===s)throw new Ce.ErrnoError(6);if(null==a)break;s++,t[r+o]=a}return s&&(e.node.timestamp=Date.now()),s},write(e,t,r,i,n){if(!e.tty||!e.tty.ops.put_char)throw new Ce.ErrnoError(60);try{for(var s=0;s<i;s++)e.tty.ops.put_char(e.tty,t[r+s])}catch(e){throw new Ce.ErrnoError(29)}return i&&(e.node.timestamp=Date.now()),s}},default_tty_ops:{get_char:e=>ye(),put_char(e,t){null===t||10===t?(b(fe(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync(e){e.output&&e.output.length>0&&(b(fe(e.output,0)),e.output=[])},ioctl_tcgets:e=>({c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}),ioctl_tcsets:(e,t,r)=>0,ioctl_tiocgwinsz:e=>[24,80]},default_tty1_ops:{put_char(e,t){null===t||10===t?(w(fe(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync(e){e.output&&e.output.length>0&&(w(fe(e.output,0)),e.output=[])}}},be=e=>{j()},we={ops_table:null,mount:e=>we.createNode(null,"/",16895,0),createNode(e,t,r,i){if(Ce.isBlkdev(r)||Ce.isFIFO(r))throw new Ce.ErrnoError(63);we.ops_table||(we.ops_table={dir:{node:{getattr:we.node_ops.getattr,setattr:we.node_ops.setattr,lookup:we.node_ops.lookup,mknod:we.node_ops.mknod,rename:we.node_ops.rename,unlink:we.node_ops.unlink,rmdir:we.node_ops.rmdir,readdir:we.node_ops.readdir,symlink:we.node_ops.symlink},stream:{llseek:we.stream_ops.llseek}},file:{node:{getattr:we.node_ops.getattr,setattr:we.node_ops.setattr},stream:{llseek:we.stream_ops.llseek,read:we.stream_ops.read,write:we.stream_ops.write,allocate:we.stream_ops.allocate,mmap:we.stream_ops.mmap,msync:we.stream_ops.msync}},link:{node:{getattr:we.node_ops.getattr,setattr:we.node_ops.setattr,readlink:we.node_ops.readlink},stream:{}},chrdev:{node:{getattr:we.node_ops.getattr,setattr:we.node_ops.setattr},stream:Ce.chrdev_stream_ops}});var n=Ce.createNode(e,t,r,i);return Ce.isDir(n.mode)?(n.node_ops=we.ops_table.dir.node,n.stream_ops=we.ops_table.dir.stream,n.contents={}):Ce.isFile(n.mode)?(n.node_ops=we.ops_table.file.node,n.stream_ops=we.ops_table.file.stream,n.usedBytes=0,n.contents=null):Ce.isLink(n.mode)?(n.node_ops=we.ops_table.link.node,n.stream_ops=we.ops_table.link.stream):Ce.isChrdev(n.mode)&&(n.node_ops=we.ops_table.chrdev.node,n.stream_ops=we.ops_table.chrdev.stream),n.timestamp=Date.now(),e&&(e.contents[t]=n,e.timestamp=n.timestamp),n},getFileDataAsTypedArray:e=>e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0),expandFileStorage(e,t){var r=e.contents?e.contents.length:0;if(!(r>=t)){t=Math.max(t,r*(r<1048576?2:1.125)>>>0),0!=r&&(t=Math.max(t,256));var i=e.contents;e.contents=new Uint8Array(t),e.usedBytes>0&&e.contents.set(i.subarray(0,e.usedBytes),0)}},resizeFileStorage(e,t){if(e.usedBytes!=t)if(0==t)e.contents=null,e.usedBytes=0;else{var r=e.contents;e.contents=new Uint8Array(t),r&&e.contents.set(r.subarray(0,Math.min(t,e.usedBytes))),e.usedBytes=t}},node_ops:{getattr(e){var t={};return t.dev=Ce.isChrdev(e.mode)?e.id:1,t.ino=e.id,t.mode=e.mode,t.nlink=1,t.uid=0,t.gid=0,t.rdev=e.rdev,Ce.isDir(e.mode)?t.size=4096:Ce.isFile(e.mode)?t.size=e.usedBytes:Ce.isLink(e.mode)?t.size=e.link.length:t.size=0,t.atime=new Date(e.timestamp),t.mtime=new Date(e.timestamp),t.ctime=new Date(e.timestamp),t.blksize=4096,t.blocks=Math.ceil(t.size/t.blksize),t},setattr(e,t){void 0!==t.mode&&(e.mode=t.mode),void 0!==t.timestamp&&(e.timestamp=t.timestamp),void 0!==t.size&&we.resizeFileStorage(e,t.size)},lookup(e,t){throw Ce.genericErrors[44]},mknod:(e,t,r,i)=>we.createNode(e,t,r,i),rename(e,t,r){if(Ce.isDir(e.mode)){var i;try{i=Ce.lookupNode(t,r)}catch(e){}if(i)for(var n in i.contents)throw new Ce.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=r,t.contents[r]=e,t.timestamp=e.parent.timestamp,e.parent=t},unlink(e,t){delete e.contents[t],e.timestamp=Date.now()},rmdir(e,t){var r=Ce.lookupNode(e,t);for(var i in r.contents)throw new Ce.ErrnoError(55);delete e.contents[t],e.timestamp=Date.now()},readdir(e){var t=[".",".."];for(var r in e.contents)e.contents.hasOwnProperty(r)&&t.push(r);return t},symlink(e,t,r){var i=we.createNode(e,t,41471,0);return i.link=r,i},readlink(e){if(!Ce.isLink(e.mode))throw new Ce.ErrnoError(28);return e.link}},stream_ops:{read(e,t,r,i,n){var s=e.node.contents;if(n>=e.node.usedBytes)return 0;var o=Math.min(e.node.usedBytes-n,i);if(o>8&&s.subarray)t.set(s.subarray(n,n+o),r);else for(var a=0;a<o;a++)t[r+a]=s[n+a];return o},write(e,t,r,i,n,s){if(!i)return 0;var o=e.node;if(o.timestamp=Date.now(),t.subarray&&(!o.contents||o.contents.subarray)){if(s)return o.contents=t.subarray(r,r+i),o.usedBytes=i,i;if(0===o.usedBytes&&0===n)return o.contents=t.slice(r,r+i),o.usedBytes=i,i;if(n+i<=o.usedBytes)return o.contents.set(t.subarray(r,r+i),n),i}if(we.expandFileStorage(o,n+i),o.contents.subarray&&t.subarray)o.contents.set(t.subarray(r,r+i),n);else for(var a=0;a<i;a++)o.contents[n+a]=t[r+a];return o.usedBytes=Math.max(o.usedBytes,n+i),i},llseek(e,t,r){var i=t;if(1===r?i+=e.position:2===r&&Ce.isFile(e.node.mode)&&(i+=e.node.usedBytes),i<0)throw new Ce.ErrnoError(28);return i},allocate(e,t,r){we.expandFileStorage(e.node,t+r),e.node.usedBytes=Math.max(e.node.usedBytes,t+r)},mmap(e,t,r,i,n){if(!Ce.isFile(e.node.mode))throw new Ce.ErrnoError(43);var s,o,a=e.node.contents;if(2&n||a.buffer!==E.buffer){if((r>0||r+t<a.length)&&(a=a.subarray?a.subarray(r,r+t):Array.prototype.slice.call(a,r,r+t)),o=!0,!(s=be()))throw new Ce.ErrnoError(48);E.set(a,s)}else o=!1,s=a.byteOffset;return{ptr:s,allocated:o}},msync:(e,t,r,i,n)=>(we.stream_ops.write(e,t,0,i,r,!1),0)}},Ee=(e,t,r,i)=>{var n=i?"":`al ${e}`;o(e,(r=>{F(r,`Loading data file "${e}" failed (no arrayBuffer).`),t(new Uint8Array(r)),n&&W()}),(t=>{if(!r)throw`Loading data file "${e}" failed.`;r()})),n&&V()},Se=(e,t,r,i,n,s)=>Ce.createDataFile(e,t,r,i,n,s),Ue=n.preloadPlugins||[],xe=(e,t,r,i)=>{"undefined"!=typeof Browser&&Browser.init();var n=!1;return Ue.forEach((s=>{n||s.canHandle(t)&&(s.handle(e,t,r,i),n=!0)})),n},ke=(e,t,r,i,n,s,o,a,l,d)=>{var u=t?he.resolve(le.join2(e,t)):e;function h(r){function h(r){d&&d(),a||Se(e,t,r,i,n,l),s&&s(),W()}xe(r,u,h,(()=>{o&&o(),W()}))||h(r)}V(),"string"==typeof r?Ee(r,(e=>h(e)),o):h(r)},Ae=e=>{var t={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[e];if(void 0===t)throw new Error(`Unknown file open mode: ${e}`);return t},Te=(e,t)=>{var r=0;return e&&(r|=365),t&&(r|=146),r},Ce={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(e=he.resolve(e)))return{path:"",node:null};if(t=Object.assign({follow_mount:!0,recurse_count:0},t),t.recurse_count>8)throw new Ce.ErrnoError(32);for(var r=e.split("/").filter((e=>!!e)),i=Ce.root,n="/",s=0;s<r.length;s++){var o=s===r.length-1;if(o&&t.parent)break;if(i=Ce.lookupNode(i,r[s]),n=le.join2(n,r[s]),Ce.isMountpoint(i)&&(!o||o&&t.follow_mount)&&(i=i.mounted.root),!o||t.follow)for(var a=0;Ce.isLink(i.mode);){var l=Ce.readlink(n);if(n=he.resolve(le.dirname(n),l),i=Ce.lookupPath(n,{recurse_count:t.recurse_count+1}).node,a++>40)throw new Ce.ErrnoError(32)}}return{path:n,node:i}},getPath(e){for(var t;;){if(Ce.isRoot(e)){var r=e.mount.mountpoint;return t?"/"!==r[r.length-1]?`${r}/${t}`:r+t:r}t=t?`${e.name}/${t}`:e.name,e=e.parent}},hashName(e,t){for(var r=0,i=0;i<t.length;i++)r=(r<<5)-r+t.charCodeAt(i)|0;return(e+r>>>0)%Ce.nameTable.length},hashAddNode(e){var t=Ce.hashName(e.parent.id,e.name);e.name_next=Ce.nameTable[t],Ce.nameTable[t]=e},hashRemoveNode(e){var t=Ce.hashName(e.parent.id,e.name);if(Ce.nameTable[t]===e)Ce.nameTable[t]=e.name_next;else for(var r=Ce.nameTable[t];r;){if(r.name_next===e){r.name_next=e.name_next;break}r=r.name_next}},lookupNode(e,t){var r=Ce.mayLookup(e);if(r)throw new Ce.ErrnoError(r,e);for(var i=Ce.hashName(e.id,t),n=Ce.nameTable[i];n;n=n.name_next){var s=n.name;if(n.parent.id===e.id&&s===t)return n}return Ce.lookup(e,t)},createNode(e,t,r,i){var n=new Ce.FSNode(e,t,r,i);return Ce.hashAddNode(n),n},destroyNode(e){Ce.hashRemoveNode(e)},isRoot:e=>e===e.parent,isMountpoint:e=>!!e.mounted,isFile:e=>32768==(61440&e),isDir:e=>16384==(61440&e),isLink:e=>40960==(61440&e),isChrdev:e=>8192==(61440&e),isBlkdev:e=>24576==(61440&e),isFIFO:e=>4096==(61440&e),isSocket:e=>49152==(49152&e),flagsToPermissionString(e){var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},nodePermissions:(e,t)=>Ce.ignorePermissions||(!t.includes("r")||292&e.mode)&&(!t.includes("w")||146&e.mode)&&(!t.includes("x")||73&e.mode)?0:2,mayLookup(e){var t=Ce.nodePermissions(e,"x");return t||(e.node_ops.lookup?0:2)},mayCreate(e,t){try{Ce.lookupNode(e,t);return 20}catch(e){}return Ce.nodePermissions(e,"wx")},mayDelete(e,t,r){var i;try{i=Ce.lookupNode(e,t)}catch(e){return e.errno}var n=Ce.nodePermissions(e,"wx");if(n)return n;if(r){if(!Ce.isDir(i.mode))return 54;if(Ce.isRoot(i)||Ce.getPath(i)===Ce.cwd())return 10}else if(Ce.isDir(i.mode))return 31;return 0},mayOpen:(e,t)=>e?Ce.isLink(e.mode)?32:Ce.isDir(e.mode)&&("r"!==Ce.flagsToPermissionString(t)||512&t)?31:Ce.nodePermissions(e,Ce.flagsToPermissionString(t)):44,MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=Ce.MAX_OPEN_FDS;e++)if(!Ce.streams[e])return e;throw new Ce.ErrnoError(33)},getStreamChecked(e){var t=Ce.getStream(e);if(!t)throw new Ce.ErrnoError(8);return t},getStream:e=>Ce.streams[e],createStream(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return Ce.FSStream||(Ce.FSStream=function(){this.shared={}},Ce.FSStream.prototype={},Object.defineProperties(Ce.FSStream.prototype,{object:{get(){return this.node},set(e){this.node=e}},isRead:{get(){return 1!=(2097155&this.flags)}},isWrite:{get(){return 0!=(2097155&this.flags)}},isAppend:{get(){return 1024&this.flags}},flags:{get(){return this.shared.flags},set(e){this.shared.flags=e}},position:{get(){return this.shared.position},set(e){this.shared.position=e}}})),e=Object.assign(new Ce.FSStream,e),-1==t&&(t=Ce.nextfd()),e.fd=t,Ce.streams[t]=e,e},closeStream(e){Ce.streams[e]=null},chrdev_stream_ops:{open(e){var t=Ce.getDevice(e.node.rdev);e.stream_ops=t.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek(){throw new Ce.ErrnoError(70)}},major:e=>e>>8,minor:e=>255&e,makedev:(e,t)=>e<<8|t,registerDevice(e,t){Ce.devices[e]={stream_ops:t}},getDevice:e=>Ce.devices[e],getMounts(e){for(var t=[],r=[e];r.length;){var i=r.pop();t.push(i),r.push.apply(r,i.mounts)}return t},syncfs(e,t){"function"==typeof e&&(t=e,e=!1),Ce.syncFSRequests++,Ce.syncFSRequests>1&&w(`warning: ${Ce.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var r=Ce.getMounts(Ce.root.mount),i=0;function n(e){return Ce.syncFSRequests--,t(e)}function s(e){if(e)return s.errored?void 0:(s.errored=!0,n(e));++i>=r.length&&n(null)}r.forEach((t=>{if(!t.type.syncfs)return s(null);t.type.syncfs(t,e,s)}))},mount(e,t,r){var i,n="/"===r,s=!r;if(n&&Ce.root)throw new Ce.ErrnoError(10);if(!n&&!s){var o=Ce.lookupPath(r,{follow_mount:!1});if(r=o.path,i=o.node,Ce.isMountpoint(i))throw new Ce.ErrnoError(10);if(!Ce.isDir(i.mode))throw new Ce.ErrnoError(54)}var a={type:e,opts:t,mountpoint:r,mounts:[]},l=e.mount(a);return l.mount=a,a.root=l,n?Ce.root=l:i&&(i.mounted=a,i.mount&&i.mount.mounts.push(a)),l},unmount(e){var t=Ce.lookupPath(e,{follow_mount:!1});if(!Ce.isMountpoint(t.node))throw new Ce.ErrnoError(28);var r=t.node,i=r.mounted,n=Ce.getMounts(i);Object.keys(Ce.nameTable).forEach((e=>{for(var t=Ce.nameTable[e];t;){var r=t.name_next;n.includes(t.mount)&&Ce.destroyNode(t),t=r}})),r.mounted=null;var s=r.mount.mounts.indexOf(i);r.mount.mounts.splice(s,1)},lookup:(e,t)=>e.node_ops.lookup(e,t),mknod(e,t,r){var i=Ce.lookupPath(e,{parent:!0}).node,n=le.basename(e);if(!n||"."===n||".."===n)throw new Ce.ErrnoError(28);var s=Ce.mayCreate(i,n);if(s)throw new Ce.ErrnoError(s);if(!i.node_ops.mknod)throw new Ce.ErrnoError(63);return i.node_ops.mknod(i,n,t,r)},create:(e,t)=>(t=void 0!==t?t:438,t&=4095,t|=32768,Ce.mknod(e,t,0)),mkdir:(e,t)=>(t=void 0!==t?t:511,t&=1023,t|=16384,Ce.mknod(e,t,0)),mkdirTree(e,t){for(var r=e.split("/"),i="",n=0;n<r.length;++n)if(r[n]){i+="/"+r[n];try{Ce.mkdir(i,t)}catch(e){if(20!=e.errno)throw e}}},mkdev:(e,t,r)=>(void 0===r&&(r=t,t=438),t|=8192,Ce.mknod(e,t,r)),symlink(e,t){if(!he.resolve(e))throw new Ce.ErrnoError(44);var r=Ce.lookupPath(t,{parent:!0}).node;if(!r)throw new Ce.ErrnoError(44);var i=le.basename(t),n=Ce.mayCreate(r,i);if(n)throw new Ce.ErrnoError(n);if(!r.node_ops.symlink)throw new Ce.ErrnoError(63);return r.node_ops.symlink(r,i,e)},rename(e,t){var r,i,n=le.dirname(e),s=le.dirname(t),o=le.basename(e),a=le.basename(t);if(r=Ce.lookupPath(e,{parent:!0}).node,i=Ce.lookupPath(t,{parent:!0}).node,!r||!i)throw new Ce.ErrnoError(44);if(r.mount!==i.mount)throw new Ce.ErrnoError(75);var l,d=Ce.lookupNode(r,o),u=he.relative(e,s);if("."!==u.charAt(0))throw new Ce.ErrnoError(28);if("."!==(u=he.relative(t,n)).charAt(0))throw new Ce.ErrnoError(55);try{l=Ce.lookupNode(i,a)}catch(e){}if(d!==l){var h=Ce.isDir(d.mode),c=Ce.mayDelete(r,o,h);if(c)throw new Ce.ErrnoError(c);if(c=l?Ce.mayDelete(i,a,h):Ce.mayCreate(i,a))throw new Ce.ErrnoError(c);if(!r.node_ops.rename)throw new Ce.ErrnoError(63);if(Ce.isMountpoint(d)||l&&Ce.isMountpoint(l))throw new Ce.ErrnoError(10);if(i!==r&&(c=Ce.nodePermissions(r,"w")))throw new Ce.ErrnoError(c);Ce.hashRemoveNode(d);try{r.node_ops.rename(d,i,a)}catch(e){throw e}finally{Ce.hashAddNode(d)}}},rmdir(e){var t=Ce.lookupPath(e,{parent:!0}).node,r=le.basename(e),i=Ce.lookupNode(t,r),n=Ce.mayDelete(t,r,!0);if(n)throw new Ce.ErrnoError(n);if(!t.node_ops.rmdir)throw new Ce.ErrnoError(63);if(Ce.isMountpoint(i))throw new Ce.ErrnoError(10);t.node_ops.rmdir(t,r),Ce.destroyNode(i)},readdir(e){var t=Ce.lookupPath(e,{follow:!0}).node;if(!t.node_ops.readdir)throw new Ce.ErrnoError(54);return t.node_ops.readdir(t)},unlink(e){var t=Ce.lookupPath(e,{parent:!0}).node;if(!t)throw new Ce.ErrnoError(44);var r=le.basename(e),i=Ce.lookupNode(t,r),n=Ce.mayDelete(t,r,!1);if(n)throw new Ce.ErrnoError(n);if(!t.node_ops.unlink)throw new Ce.ErrnoError(63);if(Ce.isMountpoint(i))throw new Ce.ErrnoError(10);t.node_ops.unlink(t,r),Ce.destroyNode(i)},readlink(e){var t=Ce.lookupPath(e).node;if(!t)throw new Ce.ErrnoError(44);if(!t.node_ops.readlink)throw new Ce.ErrnoError(28);return he.resolve(Ce.getPath(t.parent),t.node_ops.readlink(t))},stat(e,t){var r=Ce.lookupPath(e,{follow:!t}).node;if(!r)throw new Ce.ErrnoError(44);if(!r.node_ops.getattr)throw new Ce.ErrnoError(63);return r.node_ops.getattr(r)},lstat:e=>Ce.stat(e,!0),chmod(e,t,r){var i;"string"==typeof e?i=Ce.lookupPath(e,{follow:!r}).node:i=e;if(!i.node_ops.setattr)throw new Ce.ErrnoError(63);i.node_ops.setattr(i,{mode:4095&t|-4096&i.mode,timestamp:Date.now()})},lchmod(e,t){Ce.chmod(e,t,!0)},fchmod(e,t){var r=Ce.getStreamChecked(e);Ce.chmod(r.node,t)},chown(e,t,r,i){var n;"string"==typeof e?n=Ce.lookupPath(e,{follow:!i}).node:n=e;if(!n.node_ops.setattr)throw new Ce.ErrnoError(63);n.node_ops.setattr(n,{timestamp:Date.now()})},lchown(e,t,r){Ce.chown(e,t,r,!0)},fchown(e,t,r){var i=Ce.getStreamChecked(e);Ce.chown(i.node,t,r)},truncate(e,t){if(t<0)throw new Ce.ErrnoError(28);var r;"string"==typeof e?r=Ce.lookupPath(e,{follow:!0}).node:r=e;if(!r.node_ops.setattr)throw new Ce.ErrnoError(63);if(Ce.isDir(r.mode))throw new Ce.ErrnoError(31);if(!Ce.isFile(r.mode))throw new Ce.ErrnoError(28);var i=Ce.nodePermissions(r,"w");if(i)throw new Ce.ErrnoError(i);r.node_ops.setattr(r,{size:t,timestamp:Date.now()})},ftruncate(e,t){var r=Ce.getStreamChecked(e);if(0==(2097155&r.flags))throw new Ce.ErrnoError(28);Ce.truncate(r.node,t)},utime(e,t,r){var i=Ce.lookupPath(e,{follow:!0}).node;i.node_ops.setattr(i,{timestamp:Math.max(t,r)})},open(e,t,r){if(""===e)throw new Ce.ErrnoError(44);var i;if(r=void 0===r?438:r,r=64&(t="string"==typeof t?Ae(t):t)?4095&r|32768:0,"object"==typeof e)i=e;else{e=le.normalize(e);try{i=Ce.lookupPath(e,{follow:!(131072&t)}).node}catch(e){}}var s=!1;if(64&t)if(i){if(128&t)throw new Ce.ErrnoError(20)}else i=Ce.mknod(e,r,0),s=!0;if(!i)throw new Ce.ErrnoError(44);if(Ce.isChrdev(i.mode)&&(t&=-513),65536&t&&!Ce.isDir(i.mode))throw new Ce.ErrnoError(54);if(!s){var o=Ce.mayOpen(i,t);if(o)throw new Ce.ErrnoError(o)}512&t&&!s&&Ce.truncate(i,0),t&=-131713;var a=Ce.createStream({node:i,path:Ce.getPath(i),flags:t,seekable:!0,position:0,stream_ops:i.stream_ops,ungotten:[],error:!1});return a.stream_ops.open&&a.stream_ops.open(a),!n.logReadFiles||1&t||(Ce.readFiles||(Ce.readFiles={}),e in Ce.readFiles||(Ce.readFiles[e]=1)),a},close(e){if(Ce.isClosed(e))throw new Ce.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{Ce.closeStream(e.fd)}e.fd=null},isClosed:e=>null===e.fd,llseek(e,t,r){if(Ce.isClosed(e))throw new Ce.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new Ce.ErrnoError(70);if(0!=r&&1!=r&&2!=r)throw new Ce.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,r),e.ungotten=[],e.position},read(e,t,r,i,n){if(i<0||n<0)throw new Ce.ErrnoError(28);if(Ce.isClosed(e))throw new Ce.ErrnoError(8);if(1==(2097155&e.flags))throw new Ce.ErrnoError(8);if(Ce.isDir(e.node.mode))throw new Ce.ErrnoError(31);if(!e.stream_ops.read)throw new Ce.ErrnoError(28);var s=void 0!==n;if(s){if(!e.seekable)throw new Ce.ErrnoError(70)}else n=e.position;var o=e.stream_ops.read(e,t,r,i,n);return s||(e.position+=o),o},write(e,t,r,i,n,s){if(i<0||n<0)throw new Ce.ErrnoError(28);if(Ce.isClosed(e))throw new Ce.ErrnoError(8);if(0==(2097155&e.flags))throw new Ce.ErrnoError(8);if(Ce.isDir(e.node.mode))throw new Ce.ErrnoError(31);if(!e.stream_ops.write)throw new Ce.ErrnoError(28);e.seekable&&1024&e.flags&&Ce.llseek(e,0,2);var o=void 0!==n;if(o){if(!e.seekable)throw new Ce.ErrnoError(70)}else n=e.position;var a=e.stream_ops.write(e,t,r,i,n,s);return o||(e.position+=a),a},allocate(e,t,r){if(Ce.isClosed(e))throw new Ce.ErrnoError(8);if(t<0||r<=0)throw new Ce.ErrnoError(28);if(0==(2097155&e.flags))throw new Ce.ErrnoError(8);if(!Ce.isFile(e.node.mode)&&!Ce.isDir(e.node.mode))throw new Ce.ErrnoError(43);if(!e.stream_ops.allocate)throw new Ce.ErrnoError(138);e.stream_ops.allocate(e,t,r)},mmap(e,t,r,i,n){if(0!=(2&i)&&0==(2&n)&&2!=(2097155&e.flags))throw new Ce.ErrnoError(2);if(1==(2097155&e.flags))throw new Ce.ErrnoError(2);if(!e.stream_ops.mmap)throw new Ce.ErrnoError(43);return e.stream_ops.mmap(e,t,r,i,n)},msync:(e,t,r,i,n)=>e.stream_ops.msync?e.stream_ops.msync(e,t,r,i,n):0,munmap:e=>0,ioctl(e,t,r){if(!e.stream_ops.ioctl)throw new Ce.ErrnoError(59);return e.stream_ops.ioctl(e,t,r)},readFile(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t.flags=t.flags||0,t.encoding=t.encoding||"binary","utf8"!==t.encoding&&"binary"!==t.encoding)throw new Error(`Invalid encoding type "${t.encoding}"`);var r,i=Ce.open(e,t.flags),n=Ce.stat(e).size,s=new Uint8Array(n);return Ce.read(i,s,0,n,0),"utf8"===t.encoding?r=fe(s,0):"binary"===t.encoding&&(r=s),Ce.close(i),r},writeFile(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};r.flags=r.flags||577;var i=Ce.open(e,r.flags,r.mode);if("string"==typeof t){var n=new Uint8Array(me(t)+1),s=_e(t,n,0,n.length);Ce.write(i,n,0,s,void 0,r.canOwn)}else{if(!ArrayBuffer.isView(t))throw new Error("Unsupported data type");Ce.write(i,t,0,t.byteLength,void 0,r.canOwn)}Ce.close(i)},cwd:()=>Ce.currentPath,chdir(e){var t=Ce.lookupPath(e,{follow:!0});if(null===t.node)throw new Ce.ErrnoError(44);if(!Ce.isDir(t.node.mode))throw new Ce.ErrnoError(54);var r=Ce.nodePermissions(t.node,"x");if(r)throw new Ce.ErrnoError(r);Ce.currentPath=t.path},createDefaultDirectories(){Ce.mkdir("/tmp"),Ce.mkdir("/home"),Ce.mkdir("/home/web_user")},createDefaultDevices(){Ce.mkdir("/dev"),Ce.registerDevice(Ce.makedev(1,3),{read:()=>0,write:(e,t,r,i,n)=>i}),Ce.mkdev("/dev/null",Ce.makedev(1,3)),ve.register(Ce.makedev(5,0),ve.default_tty_ops),ve.register(Ce.makedev(6,0),ve.default_tty1_ops),Ce.mkdev("/dev/tty",Ce.makedev(5,0)),Ce.mkdev("/dev/tty1",Ce.makedev(6,0));var e=new Uint8Array(1024),t=0,r=()=>(0===t&&(t=ue(e).byteLength),e[--t]);Ce.createDevice("/dev","random",r),Ce.createDevice("/dev","urandom",r),Ce.mkdir("/dev/shm"),Ce.mkdir("/dev/shm/tmp")},createSpecialDirectories(){Ce.mkdir("/proc");var e=Ce.mkdir("/proc/self");Ce.mkdir("/proc/self/fd"),Ce.mount({mount(){var t=Ce.createNode(e,"fd",16895,73);return t.node_ops={lookup(e,t){var r=+t,i=Ce.getStreamChecked(r),n={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>i.path}};return n.parent=n,n}},t}},{},"/proc/self/fd")},createStandardStreams(){n.stdin?Ce.createDevice("/dev","stdin",n.stdin):Ce.symlink("/dev/tty","/dev/stdin"),n.stdout?Ce.createDevice("/dev","stdout",null,n.stdout):Ce.symlink("/dev/tty","/dev/stdout"),n.stderr?Ce.createDevice("/dev","stderr",null,n.stderr):Ce.symlink("/dev/tty1","/dev/stderr"),Ce.open("/dev/stdin",0),Ce.open("/dev/stdout",1),Ce.open("/dev/stderr",1)},ensureErrnoError(){Ce.ErrnoError||(Ce.ErrnoError=function(e,t){this.name="ErrnoError",this.node=t,this.setErrno=function(e){this.errno=e},this.setErrno(e),this.message="FS error"},Ce.ErrnoError.prototype=new Error,Ce.ErrnoError.prototype.constructor=Ce.ErrnoError,[44].forEach((e=>{Ce.genericErrors[e]=new Ce.ErrnoError(e),Ce.genericErrors[e].stack="<generic error, no stack>"})))},staticInit(){Ce.ensureErrnoError(),Ce.nameTable=new Array(4096),Ce.mount(we,{},"/"),Ce.createDefaultDirectories(),Ce.createDefaultDevices(),Ce.createSpecialDirectories(),Ce.filesystems={MEMFS:we}},init(e,t,r){Ce.init.initialized=!0,Ce.ensureErrnoError(),n.stdin=e||n.stdin,n.stdout=t||n.stdout,n.stderr=r||n.stderr,Ce.createStandardStreams()},quit(){Ce.init.initialized=!1;for(var e=0;e<Ce.streams.length;e++){var t=Ce.streams[e];t&&Ce.close(t)}},findObject(e,t){var r=Ce.analyzePath(e,t);return r.exists?r.object:null},analyzePath(e,t){try{e=(i=Ce.lookupPath(e,{follow:!t})).path}catch(e){}var r={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var i=Ce.lookupPath(e,{parent:!0});r.parentExists=!0,r.parentPath=i.path,r.parentObject=i.node,r.name=le.basename(e),i=Ce.lookupPath(e,{follow:!t}),r.exists=!0,r.path=i.path,r.object=i.node,r.name=i.node.name,r.isRoot="/"===i.path}catch(e){r.error=e.errno}return r},createPath(e,t,r,i){e="string"==typeof e?e:Ce.getPath(e);for(var n=t.split("/").reverse();n.length;){var s=n.pop();if(s){var o=le.join2(e,s);try{Ce.mkdir(o)}catch(e){}e=o}}return o},createFile(e,t,r,i,n){var s=le.join2("string"==typeof e?e:Ce.getPath(e),t),o=Te(i,n);return Ce.create(s,o)},createDataFile(e,t,r,i,n,s){var o=t;e&&(e="string"==typeof e?e:Ce.getPath(e),o=t?le.join2(e,t):e);var a=Te(i,n),l=Ce.create(o,a);if(r){if("string"==typeof r){for(var d=new Array(r.length),u=0,h=r.length;u<h;++u)d[u]=r.charCodeAt(u);r=d}Ce.chmod(l,146|a);var c=Ce.open(l,577);Ce.write(c,r,0,r.length,0,s),Ce.close(c),Ce.chmod(l,a)}return l},createDevice(e,t,r,i){var n=le.join2("string"==typeof e?e:Ce.getPath(e),t),s=Te(!!r,!!i);Ce.createDevice.major||(Ce.createDevice.major=64);var o=Ce.makedev(Ce.createDevice.major++,0);return Ce.registerDevice(o,{open(e){e.seekable=!1},close(e){i&&i.buffer&&i.buffer.length&&i(10)},read(e,t,i,n,s){for(var o=0,a=0;a<n;a++){var l;try{l=r()}catch(e){throw new Ce.ErrnoError(29)}if(void 0===l&&0===o)throw new Ce.ErrnoError(6);if(null==l)break;o++,t[i+a]=l}return o&&(e.node.timestamp=Date.now()),o},write(e,t,r,n,s){for(var o=0;o<n;o++)try{i(t[r+o])}catch(e){throw new Ce.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),o}}),Ce.mkdev(n,s,o)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if("undefined"!=typeof XMLHttpRequest)throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(!s)throw new Error("Cannot load without read() or XMLHttpRequest.");try{e.contents=ge(s(e.url),!0),e.usedBytes=e.contents.length}catch(e){throw new Ce.ErrnoError(29)}},createLazyFile(e,t,r,i,n){function s(){this.lengthKnown=!1,this.chunks=[]}if(s.prototype.get=function(e){if(!(e>this.length-1||e<0)){var t=e%this.chunkSize,r=e/this.chunkSize|0;return this.getter(r)[t]}},s.prototype.setDataGetter=function(e){this.getter=e},s.prototype.cacheLength=function(){var e=new XMLHttpRequest;if(e.open("HEAD",r,!1),e.send(null),!(e.status>=200&&e.status<300||304===e.status))throw new Error("Couldn't load "+r+". Status: "+e.status);var t,i=Number(e.getResponseHeader("Content-length")),n=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t,s=(t=e.getResponseHeader("Content-Encoding"))&&"gzip"===t,o=1048576;n||(o=i);var a=this;a.setDataGetter((e=>{var t=e*o,n=(e+1)*o-1;if(n=Math.min(n,i-1),void 0===a.chunks[e]&&(a.chunks[e]=((e,t)=>{if(e>t)throw new Error("invalid range ("+e+", "+t+") or no bytes requested!");if(t>i-1)throw new Error("only "+i+" bytes available! programmer error!");var n=new XMLHttpRequest;if(n.open("GET",r,!1),i!==o&&n.setRequestHeader("Range","bytes="+e+"-"+t),n.responseType="arraybuffer",n.overrideMimeType&&n.overrideMimeType("text/plain; charset=x-user-defined"),n.send(null),!(n.status>=200&&n.status<300||304===n.status))throw new Error("Couldn't load "+r+". Status: "+n.status);return void 0!==n.response?new Uint8Array(n.response||[]):ge(n.responseText||"",!0)})(t,n)),void 0===a.chunks[e])throw new Error("doXHR failed!");return a.chunks[e]})),!s&&i||(o=i=1,i=this.getter(0).length,o=i,b("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=i,this._chunkSize=o,this.lengthKnown=!0},"undefined"!=typeof XMLHttpRequest){if(!h)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var o=new s;Object.defineProperties(o,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var a={isDevice:!1,contents:o}}else a={isDevice:!1,url:r};var l=Ce.createFile(e,t,a,i,n);a.contents?l.contents=a.contents:a.url&&(l.contents=null,l.url=a.url),Object.defineProperties(l,{usedBytes:{get:function(){return this.contents.length}}});var d={};function u(e,t,r,i,n){var s=e.node.contents;if(n>=s.length)return 0;var o=Math.min(s.length-n,i);if(s.slice)for(var a=0;a<o;a++)t[r+a]=s[n+a];else for(a=0;a<o;a++)t[r+a]=s.get(n+a);return o}return Object.keys(l.stream_ops).forEach((e=>{var t=l.stream_ops[e];d[e]=function(){return Ce.forceLoadFile(l),t.apply(null,arguments)}})),d.read=(e,t,r,i,n)=>(Ce.forceLoadFile(l),u(e,t,r,i,n)),d.mmap=(e,t,r,i,n)=>{Ce.forceLoadFile(l);var s=be();if(!s)throw new Ce.ErrnoError(48);return u(e,E,s,t,r),{ptr:s,allocated:!0}},l.stream_ops=d,l}},Be=(e,t)=>e?fe(S,e,t):"",Fe={DEFAULT_POLLMASK:5,calculateAt(e,t,r){if(le.isAbs(t))return t;var i;-100===e?i=Ce.cwd():i=Fe.getStreamFromFD(e).path;if(0==t.length){if(!r)throw new Ce.ErrnoError(44);return i}return le.join2(i,t)},doStat(e,t,r){try{var i=e(t)}catch(e){if(e&&e.node&&le.normalize(t)!==le.normalize(Ce.getPath(e.node)))return-54;throw e}k[r>>2]=i.dev,k[r+4>>2]=i.mode,A[r+8>>2]=i.nlink,k[r+12>>2]=i.uid,k[r+16>>2]=i.gid,k[r+20>>2]=i.rdev,K=[i.size>>>0,(q=i.size,+Math.abs(q)>=1?q>0?+Math.floor(q/4294967296)>>>0:~~+Math.ceil((q-+(~~q>>>0))/4294967296)>>>0:0)],k[r+24>>2]=K[0],k[r+28>>2]=K[1],k[r+32>>2]=4096,k[r+36>>2]=i.blocks;var n=i.atime.getTime(),s=i.mtime.getTime(),o=i.ctime.getTime();return K=[Math.floor(n/1e3)>>>0,(q=Math.floor(n/1e3),+Math.abs(q)>=1?q>0?+Math.floor(q/4294967296)>>>0:~~+Math.ceil((q-+(~~q>>>0))/4294967296)>>>0:0)],k[r+40>>2]=K[0],k[r+44>>2]=K[1],A[r+48>>2]=n%1e3*1e3,K=[Math.floor(s/1e3)>>>0,(q=Math.floor(s/1e3),+Math.abs(q)>=1?q>0?+Math.floor(q/4294967296)>>>0:~~+Math.ceil((q-+(~~q>>>0))/4294967296)>>>0:0)],k[r+56>>2]=K[0],k[r+60>>2]=K[1],A[r+64>>2]=s%1e3*1e3,K=[Math.floor(o/1e3)>>>0,(q=Math.floor(o/1e3),+Math.abs(q)>=1?q>0?+Math.floor(q/4294967296)>>>0:~~+Math.ceil((q-+(~~q>>>0))/4294967296)>>>0:0)],k[r+72>>2]=K[0],k[r+76>>2]=K[1],A[r+80>>2]=o%1e3*1e3,K=[i.ino>>>0,(q=i.ino,+Math.abs(q)>=1?q>0?+Math.floor(q/4294967296)>>>0:~~+Math.ceil((q-+(~~q>>>0))/4294967296)>>>0:0)],k[r+88>>2]=K[0],k[r+92>>2]=K[1],0},doMsync(e,t,r,i,n){if(!Ce.isFile(t.node.mode))throw new Ce.ErrnoError(43);if(2&i)return 0;var s=S.slice(e,e+r);Ce.msync(t,s,n,r,i)},varargs:void 0,get(){var e=k[+Fe.varargs>>2];return Fe.varargs+=4,e},getp:()=>Fe.get(),getStr:e=>Be(e),getStreamFromFD:e=>Ce.getStreamChecked(e)};function Pe(e,t,r){Fe.varargs=r;try{var i=Fe.getStreamFromFD(e);switch(t){case 0:if((n=Fe.get())<0)return-28;for(;Ce.streams[n];)n++;return Ce.createStream(i,n).fd;case 1:case 2:case 6:case 7:return 0;case 3:return i.flags;case 4:var n=Fe.get();return i.flags|=n,0;case 5:n=Fe.getp();return U[n+0>>1]=2,0;case 16:case 8:default:return-28;case 9:return ae(28),-1}}catch(e){if(void 0===Ce||"ErrnoError"!==e.name)throw e;return-e.errno}}function De(e,t,r,i){Fe.varargs=i;try{t=Fe.getStr(t),t=Fe.calculateAt(e,t);var n=i?Fe.get():0;return Ce.open(t,r,n).fd}catch(e){if(void 0===Ce||"ErrnoError"!==e.name)throw e;return-e.errno}}var Ie,Le,Re,ze=(e,t,r,i,n)=>{},Me=()=>{for(var e=new Array(256),t=0;t<256;++t)e[t]=String.fromCharCode(t);Ie=e},Oe=e=>{for(var t="",r=e;S[r];)t+=Ie[S[r++]];return t},Ne={},$e={},Ge={},He=e=>{throw new Le(e)},Ve=e=>{throw new Re(e)},We=(e,t,r)=>{function i(t){var i=r(t);i.length!==e.length&&Ve("Mismatched type converter count");for(var n=0;n<e.length;++n)Ye(e[n],i[n])}e.forEach((function(e){Ge[e]=t}));var n=new Array(t.length),s=[],o=0;t.forEach(((e,t)=>{$e.hasOwnProperty(e)?n[t]=$e[e]:(s.push(e),Ne.hasOwnProperty(e)||(Ne[e]=[]),Ne[e].push((()=>{n[t]=$e[e],++o===s.length&&i(n)})))})),0===s.length&&i(n)};function je(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var i=t.name;if(e||He(`type "${i}" must have a positive integer typeid pointer`),$e.hasOwnProperty(e)){if(r.ignoreDuplicateRegistrations)return;He(`Cannot register type '${i}' twice`)}if($e[e]=t,delete Ge[e],Ne.hasOwnProperty(e)){var n=Ne[e];delete Ne[e],n.forEach((e=>e()))}}function Ye(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");return je(e,t,r)}var qe,Ke=8,Xe=(e,t,r,i)=>{Ye(e,{name:t=Oe(t),fromWireType:function(e){return!!e},toWireType:function(e,t){return t?r:i},argPackAdvance:Ke,readValueFromPointer:function(e){return this.fromWireType(S[e])},destructorFunction:null})},Ze=e=>({count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}),Je=e=>{He(e.$$.ptrType.registeredClass.name+" instance already deleted")},Qe=!1,et=e=>{},tt=e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)},rt=e=>{e.count.value-=1,0===e.count.value&&tt(e)},it=(e,t,r)=>{if(t===r)return e;if(void 0===r.baseClass)return null;var i=it(e,t,r.baseClass);return null===i?null:r.downcast(i)},nt={},st=()=>Object.keys(ht).length,ot=()=>{var e=[];for(var t in ht)ht.hasOwnProperty(t)&&e.push(ht[t]);return e},at=[],lt=()=>{for(;at.length;){var e=at.pop();e.$$.deleteScheduled=!1,e.delete()}},dt=e=>{qe=e,at.length&&qe&&qe(lt)},ut=()=>{n.getInheritedInstanceCount=st,n.getLiveInheritedInstances=ot,n.flushPendingDeletes=lt,n.setDelayFunction=dt},ht={},ct=(e,t)=>{for(void 0===t&&He("ptr should not be undefined");e.baseClass;)t=e.upcast(t),e=e.baseClass;return t},ft=(e,t)=>(t=ct(e,t),ht[t]),pt=(e,t)=>(t.ptrType&&t.ptr||Ve("makeClassHandle requires ptr and ptrType"),!!t.smartPtrType!==!!t.smartPtr&&Ve("Both smartPtrType and smartPtr must be specified"),t.count={value:1},_t(Object.create(e,{$$:{value:t}})));function mt(e){var t=this.getPointee(e);if(!t)return this.destructor(e),null;var r=ft(this.registeredClass,t);if(void 0!==r){if(0===r.$$.count.value)return r.$$.ptr=t,r.$$.smartPtr=e,r.clone();var i=r.clone();return this.destructor(e),i}function n(){return this.isSmartPointer?pt(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:t,smartPtrType:this,smartPtr:e}):pt(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var s,o=this.registeredClass.getActualType(t),a=nt[o];if(!a)return n.call(this);s=this.isConst?a.constPointerType:a.pointerType;var l=it(t,this.registeredClass,s.registeredClass);return null===l?n.call(this):this.isSmartPointer?pt(s.registeredClass.instancePrototype,{ptrType:s,ptr:l,smartPtrType:this,smartPtr:e}):pt(s.registeredClass.instancePrototype,{ptrType:s,ptr:l})}var _t=e=>"undefined"==typeof FinalizationRegistry?(_t=e=>e,e):(Qe=new FinalizationRegistry((e=>{rt(e.$$)})),_t=e=>{var t=e.$$;if(!!t.smartPtr){var r={$$:t};Qe.register(e,r,e)}return e},et=e=>Qe.unregister(e),_t(e)),gt=()=>{Object.assign(yt.prototype,{isAliasOf(e){if(!(this instanceof yt))return!1;if(!(e instanceof yt))return!1;var t=this.$$.ptrType.registeredClass,r=this.$$.ptr;e.$$=e.$$;for(var i=e.$$.ptrType.registeredClass,n=e.$$.ptr;t.baseClass;)r=t.upcast(r),t=t.baseClass;for(;i.baseClass;)n=i.upcast(n),i=i.baseClass;return t===i&&r===n},clone(){if(this.$$.ptr||Je(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=_t(Object.create(Object.getPrototypeOf(this),{$$:{value:Ze(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=!1,e},delete(){this.$$.ptr||Je(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&He("Object already scheduled for deletion"),et(this),rt(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||Je(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&He("Object already scheduled for deletion"),at.push(this),1===at.length&&qe&&qe(lt),this.$$.deleteScheduled=!0,this}})};function yt(){}var vt=48,bt=57,wt=e=>{if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return t>=vt&&t<=bt?`_${e}`:e};function Et(e,t){return{[e=wt(e)]:function(){return t.apply(this,arguments)}}[e]}var St=(e,t,r)=>{if(void 0===e[t].overloadTable){var i=e[t];e[t]=function(){return e[t].overloadTable.hasOwnProperty(arguments.length)||He(`Function '${r}' called with an invalid number of arguments (${arguments.length}) - expects one of (${e[t].overloadTable})!`),e[t].overloadTable[arguments.length].apply(this,arguments)},e[t].overloadTable=[],e[t].overloadTable[i.argCount]=i}},Ut=(e,t,r)=>{n.hasOwnProperty(e)?((void 0===r||void 0!==n[e].overloadTable&&void 0!==n[e].overloadTable[r])&&He(`Cannot register public name '${e}' twice`),St(n,e,e),n.hasOwnProperty(r)&&He(`Cannot register multiple overloads of a function with the same number of arguments (${r})!`),n[e].overloadTable[r]=t):(n[e]=t,void 0!==r&&(n[e].numArguments=r))};function xt(e,t,r,i,n,s,o,a){this.name=e,this.constructor=t,this.instancePrototype=r,this.rawDestructor=i,this.baseClass=n,this.getActualType=s,this.upcast=o,this.downcast=a,this.pureVirtualFunctions=[]}var kt=(e,t,r)=>{for(;t!==r;)t.upcast||He(`Expected null or instance of ${r.name}, got an instance of ${t.name}`),e=t.upcast(e),t=t.baseClass;return e};function At(e,t){if(null===t)return this.isReference&&He(`null is not a valid ${this.name}`),0;t.$$||He(`Cannot pass "${ar(t)}" as a ${this.name}`),t.$$.ptr||He(`Cannot pass deleted object as a pointer of type ${this.name}`);var r=t.$$.ptrType.registeredClass;return kt(t.$$.ptr,r,this.registeredClass)}function Tt(e,t){var r;if(null===t)return this.isReference&&He(`null is not a valid ${this.name}`),this.isSmartPointer?(r=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,r),r):0;t.$$||He(`Cannot pass "${ar(t)}" as a ${this.name}`),t.$$.ptr||He(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&t.$$.ptrType.isConst&&He(`Cannot convert argument of type ${t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name} to parameter type ${this.name}`);var i=t.$$.ptrType.registeredClass;if(r=kt(t.$$.ptr,i,this.registeredClass),this.isSmartPointer)switch(void 0===t.$$.smartPtr&&He("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:t.$$.smartPtrType===this?r=t.$$.smartPtr:He(`Cannot convert argument of type ${t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:r=t.$$.smartPtr;break;case 2:if(t.$$.smartPtrType===this)r=t.$$.smartPtr;else{var n=t.clone();r=this.rawShare(r,nr.toHandle((()=>n.delete()))),null!==e&&e.push(this.rawDestructor,r)}break;default:He("Unsupporting sharing policy")}return r}function Ct(e,t){if(null===t)return this.isReference&&He(`null is not a valid ${this.name}`),0;t.$$||He(`Cannot pass "${ar(t)}" as a ${this.name}`),t.$$.ptr||He(`Cannot pass deleted object as a pointer of type ${this.name}`),t.$$.ptrType.isConst&&He(`Cannot convert argument of type ${t.$$.ptrType.name} to parameter type ${this.name}`);var r=t.$$.ptrType.registeredClass;return kt(t.$$.ptr,r,this.registeredClass)}function Bt(e){return this.fromWireType(A[e>>2])}var Ft=()=>{Object.assign(Pt.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){this.rawDestructor&&this.rawDestructor(e)},argPackAdvance:Ke,readValueFromPointer:Bt,deleteObject(e){null!==e&&e.delete()},fromWireType:mt})};function Pt(e,t,r,i,n,s,o,a,l,d,u){this.name=e,this.registeredClass=t,this.isReference=r,this.isConst=i,this.isSmartPointer=n,this.pointeeType=s,this.sharingPolicy=o,this.rawGetPointee=a,this.rawConstructor=l,this.rawShare=d,this.rawDestructor=u,n||void 0!==t.baseClass?this.toWireType=Tt:i?(this.toWireType=At,this.destructorFunction=null):(this.toWireType=Ct,this.destructorFunction=null)}var Dt,It,Lt=(e,t,r)=>{n.hasOwnProperty(e)||Ve("Replacing nonexistant public symbol"),void 0!==n[e].overloadTable&&void 0!==r?n[e].overloadTable[r]=t:(n[e]=t,n[e].argCount=r)},Rt=(e,t,r)=>{var i=n["dynCall_"+e];return r&&r.length?i.apply(null,[t].concat(r)):i.call(null,t)},zt=[],Mt=e=>{var t=zt[e];return t||(e>=zt.length&&(zt.length=e+1),zt[e]=t=Dt.get(e)),t},Ot=(e,t,r)=>e.includes("j")?Rt(e,t,r):Mt(t).apply(null,r),Nt=(e,t)=>{var r=[];return function(){return r.length=0,Object.assign(r,arguments),Ot(e,t,r)}},$t=(e,t)=>{var r=(e=Oe(e)).includes("j")?Nt(e,t):Mt(t);return"function"!=typeof r&&He(`unknown function pointer with signature ${e}: ${t}`),r},Gt=(e,t)=>{var r=Et(t,(function(e){this.name=t,this.message=e;var r=new Error(e).stack;void 0!==r&&(this.stack=this.toString()+"\n"+r.replace(/^Error(:[^\n]*)?\n/,""))}));return r.prototype=Object.create(e.prototype),r.prototype.constructor=r,r.prototype.toString=function(){return void 0===this.message?this.name:`${this.name}: ${this.message}`},r},Ht=e=>{var t=si(e),r=Oe(t);return ii(t),r},Vt=(e,t)=>{var r=[],i={};throw t.forEach((function e(t){i[t]||$e[t]||(Ge[t]?Ge[t].forEach(e):(r.push(t),i[t]=!0))})),new It(`${e}: `+r.map(Ht).join([", "]))},Wt=(e,t,r,i,n,s,o,a,l,d,u,h,c)=>{u=Oe(u),s=$t(n,s),a&&(a=$t(o,a)),d&&(d=$t(l,d)),c=$t(h,c);var f=wt(u);Ut(f,(function(){Vt(`Cannot construct ${u} due to unbound types`,[i])})),We([e,t,r],i?[i]:[],(function(t){var r,n;t=t[0],n=i?(r=t.registeredClass).instancePrototype:yt.prototype;var o=Et(f,(function(){if(Object.getPrototypeOf(this)!==l)throw new Le("Use 'new' to construct "+u);if(void 0===h.constructor_body)throw new Le(u+" has no accessible constructor");var e=h.constructor_body[arguments.length];if(void 0===e)throw new Le(`Tried to invoke ctor of ${u} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(h.constructor_body).toString()}) parameters instead!`);return e.apply(this,arguments)})),l=Object.create(n,{constructor:{value:o}});o.prototype=l;var h=new xt(u,o,l,c,r,s,a,d);h.baseClass&&(void 0===h.baseClass.__derivedClasses&&(h.baseClass.__derivedClasses=[]),h.baseClass.__derivedClasses.push(h));var p=new Pt(u,h,!0,!1,!1),m=new Pt(u+"*",h,!1,!1,!1),_=new Pt(u+" const*",h,!1,!0,!1);return nt[e]={pointerType:m,constPointerType:_},Lt(f,o),[p,m,_]}))},jt=(e,t)=>{for(var r=[],i=0;i<e;i++)r.push(A[t+4*i>>2]);return r},Yt=e=>{for(;e.length;){var t=e.pop();e.pop()(t)}};function qt(e,t){if(!(e instanceof Function))throw new TypeError(`new_ called with constructor type ${typeof e} which is not a function`);var r=Et(e.name||"unknownFunctionName",(function(){}));r.prototype=e.prototype;var i=new r,n=e.apply(i,t);return n instanceof Object?n:i}function Kt(e,t,r,i,n,s){var o=t.length;o<2&&He("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var a=null!==t[1]&&null!==r,l=!1,d=1;d<t.length;++d)if(null!==t[d]&&void 0===t[d].destructorFunction){l=!0;break}var u="void"!==t[0].name,h="",c="";for(d=0;d<o-2;++d)h+=(0!==d?", ":"")+"arg"+d,c+=(0!==d?", ":"")+"arg"+d+"Wired";var f=`\n return function ${wt(e)}(${h}) {\n if (arguments.length !== ${o-2}) {\n throwBindingError('function ${e} called with ' + arguments.length + ' arguments, expected ${o-2}');\n }`;l&&(f+="var destructors = [];\n");var p=l?"destructors":"null",m=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],_=[He,i,n,Yt,t[0],t[1]];a&&(f+="var thisWired = classParam.toWireType("+p+", this);\n");for(d=0;d<o-2;++d)f+="var arg"+d+"Wired = argType"+d+".toWireType("+p+", arg"+d+"); // "+t[d+2].name+"\n",m.push("argType"+d),_.push(t[d+2]);if(a&&(c="thisWired"+(c.length>0?", ":"")+c),f+=(u||s?"var rv = ":"")+"invoker(fn"+(c.length>0?", ":"")+c+");\n",l)f+="runDestructors(destructors);\n";else for(d=a?1:2;d<t.length;++d){var g=1===d?"thisWired":"arg"+(d-2)+"Wired";null!==t[d].destructorFunction&&(f+=g+"_dtor("+g+"); // "+t[d].name+"\n",m.push(g+"_dtor"),_.push(t[d].destructorFunction))}return u&&(f+="var ret = retType.fromWireType(rv);\nreturn ret;\n"),f+="}\n",m.push(f),qt(Function,m).apply(null,_)}var Xt=(e,t,r,i,n,s)=>{var o=jt(t,r);n=$t(i,n),We([],[e],(function(e){var r=`constructor ${(e=e[0]).name}`;if(void 0===e.registeredClass.constructor_body&&(e.registeredClass.constructor_body=[]),void 0!==e.registeredClass.constructor_body[t-1])throw new Le(`Cannot register multiple constructors with identical number of parameters (${t-1}) for class '${e.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return e.registeredClass.constructor_body[t-1]=()=>{Vt(`Cannot construct ${e.name} due to unbound types`,o)},We([],o,(i=>(i.splice(1,0,null),e.registeredClass.constructor_body[t-1]=Kt(r,i,null,n,s),[]))),[]}))},Zt=(e,t,r,i,n,s,o,a,l)=>{var d=jt(r,i);t=Oe(t),s=$t(n,s),We([],[e],(function(e){var i=`${(e=e[0]).name}.${t}`;function n(){Vt(`Cannot call ${i} due to unbound types`,d)}t.startsWith("@@")&&(t=Symbol[t.substring(2)]),a&&e.registeredClass.pureVirtualFunctions.push(t);var u=e.registeredClass.instancePrototype,h=u[t];return void 0===h||void 0===h.overloadTable&&h.className!==e.name&&h.argCount===r-2?(n.argCount=r-2,n.className=e.name,u[t]=n):(St(u,t,i),u[t].overloadTable[r-2]=n),We([],d,(function(n){var a=Kt(i,n,e,s,o,l);return void 0===u[t].overloadTable?(a.argCount=r-2,u[t]=a):u[t].overloadTable[r-2]=a,[]})),[]}))};function Jt(){Object.assign(Qt.prototype,{get(e){return this.allocated[e]},has(e){return void 0!==this.allocated[e]},allocate(e){var t=this.freelist.pop()||this.allocated.length;return this.allocated[t]=e,t},free(e){this.allocated[e]=void 0,this.freelist.push(e)}})}function Qt(){this.allocated=[void 0],this.freelist=[]}var er=new Qt,tr=e=>{e>=er.reserved&&0==--er.get(e).refcount&&er.free(e)},rr=()=>{for(var e=0,t=er.reserved;t<er.allocated.length;++t)void 0!==er.allocated[t]&&++e;return e},ir=()=>{er.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),er.reserved=er.allocated.length,n.count_emval_handles=rr},nr={toValue:e=>(e||He("Cannot use deleted val. handle = "+e),er.get(e).value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return er.allocate({refcount:1,value:e})}}};function sr(e){return this.fromWireType(k[e>>2])}var or=(e,t)=>{Ye(e,{name:t=Oe(t),fromWireType:e=>{var t=nr.toValue(e);return tr(e),t},toWireType:(e,t)=>nr.toHandle(t),argPackAdvance:Ke,readValueFromPointer:sr,destructorFunction:null})},ar=e=>{if(null===e)return"null";var t=typeof e;return"object"===t||"array"===t||"function"===t?e.toString():""+e},lr=(e,t)=>{switch(t){case 4:return function(e){return this.fromWireType(T[e>>2])};case 8:return function(e){return this.fromWireType(C[e>>3])};default:throw new TypeError(`invalid float width (${t}): ${e}`)}},dr=(e,t,r)=>{Ye(e,{name:t=Oe(t),fromWireType:e=>e,toWireType:(e,t)=>t,argPackAdvance:Ke,readValueFromPointer:lr(t,r),destructorFunction:null})},ur=(e,t,r)=>{switch(t){case 1:return r?e=>E[e>>0]:e=>S[e>>0];case 2:return r?e=>U[e>>1]:e=>x[e>>1];case 4:return r?e=>k[e>>2]:e=>A[e>>2];default:throw new TypeError(`invalid integer width (${t}): ${e}`)}},hr=(e,t,r,i,n)=>{t=Oe(t);var s=e=>e;if(0===i){var o=32-8*r;s=e=>e<<o>>>o}var a=t.includes("unsigned");Ye(e,{name:t,fromWireType:s,toWireType:a?function(e,t){return this.name,t>>>0}:function(e,t){return this.name,t},argPackAdvance:Ke,readValueFromPointer:ur(t,r,0!==i),destructorFunction:null})},cr=(e,t,r)=>{var i=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];function n(e){var t=A[e>>2],r=A[e+4>>2];return new i(E.buffer,r,t)}Ye(e,{name:r=Oe(r),fromWireType:n,argPackAdvance:Ke,readValueFromPointer:n},{ignoreDuplicateRegistrations:!0})},fr=(e,t,r)=>_e(e,S,t,r),pr=(e,t)=>{var r="std::string"===(t=Oe(t));Ye(e,{name:t,fromWireType(e){var t,i=A[e>>2],n=e+4;if(r)for(var s=n,o=0;o<=i;++o){var a=n+o;if(o==i||0==S[a]){var l=Be(s,a-s);void 0===t?t=l:(t+=String.fromCharCode(0),t+=l),s=a+1}}else{var d=new Array(i);for(o=0;o<i;++o)d[o]=String.fromCharCode(S[n+o]);t=d.join("")}return ii(e),t},toWireType(e,t){var i;t instanceof ArrayBuffer&&(t=new Uint8Array(t));var n="string"==typeof t;n||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||He("Cannot pass non-string to std::string"),i=r&&n?me(t):t.length;var s=ai(4+i+1),o=s+4;if(A[s>>2]=i,r&&n)fr(t,o,i+1);else if(n)for(var a=0;a<i;++a){var l=t.charCodeAt(a);l>255&&(ii(o),He("String has UTF-16 code units that do not fit in 8 bits")),S[o+a]=l}else for(a=0;a<i;++a)S[o+a]=t[a];return null!==e&&e.push(ii,s),s},argPackAdvance:Ke,readValueFromPointer:Bt,destructorFunction(e){ii(e)}})},mr="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,_r=(e,t)=>{for(var r=e,i=r>>1,n=i+t/2;!(i>=n)&&x[i];)++i;if((r=i<<1)-e>32&&mr)return mr.decode(S.subarray(e,r));for(var s="",o=0;!(o>=t/2);++o){var a=U[e+2*o>>1];if(0==a)break;s+=String.fromCharCode(a)}return s},gr=(e,t,r)=>{if(void 0===r&&(r=2147483647),r<2)return 0;for(var i=t,n=(r-=2)<2*e.length?r/2:e.length,s=0;s<n;++s){var o=e.charCodeAt(s);U[t>>1]=o,t+=2}return U[t>>1]=0,t-i},yr=e=>2*e.length,vr=(e,t)=>{for(var r=0,i="";!(r>=t/4);){var n=k[e+4*r>>2];if(0==n)break;if(++r,n>=65536){var s=n-65536;i+=String.fromCharCode(55296|s>>10,56320|1023&s)}else i+=String.fromCharCode(n)}return i},br=(e,t,r)=>{if(void 0===r&&(r=2147483647),r<4)return 0;for(var i=t,n=i+r-4,s=0;s<e.length;++s){var o=e.charCodeAt(s);if(o>=55296&&o<=57343)o=65536+((1023&o)<<10)|1023&e.charCodeAt(++s);if(k[t>>2]=o,(t+=4)+4>n)break}return k[t>>2]=0,t-i},wr=e=>{for(var t=0,r=0;r<e.length;++r){var i=e.charCodeAt(r);i>=55296&&i<=57343&&++r,t+=4}return t},Er=(e,t,r)=>{var i,n,s,o,a;r=Oe(r),2===t?(i=_r,n=gr,o=yr,s=()=>x,a=1):4===t&&(i=vr,n=br,o=wr,s=()=>A,a=2),Ye(e,{name:r,fromWireType:e=>{for(var r,n=A[e>>2],o=s(),l=e+4,d=0;d<=n;++d){var u=e+4+d*t;if(d==n||0==o[u>>a]){var h=i(l,u-l);void 0===r?r=h:(r+=String.fromCharCode(0),r+=h),l=u+t}}return ii(e),r},toWireType:(e,i)=>{"string"!=typeof i&&He(`Cannot pass non-string to C++ string type ${r}`);var s=o(i),l=ai(4+s+t);return A[l>>2]=s>>a,n(i,l+4,s+t),null!==e&&e.push(ii,l),l},argPackAdvance:Ke,readValueFromPointer:sr,destructorFunction(e){ii(e)}})},Sr=(e,t)=>{Ye(e,{isVoid:!0,name:t=Oe(t),argPackAdvance:0,fromWireType:()=>{},toWireType:(e,t)=>{}})},Ur={},xr=e=>{var t=Ur[e];return void 0===t?Oe(e):t},kr=[],Ar=(e,t,r,i)=>{(e=kr[e])(t=nr.toValue(t),r=xr(r),null,i)},Tr=e=>{var t=kr.length;return kr.push(e),t},Cr=(e,t)=>{var r=$e[e];return void 0===r&&He(t+" has unknown type "+Ht(e)),r},Br=(e,t)=>{for(var r=new Array(e),i=0;i<e;++i)r[i]=Cr(A[t+4*i>>2],"parameter "+i);return r},Fr={},Pr=(e,t)=>{var r=Br(e,t),i=r[0],n=i.name+"_$"+r.slice(1).map((function(e){return e.name})).join("_")+"$",s=Fr[n];if(void 0!==s)return s;for(var o=["retType"],a=[i],l="",d=0;d<e-1;++d)l+=(0!==d?", ":"")+"arg"+d,o.push("argType"+d),a.push(r[1+d]);var u="return function "+wt("methodCaller_"+n)+"(handle, name, destructors, args) {\n",h=0;for(d=0;d<e-1;++d)u+=" var arg"+d+" = argType"+d+".readValueFromPointer(args"+(h?"+"+h:"")+");\n",h+=r[d+1].argPackAdvance;u+=" var rv = handle[name]("+l+");\n";for(d=0;d<e-1;++d)r[d+1].deleteObject&&(u+=" argType"+d+".deleteObject(arg"+d+");\n");i.isVoid||(u+=" return retType.toWireType(destructors, rv);\n"),u+="};\n",o.push(u);var c=qt(Function,o).apply(null,a);return s=Tr(c),Fr[n]=s,s},Dr=(e,t)=>t+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*t:NaN,Ir=()=>{j("")},Lr=()=>Date.now(),Rr=(e,t,r)=>S.copyWithin(e,t,t+r),zr=e=>{j("OOM")},Mr=e=>{S.length,zr()},Or={},Nr=()=>d||"./this.program",$r=()=>{if(!$r.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:Nr()};for(var t in Or)void 0===Or[t]?delete e[t]:e[t]=Or[t];var r=[];for(var t in e)r.push(`${t}=${e[t]}`);$r.strings=r}return $r.strings},Gr=(e,t)=>{for(var r=0;r<e.length;++r)E[t++>>0]=e.charCodeAt(r);E[t>>0]=0},Hr=(e,t)=>{var r=0;return $r().forEach(((i,n)=>{var s=t+r;A[e+4*n>>2]=s,Gr(i,s),r+=i.length+1})),0},Vr=(e,t)=>{var r=$r();A[e>>2]=r.length;var i=0;return r.forEach((e=>i+=e.length+1)),A[t>>2]=i,0};function Wr(e){try{var t=Fe.getStreamFromFD(e);return Ce.close(t),0}catch(e){if(void 0===Ce||"ErrnoError"!==e.name)throw e;return e.errno}}function jr(e,t){try{var r=Fe.getStreamFromFD(e),i=r.tty?2:Ce.isDir(r.mode)?3:Ce.isLink(r.mode)?7:4;return E[t>>0]=i,U[t+2>>1]=0,K=[0,(q=0,+Math.abs(q)>=1?q>0?+Math.floor(q/4294967296)>>>0:~~+Math.ceil((q-+(~~q>>>0))/4294967296)>>>0:0)],k[t+8>>2]=K[0],k[t+12>>2]=K[1],K=[0,(q=0,+Math.abs(q)>=1?q>0?+Math.floor(q/4294967296)>>>0:~~+Math.ceil((q-+(~~q>>>0))/4294967296)>>>0:0)],k[t+16>>2]=K[0],k[t+20>>2]=K[1],0}catch(e){if(void 0===Ce||"ErrnoError"!==e.name)throw e;return e.errno}}var Yr=(e,t,r,i)=>{for(var n=0,s=0;s<r;s++){var o=A[t>>2],a=A[t+4>>2];t+=8;var l=Ce.read(e,E,o,a,i);if(l<0)return-1;if(n+=l,l<a)break;void 0!==i&&(i+=l)}return n};function qr(e,t,r,i){try{var n=Fe.getStreamFromFD(e),s=Yr(n,t,r);return A[i>>2]=s,0}catch(e){if(void 0===Ce||"ErrnoError"!==e.name)throw e;return e.errno}}function Kr(e,t,r,i,n){var s=Dr(t,r);try{if(isNaN(s))return 61;var o=Fe.getStreamFromFD(e);return Ce.llseek(o,s,i),K=[o.position>>>0,(q=o.position,+Math.abs(q)>=1?q>0?+Math.floor(q/4294967296)>>>0:~~+Math.ceil((q-+(~~q>>>0))/4294967296)>>>0:0)],k[n>>2]=K[0],k[n+4>>2]=K[1],o.getdents&&0===s&&0===i&&(o.getdents=null),0}catch(e){if(void 0===Ce||"ErrnoError"!==e.name)throw e;return e.errno}}var Xr=(e,t,r,i)=>{for(var n=0,s=0;s<r;s++){var o=A[t>>2],a=A[t+4>>2];t+=8;var l=Ce.write(e,E,o,a,i);if(l<0)return-1;n+=l,void 0!==i&&(i+=l)}return n};function Zr(e,t,r,i){try{var n=Fe.getStreamFromFD(e),s=Xr(n,t,r);return A[i>>2]=s,0}catch(e){if(void 0===Ce||"ErrnoError"!==e.name)throw e;return e.errno}}var Jr=function(e,t,r,i){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=Ce.nextInode++,this.name=t,this.mode=r,this.node_ops={},this.stream_ops={},this.rdev=i},Qr=365,ei=146;Object.defineProperties(Jr.prototype,{read:{get:function(){return(this.mode&Qr)===Qr},set:function(e){e?this.mode|=Qr:this.mode&=~Qr}},write:{get:function(){return(this.mode&ei)===ei},set:function(e){e?this.mode|=ei:this.mode&=~ei}},isFolder:{get:function(){return Ce.isDir(this.mode)}},isDevice:{get:function(){return Ce.isChrdev(this.mode)}}}),Ce.FSNode=Jr,Ce.createPreloadedFile=ke,Ce.staticInit(),Me(),Le=n.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},Re=n.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}},gt(),ut(),Ft(),It=n.UnboundTypeError=Gt(Error,"UnboundTypeError"),Jt(),ir();var ti={p:oe,B:Pe,v:De,t:ze,n:Xe,r:Wt,q:Xt,f:Zt,C:or,m:dr,c:hr,b:cr,l:pr,h:Er,o:Sr,d:Ar,i:tr,e:Pr,a:Ir,g:Lr,z:Rr,u:Mr,x:Hr,y:Vr,k:Wr,w:jr,A:qr,s:Kr,j:Zr},ri=ie(),ii=e=>(ii=ri.F)(e),ni=()=>(ni=ri.H)(),si=e=>(si=ri.I)(e);n.__embind_initialize_bindings=()=>(n.__embind_initialize_bindings=ri.J)();var oi,ai=e=>(ai=ri.K)(e),li=e=>(li=ri.M)(e);function di(){function e(){oi||(oi=!0,n.calledRun=!0,B||(z(),r(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),M()))}G>0||(R(),G>0||(n.setStatus?(n.setStatus("Running..."),setTimeout((function(){setTimeout((function(){n.setStatus("")}),1),e()}),1)):e()))}if(n.dynCall_viiijj=(e,t,r,i,s,o,a,l)=>(n.dynCall_viiijj=ri.N)(e,t,r,i,s,o,a,l),n.dynCall_jij=(e,t,r,i)=>(n.dynCall_jij=ri.O)(e,t,r,i),n.dynCall_jii=(e,t,r)=>(n.dynCall_jii=ri.P)(e,t,r),n.dynCall_jiji=(e,t,r,i,s)=>(n.dynCall_jiji=ri.Q)(e,t,r,i,s),H=function e(){oi||di(),oi||(H=e)},n.preInit)for("function"==typeof n.preInit&&(n.preInit=[n.preInit]);n.preInit.length>0;)n.preInit.pop()();return di(),t.ready}})(),n=1e-6,s="undefined"!=typeof Float32Array?Float32Array:Array;function o(){var e=new s(16);return s!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function a(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var l,d=function(e,t,r,i,n,s,o){var a=1/(t-r),l=1/(i-n),d=1/(s-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*d,e[11]=0,e[12]=(t+r)*a,e[13]=(n+i)*l,e[14]=(o+s)*d,e[15]=1,e};function u(e,t,r){var i=new s(3);return i[0]=e,i[1]=t,i[2]=r,i}l=new s(3),s!=Float32Array&&(l[0]=0,l[1]=0,l[2]=0);var h=(e,t)=>{t&&e.pixelStorei(e.UNPACK_ALIGNMENT,1);const r=function(){const t=m(e.VERTEX_SHADER,"\n attribute vec4 aVertexPosition;\n attribute vec2 aTexturePosition;\n uniform mat4 uModelMatrix;\n uniform mat4 uViewMatrix;\n uniform mat4 uProjectionMatrix;\n varying lowp vec2 vTexturePosition;\n void main(void) {\n gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * aVertexPosition;\n vTexturePosition = aTexturePosition;\n }\n "),r=m(e.FRAGMENT_SHADER,"\n precision highp float;\n varying highp vec2 vTexturePosition;\n uniform int isyuv;\n uniform sampler2D rgbaTexture;\n uniform sampler2D yTexture;\n uniform sampler2D uTexture;\n uniform sampler2D vTexture;\n\n const mat4 YUV2RGB = mat4( 1.1643828125, 0, 1.59602734375, -.87078515625,\n 1.1643828125, -.39176171875, -.81296875, .52959375,\n 1.1643828125, 2.017234375, 0, -1.081390625,\n 0, 0, 0, 1);\n\n\n void main(void) {\n\n if (isyuv>0) {\n\n highp float y = texture2D(yTexture, vTexturePosition).r;\n highp float u = texture2D(uTexture, vTexturePosition).r;\n highp float v = texture2D(vTexture, vTexturePosition).r;\n gl_FragColor = vec4(y, u, v, 1) * YUV2RGB;\n\n } else {\n gl_FragColor = texture2D(rgbaTexture, vTexturePosition);\n }\n }\n "),i=e.createProgram();if(e.attachShader(i,t),e.attachShader(i,r),e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS))return console.log("Unable to initialize the shader program: "+e.getProgramInfoLog(i)),null;return i}();let i={program:r,attribLocations:{vertexPosition:e.getAttribLocation(r,"aVertexPosition"),texturePosition:e.getAttribLocation(r,"aTexturePosition")},uniformLocations:{projectionMatrix:e.getUniformLocation(r,"uProjectionMatrix"),modelMatrix:e.getUniformLocation(r,"uModelMatrix"),viewMatrix:e.getUniformLocation(r,"uViewMatrix"),rgbatexture:e.getUniformLocation(r,"rgbaTexture"),ytexture:e.getUniformLocation(r,"yTexture"),utexture:e.getUniformLocation(r,"uTexture"),vtexture:e.getUniformLocation(r,"vTexture"),isyuv:e.getUniformLocation(r,"isyuv")}},s=function(){const t=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,t);e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,-1,-1,1,1,-1,-1,1,-1]),e.STATIC_DRAW);var r=[];r=r.concat([0,1],[1,1],[1,0],[0,0]);const i=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,i),e.bufferData(e.ARRAY_BUFFER,new Float32Array(r),e.STATIC_DRAW);const n=e.createBuffer();e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n);return e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Uint16Array([0,1,2,0,2,3]),e.STATIC_DRAW),{position:t,texPosition:i,indices:n}}(),l=p(),h=p(),c=p(),f=p();function p(){let t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),t}function m(t,r){const i=e.createShader(t);return e.shaderSource(i,r),e.compileShader(i),e.getShaderParameter(i,e.COMPILE_STATUS)?i:(console.log("An error occurred compiling the shaders: "+e.getShaderInfoLog(i)),e.deleteShader(i),null)}function _(t,r){e.viewport(0,0,t,r),e.clearColor(0,0,0,0),e.clearDepth(1),e.enable(e.DEPTH_TEST),e.depthFunc(e.LEQUAL),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT);const l=o();d(l,-1,1,-1,1,.1,100);const p=o();a(p);const m=o();!function(e,t,r,i){var s,o,l,d,u,h,c,f,p,m,_=t[0],g=t[1],y=t[2],v=i[0],b=i[1],w=i[2],E=r[0],S=r[1],U=r[2];Math.abs(_-E)<n&&Math.abs(g-S)<n&&Math.abs(y-U)<n?a(e):(c=_-E,f=g-S,p=y-U,s=b*(p*=m=1/Math.hypot(c,f,p))-w*(f*=m),o=w*(c*=m)-v*p,l=v*f-b*c,(m=Math.hypot(s,o,l))?(s*=m=1/m,o*=m,l*=m):(s=0,o=0,l=0),d=f*l-p*o,u=p*s-c*l,h=c*o-f*s,(m=Math.hypot(d,u,h))?(d*=m=1/m,u*=m,h*=m):(d=0,u=0,h=0),e[0]=s,e[1]=d,e[2]=c,e[3]=0,e[4]=o,e[5]=u,e[6]=f,e[7]=0,e[8]=l,e[9]=h,e[10]=p,e[11]=0,e[12]=-(s*_+o*g+l*y),e[13]=-(d*_+u*g+h*y),e[14]=-(c*_+f*g+p*y),e[15]=1)}(m,u(0,0,0),u(0,0,-1),u(0,1,0));{const t=3,r=e.FLOAT,n=!1,o=0,a=0;e.bindBuffer(e.ARRAY_BUFFER,s.position),e.vertexAttribPointer(i.attribLocations.vertexPosition,t,r,n,o,a),e.enableVertexAttribArray(i.attribLocations.vertexPosition)}{const t=2,r=e.FLOAT,n=!1,o=0,a=0;e.bindBuffer(e.ARRAY_BUFFER,s.texPosition),e.vertexAttribPointer(i.attribLocations.texturePosition,t,r,n,o,a),e.enableVertexAttribArray(i.attribLocations.texturePosition)}e.activeTexture(e.TEXTURE0+3),e.bindTexture(e.TEXTURE_2D,h),e.activeTexture(e.TEXTURE0+4),e.bindTexture(e.TEXTURE_2D,c),e.activeTexture(e.TEXTURE0+5),e.bindTexture(e.TEXTURE_2D,f),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,s.indices),e.useProgram(i.program),e.uniformMatrix4fv(i.uniformLocations.projectionMatrix,!1,l),e.uniformMatrix4fv(i.uniformLocations.modelMatrix,!1,p),e.uniformMatrix4fv(i.uniformLocations.viewMatrix,!1,m),e.uniform1i(i.uniformLocations.rgbatexture,2),e.uniform1i(i.uniformLocations.ytexture,3),e.uniform1i(i.uniformLocations.utexture,4),e.uniform1i(i.uniformLocations.vtexture,5),e.uniform1i(i.uniformLocations.isyuv,1);{const t=6,r=e.UNSIGNED_SHORT,i=0;e.drawElements(e.TRIANGLES,t,r,i)}}return{render:function(t,r,i,n,s){e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,h),e.texImage2D(e.TEXTURE_2D,0,e.LUMINANCE,t,r,0,e.LUMINANCE,e.UNSIGNED_BYTE,i),e.activeTexture(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,c),e.texImage2D(e.TEXTURE_2D,0,e.LUMINANCE,t/2,r/2,0,e.LUMINANCE,e.UNSIGNED_BYTE,n),e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,f),e.texImage2D(e.TEXTURE_2D,0,e.LUMINANCE,t/2,r/2,0,e.LUMINANCE,e.UNSIGNED_BYTE,s),_(t,r)},renderYUV:function(t,r,i){let n=i.slice(0,t*r),s=i.slice(t*r,t*r*5/4),o=i.slice(t*r*5/4,t*r*3/2);e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,h),e.texImage2D(e.TEXTURE_2D,0,e.LUMINANCE,t,r,0,e.LUMINANCE,e.UNSIGNED_BYTE,n),e.activeTexture(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,c),e.texImage2D(e.TEXTURE_2D,0,e.LUMINANCE,t/2,r/2,0,e.LUMINANCE,e.UNSIGNED_BYTE,s),e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,f),e.texImage2D(e.TEXTURE_2D,0,e.LUMINANCE,t/2,r/2,0,e.LUMINANCE,e.UNSIGNED_BYTE,o),_(t,r)},destroy:function(){e.deleteProgram(i.program),e.deleteBuffer(s.position),e.deleteBuffer(s.texPosition),e.deleteBuffer(s.indices),e.deleteTexture(l),e.deleteTexture(h),e.deleteTexture(c),e.deleteTexture(f),i=null,s=null,l=null,h=null,c=null,f=null}}};const c=1,f=2,p="fetch",m="websocket",_="player",g="playbackTF",y="mp4",v="debug",b="warn",w=36e5,E=4080,S={playType:_,container:"",videoBuffer:1e3,videoBufferDelay:1e3,networkDelay:1e4,isResize:!0,isFullResize:!1,isFlv:!1,isHls:!1,isFmp4:!1,isFmp4Private:!1,isWebrtc:!1,isWebrtcForZLM:!1,isWebrtcForSRS:!1,isWebrtcForOthers:!1,isNakedFlow:!1,isMpeg4:!1,isAliyunRtc:!1,debug:!1,debugLevel:b,debugUuid:"",isMulti:!0,multiIndex:-1,hotKey:!1,loadingTimeout:10,heartTimeout:10,timeout:10,pageVisibilityHiddenTimeout:300,loadingTimeoutReplay:!0,heartTimeoutReplay:!0,loadingTimeoutReplayTimes:3,heartTimeoutReplayTimes:3,heartTimeoutReplayUseLastFrameShow:!0,replayUseLastFrameShow:!0,replayShowLoadingIcon:!1,supportDblclickFullscreen:!1,showBandwidth:!1,showPerformance:!1,mseCorrectTimeDuration:20,keepScreenOn:!0,isNotMute:!1,hasAudio:!0,hasVideo:!0,operateBtns:{fullscreen:!1,screenshot:!1,play:!1,audio:!1,record:!1,ptz:!1,quality:!1,zoom:!1,close:!1,scale:!1,performance:!1,logSave:!1,aiFace:!1,aiObject:!1,aiOcclusion:!1,fullscreenFn:null,fullscreenExitFn:null,screenshotFn:null,playFn:null,pauseFn:null,recordFn:null,recordStopFn:null},extendOperateBtns:[],contextmenuBtns:[],watermarkConfig:{},controlAutoHide:!1,hasControl:!1,loadingIcon:!0,loadingIconStyle:{},loadingText:"",background:"",backgroundLoadingShow:!1,loadingBackground:"",loadingBackgroundWidth:0,loadingBackgroundHeight:0,decoder:"decoder-pro.js",decoderAudio:"decoder-pro-audio.js",decoderHard:"decoder-pro-hard.js",wasmMp4RecorderDecoder:"jessibuca-pro-mp4-recorder-decoder.js",decoderWASM:"",isDecoderUseCDN:!1,url:"",rotate:0,mirrorRotate:"none",aspectRatio:"default",playbackConfig:{playList:[],fps:"",showControl:!0,controlType:"normal",duration:0,startTime:"",showRateBtn:!1,rateConfig:[],showPrecision:"",showPrecisionBtn:!0,isCacheBeforeDecodeForFpsRender:!1,uiUsePlaybackPause:!1,isPlaybackPauseClearCache:!0,isUseFpsRender:!1,isUseLocalCalculateTime:!1,localOneFrameTimestamp:40,supportWheel:!1,useWCS:!1,useMSE:!1},qualityConfig:[],defaultStreamQuality:"",scaleConfig:["拉伸","缩放","正常"],forceNoOffscreen:!0,hiddenAutoPause:!1,protocol:f,demuxType:"flv",useWasm:!1,useMSE:!1,useWCS:!1,useSIMD:!0,useMThreading:!1,wcsUseVideoRender:!0,wcsUseWebgl2Render:!0,wasmUseVideoRender:!0,mseUseCanvasRender:!1,hlsUseCanvasRender:!1,webrtcUseCanvasRender:!1,useOffscreen:!1,useWebGPU:!1,mseDecodeErrorReplay:!0,wcsDecodeErrorReplay:!0,wasmDecodeErrorReplay:!0,simdDecodeErrorReplay:!0,simdDecodeErrorReplayType:"wasm",autoWasm:!0,decoderErrorAutoWasm:!0,hardDecodingNotSupportAutoWasm:!0,webglAlignmentErrorReplay:!0,webglContextLostErrorReplay:!0,openWebglAlignment:!1,syncAudioAndVideo:!0,syncAudioAndVideoDiff:400,playbackDelayTime:1e3,playbackFps:25,playbackForwardMaxRateDecodeIFrame:4,playbackCurrentTimeMove:!0,useVideoRender:!0,useCanvasRender:!1,networkDelayTimeoutReplay:!1,recordType:y,checkFirstIFrame:!0,nakedFlowFps:25,audioEngine:null,isShowRecordingUI:!0,isShowZoomingUI:!0,useFaceDetector:!1,useObjectDetector:!1,useImageDetector:!1,useOcclusionDetector:!1,ptzClickType:"click",ptzStopEmitDelay:.3,ptzZoomShow:!1,ptzApertureShow:!1,ptzFocusShow:!1,ptzMoreArrowShow:!1,weiXinInAndroidAudioBufferSize:4800,isM7sCrypto:!1,m7sCryptoAudio:!1,isSm4Crypto:!1,isXorCrypto:!1,sm4CryptoKey:"",m7sCryptoKey:"",xorCryptoKey:"",cryptoKey:"",cryptoIV:"",cryptoKeyUrl:"",autoResize:!1,useWebFullScreen:!1,ptsMaxDiff:3600,aiFaceDetectLevel:2,aiFaceDetectWidth:240,aiFaceDetectShowRect:!0,aiFaceDetectInterval:1e3,aiFaceDetectRectConfig:{},aiObjectDetectLevel:2,aiObjectDetectWidth:240,aiObjectDetectShowRect:!0,aiObjectDetectInterval:1e3,aiObjectDetectRectConfig:{},aiOcclusionDetectInterval:1e3,aiImageDetectDrop:!1,aiImageDetectActive:!1,videoRenderSupportScale:!0,mediaSourceTsIsMaxDiffReplay:!0,controlHtml:"",isH265:!1,isWebrtcH265:!1,supportLockScreenPlayAudio:!0,supportHls265:!0,isEmitSEI:!1,pauseAndNextPlayUseLastFrameShow:!1,demuxUseWorker:!0,playFailedAndReplay:!0,showMessageConfig:{webglAlignmentError:"Webgl 渲染失败",webglContextLostError:"webgl 上下文丢失",mediaSourceH265NotSupport:"不支持硬解码H265",mediaSourceFull:"缓冲区已满",mediaSourceAppendBufferError:"初始化解码器失败",mseSourceBufferError:"解码失败",mseAddSourceBufferError:"初始化解码器失败",mediaSourceDecoderConfigurationError:"初始化解码器失败",mediaSourceTsIsMaxDiff:"流异常",mseWidthOrHeightChange:"流异常",mediaSourceAudioG711NotSupport:"硬解码不支持G711a/u音频格式",mediaSourceUseCanvasRenderPlayFailed:"MediaSource解码使用canvas渲染失败",webcodecsH265NotSupport:"不支持硬解码H265",webcodecsUnsupportedConfigurationError:"初始化解码器失败",webcodecsDecodeConfigureError:"初始化解码器失败",webcodecsDecodeError:"解码失败",wcsWidthOrHeightChange:"解码失败",wasmDecodeError:"解码失败",simdDecodeError:"解码失败",wasmWidthOrHeightChange:"流异常",wasmUseVideoRenderError:"video自动渲染失败",videoElementPlayingFailed:"video自动渲染失败",simdH264DecodeVideoWidthIsTooLarge:"不支持该分辨率的视频",networkDelayTimeout:"网络超时重播失败",fetchError:"请求失败",streamEnd:"请求结束",websocketError:"请求失败",webrtcError:"请求失败",hlsError:"请求失败",decoderWorkerInitError:"初始化worker失败",videoElementPlayingFailedForWebrtc:"video自动渲染失败",videoInfoError:"解析视频分辨率失败",webrtcStreamH265:"webrtc不支持H265",hlsV2Mp4NotSupport:"Hls解码器不支持解码",delayTimeout:"播放超时重播失败",loadingTimeout:"加载超时重播失败",loadingTimeoutRetryEnd:"加载超时重播失败",delayTimeoutRetryEnd:"播放超时重播失败"},videoElementPlayingFailedReplay:!0,mp4RecordUseWasm:!0,mseAutoCleanupSourceBuffer:!0,mseAutoCleanupMaxBackwardDuration:30,mseAutoCleanupMinBackwardDuration:10,widthOrHeightChangeReplay:!0,simdH264DecodeVideoWidthIsTooLargeReplay:!0,mediaSourceAudioG711NotSupportReplay:!0,mediaSourceAudioInitTimeoutReplay:!0,mediaSourceUseCanvasRenderPlayFailedReplay:!0,mediaSourceUseCanvasRenderPlayFailedReplayType:"video",ghostWatermarkConfig:{on:5,off:5,content:"",fontSize:12,color:"white",opacity:.15,speed:.2},dynamicWatermarkConfig:{content:"",speed:.2,fontSize:12,color:"white",opacity:.15},isDropSameTimestampGop:!1,mseDecodeAudio:!0,nakedFlowH265DemuxUseNew:!0},U="init",x="initVideo",k="render",A="playAudio",T="initAudio",C="audioCode",B="audioNalu",F="audioAACSequenceHeader",P="videoCode",D="videoCodec",I="videoNalu",L="videoPayload",R="audioPayload",z="workerFetch",M="iframeIntervalTs",O="isDropping",N="workerEnd",$="playbackStreamVideoFps",G="wasmWidthOrHeightChange",H="simdDecodeError",V="simdH264DecodeVideoWidthIsTooLarge",W="closeEnd",j="tempStream",Y="videoSEI",q="flvScriptData",K="aacSequenceHeader",X="videoSequenceHeader",Z="flvBufferData",J="checkFirstIFrame",Q=1,ee=2,te=8,re=9,ie=18,ne="init",se="decode",oe="audioDecode",ae="videoDecode",le="close",de="updateConfig",ue="clearBuffer",he="fetchStream",ce="sendWsMessage",fe="streamEnd",pe="streamRate",me="streamAbps",_e="streamVbps",ge="streamDts",ye="streamSuccess",ve="streamStats",be="networkDelayTimeout",we="websocketOpen",Ee={playError:"playIsNotPauseOrUrlIsNull",fetchError:"fetchError",websocketError:"websocketError",webcodecsH265NotSupport:"webcodecsH265NotSupport",webcodecsDecodeError:"webcodecsDecodeError",webcodecsUnsupportedConfigurationError:"webcodecsUnsupportedConfigurationError",webcodecsDecodeConfigureError:"webcodecsDecodeConfigureError",mediaSourceH265NotSupport:"mediaSourceH265NotSupport",mediaSourceAudioG711NotSupport:"mediaSourceAudioG711NotSupport",mediaSourceAudioInitTimeout:"mediaSourceAudioInitTimeout",mediaSourceDecoderConfigurationError:"mediaSourceDecoderConfigurationError",mediaSourceFull:"mseSourceBufferFull",mseSourceBufferError:"mseSourceBufferError",mseAddSourceBufferError:"mseAddSourceBufferError",mediaSourceAppendBufferError:"mediaSourceAppendBufferError",mediaSourceTsIsMaxDiff:"mediaSourceTsIsMaxDiff",mediaSourceUseCanvasRenderPlayFailed:"mediaSourceUseCanvasRenderPlayFailed",mediaSourceBufferedIsZeroError:"mediaSourceBufferedIsZeroError",wasmDecodeError:"wasmDecodeError",wasmUseVideoRenderError:"wasmUseVideoRenderError",hlsError:"hlsError",hlsV2Mp4NotSupport:"hlsV2Mp4NotSupport",webrtcError:"webrtcError",webrtcClosed:"webrtcClosed",webrtcIceCandidateError:"webrtcIceCandidateError",webglAlignmentError:"webglAlignmentError",wasmWidthOrHeightChange:"wasmWidthOrHeightChange",mseWidthOrHeightChange:"mseWidthOrHeightChange",wcsWidthOrHeightChange:"wcsWidthOrHeightChange",widthOrHeightChange:"widthOrHeightChange",tallWebsocketClosedByError:"tallWebsocketClosedByError",flvDemuxBufferSizeTooLarge:"flvDemuxBufferSizeTooLarge",wasmDecodeVideoNoResponseError:"wasmDecodeVideoNoResponseError",audioChannelError:"audioChannelError",simdH264DecodeVideoWidthIsTooLarge:"simdH264DecodeVideoWidthIsTooLarge",simdDecodeError:"simdDecodeError",webglContextLostError:"webglContextLostError",videoElementPlayingFailed:"videoElementPlayingFailed",videoElementPlayingFailedForWebrtc:"videoElementPlayingFailedForWebrtc",decoderWorkerInitError:"decoderWorkerInitError",videoInfoError:"videoInfoError",videoCodecIdError:"videoCodecIdError",streamEnd:fe,delayTimeout:"delayTimeout",loadingTimeout:"loadingTimeout",networkDelayTimeout:be,aliyunRtcError:"aliyunRtcError",...{talkStreamError:"talkStreamError",talkStreamClose:"talkStreamClose"}},Se=1,Ue=7,xe=12,ke=99,Ae="H264(AVC)",Te="H265(HEVC)",Ce=10,Be=7,Fe=8,Pe=2,De=7,Ie=8,Le=5,Re=6,ze=19,Me=20,Oe=32,Ne=33,$e=34,Ge=39,He=39,Ve=40,We="key",je="delta",Ye="hevc",qe="AbortError",Ke=0,Xe=1,Ze=1,Je="idle",Qe="buffering",et="complete",tt=128,rt=0,it=1,nt=3,st=16;function ot(e,t){return e(t={exports:{}},t.exports),t.exports}function at(e){let{profile:t,sampleRate:r,channel:i}=e;return new Uint8Array([175,0,t<<3|(14&r)>>1,(1&r)<<7|i<<3])}function lt(e){return dt(e)&&e[1]===Ke}function dt(e){return e[0]>>4===Ce}ot((function(e){!function(){var t="undefined"!=typeof window&&void 0!==window.document?window.document:{},r=e.exports,i=function(){for(var e,r=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],i=0,n=r.length,s={};i<n;i++)if((e=r[i])&&e[1]in t){for(i=0;i<e.length;i++)s[r[0][i]]=e[i];return s}return!1}(),n={change:i.fullscreenchange,error:i.fullscreenerror},s={request:function(e,r){return new Promise(function(n,s){var o=function(){this.off("change",o),n()}.bind(this);this.on("change",o);var a=(e=e||t.documentElement)[i.requestFullscreen](r);a instanceof Promise&&a.then(o).catch(s)}.bind(this))},exit:function(){return new Promise(function(e,r){if(this.isFullscreen){var n=function(){this.off("change",n),e()}.bind(this);this.on("change",n);var s=t[i.exitFullscreen]();s instanceof Promise&&s.then(n).catch(r)}else e()}.bind(this))},toggle:function(e,t){return this.isFullscreen?this.exit():this.request(e,t)},onchange:function(e){this.on("change",e)},onerror:function(e){this.on("error",e)},on:function(e,r){var i=n[e];i&&t.addEventListener(i,r,!1)},off:function(e,r){var i=n[e];i&&t.removeEventListener(i,r,!1)},raw:i};i?(Object.defineProperties(s,{isFullscreen:{get:function(){return Boolean(t[i.fullscreenElement])}},element:{enumerable:!0,get:function(){return t[i.fullscreenElement]}},isEnabled:{enumerable:!0,get:function(){return Boolean(t[i.fullscreenEnabled])}}}),r?e.exports=s:window.screenfull=s):r?e.exports={isEnabled:!1}:window.screenfull={isEnabled:!1}}()})).isEnabled;const ut=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];function ht(){return(new Date).getTime()}function ct(e,t,r){return Math.max(Math.min(e,Math.max(t,r)),Math.min(t,r))}function ft(){return performance&&"function"==typeof performance.now?performance.now():Date.now()}function pt(e){let t=0,r=ft();return i=>{if(n=i,"[object Number]"!==Object.prototype.toString.call(n))return;var n;t+=i;const s=ft(),o=s-r;o>=1e3&&(e(t/o*1e3),r=s,t=0)}}(()=>{try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){const e=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(e instanceof WebAssembly.Module)return new WebAssembly.Instance(e)instanceof WebAssembly.Instance}}catch(e){}})();function mt(e){let t=e.subarray(1,4),r="avc1.";for(let e=0;e<3;e++){let i=t[e].toString(16);i.length<2&&(i="0"+i),r+=i}return{codec:r,description:e}}function _t(e){return null==e}function gt(e){return!_t(e)}function yt(e){return"function"==typeof e}function vt(e){let t=null,r=31&e[0];return r!==De&&r!==Ie||(t=Ae),t||(r=(126&e[0])>>1,r!==Oe&&r!==Ne&&r!==$e||(t=Te)),t}function bt(){return"undefined"!=typeof WritableStream}function wt(e){e.close()}function Et(e,t){t&&(e=e.filter((e=>e.type&&e.type===t)));let r=e[0],i=null,n=1;if(e.length>0){let t=e[1];t&&t.ts-r.ts>1e5&&(r=t,n=2)}if(r)for(let s=n;s<e.length;s++){let n=e[s];if(t&&n.type&&n.type!==t&&(n=null),n){if(n.ts-r.ts>=1e3){e[s-1].ts-r.ts<1e3&&(i=s+1)}}}return i}function St(e){return e.ok&&e.status>=200&&e.status<=299}function Ut(){return function(e){let t="";if("object"==typeof e)try{t=JSON.stringify(e),t=JSON.parse(t)}catch(r){t=e}else t=e;return t}(S)}function xt(e){return e[0]>>4===Xe&&e[1]===Ke}function kt(e){return!0===e||"true"===e}function At(e){return!0!==e&&"true"!==e}var Tt=function(e,t,r,i){return new(r||(r=Promise))((function(n,s){function o(e){try{l(i.next(e))}catch(e){s(e)}}function a(e){try{l(i.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}l((i=i.apply(e,t||[])).next())}))};const Ct=Symbol(32),Bt=Symbol(16),Ft=Symbol(8);class Pt{constructor(e){this.g=e,this.consumed=0,e&&(this.need=e.next().value)}setG(e){this.g=e,this.demand(e.next().value,!0)}consume(){this.buffer&&this.consumed&&(this.buffer.copyWithin(0,this.consumed),this.buffer=this.buffer.subarray(0,this.buffer.length-this.consumed),this.consumed=0)}demand(e,t){return t&&this.consume(),this.need=e,this.flush()}read(e){return Tt(this,void 0,void 0,(function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise(((t,r)=>{var i;this.reject=r,this.resolve=e=>{delete this.lastReadPromise,delete this.resolve,delete this.need,t(e)};this.demand(e,!0)||null===(i=this.pull)||void 0===i||i.call(this,e)}))}))}readU32(){return this.read(Ct)}readU16(){return this.read(Bt)}readU8(){return this.read(Ft)}close(){var e;this.g&&this.g.return(),this.buffer&&this.buffer.subarray(0,0),null===(e=this.reject)||void 0===e||e.call(this,new Error("EOF")),delete this.lastReadPromise}flush(){if(!this.buffer||!this.need)return;let e=null;const t=this.buffer.subarray(this.consumed);let r=0;const i=e=>t.length<(r=e);if("number"==typeof this.need){if(i(this.need))return;e=t.subarray(0,r)}else if(this.need===Ct){if(i(4))return;e=t[0]<<24|t[1]<<16|t[2]<<8|t[3]}else if(this.need===Bt){if(i(2))return;e=t[0]<<8|t[1]}else if(this.need===Ft){if(i(1))return;e=t[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(i(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(t.subarray(0,r)),e=this.need}else if(this.g)return void this.g.throw(new Error("Unsupported type"))}else{if(i(this.need.byteLength))return;new Uint8Array(this.need).set(t.subarray(0,r)),e=this.need}return this.consumed+=r,this.g?this.demand(this.g.next(e).value,!0):this.resolve&&this.resolve(e),e}write(e){if(e instanceof Uint8Array?this.malloc(e.length).set(e):"buffer"in e?this.malloc(e.byteLength).set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):this.malloc(e.byteLength).set(new Uint8Array(e)),!this.g&&!this.resolve)return new Promise((e=>this.pull=e));this.flush()}writeU32(e){this.malloc(4).set([e>>24&255,e>>16&255,e>>8&255,255&e]),this.flush()}writeU16(e){this.malloc(2).set([e>>8&255,255&e]),this.flush()}writeU8(e){this.malloc(1)[0]=e,this.flush()}malloc(e){if(this.buffer){const t=this.buffer.length,r=t+e;if(r<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,r);else{const e=new Uint8Array(r);e.set(this.buffer),this.buffer=e}return this.buffer.subarray(t,r)}return this.buffer=new Uint8Array(e),this.buffer}}Pt.U32=Ct,Pt.U16=Bt,Pt.U8=Ft;class Dt{constructor(e){this.log=function(t){if(e._opt.debug&&e._opt.debugLevel==v){const s=e._opt.debugUuid?`[${e._opt.debugUuid}]`:"";for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];console.log(`JbPro${s}[✅✅✅][${t}]`,...i)}},this.warn=function(t){if(e._opt.debug&&(e._opt.debugLevel==v||e._opt.debugLevel==b)){const s=e._opt.debugUuid?`[${e._opt.debugUuid}]`:"";for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];console.log(`JbPro${s}[❗❗❗][${t}]`,...i)}},this.error=function(t){const r=e._opt.debugUuid?`[${e._opt.debugUuid}]`:"";for(var i=arguments.length,n=new Array(i>1?i-1:0),s=1;s<i;s++)n[s-1]=arguments[s];console.error(`JbPro${r}[❌❌❌][${t}]`,...n)}}}class It{constructor(e){this._buffer=e,this._buffer_index=0,this._total_bytes=e.byteLength,this._total_bits=8*e.byteLength,this._current_word=0,this._current_word_bits_left=0}destroy(){this._buffer=null}_fillCurrentWord(){let e=this._total_bytes-this._buffer_index;if(e<=0)return void console.error("ExpGolomb: _fillCurrentWord() but no bytes available",this._total_bytes,this._buffer_index);let t=Math.min(4,e),r=new Uint8Array(4);r.set(this._buffer.subarray(this._buffer_index,this._buffer_index+t)),this._current_word=new DataView(r.buffer).getUint32(0,!1),this._buffer_index+=t,this._current_word_bits_left=8*t}readBits(e){if(e>32&&console.error("ExpGolomb: readBits() bits exceeded max 32bits!"),e<=this._current_word_bits_left){let t=this._current_word>>>32-e;return this._current_word<<=e,this._current_word_bits_left-=e,t}let t=this._current_word_bits_left?this._current_word:0;t>>>=32-this._current_word_bits_left;let r=e-this._current_word_bits_left;this._fillCurrentWord();let i=Math.min(r,this._current_word_bits_left),n=this._current_word>>>32-i;return this._current_word<<=i,this._current_word_bits_left-=i,t=t<<i|n,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 Lt{static _ebsp2rbsp(e){let t=e,r=t.byteLength,i=new Uint8Array(r),n=0;for(let e=0;e<r;e++)e>=2&&3===t[e]&&0===t[e-1]&&0===t[e-2]||(i[n]=t[e],n++);return new Uint8Array(i.buffer,0,n)}static parseSPS(e){let t=Lt._ebsp2rbsp(e),r=new It(t);r.readByte();let i=r.readByte();r.readByte();let n=r.readByte();r.readUEG();let s=Lt.getProfileString(i),o=Lt.getLevelString(n),a=1,l=420,d=[0,420,422,444],u=8;if((100===i||110===i||122===i||244===i||44===i||83===i||86===i||118===i||128===i||138===i||144===i)&&(a=r.readUEG(),3===a&&r.readBits(1),a<=3&&(l=d[a]),u=r.readUEG()+8,r.readUEG(),r.readBits(1),r.readBool())){let e=3!==a?8:12;for(let t=0;t<e;t++)r.readBool()&&(t<6?Lt._skipScalingList(r,16):Lt._skipScalingList(r,64))}r.readUEG();let h=r.readUEG();if(0===h)r.readUEG();else if(1===h){r.readBits(1),r.readSEG(),r.readSEG();let e=r.readUEG();for(let t=0;t<e;t++)r.readSEG()}let c=r.readUEG();r.readBits(1);let f=r.readUEG(),p=r.readUEG(),m=r.readBits(1);0===m&&r.readBits(1),r.readBits(1);let _=0,g=0,y=0,v=0;r.readBool()&&(_=r.readUEG(),g=r.readUEG(),y=r.readUEG(),v=r.readUEG());let b=1,w=1,E=0,S=!0,U=0,x=0;if(r.readBool()){if(r.readBool()){let e=r.readByte(),t=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],i=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];e>0&&e<16?(b=t[e-1],w=i[e-1]):255===e&&(b=r.readByte()<<8|r.readByte(),w=r.readByte()<<8|r.readByte())}if(r.readBool()&&r.readBool(),r.readBool()&&(r.readBits(4),r.readBool()&&r.readBits(24)),r.readBool()&&(r.readUEG(),r.readUEG()),r.readBool()){let e=r.readBits(32),t=r.readBits(32);S=r.readBool(),U=t,x=2*e,E=U/x}}let k=1;1===b&&1===w||(k=b/w);let A=0,T=0;if(0===a)A=1,T=2-m;else{A=3===a?1:2,T=(1===a?2:1)*(2-m)}let C=16*(f+1),B=16*(p+1)*(2-m);C-=(_+g)*A,B-=(y+v)*T;let F=Math.ceil(C*k);return r.destroy(),r=null,{profile_string:s,level_string:o,bit_depth:u,ref_frames:c,chroma_format:l,chroma_format_string:Lt.getChromaFormatString(l),frame_rate:{fixed:S,fps:E,fps_den:x,fps_num:U},sar_ratio:{width:b,height:w},codec_size:{width:C,height:B},present_size:{width:F,height:B}}}static parseSPS$2(e){let t=e.subarray(1,4),r="avc1.";for(let e=0;e<3;e++){let i=t[e].toString(16);i.length<2&&(i="0"+i),r+=i}let i=Lt._ebsp2rbsp(e),n=new It(i);n.readByte();let s=n.readByte();n.readByte();let o=n.readByte();n.readUEG();let a=Lt.getProfileString(s),l=Lt.getLevelString(o),d=1,u=420,h=[0,420,422,444],c=8,f=8;if((100===s||110===s||122===s||244===s||44===s||83===s||86===s||118===s||128===s||138===s||144===s)&&(d=n.readUEG(),3===d&&n.readBits(1),d<=3&&(u=h[d]),c=n.readUEG()+8,f=n.readUEG()+8,n.readBits(1),n.readBool())){let e=3!==d?8:12;for(let t=0;t<e;t++)n.readBool()&&(t<6?Lt._skipScalingList(n,16):Lt._skipScalingList(n,64))}n.readUEG();let p=n.readUEG();if(0===p)n.readUEG();else if(1===p){n.readBits(1),n.readSEG(),n.readSEG();let e=n.readUEG();for(let t=0;t<e;t++)n.readSEG()}let m=n.readUEG();n.readBits(1);let _=n.readUEG(),g=n.readUEG(),y=n.readBits(1);0===y&&n.readBits(1),n.readBits(1);let v=0,b=0,w=0,E=0;n.readBool()&&(v=n.readUEG(),b=n.readUEG(),w=n.readUEG(),E=n.readUEG());let S=1,U=1,x=0,k=!0,A=0,T=0;if(n.readBool()){if(n.readBool()){let e=n.readByte(),t=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],r=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];e>0&&e<16?(S=t[e-1],U=r[e-1]):255===e&&(S=n.readByte()<<8|n.readByte(),U=n.readByte()<<8|n.readByte())}if(n.readBool()&&n.readBool(),n.readBool()&&(n.readBits(4),n.readBool()&&n.readBits(24)),n.readBool()&&(n.readUEG(),n.readUEG()),n.readBool()){let e=n.readBits(32),t=n.readBits(32);k=n.readBool(),A=t,T=2*e,x=A/T}}let C=1;1===S&&1===U||(C=S/U);let B=0,F=0;if(0===d)B=1,F=2-y;else{B=3===d?1:2,F=(1===d?2:1)*(2-y)}let P=16*(_+1),D=16*(g+1)*(2-y);P-=(v+b)*B,D-=(w+E)*F;let I=Math.ceil(P*C);return n.destroy(),n=null,{codec_mimetype:r,profile_idc:s,level_idc:o,profile_string:a,level_string:l,chroma_format_idc:d,bit_depth:c,bit_depth_luma:c,bit_depth_chroma:f,ref_frames:m,chroma_format:u,chroma_format_string:Lt.getChromaFormatString(u),frame_rate:{fixed:k,fps:x,fps_den:T,fps_num:A},sar_ratio:{width:S,height:U},codec_size:{width:P,height:D},present_size:{width:I,height:D}}}static _skipScalingList(e,t){let r=8,i=8,n=0;for(let s=0;s<t;s++)0!==i&&(n=e.readSEG(),i=(r+n+256)%256),r=0===i?r:i}static getProfileString(e){switch(e){case 66:return"Baseline";case 77:return"Main";case 88:return"Extended";case 100:return"High";case 110:return"High10";case 122:return"High422";case 244:return"High444";default:return"Unknown"}}static getLevelString(e){return(e/10).toFixed(1)}static getChromaFormatString(e){switch(e){case 420:return"4:2:0";case 422:return"4:2:2";case 444:return"4:4:4";default:return"Unknown"}}}class Rt{constructor(e){this.buffer=e,this.buflen=e.length,this.bufpos=0,this.bufoff=0,this.iserro=!1}read(e){let t=0,r=0;for(;e;){if(e<0||this.bufpos>=this.buflen)return this.iserro=!0,0;this.iserro=!1,r=this.bufoff+e>8?8-this.bufoff:e,t<<=r,t+=this.buffer[this.bufpos]>>8-this.bufoff-r&255>>8-r,this.bufoff+=r,e-=r,8==this.bufoff&&(this.bufpos++,this.bufoff=0)}return t}look(e){let t=this.bufpos,r=this.bufoff,i=this.read(e);return this.bufpos=t,this.bufoff=r,i}read_golomb(){let e;for(e=0;0===this.read(1)&&!this.iserro;e++);return(1<<e)+this.read(e)-1}}function zt(e){const t={},r=new DataView(e.buffer);let i=r.getUint8(0),n=r.getUint8(1);if(r.getUint8(2),r.getUint8(3),1!==i||0===n)return{};const s=1+(3&r.getUint8(4));if(3!==s&&4!==s)return{};let o=31&r.getUint8(5);if(0===o)return{};let a=6;for(let i=0;i<o;i++){let n=r.getUint16(a,!1);if(a+=2,0===n)continue;let s=new Uint8Array(e.buffer,a,n);a+=n;let o=Lt.parseSPS(s);if(0!==i)continue;t.sps=s,t.timescale=1e3,t.codecWidth=o.codec_size.width,t.codecHeight=o.codec_size.height,t.presentWidth=o.present_size.width,t.presentHeight=o.present_size.height,t.profile=o.profile_string,t.level=o.level_string,t.bitDepth=o.bit_depth,t.chromaFormat=o.chroma_format,t.sarRatio=o.sar_ratio,t.frameRate=o.frame_rate,!1!==o.frame_rate.fixed&&0!==o.frame_rate.fps_num&&0!==o.frame_rate.fps_den||(t.frameRate={fixed:!0,fps:25,fps_num:25e3,fps_den:1e3});let l=t.frameRate.fps_den,d=t.frameRate.fps_num;t.refSampleDuration=t.timescale*(l/d);let u=s.subarray(1,4),h="avc1.";for(let e=0;e<3;e++){let t=u[e].toString(16);t.length<2&&(t="0"+t),h+=t}t.codec=h}let l=r.getUint8(a);if(0===l)return{};a++;for(let i=0;i<l;i++){let i=r.getUint16(a,!1);if(a+=2,0===i)continue;let n=new Uint8Array(e.buffer,a,i);a+=i,t.pps=n}if(t.videoType="avc",t.sps){const e=t.sps.byteLength,r=new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e]),i=new Uint8Array(e+4);i.set(r,0),i.set(t.sps,4),t.sps=i}if(t.pps){const e=t.pps.byteLength,r=new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e]),i=new Uint8Array(e+4);i.set(r,0),i.set(t.pps,4),t.pps=i}return t}function Mt(e){let{sps:t,pps:r}=e;const i=[23,0,0,0,0,1,66,0,30,255];i[0]=23,i[6]=t[1],i[7]=t[2],i[8]=t[3],i[10]=225,i[11]=t.byteLength>>8&255,i[12]=255&t.byteLength,i.push(...t,1,r.byteLength>>8&255,255&r.byteLength,...r);return new Uint8Array(i)}function Ot(e,t){let r=[];r[0]=t?23:39,r[1]=1,r[2]=0,r[3]=0,r[4]=0,r[5]=e.byteLength>>24&255,r[6]=e.byteLength>>16&255,r[7]=e.byteLength>>8&255,r[8]=255&e.byteLength;const i=new Uint8Array(r.length+e.byteLength);return i.set(r,0),i.set(e,r.length),i}function Nt(e,t){let r=[];r[0]=t?23:39,r[1]=1,r[2]=0,r[3]=0,r[4]=0;const i=new Uint8Array(r.length+e.byteLength);return i.set(r,0),i.set(e,r.length),i}function $t(e){return 31&e[0]}function Gt(e){return e===Re}function Ht(e){return!function(e){return e===De||e===Ie}(e)&&!Gt(e)}function Vt(e){return e===Le}function Wt(e){if(0===e.length)return!1;const t=$t(e[0]);for(let r=1;r<e.length;r++)if(t!==$t(e[r]))return!1;return!0}const jt=e=>{let t=e,r=t.byteLength,i=new Uint8Array(r),n=0;for(let e=0;e<r;e++)e>=2&&3===t[e]&&0===t[e-1]&&0===t[e-2]||(i[n]=t[e],n++);return new Uint8Array(i.buffer,0,n)},Yt=e=>{switch(e){case 0:return"4:0:0";case 1:return"4:2:0";case 2:return"4:2:2";case 3:return"4:4:4";default:return"Unknown"}};function qt(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+(e[t+3]||0)}function Kt(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;if(e.length<4)return;const r=e.length,i=[];let n,s=0;for(;s+t<r;)if(n=qt(e,s),3===t&&(n>>>=8),s+=t,n){if(s+n>r)break;i.push(e.subarray(s,s+n)),s+=n}return i}function Xt(e){const t=e.byteLength,r=new Uint8Array(4);r[0]=t>>>24&255,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=255&t;const i=new Uint8Array(t+4);return i.set(r,0),i.set(e,4),i}function Zt(e,t){let r=null;return t?e.length>=28&&(r=1+(3&e[26])):e.length>=12&&(r=1+(3&e[9])),r}function Jt(e){let t={width:0,height:0,profile:0,level:0};e=e.slice(5);do{let r={};if(e.length<23){console.warn("parseHEVCDecoderConfigurationRecord$2",`arrayBuffer.length ${e.length} < 23`);break}if(r.configurationVersion=e[0],1!=r.configurationVersion)break;r.general_profile_space=e[1]>>6&3,r.general_tier_flag=e[1]>>5&1,r.general_profile_idc=31&e[1],r.general_profile_compatibility_flags=e[2]<<24|e[3]<<16|e[4]<<8|e[5],r.general_constraint_indicator_flags=e[6]<<24|e[7]<<16|e[8]<<8|e[9],r.general_constraint_indicator_flags=r.general_constraint_indicator_flags<<16|e[10]<<8|e[11],r.general_level_idc=e[12],r.min_spatial_segmentation_idc=(15&e[13])<<8|e[14],r.parallelismType=3&e[15],r.chromaFormat=3&e[16],r.bitDepthLumaMinus8=7&e[17],r.bitDepthChromaMinus8=7&e[18],r.avgFrameRate=e[19]<<8|e[20],r.constantFrameRate=e[21]>>6&3,r.numTemporalLayers=e[21]>>3&7,r.temporalIdNested=e[21]>>2&1,r.lengthSizeMinusOne=3&e[21];let i=e[22],n=e.slice(23);for(let e=0;e<i&&!(n.length<3);e++){let e=63&n[0],i=n[1]<<8|n[2];n=n.slice(3);for(let s=0;s<i&&!(n.length<2);s++){let i=n[0]<<8|n[1];if(n.length<2+i)break;if(n=n.slice(2),33==e){let e=new Uint8Array(i);e.set(n.slice(0,i),0),r.psps=Qt(e,r),t.profile=r.general_profile_idc,t.level=r.general_level_idc/30,t.width=r.psps.pic_width_in_luma_samples-(r.psps.conf_win_left_offset+r.psps.conf_win_right_offset),t.height=r.psps.pic_height_in_luma_samples-(r.psps.conf_win_top_offset+r.psps.conf_win_bottom_offset)}n=n.slice(i)}}}while(0);return t.codecWidth=t.width||1920,t.codecHeight=t.height||1080,t.presentHeight=t.codecHeight,t.presentWidth=t.codecWidth,t.timescale=1e3,t.refSampleDuration=1e3/23976*1e3,t.videoType=Ye,t}function Qt(e,t){let r={},i=e.length,n=[],s=new Rt(e);s.read(1),s.read(6),s.read(6),s.read(3);for(let e=2;e<i;e++)e+2<i&&3==s.look(24)?(n.push(s.read(8)),n.push(s.read(8)),e+=2,s.read(8)):n.push(s.read(8));let o=new Uint8Array(n),a=new Rt(o);if(r.sps_video_parameter_set_id=a.read(4),r.sps_max_sub_layers_minus1=a.read(3),r.sps_temporal_id_nesting_flag=a.read(1),r.profile_tier_level=function(e,t,r){let i={};i.profile_space=e.read(2),i.tier_flag=e.read(1),i.profile_idc=e.read(5),i.profile_compatibility_flags=e.read(32),i.general_progressive_source_flag=e.read(1),i.general_interlaced_source_flag=e.read(1),i.general_non_packed_constraint_flag=e.read(1),i.general_frame_only_constraint_flag=e.read(1),e.read(32),e.read(12),i.level_idc=e.read(8),i.sub_layer_profile_present_flag=[],i.sub_layer_level_present_flag=[];for(let t=0;t<r;t++)i.sub_layer_profile_present_flag[t]=e.read(1),i.sub_layer_level_present_flag[t]=e.read(1);if(r>0)for(let t=r;t<8;t++)e.read(2);i.sub_layer_profile_space=[],i.sub_layer_tier_flag=[],i.sub_layer_profile_idc=[],i.sub_layer_profile_compatibility_flag=[],i.sub_layer_progressive_source_flag=[],i.sub_layer_interlaced_source_flag=[],i.sub_layer_non_packed_constraint_flag=[],i.sub_layer_frame_only_constraint_flag=[],i.sub_layer_level_idc=[];for(let t=0;t<r;t++)i.sub_layer_profile_present_flag[t]&&(i.sub_layer_profile_space[t]=e.read(2),i.sub_layer_tier_flag[t]=e.read(1),i.sub_layer_profile_idc[t]=e.read(5),i.sub_layer_profile_compatibility_flag[t]=e.read(32),i.sub_layer_progressive_source_flag[t]=e.read(1),i.sub_layer_interlaced_source_flag[t]=e.read(1),i.sub_layer_non_packed_constraint_flag[t]=e.read(1),i.sub_layer_frame_only_constraint_flag[t]=e.read(1),e.read(32),e.read(12)),i.sub_layer_level_present_flag[t]?i.sub_layer_level_idc[t]=e.read(8):i.sub_layer_level_idc[t]=1;return i}(a,0,r.sps_max_sub_layers_minus1),r.sps_seq_parameter_set_id=a.read_golomb(),r.chroma_format_idc=a.read_golomb(),3==r.chroma_format_idc?r.separate_colour_plane_flag=a.read(1):r.separate_colour_plane_flag=0,r.pic_width_in_luma_samples=a.read_golomb(),r.pic_height_in_luma_samples=a.read_golomb(),r.conformance_window_flag=a.read(1),r.conformance_window_flag){let e=1+(r.chroma_format_idc<2),t=1+(r.chroma_format_idc<3);r.conf_win_left_offset=a.read_golomb()*t,r.conf_win_right_offset=a.read_golomb()*t,r.conf_win_top_offset=a.read_golomb()*e,r.conf_win_bottom_offset=a.read_golomb()*e}else r.conf_win_left_offset=0,r.conf_win_right_offset=0,r.conf_win_top_offset=0,r.conf_win_bottom_offset=0;return r}function er(e){let{vps:t,pps:r,sps:i}=e,n={configurationVersion:1};const s=(e=>{let t=jt(e),r=new It(t);return r.readByte(),r.readByte(),r.readBits(4),r.readBits(2),r.readBits(6),{num_temporal_layers:r.readBits(3)+1,temporal_id_nested:r.readBool()}})(t),o=(e=>{let t=jt(e),r=new It(t);r.readByte(),r.readByte();let i=0,n=0,s=0,o=0;r.readBits(4);let a=r.readBits(3);r.readBool();let l=r.readBits(2),d=r.readBool(),u=r.readBits(5),h=r.readByte(),c=r.readByte(),f=r.readByte(),p=r.readByte(),m=r.readByte(),_=r.readByte(),g=r.readByte(),y=r.readByte(),v=r.readByte(),b=r.readByte(),w=r.readByte(),E=[],S=[];for(let e=0;e<a;e++)E.push(r.readBool()),S.push(r.readBool());if(a>0)for(let e=a;e<8;e++)r.readBits(2);for(let e=0;e<a;e++)E[e]&&(r.readByte(),r.readByte(),r.readByte(),r.readByte(),r.readByte(),r.readByte(),r.readByte(),r.readByte(),r.readByte(),r.readByte(),r.readByte()),E[e]&&r.readByte();r.readUEG();let U=r.readUEG();3==U&&r.readBits(1);let x=r.readUEG(),k=r.readUEG();r.readBool()&&(i+=r.readUEG(),n+=r.readUEG(),s+=r.readUEG(),o+=r.readUEG());let A=r.readUEG(),T=r.readUEG(),C=r.readUEG();for(let e=r.readBool()?0:a;e<=a;e++)r.readUEG(),r.readUEG(),r.readUEG();if(r.readUEG(),r.readUEG(),r.readUEG(),r.readUEG(),r.readUEG(),r.readUEG(),r.readBool()&&r.readBool())for(let e=0;e<4;e++)for(let t=0;t<(3===e?2:6);t++)if(r.readBool()){let t=Math.min(64,1<<4+(e<<1));e>1&&r.readSEG();for(let e=0;e<t;e++)r.readSEG()}else r.readUEG();r.readBool(),r.readBool(),r.readBool()&&(r.readByte(),r.readUEG(),r.readUEG(),r.readBool());let B=r.readUEG(),F=0;for(let e=0;e<B;e++){let t=!1;if(0!==e&&(t=r.readBool()),t){e===B&&r.readUEG(),r.readBool(),r.readUEG();let t=0;for(let e=0;e<=F;e++){let e=r.readBool(),i=!1;e||(i=r.readBool()),(e||i)&&t++}F=t}else{let e=r.readUEG(),t=r.readUEG();F=e+t;for(let t=0;t<e;t++)r.readUEG(),r.readBool();for(let e=0;e<t;e++)r.readUEG(),r.readBool()}}if(r.readBool()){let e=r.readUEG();for(let t=0;t<e;t++){for(let e=0;e<C+4;e++)r.readBits(1);r.readBits(1)}}let P=!1,D=0,I=1,L=1,R=!1,z=1,M=1;if(r.readBool(),r.readBool(),r.readBool()){if(r.readBool()){let e=r.readByte(),t=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],i=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];e>0&&e<16?(I=t[e-1],L=i[e-1]):255===e&&(I=r.readBits(16),L=r.readBits(16))}if(r.readBool()&&r.readBool(),r.readBool()&&(r.readBits(3),r.readBool(),r.readBool()&&(r.readByte(),r.readByte(),r.readByte())),r.readBool()&&(r.readUEG(),r.readUEG()),r.readBool(),r.readBool(),r.readBool(),P=r.readBool(),P&&(i+=r.readUEG(),n+=r.readUEG(),s+=r.readUEG(),o+=r.readUEG()),r.readBool()&&(z=r.readBits(32),M=r.readBits(32),r.readBool()&&(r.readUEG(),r.readBool()))){let e=!1,t=!1,i=!1;e=r.readBool(),t=r.readBool(),(e||t)&&(i=r.readBool(),i&&(r.readByte(),r.readBits(5),r.readBool(),r.readBits(5)),r.readBits(4),r.readBits(4),i&&r.readBits(4),r.readBits(5),r.readBits(5),r.readBits(5));for(let n=0;n<=a;n++){let n=r.readBool();R=n;let s=!1,o=1;n||(s=r.readBool());let a=!1;if(s?r.readSEG():a=r.readBool(),a||(cpbcnt=r.readUEG()+1),e)for(let e=0;e<o;e++)r.readUEG(),r.readUEG(),i&&(r.readUEG(),r.readUEG());if(t)for(let e=0;e<o;e++)r.readUEG(),r.readUEG(),i&&(r.readUEG(),r.readUEG())}}r.readBool()&&(r.readBool(),r.readBool(),r.readBool(),D=r.readUEG(),r.readUEG(),r.readUEG(),r.readUEG(),r.readUEG())}r.readBool();let O=`hvc1.${u}.1.L${w}.B0`,N=x,$=k,G=1;return 1!==I&&1!==L&&(G=I/L),r.destroy(),r=null,{codec_mimetype:O,level_string:(H=w,(H/30).toFixed(1)),profile_idc:u,bit_depth:A+8,ref_frames:1,chroma_format:U,chroma_format_string:Yt(U),general_level_idc:w,general_profile_space:l,general_tier_flag:d,general_profile_idc:u,general_profile_compatibility_flags_1:h,general_profile_compatibility_flags_2:c,general_profile_compatibility_flags_3:f,general_profile_compatibility_flags_4:p,general_constraint_indicator_flags_1:m,general_constraint_indicator_flags_2:_,general_constraint_indicator_flags_3:g,general_constraint_indicator_flags_4:y,general_constraint_indicator_flags_5:v,general_constraint_indicator_flags_6:b,min_spatial_segmentation_idc:D,constant_frame_rate:0,chroma_format_idc:U,bit_depth_luma_minus8:A,bit_depth_chroma_minus8:T,frame_rate:{fixed:R,fps:M/z,fps_den:z,fps_num:M},sar_ratio:{width:I,height:L},codec_size:{width:N,height:$},present_size:{width:N*G,height:$}};var H})(i),a=(e=>{let t=jt(e),r=new It(t);r.readByte(),r.readByte(),r.readUEG(),r.readUEG(),r.readBool(),r.readBool(),r.readBits(3),r.readBool(),r.readBool(),r.readUEG(),r.readUEG(),r.readSEG(),r.readBool(),r.readBool(),r.readBool()&&r.readUEG(),r.readSEG(),r.readSEG(),r.readBool(),r.readBool(),r.readBool(),r.readBool();let i=r.readBool(),n=r.readBool(),s=1;return n&&i?s=0:n?s=3:i&&(s=2),{parallelismType:s}})(r);n=Object.assign(n,s,o,a);let l=23+(5+t.byteLength)+(5+i.byteLength)+(5+r.byteLength),d=new Uint8Array(l);d[0]=1,d[1]=(3&n.general_profile_space)<<6|(n.general_tier_flag?1:0)<<5|31&n.general_profile_idc,d[2]=n.general_profile_compatibility_flags_1||0,d[3]=n.general_profile_compatibility_flags_2||0,d[4]=n.general_profile_compatibility_flags_3||0,d[5]=n.general_profile_compatibility_flags_4||0,d[6]=n.general_constraint_indicator_flags_1||0,d[7]=n.general_constraint_indicator_flags_2||0,d[8]=n.general_constraint_indicator_flags_3||0,d[9]=n.general_constraint_indicator_flags_4||0,d[10]=n.general_constraint_indicator_flags_5||0,d[11]=n.general_constraint_indicator_flags_6||0,d[12]=60,d[13]=240|(3840&n.min_spatial_segmentation_idc)>>8,d[14]=255&n.min_spatial_segmentation_idc,d[15]=252|3&n.parallelismType,d[16]=252|3&n.chroma_format_idc,d[17]=248|7&n.bit_depth_luma_minus8,d[18]=248|7&n.bit_depth_chroma_minus8,d[19]=0,d[20]=0,d[21]=(3&n.constant_frame_rate)<<6|(7&n.num_temporal_layers)<<3|(n.temporal_id_nested?1:0)<<2|3,d[22]=3,d[23]=128|Oe,d[24]=0,d[25]=1,d[26]=(65280&t.byteLength)>>8,d[27]=(255&t.byteLength)>>0,d.set(t,28),d[23+(5+t.byteLength)+0]=128|Ne,d[23+(5+t.byteLength)+1]=0,d[23+(5+t.byteLength)+2]=1,d[23+(5+t.byteLength)+3]=(65280&i.byteLength)>>8,d[23+(5+t.byteLength)+4]=(255&i.byteLength)>>0,d.set(i,23+(5+t.byteLength)+5),d[23+(5+t.byteLength+5+i.byteLength)+0]=128|$e,d[23+(5+t.byteLength+5+i.byteLength)+1]=0,d[23+(5+t.byteLength+5+i.byteLength)+2]=1,d[23+(5+t.byteLength+5+i.byteLength)+3]=(65280&r.byteLength)>>8,d[23+(5+t.byteLength+5+i.byteLength)+4]=(255&r.byteLength)>>0,d.set(r,23+(5+t.byteLength+5+i.byteLength)+5);const u=[28,0,0,0,0],h=new Uint8Array(u.length+d.byteLength);return h.set(u,0),h.set(d,u.length),h}function tr(e,t){let r=[];r[0]=t?28:44,r[1]=1,r[2]=0,r[3]=0,r[4]=0,r[5]=e.byteLength>>24&255,r[6]=e.byteLength>>16&255,r[7]=e.byteLength>>8&255,r[8]=255&e.byteLength;const i=new Uint8Array(r.length+e.byteLength);return i.set(r,0),i.set(e,r.length),i}function rr(e,t){let r=[];r[0]=t?28:44,r[1]=1,r[2]=0,r[3]=0,r[4]=0;const i=new Uint8Array(r.length+e.byteLength);return i.set(r,0),i.set(e,r.length),i}function ir(e){return(126&e[0])>>1}function nr(e){return e===Ge}function sr(e){return!function(e){return e>=32&&e<=40}(e)}function or(e){return e>=16&&e<=21}function ar(e){if(0===e.length)return!1;const t=ir(e[0]);for(let r=1;r<e.length;r++)if(t!==ir(e[r]))return!1;return!0}function lr(e){return parseInt(e)===e}function dr(e){if(!lr(e.length))return!1;for(var t=0;t<e.length;t++)if(!lr(e[t])||e[t]<0||e[t]>255)return!1;return!0}function ur(e,t){if(e.buffer&&"Uint8Array"===e.name)return t&&(e=e.slice?e.slice():Array.prototype.slice.call(e)),e;if(Array.isArray(e)){if(!dr(e))throw new Error("Array contains invalid value: "+e);return new Uint8Array(e)}if(lr(e.length)&&dr(e))return new Uint8Array(e);throw new Error("unsupported array-like object")}function hr(e){return new Uint8Array(e)}function cr(e,t,r,i,n){null==i&&null==n||(e=e.slice?e.slice(i,n):Array.prototype.slice.call(e,i,n)),t.set(e,r)}var fr,pr={toBytes:function(e){var t=[],r=0;for(e=encodeURI(e);r<e.length;){var i=e.charCodeAt(r++);37===i?(t.push(parseInt(e.substr(r,2),16)),r+=2):t.push(i)}return ur(t)},fromBytes:function(e){for(var t=[],r=0;r<e.length;){var i=e[r];i<128?(t.push(String.fromCharCode(i)),r++):i>191&&i<224?(t.push(String.fromCharCode((31&i)<<6|63&e[r+1])),r+=2):(t.push(String.fromCharCode((15&i)<<12|(63&e[r+1])<<6|63&e[r+2])),r+=3)}return t.join("")}},mr=(fr="0123456789abcdef",{toBytes:function(e){for(var t=[],r=0;r<e.length;r+=2)t.push(parseInt(e.substr(r,2),16));return t},fromBytes:function(e){for(var t=[],r=0;r<e.length;r++){var i=e[r];t.push(fr[(240&i)>>4]+fr[15&i])}return t.join("")}}),_r={16:10,24:12,32:14},gr=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],yr=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],vr=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],br=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],wr=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],Er=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],Sr=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],Ur=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],xr=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],kr=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],Ar=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],Tr=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],Cr=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],Br=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],Fr=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function Pr(e){for(var t=[],r=0;r<e.length;r+=4)t.push(e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3]);return t}var Dr=function(e){if(!(this instanceof Dr))throw Error("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:ur(e,!0)}),this._prepare()};Dr.prototype._prepare=function(){var e=_r[this.key.length];if(null==e)throw new Error("invalid key size (must be 16, 24 or 32 bytes)");this._Ke=[],this._Kd=[];for(var t=0;t<=e;t++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);var r,i=4*(e+1),n=this.key.length/4,s=Pr(this.key);for(t=0;t<n;t++)r=t>>2,this._Ke[r][t%4]=s[t],this._Kd[e-r][t%4]=s[t];for(var o,a=0,l=n;l<i;){if(o=s[n-1],s[0]^=yr[o>>16&255]<<24^yr[o>>8&255]<<16^yr[255&o]<<8^yr[o>>24&255]^gr[a]<<24,a+=1,8!=n)for(t=1;t<n;t++)s[t]^=s[t-1];else{for(t=1;t<n/2;t++)s[t]^=s[t-1];o=s[n/2-1],s[n/2]^=yr[255&o]^yr[o>>8&255]<<8^yr[o>>16&255]<<16^yr[o>>24&255]<<24;for(t=n/2+1;t<n;t++)s[t]^=s[t-1]}for(t=0;t<n&&l<i;)d=l>>2,u=l%4,this._Ke[d][u]=s[t],this._Kd[e-d][u]=s[t++],l++}for(var d=1;d<e;d++)for(var u=0;u<4;u++)o=this._Kd[d][u],this._Kd[d][u]=Tr[o>>24&255]^Cr[o>>16&255]^Br[o>>8&255]^Fr[255&o]},Dr.prototype.encrypt=function(e){if(16!=e.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var t=this._Ke.length-1,r=[0,0,0,0],i=Pr(e),n=0;n<4;n++)i[n]^=this._Ke[0][n];for(var s=1;s<t;s++){for(n=0;n<4;n++)r[n]=br[i[n]>>24&255]^wr[i[(n+1)%4]>>16&255]^Er[i[(n+2)%4]>>8&255]^Sr[255&i[(n+3)%4]]^this._Ke[s][n];i=r.slice()}var o,a=hr(16);for(n=0;n<4;n++)o=this._Ke[t][n],a[4*n]=255&(yr[i[n]>>24&255]^o>>24),a[4*n+1]=255&(yr[i[(n+1)%4]>>16&255]^o>>16),a[4*n+2]=255&(yr[i[(n+2)%4]>>8&255]^o>>8),a[4*n+3]=255&(yr[255&i[(n+3)%4]]^o);return a},Dr.prototype.decrypt=function(e){if(16!=e.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var t=this._Kd.length-1,r=[0,0,0,0],i=Pr(e),n=0;n<4;n++)i[n]^=this._Kd[0][n];for(var s=1;s<t;s++){for(n=0;n<4;n++)r[n]=Ur[i[n]>>24&255]^xr[i[(n+3)%4]>>16&255]^kr[i[(n+2)%4]>>8&255]^Ar[255&i[(n+1)%4]]^this._Kd[s][n];i=r.slice()}var o,a=hr(16);for(n=0;n<4;n++)o=this._Kd[t][n],a[4*n]=255&(vr[i[n]>>24&255]^o>>24),a[4*n+1]=255&(vr[i[(n+3)%4]>>16&255]^o>>16),a[4*n+2]=255&(vr[i[(n+2)%4]>>8&255]^o>>8),a[4*n+3]=255&(vr[255&i[(n+1)%4]]^o);return a};var Ir=function(e){if(!(this instanceof Ir))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new Dr(e)};Ir.prototype.encrypt=function(e){if((e=ur(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=hr(e.length),r=hr(16),i=0;i<e.length;i+=16)cr(e,r,0,i,i+16),cr(r=this._aes.encrypt(r),t,i);return t},Ir.prototype.decrypt=function(e){if((e=ur(e)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var t=hr(e.length),r=hr(16),i=0;i<e.length;i+=16)cr(e,r,0,i,i+16),cr(r=this._aes.decrypt(r),t,i);return t};var Lr=function(e,t){if(!(this instanceof Lr))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Block Chaining",this.name="cbc",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 bytes)")}else t=hr(16);this._lastCipherblock=ur(t,!0),this._aes=new Dr(e)};Lr.prototype.encrypt=function(e){if((e=ur(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=hr(e.length),r=hr(16),i=0;i<e.length;i+=16){cr(e,r,0,i,i+16);for(var n=0;n<16;n++)r[n]^=this._lastCipherblock[n];this._lastCipherblock=this._aes.encrypt(r),cr(this._lastCipherblock,t,i)}return t},Lr.prototype.decrypt=function(e){if((e=ur(e)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var t=hr(e.length),r=hr(16),i=0;i<e.length;i+=16){cr(e,r,0,i,i+16),r=this._aes.decrypt(r);for(var n=0;n<16;n++)t[i+n]=r[n]^this._lastCipherblock[n];cr(e,this._lastCipherblock,0,i,i+16)}return t};var Rr=function(e,t,r){if(!(this instanceof Rr))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Feedback",this.name="cfb",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 size)")}else t=hr(16);r||(r=1),this.segmentSize=r,this._shiftRegister=ur(t,!0),this._aes=new Dr(e)};Rr.prototype.encrypt=function(e){if(e.length%this.segmentSize!=0)throw new Error("invalid plaintext size (must be segmentSize bytes)");for(var t,r=ur(e,!0),i=0;i<r.length;i+=this.segmentSize){t=this._aes.encrypt(this._shiftRegister);for(var n=0;n<this.segmentSize;n++)r[i+n]^=t[n];cr(this._shiftRegister,this._shiftRegister,0,this.segmentSize),cr(r,this._shiftRegister,16-this.segmentSize,i,i+this.segmentSize)}return r},Rr.prototype.decrypt=function(e){if(e.length%this.segmentSize!=0)throw new Error("invalid ciphertext size (must be segmentSize bytes)");for(var t,r=ur(e,!0),i=0;i<r.length;i+=this.segmentSize){t=this._aes.encrypt(this._shiftRegister);for(var n=0;n<this.segmentSize;n++)r[i+n]^=t[n];cr(this._shiftRegister,this._shiftRegister,0,this.segmentSize),cr(e,this._shiftRegister,16-this.segmentSize,i,i+this.segmentSize)}return r};var zr=function(e,t){if(!(this instanceof zr))throw Error("AES must be instanitated with `new`");if(this.description="Output Feedback",this.name="ofb",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 bytes)")}else t=hr(16);this._lastPrecipher=ur(t,!0),this._lastPrecipherIndex=16,this._aes=new Dr(e)};zr.prototype.encrypt=function(e){for(var t=ur(e,!0),r=0;r<t.length;r++)16===this._lastPrecipherIndex&&(this._lastPrecipher=this._aes.encrypt(this._lastPrecipher),this._lastPrecipherIndex=0),t[r]^=this._lastPrecipher[this._lastPrecipherIndex++];return t},zr.prototype.decrypt=zr.prototype.encrypt;var Mr=function(e){if(!(this instanceof Mr))throw Error("Counter must be instanitated with `new`");0===e||e||(e=1),"number"==typeof e?(this._counter=hr(16),this.setValue(e)):this.setBytes(e)};Mr.prototype.setValue=function(e){if("number"!=typeof e||parseInt(e)!=e)throw new Error("invalid counter value (must be an integer)");if(e>Number.MAX_SAFE_INTEGER)throw new Error("integer value out of safe range");for(var t=15;t>=0;--t)this._counter[t]=e%256,e=parseInt(e/256)},Mr.prototype.setBytes=function(e){if(16!=(e=ur(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e},Mr.prototype.increment=function(){for(var e=15;e>=0;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}};var Or=function(e,t){if(!(this instanceof Or))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",t instanceof Mr||(t=new Mr(t)),this._counter=t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new Dr(e)};Or.prototype.encrypt=function(e){for(var t=ur(e,!0),r=0;r<t.length;r++)16===this._remainingCounterIndex&&(this._remainingCounter=this._aes.encrypt(this._counter._counter),this._remainingCounterIndex=0,this._counter.increment()),t[r]^=this._remainingCounter[this._remainingCounterIndex++];return t},Or.prototype.decrypt=Or.prototype.encrypt;const Nr={AES:Dr,Counter:Mr,ModeOfOperation:{ecb:Ir,cbc:Lr,cfb:Rr,ofb:zr,ctr:Or},utils:{hex:mr,utf8:pr},padding:{pkcs7:{pad:function(e){var t=16-(e=ur(e,!0)).length%16,r=hr(e.length+t);cr(e,r);for(var i=e.length;i<r.length;i++)r[i]=t;return r},strip:function(e){if((e=ur(e,!0)).length<16)throw new Error("PKCS#7 invalid length");var t=e[e.length-1];if(t>16)throw new Error("PKCS#7 padding byte out of range");for(var r=e.length-t,i=0;i<t;i++)if(e[r+i]!==t)throw new Error("PKCS#7 invalid padding byte");var n=hr(r);return cr(e,n,0,0,r),n}}},_arrayTest:{coerceArray:ur,createArray:hr,copyArray:cr}};function $r(e){return e[3]|e[2]<<8|e[1]<<16|e[0]<<24}function Gr(e,t,r){let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];t=new Uint8Array(t),r=new Uint8Array(r);const n=e.byteLength;let s=5;for(;s<n;){let o=$r(e.slice(s,s+4));if(o>n)break;let a=e[s+4],l=!1;if(i?(a=a>>>1&63,l=[0,1,2,3,4,5,6,7,8,9,16,17,18,19,20,21].includes(a)):(a&=31,l=1===a||5===a),l){const i=e.slice(s+4+2,s+4+o);let n=new Nr.ModeOfOperation.ctr(t,new Nr.Counter(r));const a=n.decrypt(i);n=null,e.set(a,s+4+2)}s=s+4+o}return e}function Hr(e,t,r){if(e.byteLength<=30)return e;const i=e.slice(32);let n=new Nr.ModeOfOperation.ctr(t,new Nr.Counter(r));const s=n.decrypt(i);return n=null,e.set(s,32),e}var Vr=ot((function(e,t){var r,n,s,o=(r=new Date,n=4,s={setLogLevel:function(e){n=e==this.debug?1:e==this.info?2:e==this.warn?3:(this.error,4)},debug:function(e,t){void 0===console.debug&&(console.debug=console.log),1>=n&&console.debug("["+o.getDurationString(new Date-r,1e3)+"]","["+e+"]",t)},log:function(e,t){this.debug(e.msg)},info:function(e,t){2>=n&&console.info("["+o.getDurationString(new Date-r,1e3)+"]","["+e+"]",t)},warn:function(e,t){3>=n&&console.warn("["+o.getDurationString(new Date-r,1e3)+"]","["+e+"]",t)},error:function(e,t){4>=n&&console.error("["+o.getDurationString(new Date-r,1e3)+"]","["+e+"]",t)}},s);o.getDurationString=function(e,t){var r;function i(e,t){for(var r=(""+e).split(".");r[0].length<t;)r[0]="0"+r[0];return r.join(".")}e<0?(r=!0,e=-e):r=!1;var n=e/(t||1),s=Math.floor(n/3600);n-=3600*s;var o=Math.floor(n/60),a=1e3*(n-=60*o);return a-=1e3*(n=Math.floor(n)),a=Math.floor(a),(r?"-":"")+s+":"+i(o,2)+":"+i(n,2)+"."+i(a,3)},o.printRanges=function(e){var t=e.length;if(t>0){for(var r="",i=0;i<t;i++)i>0&&(r+=","),r+="["+o.getDurationString(e.start(i))+","+o.getDurationString(e.end(i))+"]";return r}return"(empty)"},t.Log=o;var a=function(e){if(!(e instanceof ArrayBuffer))throw"Needs an array buffer";this.buffer=e,this.dataview=new DataView(e),this.position=0};a.prototype.getPosition=function(){return this.position},a.prototype.getEndPosition=function(){return this.buffer.byteLength},a.prototype.getLength=function(){return this.buffer.byteLength},a.prototype.seek=function(e){var t=Math.max(0,Math.min(this.buffer.byteLength,e));return this.position=isNaN(t)||!isFinite(t)?0:t,!0},a.prototype.isEos=function(){return this.getPosition()>=this.getEndPosition()},a.prototype.readAnyInt=function(e,t){var r=0;if(this.position+e<=this.buffer.byteLength){switch(e){case 1:r=t?this.dataview.getInt8(this.position):this.dataview.getUint8(this.position);break;case 2:r=t?this.dataview.getInt16(this.position):this.dataview.getUint16(this.position);break;case 3:if(t)throw"No method for reading signed 24 bits values";r=this.dataview.getUint8(this.position)<<16,r|=this.dataview.getUint8(this.position+1)<<8,r|=this.dataview.getUint8(this.position+2);break;case 4:r=t?this.dataview.getInt32(this.position):this.dataview.getUint32(this.position);break;case 8:if(t)throw"No method for reading signed 64 bits values";r=this.dataview.getUint32(this.position)<<32,r|=this.dataview.getUint32(this.position+4);break;default:throw"readInt method not implemented for size: "+e}return this.position+=e,r}throw"Not enough bytes in buffer"},a.prototype.readUint8=function(){return this.readAnyInt(1,!1)},a.prototype.readUint16=function(){return this.readAnyInt(2,!1)},a.prototype.readUint24=function(){return this.readAnyInt(3,!1)},a.prototype.readUint32=function(){return this.readAnyInt(4,!1)},a.prototype.readUint64=function(){return this.readAnyInt(8,!1)},a.prototype.readString=function(e){if(this.position+e<=this.buffer.byteLength){for(var t="",r=0;r<e;r++)t+=String.fromCharCode(this.readUint8());return t}throw"Not enough bytes in buffer"},a.prototype.readCString=function(){for(var e=[];;){var t=this.readUint8();if(0===t)break;e.push(t)}return String.fromCharCode.apply(null,e)},a.prototype.readInt8=function(){return this.readAnyInt(1,!0)},a.prototype.readInt16=function(){return this.readAnyInt(2,!0)},a.prototype.readInt32=function(){return this.readAnyInt(4,!0)},a.prototype.readInt64=function(){return this.readAnyInt(8,!1)},a.prototype.readUint8Array=function(e){for(var t=new Uint8Array(e),r=0;r<e;r++)t[r]=this.readUint8();return t},a.prototype.readInt16Array=function(e){for(var t=new Int16Array(e),r=0;r<e;r++)t[r]=this.readInt16();return t},a.prototype.readUint16Array=function(e){for(var t=new Int16Array(e),r=0;r<e;r++)t[r]=this.readUint16();return t},a.prototype.readUint32Array=function(e){for(var t=new Uint32Array(e),r=0;r<e;r++)t[r]=this.readUint32();return t},a.prototype.readInt32Array=function(e){for(var t=new Int32Array(e),r=0;r<e;r++)t[r]=this.readInt32();return t},t.MP4BoxStream=a;var l=function(e,t,r){this._byteOffset=t||0,e instanceof ArrayBuffer?this.buffer=e:"object"==typeof e?(this.dataView=e,t&&(this._byteOffset+=t)):this.buffer=new ArrayBuffer(e||0),this.position=0,this.endianness=null==r?l.LITTLE_ENDIAN:r};l.prototype={},l.prototype.getPosition=function(){return this.position},l.prototype._realloc=function(e){if(this._dynamicSize){var t=this._byteOffset+this.position+e,r=this._buffer.byteLength;if(t<=r)t>this._byteLength&&(this._byteLength=t);else{for(r<1&&(r=1);t>r;)r*=2;var i=new ArrayBuffer(r),n=new Uint8Array(this._buffer);new Uint8Array(i,0,n.length).set(n),this.buffer=i,this._byteLength=t}}},l.prototype._trimAlloc=function(){if(this._byteLength!=this._buffer.byteLength){var e=new ArrayBuffer(this._byteLength),t=new Uint8Array(e),r=new Uint8Array(this._buffer,0,t.length);t.set(r),this.buffer=e}},l.BIG_ENDIAN=!1,l.LITTLE_ENDIAN=!0,l.prototype._byteLength=0,Object.defineProperty(l.prototype,"byteLength",{get:function(){return this._byteLength-this._byteOffset}}),Object.defineProperty(l.prototype,"buffer",{get:function(){return this._trimAlloc(),this._buffer},set:function(e){this._buffer=e,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}}),Object.defineProperty(l.prototype,"byteOffset",{get:function(){return this._byteOffset},set:function(e){this._byteOffset=e,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}}),Object.defineProperty(l.prototype,"dataView",{get:function(){return this._dataView},set:function(e){this._byteOffset=e.byteOffset,this._buffer=e.buffer,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._byteOffset+e.byteLength}}),l.prototype.seek=function(e){var t=Math.max(0,Math.min(this.byteLength,e));this.position=isNaN(t)||!isFinite(t)?0:t},l.prototype.isEof=function(){return this.position>=this._byteLength},l.prototype.mapUint8Array=function(e){this._realloc(1*e);var t=new Uint8Array(this._buffer,this.byteOffset+this.position,e);return this.position+=1*e,t},l.prototype.readInt32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var r=new Int32Array(e);return l.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),l.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},l.prototype.readInt16Array=function(e,t){e=null==e?this.byteLength-this.position/2:e;var r=new Int16Array(e);return l.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),l.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},l.prototype.readInt8Array=function(e){e=null==e?this.byteLength-this.position:e;var t=new Int8Array(e);return l.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT),this.position+=t.byteLength,t},l.prototype.readUint32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var r=new Uint32Array(e);return l.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),l.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},l.prototype.readUint16Array=function(e,t){e=null==e?this.byteLength-this.position/2:e;var r=new Uint16Array(e);return l.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),l.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},l.prototype.readUint8Array=function(e){e=null==e?this.byteLength-this.position:e;var t=new Uint8Array(e);return l.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT),this.position+=t.byteLength,t},l.prototype.readFloat64Array=function(e,t){e=null==e?this.byteLength-this.position/8:e;var r=new Float64Array(e);return l.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),l.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},l.prototype.readFloat32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var r=new Float32Array(e);return l.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),l.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},l.prototype.readInt32=function(e){var t=this._dataView.getInt32(this.position,null==e?this.endianness:e);return this.position+=4,t},l.prototype.readInt16=function(e){var t=this._dataView.getInt16(this.position,null==e?this.endianness:e);return this.position+=2,t},l.prototype.readInt8=function(){var e=this._dataView.getInt8(this.position);return this.position+=1,e},l.prototype.readUint32=function(e){var t=this._dataView.getUint32(this.position,null==e?this.endianness:e);return this.position+=4,t},l.prototype.readUint16=function(e){var t=this._dataView.getUint16(this.position,null==e?this.endianness:e);return this.position+=2,t},l.prototype.readUint8=function(){var e=this._dataView.getUint8(this.position);return this.position+=1,e},l.prototype.readFloat32=function(e){var t=this._dataView.getFloat32(this.position,null==e?this.endianness:e);return this.position+=4,t},l.prototype.readFloat64=function(e){var t=this._dataView.getFloat64(this.position,null==e?this.endianness:e);return this.position+=8,t},l.endianness=new Int8Array(new Int16Array([1]).buffer)[0]>0,l.memcpy=function(e,t,r,i,n){var s=new Uint8Array(e,t,n),o=new Uint8Array(r,i,n);s.set(o)},l.arrayToNative=function(e,t){return t==this.endianness?e:this.flipArrayEndianness(e)},l.nativeToEndian=function(e,t){return this.endianness==t?e:this.flipArrayEndianness(e)},l.flipArrayEndianness=function(e){for(var t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=0;r<e.byteLength;r+=e.BYTES_PER_ELEMENT)for(var i=r+e.BYTES_PER_ELEMENT-1,n=r;i>n;i--,n++){var s=t[n];t[n]=t[i],t[i]=s}return e},l.prototype.failurePosition=0,String.fromCharCodeUint8=function(e){for(var t=[],r=0;r<e.length;r++)t[r]=e[r];return String.fromCharCode.apply(null,t)},l.prototype.readString=function(e,t){return null==t||"ASCII"==t?String.fromCharCodeUint8.apply(null,[this.mapUint8Array(null==e?this.byteLength-this.position:e)]):new TextDecoder(t).decode(this.mapUint8Array(e))},l.prototype.readCString=function(e){var t=this.byteLength-this.position,r=new Uint8Array(this._buffer,this._byteOffset+this.position),i=t;null!=e&&(i=Math.min(e,t));for(var n=0;n<i&&0!==r[n];n++);var s=String.fromCharCodeUint8.apply(null,[this.mapUint8Array(n)]);return null!=e?this.position+=i-n:n!=t&&(this.position+=1),s};var d=Math.pow(2,32);l.prototype.readInt64=function(){return this.readInt32()*d+this.readUint32()},l.prototype.readUint64=function(){return this.readUint32()*d+this.readUint32()},l.prototype.readInt64=function(){return this.readUint32()*d+this.readUint32()},l.prototype.readUint24=function(){return(this.readUint8()<<16)+(this.readUint8()<<8)+this.readUint8()},t.DataStream=l,l.prototype.save=function(e){var t=new Blob([this.buffer]);if(!window.URL||!URL.createObjectURL)throw"DataStream.save: Can't create object URL.";var r=window.URL.createObjectURL(t),i=document.createElement("a");document.body.appendChild(i),i.setAttribute("href",r),i.setAttribute("download",e),i.setAttribute("target","_self"),i.click(),window.URL.revokeObjectURL(r)},l.prototype._dynamicSize=!0,Object.defineProperty(l.prototype,"dynamicSize",{get:function(){return this._dynamicSize},set:function(e){e||this._trimAlloc(),this._dynamicSize=e}}),l.prototype.shift=function(e){var t=new ArrayBuffer(this._byteLength-e),r=new Uint8Array(t),i=new Uint8Array(this._buffer,e,r.length);r.set(i),this.buffer=t,this.position-=e},l.prototype.writeInt32Array=function(e,t){if(this._realloc(4*e.length),e instanceof Int32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapInt32Array(e.length,t);else for(var r=0;r<e.length;r++)this.writeInt32(e[r],t)},l.prototype.writeInt16Array=function(e,t){if(this._realloc(2*e.length),e instanceof Int16Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapInt16Array(e.length,t);else for(var r=0;r<e.length;r++)this.writeInt16(e[r],t)},l.prototype.writeInt8Array=function(e){if(this._realloc(1*e.length),e instanceof Int8Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapInt8Array(e.length);else for(var t=0;t<e.length;t++)this.writeInt8(e[t])},l.prototype.writeUint32Array=function(e,t){if(this._realloc(4*e.length),e instanceof Uint32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapUint32Array(e.length,t);else for(var r=0;r<e.length;r++)this.writeUint32(e[r],t)},l.prototype.writeUint16Array=function(e,t){if(this._realloc(2*e.length),e instanceof Uint16Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapUint16Array(e.length,t);else for(var r=0;r<e.length;r++)this.writeUint16(e[r],t)},l.prototype.writeUint8Array=function(e){if(this._realloc(1*e.length),e instanceof Uint8Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapUint8Array(e.length);else for(var t=0;t<e.length;t++)this.writeUint8(e[t])},l.prototype.writeFloat64Array=function(e,t){if(this._realloc(8*e.length),e instanceof Float64Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapFloat64Array(e.length,t);else for(var r=0;r<e.length;r++)this.writeFloat64(e[r],t)},l.prototype.writeFloat32Array=function(e,t){if(this._realloc(4*e.length),e instanceof Float32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)l.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapFloat32Array(e.length,t);else for(var r=0;r<e.length;r++)this.writeFloat32(e[r],t)},l.prototype.writeInt32=function(e,t){this._realloc(4),this._dataView.setInt32(this.position,e,null==t?this.endianness:t),this.position+=4},l.prototype.writeInt16=function(e,t){this._realloc(2),this._dataView.setInt16(this.position,e,null==t?this.endianness:t),this.position+=2},l.prototype.writeInt8=function(e){this._realloc(1),this._dataView.setInt8(this.position,e),this.position+=1},l.prototype.writeUint32=function(e,t){this._realloc(4),this._dataView.setUint32(this.position,e,null==t?this.endianness:t),this.position+=4},l.prototype.writeUint16=function(e,t){this._realloc(2),this._dataView.setUint16(this.position,e,null==t?this.endianness:t),this.position+=2},l.prototype.writeUint8=function(e){this._realloc(1),this._dataView.setUint8(this.position,e),this.position+=1},l.prototype.writeFloat32=function(e,t){this._realloc(4),this._dataView.setFloat32(this.position,e,null==t?this.endianness:t),this.position+=4},l.prototype.writeFloat64=function(e,t){this._realloc(8),this._dataView.setFloat64(this.position,e,null==t?this.endianness:t),this.position+=8},l.prototype.writeUCS2String=function(e,t,r){null==r&&(r=e.length);for(var i=0;i<e.length&&i<r;i++)this.writeUint16(e.charCodeAt(i),t);for(;i<r;i++)this.writeUint16(0)},l.prototype.writeString=function(e,t,r){var i=0;if(null==t||"ASCII"==t)if(null!=r){var n=Math.min(e.length,r);for(i=0;i<n;i++)this.writeUint8(e.charCodeAt(i));for(;i<r;i++)this.writeUint8(0)}else for(i=0;i<e.length;i++)this.writeUint8(e.charCodeAt(i));else this.writeUint8Array(new TextEncoder(t).encode(e.substring(0,r)))},l.prototype.writeCString=function(e,t){var r=0;if(null!=t){var i=Math.min(e.length,t);for(r=0;r<i;r++)this.writeUint8(e.charCodeAt(r));for(;r<t;r++)this.writeUint8(0)}else{for(r=0;r<e.length;r++)this.writeUint8(e.charCodeAt(r));this.writeUint8(0)}},l.prototype.writeStruct=function(e,t){for(var r=0;r<e.length;r+=2){var i=e[r+1];this.writeType(i,t[e[r]],t)}},l.prototype.writeType=function(e,t,r){var i;if("function"==typeof e)return e(this,t);if("object"==typeof e&&!(e instanceof Array))return e.set(this,t,r);var n=null,s="ASCII",o=this.position;switch("string"==typeof e&&/:/.test(e)&&(i=e.split(":"),e=i[0],n=parseInt(i[1])),"string"==typeof e&&/,/.test(e)&&(i=e.split(","),e=i[0],s=parseInt(i[1])),e){case"uint8":this.writeUint8(t);break;case"int8":this.writeInt8(t);break;case"uint16":this.writeUint16(t,this.endianness);break;case"int16":this.writeInt16(t,this.endianness);break;case"uint32":this.writeUint32(t,this.endianness);break;case"int32":this.writeInt32(t,this.endianness);break;case"float32":this.writeFloat32(t,this.endianness);break;case"float64":this.writeFloat64(t,this.endianness);break;case"uint16be":this.writeUint16(t,l.BIG_ENDIAN);break;case"int16be":this.writeInt16(t,l.BIG_ENDIAN);break;case"uint32be":this.writeUint32(t,l.BIG_ENDIAN);break;case"int32be":this.writeInt32(t,l.BIG_ENDIAN);break;case"float32be":this.writeFloat32(t,l.BIG_ENDIAN);break;case"float64be":this.writeFloat64(t,l.BIG_ENDIAN);break;case"uint16le":this.writeUint16(t,l.LITTLE_ENDIAN);break;case"int16le":this.writeInt16(t,l.LITTLE_ENDIAN);break;case"uint32le":this.writeUint32(t,l.LITTLE_ENDIAN);break;case"int32le":this.writeInt32(t,l.LITTLE_ENDIAN);break;case"float32le":this.writeFloat32(t,l.LITTLE_ENDIAN);break;case"float64le":this.writeFloat64(t,l.LITTLE_ENDIAN);break;case"cstring":this.writeCString(t,n);break;case"string":this.writeString(t,s,n);break;case"u16string":this.writeUCS2String(t,this.endianness,n);break;case"u16stringle":this.writeUCS2String(t,l.LITTLE_ENDIAN,n);break;case"u16stringbe":this.writeUCS2String(t,l.BIG_ENDIAN,n);break;default:if(3==e.length){for(var a=e[1],d=0;d<t.length;d++)this.writeType(a,t[d]);break}this.writeStruct(e,t)}null!=n&&(this.position=o,this._realloc(n),this.position=o+n)},l.prototype.writeUint64=function(e){var t=Math.floor(e/d);this.writeUint32(t),this.writeUint32(4294967295&e)},l.prototype.writeUint24=function(e){this.writeUint8((16711680&e)>>16),this.writeUint8((65280&e)>>8),this.writeUint8(255&e)},l.prototype.adjustUint32=function(e,t){var r=this.position;this.seek(e),this.writeUint32(t),this.seek(r)},l.prototype.mapInt32Array=function(e,t){this._realloc(4*e);var r=new Int32Array(this._buffer,this.byteOffset+this.position,e);return l.arrayToNative(r,null==t?this.endianness:t),this.position+=4*e,r},l.prototype.mapInt16Array=function(e,t){this._realloc(2*e);var r=new Int16Array(this._buffer,this.byteOffset+this.position,e);return l.arrayToNative(r,null==t?this.endianness:t),this.position+=2*e,r},l.prototype.mapInt8Array=function(e){this._realloc(1*e);var t=new Int8Array(this._buffer,this.byteOffset+this.position,e);return this.position+=1*e,t},l.prototype.mapUint32Array=function(e,t){this._realloc(4*e);var r=new Uint32Array(this._buffer,this.byteOffset+this.position,e);return l.arrayToNative(r,null==t?this.endianness:t),this.position+=4*e,r},l.prototype.mapUint16Array=function(e,t){this._realloc(2*e);var r=new Uint16Array(this._buffer,this.byteOffset+this.position,e);return l.arrayToNative(r,null==t?this.endianness:t),this.position+=2*e,r},l.prototype.mapFloat64Array=function(e,t){this._realloc(8*e);var r=new Float64Array(this._buffer,this.byteOffset+this.position,e);return l.arrayToNative(r,null==t?this.endianness:t),this.position+=8*e,r},l.prototype.mapFloat32Array=function(e,t){this._realloc(4*e);var r=new Float32Array(this._buffer,this.byteOffset+this.position,e);return l.arrayToNative(r,null==t?this.endianness:t),this.position+=4*e,r};var u=function(e){this.buffers=[],this.bufferIndex=-1,e&&(this.insertBuffer(e),this.bufferIndex=0)};(u.prototype=new l(new ArrayBuffer,0,l.BIG_ENDIAN)).initialized=function(){var e;return this.bufferIndex>-1||(this.buffers.length>0?0===(e=this.buffers[0]).fileStart?(this.buffer=e,this.bufferIndex=0,o.debug("MultiBufferStream","Stream ready for parsing"),!0):(o.warn("MultiBufferStream","The first buffer should have a fileStart of 0"),this.logBufferLevel(),!1):(o.warn("MultiBufferStream","No buffer to start parsing from"),this.logBufferLevel(),!1))},ArrayBuffer.concat=function(e,t){o.debug("ArrayBuffer","Trying to create a new buffer of size: "+(e.byteLength+t.byteLength));var r=new Uint8Array(e.byteLength+t.byteLength);return r.set(new Uint8Array(e),0),r.set(new Uint8Array(t),e.byteLength),r.buffer},u.prototype.reduceBuffer=function(e,t,r){var i;return(i=new Uint8Array(r)).set(new Uint8Array(e,t,r)),i.buffer.fileStart=e.fileStart+t,i.buffer.usedBytes=0,i.buffer},u.prototype.insertBuffer=function(e){for(var t=!0,r=0;r<this.buffers.length;r++){var i=this.buffers[r];if(e.fileStart<=i.fileStart){if(e.fileStart===i.fileStart){if(e.byteLength>i.byteLength){this.buffers.splice(r,1),r--;continue}o.warn("MultiBufferStream","Buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+") already appended, ignoring")}else e.fileStart+e.byteLength<=i.fileStart||(e=this.reduceBuffer(e,0,i.fileStart-e.fileStart)),o.debug("MultiBufferStream","Appending new buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+")"),this.buffers.splice(r,0,e),0===r&&(this.buffer=e);t=!1;break}if(e.fileStart<i.fileStart+i.byteLength){var n=i.fileStart+i.byteLength-e.fileStart,s=e.byteLength-n;if(!(s>0)){t=!1;break}e=this.reduceBuffer(e,n,s)}}t&&(o.debug("MultiBufferStream","Appending new buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+")"),this.buffers.push(e),0===r&&(this.buffer=e))},u.prototype.logBufferLevel=function(e){var t,r,i,n,s,a=[],l="";for(i=0,n=0,t=0;t<this.buffers.length;t++)r=this.buffers[t],0===t?(s={},a.push(s),s.start=r.fileStart,s.end=r.fileStart+r.byteLength,l+="["+s.start+"-"):s.end===r.fileStart?s.end=r.fileStart+r.byteLength:((s={}).start=r.fileStart,l+=a[a.length-1].end-1+"], ["+s.start+"-",s.end=r.fileStart+r.byteLength,a.push(s)),i+=r.usedBytes,n+=r.byteLength;a.length>0&&(l+=s.end-1+"]");var d=e?o.info:o.debug;0===this.buffers.length?d("MultiBufferStream","No more buffer in memory"):d("MultiBufferStream",this.buffers.length+" stored buffer(s) ("+i+"/"+n+" bytes), continuous ranges: "+l)},u.prototype.cleanBuffers=function(){var e,t;for(e=0;e<this.buffers.length;e++)(t=this.buffers[e]).usedBytes===t.byteLength&&(o.debug("MultiBufferStream","Removing buffer #"+e),this.buffers.splice(e,1),e--)},u.prototype.mergeNextBuffer=function(){var e;if(this.bufferIndex+1<this.buffers.length){if((e=this.buffers[this.bufferIndex+1]).fileStart===this.buffer.fileStart+this.buffer.byteLength){var t=this.buffer.byteLength,r=this.buffer.usedBytes,i=this.buffer.fileStart;return this.buffers[this.bufferIndex]=ArrayBuffer.concat(this.buffer,e),this.buffer=this.buffers[this.bufferIndex],this.buffers.splice(this.bufferIndex+1,1),this.buffer.usedBytes=r,this.buffer.fileStart=i,o.debug("ISOFile","Concatenating buffer for box parsing (length: "+t+"->"+this.buffer.byteLength+")"),!0}return!1}return!1},u.prototype.findPosition=function(e,t,r){var i,n=null,s=-1;for(i=!0===e?0:this.bufferIndex;i<this.buffers.length&&(n=this.buffers[i]).fileStart<=t;)s=i,r&&(n.fileStart+n.byteLength<=t?n.usedBytes=n.byteLength:n.usedBytes=t-n.fileStart,this.logBufferLevel()),i++;return-1!==s&&(n=this.buffers[s]).fileStart+n.byteLength>=t?(o.debug("MultiBufferStream","Found position in existing buffer #"+s),s):-1},u.prototype.findEndContiguousBuf=function(e){var t,r,i,n=void 0!==e?e:this.bufferIndex;if(r=this.buffers[n],this.buffers.length>n+1)for(t=n+1;t<this.buffers.length&&(i=this.buffers[t]).fileStart===r.fileStart+r.byteLength;t++)r=i;return r.fileStart+r.byteLength},u.prototype.getEndFilePositionAfter=function(e){var t=this.findPosition(!0,e,!1);return-1!==t?this.findEndContiguousBuf(t):e},u.prototype.addUsedBytes=function(e){this.buffer.usedBytes+=e,this.logBufferLevel()},u.prototype.setAllUsedBytes=function(){this.buffer.usedBytes=this.buffer.byteLength,this.logBufferLevel()},u.prototype.seek=function(e,t,r){var i;return-1!==(i=this.findPosition(t,e,r))?(this.buffer=this.buffers[i],this.bufferIndex=i,this.position=e-this.buffer.fileStart,o.debug("MultiBufferStream","Repositioning parser at buffer position: "+this.position),!0):(o.debug("MultiBufferStream","Position "+e+" not found in buffered data"),!1)},u.prototype.getPosition=function(){if(-1===this.bufferIndex||null===this.buffers[this.bufferIndex])throw"Error accessing position in the MultiBufferStream";return this.buffers[this.bufferIndex].fileStart+this.position},u.prototype.getLength=function(){return this.byteLength},u.prototype.getEndPosition=function(){if(-1===this.bufferIndex||null===this.buffers[this.bufferIndex])throw"Error accessing position in the MultiBufferStream";return this.buffers[this.bufferIndex].fileStart+this.byteLength},t.MultiBufferStream=u;var h=function(){var e=[];e[3]="ES_Descriptor",e[4]="DecoderConfigDescriptor",e[5]="DecoderSpecificInfo",e[6]="SLConfigDescriptor",this.getDescriptorName=function(t){return e[t]};var t=this,r={};return this.parseOneDescriptor=function(t){var i,n,s,a=0;for(i=t.readUint8(),s=t.readUint8();128&s;)a=(127&s)<<7,s=t.readUint8();return a+=127&s,o.debug("MPEG4DescriptorParser","Found "+(e[i]||"Descriptor "+i)+", size "+a+" at position "+t.getPosition()),(n=e[i]?new r[e[i]](a):new r.Descriptor(a)).parse(t),n},r.Descriptor=function(e,t){this.tag=e,this.size=t,this.descs=[]},r.Descriptor.prototype.parse=function(e){this.data=e.readUint8Array(this.size)},r.Descriptor.prototype.findDescriptor=function(e){for(var t=0;t<this.descs.length;t++)if(this.descs[t].tag==e)return this.descs[t];return null},r.Descriptor.prototype.parseRemainingDescriptors=function(e){for(var r=e.position;e.position<r+this.size;){var i=t.parseOneDescriptor(e);this.descs.push(i)}},r.ES_Descriptor=function(e){r.Descriptor.call(this,3,e)},r.ES_Descriptor.prototype=new r.Descriptor,r.ES_Descriptor.prototype.parse=function(e){if(this.ES_ID=e.readUint16(),this.flags=e.readUint8(),this.size-=3,128&this.flags?(this.dependsOn_ES_ID=e.readUint16(),this.size-=2):this.dependsOn_ES_ID=0,64&this.flags){var t=e.readUint8();this.URL=e.readString(t),this.size-=t+1}else this.URL="";32&this.flags?(this.OCR_ES_ID=e.readUint16(),this.size-=2):this.OCR_ES_ID=0,this.parseRemainingDescriptors(e)},r.ES_Descriptor.prototype.getOTI=function(e){var t=this.findDescriptor(4);return t?t.oti:0},r.ES_Descriptor.prototype.getAudioConfig=function(e){var t=this.findDescriptor(4);if(!t)return null;var r=t.findDescriptor(5);if(r&&r.data){var i=(248&r.data[0])>>3;return 31===i&&r.data.length>=2&&(i=32+((7&r.data[0])<<3)+((224&r.data[1])>>5)),i}return null},r.DecoderConfigDescriptor=function(e){r.Descriptor.call(this,4,e)},r.DecoderConfigDescriptor.prototype=new r.Descriptor,r.DecoderConfigDescriptor.prototype.parse=function(e){this.oti=e.readUint8(),this.streamType=e.readUint8(),this.upStream=0!=(this.streamType>>1&1),this.streamType=this.streamType>>>2,this.bufferSize=e.readUint24(),this.maxBitrate=e.readUint32(),this.avgBitrate=e.readUint32(),this.size-=13,this.parseRemainingDescriptors(e)},r.DecoderSpecificInfo=function(e){r.Descriptor.call(this,5,e)},r.DecoderSpecificInfo.prototype=new r.Descriptor,r.SLConfigDescriptor=function(e){r.Descriptor.call(this,6,e)},r.SLConfigDescriptor.prototype=new r.Descriptor,this};t.MPEG4DescriptorParser=h;var c={ERR_INVALID_DATA:-1,ERR_NOT_ENOUGH_DATA:0,OK:1,BASIC_BOXES:["mdat","idat","free","skip","meco","strk"],FULL_BOXES:["hmhd","nmhd","iods","xml ","bxml","ipro","mere"],CONTAINER_BOXES:[["moov",["trak","pssh"]],["trak"],["edts"],["mdia"],["minf"],["dinf"],["stbl",["sgpd","sbgp"]],["mvex",["trex"]],["moof",["traf"]],["traf",["trun","sgpd","sbgp"]],["vttc"],["tref"],["iref"],["mfra",["tfra"]],["meco"],["hnti"],["hinf"],["strk"],["strd"],["sinf"],["rinf"],["schi"],["trgr"],["udta",["kind"]],["iprp",["ipma"]],["ipco"],["grpl"],["j2kH"],["etyp",["tyco"]]],boxCodes:[],fullBoxCodes:[],containerBoxCodes:[],sampleEntryCodes:{},sampleGroupEntryCodes:[],trackGroupTypes:[],UUIDBoxes:{},UUIDs:[],initialize:function(){c.FullBox.prototype=new c.Box,c.ContainerBox.prototype=new c.Box,c.SampleEntry.prototype=new c.Box,c.TrackGroupTypeBox.prototype=new c.FullBox,c.BASIC_BOXES.forEach((function(e){c.createBoxCtor(e)})),c.FULL_BOXES.forEach((function(e){c.createFullBoxCtor(e)})),c.CONTAINER_BOXES.forEach((function(e){c.createContainerBoxCtor(e[0],null,e[1])}))},Box:function(e,t,r){this.type=e,this.size=t,this.uuid=r},FullBox:function(e,t,r){c.Box.call(this,e,t,r),this.flags=0,this.version=0},ContainerBox:function(e,t,r){c.Box.call(this,e,t,r),this.boxes=[]},SampleEntry:function(e,t,r,i){c.ContainerBox.call(this,e,t),this.hdr_size=r,this.start=i},SampleGroupEntry:function(e){this.grouping_type=e},TrackGroupTypeBox:function(e,t){c.FullBox.call(this,e,t)},createBoxCtor:function(e,t){c.boxCodes.push(e),c[e+"Box"]=function(t){c.Box.call(this,e,t)},c[e+"Box"].prototype=new c.Box,t&&(c[e+"Box"].prototype.parse=t)},createFullBoxCtor:function(e,t){c[e+"Box"]=function(t){c.FullBox.call(this,e,t)},c[e+"Box"].prototype=new c.FullBox,c[e+"Box"].prototype.parse=function(e){this.parseFullHeader(e),t&&t.call(this,e)}},addSubBoxArrays:function(e){if(e){this.subBoxNames=e;for(var t=e.length,r=0;r<t;r++)this[e[r]+"s"]=[]}},createContainerBoxCtor:function(e,t,r){c[e+"Box"]=function(t){c.ContainerBox.call(this,e,t),c.addSubBoxArrays.call(this,r)},c[e+"Box"].prototype=new c.ContainerBox,t&&(c[e+"Box"].prototype.parse=t)},createMediaSampleEntryCtor:function(e,t,r){c.sampleEntryCodes[e]=[],c[e+"SampleEntry"]=function(e,t){c.SampleEntry.call(this,e,t),c.addSubBoxArrays.call(this,r)},c[e+"SampleEntry"].prototype=new c.SampleEntry,t&&(c[e+"SampleEntry"].prototype.parse=t)},createSampleEntryCtor:function(e,t,r,i){c.sampleEntryCodes[e].push(t),c[t+"SampleEntry"]=function(r){c[e+"SampleEntry"].call(this,t,r),c.addSubBoxArrays.call(this,i)},c[t+"SampleEntry"].prototype=new c[e+"SampleEntry"],r&&(c[t+"SampleEntry"].prototype.parse=r)},createEncryptedSampleEntryCtor:function(e,t,r){c.createSampleEntryCtor.call(this,e,t,r,["sinf"])},createSampleGroupCtor:function(e,t){c[e+"SampleGroupEntry"]=function(t){c.SampleGroupEntry.call(this,e,t)},c[e+"SampleGroupEntry"].prototype=new c.SampleGroupEntry,t&&(c[e+"SampleGroupEntry"].prototype.parse=t)},createTrackGroupCtor:function(e,t){c[e+"TrackGroupTypeBox"]=function(t){c.TrackGroupTypeBox.call(this,e,t)},c[e+"TrackGroupTypeBox"].prototype=new c.TrackGroupTypeBox,t&&(c[e+"TrackGroupTypeBox"].prototype.parse=t)},createUUIDBox:function(e,t,r,i){c.UUIDs.push(e),c.UUIDBoxes[e]=function(i){t?c.FullBox.call(this,"uuid",i,e):r?c.ContainerBox.call(this,"uuid",i,e):c.Box.call(this,"uuid",i,e)},c.UUIDBoxes[e].prototype=t?new c.FullBox:r?new c.ContainerBox:new c.Box,i&&(c.UUIDBoxes[e].prototype.parse=t?function(e){this.parseFullHeader(e),i&&i.call(this,e)}:i)}};function f(e,t){this.x=e,this.y=t}function p(e,t){this.bad_pixel_row=e,this.bad_pixel_column=t}c.initialize(),c.TKHD_FLAG_ENABLED=1,c.TKHD_FLAG_IN_MOVIE=2,c.TKHD_FLAG_IN_PREVIEW=4,c.TFHD_FLAG_BASE_DATA_OFFSET=1,c.TFHD_FLAG_SAMPLE_DESC=2,c.TFHD_FLAG_SAMPLE_DUR=8,c.TFHD_FLAG_SAMPLE_SIZE=16,c.TFHD_FLAG_SAMPLE_FLAGS=32,c.TFHD_FLAG_DUR_EMPTY=65536,c.TFHD_FLAG_DEFAULT_BASE_IS_MOOF=131072,c.TRUN_FLAGS_DATA_OFFSET=1,c.TRUN_FLAGS_FIRST_FLAG=4,c.TRUN_FLAGS_DURATION=256,c.TRUN_FLAGS_SIZE=512,c.TRUN_FLAGS_FLAGS=1024,c.TRUN_FLAGS_CTS_OFFSET=2048,c.Box.prototype.add=function(e){return this.addBox(new c[e+"Box"])},c.Box.prototype.addBox=function(e){return this.boxes.push(e),this[e.type+"s"]?this[e.type+"s"].push(e):this[e.type]=e,e},c.Box.prototype.set=function(e,t){return this[e]=t,this},c.Box.prototype.addEntry=function(e,t){var r=t||"entries";return this[r]||(this[r]=[]),this[r].push(e),this},t.BoxParser=c,c.parseUUID=function(e){return c.parseHex16(e)},c.parseHex16=function(e){for(var t="",r=0;r<16;r++){var i=e.readUint8().toString(16);t+=1===i.length?"0"+i:i}return t},c.parseOneBox=function(e,t,r){var i,n,s,a=e.getPosition(),l=0;if(e.getEndPosition()-a<8)return o.debug("BoxParser","Not enough data in stream to parse the type and size of the box"),{code:c.ERR_NOT_ENOUGH_DATA};if(r&&r<8)return o.debug("BoxParser","Not enough bytes left in the parent box to parse a new box"),{code:c.ERR_NOT_ENOUGH_DATA};var d=e.readUint32(),u=e.readString(4),h=u;if(o.debug("BoxParser","Found box of type '"+u+"' and size "+d+" at position "+a),l=8,"uuid"==u){if(e.getEndPosition()-e.getPosition()<16||r-l<16)return e.seek(a),o.debug("BoxParser","Not enough bytes left in the parent box to parse a UUID box"),{code:c.ERR_NOT_ENOUGH_DATA};l+=16,h=s=c.parseUUID(e)}if(1==d){if(e.getEndPosition()-e.getPosition()<8||r&&r-l<8)return e.seek(a),o.warn("BoxParser",'Not enough data in stream to parse the extended size of the "'+u+'" box'),{code:c.ERR_NOT_ENOUGH_DATA};d=e.readUint64(),l+=8}else if(0===d)if(r)d=r;else if("mdat"!==u)return o.error("BoxParser","Unlimited box size not supported for type: '"+u+"'"),i=new c.Box(u,d),{code:c.OK,box:i,size:i.size};return 0!==d&&d<l?(o.error("BoxParser","Box of type "+u+" has an invalid size "+d+" (too small to be a box)"),{code:c.ERR_NOT_ENOUGH_DATA,type:u,size:d,hdr_size:l,start:a}):0!==d&&r&&d>r?(o.error("BoxParser","Box of type '"+u+"' has a size "+d+" greater than its container size "+r),{code:c.ERR_NOT_ENOUGH_DATA,type:u,size:d,hdr_size:l,start:a}):0!==d&&a+d>e.getEndPosition()?(e.seek(a),o.info("BoxParser","Not enough data in stream to parse the entire '"+u+"' box"),{code:c.ERR_NOT_ENOUGH_DATA,type:u,size:d,hdr_size:l,start:a}):t?{code:c.OK,type:u,size:d,hdr_size:l,start:a}:(c[u+"Box"]?i=new c[u+"Box"](d):"uuid"!==u?(o.warn("BoxParser","Unknown box type: '"+u+"'"),(i=new c.Box(u,d)).has_unparsed_data=!0):c.UUIDBoxes[s]?i=new c.UUIDBoxes[s](d):(o.warn("BoxParser","Unknown uuid type: '"+s+"'"),(i=new c.Box(u,d)).uuid=s,i.has_unparsed_data=!0),i.hdr_size=l,i.start=a,i.write===c.Box.prototype.write&&"mdat"!==i.type&&(o.info("BoxParser","'"+h+"' box writing not yet implemented, keeping unparsed data in memory for later write"),i.parseDataAndRewind(e)),i.parse(e),(n=e.getPosition()-(i.start+i.size))<0?(o.warn("BoxParser","Parsing of box '"+h+"' did not read the entire indicated box data size (missing "+-n+" bytes), seeking forward"),e.seek(i.start+i.size)):n>0&&(o.error("BoxParser","Parsing of box '"+h+"' read "+n+" more bytes than the indicated box data size, seeking backwards"),0!==i.size&&e.seek(i.start+i.size)),{code:c.OK,box:i,size:i.size})},c.Box.prototype.parse=function(e){"mdat"!=this.type?this.data=e.readUint8Array(this.size-this.hdr_size):0===this.size?e.seek(e.getEndPosition()):e.seek(this.start+this.size)},c.Box.prototype.parseDataAndRewind=function(e){this.data=e.readUint8Array(this.size-this.hdr_size),e.position-=this.size-this.hdr_size},c.FullBox.prototype.parseDataAndRewind=function(e){this.parseFullHeader(e),this.data=e.readUint8Array(this.size-this.hdr_size),this.hdr_size-=4,e.position-=this.size-this.hdr_size},c.FullBox.prototype.parseFullHeader=function(e){this.version=e.readUint8(),this.flags=e.readUint24(),this.hdr_size+=4},c.FullBox.prototype.parse=function(e){this.parseFullHeader(e),this.data=e.readUint8Array(this.size-this.hdr_size)},c.ContainerBox.prototype.parse=function(e){for(var t,r;e.getPosition()<this.start+this.size;){if((t=c.parseOneBox(e,!1,this.size-(e.getPosition()-this.start))).code!==c.OK)return;if(r=t.box,this.boxes.push(r),this.subBoxNames&&-1!=this.subBoxNames.indexOf(r.type))this[this.subBoxNames[this.subBoxNames.indexOf(r.type)]+"s"].push(r);else{var i="uuid"!==r.type?r.type:r.uuid;this[i]?o.warn("Box of type "+i+" already stored in field of this type"):this[i]=r}}},c.Box.prototype.parseLanguage=function(e){this.language=e.readUint16();var t=[];t[0]=this.language>>10&31,t[1]=this.language>>5&31,t[2]=31&this.language,this.languageString=String.fromCharCode(t[0]+96,t[1]+96,t[2]+96)},c.SAMPLE_ENTRY_TYPE_VISUAL="Visual",c.SAMPLE_ENTRY_TYPE_AUDIO="Audio",c.SAMPLE_ENTRY_TYPE_HINT="Hint",c.SAMPLE_ENTRY_TYPE_METADATA="Metadata",c.SAMPLE_ENTRY_TYPE_SUBTITLE="Subtitle",c.SAMPLE_ENTRY_TYPE_SYSTEM="System",c.SAMPLE_ENTRY_TYPE_TEXT="Text",c.SampleEntry.prototype.parseHeader=function(e){e.readUint8Array(6),this.data_reference_index=e.readUint16(),this.hdr_size+=8},c.SampleEntry.prototype.parse=function(e){this.parseHeader(e),this.data=e.readUint8Array(this.size-this.hdr_size)},c.SampleEntry.prototype.parseDataAndRewind=function(e){this.parseHeader(e),this.data=e.readUint8Array(this.size-this.hdr_size),this.hdr_size-=8,e.position-=this.size-this.hdr_size},c.SampleEntry.prototype.parseFooter=function(e){c.ContainerBox.prototype.parse.call(this,e)},c.createMediaSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_HINT),c.createMediaSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_METADATA),c.createMediaSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SUBTITLE),c.createMediaSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SYSTEM),c.createMediaSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_TEXT),c.createMediaSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,(function(e){var t;this.parseHeader(e),e.readUint16(),e.readUint16(),e.readUint32Array(3),this.width=e.readUint16(),this.height=e.readUint16(),this.horizresolution=e.readUint32(),this.vertresolution=e.readUint32(),e.readUint32(),this.frame_count=e.readUint16(),t=Math.min(31,e.readUint8()),this.compressorname=e.readString(t),t<31&&e.readString(31-t),this.depth=e.readUint16(),e.readUint16(),this.parseFooter(e)})),c.createMediaSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO,(function(e){this.parseHeader(e),e.readUint32Array(2),this.channel_count=e.readUint16(),this.samplesize=e.readUint16(),e.readUint16(),e.readUint16(),this.samplerate=e.readUint32()/65536,this.parseFooter(e)})),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"avc1"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"avc2"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"avc3"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"avc4"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"av01"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"dav1"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"hvc1"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"hev1"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"hvt1"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"lhe1"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"dvh1"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"dvhe"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"vvc1"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"vvi1"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"vvs1"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"vvcN"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"vp08"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"vp09"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"avs3"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"j2ki"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"mjp2"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"mjpg"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"uncv"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO,"mp4a"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO,"ac-3"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO,"ac-4"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO,"ec-3"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO,"Opus"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO,"mha1"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO,"mha2"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO,"mhm1"),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO,"mhm2"),c.createEncryptedSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_VISUAL,"encv"),c.createEncryptedSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_AUDIO,"enca"),c.createEncryptedSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SUBTITLE,"encu"),c.createEncryptedSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SYSTEM,"encs"),c.createEncryptedSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_TEXT,"enct"),c.createEncryptedSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_METADATA,"encm"),c.createBoxCtor("a1lx",(function(e){var t=16*(1+(1&(1&e.readUint8())));this.layer_size=[];for(var r=0;r<3;r++)this.layer_size[r]=16==t?e.readUint16():e.readUint32()})),c.createBoxCtor("a1op",(function(e){this.op_index=e.readUint8()})),c.createFullBoxCtor("auxC",(function(e){this.aux_type=e.readCString();var t=this.size-this.hdr_size-(this.aux_type.length+1);this.aux_subtype=e.readUint8Array(t)})),c.createBoxCtor("av1C",(function(e){var t=e.readUint8();if(t>>7&!1)o.error("av1C marker problem");else if(this.version=127&t,1===this.version)if(t=e.readUint8(),this.seq_profile=t>>5&7,this.seq_level_idx_0=31&t,t=e.readUint8(),this.seq_tier_0=t>>7&1,this.high_bitdepth=t>>6&1,this.twelve_bit=t>>5&1,this.monochrome=t>>4&1,this.chroma_subsampling_x=t>>3&1,this.chroma_subsampling_y=t>>2&1,this.chroma_sample_position=3&t,t=e.readUint8(),this.reserved_1=t>>5&7,0===this.reserved_1){if(this.initial_presentation_delay_present=t>>4&1,1===this.initial_presentation_delay_present)this.initial_presentation_delay_minus_one=15&t;else if(this.reserved_2=15&t,0!==this.reserved_2)return void o.error("av1C reserved_2 parsing problem");var r=this.size-this.hdr_size-4;this.configOBUs=e.readUint8Array(r)}else o.error("av1C reserved_1 parsing problem");else o.error("av1C version "+this.version+" not supported")})),c.createBoxCtor("avcC",(function(e){var t,r;for(this.configurationVersion=e.readUint8(),this.AVCProfileIndication=e.readUint8(),this.profile_compatibility=e.readUint8(),this.AVCLevelIndication=e.readUint8(),this.lengthSizeMinusOne=3&e.readUint8(),this.nb_SPS_nalus=31&e.readUint8(),r=this.size-this.hdr_size-6,this.SPS=[],t=0;t<this.nb_SPS_nalus;t++)this.SPS[t]={},this.SPS[t].length=e.readUint16(),this.SPS[t].nalu=e.readUint8Array(this.SPS[t].length),r-=2+this.SPS[t].length;for(this.nb_PPS_nalus=e.readUint8(),r--,this.PPS=[],t=0;t<this.nb_PPS_nalus;t++)this.PPS[t]={},this.PPS[t].length=e.readUint16(),this.PPS[t].nalu=e.readUint8Array(this.PPS[t].length),r-=2+this.PPS[t].length;r>0&&(this.ext=e.readUint8Array(r))})),c.createBoxCtor("btrt",(function(e){this.bufferSizeDB=e.readUint32(),this.maxBitrate=e.readUint32(),this.avgBitrate=e.readUint32()})),c.createFullBoxCtor("ccst",(function(e){var t=e.readUint8();this.all_ref_pics_intra=128==(128&t),this.intra_pred_used=64==(64&t),this.max_ref_per_pic=(63&t)>>2,e.readUint24()})),c.createBoxCtor("cdef",(function(e){var t;for(this.channel_count=e.readUint16(),this.channel_indexes=[],this.channel_types=[],this.channel_associations=[],t=0;t<this.channel_count;t++)this.channel_indexes.push(e.readUint16()),this.channel_types.push(e.readUint16()),this.channel_associations.push(e.readUint16())})),c.createBoxCtor("clap",(function(e){this.cleanApertureWidthN=e.readUint32(),this.cleanApertureWidthD=e.readUint32(),this.cleanApertureHeightN=e.readUint32(),this.cleanApertureHeightD=e.readUint32(),this.horizOffN=e.readUint32(),this.horizOffD=e.readUint32(),this.vertOffN=e.readUint32(),this.vertOffD=e.readUint32()})),c.createBoxCtor("clli",(function(e){this.max_content_light_level=e.readUint16(),this.max_pic_average_light_level=e.readUint16()})),c.createFullBoxCtor("cmex",(function(e){1&this.flags&&(this.pos_x=e.readInt32()),2&this.flags&&(this.pos_y=e.readInt32()),4&this.flags&&(this.pos_z=e.readInt32()),8&this.flags&&(0==this.version?16&this.flags?(this.quat_x=e.readInt32(),this.quat_y=e.readInt32(),this.quat_z=e.readInt32()):(this.quat_x=e.readInt16(),this.quat_y=e.readInt16(),this.quat_z=e.readInt16()):this.version),32&this.flags&&(this.id=e.readUint32())})),c.createFullBoxCtor("cmin",(function(e){this.focal_length_x=e.readInt32(),this.principal_point_x=e.readInt32(),this.principal_point_y=e.readInt32(),1&this.flags&&(this.focal_length_y=e.readInt32(),this.skew_factor=e.readInt32())})),c.createBoxCtor("cmpd",(function(e){for(this.component_count=e.readUint32(),this.component_types=[],this.component_type_urls=[],i=0;i<this.component_count;i++){var t=e.readUint16();this.component_types.push(t),t>=32768&&this.component_type_urls.push(e.readCString())}})),c.createFullBoxCtor("co64",(function(e){var t,r;if(t=e.readUint32(),this.chunk_offsets=[],0===this.version)for(r=0;r<t;r++)this.chunk_offsets.push(e.readUint64())})),c.createFullBoxCtor("CoLL",(function(e){this.maxCLL=e.readUint16(),this.maxFALL=e.readUint16()})),c.createBoxCtor("colr",(function(e){if(this.colour_type=e.readString(4),"nclx"===this.colour_type){this.colour_primaries=e.readUint16(),this.transfer_characteristics=e.readUint16(),this.matrix_coefficients=e.readUint16();var t=e.readUint8();this.full_range_flag=t>>7}else("rICC"===this.colour_type||"prof"===this.colour_type)&&(this.ICC_profile=e.readUint8Array(this.size-4))})),c.createFullBoxCtor("cprt",(function(e){this.parseLanguage(e),this.notice=e.readCString()})),c.createFullBoxCtor("cslg",(function(e){0===this.version&&(this.compositionToDTSShift=e.readInt32(),this.leastDecodeToDisplayDelta=e.readInt32(),this.greatestDecodeToDisplayDelta=e.readInt32(),this.compositionStartTime=e.readInt32(),this.compositionEndTime=e.readInt32())})),c.createFullBoxCtor("ctts",(function(e){var t,r;if(t=e.readUint32(),this.sample_counts=[],this.sample_offsets=[],0===this.version)for(r=0;r<t;r++){this.sample_counts.push(e.readUint32());var i=e.readInt32();i<0&&o.warn("BoxParser","ctts box uses negative values without using version 1"),this.sample_offsets.push(i)}else if(1==this.version)for(r=0;r<t;r++)this.sample_counts.push(e.readUint32()),this.sample_offsets.push(e.readInt32())})),c.createBoxCtor("dac3",(function(e){var t=e.readUint8(),r=e.readUint8(),i=e.readUint8();this.fscod=t>>6,this.bsid=t>>1&31,this.bsmod=(1&t)<<2|r>>6&3,this.acmod=r>>3&7,this.lfeon=r>>2&1,this.bit_rate_code=3&r|i>>5&7})),c.createBoxCtor("dec3",(function(e){var t=e.readUint16();this.data_rate=t>>3,this.num_ind_sub=7&t,this.ind_subs=[];for(var r=0;r<this.num_ind_sub+1;r++){var i={};this.ind_subs.push(i);var n=e.readUint8(),s=e.readUint8(),o=e.readUint8();i.fscod=n>>6,i.bsid=n>>1&31,i.bsmod=(1&n)<<4|s>>4&15,i.acmod=s>>1&7,i.lfeon=1&s,i.num_dep_sub=o>>1&15,i.num_dep_sub>0&&(i.chan_loc=(1&o)<<8|e.readUint8())}})),c.createFullBoxCtor("dfLa",(function(e){var t=[],r=["STREAMINFO","PADDING","APPLICATION","SEEKTABLE","VORBIS_COMMENT","CUESHEET","PICTURE","RESERVED"];for(this.parseFullHeader(e);;){var i=e.readUint8(),n=Math.min(127&i,r.length-1);if(n?e.readUint8Array(e.readUint24()):(e.readUint8Array(13),this.samplerate=e.readUint32()>>12,e.readUint8Array(20)),t.push(r[n]),128&i)break}this.numMetadataBlocks=t.length+" ("+t.join(", ")+")"})),c.createBoxCtor("dimm",(function(e){this.bytessent=e.readUint64()})),c.createBoxCtor("dmax",(function(e){this.time=e.readUint32()})),c.createBoxCtor("dmed",(function(e){this.bytessent=e.readUint64()})),c.createBoxCtor("dOps",(function(e){if(this.Version=e.readUint8(),this.OutputChannelCount=e.readUint8(),this.PreSkip=e.readUint16(),this.InputSampleRate=e.readUint32(),this.OutputGain=e.readInt16(),this.ChannelMappingFamily=e.readUint8(),0!==this.ChannelMappingFamily){this.StreamCount=e.readUint8(),this.CoupledCount=e.readUint8(),this.ChannelMapping=[];for(var t=0;t<this.OutputChannelCount;t++)this.ChannelMapping[t]=e.readUint8()}})),c.createFullBoxCtor("dref",(function(e){var t,r;this.entries=[];for(var i=e.readUint32(),n=0;n<i;n++){if((t=c.parseOneBox(e,!1,this.size-(e.getPosition()-this.start))).code!==c.OK)return;r=t.box,this.entries.push(r)}})),c.createBoxCtor("drep",(function(e){this.bytessent=e.readUint64()})),c.createFullBoxCtor("elng",(function(e){this.extended_language=e.readString(this.size-this.hdr_size)})),c.createFullBoxCtor("elst",(function(e){this.entries=[];for(var t=e.readUint32(),r=0;r<t;r++){var i={};this.entries.push(i),1===this.version?(i.segment_duration=e.readUint64(),i.media_time=e.readInt64()):(i.segment_duration=e.readUint32(),i.media_time=e.readInt32()),i.media_rate_integer=e.readInt16(),i.media_rate_fraction=e.readInt16()}})),c.createFullBoxCtor("emsg",(function(e){1==this.version?(this.timescale=e.readUint32(),this.presentation_time=e.readUint64(),this.event_duration=e.readUint32(),this.id=e.readUint32(),this.scheme_id_uri=e.readCString(),this.value=e.readCString()):(this.scheme_id_uri=e.readCString(),this.value=e.readCString(),this.timescale=e.readUint32(),this.presentation_time_delta=e.readUint32(),this.event_duration=e.readUint32(),this.id=e.readUint32());var t=this.size-this.hdr_size-(16+(this.scheme_id_uri.length+1)+(this.value.length+1));1==this.version&&(t-=4),this.message_data=e.readUint8Array(t)})),c.createEntityToGroupCtor=function(e,t){c[e+"Box"]=function(t){c.FullBox.call(this,e,t)},c[e+"Box"].prototype=new c.FullBox,c[e+"Box"].prototype.parse=function(e){if(this.parseFullHeader(e),t)t.call(this,e);else for(this.group_id=e.readUint32(),this.num_entities_in_group=e.readUint32(),this.entity_ids=[],i=0;i<this.num_entities_in_group;i++){var r=e.readUint32();this.entity_ids.push(r)}}},c.createEntityToGroupCtor("aebr"),c.createEntityToGroupCtor("afbr"),c.createEntityToGroupCtor("albc"),c.createEntityToGroupCtor("altr"),c.createEntityToGroupCtor("brst"),c.createEntityToGroupCtor("dobr"),c.createEntityToGroupCtor("eqiv"),c.createEntityToGroupCtor("favc"),c.createEntityToGroupCtor("fobr"),c.createEntityToGroupCtor("iaug"),c.createEntityToGroupCtor("pano"),c.createEntityToGroupCtor("slid"),c.createEntityToGroupCtor("ster"),c.createEntityToGroupCtor("tsyn"),c.createEntityToGroupCtor("wbbr"),c.createEntityToGroupCtor("prgr"),c.createFullBoxCtor("esds",(function(e){var t=e.readUint8Array(this.size-this.hdr_size),r=new h;this.esd=r.parseOneDescriptor(new l(t.buffer,0,l.BIG_ENDIAN))})),c.createBoxCtor("fiel",(function(e){this.fieldCount=e.readUint8(),this.fieldOrdering=e.readUint8()})),c.createBoxCtor("frma",(function(e){this.data_format=e.readString(4)})),c.createBoxCtor("ftyp",(function(e){var t=this.size-this.hdr_size;this.major_brand=e.readString(4),this.minor_version=e.readUint32(),t-=8,this.compatible_brands=[];for(var r=0;t>=4;)this.compatible_brands[r]=e.readString(4),t-=4,r++})),c.createFullBoxCtor("hdlr",(function(e){0===this.version&&(e.readUint32(),this.handler=e.readString(4),e.readUint32Array(3),this.name=e.readString(this.size-this.hdr_size-20),"\0"===this.name[this.name.length-1]&&(this.name=this.name.slice(0,-1)))})),c.createBoxCtor("hvcC",(function(e){var t,r,i,n;this.configurationVersion=e.readUint8(),n=e.readUint8(),this.general_profile_space=n>>6,this.general_tier_flag=(32&n)>>5,this.general_profile_idc=31&n,this.general_profile_compatibility=e.readUint32(),this.general_constraint_indicator=e.readUint8Array(6),this.general_level_idc=e.readUint8(),this.min_spatial_segmentation_idc=4095&e.readUint16(),this.parallelismType=3&e.readUint8(),this.chroma_format_idc=3&e.readUint8(),this.bit_depth_luma_minus8=7&e.readUint8(),this.bit_depth_chroma_minus8=7&e.readUint8(),this.avgFrameRate=e.readUint16(),n=e.readUint8(),this.constantFrameRate=n>>6,this.numTemporalLayers=(13&n)>>3,this.temporalIdNested=(4&n)>>2,this.lengthSizeMinusOne=3&n,this.nalu_arrays=[];var s=e.readUint8();for(t=0;t<s;t++){var o=[];this.nalu_arrays.push(o),n=e.readUint8(),o.completeness=(128&n)>>7,o.nalu_type=63&n;var a=e.readUint16();for(r=0;r<a;r++){var l={};o.push(l),i=e.readUint16(),l.data=e.readUint8Array(i)}}})),c.createFullBoxCtor("iinf",(function(e){var t;0===this.version?this.entry_count=e.readUint16():this.entry_count=e.readUint32(),this.item_infos=[];for(var r=0;r<this.entry_count;r++){if((t=c.parseOneBox(e,!1,this.size-(e.getPosition()-this.start))).code!==c.OK)return;"infe"!==t.box.type&&o.error("BoxParser","Expected 'infe' box, got "+t.box.type),this.item_infos[r]=t.box}})),c.createFullBoxCtor("iloc",(function(e){var t;t=e.readUint8(),this.offset_size=t>>4&15,this.length_size=15&t,t=e.readUint8(),this.base_offset_size=t>>4&15,1===this.version||2===this.version?this.index_size=15&t:this.index_size=0,this.items=[];var r=0;if(this.version<2)r=e.readUint16();else{if(2!==this.version)throw"version of iloc box not supported";r=e.readUint32()}for(var i=0;i<r;i++){var n={};if(this.items.push(n),this.version<2)n.item_ID=e.readUint16();else{if(2!==this.version)throw"version of iloc box not supported";n.item_ID=e.readUint32()}switch(1===this.version||2===this.version?n.construction_method=15&e.readUint16():n.construction_method=0,n.data_reference_index=e.readUint16(),this.base_offset_size){case 0:n.base_offset=0;break;case 4:n.base_offset=e.readUint32();break;case 8:n.base_offset=e.readUint64();break;default:throw"Error reading base offset size"}var s=e.readUint16();n.extents=[];for(var o=0;o<s;o++){var a={};if(n.extents.push(a),1===this.version||2===this.version)switch(this.index_size){case 0:a.extent_index=0;break;case 4:a.extent_index=e.readUint32();break;case 8:a.extent_index=e.readUint64();break;default:throw"Error reading extent index"}switch(this.offset_size){case 0:a.extent_offset=0;break;case 4:a.extent_offset=e.readUint32();break;case 8:a.extent_offset=e.readUint64();break;default:throw"Error reading extent index"}switch(this.length_size){case 0:a.extent_length=0;break;case 4:a.extent_length=e.readUint32();break;case 8:a.extent_length=e.readUint64();break;default:throw"Error reading extent index"}}}})),c.createBoxCtor("imir",(function(e){var t=e.readUint8();this.reserved=t>>7,this.axis=1&t})),c.createFullBoxCtor("infe",(function(e){if(0!==this.version&&1!==this.version||(this.item_ID=e.readUint16(),this.item_protection_index=e.readUint16(),this.item_name=e.readCString(),this.content_type=e.readCString(),this.content_encoding=e.readCString()),1===this.version)return this.extension_type=e.readString(4),o.warn("BoxParser","Cannot parse extension type"),void e.seek(this.start+this.size);this.version>=2&&(2===this.version?this.item_ID=e.readUint16():3===this.version&&(this.item_ID=e.readUint32()),this.item_protection_index=e.readUint16(),this.item_type=e.readString(4),this.item_name=e.readCString(),"mime"===this.item_type?(this.content_type=e.readCString(),this.content_encoding=e.readCString()):"uri "===this.item_type&&(this.item_uri_type=e.readCString()))})),c.createFullBoxCtor("ipma",(function(e){var t,r;for(entry_count=e.readUint32(),this.associations=[],t=0;t<entry_count;t++){var i={};this.associations.push(i),this.version<1?i.id=e.readUint16():i.id=e.readUint32();var n=e.readUint8();for(i.props=[],r=0;r<n;r++){var s=e.readUint8(),o={};i.props.push(o),o.essential=(128&s)>>7==1,1&this.flags?o.property_index=(127&s)<<8|e.readUint8():o.property_index=127&s}}})),c.createFullBoxCtor("iref",(function(e){var t,r;for(this.references=[];e.getPosition()<this.start+this.size;){if((t=c.parseOneBox(e,!0,this.size-(e.getPosition()-this.start))).code!==c.OK)return;(r=0===this.version?new c.SingleItemTypeReferenceBox(t.type,t.size,t.hdr_size,t.start):new c.SingleItemTypeReferenceBoxLarge(t.type,t.size,t.hdr_size,t.start)).write===c.Box.prototype.write&&"mdat"!==r.type&&(o.warn("BoxParser",r.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),r.parseDataAndRewind(e)),r.parse(e),this.references.push(r)}})),c.createBoxCtor("irot",(function(e){this.angle=3&e.readUint8()})),c.createFullBoxCtor("ispe",(function(e){this.image_width=e.readUint32(),this.image_height=e.readUint32()})),c.createFullBoxCtor("kind",(function(e){this.schemeURI=e.readCString(),this.value=e.readCString()})),c.createFullBoxCtor("leva",(function(e){var t=e.readUint8();this.levels=[];for(var r=0;r<t;r++){var i={};this.levels[r]=i,i.track_ID=e.readUint32();var n=e.readUint8();switch(i.padding_flag=n>>7,i.assignment_type=127&n,i.assignment_type){case 0:i.grouping_type=e.readString(4);break;case 1:i.grouping_type=e.readString(4),i.grouping_type_parameter=e.readUint32();break;case 2:case 3:break;case 4:i.sub_track_id=e.readUint32();break;default:o.warn("BoxParser","Unknown leva assignement type")}}})),c.createBoxCtor("lsel",(function(e){this.layer_id=e.readUint16()})),c.createBoxCtor("maxr",(function(e){this.period=e.readUint32(),this.bytes=e.readUint32()})),f.prototype.toString=function(){return"("+this.x+","+this.y+")"},c.createBoxCtor("mdcv",(function(e){this.display_primaries=[],this.display_primaries[0]=new f(e.readUint16(),e.readUint16()),this.display_primaries[1]=new f(e.readUint16(),e.readUint16()),this.display_primaries[2]=new f(e.readUint16(),e.readUint16()),this.white_point=new f(e.readUint16(),e.readUint16()),this.max_display_mastering_luminance=e.readUint32(),this.min_display_mastering_luminance=e.readUint32()})),c.createFullBoxCtor("mdhd",(function(e){1==this.version?(this.creation_time=e.readUint64(),this.modification_time=e.readUint64(),this.timescale=e.readUint32(),this.duration=e.readUint64()):(this.creation_time=e.readUint32(),this.modification_time=e.readUint32(),this.timescale=e.readUint32(),this.duration=e.readUint32()),this.parseLanguage(e),e.readUint16()})),c.createFullBoxCtor("mehd",(function(e){1&this.flags&&(o.warn("BoxParser","mehd box incorrectly uses flags set to 1, converting version to 1"),this.version=1),1==this.version?this.fragment_duration=e.readUint64():this.fragment_duration=e.readUint32()})),c.createFullBoxCtor("meta",(function(e){this.boxes=[],c.ContainerBox.prototype.parse.call(this,e)})),c.createFullBoxCtor("mfhd",(function(e){this.sequence_number=e.readUint32()})),c.createFullBoxCtor("mfro",(function(e){this._size=e.readUint32()})),c.createFullBoxCtor("mskC",(function(e){this.bits_per_pixel=e.readUint8()})),c.createFullBoxCtor("mvhd",(function(e){1==this.version?(this.creation_time=e.readUint64(),this.modification_time=e.readUint64(),this.timescale=e.readUint32(),this.duration=e.readUint64()):(this.creation_time=e.readUint32(),this.modification_time=e.readUint32(),this.timescale=e.readUint32(),this.duration=e.readUint32()),this.rate=e.readUint32(),this.volume=e.readUint16()>>8,e.readUint16(),e.readUint32Array(2),this.matrix=e.readUint32Array(9),e.readUint32Array(6),this.next_track_id=e.readUint32()})),c.createBoxCtor("npck",(function(e){this.packetssent=e.readUint32()})),c.createBoxCtor("nump",(function(e){this.packetssent=e.readUint64()})),c.createFullBoxCtor("padb",(function(e){var t=e.readUint32();this.padbits=[];for(var r=0;r<Math.floor((t+1)/2);r++)this.padbits=e.readUint8()})),c.createBoxCtor("pasp",(function(e){this.hSpacing=e.readUint32(),this.vSpacing=e.readUint32()})),c.createBoxCtor("payl",(function(e){this.text=e.readString(this.size-this.hdr_size)})),c.createBoxCtor("payt",(function(e){this.payloadID=e.readUint32();var t=e.readUint8();this.rtpmap_string=e.readString(t)})),c.createFullBoxCtor("pdin",(function(e){var t=(this.size-this.hdr_size)/8;this.rate=[],this.initial_delay=[];for(var r=0;r<t;r++)this.rate[r]=e.readUint32(),this.initial_delay[r]=e.readUint32()})),c.createFullBoxCtor("pitm",(function(e){0===this.version?this.item_id=e.readUint16():this.item_id=e.readUint32()})),c.createFullBoxCtor("pixi",(function(e){var t;for(this.num_channels=e.readUint8(),this.bits_per_channels=[],t=0;t<this.num_channels;t++)this.bits_per_channels[t]=e.readUint8()})),c.createBoxCtor("pmax",(function(e){this.bytes=e.readUint32()})),c.createFullBoxCtor("prdi",(function(e){if(this.step_count=e.readUint16(),this.item_count=[],2&this.flags)for(var t=0;t<this.step_count;t++)this.item_count[t]=e.readUint16()})),c.createFullBoxCtor("prft",(function(e){this.ref_track_id=e.readUint32(),this.ntp_timestamp=e.readUint64(),0===this.version?this.media_time=e.readUint32():this.media_time=e.readUint64()})),c.createFullBoxCtor("pssh",(function(e){if(this.system_id=c.parseHex16(e),this.version>0){var t=e.readUint32();this.kid=[];for(var r=0;r<t;r++)this.kid[r]=c.parseHex16(e)}var i=e.readUint32();i>0&&(this.data=e.readUint8Array(i))})),c.createFullBoxCtor("clef",(function(e){this.width=e.readUint32(),this.height=e.readUint32()})),c.createFullBoxCtor("enof",(function(e){this.width=e.readUint32(),this.height=e.readUint32()})),c.createFullBoxCtor("prof",(function(e){this.width=e.readUint32(),this.height=e.readUint32()})),c.createContainerBoxCtor("tapt",null,["clef","prof","enof"]),c.createBoxCtor("rtp ",(function(e){this.descriptionformat=e.readString(4),this.sdptext=e.readString(this.size-this.hdr_size-4)})),c.createFullBoxCtor("saio",(function(e){1&this.flags&&(this.aux_info_type=e.readUint32(),this.aux_info_type_parameter=e.readUint32());var t=e.readUint32();this.offset=[];for(var r=0;r<t;r++)0===this.version?this.offset[r]=e.readUint32():this.offset[r]=e.readUint64()})),c.createFullBoxCtor("saiz",(function(e){1&this.flags&&(this.aux_info_type=e.readUint32(),this.aux_info_type_parameter=e.readUint32()),this.default_sample_info_size=e.readUint8();var t=e.readUint32();if(this.sample_info_size=[],0===this.default_sample_info_size)for(var r=0;r<t;r++)this.sample_info_size[r]=e.readUint8()})),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_METADATA,"mett",(function(e){this.parseHeader(e),this.content_encoding=e.readCString(),this.mime_format=e.readCString(),this.parseFooter(e)})),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_METADATA,"metx",(function(e){this.parseHeader(e),this.content_encoding=e.readCString(),this.namespace=e.readCString(),this.schema_location=e.readCString(),this.parseFooter(e)})),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SUBTITLE,"sbtt",(function(e){this.parseHeader(e),this.content_encoding=e.readCString(),this.mime_format=e.readCString(),this.parseFooter(e)})),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SUBTITLE,"stpp",(function(e){this.parseHeader(e),this.namespace=e.readCString(),this.schema_location=e.readCString(),this.auxiliary_mime_types=e.readCString(),this.parseFooter(e)})),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SUBTITLE,"stxt",(function(e){this.parseHeader(e),this.content_encoding=e.readCString(),this.mime_format=e.readCString(),this.parseFooter(e)})),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_SUBTITLE,"tx3g",(function(e){this.parseHeader(e),this.displayFlags=e.readUint32(),this.horizontal_justification=e.readInt8(),this.vertical_justification=e.readInt8(),this.bg_color_rgba=e.readUint8Array(4),this.box_record=e.readInt16Array(4),this.style_record=e.readUint8Array(12),this.parseFooter(e)})),c.createSampleEntryCtor(c.SAMPLE_ENTRY_TYPE_METADATA,"wvtt",(function(e){this.parseHeader(e),this.parseFooter(e)})),c.createSampleGroupCtor("alst",(function(e){var t,r=e.readUint16();for(this.first_output_sample=e.readUint16(),this.sample_offset=[],t=0;t<r;t++)this.sample_offset[t]=e.readUint32();var i=this.description_length-4-4*r;for(this.num_output_samples=[],this.num_total_samples=[],t=0;t<i/4;t++)this.num_output_samples[t]=e.readUint16(),this.num_total_samples[t]=e.readUint16()})),c.createSampleGroupCtor("avll",(function(e){this.layerNumber=e.readUint8(),this.accurateStatisticsFlag=e.readUint8(),this.avgBitRate=e.readUint16(),this.avgFrameRate=e.readUint16()})),c.createSampleGroupCtor("avss",(function(e){this.subSequenceIdentifier=e.readUint16(),this.layerNumber=e.readUint8();var t=e.readUint8();this.durationFlag=t>>7,this.avgRateFlag=t>>6&1,this.durationFlag&&(this.duration=e.readUint32()),this.avgRateFlag&&(this.accurateStatisticsFlag=e.readUint8(),this.avgBitRate=e.readUint16(),this.avgFrameRate=e.readUint16()),this.dependency=[];for(var r=e.readUint8(),i=0;i<r;i++){var n={};this.dependency.push(n),n.subSeqDirectionFlag=e.readUint8(),n.layerNumber=e.readUint8(),n.subSequenceIdentifier=e.readUint16()}})),c.createSampleGroupCtor("dtrt",(function(e){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),c.createSampleGroupCtor("mvif",(function(e){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),c.createSampleGroupCtor("prol",(function(e){this.roll_distance=e.readInt16()})),c.createSampleGroupCtor("rap ",(function(e){var t=e.readUint8();this.num_leading_samples_known=t>>7,this.num_leading_samples=127&t})),c.createSampleGroupCtor("rash",(function(e){if(this.operation_point_count=e.readUint16(),this.description_length!==2+(1===this.operation_point_count?2:6*this.operation_point_count)+9)o.warn("BoxParser","Mismatch in "+this.grouping_type+" sample group length"),this.data=e.readUint8Array(this.description_length-2);else{if(1===this.operation_point_count)this.target_rate_share=e.readUint16();else{this.target_rate_share=[],this.available_bitrate=[];for(var t=0;t<this.operation_point_count;t++)this.available_bitrate[t]=e.readUint32(),this.target_rate_share[t]=e.readUint16()}this.maximum_bitrate=e.readUint32(),this.minimum_bitrate=e.readUint32(),this.discard_priority=e.readUint8()}})),c.createSampleGroupCtor("roll",(function(e){this.roll_distance=e.readInt16()})),c.SampleGroupEntry.prototype.parse=function(e){o.warn("BoxParser","Unknown Sample Group type: "+this.grouping_type),this.data=e.readUint8Array(this.description_length)},c.createSampleGroupCtor("scif",(function(e){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),c.createSampleGroupCtor("scnm",(function(e){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),c.createSampleGroupCtor("seig",(function(e){this.reserved=e.readUint8();var t=e.readUint8();this.crypt_byte_block=t>>4,this.skip_byte_block=15&t,this.isProtected=e.readUint8(),this.Per_Sample_IV_Size=e.readUint8(),this.KID=c.parseHex16(e),this.constant_IV_size=0,this.constant_IV=0,1===this.isProtected&&0===this.Per_Sample_IV_Size&&(this.constant_IV_size=e.readUint8(),this.constant_IV=e.readUint8Array(this.constant_IV_size))})),c.createSampleGroupCtor("stsa",(function(e){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),c.createSampleGroupCtor("sync",(function(e){var t=e.readUint8();this.NAL_unit_type=63&t})),c.createSampleGroupCtor("tele",(function(e){var t=e.readUint8();this.level_independently_decodable=t>>7})),c.createSampleGroupCtor("tsas",(function(e){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),c.createSampleGroupCtor("tscl",(function(e){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),c.createSampleGroupCtor("vipr",(function(e){o.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")})),c.createFullBoxCtor("sbgp",(function(e){this.grouping_type=e.readString(4),1===this.version?this.grouping_type_parameter=e.readUint32():this.grouping_type_parameter=0,this.entries=[];for(var t=e.readUint32(),r=0;r<t;r++){var i={};this.entries.push(i),i.sample_count=e.readInt32(),i.group_description_index=e.readInt32()}})),p.prototype.toString=function(){return"[row: "+this.bad_pixel_row+", column: "+this.bad_pixel_column+"]"},c.createFullBoxCtor("sbpm",(function(e){var t;for(this.component_count=e.readUint16(),this.component_index=[],t=0;t<this.component_count;t++)this.component_index.push(e.readUint16());var r=e.readUint8();for(this.correction_applied=128==(128&r),this.num_bad_rows=e.readUint32(),this.num_bad_cols=e.readUint32(),this.num_bad_pixels=e.readUint32(),this.bad_rows=[],this.bad_columns=[],this.bad_pixels=[],t=0;t<this.num_bad_rows;t++)this.bad_rows.push(e.readUint32());for(t=0;t<this.num_bad_cols;t++)this.bad_columns.push(e.readUint32());for(t=0;t<this.num_bad_pixels;t++){var i=e.readUint32(),n=e.readUint32();this.bad_pixels.push(new p(i,n))}})),c.createFullBoxCtor("schm",(function(e){this.scheme_type=e.readString(4),this.scheme_version=e.readUint32(),1&this.flags&&(this.scheme_uri=e.readString(this.size-this.hdr_size-8))})),c.createBoxCtor("sdp ",(function(e){this.sdptext=e.readString(this.size-this.hdr_size)})),c.createFullBoxCtor("sdtp",(function(e){var t,r=this.size-this.hdr_size;this.is_leading=[],this.sample_depends_on=[],this.sample_is_depended_on=[],this.sample_has_redundancy=[];for(var i=0;i<r;i++)t=e.readUint8(),this.is_leading[i]=t>>6,this.sample_depends_on[i]=t>>4&3,this.sample_is_depended_on[i]=t>>2&3,this.sample_has_redundancy[i]=3&t})),c.createFullBoxCtor("senc"),c.createFullBoxCtor("sgpd",(function(e){this.grouping_type=e.readString(4),o.debug("BoxParser","Found Sample Groups of type "+this.grouping_type),1===this.version?this.default_length=e.readUint32():this.default_length=0,this.version>=2&&(this.default_group_description_index=e.readUint32()),this.entries=[];for(var t=e.readUint32(),r=0;r<t;r++){var i;i=c[this.grouping_type+"SampleGroupEntry"]?new c[this.grouping_type+"SampleGroupEntry"](this.grouping_type):new c.SampleGroupEntry(this.grouping_type),this.entries.push(i),1===this.version&&0===this.default_length?i.description_length=e.readUint32():i.description_length=this.default_length,i.write===c.SampleGroupEntry.prototype.write&&(o.info("BoxParser","SampleGroup for type "+this.grouping_type+" writing not yet implemented, keeping unparsed data in memory for later write"),i.data=e.readUint8Array(i.description_length),e.position-=i.description_length),i.parse(e)}})),c.createFullBoxCtor("sidx",(function(e){this.reference_ID=e.readUint32(),this.timescale=e.readUint32(),0===this.version?(this.earliest_presentation_time=e.readUint32(),this.first_offset=e.readUint32()):(this.earliest_presentation_time=e.readUint64(),this.first_offset=e.readUint64()),e.readUint16(),this.references=[];for(var t=e.readUint16(),r=0;r<t;r++){var i={};this.references.push(i);var n=e.readUint32();i.reference_type=n>>31&1,i.referenced_size=2147483647&n,i.subsegment_duration=e.readUint32(),n=e.readUint32(),i.starts_with_SAP=n>>31&1,i.SAP_type=n>>28&7,i.SAP_delta_time=268435455&n}})),c.SingleItemTypeReferenceBox=function(e,t,r,i){c.Box.call(this,e,t),this.hdr_size=r,this.start=i},c.SingleItemTypeReferenceBox.prototype=new c.Box,c.SingleItemTypeReferenceBox.prototype.parse=function(e){this.from_item_ID=e.readUint16();var t=e.readUint16();this.references=[];for(var r=0;r<t;r++)this.references[r]={},this.references[r].to_item_ID=e.readUint16()},c.SingleItemTypeReferenceBoxLarge=function(e,t,r,i){c.Box.call(this,e,t),this.hdr_size=r,this.start=i},c.SingleItemTypeReferenceBoxLarge.prototype=new c.Box,c.SingleItemTypeReferenceBoxLarge.prototype.parse=function(e){this.from_item_ID=e.readUint32();var t=e.readUint16();this.references=[];for(var r=0;r<t;r++)this.references[r]={},this.references[r].to_item_ID=e.readUint32()},c.createFullBoxCtor("SmDm",(function(e){this.primaryRChromaticity_x=e.readUint16(),this.primaryRChromaticity_y=e.readUint16(),this.primaryGChromaticity_x=e.readUint16(),this.primaryGChromaticity_y=e.readUint16(),this.primaryBChromaticity_x=e.readUint16(),this.primaryBChromaticity_y=e.readUint16(),this.whitePointChromaticity_x=e.readUint16(),this.whitePointChromaticity_y=e.readUint16(),this.luminanceMax=e.readUint32(),this.luminanceMin=e.readUint32()})),c.createFullBoxCtor("smhd",(function(e){this.balance=e.readUint16(),e.readUint16()})),c.createFullBoxCtor("ssix",(function(e){this.subsegments=[];for(var t=e.readUint32(),r=0;r<t;r++){var i={};this.subsegments.push(i),i.ranges=[];for(var n=e.readUint32(),s=0;s<n;s++){var o={};i.ranges.push(o),o.level=e.readUint8(),o.range_size=e.readUint24()}}})),c.createFullBoxCtor("stco",(function(e){var t;if(t=e.readUint32(),this.chunk_offsets=[],0===this.version)for(var r=0;r<t;r++)this.chunk_offsets.push(e.readUint32())})),c.createFullBoxCtor("stdp",(function(e){var t=(this.size-this.hdr_size)/2;this.priority=[];for(var r=0;r<t;r++)this.priority[r]=e.readUint16()})),c.createFullBoxCtor("sthd"),c.createFullBoxCtor("stri",(function(e){this.switch_group=e.readUint16(),this.alternate_group=e.readUint16(),this.sub_track_id=e.readUint32();var t=(this.size-this.hdr_size-8)/4;this.attribute_list=[];for(var r=0;r<t;r++)this.attribute_list[r]=e.readUint32()})),c.createFullBoxCtor("stsc",(function(e){var t,r;if(t=e.readUint32(),this.first_chunk=[],this.samples_per_chunk=[],this.sample_description_index=[],0===this.version)for(r=0;r<t;r++)this.first_chunk.push(e.readUint32()),this.samples_per_chunk.push(e.readUint32()),this.sample_description_index.push(e.readUint32())})),c.createFullBoxCtor("stsd",(function(e){var t,r,i,n;for(this.entries=[],i=e.readUint32(),t=1;t<=i;t++){if((r=c.parseOneBox(e,!0,this.size-(e.getPosition()-this.start))).code!==c.OK)return;c[r.type+"SampleEntry"]?((n=new c[r.type+"SampleEntry"](r.size)).hdr_size=r.hdr_size,n.start=r.start):(o.warn("BoxParser","Unknown sample entry type: "+r.type),n=new c.SampleEntry(r.type,r.size,r.hdr_size,r.start)),n.write===c.SampleEntry.prototype.write&&(o.info("BoxParser","SampleEntry "+n.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),n.parseDataAndRewind(e)),n.parse(e),this.entries.push(n)}})),c.createFullBoxCtor("stsg",(function(e){this.grouping_type=e.readUint32();var t=e.readUint16();this.group_description_index=[];for(var r=0;r<t;r++)this.group_description_index[r]=e.readUint32()})),c.createFullBoxCtor("stsh",(function(e){var t,r;if(t=e.readUint32(),this.shadowed_sample_numbers=[],this.sync_sample_numbers=[],0===this.version)for(r=0;r<t;r++)this.shadowed_sample_numbers.push(e.readUint32()),this.sync_sample_numbers.push(e.readUint32())})),c.createFullBoxCtor("stss",(function(e){var t,r;if(r=e.readUint32(),0===this.version)for(this.sample_numbers=[],t=0;t<r;t++)this.sample_numbers.push(e.readUint32())})),c.createFullBoxCtor("stsz",(function(e){var t;if(this.sample_sizes=[],0===this.version)for(this.sample_size=e.readUint32(),this.sample_count=e.readUint32(),t=0;t<this.sample_count;t++)0===this.sample_size?this.sample_sizes.push(e.readUint32()):this.sample_sizes[t]=this.sample_size})),c.createFullBoxCtor("stts",(function(e){var t,r,i;if(t=e.readUint32(),this.sample_counts=[],this.sample_deltas=[],0===this.version)for(r=0;r<t;r++)this.sample_counts.push(e.readUint32()),(i=e.readInt32())<0&&(o.warn("BoxParser","File uses negative stts sample delta, using value 1 instead, sync may be lost!"),i=1),this.sample_deltas.push(i)})),c.createFullBoxCtor("stvi",(function(e){var t=e.readUint32();this.single_view_allowed=3&t,this.stereo_scheme=e.readUint32();var r,i,n=e.readUint32();for(this.stereo_indication_type=e.readString(n),this.boxes=[];e.getPosition()<this.start+this.size;){if((r=c.parseOneBox(e,!1,this.size-(e.getPosition()-this.start))).code!==c.OK)return;i=r.box,this.boxes.push(i),this[i.type]=i}})),c.createBoxCtor("styp",(function(e){c.ftypBox.prototype.parse.call(this,e)})),c.createFullBoxCtor("stz2",(function(e){var t,r;if(this.sample_sizes=[],0===this.version)if(this.reserved=e.readUint24(),this.field_size=e.readUint8(),r=e.readUint32(),4===this.field_size)for(t=0;t<r;t+=2){var i=e.readUint8();this.sample_sizes[t]=i>>4&15,this.sample_sizes[t+1]=15&i}else if(8===this.field_size)for(t=0;t<r;t++)this.sample_sizes[t]=e.readUint8();else if(16===this.field_size)for(t=0;t<r;t++)this.sample_sizes[t]=e.readUint16();else o.error("BoxParser","Error in length field in stz2 box")})),c.createFullBoxCtor("subs",(function(e){var t,r,i,n;for(i=e.readUint32(),this.entries=[],t=0;t<i;t++){var s={};if(this.entries[t]=s,s.sample_delta=e.readUint32(),s.subsamples=[],(n=e.readUint16())>0)for(r=0;r<n;r++){var o={};s.subsamples.push(o),1==this.version?o.size=e.readUint32():o.size=e.readUint16(),o.priority=e.readUint8(),o.discardable=e.readUint8(),o.codec_specific_parameters=e.readUint32()}}})),c.createFullBoxCtor("tenc",(function(e){if(e.readUint8(),0===this.version)e.readUint8();else{var t=e.readUint8();this.default_crypt_byte_block=t>>4&15,this.default_skip_byte_block=15&t}this.default_isProtected=e.readUint8(),this.default_Per_Sample_IV_Size=e.readUint8(),this.default_KID=c.parseHex16(e),1===this.default_isProtected&&0===this.default_Per_Sample_IV_Size&&(this.default_constant_IV_size=e.readUint8(),this.default_constant_IV=e.readUint8Array(this.default_constant_IV_size))})),c.createFullBoxCtor("tfdt",(function(e){1==this.version?this.baseMediaDecodeTime=e.readUint64():this.baseMediaDecodeTime=e.readUint32()})),c.createFullBoxCtor("tfhd",(function(e){var t=0;this.track_id=e.readUint32(),this.size-this.hdr_size>t&&this.flags&c.TFHD_FLAG_BASE_DATA_OFFSET?(this.base_data_offset=e.readUint64(),t+=8):this.base_data_offset=0,this.size-this.hdr_size>t&&this.flags&c.TFHD_FLAG_SAMPLE_DESC?(this.default_sample_description_index=e.readUint32(),t+=4):this.default_sample_description_index=0,this.size-this.hdr_size>t&&this.flags&c.TFHD_FLAG_SAMPLE_DUR?(this.default_sample_duration=e.readUint32(),t+=4):this.default_sample_duration=0,this.size-this.hdr_size>t&&this.flags&c.TFHD_FLAG_SAMPLE_SIZE?(this.default_sample_size=e.readUint32(),t+=4):this.default_sample_size=0,this.size-this.hdr_size>t&&this.flags&c.TFHD_FLAG_SAMPLE_FLAGS?(this.default_sample_flags=e.readUint32(),t+=4):this.default_sample_flags=0})),c.createFullBoxCtor("tfra",(function(e){this.track_ID=e.readUint32(),e.readUint24();var t=e.readUint8();this.length_size_of_traf_num=t>>4&3,this.length_size_of_trun_num=t>>2&3,this.length_size_of_sample_num=3&t,this.entries=[];for(var r=e.readUint32(),i=0;i<r;i++)1===this.version?(this.time=e.readUint64(),this.moof_offset=e.readUint64()):(this.time=e.readUint32(),this.moof_offset=e.readUint32()),this.traf_number=e["readUint"+8*(this.length_size_of_traf_num+1)](),this.trun_number=e["readUint"+8*(this.length_size_of_trun_num+1)](),this.sample_number=e["readUint"+8*(this.length_size_of_sample_num+1)]()})),c.createFullBoxCtor("tkhd",(function(e){1==this.version?(this.creation_time=e.readUint64(),this.modification_time=e.readUint64(),this.track_id=e.readUint32(),e.readUint32(),this.duration=e.readUint64()):(this.creation_time=e.readUint32(),this.modification_time=e.readUint32(),this.track_id=e.readUint32(),e.readUint32(),this.duration=e.readUint32()),e.readUint32Array(2),this.layer=e.readInt16(),this.alternate_group=e.readInt16(),this.volume=e.readInt16()>>8,e.readUint16(),this.matrix=e.readInt32Array(9),this.width=e.readUint32(),this.height=e.readUint32()})),c.createBoxCtor("tmax",(function(e){this.time=e.readUint32()})),c.createBoxCtor("tmin",(function(e){this.time=e.readUint32()})),c.createBoxCtor("totl",(function(e){this.bytessent=e.readUint32()})),c.createBoxCtor("tpay",(function(e){this.bytessent=e.readUint32()})),c.createBoxCtor("tpyl",(function(e){this.bytessent=e.readUint64()})),c.TrackGroupTypeBox.prototype.parse=function(e){this.parseFullHeader(e),this.track_group_id=e.readUint32()},c.createTrackGroupCtor("msrc"),c.TrackReferenceTypeBox=function(e,t,r,i){c.Box.call(this,e,t),this.hdr_size=r,this.start=i},c.TrackReferenceTypeBox.prototype=new c.Box,c.TrackReferenceTypeBox.prototype.parse=function(e){this.track_ids=e.readUint32Array((this.size-this.hdr_size)/4)},c.trefBox.prototype.parse=function(e){for(var t,r;e.getPosition()<this.start+this.size;){if((t=c.parseOneBox(e,!0,this.size-(e.getPosition()-this.start))).code!==c.OK)return;(r=new c.TrackReferenceTypeBox(t.type,t.size,t.hdr_size,t.start)).write===c.Box.prototype.write&&"mdat"!==r.type&&(o.info("BoxParser","TrackReference "+r.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),r.parseDataAndRewind(e)),r.parse(e),this.boxes.push(r)}},c.createFullBoxCtor("trep",(function(e){for(this.track_ID=e.readUint32(),this.boxes=[];e.getPosition()<this.start+this.size;){if(ret=c.parseOneBox(e,!1,this.size-(e.getPosition()-this.start)),ret.code!==c.OK)return;box=ret.box,this.boxes.push(box)}})),c.createFullBoxCtor("trex",(function(e){this.track_id=e.readUint32(),this.default_sample_description_index=e.readUint32(),this.default_sample_duration=e.readUint32(),this.default_sample_size=e.readUint32(),this.default_sample_flags=e.readUint32()})),c.createBoxCtor("trpy",(function(e){this.bytessent=e.readUint64()})),c.createFullBoxCtor("trun",(function(e){var t=0;if(this.sample_count=e.readUint32(),t+=4,this.size-this.hdr_size>t&&this.flags&c.TRUN_FLAGS_DATA_OFFSET?(this.data_offset=e.readInt32(),t+=4):this.data_offset=0,this.size-this.hdr_size>t&&this.flags&c.TRUN_FLAGS_FIRST_FLAG?(this.first_sample_flags=e.readUint32(),t+=4):this.first_sample_flags=0,this.sample_duration=[],this.sample_size=[],this.sample_flags=[],this.sample_composition_time_offset=[],this.size-this.hdr_size>t)for(var r=0;r<this.sample_count;r++)this.flags&c.TRUN_FLAGS_DURATION&&(this.sample_duration[r]=e.readUint32()),this.flags&c.TRUN_FLAGS_SIZE&&(this.sample_size[r]=e.readUint32()),this.flags&c.TRUN_FLAGS_FLAGS&&(this.sample_flags[r]=e.readUint32()),this.flags&c.TRUN_FLAGS_CTS_OFFSET&&(0===this.version?this.sample_composition_time_offset[r]=e.readUint32():this.sample_composition_time_offset[r]=e.readInt32())})),c.createFullBoxCtor("tsel",(function(e){this.switch_group=e.readUint32();var t=(this.size-this.hdr_size-4)/4;this.attribute_list=[];for(var r=0;r<t;r++)this.attribute_list[r]=e.readUint32()})),c.createFullBoxCtor("txtC",(function(e){this.config=e.readCString()})),c.createBoxCtor("tyco",(function(e){var t=(this.size-this.hdr_size)/4;this.compatible_brands=[];for(var r=0;r<t;r++)this.compatible_brands[r]=e.readString(4)})),c.createFullBoxCtor("udes",(function(e){this.lang=e.readCString(),this.name=e.readCString(),this.description=e.readCString(),this.tags=e.readCString()})),c.createFullBoxCtor("uncC",(function(e){var t;if(this.profile=e.readUint32(),1==this.version);else if(0==this.version){for(this.component_count=e.readUint32(),this.component_index=[],this.component_bit_depth_minus_one=[],this.component_format=[],this.component_align_size=[],t=0;t<this.component_count;t++)this.component_index.push(e.readUint16()),this.component_bit_depth_minus_one.push(e.readUint8()),this.component_format.push(e.readUint8()),this.component_align_size.push(e.readUint8());this.sampling_type=e.readUint8(),this.interleave_type=e.readUint8(),this.block_size=e.readUint8();var r=e.readUint8();this.component_little_endian=r>>7&1,this.block_pad_lsb=r>>6&1,this.block_little_endian=r>>5&1,this.block_reversed=r>>4&1,this.pad_unknown=r>>3&1,this.pixel_size=e.readUint32(),this.row_align_size=e.readUint32(),this.tile_align_size=e.readUint32(),this.num_tile_cols_minus_one=e.readUint32(),this.num_tile_rows_minus_one=e.readUint32()}})),c.createFullBoxCtor("url ",(function(e){1!==this.flags&&(this.location=e.readCString())})),c.createFullBoxCtor("urn ",(function(e){this.name=e.readCString(),this.size-this.hdr_size-this.name.length-1>0&&(this.location=e.readCString())})),c.createUUIDBox("a5d40b30e81411ddba2f0800200c9a66",!0,!1,(function(e){this.LiveServerManifest=e.readString(this.size-this.hdr_size).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")})),c.createUUIDBox("d08a4f1810f34a82b6c832d8aba183d3",!0,!1,(function(e){this.system_id=c.parseHex16(e);var t=e.readUint32();t>0&&(this.data=e.readUint8Array(t))})),c.createUUIDBox("a2394f525a9b4f14a2446c427c648df4",!0,!1),c.createUUIDBox("8974dbce7be74c5184f97148f9882554",!0,!1,(function(e){this.default_AlgorithmID=e.readUint24(),this.default_IV_size=e.readUint8(),this.default_KID=c.parseHex16(e)})),c.createUUIDBox("d4807ef2ca3946958e5426cb9e46a79f",!0,!1,(function(e){this.fragment_count=e.readUint8(),this.entries=[];for(var t=0;t<this.fragment_count;t++){var r={},i=0,n=0;1===this.version?(i=e.readUint64(),n=e.readUint64()):(i=e.readUint32(),n=e.readUint32()),r.absolute_time=i,r.absolute_duration=n,this.entries.push(r)}})),c.createUUIDBox("6d1d9b0542d544e680e2141daff757b2",!0,!1,(function(e){1===this.version?(this.absolute_time=e.readUint64(),this.duration=e.readUint64()):(this.absolute_time=e.readUint32(),this.duration=e.readUint32())})),c.createFullBoxCtor("vmhd",(function(e){this.graphicsmode=e.readUint16(),this.opcolor=e.readUint16Array(3)})),c.createFullBoxCtor("vpcC",(function(e){var t;1===this.version?(this.profile=e.readUint8(),this.level=e.readUint8(),t=e.readUint8(),this.bitDepth=t>>4,this.chromaSubsampling=t>>1&7,this.videoFullRangeFlag=1&t,this.colourPrimaries=e.readUint8(),this.transferCharacteristics=e.readUint8(),this.matrixCoefficients=e.readUint8(),this.codecIntializationDataSize=e.readUint16(),this.codecIntializationData=e.readUint8Array(this.codecIntializationDataSize)):(this.profile=e.readUint8(),this.level=e.readUint8(),t=e.readUint8(),this.bitDepth=t>>4&15,this.colorSpace=15&t,t=e.readUint8(),this.chromaSubsampling=t>>4&15,this.transferFunction=t>>1&7,this.videoFullRangeFlag=1&t,this.codecIntializationDataSize=e.readUint16(),this.codecIntializationData=e.readUint8Array(this.codecIntializationDataSize))})),c.createBoxCtor("vttC",(function(e){this.text=e.readString(this.size-this.hdr_size)})),c.createFullBoxCtor("vvcC",(function(e){var t,r,i={held_bits:void 0,num_held_bits:0,stream_read_1_bytes:function(e){this.held_bits=e.readUint8(),this.num_held_bits=8},stream_read_2_bytes:function(e){this.held_bits=e.readUint16(),this.num_held_bits=16},extract_bits:function(e){var t=this.held_bits>>this.num_held_bits-e&(1<<e)-1;return this.num_held_bits-=e,t}};if(i.stream_read_1_bytes(e),i.extract_bits(5),this.lengthSizeMinusOne=i.extract_bits(2),this.ptl_present_flag=i.extract_bits(1),this.ptl_present_flag){if(i.stream_read_2_bytes(e),this.ols_idx=i.extract_bits(9),this.num_sublayers=i.extract_bits(3),this.constant_frame_rate=i.extract_bits(2),this.chroma_format_idc=i.extract_bits(2),i.stream_read_1_bytes(e),this.bit_depth_minus8=i.extract_bits(3),i.extract_bits(5),i.stream_read_2_bytes(e),i.extract_bits(2),this.num_bytes_constraint_info=i.extract_bits(6),this.general_profile_idc=i.extract_bits(7),this.general_tier_flag=i.extract_bits(1),this.general_level_idc=e.readUint8(),i.stream_read_1_bytes(e),this.ptl_frame_only_constraint_flag=i.extract_bits(1),this.ptl_multilayer_enabled_flag=i.extract_bits(1),this.general_constraint_info=new Uint8Array(this.num_bytes_constraint_info),this.num_bytes_constraint_info){for(t=0;t<this.num_bytes_constraint_info-1;t++){var n=i.extract_bits(6);i.stream_read_1_bytes(e);var s=i.extract_bits(2);this.general_constraint_info[t]=n<<2|s}this.general_constraint_info[this.num_bytes_constraint_info-1]=i.extract_bits(6)}else i.extract_bits(6);if(this.num_sublayers>1){for(i.stream_read_1_bytes(e),this.ptl_sublayer_present_mask=0,r=this.num_sublayers-2;r>=0;--r){var o=i.extract_bits(1);this.ptl_sublayer_present_mask|=o<<r}for(r=this.num_sublayers;r<=8&&this.num_sublayers>1;++r)i.extract_bits(1);for(this.sublayer_level_idc=[],r=this.num_sublayers-2;r>=0;--r)this.ptl_sublayer_present_mask&1<<r&&(this.sublayer_level_idc[r]=e.readUint8())}if(this.ptl_num_sub_profiles=e.readUint8(),this.general_sub_profile_idc=[],this.ptl_num_sub_profiles)for(t=0;t<this.ptl_num_sub_profiles;t++)this.general_sub_profile_idc.push(e.readUint32());this.max_picture_width=e.readUint16(),this.max_picture_height=e.readUint16(),this.avg_frame_rate=e.readUint16()}this.nalu_arrays=[];var a=e.readUint8();for(t=0;t<a;t++){var l=[];this.nalu_arrays.push(l),i.stream_read_1_bytes(e),l.completeness=i.extract_bits(1),i.extract_bits(2),l.nalu_type=i.extract_bits(5);var d=1;for(13!=l.nalu_type&&12!=l.nalu_type&&(d=e.readUint16()),r=0;r<d;r++){var u=e.readUint16();l.push({data:e.readUint8Array(u),length:u})}}})),c.createFullBoxCtor("vvnC",(function(e){var t=strm.readUint8();this.lengthSizeMinusOne=3&t})),c.SampleEntry.prototype.isVideo=function(){return!1},c.SampleEntry.prototype.isAudio=function(){return!1},c.SampleEntry.prototype.isSubtitle=function(){return!1},c.SampleEntry.prototype.isMetadata=function(){return!1},c.SampleEntry.prototype.isHint=function(){return!1},c.SampleEntry.prototype.getCodec=function(){return this.type.replace(".","")},c.SampleEntry.prototype.getWidth=function(){return""},c.SampleEntry.prototype.getHeight=function(){return""},c.SampleEntry.prototype.getChannelCount=function(){return""},c.SampleEntry.prototype.getSampleRate=function(){return""},c.SampleEntry.prototype.getSampleSize=function(){return""},c.VisualSampleEntry.prototype.isVideo=function(){return!0},c.VisualSampleEntry.prototype.getWidth=function(){return this.width},c.VisualSampleEntry.prototype.getHeight=function(){return this.height},c.AudioSampleEntry.prototype.isAudio=function(){return!0},c.AudioSampleEntry.prototype.getChannelCount=function(){return this.channel_count},c.AudioSampleEntry.prototype.getSampleRate=function(){return this.samplerate},c.AudioSampleEntry.prototype.getSampleSize=function(){return this.samplesize},c.SubtitleSampleEntry.prototype.isSubtitle=function(){return!0},c.MetadataSampleEntry.prototype.isMetadata=function(){return!0},c.decimalToHex=function(e,t){var r=Number(e).toString(16);for(t=null==t?t=2:t;r.length<t;)r="0"+r;return r},c.avc1SampleEntry.prototype.getCodec=c.avc2SampleEntry.prototype.getCodec=c.avc3SampleEntry.prototype.getCodec=c.avc4SampleEntry.prototype.getCodec=function(){var e=c.SampleEntry.prototype.getCodec.call(this);return this.avcC?e+"."+c.decimalToHex(this.avcC.AVCProfileIndication)+c.decimalToHex(this.avcC.profile_compatibility)+c.decimalToHex(this.avcC.AVCLevelIndication):e},c.hev1SampleEntry.prototype.getCodec=c.hvc1SampleEntry.prototype.getCodec=function(){var e,t=c.SampleEntry.prototype.getCodec.call(this);if(this.hvcC){switch(t+=".",this.hvcC.general_profile_space){case 0:t+="";break;case 1:t+="A";break;case 2:t+="B";break;case 3:t+="C"}t+=this.hvcC.general_profile_idc,t+=".";var r=this.hvcC.general_profile_compatibility,i=0;for(e=0;e<32&&(i|=1&r,31!=e);e++)i<<=1,r>>=1;t+=c.decimalToHex(i,0),t+=".",0===this.hvcC.general_tier_flag?t+="L":t+="H",t+=this.hvcC.general_level_idc;var n=!1,s="";for(e=5;e>=0;e--)(this.hvcC.general_constraint_indicator[e]||n)&&(s="."+c.decimalToHex(this.hvcC.general_constraint_indicator[e],0)+s,n=!0);t+=s}return t},c.vvc1SampleEntry.prototype.getCodec=c.vvi1SampleEntry.prototype.getCodec=function(){var e,t=c.SampleEntry.prototype.getCodec.call(this);if(this.vvcC){t+="."+this.vvcC.general_profile_idc,this.vvcC.general_tier_flag?t+=".H":t+=".L",t+=this.vvcC.general_level_idc;var r="";if(this.vvcC.general_constraint_info){var i,n=[],s=0;for(s|=this.vvcC.ptl_frame_only_constraint<<7,s|=this.vvcC.ptl_multilayer_enabled<<6,e=0;e<this.vvcC.general_constraint_info.length;++e)s|=this.vvcC.general_constraint_info[e]>>2&63,n.push(s),s&&(i=e),s=this.vvcC.general_constraint_info[e]>>2&3;if(void 0===i)r=".CA";else{r=".C";var o="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",a=0,l=0;for(e=0;e<=i;++e)for(a=a<<8|n[e],l+=8;l>=5;){r+=o[a>>l-5&31],a&=(1<<(l-=5))-1}l&&(r+=o[31&(a<<=5-l)])}}t+=r}return t},c.mp4aSampleEntry.prototype.getCodec=function(){var e=c.SampleEntry.prototype.getCodec.call(this);if(this.esds&&this.esds.esd){var t=this.esds.esd.getOTI(),r=this.esds.esd.getAudioConfig();return e+"."+c.decimalToHex(t)+(r?"."+r:"")}return e},c.stxtSampleEntry.prototype.getCodec=function(){var e=c.SampleEntry.prototype.getCodec.call(this);return this.mime_format?e+"."+this.mime_format:e},c.vp08SampleEntry.prototype.getCodec=c.vp09SampleEntry.prototype.getCodec=function(){var e=c.SampleEntry.prototype.getCodec.call(this),t=this.vpcC.level;0==t&&(t="00");var r=this.vpcC.bitDepth;return 8==r&&(r="08"),e+".0"+this.vpcC.profile+"."+t+"."+r},c.av01SampleEntry.prototype.getCodec=function(){var e,t=c.SampleEntry.prototype.getCodec.call(this),r=this.av1C.seq_level_idx_0;return r<10&&(r="0"+r),2===this.av1C.seq_profile&&1===this.av1C.high_bitdepth?e=1===this.av1C.twelve_bit?"12":"10":this.av1C.seq_profile<=2&&(e=1===this.av1C.high_bitdepth?"10":"08"),t+"."+this.av1C.seq_profile+"."+r+(this.av1C.seq_tier_0?"H":"M")+"."+e},c.Box.prototype.writeHeader=function(e,t){this.size+=8,this.size>d&&(this.size+=8),"uuid"===this.type&&(this.size+=16),o.debug("BoxWriter","Writing box "+this.type+" of size: "+this.size+" at position "+e.getPosition()+(t||"")),this.size>d?e.writeUint32(1):(this.sizePosition=e.getPosition(),e.writeUint32(this.size)),e.writeString(this.type,null,4),"uuid"===this.type&&e.writeUint8Array(this.uuid),this.size>d&&e.writeUint64(this.size)},c.FullBox.prototype.writeHeader=function(e){this.size+=4,c.Box.prototype.writeHeader.call(this,e," v="+this.version+" f="+this.flags),e.writeUint8(this.version),e.writeUint24(this.flags)},c.Box.prototype.write=function(e){"mdat"===this.type?this.data&&(this.size=this.data.length,this.writeHeader(e),e.writeUint8Array(this.data)):(this.size=this.data?this.data.length:0,this.writeHeader(e),this.data&&e.writeUint8Array(this.data))},c.ContainerBox.prototype.write=function(e){this.size=0,this.writeHeader(e);for(var t=0;t<this.boxes.length;t++)this.boxes[t]&&(this.boxes[t].write(e),this.size+=this.boxes[t].size);o.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},c.TrackReferenceTypeBox.prototype.write=function(e){this.size=4*this.track_ids.length,this.writeHeader(e),e.writeUint32Array(this.track_ids)},c.avcCBox.prototype.write=function(e){var t;for(this.size=7,t=0;t<this.SPS.length;t++)this.size+=2+this.SPS[t].length;for(t=0;t<this.PPS.length;t++)this.size+=2+this.PPS[t].length;for(this.ext&&(this.size+=this.ext.length),this.writeHeader(e),e.writeUint8(this.configurationVersion),e.writeUint8(this.AVCProfileIndication),e.writeUint8(this.profile_compatibility),e.writeUint8(this.AVCLevelIndication),e.writeUint8(this.lengthSizeMinusOne+252),e.writeUint8(this.SPS.length+224),t=0;t<this.SPS.length;t++)e.writeUint16(this.SPS[t].length),e.writeUint8Array(this.SPS[t].nalu);for(e.writeUint8(this.PPS.length),t=0;t<this.PPS.length;t++)e.writeUint16(this.PPS[t].length),e.writeUint8Array(this.PPS[t].nalu);this.ext&&e.writeUint8Array(this.ext)},c.co64Box.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=4+8*this.chunk_offsets.length,this.writeHeader(e),e.writeUint32(this.chunk_offsets.length),t=0;t<this.chunk_offsets.length;t++)e.writeUint64(this.chunk_offsets[t])},c.cslgBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=20,this.writeHeader(e),e.writeInt32(this.compositionToDTSShift),e.writeInt32(this.leastDecodeToDisplayDelta),e.writeInt32(this.greatestDecodeToDisplayDelta),e.writeInt32(this.compositionStartTime),e.writeInt32(this.compositionEndTime)},c.cttsBox.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=4+8*this.sample_counts.length,this.writeHeader(e),e.writeUint32(this.sample_counts.length),t=0;t<this.sample_counts.length;t++)e.writeUint32(this.sample_counts[t]),1===this.version?e.writeInt32(this.sample_offsets[t]):e.writeUint32(this.sample_offsets[t])},c.drefBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4,this.writeHeader(e),e.writeUint32(this.entries.length);for(var t=0;t<this.entries.length;t++)this.entries[t].write(e),this.size+=this.entries[t].size;o.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},c.elngBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=this.extended_language.length,this.writeHeader(e),e.writeString(this.extended_language)},c.elstBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4+12*this.entries.length,this.writeHeader(e),e.writeUint32(this.entries.length);for(var t=0;t<this.entries.length;t++){var r=this.entries[t];e.writeUint32(r.segment_duration),e.writeInt32(r.media_time),e.writeInt16(r.media_rate_integer),e.writeInt16(r.media_rate_fraction)}},c.emsgBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=16+this.message_data.length+(this.scheme_id_uri.length+1)+(this.value.length+1),this.writeHeader(e),e.writeCString(this.scheme_id_uri),e.writeCString(this.value),e.writeUint32(this.timescale),e.writeUint32(this.presentation_time_delta),e.writeUint32(this.event_duration),e.writeUint32(this.id),e.writeUint8Array(this.message_data)},c.ftypBox.prototype.write=function(e){this.size=8+4*this.compatible_brands.length,this.writeHeader(e),e.writeString(this.major_brand,null,4),e.writeUint32(this.minor_version);for(var t=0;t<this.compatible_brands.length;t++)e.writeString(this.compatible_brands[t],null,4)},c.hdlrBox.prototype.write=function(e){this.size=20+this.name.length+1,this.version=0,this.flags=0,this.writeHeader(e),e.writeUint32(0),e.writeString(this.handler,null,4),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeCString(this.name)},c.hvcCBox.prototype.write=function(e){var t,r;for(this.size=23,t=0;t<this.nalu_arrays.length;t++)for(this.size+=3,r=0;r<this.nalu_arrays[t].length;r++)this.size+=2+this.nalu_arrays[t][r].data.length;for(this.writeHeader(e),e.writeUint8(this.configurationVersion),e.writeUint8(this.general_profile_space<<6+this.general_tier_flag<<5+this.general_profile_idc),e.writeUint32(this.general_profile_compatibility),e.writeUint8Array(this.general_constraint_indicator),e.writeUint8(this.general_level_idc),e.writeUint16(this.min_spatial_segmentation_idc+(15<<24)),e.writeUint8(this.parallelismType+252),e.writeUint8(this.chroma_format_idc+252),e.writeUint8(this.bit_depth_luma_minus8+248),e.writeUint8(this.bit_depth_chroma_minus8+248),e.writeUint16(this.avgFrameRate),e.writeUint8((this.constantFrameRate<<6)+(this.numTemporalLayers<<3)+(this.temporalIdNested<<2)+this.lengthSizeMinusOne),e.writeUint8(this.nalu_arrays.length),t=0;t<this.nalu_arrays.length;t++)for(e.writeUint8((this.nalu_arrays[t].completeness<<7)+this.nalu_arrays[t].nalu_type),e.writeUint16(this.nalu_arrays[t].length),r=0;r<this.nalu_arrays[t].length;r++)e.writeUint16(this.nalu_arrays[t][r].data.length),e.writeUint8Array(this.nalu_arrays[t][r].data)},c.kindBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=this.schemeURI.length+1+(this.value.length+1),this.writeHeader(e),e.writeCString(this.schemeURI),e.writeCString(this.value)},c.mdhdBox.prototype.write=function(e){this.size=20,this.flags=0,this.version=0,this.writeHeader(e),e.writeUint32(this.creation_time),e.writeUint32(this.modification_time),e.writeUint32(this.timescale),e.writeUint32(this.duration),e.writeUint16(this.language),e.writeUint16(0)},c.mehdBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4,this.writeHeader(e),e.writeUint32(this.fragment_duration)},c.mfhdBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4,this.writeHeader(e),e.writeUint32(this.sequence_number)},c.mvhdBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=96,this.writeHeader(e),e.writeUint32(this.creation_time),e.writeUint32(this.modification_time),e.writeUint32(this.timescale),e.writeUint32(this.duration),e.writeUint32(this.rate),e.writeUint16(this.volume<<8),e.writeUint16(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32Array(this.matrix),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32(this.next_track_id)},c.SampleEntry.prototype.writeHeader=function(e){this.size=8,c.Box.prototype.writeHeader.call(this,e),e.writeUint8(0),e.writeUint8(0),e.writeUint8(0),e.writeUint8(0),e.writeUint8(0),e.writeUint8(0),e.writeUint16(this.data_reference_index)},c.SampleEntry.prototype.writeFooter=function(e){for(var t=0;t<this.boxes.length;t++)this.boxes[t].write(e),this.size+=this.boxes[t].size;o.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},c.SampleEntry.prototype.write=function(e){this.writeHeader(e),e.writeUint8Array(this.data),this.size+=this.data.length,o.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},c.VisualSampleEntry.prototype.write=function(e){this.writeHeader(e),this.size+=70,e.writeUint16(0),e.writeUint16(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeUint16(this.width),e.writeUint16(this.height),e.writeUint32(this.horizresolution),e.writeUint32(this.vertresolution),e.writeUint32(0),e.writeUint16(this.frame_count),e.writeUint8(Math.min(31,this.compressorname.length)),e.writeString(this.compressorname,null,31),e.writeUint16(this.depth),e.writeInt16(-1),this.writeFooter(e)},c.AudioSampleEntry.prototype.write=function(e){this.writeHeader(e),this.size+=20,e.writeUint32(0),e.writeUint32(0),e.writeUint16(this.channel_count),e.writeUint16(this.samplesize),e.writeUint16(0),e.writeUint16(0),e.writeUint32(this.samplerate<<16),this.writeFooter(e)},c.stppSampleEntry.prototype.write=function(e){this.writeHeader(e),this.size+=this.namespace.length+1+this.schema_location.length+1+this.auxiliary_mime_types.length+1,e.writeCString(this.namespace),e.writeCString(this.schema_location),e.writeCString(this.auxiliary_mime_types),this.writeFooter(e)},c.SampleGroupEntry.prototype.write=function(e){e.writeUint8Array(this.data)},c.sbgpBox.prototype.write=function(e){this.version=1,this.flags=0,this.size=12+8*this.entries.length,this.writeHeader(e),e.writeString(this.grouping_type,null,4),e.writeUint32(this.grouping_type_parameter),e.writeUint32(this.entries.length);for(var t=0;t<this.entries.length;t++){var r=this.entries[t];e.writeInt32(r.sample_count),e.writeInt32(r.group_description_index)}},c.sgpdBox.prototype.write=function(e){var t,r;for(this.flags=0,this.size=12,t=0;t<this.entries.length;t++)r=this.entries[t],1===this.version&&(0===this.default_length&&(this.size+=4),this.size+=r.data.length);for(this.writeHeader(e),e.writeString(this.grouping_type,null,4),1===this.version&&e.writeUint32(this.default_length),this.version>=2&&e.writeUint32(this.default_sample_description_index),e.writeUint32(this.entries.length),t=0;t<this.entries.length;t++)r=this.entries[t],1===this.version&&0===this.default_length&&e.writeUint32(r.description_length),r.write(e)},c.sidxBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=20+12*this.references.length,this.writeHeader(e),e.writeUint32(this.reference_ID),e.writeUint32(this.timescale),e.writeUint32(this.earliest_presentation_time),e.writeUint32(this.first_offset),e.writeUint16(0),e.writeUint16(this.references.length);for(var t=0;t<this.references.length;t++){var r=this.references[t];e.writeUint32(r.reference_type<<31|r.referenced_size),e.writeUint32(r.subsegment_duration),e.writeUint32(r.starts_with_SAP<<31|r.SAP_type<<28|r.SAP_delta_time)}},c.smhdBox.prototype.write=function(e){this.version=0,this.flags=1,this.size=4,this.writeHeader(e),e.writeUint16(this.balance),e.writeUint16(0)},c.stcoBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4+4*this.chunk_offsets.length,this.writeHeader(e),e.writeUint32(this.chunk_offsets.length),e.writeUint32Array(this.chunk_offsets)},c.stscBox.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=4+12*this.first_chunk.length,this.writeHeader(e),e.writeUint32(this.first_chunk.length),t=0;t<this.first_chunk.length;t++)e.writeUint32(this.first_chunk[t]),e.writeUint32(this.samples_per_chunk[t]),e.writeUint32(this.sample_description_index[t])},c.stsdBox.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=0,this.writeHeader(e),e.writeUint32(this.entries.length),this.size+=4,t=0;t<this.entries.length;t++)this.entries[t].write(e),this.size+=this.entries[t].size;o.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},c.stshBox.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=4+8*this.shadowed_sample_numbers.length,this.writeHeader(e),e.writeUint32(this.shadowed_sample_numbers.length),t=0;t<this.shadowed_sample_numbers.length;t++)e.writeUint32(this.shadowed_sample_numbers[t]),e.writeUint32(this.sync_sample_numbers[t])},c.stssBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4+4*this.sample_numbers.length,this.writeHeader(e),e.writeUint32(this.sample_numbers.length),e.writeUint32Array(this.sample_numbers)},c.stszBox.prototype.write=function(e){var t,r=!0;if(this.version=0,this.flags=0,this.sample_sizes.length>0)for(t=0;t+1<this.sample_sizes.length;){if(this.sample_sizes[t+1]!==this.sample_sizes[0]){r=!1;break}t++}else r=!1;this.size=8,r||(this.size+=4*this.sample_sizes.length),this.writeHeader(e),r?e.writeUint32(this.sample_sizes[0]):e.writeUint32(0),e.writeUint32(this.sample_sizes.length),r||e.writeUint32Array(this.sample_sizes)},c.sttsBox.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=4+8*this.sample_counts.length,this.writeHeader(e),e.writeUint32(this.sample_counts.length),t=0;t<this.sample_counts.length;t++)e.writeUint32(this.sample_counts[t]),e.writeUint32(this.sample_deltas[t])},c.tfdtBox.prototype.write=function(e){var t=Math.pow(2,32)-1;this.version=this.baseMediaDecodeTime>t?1:0,this.flags=0,this.size=4,1===this.version&&(this.size+=4),this.writeHeader(e),1===this.version?e.writeUint64(this.baseMediaDecodeTime):e.writeUint32(this.baseMediaDecodeTime)},c.tfhdBox.prototype.write=function(e){this.version=0,this.size=4,this.flags&c.TFHD_FLAG_BASE_DATA_OFFSET&&(this.size+=8),this.flags&c.TFHD_FLAG_SAMPLE_DESC&&(this.size+=4),this.flags&c.TFHD_FLAG_SAMPLE_DUR&&(this.size+=4),this.flags&c.TFHD_FLAG_SAMPLE_SIZE&&(this.size+=4),this.flags&c.TFHD_FLAG_SAMPLE_FLAGS&&(this.size+=4),this.writeHeader(e),e.writeUint32(this.track_id),this.flags&c.TFHD_FLAG_BASE_DATA_OFFSET&&e.writeUint64(this.base_data_offset),this.flags&c.TFHD_FLAG_SAMPLE_DESC&&e.writeUint32(this.default_sample_description_index),this.flags&c.TFHD_FLAG_SAMPLE_DUR&&e.writeUint32(this.default_sample_duration),this.flags&c.TFHD_FLAG_SAMPLE_SIZE&&e.writeUint32(this.default_sample_size),this.flags&c.TFHD_FLAG_SAMPLE_FLAGS&&e.writeUint32(this.default_sample_flags)},c.tkhdBox.prototype.write=function(e){this.version=0,this.size=80,this.writeHeader(e),e.writeUint32(this.creation_time),e.writeUint32(this.modification_time),e.writeUint32(this.track_id),e.writeUint32(0),e.writeUint32(this.duration),e.writeUint32(0),e.writeUint32(0),e.writeInt16(this.layer),e.writeInt16(this.alternate_group),e.writeInt16(this.volume<<8),e.writeUint16(0),e.writeInt32Array(this.matrix),e.writeUint32(this.width),e.writeUint32(this.height)},c.trexBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=20,this.writeHeader(e),e.writeUint32(this.track_id),e.writeUint32(this.default_sample_description_index),e.writeUint32(this.default_sample_duration),e.writeUint32(this.default_sample_size),e.writeUint32(this.default_sample_flags)},c.trunBox.prototype.write=function(e){this.version=0,this.size=4,this.flags&c.TRUN_FLAGS_DATA_OFFSET&&(this.size+=4),this.flags&c.TRUN_FLAGS_FIRST_FLAG&&(this.size+=4),this.flags&c.TRUN_FLAGS_DURATION&&(this.size+=4*this.sample_duration.length),this.flags&c.TRUN_FLAGS_SIZE&&(this.size+=4*this.sample_size.length),this.flags&c.TRUN_FLAGS_FLAGS&&(this.size+=4*this.sample_flags.length),this.flags&c.TRUN_FLAGS_CTS_OFFSET&&(this.size+=4*this.sample_composition_time_offset.length),this.writeHeader(e),e.writeUint32(this.sample_count),this.flags&c.TRUN_FLAGS_DATA_OFFSET&&(this.data_offset_position=e.getPosition(),e.writeInt32(this.data_offset)),this.flags&c.TRUN_FLAGS_FIRST_FLAG&&e.writeUint32(this.first_sample_flags);for(var t=0;t<this.sample_count;t++)this.flags&c.TRUN_FLAGS_DURATION&&e.writeUint32(this.sample_duration[t]),this.flags&c.TRUN_FLAGS_SIZE&&e.writeUint32(this.sample_size[t]),this.flags&c.TRUN_FLAGS_FLAGS&&e.writeUint32(this.sample_flags[t]),this.flags&c.TRUN_FLAGS_CTS_OFFSET&&(0===this.version?e.writeUint32(this.sample_composition_time_offset[t]):e.writeInt32(this.sample_composition_time_offset[t]))},c["url Box"].prototype.write=function(e){this.version=0,this.location?(this.flags=0,this.size=this.location.length+1):(this.flags=1,this.size=0),this.writeHeader(e),this.location&&e.writeCString(this.location)},c["urn Box"].prototype.write=function(e){this.version=0,this.flags=0,this.size=this.name.length+1+(this.location?this.location.length+1:0),this.writeHeader(e),e.writeCString(this.name),this.location&&e.writeCString(this.location)},c.vmhdBox.prototype.write=function(e){this.version=0,this.flags=1,this.size=8,this.writeHeader(e),e.writeUint16(this.graphicsmode),e.writeUint16Array(this.opcolor)},c.cttsBox.prototype.unpack=function(e){var t,r,i;for(i=0,t=0;t<this.sample_counts.length;t++)for(r=0;r<this.sample_counts[t];r++)e[i].pts=e[i].dts+this.sample_offsets[t],i++},c.sttsBox.prototype.unpack=function(e){var t,r,i;for(i=0,t=0;t<this.sample_counts.length;t++)for(r=0;r<this.sample_counts[t];r++)e[i].dts=0===i?0:e[i-1].dts+this.sample_deltas[t],i++},c.stcoBox.prototype.unpack=function(e){var t;for(t=0;t<this.chunk_offsets.length;t++)e[t].offset=this.chunk_offsets[t]},c.stscBox.prototype.unpack=function(e){var t,r,i,n,s;for(n=0,s=0,t=0;t<this.first_chunk.length;t++)for(r=0;r<(t+1<this.first_chunk.length?this.first_chunk[t+1]:1/0);r++)for(s++,i=0;i<this.samples_per_chunk[t];i++){if(!e[n])return;e[n].description_index=this.sample_description_index[t],e[n].chunk_index=s,n++}},c.stszBox.prototype.unpack=function(e){var t;for(t=0;t<this.sample_sizes.length;t++)e[t].size=this.sample_sizes[t]},c.DIFF_BOXES_PROP_NAMES=["boxes","entries","references","subsamples","items","item_infos","extents","associations","subsegments","ranges","seekLists","seekPoints","esd","levels"],c.DIFF_PRIMITIVE_ARRAY_PROP_NAMES=["compatible_brands","matrix","opcolor","sample_counts","sample_counts","sample_deltas","first_chunk","samples_per_chunk","sample_sizes","chunk_offsets","sample_offsets","sample_description_index","sample_duration"],c.boxEqualFields=function(e,t){if(e&&!t)return!1;var r;for(r in e)if(!(c.DIFF_BOXES_PROP_NAMES.indexOf(r)>-1||e[r]instanceof c.Box||t[r]instanceof c.Box||void 0===e[r]||void 0===t[r]||"function"==typeof e[r]||"function"==typeof t[r]||e.subBoxNames&&e.subBoxNames.indexOf(r.slice(0,4))>-1||t.subBoxNames&&t.subBoxNames.indexOf(r.slice(0,4))>-1||"data"===r||"start"===r||"size"===r||"creation_time"===r||"modification_time"===r||c.DIFF_PRIMITIVE_ARRAY_PROP_NAMES.indexOf(r)>-1||e[r]===t[r]))return!1;return!0},c.boxEqual=function(e,t){if(!c.boxEqualFields(e,t))return!1;for(var r=0;r<c.DIFF_BOXES_PROP_NAMES.length;r++){var i=c.DIFF_BOXES_PROP_NAMES[r];if(e[i]&&t[i]&&!c.boxEqual(e[i],t[i]))return!1}return!0};var m=function(){};m.prototype.parseSample=function(e){var t,r={};r.resources=[];var i=new a(e.data.buffer);if(e.subsamples&&0!==e.subsamples.length){if(r.documentString=i.readString(e.subsamples[0].size),e.subsamples.length>1)for(t=1;t<e.subsamples.length;t++)r.resources[t]=i.readUint8Array(e.subsamples[t].size)}else r.documentString=i.readString(e.data.length);return"undefined"!=typeof DOMParser&&(r.document=(new DOMParser).parseFromString(r.documentString,"application/xml")),r};var _=function(){};_.prototype.parseSample=function(e){return new a(e.data.buffer).readString(e.data.length)},_.prototype.parseConfig=function(e){var t=new a(e.buffer);return t.readUint32(),t.readCString()},t.XMLSubtitlein4Parser=m,t.Textin4Parser=_;var g=function(e){this.stream=e||new u,this.boxes=[],this.mdats=[],this.moofs=[],this.isProgressive=!1,this.moovStartFound=!1,this.onMoovStart=null,this.moovStartSent=!1,this.onReady=null,this.readySent=!1,this.onSegment=null,this.onSamples=null,this.onError=null,this.sampleListBuilt=!1,this.fragmentedTracks=[],this.extractedTracks=[],this.isFragmentationInitialized=!1,this.sampleProcessingStarted=!1,this.nextMoofNumber=0,this.itemListBuilt=!1,this.onSidx=null,this.sidxSent=!1};g.prototype.setSegmentOptions=function(e,t,r){var i=this.getTrackById(e);if(i){var n={};this.fragmentedTracks.push(n),n.id=e,n.user=t,n.trak=i,i.nextSample=0,n.segmentStream=null,n.nb_samples=1e3,n.rapAlignement=!0,r&&(r.nbSamples&&(n.nb_samples=r.nbSamples),r.rapAlignement&&(n.rapAlignement=r.rapAlignement))}},g.prototype.unsetSegmentOptions=function(e){for(var t=-1,r=0;r<this.fragmentedTracks.length;r++){this.fragmentedTracks[r].id==e&&(t=r)}t>-1&&this.fragmentedTracks.splice(t,1)},g.prototype.setExtractionOptions=function(e,t,r){var i=this.getTrackById(e);if(i){var n={};this.extractedTracks.push(n),n.id=e,n.user=t,n.trak=i,i.nextSample=0,n.nb_samples=1e3,n.samples=[],r&&r.nbSamples&&(n.nb_samples=r.nbSamples)}},g.prototype.unsetExtractionOptions=function(e){for(var t=-1,r=0;r<this.extractedTracks.length;r++){this.extractedTracks[r].id==e&&(t=r)}t>-1&&this.extractedTracks.splice(t,1)},g.prototype.parse=function(){var e,t;if(!this.restoreParsePosition||this.restoreParsePosition())for(;;){if(this.hasIncompleteMdat&&this.hasIncompleteMdat()){if(this.processIncompleteMdat())continue;return}if(this.saveParsePosition&&this.saveParsePosition(),(e=c.parseOneBox(this.stream,false)).code===c.ERR_NOT_ENOUGH_DATA){if(this.processIncompleteBox){if(this.processIncompleteBox(e))continue;return}return}var r;switch(r="uuid"!==(t=e.box).type?t.type:t.uuid,this.boxes.push(t),r){case"mdat":this.mdats.push(t);break;case"moof":this.moofs.push(t);break;case"moov":this.moovStartFound=!0,0===this.mdats.length&&(this.isProgressive=!0);default:void 0!==this[r]&&o.warn("ISOFile","Duplicate Box of type: "+r+", overriding previous occurrence"),this[r]=t}this.updateUsedBytes&&this.updateUsedBytes(t,e)}},g.prototype.checkBuffer=function(e){if(null==e)throw"Buffer must be defined and non empty";if(void 0===e.fileStart)throw"Buffer must have a fileStart property";return 0===e.byteLength?(o.warn("ISOFile","Ignoring empty buffer (fileStart: "+e.fileStart+")"),this.stream.logBufferLevel(),!1):(o.info("ISOFile","Processing buffer (fileStart: "+e.fileStart+")"),e.usedBytes=0,this.stream.insertBuffer(e),this.stream.logBufferLevel(),!!this.stream.initialized()||(o.warn("ISOFile","Not ready to start parsing"),!1))},g.prototype.appendBuffer=function(e,t){var r;if(this.checkBuffer(e))return this.parse(),this.moovStartFound&&!this.moovStartSent&&(this.moovStartSent=!0,this.onMoovStart&&this.onMoovStart()),this.moov?(this.sampleListBuilt||(this.buildSampleLists(),this.sampleListBuilt=!0),this.updateSampleLists(),this.onReady&&!this.readySent&&(this.readySent=!0,this.onReady(this.getInfo())),this.processSamples(t),this.nextSeekPosition?(r=this.nextSeekPosition,this.nextSeekPosition=void 0):r=this.nextParsePosition,this.stream.getEndFilePositionAfter&&(r=this.stream.getEndFilePositionAfter(r))):r=this.nextParsePosition?this.nextParsePosition:0,this.sidx&&this.onSidx&&!this.sidxSent&&(this.onSidx(this.sidx),this.sidxSent=!0),this.meta&&(this.flattenItemInfo&&!this.itemListBuilt&&(this.flattenItemInfo(),this.itemListBuilt=!0),this.processItems&&this.processItems(this.onItem)),this.stream.cleanBuffers&&(o.info("ISOFile","Done processing buffer (fileStart: "+e.fileStart+") - next buffer to fetch should have a fileStart position of "+r),this.stream.logBufferLevel(),this.stream.cleanBuffers(),this.stream.logBufferLevel(!0),o.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize())),r},g.prototype.getInfo=function(){var e,t,r,i,n,s,o={},a=new Date("1904-01-01T00:00:00Z").getTime();if(this.moov)for(o.hasMoov=!0,o.duration=this.moov.mvhd.duration,o.timescale=this.moov.mvhd.timescale,o.isFragmented=null!=this.moov.mvex,o.isFragmented&&this.moov.mvex.mehd&&(o.fragment_duration=this.moov.mvex.mehd.fragment_duration),o.isProgressive=this.isProgressive,o.hasIOD=null!=this.moov.iods,o.brands=[],o.brands.push(this.ftyp.major_brand),o.brands=o.brands.concat(this.ftyp.compatible_brands),o.created=new Date(a+1e3*this.moov.mvhd.creation_time),o.modified=new Date(a+1e3*this.moov.mvhd.modification_time),o.tracks=[],o.audioTracks=[],o.videoTracks=[],o.subtitleTracks=[],o.metadataTracks=[],o.hintTracks=[],o.otherTracks=[],e=0;e<this.moov.traks.length;e++){if(s=(r=this.moov.traks[e]).mdia.minf.stbl.stsd.entries[0],i={},o.tracks.push(i),i.id=r.tkhd.track_id,i.name=r.mdia.hdlr.name,i.references=[],r.tref)for(t=0;t<r.tref.boxes.length;t++)n={},i.references.push(n),n.type=r.tref.boxes[t].type,n.track_ids=r.tref.boxes[t].track_ids;r.edts&&(i.edits=r.edts.elst.entries),i.created=new Date(a+1e3*r.tkhd.creation_time),i.modified=new Date(a+1e3*r.tkhd.modification_time),i.movie_duration=r.tkhd.duration,i.movie_timescale=o.timescale,i.layer=r.tkhd.layer,i.alternate_group=r.tkhd.alternate_group,i.volume=r.tkhd.volume,i.matrix=r.tkhd.matrix,i.track_width=r.tkhd.width/65536,i.track_height=r.tkhd.height/65536,i.timescale=r.mdia.mdhd.timescale,i.cts_shift=r.mdia.minf.stbl.cslg,i.duration=r.mdia.mdhd.duration,i.samples_duration=r.samples_duration,i.codec=s.getCodec(),i.kind=r.udta&&r.udta.kinds.length?r.udta.kinds[0]:{schemeURI:"",value:""},i.language=r.mdia.elng?r.mdia.elng.extended_language:r.mdia.mdhd.languageString,i.nb_samples=r.samples.length,i.size=r.samples_size,i.bitrate=8*i.size*i.timescale/i.samples_duration,s.isAudio()?(i.type="audio",o.audioTracks.push(i),i.audio={},i.audio.sample_rate=s.getSampleRate(),i.audio.channel_count=s.getChannelCount(),i.audio.sample_size=s.getSampleSize()):s.isVideo()?(i.type="video",o.videoTracks.push(i),i.video={},i.video.width=s.getWidth(),i.video.height=s.getHeight()):s.isSubtitle()?(i.type="subtitles",o.subtitleTracks.push(i)):s.isHint()?(i.type="metadata",o.hintTracks.push(i)):s.isMetadata()?(i.type="metadata",o.metadataTracks.push(i)):(i.type="metadata",o.otherTracks.push(i))}else o.hasMoov=!1;if(o.mime="",o.hasMoov&&o.tracks){for(o.videoTracks&&o.videoTracks.length>0?o.mime+='video/mp4; codecs="':o.audioTracks&&o.audioTracks.length>0?o.mime+='audio/mp4; codecs="':o.mime+='application/mp4; codecs="',e=0;e<o.tracks.length;e++)0!==e&&(o.mime+=","),o.mime+=o.tracks[e].codec;o.mime+='"; profiles="',o.mime+=this.ftyp.compatible_brands.join(),o.mime+='"'}return o},g.prototype.setNextSeekPositionFromSample=function(e){e&&(this.nextSeekPosition?this.nextSeekPosition=Math.min(e.offset+e.alreadyRead,this.nextSeekPosition):this.nextSeekPosition=e.offset+e.alreadyRead)},g.prototype.processSamples=function(e){var t,r;if(this.sampleProcessingStarted){if(this.isFragmentationInitialized&&null!==this.onSegment)for(t=0;t<this.fragmentedTracks.length;t++){var i=this.fragmentedTracks[t];for(r=i.trak;r.nextSample<r.samples.length&&this.sampleProcessingStarted;){o.debug("ISOFile","Creating media fragment on track #"+i.id+" for sample "+r.nextSample);var n=this.createFragment(i.id,r.nextSample,i.segmentStream);if(!n)break;if(i.segmentStream=n,r.nextSample++,(r.nextSample%i.nb_samples==0||e||r.nextSample>=r.samples.length)&&(o.info("ISOFile","Sending fragmented data on track #"+i.id+" for samples ["+Math.max(0,r.nextSample-i.nb_samples)+","+(r.nextSample-1)+"]"),o.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize()),this.onSegment&&this.onSegment(i.id,i.user,i.segmentStream.buffer,r.nextSample,e||r.nextSample>=r.samples.length),i.segmentStream=null,i!==this.fragmentedTracks[t]))break}}if(null!==this.onSamples)for(t=0;t<this.extractedTracks.length;t++){var s=this.extractedTracks[t];for(r=s.trak;r.nextSample<r.samples.length&&this.sampleProcessingStarted;){o.debug("ISOFile","Exporting on track #"+s.id+" sample #"+r.nextSample);var a=this.getSample(r,r.nextSample);if(!a){this.setNextSeekPositionFromSample(r.samples[r.nextSample]);break}if(r.nextSample++,s.samples.push(a),(r.nextSample%s.nb_samples==0||r.nextSample>=r.samples.length)&&(o.debug("ISOFile","Sending samples on track #"+s.id+" for sample "+r.nextSample),this.onSamples&&this.onSamples(s.id,s.user,s.samples),s.samples=[],s!==this.extractedTracks[t]))break}}}},g.prototype.getBox=function(e){var t=this.getBoxes(e,!0);return t.length?t[0]:null},g.prototype.getBoxes=function(e,t){var r=[];return g._sweep.call(this,e,r,t),r},g._sweep=function(e,t,r){for(var i in this.type&&this.type==e&&t.push(this),this.boxes){if(t.length&&r)return;g._sweep.call(this.boxes[i],e,t,r)}},g.prototype.getTrackSamplesInfo=function(e){var t=this.getTrackById(e);return t?t.samples:void 0},g.prototype.getTrackSample=function(e,t){var r=this.getTrackById(e);return this.getSample(r,t)},g.prototype.releaseUsedSamples=function(e,t){var r=0,i=this.getTrackById(e);i.lastValidSample||(i.lastValidSample=0);for(var n=i.lastValidSample;n<t;n++)r+=this.releaseSample(i,n);o.info("ISOFile","Track #"+e+" released samples up to "+t+" (released size: "+r+", remaining: "+this.samplesDataSize+")"),i.lastValidSample=t},g.prototype.start=function(){this.sampleProcessingStarted=!0,this.processSamples(!1)},g.prototype.stop=function(){this.sampleProcessingStarted=!1},g.prototype.flush=function(){o.info("ISOFile","Flushing remaining samples"),this.updateSampleLists(),this.processSamples(!0),this.stream.cleanBuffers(),this.stream.logBufferLevel(!0)},g.prototype.seekTrack=function(e,t,r){var i,n,s,a,l=0,d=0;if(0===r.samples.length)return o.info("ISOFile","No sample in track, cannot seek! Using time "+o.getDurationString(0,1)+" and offset: 0"),{offset:0,time:0};for(i=0;i<r.samples.length;i++){if(n=r.samples[i],0===i)d=0,a=n.timescale;else if(n.cts>e*n.timescale){d=i-1;break}t&&n.is_sync&&(l=i)}for(t&&(d=l),e=r.samples[d].cts,r.nextSample=d;r.samples[d].alreadyRead===r.samples[d].size&&r.samples[d+1];)d++;return s=r.samples[d].offset+r.samples[d].alreadyRead,o.info("ISOFile","Seeking to "+(t?"RAP":"")+" sample #"+r.nextSample+" on track "+r.tkhd.track_id+", time "+o.getDurationString(e,a)+" and offset: "+s),{offset:s,time:e/a}},g.prototype.getTrackDuration=function(e){var t;return e.samples?((t=e.samples[e.samples.length-1]).cts+t.duration)/t.timescale:1/0},g.prototype.seek=function(e,t){var r,i,n,s=this.moov,a={offset:1/0,time:1/0};if(this.moov){for(n=0;n<s.traks.length;n++)r=s.traks[n],e>this.getTrackDuration(r)||((i=this.seekTrack(e,t,r)).offset<a.offset&&(a.offset=i.offset),i.time<a.time&&(a.time=i.time));return o.info("ISOFile","Seeking at time "+o.getDurationString(a.time,1)+" needs a buffer with a fileStart position of "+a.offset),a.offset===1/0?a={offset:this.nextParsePosition,time:0}:a.offset=this.stream.getEndFilePositionAfter(a.offset),o.info("ISOFile","Adjusted seek position (after checking data already in buffer): "+a.offset),a}throw"Cannot seek: moov not received!"},g.prototype.equal=function(e){for(var t=0;t<this.boxes.length&&t<e.boxes.length;){var r=this.boxes[t],i=e.boxes[t];if(!c.boxEqual(r,i))return!1;t++}return!0},t.ISOFile=g,g.prototype.lastBoxStartPosition=0,g.prototype.parsingMdat=null,g.prototype.nextParsePosition=0,g.prototype.discardMdatData=!1,g.prototype.processIncompleteBox=function(e){var t;return"mdat"===e.type?(t=new c[e.type+"Box"](e.size),this.parsingMdat=t,this.boxes.push(t),this.mdats.push(t),t.start=e.start,t.hdr_size=e.hdr_size,this.stream.addUsedBytes(t.hdr_size),this.lastBoxStartPosition=t.start+t.size,this.stream.seek(t.start+t.size,!1,this.discardMdatData)?(this.parsingMdat=null,!0):(this.moovStartFound?this.nextParsePosition=this.stream.findEndContiguousBuf():this.nextParsePosition=t.start+t.size,!1)):("moov"===e.type&&(this.moovStartFound=!0,0===this.mdats.length&&(this.isProgressive=!0)),!!this.stream.mergeNextBuffer&&this.stream.mergeNextBuffer()?(this.nextParsePosition=this.stream.getEndPosition(),!0):(e.type?this.moovStartFound?this.nextParsePosition=this.stream.getEndPosition():this.nextParsePosition=this.stream.getPosition()+e.size:this.nextParsePosition=this.stream.getEndPosition(),!1))},g.prototype.hasIncompleteMdat=function(){return null!==this.parsingMdat},g.prototype.processIncompleteMdat=function(){var e;return e=this.parsingMdat,this.stream.seek(e.start+e.size,!1,this.discardMdatData)?(o.debug("ISOFile","Found 'mdat' end in buffered data"),this.parsingMdat=null,!0):(this.nextParsePosition=this.stream.findEndContiguousBuf(),!1)},g.prototype.restoreParsePosition=function(){return this.stream.seek(this.lastBoxStartPosition,!0,this.discardMdatData)},g.prototype.saveParsePosition=function(){this.lastBoxStartPosition=this.stream.getPosition()},g.prototype.updateUsedBytes=function(e,t){this.stream.addUsedBytes&&("mdat"===e.type?(this.stream.addUsedBytes(e.hdr_size),this.discardMdatData&&this.stream.addUsedBytes(e.size-e.hdr_size)):this.stream.addUsedBytes(e.size))},g.prototype.add=c.Box.prototype.add,g.prototype.addBox=c.Box.prototype.addBox,g.prototype.init=function(e){var t=e||{};this.add("ftyp").set("major_brand",t.brands&&t.brands[0]||"iso4").set("minor_version",0).set("compatible_brands",t.brands||["iso4"]);var r=this.add("moov");return r.add("mvhd").set("timescale",t.timescale||600).set("rate",t.rate||65536).set("creation_time",0).set("modification_time",0).set("duration",t.duration||0).set("volume",t.width?0:256).set("matrix",[65536,0,0,0,65536,0,0,0,1073741824]).set("next_track_id",1),r.add("mvex"),this},g.prototype.addTrack=function(e){this.moov||this.init(e);var t=e||{};t.width=t.width||320,t.height=t.height||320,t.id=t.id||this.moov.mvhd.next_track_id,t.type=t.type||"avc1";var r=this.moov.add("trak");this.moov.mvhd.next_track_id=t.id+1,r.add("tkhd").set("flags",c.TKHD_FLAG_ENABLED|c.TKHD_FLAG_IN_MOVIE|c.TKHD_FLAG_IN_PREVIEW).set("creation_time",0).set("modification_time",0).set("track_id",t.id).set("duration",t.duration||0).set("layer",t.layer||0).set("alternate_group",0).set("volume",1).set("matrix",[0,0,0,0,0,0,0,0,0]).set("width",t.width<<16).set("height",t.height<<16);var i=r.add("mdia");i.add("mdhd").set("creation_time",0).set("modification_time",0).set("timescale",t.timescale||1).set("duration",t.media_duration||0).set("language",t.language||"und"),i.add("hdlr").set("handler",t.hdlr||"vide").set("name",t.name||"Track created with MP4Box.js"),i.add("elng").set("extended_language",t.language||"fr-FR");var n=i.add("minf");if(void 0!==c[t.type+"SampleEntry"]){var s=new c[t.type+"SampleEntry"];s.data_reference_index=1;var o="";for(var l in c.sampleEntryCodes)for(var d=c.sampleEntryCodes[l],u=0;u<d.length;u++)if(d.indexOf(t.type)>-1){o=l;break}switch(o){case"Visual":if(n.add("vmhd").set("graphicsmode",0).set("opcolor",[0,0,0]),s.set("width",t.width).set("height",t.height).set("horizresolution",72<<16).set("vertresolution",72<<16).set("frame_count",1).set("compressorname",t.type+" Compressor").set("depth",24),t.avcDecoderConfigRecord){var h=new c.avcCBox;h.parse(new a(t.avcDecoderConfigRecord)),s.addBox(h)}else if(t.hevcDecoderConfigRecord){var f=new c.hvcCBox;f.parse(new a(t.hevcDecoderConfigRecord)),s.addBox(f)}break;case"Audio":n.add("smhd").set("balance",t.balance||0),s.set("channel_count",t.channel_count||2).set("samplesize",t.samplesize||16).set("samplerate",t.samplerate||65536);break;case"Hint":n.add("hmhd");break;case"Subtitle":if(n.add("sthd"),"stpp"===t.type)s.set("namespace",t.namespace||"nonamespace").set("schema_location",t.schema_location||"").set("auxiliary_mime_types",t.auxiliary_mime_types||"");break;default:n.add("nmhd")}t.description&&s.addBox(t.description),t.description_boxes&&t.description_boxes.forEach((function(e){s.addBox(e)})),n.add("dinf").add("dref").addEntry((new c["url Box"]).set("flags",1));var p=n.add("stbl");return p.add("stsd").addEntry(s),p.add("stts").set("sample_counts",[]).set("sample_deltas",[]),p.add("stsc").set("first_chunk",[]).set("samples_per_chunk",[]).set("sample_description_index",[]),p.add("stco").set("chunk_offsets",[]),p.add("stsz").set("sample_sizes",[]),this.moov.mvex.add("trex").set("track_id",t.id).set("default_sample_description_index",t.default_sample_description_index||1).set("default_sample_duration",t.default_sample_duration||0).set("default_sample_size",t.default_sample_size||0).set("default_sample_flags",t.default_sample_flags||0),this.buildTrakSampleLists(r),t.id}},c.Box.prototype.computeSize=function(e){var t=e||new l;t.endianness=l.BIG_ENDIAN,this.write(t)},g.prototype.addSample=function(e,t,r){var i=r||{},n={},s=this.getTrackById(e);if(null!==s){n.number=s.samples.length,n.track_id=s.tkhd.track_id,n.timescale=s.mdia.mdhd.timescale,n.description_index=i.sample_description_index?i.sample_description_index-1:0,n.description=s.mdia.minf.stbl.stsd.entries[n.description_index],n.data=t,n.size=t.byteLength,n.alreadyRead=n.size,n.duration=i.duration||1,n.cts=i.cts||0,n.dts=i.dts||0,n.is_sync=i.is_sync||!1,n.is_leading=i.is_leading||0,n.depends_on=i.depends_on||0,n.is_depended_on=i.is_depended_on||0,n.has_redundancy=i.has_redundancy||0,n.degradation_priority=i.degradation_priority||0,n.offset=0,n.subsamples=i.subsamples,s.samples.push(n),s.samples_size+=n.size,s.samples_duration+=n.duration,void 0===s.first_dts&&(s.first_dts=i.dts),this.processSamples();var o=this.createSingleSampleMoof(n);return this.addBox(o),o.computeSize(),o.trafs[0].truns[0].data_offset=o.size+8,this.add("mdat").data=new Uint8Array(t),n}},g.prototype.createSingleSampleMoof=function(e){var t=0;t=e.is_sync?1<<25:65536;var r=new c.moofBox;r.add("mfhd").set("sequence_number",this.nextMoofNumber),this.nextMoofNumber++;var i=r.add("traf"),n=this.getTrackById(e.track_id);return i.add("tfhd").set("track_id",e.track_id).set("flags",c.TFHD_FLAG_DEFAULT_BASE_IS_MOOF),i.add("tfdt").set("baseMediaDecodeTime",e.dts-(n.first_dts||0)),i.add("trun").set("flags",c.TRUN_FLAGS_DATA_OFFSET|c.TRUN_FLAGS_DURATION|c.TRUN_FLAGS_SIZE|c.TRUN_FLAGS_FLAGS|c.TRUN_FLAGS_CTS_OFFSET).set("data_offset",0).set("first_sample_flags",0).set("sample_count",1).set("sample_duration",[e.duration]).set("sample_size",[e.size]).set("sample_flags",[t]).set("sample_composition_time_offset",[e.cts-e.dts]),r},g.prototype.lastMoofIndex=0,g.prototype.samplesDataSize=0,g.prototype.resetTables=function(){var e,t,r,i,n,s;for(this.initial_duration=this.moov.mvhd.duration,this.moov.mvhd.duration=0,e=0;e<this.moov.traks.length;e++){(t=this.moov.traks[e]).tkhd.duration=0,t.mdia.mdhd.duration=0,(t.mdia.minf.stbl.stco||t.mdia.minf.stbl.co64).chunk_offsets=[],(r=t.mdia.minf.stbl.stsc).first_chunk=[],r.samples_per_chunk=[],r.sample_description_index=[],(t.mdia.minf.stbl.stsz||t.mdia.minf.stbl.stz2).sample_sizes=[],(i=t.mdia.minf.stbl.stts).sample_counts=[],i.sample_deltas=[],(n=t.mdia.minf.stbl.ctts)&&(n.sample_counts=[],n.sample_offsets=[]),s=t.mdia.minf.stbl.stss;var o=t.mdia.minf.stbl.boxes.indexOf(s);-1!=o&&(t.mdia.minf.stbl.boxes[o]=null)}},g.initSampleGroups=function(e,t,r,i,n){var s,o,a,l;function d(e,t,r){this.grouping_type=e,this.grouping_type_parameter=t,this.sbgp=r,this.last_sample_in_run=-1,this.entry_index=-1}for(t&&(t.sample_groups_info=[]),e.sample_groups_info||(e.sample_groups_info=[]),o=0;o<r.length;o++){for(l=r[o].grouping_type+"/"+r[o].grouping_type_parameter,a=new d(r[o].grouping_type,r[o].grouping_type_parameter,r[o]),t&&(t.sample_groups_info[l]=a),e.sample_groups_info[l]||(e.sample_groups_info[l]=a),s=0;s<i.length;s++)i[s].grouping_type===r[o].grouping_type&&(a.description=i[s],a.description.used=!0);if(n)for(s=0;s<n.length;s++)n[s].grouping_type===r[o].grouping_type&&(a.fragment_description=n[s],a.fragment_description.used=!0,a.is_fragment=!0)}if(t){if(n)for(o=0;o<n.length;o++)!n[o].used&&n[o].version>=2&&(l=n[o].grouping_type+"/0",(a=new d(n[o].grouping_type,0)).is_fragment=!0,t.sample_groups_info[l]||(t.sample_groups_info[l]=a))}else for(o=0;o<i.length;o++)!i[o].used&&i[o].version>=2&&(l=i[o].grouping_type+"/0",a=new d(i[o].grouping_type,0),e.sample_groups_info[l]||(e.sample_groups_info[l]=a))},g.setSampleGroupProperties=function(e,t,r,i){var n,s;for(n in t.sample_groups=[],i){var o;if(t.sample_groups[n]={},t.sample_groups[n].grouping_type=i[n].grouping_type,t.sample_groups[n].grouping_type_parameter=i[n].grouping_type_parameter,r>=i[n].last_sample_in_run&&(i[n].last_sample_in_run<0&&(i[n].last_sample_in_run=0),i[n].entry_index++,i[n].entry_index<=i[n].sbgp.entries.length-1&&(i[n].last_sample_in_run+=i[n].sbgp.entries[i[n].entry_index].sample_count)),i[n].entry_index<=i[n].sbgp.entries.length-1?t.sample_groups[n].group_description_index=i[n].sbgp.entries[i[n].entry_index].group_description_index:t.sample_groups[n].group_description_index=-1,0!==t.sample_groups[n].group_description_index)o=i[n].fragment_description?i[n].fragment_description:i[n].description,t.sample_groups[n].group_description_index>0?(s=t.sample_groups[n].group_description_index>65535?(t.sample_groups[n].group_description_index>>16)-1:t.sample_groups[n].group_description_index-1,o&&s>=0&&(t.sample_groups[n].description=o.entries[s])):o&&o.version>=2&&o.default_group_description_index>0&&(t.sample_groups[n].description=o.entries[o.default_group_description_index-1])}},g.process_sdtp=function(e,t,r){t&&(e?(t.is_leading=e.is_leading[r],t.depends_on=e.sample_depends_on[r],t.is_depended_on=e.sample_is_depended_on[r],t.has_redundancy=e.sample_has_redundancy[r]):(t.is_leading=0,t.depends_on=0,t.is_depended_on=0,t.has_redundancy=0))},g.prototype.buildSampleLists=function(){var e,t;for(e=0;e<this.moov.traks.length;e++)t=this.moov.traks[e],this.buildTrakSampleLists(t)},g.prototype.buildTrakSampleLists=function(e){var t,r,i,n,s,o,a,l,d,u,h,c,f,p,m,_,y,v,b,w,E,S,U,x;if(e.samples=[],e.samples_duration=0,e.samples_size=0,r=e.mdia.minf.stbl.stco||e.mdia.minf.stbl.co64,i=e.mdia.minf.stbl.stsc,n=e.mdia.minf.stbl.stsz||e.mdia.minf.stbl.stz2,s=e.mdia.minf.stbl.stts,o=e.mdia.minf.stbl.ctts,a=e.mdia.minf.stbl.stss,l=e.mdia.minf.stbl.stsd,d=e.mdia.minf.stbl.subs,c=e.mdia.minf.stbl.stdp,u=e.mdia.minf.stbl.sbgps,h=e.mdia.minf.stbl.sgpds,v=-1,b=-1,w=-1,E=-1,S=0,U=0,x=0,g.initSampleGroups(e,null,u,h),void 0!==n){for(t=0;t<n.sample_sizes.length;t++){var k={};k.number=t,k.track_id=e.tkhd.track_id,k.timescale=e.mdia.mdhd.timescale,k.alreadyRead=0,e.samples[t]=k,k.size=n.sample_sizes[t],e.samples_size+=k.size,0===t?(p=1,f=0,k.chunk_index=p,k.chunk_run_index=f,y=i.samples_per_chunk[f],_=0,m=f+1<i.first_chunk.length?i.first_chunk[f+1]-1:1/0):t<y?(k.chunk_index=p,k.chunk_run_index=f):(p++,k.chunk_index=p,_=0,p<=m||(m=++f+1<i.first_chunk.length?i.first_chunk[f+1]-1:1/0),k.chunk_run_index=f,y+=i.samples_per_chunk[f]),k.description_index=i.sample_description_index[k.chunk_run_index]-1,k.description=l.entries[k.description_index],k.offset=r.chunk_offsets[k.chunk_index-1]+_,_+=k.size,t>v&&(b++,v<0&&(v=0),v+=s.sample_counts[b]),t>0?(e.samples[t-1].duration=s.sample_deltas[b],e.samples_duration+=e.samples[t-1].duration,k.dts=e.samples[t-1].dts+e.samples[t-1].duration):k.dts=0,o?(t>=w&&(E++,w<0&&(w=0),w+=o.sample_counts[E]),k.cts=e.samples[t].dts+o.sample_offsets[E]):k.cts=k.dts,a?(t==a.sample_numbers[S]-1?(k.is_sync=!0,S++):(k.is_sync=!1,k.degradation_priority=0),d&&d.entries[U].sample_delta+x==t+1&&(k.subsamples=d.entries[U].subsamples,x+=d.entries[U].sample_delta,U++)):k.is_sync=!0,g.process_sdtp(e.mdia.minf.stbl.sdtp,k,k.number),k.degradation_priority=c?c.priority[t]:0,d&&d.entries[U].sample_delta+x==t&&(k.subsamples=d.entries[U].subsamples,x+=d.entries[U].sample_delta),(u.length>0||h.length>0)&&g.setSampleGroupProperties(e,k,t,e.sample_groups_info)}t>0&&(e.samples[t-1].duration=Math.max(e.mdia.mdhd.duration-e.samples[t-1].dts,0),e.samples_duration+=e.samples[t-1].duration)}},g.prototype.updateSampleLists=function(){var e,t,r,i,n,s,o,a,l,d,u,h,f,p,m;if(void 0!==this.moov)for(;this.lastMoofIndex<this.moofs.length;)if(l=this.moofs[this.lastMoofIndex],this.lastMoofIndex++,"moof"==l.type)for(d=l,e=0;e<d.trafs.length;e++){for(u=d.trafs[e],h=this.getTrackById(u.tfhd.track_id),f=this.getTrexById(u.tfhd.track_id),i=u.tfhd.flags&c.TFHD_FLAG_SAMPLE_DESC?u.tfhd.default_sample_description_index:f?f.default_sample_description_index:1,n=u.tfhd.flags&c.TFHD_FLAG_SAMPLE_DUR?u.tfhd.default_sample_duration:f?f.default_sample_duration:0,s=u.tfhd.flags&c.TFHD_FLAG_SAMPLE_SIZE?u.tfhd.default_sample_size:f?f.default_sample_size:0,o=u.tfhd.flags&c.TFHD_FLAG_SAMPLE_FLAGS?u.tfhd.default_sample_flags:f?f.default_sample_flags:0,u.sample_number=0,u.sbgps.length>0&&g.initSampleGroups(h,u,u.sbgps,h.mdia.minf.stbl.sgpds,u.sgpds),t=0;t<u.truns.length;t++){var _=u.truns[t];for(r=0;r<_.sample_count;r++){(p={}).moof_number=this.lastMoofIndex,p.number_in_traf=u.sample_number,u.sample_number++,p.number=h.samples.length,u.first_sample_index=h.samples.length,h.samples.push(p),p.track_id=h.tkhd.track_id,p.timescale=h.mdia.mdhd.timescale,p.description_index=i-1,p.description=h.mdia.minf.stbl.stsd.entries[p.description_index],p.size=s,_.flags&c.TRUN_FLAGS_SIZE&&(p.size=_.sample_size[r]),h.samples_size+=p.size,p.duration=n,_.flags&c.TRUN_FLAGS_DURATION&&(p.duration=_.sample_duration[r]),h.samples_duration+=p.duration,h.first_traf_merged||r>0?p.dts=h.samples[h.samples.length-2].dts+h.samples[h.samples.length-2].duration:(u.tfdt?p.dts=u.tfdt.baseMediaDecodeTime:p.dts=0,h.first_traf_merged=!0),p.cts=p.dts,_.flags&c.TRUN_FLAGS_CTS_OFFSET&&(p.cts=p.dts+_.sample_composition_time_offset[r]),m=o,_.flags&c.TRUN_FLAGS_FLAGS?m=_.sample_flags[r]:0===r&&_.flags&c.TRUN_FLAGS_FIRST_FLAG&&(m=_.first_sample_flags),p.is_sync=!(m>>16&1),p.is_leading=m>>26&3,p.depends_on=m>>24&3,p.is_depended_on=m>>22&3,p.has_redundancy=m>>20&3,p.degradation_priority=65535&m;var y=!!(u.tfhd.flags&c.TFHD_FLAG_BASE_DATA_OFFSET),v=!!(u.tfhd.flags&c.TFHD_FLAG_DEFAULT_BASE_IS_MOOF),b=!!(_.flags&c.TRUN_FLAGS_DATA_OFFSET),w=0;w=y?u.tfhd.base_data_offset:v||0===t?d.start:a,p.offset=0===t&&0===r?b?w+_.data_offset:w:a,a=p.offset+p.size,(u.sbgps.length>0||u.sgpds.length>0||h.mdia.minf.stbl.sbgps.length>0||h.mdia.minf.stbl.sgpds.length>0)&&g.setSampleGroupProperties(h,p,p.number_in_traf,u.sample_groups_info)}}if(u.subs){h.has_fragment_subsamples=!0;var E=u.first_sample_index;for(t=0;t<u.subs.entries.length;t++)E+=u.subs.entries[t].sample_delta,(p=h.samples[E-1]).subsamples=u.subs.entries[t].subsamples}}},g.prototype.getSample=function(e,t){var r,i=e.samples[t];if(!this.moov)return null;if(i.data){if(i.alreadyRead==i.size)return i}else i.data=new Uint8Array(i.size),i.alreadyRead=0,this.samplesDataSize+=i.size,o.debug("ISOFile","Allocating sample #"+t+" on track #"+e.tkhd.track_id+" of size "+i.size+" (total: "+this.samplesDataSize+")");for(;;){var n=this.stream.findPosition(!0,i.offset+i.alreadyRead,!1);if(!(n>-1))return null;var s=(r=this.stream.buffers[n]).byteLength-(i.offset+i.alreadyRead-r.fileStart);if(i.size-i.alreadyRead<=s)return o.debug("ISOFile","Getting sample #"+t+" data (alreadyRead: "+i.alreadyRead+" offset: "+(i.offset+i.alreadyRead-r.fileStart)+" read size: "+(i.size-i.alreadyRead)+" full size: "+i.size+")"),l.memcpy(i.data.buffer,i.alreadyRead,r,i.offset+i.alreadyRead-r.fileStart,i.size-i.alreadyRead),r.usedBytes+=i.size-i.alreadyRead,this.stream.logBufferLevel(),i.alreadyRead=i.size,i;if(0===s)return null;o.debug("ISOFile","Getting sample #"+t+" partial data (alreadyRead: "+i.alreadyRead+" offset: "+(i.offset+i.alreadyRead-r.fileStart)+" read size: "+s+" full size: "+i.size+")"),l.memcpy(i.data.buffer,i.alreadyRead,r,i.offset+i.alreadyRead-r.fileStart,s),i.alreadyRead+=s,r.usedBytes+=s,this.stream.logBufferLevel()}},g.prototype.releaseSample=function(e,t){var r=e.samples[t];return r.data?(this.samplesDataSize-=r.size,r.data=null,r.alreadyRead=0,r.size):0},g.prototype.getAllocatedSampleDataSize=function(){return this.samplesDataSize},g.prototype.getCodecs=function(){var e,t="";for(e=0;e<this.moov.traks.length;e++){e>0&&(t+=","),t+=this.moov.traks[e].mdia.minf.stbl.stsd.entries[0].getCodec()}return t},g.prototype.getTrexById=function(e){var t;if(!this.moov||!this.moov.mvex)return null;for(t=0;t<this.moov.mvex.trexs.length;t++){var r=this.moov.mvex.trexs[t];if(r.track_id==e)return r}return null},g.prototype.getTrackById=function(e){if(void 0===this.moov)return null;for(var t=0;t<this.moov.traks.length;t++){var r=this.moov.traks[t];if(r.tkhd.track_id==e)return r}return null},g.prototype.items=[],g.prototype.entity_groups=[],g.prototype.itemsDataSize=0,g.prototype.flattenItemInfo=function(){var e,t,r,i=this.items,n=this.entity_groups,s=this.meta;if(null!=s&&void 0!==s.hdlr&&void 0!==s.iinf){for(e=0;e<s.iinf.item_infos.length;e++)(r={}).id=s.iinf.item_infos[e].item_ID,i[r.id]=r,r.ref_to=[],r.name=s.iinf.item_infos[e].item_name,s.iinf.item_infos[e].protection_index>0&&(r.protection=s.ipro.protections[s.iinf.item_infos[e].protection_index-1]),s.iinf.item_infos[e].item_type?r.type=s.iinf.item_infos[e].item_type:r.type="mime",r.content_type=s.iinf.item_infos[e].content_type,r.content_encoding=s.iinf.item_infos[e].content_encoding;if(s.grpl)for(e=0;e<s.grpl.boxes.length;e++)entity_group={},entity_group.id=s.grpl.boxes[e].group_id,entity_group.entity_ids=s.grpl.boxes[e].entity_ids,entity_group.type=s.grpl.boxes[e].type,n[entity_group.id]=entity_group;if(s.iloc)for(e=0;e<s.iloc.items.length;e++){var a=s.iloc.items[e];switch(r=i[a.item_ID],0!==a.data_reference_index&&(o.warn("Item storage with reference to other files: not supported"),r.source=s.dinf.boxes[a.data_reference_index-1]),a.construction_method){case 0:break;case 1:case 2:o.warn("Item storage with construction_method : not supported")}for(r.extents=[],r.size=0,t=0;t<a.extents.length;t++)r.extents[t]={},r.extents[t].offset=a.extents[t].extent_offset+a.base_offset,r.extents[t].length=a.extents[t].extent_length,r.extents[t].alreadyRead=0,r.size+=r.extents[t].length}if(s.pitm&&(i[s.pitm.item_id].primary=!0),s.iref)for(e=0;e<s.iref.references.length;e++){var l=s.iref.references[e];for(t=0;t<l.references.length;t++)i[l.from_item_ID].ref_to.push({type:l.type,id:l.references[t]})}if(s.iprp)for(var d=0;d<s.iprp.ipmas.length;d++){var u=s.iprp.ipmas[d];for(e=0;e<u.associations.length;e++){var h=u.associations[e];if((r=i[h.id])||(r=n[h.id]),r)for(void 0===r.properties&&(r.properties={},r.properties.boxes=[]),t=0;t<h.props.length;t++){var c=h.props[t];if(c.property_index>0&&c.property_index-1<s.iprp.ipco.boxes.length){var f=s.iprp.ipco.boxes[c.property_index-1];r.properties[f.type]=f,r.properties.boxes.push(f)}}}}}},g.prototype.getItem=function(e){var t,r;if(!this.meta)return null;if(!(r=this.items[e]).data&&r.size)r.data=new Uint8Array(r.size),r.alreadyRead=0,this.itemsDataSize+=r.size,o.debug("ISOFile","Allocating item #"+e+" of size "+r.size+" (total: "+this.itemsDataSize+")");else if(r.alreadyRead===r.size)return r;for(var i=0;i<r.extents.length;i++){var n=r.extents[i];if(n.alreadyRead!==n.length){var s=this.stream.findPosition(!0,n.offset+n.alreadyRead,!1);if(!(s>-1))return null;var a=(t=this.stream.buffers[s]).byteLength-(n.offset+n.alreadyRead-t.fileStart);if(!(n.length-n.alreadyRead<=a))return o.debug("ISOFile","Getting item #"+e+" extent #"+i+" partial data (alreadyRead: "+n.alreadyRead+" offset: "+(n.offset+n.alreadyRead-t.fileStart)+" read size: "+a+" full extent size: "+n.length+" full item size: "+r.size+")"),l.memcpy(r.data.buffer,r.alreadyRead,t,n.offset+n.alreadyRead-t.fileStart,a),n.alreadyRead+=a,r.alreadyRead+=a,t.usedBytes+=a,this.stream.logBufferLevel(),null;o.debug("ISOFile","Getting item #"+e+" extent #"+i+" data (alreadyRead: "+n.alreadyRead+" offset: "+(n.offset+n.alreadyRead-t.fileStart)+" read size: "+(n.length-n.alreadyRead)+" full extent size: "+n.length+" full item size: "+r.size+")"),l.memcpy(r.data.buffer,r.alreadyRead,t,n.offset+n.alreadyRead-t.fileStart,n.length-n.alreadyRead),t.usedBytes+=n.length-n.alreadyRead,this.stream.logBufferLevel(),r.alreadyRead+=n.length-n.alreadyRead,n.alreadyRead=n.length}}return r.alreadyRead===r.size?r:null},g.prototype.releaseItem=function(e){var t=this.items[e];if(t.data){this.itemsDataSize-=t.size,t.data=null,t.alreadyRead=0;for(var r=0;r<t.extents.length;r++){t.extents[r].alreadyRead=0}return t.size}return 0},g.prototype.processItems=function(e){for(var t in this.items){var r=this.items[t];this.getItem(r.id),e&&!r.sent&&(e(r),r.sent=!0,r.data=null)}},g.prototype.hasItem=function(e){for(var t in this.items){var r=this.items[t];if(r.name===e)return r.id}return-1},g.prototype.getMetaHandler=function(){return this.meta?this.meta.hdlr.handler:null},g.prototype.getPrimaryItem=function(){return this.meta&&this.meta.pitm?this.getItem(this.meta.pitm.item_id):null},g.prototype.itemToFragmentedTrackFile=function(e){var t=e||{},r=null;if(null==(r=t.itemId?this.getItem(t.itemId):this.getPrimaryItem()))return null;var i=new g;i.discardMdatData=!1;var n={type:r.type,description_boxes:r.properties.boxes};r.properties.ispe&&(n.width=r.properties.ispe.image_width,n.height=r.properties.ispe.image_height);var s=i.addTrack(n);return s?(i.addSample(s,r.data),i):null},g.prototype.write=function(e){for(var t=0;t<this.boxes.length;t++)this.boxes[t].write(e)},g.prototype.createFragment=function(e,t,r){var i=this.getTrackById(e),n=this.getSample(i,t);if(null==n)return this.setNextSeekPositionFromSample(i.samples[t]),null;var s=r||new l;s.endianness=l.BIG_ENDIAN;var a=this.createSingleSampleMoof(n);a.write(s),a.trafs[0].truns[0].data_offset=a.size+8,o.debug("MP4Box","Adjusting data_offset with new value "+a.trafs[0].truns[0].data_offset),s.adjustUint32(a.trafs[0].truns[0].data_offset_position,a.trafs[0].truns[0].data_offset);var d=new c.mdatBox;return d.data=n.data,d.write(s),s},g.writeInitializationSegment=function(e,t,r,i){var n;o.debug("ISOFile","Generating initialization segment");var s=new l;s.endianness=l.BIG_ENDIAN,e.write(s);var a=t.add("mvex");for(r&&a.add("mehd").set("fragment_duration",r),n=0;n<t.traks.length;n++)a.add("trex").set("track_id",t.traks[n].tkhd.track_id).set("default_sample_description_index",1).set("default_sample_duration",i).set("default_sample_size",0).set("default_sample_flags",65536);return t.write(s),s.buffer},g.prototype.save=function(e){var t=new l;t.endianness=l.BIG_ENDIAN,this.write(t),t.save(e)},g.prototype.getBuffer=function(){var e=new l;return e.endianness=l.BIG_ENDIAN,this.write(e),e.buffer},g.prototype.initializeSegmentation=function(){var e,t,r,i;for(null===this.onSegment&&o.warn("MP4Box","No segmentation callback set!"),this.isFragmentationInitialized||(this.isFragmentationInitialized=!0,this.nextMoofNumber=0,this.resetTables()),t=[],e=0;e<this.fragmentedTracks.length;e++){var n=new c.moovBox;n.mvhd=this.moov.mvhd,n.boxes.push(n.mvhd),r=this.getTrackById(this.fragmentedTracks[e].id),n.boxes.push(r),n.traks.push(r),(i={}).id=r.tkhd.track_id,i.user=this.fragmentedTracks[e].user,i.buffer=g.writeInitializationSegment(this.ftyp,n,this.moov.mvex&&this.moov.mvex.mehd?this.moov.mvex.mehd.fragment_duration:void 0,this.moov.traks[e].samples.length>0?this.moov.traks[e].samples[0].duration:0),t.push(i)}return t},c.Box.prototype.printHeader=function(e){this.size+=8,this.size>d&&(this.size+=8),"uuid"===this.type&&(this.size+=16),e.log(e.indent+"size:"+this.size),e.log(e.indent+"type:"+this.type)},c.FullBox.prototype.printHeader=function(e){this.size+=4,c.Box.prototype.printHeader.call(this,e),e.log(e.indent+"version:"+this.version),e.log(e.indent+"flags:"+this.flags)},c.Box.prototype.print=function(e){this.printHeader(e)},c.ContainerBox.prototype.print=function(e){this.printHeader(e);for(var t=0;t<this.boxes.length;t++)if(this.boxes[t]){var r=e.indent;e.indent+=" ",this.boxes[t].print(e),e.indent=r}},g.prototype.print=function(e){e.indent="";for(var t=0;t<this.boxes.length;t++)this.boxes[t]&&this.boxes[t].print(e)},c.mvhdBox.prototype.print=function(e){c.FullBox.prototype.printHeader.call(this,e),e.log(e.indent+"creation_time: "+this.creation_time),e.log(e.indent+"modification_time: "+this.modification_time),e.log(e.indent+"timescale: "+this.timescale),e.log(e.indent+"duration: "+this.duration),e.log(e.indent+"rate: "+this.rate),e.log(e.indent+"volume: "+(this.volume>>8)),e.log(e.indent+"matrix: "+this.matrix.join(", ")),e.log(e.indent+"next_track_id: "+this.next_track_id)},c.tkhdBox.prototype.print=function(e){c.FullBox.prototype.printHeader.call(this,e),e.log(e.indent+"creation_time: "+this.creation_time),e.log(e.indent+"modification_time: "+this.modification_time),e.log(e.indent+"track_id: "+this.track_id),e.log(e.indent+"duration: "+this.duration),e.log(e.indent+"volume: "+(this.volume>>8)),e.log(e.indent+"matrix: "+this.matrix.join(", ")),e.log(e.indent+"layer: "+this.layer),e.log(e.indent+"alternate_group: "+this.alternate_group),e.log(e.indent+"width: "+this.width),e.log(e.indent+"height: "+this.height)};var y={createFile:function(e,t){var r=void 0===e||e,i=new g(t);return i.discardMdatData=!r,i}};t.createFile=y.createFile}));function Wr(e){return e.reduce(((e,t)=>256*e+t))}function jr(e){const t=[101,103,119,99],r=e.length-28,i=e.slice(r,r+t.length);return t.every(((e,t)=>e===i[t]))}Vr.Log,Vr.MP4BoxStream,Vr.DataStream,Vr.MultiBufferStream,Vr.MPEG4DescriptorParser,Vr.BoxParser,Vr.XMLSubtitlein4Parser,Vr.Textin4Parser,Vr.ISOFile,Vr.createFile;class Yr{constructor(){this.s=null,this.a=null,this.l=0,this.c=0,this.u=1/0,this.A=!1,this.d=!1,this.r=4194304,this.n=new Uint8Array([30,158,90,33,244,57,83,165,2,70,35,87,215,231,226,108]),this.t=this.n.slice().reverse()}destroy(){this.s=null,this.a=null,this.l=0,this.c=0,this.u=1/0,this.A=!1,this.d=!1,this.r=4194304,this.n=null,this.t=null}transport(e){if(!this.s&&this.l>50)return e;if(this.l++,this.d)return e;const t=new Uint8Array(e);if(this.A){if(!(this.c<this.u))return this.a&&this.s?(this.a.set(t,this.r),this.s.parse(null,this.r,t.byteLength),this.a.slice(this.r,this.r+t.byteLength)):(console.error("video_error_2"),this.d=!0,e);jr(t)&&this.c++}else{const r=function(e,t){const r=function(e,t){for(let r=0;r<e.byteLength-t.length;r++)for(let i=0;i<t.length&&e[r+i]===t[i];i++)if(i===t.length-1)return r;return null}(e,t);if(r){const t=Wr(e.slice(r+16,r+16+8));return[t,Wr(e.slice(r+24,r+24+8)),function(e){return e.map((e=>~e))}(e.slice(r+32,r+32+t))]}return null}(t,this.t);if(!r)return e;const i=function(e){try{if("object"!=typeof WebAssembly||"function"!=typeof WebAssembly.instantiate)throw null;{const e=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(!(e instanceof WebAssembly.Module&&new WebAssembly.Instance(e)instanceof WebAssembly.Instance))throw null}}catch(e){return new Error("video_error_4")}let t;try{t={env:{__handle_stack_overflow:()=>e(new Error("video_error_1")),memory:new WebAssembly.Memory({initial:256,maximum:256})}}}catch(e){return new Error("video_error_5")}return t}(e);if(i instanceof Error)return console.error(i.message),this.d=!0,e;this.A=!0,this.u=r[1],jr(t)&&this.c++,WebAssembly.instantiate(r[2],i).then((e=>{if("function"!=typeof(t=e.instance.exports).parse||"object"!=typeof t.memory)return this.d=!0,void console.error("video_error_3");var t;this.s=e.instance.exports,this.a=new Uint8Array(this.s.memory.buffer)})).catch((e=>{this.d=!0,console.error("video_error_6")}))}return e}}const qr=16,Kr=[214,144,233,254,204,225,61,183,22,182,20,194,40,251,44,5,43,103,154,118,42,190,4,195,170,68,19,38,73,134,6,153,156,66,80,244,145,239,152,122,51,84,11,67,237,207,172,98,228,179,28,169,201,8,232,149,128,223,148,250,117,143,63,166,71,7,167,252,243,115,23,186,131,89,60,25,230,133,79,168,104,107,129,178,113,100,218,139,248,235,15,75,112,86,157,53,30,36,14,94,99,88,209,162,37,34,124,59,1,33,120,135,212,0,70,87,159,211,39,82,76,54,2,231,160,196,200,158,234,191,138,210,64,199,56,181,163,247,242,206,249,97,21,161,224,174,93,164,155,52,26,85,173,147,50,48,245,140,177,227,29,246,226,46,130,102,202,96,192,41,35,171,13,83,78,111,213,219,55,69,222,253,142,47,3,255,106,114,109,108,91,81,141,27,175,146,187,221,188,127,17,217,92,65,31,16,90,216,10,193,49,136,165,205,123,189,45,116,208,18,184,229,180,176,137,105,151,74,12,150,119,126,101,185,241,9,197,110,198,132,24,240,125,236,58,220,77,32,121,238,95,62,215,203,57,72],Xr=[462357,472066609,943670861,1415275113,1886879365,2358483617,2830087869,3301692121,3773296373,4228057617,404694573,876298825,1347903077,1819507329,2291111581,2762715833,3234320085,3705924337,4177462797,337322537,808926789,1280531041,1752135293,2223739545,2695343797,3166948049,3638552301,4110090761,269950501,741554753,1213159005,1684763257];function Zr(e){const t=[];for(let r=0,i=e.length;r<i;r+=2)t.push(parseInt(e.substr(r,2),16));return t}function Jr(e){return e.map((e=>1===(e=e.toString(16)).length?"0"+e:e)).join("")}function Qr(e){const t=[];for(let r=0,i=e.length;r<i;r++){const i=e.codePointAt(r);if(i<=127)t.push(i);else if(i<=2047)t.push(192|i>>>6),t.push(128|63&i);else if(i<=55295||i>=57344&&i<=65535)t.push(224|i>>>12),t.push(128|i>>>6&63),t.push(128|63&i);else{if(!(i>=65536&&i<=1114111))throw t.push(i),new Error("input is not supported");r++,t.push(240|i>>>18&28),t.push(128|i>>>12&63),t.push(128|i>>>6&63),t.push(128|63&i)}}return t}function ei(e){const t=[];for(let r=0,i=e.length;r<i;r++)e[r]>=240&&e[r]<=247?(t.push(String.fromCodePoint(((7&e[r])<<18)+((63&e[r+1])<<12)+((63&e[r+2])<<6)+(63&e[r+3]))),r+=3):e[r]>=224&&e[r]<=239?(t.push(String.fromCodePoint(((15&e[r])<<12)+((63&e[r+1])<<6)+(63&e[r+2]))),r+=2):e[r]>=192&&e[r]<=223?(t.push(String.fromCodePoint(((31&e[r])<<6)+(63&e[r+1]))),r++):t.push(String.fromCodePoint(e[r]));return t.join("")}function ti(e,t){const r=31&t;return e<<r|e>>>32-r}function ri(e){return(255&Kr[e>>>24&255])<<24|(255&Kr[e>>>16&255])<<16|(255&Kr[e>>>8&255])<<8|255&Kr[255&e]}function ii(e){return e^ti(e,2)^ti(e,10)^ti(e,18)^ti(e,24)}function ni(e){return e^ti(e,13)^ti(e,23)}function si(e,t,r){const i=new Array(4),n=new Array(4);for(let t=0;t<4;t++)n[0]=255&e[4*t],n[1]=255&e[4*t+1],n[2]=255&e[4*t+2],n[3]=255&e[4*t+3],i[t]=n[0]<<24|n[1]<<16|n[2]<<8|n[3];for(let e,t=0;t<32;t+=4)e=i[1]^i[2]^i[3]^r[t+0],i[0]^=ii(ri(e)),e=i[2]^i[3]^i[0]^r[t+1],i[1]^=ii(ri(e)),e=i[3]^i[0]^i[1]^r[t+2],i[2]^=ii(ri(e)),e=i[0]^i[1]^i[2]^r[t+3],i[3]^=ii(ri(e));for(let e=0;e<16;e+=4)t[e]=i[3-e/4]>>>24&255,t[e+1]=i[3-e/4]>>>16&255,t[e+2]=i[3-e/4]>>>8&255,t[e+3]=255&i[3-e/4]}function oi(e,t,r){const i=new Array(4),n=new Array(4);for(let t=0;t<4;t++)n[0]=255&e[0+4*t],n[1]=255&e[1+4*t],n[2]=255&e[2+4*t],n[3]=255&e[3+4*t],i[t]=n[0]<<24|n[1]<<16|n[2]<<8|n[3];i[0]^=2746333894,i[1]^=1453994832,i[2]^=1736282519,i[3]^=2993693404;for(let e,r=0;r<32;r+=4)e=i[1]^i[2]^i[3]^Xr[r+0],t[r+0]=i[0]^=ni(ri(e)),e=i[2]^i[3]^i[0]^Xr[r+1],t[r+1]=i[1]^=ni(ri(e)),e=i[3]^i[0]^i[1]^Xr[r+2],t[r+2]=i[2]^=ni(ri(e)),e=i[0]^i[1]^i[2]^Xr[r+3],t[r+3]=i[3]^=ni(ri(e));if(0===r)for(let e,r=0;r<16;r++)e=t[r],t[r]=t[31-r],t[31-r]=e}function ai(e,t,r){let{padding:i="pkcs#7",mode:n,iv:s=[],output:o="string"}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if("cbc"===n&&("string"==typeof s&&(s=Zr(s)),16!==s.length))throw new Error("iv is invalid");if("string"==typeof t&&(t=Zr(t)),16!==t.length)throw new Error("key is invalid");if(e="string"==typeof e?0!==r?Qr(e):Zr(e):[...e],("pkcs#5"===i||"pkcs#7"===i)&&0!==r){const t=qr-e.length%qr;for(let r=0;r<t;r++)e.push(t)}const a=new Array(32);oi(t,a,r);const l=[];let d=s,u=e.length,h=0;for(;u>=qr;){const t=e.slice(h,h+16),i=new Array(16);if("cbc"===n)for(let e=0;e<qr;e++)0!==r&&(t[e]^=d[e]);si(t,i,a);for(let e=0;e<qr;e++)"cbc"===n&&0===r&&(i[e]^=d[e]),l[h+e]=i[e];"cbc"===n&&(d=0!==r?i:t),u-=qr,h+=qr}if(("pkcs#5"===i||"pkcs#7"===i)&&0===r){const e=l.length,t=l[e-1];for(let r=1;r<=t;r++)if(l[e-r]!==t)throw new Error("padding is invalid");l.splice(e-t,t)}return"array"!==o?0!==r?Jr(l):ei(l):l}function li(e){return e[3]|e[2]<<8|e[1]<<16|e[0]<<24}function di(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const i=e.byteLength;let n=5;for(;n<i;){let s=li(e.slice(n,n+4));if(s>i)break;let o=e[n+4],a=!1;if(r?(o=o>>>1&63,a=[0,1,2,3,4,5,6,7,8,9,16,17,18,19,20,21].includes(o)):(o&=31,a=1===o||5===o),a){const r=ai(e.slice(n+4+2,n+4+s),t,0,{padding:"none",output:"array"});e.set(r,n+4+2)}n=n+4+s}return e}const ui={init:0,findFirstStartCode:1,findSecondStartCode:2};class hi extends class{on(e,t,r){const i=this.e||(this.e={});return(i[e]||(i[e]=[])).push({fn:t,ctx:r}),this}once(e,t,r){const i=this;function n(){i.off(e,n);for(var s=arguments.length,o=new Array(s),a=0;a<s;a++)o[a]=arguments[a];t.apply(r,o)}return n._=t,this.on(e,n,r)}emit(e){const t=((this.e||(this.e={}))[e]||[]).slice();for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];for(let e=0;e<t.length;e+=1)t[e].fn.apply(t[e].ctx,i);return this}off(e,t){const r=this.e||(this.e={});if(!e)return Object.keys(r).forEach((e=>{delete r[e]})),void delete this.e;const i=r[e],n=[];if(i&&t)for(let e=0,r=i.length;e<r;e+=1)i[e].fn!==t&&i[e].fn._!==t&&n.push(i[e]);return n.length?r[e]=n:delete r[e],this}}{constructor(e){super(),this.player=e,this.isDestroyed=!1,this.reset()}destroy(){this.isDestroyed=!1,this.off(),this.reset()}reset(){this.stats=ui.init,this.tempBuffer=new Uint8Array(0),this.parsedOffset=0,this.versionLayer=0}dispatch(e,t){let r=new Uint8Array(this.tempBuffer.length+e.length);for(r.set(this.tempBuffer,0),r.set(e,this.tempBuffer.length),this.tempBuffer=r;!this.isDestroyed;){if(this.state==ui.Init){let e=!1;for(;this.tempBuffer.length-this.parsedOffset>=2&&!this.isDestroyed;)if(255==this.tempBuffer[this.parsedOffset]){if(!(!1&this.tempBuffer[this.parsedOffset+1])){this.versionLayer=this.tempBuffer[this.parsedOffset+1],this.state=ui.findFirstStartCode,this.fisrtStartCodeOffset=this.parsedOffset,this.parsedOffset+=2,e=!0;break}this.parsedOffset++}else this.parsedOffset++;if(e)continue;break}if(this.state==ui.findFirstStartCode){let e=!1;for(;this.tempBuffer.length-this.parsedOffset>=2&&!this.isDestroyed;)if(255==this.tempBuffer[this.parsedOffset]){if(this.tempBuffer[this.parsedOffset+1]==this.versionLayer){this.state=ui.findSecondStartCode,this.secondStartCodeOffset=this.parsedOffset,this.parsedOffset+=2,e=!0;break}this.parsedOffset++}else this.parsedOffset++;if(e)continue;break}if(this.state==ui.findSecondStartCode){let e=this.tempBuffer.slice(this.fisrtStartCodeOffset,this.secondStartCodeOffset);this.emit("data",e,t),this.tempBuffer=this.tempBuffer.slice(this.secondStartCodeOffset),this.fisrtStartCodeOffset=0,this.parsedOffset=2,this.state=ui.findFirstStartCode}}}}function ci(e,t,r){for(let i=2;i<e.length;++i){const n=i-2,s=t[n%t.length],o=r[n%r.length];e[i]=e[i]^s^o}return e}function fi(e){return e[3]|e[2]<<8|e[1]<<16|e[0]<<24}function pi(e,t,r){let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const n=e.byteLength;let s=5;for(;s<n;){let o=fi(e.slice(s,s+4));if(o>n)break;let a=e[s+4],l=!1;if(i?(a=a>>>1&63,l=[0,1,2,3,4,5,6,7,8,9,16,17,18,19,20,21].includes(a)):(a&=31,l=1===a||5===a),l){const i=ci(e.slice(s+4,s+4+o),t,r);e.set(i,s+4)}s=s+4+o}return e}Date.now||(Date.now=function(){return(new Date).getTime()});const mi=[];mi.push(r(),t()),Promise.all(mi).then((e=>{const t=e[0];!function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=[],n=[],s={},o=new AbortController,a=null,l=null,d=null,u=null,v=null,b=null,S=!1,Ge=!1,Ye=!!kt(r),Ke=!1,Xe=null,ot=null,ft=null,Tt=[],Ct=null,Bt=null,Ft=0,It=0,Lt=null,Rt=null,jt=0,Yt=0,qt=!1,Qt=!1,lr=!1,dr=null,ur=null,hr=null,cr=!1,fr=()=>{const e=Ut();return{debug:e.debug,debugLevel:e.debugLevel,debugUuid:e.debugUuid,useOffscreen:e.useOffscreen,useWCS:e.useWCS,useMSE:e.useMSE,videoBuffer:e.videoBuffer,videoBufferDelay:e.videoBufferDelay,openWebglAlignment:e.openWebglAlignment,playType:e.playType,hasAudio:e.hasAudio,hasVideo:e.hasVideo,playbackRate:1,playbackForwardMaxRateDecodeIFrame:e.playbackForwardMaxRateDecodeIFrame,playbackIsCacheBeforeDecodeForFpsRender:e.playbackConfig.isCacheBeforeDecodeForFpsRender,sampleRate:0,networkDelay:e.networkDelay,visibility:!0,useSIMD:e.useSIMD,isRecording:!1,recordType:e.recordType,isNakedFlow:e.isNakedFlow,checkFirstIFrame:e.checkFirstIFrame,audioBufferSize:1024,isM7sCrypto:e.isM7sCrypto,m7sCryptoAudio:e.m7sCryptoAudio,cryptoKey:e.cryptoKey,cryptoIV:e.cryptoIV,isSm4Crypto:e.isSm4Crypto,sm4CryptoKey:e.sm4CryptoKey,isXorCrypto:e.isXorCrypto,isHls265:!1,isFlv:e.isFlv,isFmp4:e.isFmp4,isMpeg4:e.isMpeg4,isFmp4Private:e.isFmp4Private,isEmitSEI:e.isEmitSEI,isRecordTypeFlv:!1,isWasmMp4:!1,isChrome:!1,isDropSameTimestampGop:e.isDropSameTimestampGop,mseDecodeAudio:e.mseDecodeAudio,nakedFlowH265DemuxUseNew:e.nakedFlowH265DemuxUseNew}};"VideoEncoder"in self&&(s={hasInit:!1,isEmitInfo:!1,offscreenCanvas:null,offscreenCanvasCtx:null,decoder:new VideoDecoder({output:function(e){if(s.isEmitInfo||(yr.debug.log("worker","Webcodecs Video Decoder initSize"),postMessage({cmd:x,w:e.codedWidth,h:e.codedHeight}),s.isEmitInfo=!0,s.offscreenCanvas=new OffscreenCanvas(e.codedWidth,e.codedHeight),s.offscreenCanvasCtx=s.offscreenCanvas.getContext("2d")),yt(e.createImageBitmap))e.createImageBitmap().then((t=>{s.offscreenCanvasCtx.drawImage(t,0,0,e.codedWidth,e.codedHeight);let r=s.offscreenCanvas.transferToImageBitmap();postMessage({cmd:k,buffer:r,delay:yr.delay,ts:0},[r]),wt(e)}));else{s.offscreenCanvasCtx.drawImage(e,0,0,e.codedWidth,e.codedHeight);let t=s.offscreenCanvas.transferToImageBitmap();postMessage({cmd:k,buffer:t,delay:yr.delay,ts:0},[t]),wt(e)}},error:function(e){yr.debug.error("worker","VideoDecoder error",e)}}),decode:function(e,t,r){const i=e[0]>>4==1;if(s.hasInit){const r=new EncodedVideoChunk({data:e.slice(5),timestamp:t,type:i?We:je});s.decoder.decode(r)}else if(i&&0===e[1]){const t=15&e[0];postMessage({cmd:P,code:t});const r=mt(e.slice(5));yr._opt.recordType===y&&postMessage({cmd:D,buffer:e,codecId:t},[e.buffer]),s.decoder.configure(r),s.hasInit=!0}},reset(){s.hasInit=!1,s.isEmitInfo=!1,s.offscreenCanvas=null,s.offscreenCanvasCtx=null}});let pr=function(){if(cr=!0,yr.fetchStatus!==Qe||At(yr._opt.isChrome)){if(o)try{o.abort(),o=null}catch(e){yr.debug.log("worker","abort catch",e)}}else o=null,yr.debug.log("worker",`abort() and not abortController.abort() _status is ${yr.fetchStatus} and _isChrome is ${yr._opt.isChrome}`)},mr={init(){mr.lastBuf=null,mr.vps=null,mr.sps=null,mr.pps=null,mr.streamType=null,mr.localDts=0,mr.isSendSeqHeader=!1},destroy(){mr.lastBuf=null,mr.vps=null,mr.sps=null,mr.pps=null,mr.streamType=null,mr.localDts=0,mr.isSendSeqHeader=!1},dispatch(e){const t=new Uint8Array(e);mr.extractNALu$2(t)},getNaluDts(){let e=mr.localDts;return mr.localDts=mr.localDts+40,e},getNaluAudioDts(){const e=yr._opt.sampleRate,t=yr._opt.audioBufferSize;return mr.localDts+parseInt(t/e*1e3)},extractNALu(e){let t,r,i=0,n=e.byteLength,s=0,o=[];for(;i<n;)switch(t=e[i++],s){case 0:0===t&&(s=1);break;case 1:s=0===t?2:0;break;case 2:case 3:0===t?s=3:1===t&&i<n?(r&&o.push(e.subarray(r,i-s-1)),r=i,s=0):s=0}return r&&o.push(e.subarray(r,n)),o},extractNALu$2(e){let t=null;if(!e||e.byteLength<1)return;mr.lastBuf?(t=new Uint8Array(e.byteLength+mr.lastBuf.length),t.set(mr.lastBuf),t.set(new Uint8Array(e),mr.lastBuf.length)):t=new Uint8Array(e);let r=0,i=-1,n=-2;const s=new Array;for(let e=0;e<t.length;e+=2){const r=t[e],o=t[e+1];0==i&&0==r&&0==o?s.push(e-1):1==o&&0==r&&0==i&&0==n&&s.push(e-2),n=r,i=o}if(s.length>1)for(let e=0;e<s.length-1;++e){const i=t.subarray(s[e],s[e+1]+1);mr.handleNALu(i),r=s[e+1]}else r=s[0];if(0!=r&&r<t.length)mr.lastBuf=t.subarray(r);else{mr.lastBuf||(mr.lastBuf=t);const r=new Uint8Array(mr.lastBuf.length+e.byteLength);r.set(mr.lastBuf),r.set(new Uint8Array(e),mr.lastBuf.length),mr.lastBuf=r}},handleNALu(e){e.byteLength<=4?yr.debug.warn("worker",`handleNALu nalu byteLength is ${e.byteLength} <= 4`):(e=e.slice(4),mr.handleVideoNalu(e))},handleVideoNalu(e){if(mr.streamType||(mr.streamType=vt(e),dr=mr.streamType===Te),mr.streamType===Ae){const t=mr.handleAddNaluStartCode(e),r=mr.extractNALu(t);if(0===r.length)return void yr.debug.warn("worker","handleVideoNalu","h264 naluList.length === 0");const i=[];if(r.forEach((e=>{const t=$t(e);t===Ie||t===De?mr.handleVideoH264Nalu(e):Ht(t)&&i.push(e)})),1===i.length)mr.handleVideoH264Nalu(i[0]);else if(Wt(i)){const e=$t(i[0]),t=Vt(e);mr.handleVideoH264NaluList(i,t,e)}else i.forEach((e=>{mr.handleVideoH264Nalu(e)}))}else if(mr.streamType===Te)if(yr._opt.nakedFlowH265DemuxUseNew){const t=mr.handleAddNaluStartCode(e),r=mr.extractNALu(t);if(0===r.length)return void yr.debug.warn("worker","handleVideoNalu","h265 naluList.length === 0");const i=[];if(r.forEach((e=>{const t=ir(e);t===$e||t===Ne||t===Oe?mr.handleVideoH265Nalu(e):sr(t)&&i.push(e)})),1===i.length)mr.handleVideoH265Nalu(i[0]);else if(ar(i)){const e=ir(i[0]),t=or(e);mr.handleVideoH265NaluList(i,t,e)}else i.forEach((e=>{this.handleVideoH265Nalu(e)}))}else ir(e)===$e?mr.extractH265PPS(e):mr.handleVideoH265Nalu(e)},extractH264PPS(e){const t=mr.handleAddNaluStartCode(e);mr.extractNALu(t).forEach((e=>{Gt($t(e))?mr.extractH264SEI(e):mr.handleVideoH264Nalu(e)}))},extractH265PPS(e){const t=mr.handleAddNaluStartCode(e);mr.extractNALu(t).forEach((e=>{nr(ir(e))?mr.extractH265SEI(e):mr.handleVideoH265Nalu(e)}))},extractH264SEI(e){const t=mr.handleAddNaluStartCode(e);mr.extractNALu(t).forEach((e=>{mr.handleVideoH264Nalu(e)}))},extractH265SEI(e){const t=mr.handleAddNaluStartCode(e);mr.extractNALu(t).forEach((e=>{mr.handleVideoH265Nalu(e)}))},handleAddNaluStartCode(e){const t=[0,0,0,1],r=new Uint8Array(e.length+t.length);return r.set(t),r.set(e,t.length),r},handleVideoH264Nalu(e){const t=$t(e);switch(t){case De:mr.sps=e;break;case Ie:mr.pps=e}if(mr.isSendSeqHeader){if(mr.sps&&mr.pps){const e=Mt({sps:mr.sps,pps:mr.pps}),t=mr.getNaluDts();yr.decode(e,{type:ee,ts:t,isIFrame:!0,cts:0}),mr.sps=null,mr.pps=null}if(Ht(t)){const r=Vt(t),i=mr.getNaluDts(),n=Ot(e,r);mr.doDecode(n,{type:ee,ts:i,isIFrame:r,cts:0})}else yr.debug.warn("work",`handleVideoH264Nalu Avc Seq Head is ${t}`)}else if(mr.sps&&mr.pps){mr.isSendSeqHeader=!0;const e=Mt({sps:mr.sps,pps:mr.pps});yr.decode(e,{type:ee,ts:0,isIFrame:!0,cts:0}),mr.sps=null,mr.pps=null}},handleVideoH264NaluList(e,t,r){if(mr.isSendSeqHeader){const i=mr.getNaluDts(),n=Nt(e.reduce(((e,t)=>{const r=Xt(e),i=Xt(t),n=new Uint8Array(r.byteLength+i.byteLength);return n.set(r,0),n.set(i,r.byteLength),n})),t);mr.doDecode(n,{type:ee,ts:i,isIFrame:t,cts:0}),yr.debug.log("worker",`handleVideoH264NaluList list size is ${e.length} package length is ${n.byteLength} isIFrame is ${t},nalu type is ${r}, dts is ${i}`)}else yr.debug.warn("worker","handleVideoH264NaluList isSendSeqHeader is false")},handleVideoH265Nalu(e){const t=ir(e);switch(t){case Oe:mr.vps=e;break;case Ne:mr.sps=e;break;case $e:mr.pps=e}if(mr.isSendSeqHeader){if(mr.vps&&mr.sps&&mr.pps){const e=er({vps:mr.vps,sps:mr.sps,pps:mr.pps}),t=mr.getNaluDts();yr.decode(e,{type:ee,ts:t,isIFrame:!0,cts:0}),mr.vps=null,mr.sps=null,mr.pps=null}if(sr(t)){const r=or(t),i=mr.getNaluDts(),n=tr(e,r);mr.doDecode(n,{type:ee,ts:i,isIFrame:r,cts:0})}else yr.debug.warn("work",`handleVideoH265Nalu HevcSeqHead is ${t}`)}else if(mr.vps&&mr.sps&&mr.pps){mr.isSendSeqHeader=!0;const e=er({vps:mr.vps,sps:mr.sps,pps:mr.pps});yr.decode(e,{type:ee,ts:0,isIFrame:!0,cts:0}),mr.vps=null,mr.sps=null,mr.pps=null}},handleVideoH265NaluList(e,t,r){if(mr.isSendSeqHeader){const i=mr.getNaluDts(),n=rr(e.reduce(((e,t)=>{const r=Xt(e),i=Xt(t),n=new Uint8Array(r.byteLength+i.byteLength);return n.set(r,0),n.set(i,r.byteLength),n})),t);mr.doDecode(n,{type:ee,ts:i,isIFrame:t,cts:0}),yr.debug.log("worker",`handleVideoH265NaluList list size is ${e.length} package length is ${n.byteLength} isIFrame is ${t},nalu type is ${r}, dts is ${i}`)}else yr.debug.warn("worker","handleVideoH265NaluList isSendSeqHeader is false")},doDecode(e,t){yr.calcNetworkDelay(t.ts),t.isIFrame&&yr.calcIframeIntervalTimestamp(t.ts),postMessage({cmd:z,type:_e,value:e.byteLength}),postMessage({cmd:z,type:ge,value:t.ts}),yr.decode(e,t)}},_r={LOG_NAME:"worker fmp4Demuxer",mp4Box:Vr.createFile(),offset:0,videoTrackId:null,audioTrackId:null,isHevc:!1,listenMp4Box(){_r.mp4Box.onReady=_r.onReady,_r.mp4Box.onError=_r.onError,_r.mp4Box.onSamples=_r.onSamples},initTransportDescarmber(){_r.transportDescarmber=new Yr},_getSeqHeader(e){const t=_r.mp4Box.getTrackById(e.id);for(const e of t.mdia.minf.stbl.stsd.entries)if(e.avcC||e.hvcC){const t=new Vr.DataStream(void 0,0,Vr.DataStream.BIG_ENDIAN);let r=[];e.avcC?(e.avcC.write(t),r=[23,0,0,0,0]):(_r.isHevc=!0,dr=!0,e.hvcC.write(t),r=[28,0,0,0,0]);const i=new Uint8Array(t.buffer,8),n=new Uint8Array(r.length+i.length);return n.set(r,0),n.set(i,r.length),n}return null},onReady(e){yr.debug.log(_r.LOG_NAME,"onReady()",e);const t=e.videoTracks[0],r=e.audioTracks[0];if(t){_r.videoTrackId=t.id;const e=_r._getSeqHeader(t);e&&(yr.debug.log(_r.LOG_NAME,"seqHeader"),yr.decodeVideo(e,0,!0,0)),_r.mp4Box.setExtractionOptions(t.id)}if(r&&yr._opt.hasAudio){_r.audioTrackId=r.id;const e=r.audio||{},t=ut.indexOf(e.sample_rate),i=r.codec.replace("mp4a.40.","");_r.mp4Box.setExtractionOptions(r.id);const n=at({profile:parseInt(i,10),sampleRate:t,channel:e.channel_count});yr.debug.log(_r.LOG_NAME,"aacADTSHeader"),yr.decodeAudio(n,0)}_r.mp4Box.start()},onError(e){yr.debug.error(_r.LOG_NAME,"mp4Box onError",e)},onSamples(e,t,r){if(e===_r.videoTrackId)for(const e of r){const t=e.data,r=e.is_sync,i=1e3*e.cts/e.timescale;e.duration,e.timescale,r&&yr.calcIframeIntervalTimestamp(i);let n=null;n=_r.isHevc?rr(t,r):Nt(t,r),postMessage({cmd:z,type:_e,value:n.byteLength}),postMessage({cmd:z,type:ge,value:i}),yr.decode(n,{type:ee,ts:i,isIFrame:r,cts:0})}else if(e===_r.audioTrackId){if(yr._opt.hasAudio)for(const e of r){const t=e.data,r=1e3*e.cts/e.timescale;e.duration,e.timescale;const i=new Uint8Array(t.byteLength+2);i.set([175,1],0),i.set(t,2),postMessage({cmd:z,type:me,value:i.byteLength}),yr.decode(i,{type:Q,ts:r,isIFrame:!1,cts:0})}}else yr.debug.warn(_r.LOG_NAME,"onSamples() trackId error",e)},dispatch(e){let t=e;"string"!=typeof e?"object"==typeof e?(_r.transportDescarmber&&(t=_r.transportDescarmber.transport(t)),t.buffer.fileStart=_r.offset,_r.offset+=t.byteLength,_r.mp4Box.appendBuffer(t.buffer)):yr.debug.warn(_r.LOG_NAME,"dispatch()","data is not object",e):yr.debug.warn(_r.LOG_NAME,"dispatch()","data is string",e)},destroy(){_r.mp4Box&&(_r.mp4Box.flush(),_r.mp4Box=null),_r.transportDescarmber&&(_r.transportDescarmber.destroy(),_r.transportDescarmber=null),_r.offset=0,_r.videoTrackId=null,_r.audioTrackId=null,_r.isHevc=!1}},gr={LOG_NAME:"worker mpeg4Demuxer",lastBuffer:new Uint8Array(0),parsedOffset:0,firstStartCodeOffset:0,secondStartCodeOffset:0,state:"init",hasInitVideoCodec:!1,localDts:0,dispatch(e){const t=new Uint8Array(e);gr.extractNALu(t)},destroy(){gr.lastBuffer=new Uint8Array(0),gr.parsedOffset=0,gr.firstStartCodeOffset=0,gr.secondStartCodeOffset=0,gr.state="init",gr.hasInitVideoCodec=!1,gr.localDts=0},extractNALu(e){if(!e||e.byteLength<1)return void yr.debug.warn(gr.LOG_NAME,"extractNALu() buffer error",e);const t=new Uint8Array(gr.lastBuffer.length+e.length);for(t.set(gr.lastBuffer,0),t.set(new Uint8Array(e),gr.lastBuffer.length),gr.lastBuffer=t;;){if("init"===gr.state){let e=!1;for(;gr.lastBuffer.length-gr.parsedOffset>=4;)if(0===gr.lastBuffer[gr.parsedOffset])if(0===gr.lastBuffer[gr.parsedOffset+1])if(1===gr.lastBuffer[gr.parsedOffset+2]){if(182===gr.lastBuffer[gr.parsedOffset+3]){gr.state="findFirstStartCode",gr.firstStartCodeOffset=gr.parsedOffset,gr.parsedOffset+=4,e=!0;break}gr.parsedOffset++}else gr.parsedOffset++;else gr.parsedOffset++;else gr.parsedOffset++;if(e)continue;break}if("findFirstStartCode"===gr.state){let e=!1;for(;gr.lastBuffer.length-gr.parsedOffset>=4;)if(0===gr.lastBuffer[gr.parsedOffset])if(0===gr.lastBuffer[gr.parsedOffset+1])if(1===gr.lastBuffer[gr.parsedOffset+2]){if(182===gr.lastBuffer[gr.parsedOffset+3]){gr.state="findSecondStartCode",gr.secondStartCodeOffset=gr.parsedOffset,gr.parsedOffset+=4,e=!0;break}gr.parsedOffset++}else gr.parsedOffset++;else gr.parsedOffset++;else gr.parsedOffset++;if(e)continue;break}if("findSecondStartCode"===gr.state){if(!(gr.lastBuffer.length-gr.parsedOffset>0))break;{let e,t,r=192&gr.lastBuffer[gr.parsedOffset];e=0==r?gr.secondStartCodeOffset-14:gr.secondStartCodeOffset;let i=0==(192&gr.lastBuffer[gr.firstStartCodeOffset+4]);if(i){if(gr.firstStartCodeOffset-14<0)return void yr.debug.warn(gr.LOG_NAME,"firstStartCodeOffset -14 is",gr.firstStartCodeOffset-14);gr.hasInitVideoCodec||(gr.hasInitVideoCodec=!0,yr.debug.log(gr.LOG_NAME,"setCodec"),br.setCodec(ke,"")),t=gr.lastBuffer.subarray(gr.firstStartCodeOffset-14,e)}else t=gr.lastBuffer.subarray(gr.firstStartCodeOffset,e);let n=gr.getNaluDts();gr.hasInitVideoCodec?(postMessage({cmd:z,type:_e,value:t.byteLength}),postMessage({cmd:z,type:ge,value:n}),br.decode(t,i?1:0,n)):yr.debug.warn(gr.LOG_NAME,"has not init video codec"),gr.lastBuffer=gr.lastBuffer.subarray(e),gr.firstStartCodeOffset=0==r?14:0,gr.parsedOffset=gr.firstStartCodeOffset+4,gr.state="findFirstStartCode"}}}},getNaluDts(){let e=gr.localDts;return gr.localDts=gr.localDts+40,e}},yr={isPlayer:!0,isPlayback:!1,dropping:!1,isPushDropping:!1,isWorkerFetch:!1,isDestroyed:!1,fetchStatus:Je,_opt:fr(),mp3Demuxer:null,startStreamRateAndStatsInterval:function(){yr.stopStreamRateAndStatsInterval(),d=setInterval((()=>{l&&l(0);const e=JSON.stringify({demuxBufferDelay:yr.getVideoBufferLength(),audioDemuxBufferDelay:yr.getAudioBufferLength(),flvBufferByteLength:yr.getFlvBufferLength(),netBuf:yr.networkDelay||0,pushLatestDelay:yr.pushLatestDelay||0,isStreamTsMoreThanLocal:Ke});postMessage({cmd:z,type:ve,value:e})}),1e3)},stopStreamRateAndStatsInterval:function(){d&&(clearInterval(d),d=null)},useOffscreen:function(){return yr._opt.useOffscreen&&"undefined"!=typeof OffscreenCanvas},getDelay:function(e,t){if(!e||yr._opt.hasVideo&&!Ye)return-1;if(t===Q)return yr.delay;if(yr.preDelayTimestamp&&yr.preDelayTimestamp>e)return yr.preDelayTimestamp-e>1e3&&yr.debug.warn("worker",`getDelay() and preDelayTimestamp is ${yr.preDelayTimestamp} > timestamp is ${e} more than ${yr.preDelayTimestamp-e}ms and return ${yr.delay}`),yr.preDelayTimestamp=e,yr.delay;if(yr.firstTimestamp){if(e){const t=Date.now()-yr.startTimestamp,r=e-yr.firstTimestamp;t>=r?(Ke=!1,yr.delay=t-r):(Ke=!0,yr.delay=r-t)}}else yr.firstTimestamp=e,yr.startTimestamp=Date.now(),yr.delay=-1;return yr.preDelayTimestamp=e,yr.delay},getDelayNotUpdateDelay:function(e,t){if(!e||yr._opt.hasVideo&&!Ye)return-1;if(t===Q)return yr.pushLatestDelay;if(yr.preDelayTimestamp&&yr.preDelayTimestamp-e>1e3)return yr.debug.warn("worker",`getDelayNotUpdateDelay() and preDelayTimestamp is ${yr.preDelayTimestamp} > timestamp is ${e} more than ${yr.preDelayTimestamp-e}ms and return -1`),-1;if(yr.firstTimestamp){let t=-1;if(e){const r=Date.now()-yr.startTimestamp,i=e-yr.firstTimestamp;r>=i?(Ke=!1,t=r-i):(Ke=!0,t=i-r)}return t}return-1},resetDelay:function(){yr.firstTimestamp=null,yr.startTimestamp=null,yr.delay=-1,yr.dropping=!1},resetAllDelay:function(){yr.resetDelay(),yr.preDelayTimestamp=null},doDecode:function(e){yr._opt.isEmitSEI&&e.type===ee&&yr.isWorkerFetch&&yr.findSei(e.payload,e.ts),yr._opt.useWCS&&yr.useOffscreen()&&e.type===ee&&s.decode?s.decode(e.payload,e.ts,e.cts):e.decoder.decode(e.payload,e.ts,e.isIFrame,e.cts)},decodeNext(e){if(0===i.length)return;const t=e.ts,n=i[0],s=e.type===ee&&xt(e.payload);if(At(r))s&&(yr.debug.log("worker",`decode data type is ${e.type} and\n ts is ${t} next data type is ${n.type} ts is ${n.ts}\n isVideoSqeHeader is ${s}`),i.shift(),yr.doDecode(n));else{const r=n.ts-t,o=n.type===Q&&e.type===ee;(r<=20||o||s)&&(yr.debug.log("worker",`decode data type is ${e.type} and\n ts is ${t} next data type is ${n.type} ts is ${n.ts}\n diff is ${r} and isVideoAndNextAudio is ${o} and isVideoSqeHeader is ${s}`),i.shift(),yr.doDecode(n))}},init:function(){yr.debug.log("worker","init and opt is",JSON.stringify(yr._opt));const e=yr._opt.playType===_,t=yr._opt.playType===g;if(mr.init(),yr.isPlayer=e,yr.isPlayback=t,yr.isPlaybackCacheBeforeDecodeForFpsRender())yr.debug.log("worker","playback and playbackIsCacheBeforeDecodeForFpsRender is true");else{const t=()=>{let t=null;if(i.length){if(yr.isPushDropping)return void yr.debug.warn("worker",`loop() isPushDropping is true and bufferList length is ${i.length}`);if(yr.dropping){for(t=i.shift(),yr.debug.warn("worker",`loop() dropBuffer is dropping and isIFrame ${t.isIFrame} and delay is ${yr.delay} and bufferlist is ${i.length}`);!t.isIFrame&&i.length;)t=i.shift();const e=yr.getDelayNotUpdateDelay(t.ts,t.type);t.isIFrame&&e<=yr.getNotDroppingDelayTs()&&(yr.debug.log("worker","loop() is dropping = false, is iFrame"),yr.dropping=!1,yr.doDecode(t),yr.decodeNext(t))}else if(yr.isPlayback||yr.isPlayUseMSE())for(;i.length;)t=i.shift(),yr.doDecode(t);else if(t=i[0],-1===yr.getDelay(t.ts,t.type))yr.debug.log("worker","loop() common dumex delay is -1 ,data.ts is",t.ts),i.shift(),yr.doDecode(t),yr.decodeNext(t);else if(yr.delay>yr._opt.videoBuffer+yr._opt.videoBufferDelay&&e)yr.hasIframeInBufferList()?(yr.debug.log("worker",`delay is ${yr.delay}, set dropping is true`),yr.resetAllDelay(),yr.dropping=!0,postMessage({cmd:O})):(i.shift(),yr.doDecode(t),yr.decodeNext(t));else for(;i.length;){if(t=i[0],!(yr.getDelay(t.ts,t.type)>yr._opt.videoBuffer)){yr.delay<0&&yr.debug.warn("worker",`loop() do not decode and delay is ${yr.delay}, bufferList is ${i.length}`);break}i.shift(),yr.doDecode(t)}}else-1!==yr.delay&&yr.debug.log("worker","loop() bufferList is empty and reset delay"),yr.resetAllDelay()};yr.stopId=setInterval((()=>{let e=(new Date).getTime();Xe||(Xe=e);const r=e-Xe;r>100&&yr.debug.warn("worker",`loop demux diff time is ${r}`),t(),Xe=(new Date).getTime()}),20)}At(yr._opt.checkFirstIFrame)&&(Ye=!0)},playbackCacheLoop:function(){yr.stopId&&(clearInterval(yr.stopId),yr.stopId=null);const e=()=>{let e=null;i.length&&(e=i.shift(),yr.doDecode(e))};e();const t=Math.ceil(1e3/(yr.streamFps*yr._opt.playbackRate));yr.debug.log("worker",`playbackCacheLoop fragDuration is ${t}, streamFps is ${yr.streamFps}, streamAudioFps is ${yr.streamAudioFps} ,streamVideoFps is ${yr.streamVideoFps} playbackRate is ${yr._opt.playbackRate}`),yr.stopId=setInterval(e,t)},close:function(){if(yr.debug.log("worker","close"),yr.isDestroyed=!0,pr(),!a||1!==a.readyState&&2!==a.readyState?a&&yr.debug.log("worker",`close() and socket.readyState is ${a.readyState}`):(cr=!0,a.close(1e3,"Client disconnecting")),a=null,yr.stopStreamRateAndStatsInterval(),yr.stopId&&(clearInterval(yr.stopId),yr.stopId=null),yr.mp3Demuxer&&(yr.mp3Demuxer.destroy(),yr.mp3Demuxer=null),yr.writableStream&&At(yr.writableStream.locked)&&yr.writableStream.close().catch((e=>{yr.debug.log("worker","close() and writableStream.close() error",e)})),yr.writableStream=null,vr)try{vr.clear&&vr.clear(),vr=null}catch(e){yr.debug.warn("worker","close() and audioDecoder.clear error",e)}if(br)try{br.clear&&br.clear(),br=null}catch(e){yr.debug.warn("worker","close() and videoDecoder.clear error",e)}l=null,Xe=null,Ke=!1,s&&(s.reset&&s.reset(),s=null),yr.firstTimestamp=null,yr.startTimestamp=null,yr.networkDelay=0,yr.streamFps=null,yr.streamAudioFps=null,yr.streamVideoFps=null,yr.delay=-1,yr.pushLatestDelay=-1,yr.preDelayTimestamp=null,yr.dropping=!1,yr.isPushDropping=!1,yr.isPlayer=!0,yr.isPlayback=!1,yr.isWorkerFetch=!1,yr._opt=fr(),yr.webglObj&&(yr.webglObj.destroy(),yr.offscreenCanvas.removeEventListener("webglcontextlost",yr.onOffscreenCanvasWebglContextLost),yr.offscreenCanvas.removeEventListener("webglcontextrestored",yr.onOffscreenCanvasWebglContextRestored),yr.offscreenCanvas=null,yr.offscreenCanvasGL=null,yr.offscreenCanvasCtx=null),i=[],n=[],u=null,v=null,b=null,S=!1,Ge=!1,Ye=!1,qt=!1,Qt=!1,lr=!1,dr=null,ur=null,Tt=[],Ft=0,It=0,ot=null,ft=null,Lt=null,Rt=null,hr=null,jt=0,Yt=0,Ct=null,Bt=null,yr.fetchStatus=Je,mr.destroy(),_r.destroy(),gr.destroy(),postMessage({cmd:W})},pushBuffer:function(e,t){if(t.type===Q&&lt(e)){if(yr.debug.log("worker",`pushBuffer audio ts is ${t.ts}, isAacCodecPacket is true`),yr._opt.isRecordTypeFlv){const t=new Uint8Array(e);postMessage({cmd:K,buffer:t},[t.buffer])}yr.decodeAudio(e,t.ts)}else if(t.type===ee&&t.isIFrame&&xt(e)){if(yr.debug.log("worker",`pushBuffer video ts is ${t.ts}, isVideoSequenceHeader is true`),yr._opt.isRecordTypeFlv){const t=new Uint8Array(e);postMessage({cmd:X,buffer:t},[t.buffer])}yr.decodeVideo(e,t.ts,t.isIFrame,t.cts)}else{if(yr._opt.isRecording)if(yr._opt.isRecordTypeFlv){const r=new Uint8Array(e);postMessage({cmd:Z,type:t.type,buffer:r,ts:t.ts},[r.buffer])}else if(yr._opt.recordType===y)if(t.type===ee){const r=new Uint8Array(e).slice(5);postMessage({cmd:I,buffer:r,isIFrame:t.isIFrame,ts:t.ts,cts:t.cts},[r.buffer])}else if(t.type===Q&&yr._opt.isWasmMp4){const r=new Uint8Array(e),i=dt(r)?r.slice(2):r.slice(1);postMessage({cmd:B,buffer:i,ts:t.ts},[i.buffer])}if(yr.isPlayer&&jt>0&&Rt>0&&t.type===ee){const e=t.ts-Rt,r=jt+jt/2;e>r&&yr.debug.log("worker",`pushBuffer video\n ts is ${t.ts}, preTimestamp is ${Rt},\n diff is ${e} and preTimestampDuration is ${jt} and maxDiff is ${r}\n maybe trigger black screen or flower screen\n `)}if(yr.isPlayer&&Rt>0&&t.type===ee&&t.ts<Rt&&Rt-t.ts>w&&(yr.debug.warn("worker",`pushBuffer,\n preTimestamp is ${Rt}, options.ts is ${t.ts},\n diff is ${Rt-t.ts} more than 3600000,\n and resetAllDelay`),yr.resetAllDelay()),yr.isPlayer&&t.ts<=Rt&&Rt>0&&t.type===ee&&(yr.debug.warn("worker",`pushBuffer,\n options.ts is ${t.ts} less than (or equal) preTimestamp is ${Rt} and\n payloadBufferSize is ${e.byteLength} and prevPayloadBufferSize is ${Yt}`),yr._opt.isDropSameTimestampGop&&Ye)){const e=yr.hasIframeInBufferList(),t=At(yr.isPushDropping);return yr.debug.log("worker",`pushBuffer, isDropSameTimestampGop is true and\n hasIframe is ${e} and isNotPushDropping is ${t} and next dropBuffer`),void(e&&t?yr.dropBuffer$2():(yr.clearBuffer(!0),kt(yr._opt.checkFirstIFrame)&&kt(r)&&postMessage({cmd:J})))}if(yr.isPlayer&&Ye){const e=yr._opt.videoBuffer+yr._opt.videoBufferDelay,r=yr.getDelayNotUpdateDelay(t.ts,t.type);yr.pushLatestDelay=r,r>e&&yr.delay<e&&yr.delay>0&&yr.hasIframeInBufferList()&&!1===yr.isPushDropping&&(yr.debug.log("worker",`pushBuffer(), pushLatestDelay is ${r} more than ${e} and decoder.delay is ${yr.delay} and has iIframe and next decoder.dropBuffer$2()`),yr.dropBuffer$2())}if(yr.isPlayer&&t.type===ee&&(Rt>0&&(jt=t.ts-Rt),Yt=e.byteLength,Rt=t.ts),t.type===Q?i.push({ts:t.ts,payload:e,decoder:{decode:yr.decodeAudio},type:Q,isIFrame:!1}):t.type===ee&&i.push({ts:t.ts,cts:t.cts,payload:e,decoder:{decode:yr.decodeVideo},type:ee,isIFrame:t.isIFrame}),yr.isPlaybackCacheBeforeDecodeForFpsRender()&&(_t(yr.streamVideoFps)||_t(yr.streamAudioFps))){let e=yr.streamVideoFps,t=yr.streamAudioFps;if(_t(yr.streamVideoFps)&&(e=Et(i,ee),e&&(yr.streamVideoFps=e,postMessage({cmd:$,value:yr.streamVideoFps}),yr.streamFps=t?e+t:e,At(yr._opt.hasAudio)&&(yr.debug.log("worker","playbackCacheBeforeDecodeForFpsRender, _opt.hasAudio is false and set streamAudioFps is 0"),yr.streamAudioFps=0),yr.playbackCacheLoop())),_t(yr.streamAudioFps)&&(t=Et(i,Q),t&&(yr.streamAudioFps=t,yr.streamFps=e?e+t:t,yr.playbackCacheLoop())),_t(yr.streamVideoFps)&&_t(yr.streamAudioFps)){const r=i.map((e=>({type:e.type,ts:e.ts})));yr.debug.log("worker",`playbackCacheBeforeDecodeForFpsRender, calc streamAudioFps is ${t}, streamVideoFps is ${e}, bufferListLength is ${i.length}, and ts list is ${JSON.stringify(r)}`)}const r=yr.getAudioBufferLength()>0,n=r?60:40;i.length>=n&&(yr.debug.warn("worker",`playbackCacheBeforeDecodeForFpsRender, bufferListLength is ${i.length} more than ${n}, and hasAudio is ${r} an set streamFps is 25`),yr.streamVideoFps=25,postMessage({cmd:$,value:yr.streamVideoFps}),r?(yr.streamAudioFps=25,yr.streamFps=yr.streamVideoFps+yr.streamAudioFps):yr.streamFps=yr.streamVideoFps,yr.playbackCacheLoop())}}},getVideoBufferLength(){let e=0;return i.forEach((t=>{t.type===ee&&(e+=1)})),e},hasIframeInBufferList:()=>i.some((e=>e.type===ee&&e.isIFrame)),isAllIframeInBufferList(){const e=yr.getVideoBufferLength();let t=0;return i.forEach((e=>{e.type===ee&&e.isIFrame&&(t+=1)})),e===t},getNotDroppingDelayTs:()=>yr._opt.videoBuffer+yr._opt.videoBufferDelay/2,getAudioBufferLength(){let e=0;return i.forEach((t=>{t.type===Q&&(e+=1)})),e},getFlvBufferLength(){let e=0;return u&&u.buffer&&(e=u.buffer.byteLength),yr._opt.isNakedFlow&&mr.lastBuf&&(e=mr.lastBuf.byteLength),e},fetchStream:function(e,t){yr.debug.log("worker","fetchStream, url is "+e,"options:",JSON.stringify(t)),yr.isWorkerFetch=!0,t.isFlv?yr._opt.isFlv=!0:t.isFmp4?yr._opt.isFmp4=!0:t.isMpeg4?yr._opt.isMpeg4=!0:t.isNakedFlow&&(yr._opt.isNakedFlow=!0),l=pt((e=>{postMessage({cmd:z,type:pe,value:e})})),yr.startStreamRateAndStatsInterval(),t.isFmp4&&(_r.listenMp4Box(),yr._opt.isFmp4Private&&_r.initTransportDescarmber()),t.protocol===f?(u=new Pt(yr.demuxFlv()),fetch(e,{signal:o.signal}).then((e=>{if(kt(cr))return yr.debug.log("worker","request abort and run res.body.cancel()"),yr.fetchStatus=Je,void e.body.cancel();if(!St(e))return yr.debug.warn("worker",`fetch response status is ${e.status} and ok is ${e.ok} and emit error and next abort()`),pr(),void postMessage({cmd:z,type:Ee.fetchError,value:`fetch response status is ${e.status} and ok is ${e.ok}`});if(postMessage({cmd:z,type:ye}),bt())yr.writableStream=new WritableStream({write:e=>o&&o.signal&&o.signal.aborted?(yr.debug.log("worker","writableStream write() and abortController.signal.aborted is true so return"),void(yr.fetchStatus=et)):kt(cr)?(yr.debug.log("worker","writableStream write() and requestAbort is true so return"),void(yr.fetchStatus=et)):(yr.fetchStatus=Qe,l(e.byteLength),void(t.isFlv?u.write(e):t.isFmp4?yr.demuxFmp4(e):t.isMpeg4&&yr.demuxMpeg4(e))),close:()=>{yr.fetchStatus=et,u=null,pr(),postMessage({cmd:z,type:fe,value:p})},abort:e=>{if(o&&o.signal&&o.signal.aborted)return yr.debug.log("worker","writableStream abort() and abortController.signal.aborted is true so return"),void(yr.fetchStatus=et);u=null,e.name!==qe&&(pr(),postMessage({cmd:z,type:Ee.fetchError,value:e.toString()}))}}),e.body.pipeTo(yr.writableStream);else{const r=e.body.getReader(),i=()=>{r.read().then((e=>{let{done:r,value:n}=e;return r?(yr.fetchStatus=et,u=null,pr(),void postMessage({cmd:z,type:fe,value:p})):o&&o.signal&&o.signal.aborted?(yr.debug.log("worker","fetchNext().then() and abortController.signal.aborted is true so return"),void(yr.fetchStatus=et)):kt(cr)?(yr.debug.log("worker","fetchNext().then() and requestAbort is true so return"),void(yr.fetchStatus=et)):(yr.fetchStatus=Qe,l(n.byteLength),t.isFlv?u.write(n):t.isFmp4?yr.demuxFmp4(n):t.isMpeg4&&yr.demuxMpeg4(n),void i())})).catch((e=>{if(o&&o.signal&&o.signal.aborted)return yr.debug.log("worker","fetchNext().catch() and abortController.signal.aborted is true so return"),void(yr.fetchStatus=et);u=null,e.name!==qe&&(pr(),postMessage({cmd:z,type:Ee.fetchError,value:e.toString()}))}))};i()}})).catch((e=>{o&&o.signal&&o.signal.aborted?yr.debug.log("worker","fetch().catch() and abortController.signal.aborted is true so return"):e.name!==qe&&(pr(),postMessage({cmd:z,type:Ee.fetchError,value:e.toString()}),u=null)}))):t.protocol===c&&(t.isFlv&&(u=new Pt(yr.demuxFlv())),a=new WebSocket(e),a.binaryType="arraybuffer",a.onopen=()=>{yr.debug.log("worker","fetchStream, WebsocketStream socket open"),postMessage({cmd:z,type:ye}),postMessage({cmd:z,type:we})},a.onclose=e=>{yr.debug.log("worker",`fetchStream, WebsocketStream socket close and code is ${e.code}`),1006===e.code&&yr.debug.error("worker",`fetchStream, WebsocketStream socket close abnormally and code is ${e.code}`),kt(cr)?yr.debug.log("worker","fetchStream, WebsocketStream socket close and requestAbort is true so return"):(u=null,postMessage({cmd:z,type:fe,value:m}))},a.onerror=e=>{yr.debug.error("worker","fetchStream, WebsocketStream socket error",e),u=null,postMessage({cmd:z,type:Ee.websocketError,value:e.isTrusted?"websocket user aborted":"websocket error"})},a.onmessage=e=>{l(e.data.byteLength),t.isFlv?u.write(e.data):t.isFmp4?yr.demuxFmp4(e.data):t.isMpeg4?yr.demuxMpeg4(e.data):yr._opt.isNakedFlow?yr.demuxNakedFlow(e.data):yr.demuxM7s(e.data)})},demuxFlv:function*(){yield 9;const e=new ArrayBuffer(4),t=new Uint8Array(e),r=new Uint32Array(e);for(;;){t[3]=0;const e=yield 15,i=e[4];t[0]=e[7],t[1]=e[6],t[2]=e[5];const n=r[0];t[0]=e[10],t[1]=e[9],t[2]=e[8],t[3]=e[11];let s=r[0];const o=(yield n).slice();switch(i){case te:if(o.byteLength>0){let e=o;kt(yr._opt.m7sCryptoAudio)&&(e=yr.cryptoPayloadAudio(o)),yr.decode(e,{type:Q,ts:s})}else yr.debug.warn("worker",`demuxFlv() type is audio and payload.byteLength is ${o.byteLength} and return`);break;case re:if(o.byteLength>=6){const e=o[0];if(yr._isEnhancedH265Header(e))yr._decodeEnhancedH265Video(o,s);else{o[0];const e=o[0]>>4===Ze;if(e&&xt(o)&&null===dr){const e=15&o[0];dr=e===xe,ur=Zt(o,dr),yr.debug.log("worker",`demuxFlv() isVideoSequenceHeader is true and isHevc is ${dr} and nalUnitSize is ${ur}`)}e&&yr.calcIframeIntervalTimestamp(s),yr.isPlayer&&yr.calcNetworkDelay(s),r[0]=o[4],r[1]=o[3],r[2]=o[2],r[3]=0;let t=r[0],i=yr.cryptoPayload(o,e);yr.decode(i,{type:ee,ts:s,isIFrame:e,cts:t})}}else yr.debug.warn("worker",`demuxFlv() type is video and payload.byteLength is ${o.byteLength} and return`);break;case ie:postMessage({cmd:q,buffer:o},[o.buffer]);break;default:yr.debug.log("worker",`demuxFlv() type is ${i}`)}}},decode:function(e,t){t.type===Q?yr._opt.hasAudio&&(postMessage({cmd:z,type:me,value:e.byteLength}),yr.isPlayer?yr.pushBuffer(e,{type:t.type,ts:t.ts,cts:t.cts}):yr.isPlayback&&(yr.isPlaybackCacheBeforeDecodeForFpsRender(),yr.pushBuffer(e,{type:t.type,ts:t.ts,cts:t.cts}))):t.type===ee&&yr._opt.hasVideo&&(postMessage({cmd:z,type:_e,value:e.byteLength}),postMessage({cmd:z,type:ge,value:t.ts}),yr.isPlayer?yr.pushBuffer(e,{type:t.type,ts:t.ts,isIFrame:t.isIFrame,cts:t.cts}):yr.isPlayback&&(yr.isPlaybackOnlyDecodeIFrame()?t.isIFrame&&yr.pushBuffer(e,{type:t.type,ts:t.ts,cts:t.cts,isIFrame:t.isIFrame}):(yr.isPlaybackCacheBeforeDecodeForFpsRender(),yr.pushBuffer(e,{type:t.type,ts:t.ts,cts:t.cts,isIFrame:t.isIFrame}))))},cryptoPayload:function(e,t){let r=e;return yr._opt.isM7sCrypto?yr._opt.cryptoIV&&yr._opt.cryptoIV.byteLength>0&&yr._opt.cryptoKey&&yr._opt.cryptoKey.byteLength>0?r=Gr(e,yr._opt.cryptoKey,yr._opt.cryptoIV,dr):yr.debug.error("worker",`isM7sCrypto cryptoKey.length is ${yr._opt.cryptoKey&&yr._opt.cryptoKey.byteLength} or cryptoIV.length is ${yr._opt.cryptoIV&&yr._opt.cryptoIV.byteLength} null`):yr._opt.isSm4Crypto?yr._opt.sm4CryptoKey&&t?r=di(e,yr._opt.sm4CryptoKey):yr._opt.sm4CryptoKey||yr.debug.error("worker","isSm4Crypto opt.sm4CryptoKey is null"):yr._opt.isXorCrypto&&(yr._opt.cryptoIV&&yr._opt.cryptoIV.byteLength>0&&yr._opt.cryptoKey&&yr._opt.cryptoKey.byteLength>0?r=pi(e,yr._opt.cryptoKey,yr._opt.cryptoIV,dr):yr.debug.error("worker",`isXorCrypto cryptoKey.length is ${yr._opt.cryptoKey&&yr._opt.cryptoKey.byteLength} or cryptoIV.length is ${yr._opt.cryptoIV&&yr._opt.cryptoIV.byteLength} null`)),r},cryptoPayloadAudio:function(e){let t=e;return yr._opt.isM7sCrypto&&(yr._opt.cryptoIV&&yr._opt.cryptoIV.byteLength>0&&yr._opt.cryptoKey&&yr._opt.cryptoKey.byteLength>0?e[0]>>4===Ce&&(t=Hr(e,yr._opt.cryptoKey,yr._opt.cryptoIV)):yr.debug.error("worker",`isM7sCrypto cryptoKey.length is ${yr._opt.cryptoKey&&yr._opt.cryptoKey.byteLength} or cryptoIV.length is ${yr._opt.cryptoIV&&yr._opt.cryptoIV.byteLength} null`)),t},setCodecAudio:function(e,t){const r=e[0]>>4,i=e[0]>>1&1;if(hr=r===Ce?i?16:8:0===i?8:16,vr&&vr.setCodec)if(lt(e)||r===Be||r===Fe||r===Pe){yr.debug.log("worker",`setCodecAudio: init audio codec, codeId is ${r}`);const i=r===Ce?e.slice(2):new Uint8Array(0);vr.setCodec(r,yr._opt.sampleRate,i),postMessage({cmd:F,buffer:i},[i.buffer]),Ge=!0,r!==Ce&&(r===Pe?(yr.mp3Demuxer||(yr.mp3Demuxer=new hi(yr),yr.mp3Demuxer.on("data",((e,t)=>{vr.decode(e,t)}))),yr.mp3Demuxer.dispatch(e.slice(1),t)):vr.decode(e.slice(1),t));{const e=Number("1")||1;setTimeout((()=>{yr.debug.error("worker","jessibuca pro 体验结束,请刷新页面再次体验(wasm内部会暂停解码),如需要购买商业授权,可以联系微信:bosswancheng"),yr.close(),postMessage({cmd:N})}),60*e*60*1e3)}}else yr.debug.warn("worker","setCodecAudio: hasInitAudioCodec is false, codecId is ",r);else yr.debug.error("worker","setCodecAudio: audioDecoder or audioDecoder.setCodec is null")},decodeAudio:function(e,t){if(yr.isDestroyed)yr.debug.log("worker","decodeAudio, decoder is destroyed and return");else if(kt(r)&&kt(yr._opt.mseDecodeAudio))postMessage({cmd:R,payload:e,ts:t,cts:t},[e.buffer]);else{const r=e[0]>>4;Ge?r===Pe?yr.mp3Demuxer.dispatch(e.slice(1),t):vr.decode(r===Ce?e.slice(2):e.slice(1),t):yr.setCodecAudio(e,t)}},setCodecVideo:function(e){const t=15&e[0];if(br&&br.setCodec)if(xt(e))if(t===Ue||t===xe){yr.debug.log("worker",`setCodecVideo: init video codec , codecId is ${t}`);const r=e.slice(5);if(t===Ue&&yr._opt.useSIMD){const e=zt(r);if(e.codecWidth>E||e.codecHeight>E)return postMessage({cmd:V}),void yr.debug.warn("worker",`setCodecVideo: SIMD H264 decode video width is too large, width is ${e.codecWidth}, height is ${e.codecHeight}`)}S=!0,br.setCodec(t,r),yr._opt.recordType===y&&postMessage({cmd:D,buffer:e,codecId:t},[e.buffer])}else yr.debug.warn("worker",`setCodecVideo: hasInitVideoCodec is false, codecId is ${t} is not H264 or H265`);else yr.debug.warn("worker",`decodeVideo: hasInitVideoCodec is false, codecId is ${t} and frameType is ${e[0]>>4} and packetType is ${e[1]}`);else yr.debug.error("worker","setCodecVideo: videoDecoder or videoDecoder.setCodec is null")},decodeVideo:function(e,t,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(yr.isDestroyed)yr.debug.log("worker","decodeVideo, decoder is destroyed and return");else if(kt(r))postMessage({cmd:L,payload:e,isIFrame:i,ts:t,cts:n,delay:yr.delay},[e.buffer]);else if(S)if(!Ye&&i&&(Ye=!0),Ye){if(i&&xt(e)){const t=15&e[0];let r={};t===Ue?r=zt(e.slice(5)):t===xe&&(r=Jt(e)),r.codecWidth&&r.codecHeight&&v&&b&&(r.codecWidth!==v||r.codecHeight!==b)&&(yr.debug.warn("worker",`\n decodeVideo: video width or height is changed,\n old width is ${v}, old height is ${b},\n new width is ${r.codecWidth}, new height is ${r.codecHeight},\n and emit change event`),Qt=!0,postMessage({cmd:G}))}if(Qt)return void yr.debug.warn("worker","decodeVideo: video width or height is changed, and return");if(lr)return void yr.debug.warn("worker","decodeVideo: simd decode error, and return");if(xt(e))return void yr.debug.warn("worker","decodeVideo and payload is video sequence header so drop this frame");if(e.byteLength<12)return void yr.debug.warn("worker",`decodeVideo and payload is too small , payload length is ${e.byteLength}`);const r=e.slice(5);br.decode(r,i?1:0,t)}else yr.debug.log("worker","decodeVideo first frame is not iFrame");else yr.setCodecVideo(e)},clearBuffer:function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];yr.debug.log("worker",`clearBuffer,bufferList length is ${i.length}, need clear is ${e}`),e&&(i=[]),yr.isPlayer&&(yr.resetAllDelay(),kt(yr._opt.checkFirstIFrame)&&(yr.dropping=!0,postMessage({cmd:O}))),kt(yr._opt.checkFirstIFrame)&&At(r)&&(Ye=!1)},dropBuffer$2:function(){if(i.length>0){let e=i.findIndex((e=>kt(e.isIFrame)&&e.type===ee));if(yr.isAllIframeInBufferList())for(let t=0;t<i.length;t++){const r=i[t],n=yr.getDelayNotUpdateDelay(r.ts,r.type);if(n>=yr.getNotDroppingDelayTs()){yr.debug.log("worker",`dropBuffer$2() isAllIframeInBufferList() is true, and index is ${t} and tempDelay is ${n} and notDroppingDelayTs is ${yr.getNotDroppingDelayTs()}`),e=t;break}}if(e>=0){yr.isPushDropping=!0,postMessage({cmd:O});const t=i.length;i=i.slice(e);const r=i.shift();yr.resetAllDelay(),yr.getDelay(r.ts,r.type),yr.doDecode(r),yr.isPushDropping=!1,yr.debug.log("worker",`dropBuffer$2() iFrameIndex is ${e},and old bufferList length is ${t} ,new bufferList is ${i.length} and new delay is ${yr.delay} `)}else yr.isPushDropping=!1}0===i.length&&(yr.isPushDropping=!1)},demuxM7s:function(e){const t=new DataView(e),r=t.getUint32(1,!1),i=t.getUint8(0),n=new ArrayBuffer(4),s=new Uint32Array(n);switch(i){case Q:yr.decode(new Uint8Array(e,5),{type:Q,ts:r});break;case ee:if(t.byteLength>=11){const i=new Uint8Array(e,5),n=i[0];if(yr._isEnhancedH265Header(n))yr._decodeEnhancedH265Video(i,r);else{const e=t.getUint8(5)>>4==1;if(e&&(yr.calcIframeIntervalTimestamp(r),xt(i)&&null===dr)){const e=15&i[0];dr=e===xe}yr.isPlayer&&yr.calcNetworkDelay(r),s[0]=i[4],s[1]=i[3],s[2]=i[2],s[3]=0;let n=s[0],o=yr.cryptoPayload(i,e);yr.decode(o,{type:ee,ts:r,isIFrame:e,cts:n})}}else yr.debug.warn("worker",`demuxM7s() type is video and arrayBuffer length is ${e.byteLength} and return`)}},demuxNakedFlow:function(e){mr.dispatch(e)},demuxFmp4:function(e){const t=new Uint8Array(e);_r.dispatch(t)},demuxMpeg4:function(e){gr.dispatch(e)},_decodeEnhancedH265Video:function(e,t){const r=e[0],i=48&r,n=15&r,s=e.slice(1,5),o=new ArrayBuffer(4),a=new Uint32Array(o),l="a"==String.fromCharCode(s[0]);if(dr=At(l),n===rt){if(i===st){const r=e.slice(5);if(l);else{const i=new Uint8Array(5+r.length);i.set([28,0,0,0,0],0),i.set(r,5),ur=Zt(e,dr),yr.debug.log("worker",`demuxFlv() isVideoSequenceHeader(enhancedH265) is true and isHevc is ${dr} and nalUnitSize is ${ur}`),yr.decode(i,{type:ee,ts:t,isIFrame:!0,cts:0})}}}else if(n===it){let r=e,n=0;const s=i===st;s&&yr.calcIframeIntervalTimestamp(t),l||(a[0]=e[4],a[1]=e[3],a[2]=e[2],a[3]=0,n=a[0],r=rr(e.slice(8),s),r=yr.cryptoPayload(r,s),yr.decode(r,{type:ee,ts:t,isIFrame:s,cts:n}))}else if(n===nt){const r=i===st;r&&yr.calcIframeIntervalTimestamp(t);let n=rr(e.slice(5),r);n=yr.cryptoPayload(n,r),yr.decode(n,{type:ee,ts:t,isIFrame:r,cts:0})}},_isEnhancedH265Header:function(e){return(e&tt)===tt},findSei:function(e,t){let r=4;gt(ur)&&(r=ur),Kt(e.slice(5),r).forEach((e=>{const r=dr?e[0]>>>1&63:31&e[0];(dr&&(r===Ve||r===He)||At(dr)&&r===Re)&&postMessage({cmd:Y,buffer:e,ts:t},[e.buffer])}))},flvHasUnitTypeIDR(e,t){const r=Kt(e.slice(5));let i=!1;return r.forEach((e=>{const r=t?e[0]>>>1&63:31&e[0];(t&&(r===ze||r===Me)||At(t)&&r===Le)&&(i=!0)})),i},calcNetworkDelay:function(e){if(!(Ye&&e>0))return;null===ot?(ot=e,ft=ht()):e<ot&&(yr.debug.warn("worker",`calcNetworkDelay, dts is ${e} less than bufferStartDts is ${ot}`),ot=e,ft=ht());const t=e-ot,r=ht()-ft,i=r>t?r-t:0;yr.networkDelay=i,i>yr._opt.networkDelay&&yr._opt.playType===_&&(yr.debug.warn("worker",`calcNetworkDelay now dts:${e}, start dts is ${ot} vs start is ${t},local diff is ${r} ,delay is ${i}`),postMessage({cmd:z,type:be,value:i}))},calcIframeIntervalTimestamp:function(e){null===Lt?Lt=e:Lt<e&&(Bt=e-Lt,postMessage({cmd:M,value:Bt}),Lt=e)},canVisibilityDecodeNotDrop:function(){return yr._opt.visibility&&v*b<=2073600},isPlaybackCacheBeforeDecodeForFpsRender:function(){return yr.isPlayback&&yr._opt.playbackIsCacheBeforeDecodeForFpsRender},isPlaybackOnlyDecodeIFrame:function(){return yr._opt.playbackRate>=yr._opt.playbackForwardMaxRateDecodeIFrame},isPlayUseMSE:function(){return yr.isPlayer&&yr._opt.useMSE&&kt(r)},playbackUpdatePlaybackRate:function(){yr.clearBuffer(!0)},onOffscreenCanvasWebglContextLost:function(e){yr.debug.error("worker","handleOffscreenCanvasWebglContextLost and next try to create webgl"),e.preventDefault(),qt=!0,yr.webglObj.destroy(),yr.webglObj=null,yr.offscreenCanvasGL=null,setTimeout((()=>{yr.offscreenCanvasGL=yr.offscreenCanvas.getContext("webgl"),yr.offscreenCanvasGL&&yr.offscreenCanvasGL.getContextAttributes().stencil?(yr.webglObj=h(yr.offscreenCanvasGL,yr._opt.openWebglAlignment),qt=!1):yr.debug.error("worker","handleOffscreenCanvasWebglContextLost, stencil is false")}),500)},onOffscreenCanvasWebglContextRestored:function(e){yr.debug.log("worker","handleOffscreenCanvasWebglContextRestored"),e.preventDefault()},videoInfo:function(e,t,r){postMessage({cmd:P,code:e}),postMessage({cmd:x,w:t,h:r}),v=t,b=r,yr.useOffscreen()&&(yr.offscreenCanvas=new OffscreenCanvas(t,r),yr.offscreenCanvasGL=yr.offscreenCanvas.getContext("webgl"),yr.webglObj=h(yr.offscreenCanvasGL,yr._opt.openWebglAlignment),yr.offscreenCanvas.addEventListener("webglcontextlost",yr.onOffscreenCanvasWebglContextLost,!1),yr.offscreenCanvas.addEventListener("webglcontextrestored",yr.onOffscreenCanvasWebglContextRestored,!1))},audioInfo:function(e,t,r){postMessage({cmd:C,code:e}),postMessage({cmd:T,sampleRate:t,channels:r,depth:hr}),It=r},yuvData:function(t,r){if(yr.isDestroyed)return void yr.debug.log("worker","yuvData, decoder is destroyed and return");const i=v*b*3/2;let n=e.HEAPU8.subarray(t,t+i),s=new Uint8Array(n);if(Ct=null,yr.useOffscreen())try{if(qt)return;yr.webglObj.renderYUV(v,b,s);let e=yr.offscreenCanvas.transferToImageBitmap();postMessage({cmd:k,buffer:e,delay:yr.delay,ts:r},[e])}catch(e){yr.debug.error("worker","yuvData, transferToImageBitmap error is",e)}else postMessage({cmd:k,output:s,delay:yr.delay,ts:r},[s.buffer])},pcmData:function(e,r,i){if(yr.isDestroyed)return void yr.debug.log("worker","pcmData, decoder is destroyed and return");let s=r,o=[],a=0,l=yr._opt.audioBufferSize;for(let r=0;r<2;r++){let i=t.HEAPU32[(e>>2)+r]>>2;o[r]=t.HEAPF32.subarray(i,i+s)}if(Ft){if(!(s>=(r=l-Ft)))return Ft+=s,n[0]=Float32Array.of(...n[0],...o[0]),void(2==It&&(n[1]=Float32Array.of(...n[1],...o[1])));Tt[0]=Float32Array.of(...n[0],...o[0].subarray(0,r)),2==It&&(Tt[1]=Float32Array.of(...n[1],...o[1].subarray(0,r))),postMessage({cmd:A,buffer:Tt,ts:i},Tt.map((e=>e.buffer))),a=r,s-=r}for(Ft=s;Ft>=l;Ft-=l)Tt[0]=o[0].slice(a,a+=l),2==It&&(Tt[1]=o[1].slice(a-l,a)),postMessage({cmd:A,buffer:Tt,ts:i},Tt.map((e=>e.buffer)));Ft&&(n[0]=o[0].slice(a),2==It&&(n[1]=o[1].slice(a)))},errorInfo:function(e){null===Ct&&(Ct=ht());const t=ht(),r=ct(Bt>0?2*Bt:5e3,1e3,5e3),i=t-Ct;i>r&&(yr.debug.warn("worker",`errorInfo() emit simdDecodeError and\n iframeIntervalTimestamp is ${Bt} and diff is ${i} and maxDiff is ${r}\n and replay`),lr=!0,postMessage({cmd:H}))},sendWebsocketMessage:function(e){a?a.readyState===Se?a.send(e):yr.debug.error("worker","socket is not open"):yr.debug.error("worker","socket is null")},timeEnd:function(){yr.debug.error("worker","jessibuca pro 体验结束,请刷新页面再次体验(wasm内部会暂停解码),如需要购买商业授权,可以联系微信:bosswancheng"),yr.close(),postMessage({cmd:N})},postStreamToMain(e,t){postMessage({cmd:j,type:t,buffer:e},[e.buffer])}};yr.debug=new Dt(yr);let vr=null;t.AudioDecoder&&(vr=new t.AudioDecoder(yr));let br=null;e.VideoDecoder&&(br=new e.VideoDecoder(yr)),postMessage({cmd:U}),self.onmessage=function(e){let t=e.data;switch(t.cmd){case ne:try{yr._opt=Object.assign(yr._opt,JSON.parse(t.opt))}catch(e){}yr.init();break;case se:yr.pushBuffer(t.buffer,t.options);break;case oe:yr.decodeAudio(t.buffer,t.ts);break;case ae:yr.decodeVideo(t.buffer,t.ts,t.isIFrame);break;case ue:yr.clearBuffer(t.needClear);break;case he:yr.fetchStream(t.url,JSON.parse(t.opt));break;case le:yr.close();break;case de:yr.debug.log("worker","updateConfig",t.key,t.value),yr._opt[t.key]=t.value,"playbackRate"===t.key&&(yr.playbackUpdatePlaybackRate(),yr.isPlaybackCacheBeforeDecodeForFpsRender()&&yr.playbackCacheLoop());break;case ce:yr.sendWebsocketMessage(t.message)}}}(e[1],t)}))}));