!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(require("path"),require("fs"),require("crypto")):"function"==typeof define&&define.amd?define(["path","fs","crypto"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).path,e.fs,e.crypto$1)}(this,function(e,r,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var Sr=n(e),Pr=n(r),Ar=n(t);function o(e,r){return e(r={exports:{}},r.exports),r.exports}var i=o(function(x){var y;(y=void 0!==(y=void 0!==y?y:{})?y:{}).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 r,m,U,B,W,z,i,I=Object.assign({},y),L="./this.program",N="object"==typeof window,c="function"==typeof importScripts,H="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,e="",q=(H?(e=c?Sr.default.dirname(e)+"/":__dirname+"/",z=()=>{W||(B=Pr.default,W=Sr.default)},r=function(e,r){return z(),e=W.normalize(e),B.readFileSync(e,r?void 0:"utf8")},U=e=>{e=r(e,!0);return e=e.buffer?e:new Uint8Array(e)},m=(e,t,n)=>{z(),e=W.normalize(e),B.readFile(e,function(e,r){e?n(e):t(r.buffer)})},1{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},c&&(U=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),m=(e,r,t)=>{var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=()=>{200==n.status||0==n.status&&n.response?r(n.response):t()},n.onerror=t,n.send(null)}),y.print||console.log.bind(console)),a=y.printErr||console.warn.bind(console),V=(Object.assign(y,I),y.arguments&&y.arguments,y.thisProgram&&(L=y.thisProgram),y.quit&&y.quit,y.wasmBinary&&(i=y.wasmBinary),y.noExitRuntime,"object"!=typeof WebAssembly&&v("no native wasm support detected"),!1);function G(e,r){e||v(r)}var X,d,f,u,J,l,p,K,Z,Q,Y="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function s(e,r,t){for(var n=r+t,o=r;e[o]&&!(n<=o);)++o;if(16>10,56320|1023&a))):i+=String.fromCharCode((31&u)<<6|s)):i+=String.fromCharCode(u)}return i}function ee(e,r){return e?s(f,e,r):""}function re(e,r,t,n){if(!(0>6,r[t++]=128|63&a}else if(a<=65535){if(i<=t+2)break;r[t++]=224|a>>12,r[t++]=128|a>>6&63,r[t++]=128|63&a}else{if(i<=t+3)break;r[t++]=240|a>>18,r[t++]=128|a>>12&63,r[t++]=128|a>>6&63,r[t++]=128|63&a}}return r[t]=0,t-o}function te(e){for(var r=0,t=0;t>2]=e},this.get_type=function(){return p[this.ptr+4>>2]},this.set_destructor=function(e){p[this.ptr+8>>2]=e},this.get_destructor=function(){return p[this.ptr+8>>2]},this.set_refcount=function(e){l[this.ptr>>2]=e},this.set_caught=function(e){d[this.ptr+12>>0]=e=e?1:0},this.get_caught=function(){return 0!=d[this.ptr+12>>0]},this.set_rethrown=function(e){d[this.ptr+13>>0]=e=e?1:0},this.get_rethrown=function(){return 0!=d[this.ptr+13>>0]},this.init=function(e,r){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(r),this.set_refcount(0),this.set_caught(!1),this.set_rethrown(!1)},this.add_ref=function(){var e=l[this.ptr>>2];l[this.ptr>>2]=e+1},this.release_ref=function(){var e=l[this.ptr>>2];return l[this.ptr>>2]=e-1,1===e},this.set_adjusted_ptr=function(e){p[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return p[this.ptr+16>>2]},this.get_exception_ptr=function(){if(_r(this.get_type()))return p[this.excPtr>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}ue(h="decoder-pro-audio.wasm")||(I=h,h=y.locateFile?y.locateFile(I,e):e+I);var b={isAbs:e=>"/"===e.charAt(0),splitPath:e=>/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1),normalizeArray:(e,r)=>{for(var t=0,n=e.length-1;0<=n;n--){var o=e[n];"."===o?e.splice(n,1):".."===o?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=b.isAbs(e),t="/"===e.substr(-1);return(e=(e=b.normalizeArray(e.split("/").filter(e=>!!e),!r).join("/"))||r?e:".")&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var e=b.splitPath(e),r=e[0],e=e[1];return r||e?r+(e=e&&e.substr(0,e.length-1)):"."},basename:e=>{if("/"===e)return"/";var r=(e=(e=b.normalize(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===r?e:e.substr(r+1)},join:function(){var e=Array.prototype.slice.call(arguments,0);return b.normalize(e.join("/"))},join2:(e,r)=>b.normalize(e+"/"+r)},E={resolve:function(){for(var e="",r=!1,t=arguments.length-1;-1<=t&&!r;t--){var n=0<=t?arguments[t]:k.cwd();if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");if(!n)return"";e=n+"/"+e,r=b.isAbs(n)}return(r?"/":"")+b.normalizeArray(e.split("/").filter(e=>!!e),!r).join("/")||"."},relative:(e,r)=>{function t(e){for(var r=0;r>>0),0!=t&&(r=Math.max(r,256)),t=e.contents,e.contents=new Uint8Array(r),0=e.node.usedBytes)return 0;var s=Math.min(e.node.usedBytes-o,n);if(8!!e),!1),n=k.root,o="/",i=0;i{for(var r,t;;){if(k.isRoot(e))return t=e.mount.mountpoint,r?"/"!==t[t.length-1]?t+"/"+r:t+r:t;r=r?e.name+"/"+r:e.name,e=e.parent}},hashName:(e,r)=>{for(var t=0,n=0;n>>0)%k.nameTable.length},hashAddNode:e=>{var r=k.hashName(e.parent.id,e.name);e.name_next=k.nameTable[r],k.nameTable[r]=e},hashRemoveNode:e=>{var r=k.hashName(e.parent.id,e.name);if(k.nameTable[r]===e)k.nameTable[r]=e.name_next;else for(var t=k.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode:(e,r)=>{var t=k.mayLookup(e);if(t)throw new k.ErrnoError(t,e);for(var t=k.hashName(e.id,r),n=k.nameTable[t];n;n=n.name_next){var o=n.name;if(n.parent.id===e.id&&o===r)return n}return k.lookup(e,r)},createNode:(e,r,t,n)=>{e=new k.FSNode(e,r,t,n);return k.hashAddNode(e),e},destroyNode:e=>{k.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),flagModes:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},modeStringToFlags:e=>{var r=k.flagModes[e];if(void 0===r)throw new Error("Unknown file open mode: "+e);return r},flagsToPermissionString:e=>{var r=["r","w","rw"][3&e];return 512&e&&(r+="w"),r},nodePermissions:(e,r)=>k.ignorePermissions||(!r.includes("r")||292&e.mode)&&(!r.includes("w")||146&e.mode)&&(!r.includes("x")||73&e.mode)?0:2,mayLookup:e=>{return k.nodePermissions(e,"x")||(e.node_ops.lookup?0:2)},mayCreate:(e,r)=>{try{return k.lookupNode(e,r),20}catch(e){}return k.nodePermissions(e,"wx")},mayDelete:(e,r,t)=>{var n;try{n=k.lookupNode(e,r)}catch(e){return e.errno}r=k.nodePermissions(e,"wx");if(r)return r;if(t){if(!k.isDir(n.mode))return 54;if(k.isRoot(n)||k.getPath(n)===k.cwd())return 10}else if(k.isDir(n.mode))return 31;return 0},mayOpen:(e,r)=>e?k.isLink(e.mode)?32:k.isDir(e.mode)&&("r"!==k.flagsToPermissionString(r)||512&r)?31:k.nodePermissions(e,k.flagsToPermissionString(r)):44,MAX_OPEN_FDS:4096,nextfd:function(){for(var e=0k.streams[e],createStream:(e,r,t)=>{k.FSStream||(k.FSStream=function(){this.shared={}},k.FSStream.prototype={},Object.defineProperties(k.FSStream.prototype,{object:{get:function(){return this.node},set:function(e){this.node=e}},isRead:{get:function(){return 1!=(2097155&this.flags)}},isWrite:{get:function(){return 0!=(2097155&this.flags)}},isAppend:{get:function(){return 1024&this.flags}},flags:{get:function(){return this.shared.flags},set:function(e){this.shared.flags=e}},position:{get:function(){return this.shared.position},set:function(e){this.shared.position=e}}})),e=Object.assign(new k.FSStream,e);r=k.nextfd(r,t);return e.fd=r,k.streams[r]=e},closeStream:e=>{k.streams[e]=null},chrdev_stream_ops:{open:e=>{var r=k.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:()=>{throw new k.ErrnoError(70)}},major:e=>e>>8,minor:e=>255&e,makedev:(e,r)=>e<<8|r,registerDevice:(e,r)=>{k.devices[e]={stream_ops:r}},getDevice:e=>k.devices[e],getMounts:e=>{for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push.apply(t,n.mounts)}return r},syncfs:(r,t)=>{"function"==typeof r&&(t=r,r=!1),k.syncFSRequests++,1=n.length&&i(null)}n.forEach(e=>{if(!e.type.syncfs)return s(null);e.type.syncfs(e,r,s)})},mount:(e,r,t)=>{var n,o="/"===t,i=!t;if(o&&k.root)throw new k.ErrnoError(10);if(!o&&!i){i=k.lookupPath(t,{follow_mount:!1});if(t=i.path,n=i.node,k.isMountpoint(n))throw new k.ErrnoError(10);if(!k.isDir(n.mode))throw new k.ErrnoError(54)}i={type:e,opts:r,mountpoint:t,mounts:[]},r=e.mount(i);return(r.mount=i).root=r,o?k.root=r:n&&(n.mounted=i,n.mount&&n.mount.mounts.push(i)),r},unmount:e=>{e=k.lookupPath(e,{follow_mount:!1});if(!k.isMountpoint(e.node))throw new k.ErrnoError(28);var e=e.node,r=e.mounted,n=k.getMounts(r),r=(Object.keys(k.nameTable).forEach(e=>{for(var r=k.nameTable[e];r;){var t=r.name_next;n.includes(r.mount)&&k.destroyNode(r),r=t}}),e.mounted=null,e.mount.mounts.indexOf(r));e.mount.mounts.splice(r,1)},lookup:(e,r)=>e.node_ops.lookup(e,r),mknod:(e,r,t)=>{var n=k.lookupPath(e,{parent:!0}).node,e=b.basename(e);if(!e||"."===e||".."===e)throw new k.ErrnoError(28);var o=k.mayCreate(n,e);if(o)throw new k.ErrnoError(o);if(n.node_ops.mknod)return n.node_ops.mknod(n,e,r,t);throw new k.ErrnoError(63)},create:(e,r)=>k.mknod(e,r=(r=void 0!==r?r:438)&4095|32768,0),mkdir:(e,r)=>k.mknod(e,r=(r=void 0!==r?r:511)&1023|16384,0),mkdirTree:(e,r)=>{for(var t=e.split("/"),n="",o=0;o(void 0===t&&(t=r,r=438),k.mknod(e,r|=8192,t)),symlink:(e,r)=>{if(!E.resolve(e))throw new k.ErrnoError(44);var t=k.lookupPath(r,{parent:!0}).node;if(!t)throw new k.ErrnoError(44);var r=b.basename(r),n=k.mayCreate(t,r);if(n)throw new k.ErrnoError(n);if(t.node_ops.symlink)return t.node_ops.symlink(t,r,e);throw new k.ErrnoError(63)},rename:(e,r)=>{var t=b.dirname(e),n=b.dirname(r),o=b.basename(e),i=b.basename(r),s=k.lookupPath(e,{parent:!0}).node,a=k.lookupPath(r,{parent:!0}).node;if(!s||!a)throw new k.ErrnoError(44);if(s.mount!==a.mount)throw new k.ErrnoError(75);var u,l=k.lookupNode(s,o);if("."!==E.relative(e,n).charAt(0))throw new k.ErrnoError(28);if("."!==E.relative(r,t).charAt(0))throw new k.ErrnoError(55);try{u=k.lookupNode(a,i)}catch(e){}if(l!==u){n=k.isDir(l.mode),r=k.mayDelete(s,o,n);if(r)throw new k.ErrnoError(r);if(r=u?k.mayDelete(a,i,n):k.mayCreate(a,i))throw new k.ErrnoError(r);if(!s.node_ops.rename)throw new k.ErrnoError(63);if(k.isMountpoint(l)||u&&k.isMountpoint(u))throw new k.ErrnoError(10);if(a!==s&&(r=k.nodePermissions(s,"w")))throw new k.ErrnoError(r);k.hashRemoveNode(l);try{s.node_ops.rename(l,a,i)}catch(e){throw e}finally{k.hashAddNode(l)}}},rmdir:e=>{var r=k.lookupPath(e,{parent:!0}).node,e=b.basename(e),t=k.lookupNode(r,e),n=k.mayDelete(r,e,!0);if(n)throw new k.ErrnoError(n);if(!r.node_ops.rmdir)throw new k.ErrnoError(63);if(k.isMountpoint(t))throw new k.ErrnoError(10);r.node_ops.rmdir(r,e),k.destroyNode(t)},readdir:e=>{e=k.lookupPath(e,{follow:!0}).node;if(e.node_ops.readdir)return e.node_ops.readdir(e);throw new k.ErrnoError(54)},unlink:e=>{var r=k.lookupPath(e,{parent:!0}).node;if(!r)throw new k.ErrnoError(44);var e=b.basename(e),t=k.lookupNode(r,e),n=k.mayDelete(r,e,!1);if(n)throw new k.ErrnoError(n);if(!r.node_ops.unlink)throw new k.ErrnoError(63);if(k.isMountpoint(t))throw new k.ErrnoError(10);r.node_ops.unlink(r,e),k.destroyNode(t)},readlink:e=>{e=k.lookupPath(e).node;if(!e)throw new k.ErrnoError(44);if(e.node_ops.readlink)return E.resolve(k.getPath(e.parent),e.node_ops.readlink(e));throw new k.ErrnoError(28)},stat:(e,r)=>{e=k.lookupPath(e,{follow:!r}).node;if(!e)throw new k.ErrnoError(44);if(e.node_ops.getattr)return e.node_ops.getattr(e);throw new k.ErrnoError(63)},lstat:e=>k.stat(e,!0),chmod:(e,r,t)=>{t="string"==typeof e?k.lookupPath(e,{follow:!t}).node:e;if(!t.node_ops.setattr)throw new k.ErrnoError(63);t.node_ops.setattr(t,{mode:4095&r|-4096&t.mode,timestamp:Date.now()})},lchmod:(e,r)=>{k.chmod(e,r,!0)},fchmod:(e,r)=>{e=k.getStream(e);if(!e)throw new k.ErrnoError(8);k.chmod(e.node,r)},chown:(e,r,t,n)=>{n="string"==typeof e?k.lookupPath(e,{follow:!n}).node:e;if(!n.node_ops.setattr)throw new k.ErrnoError(63);n.node_ops.setattr(n,{timestamp:Date.now()})},lchown:(e,r,t)=>{k.chown(e,r,t,!0)},fchown:(e,r,t)=>{e=k.getStream(e);if(!e)throw new k.ErrnoError(8);k.chown(e.node,r,t)},truncate:(e,r)=>{if(r<0)throw new k.ErrnoError(28);e="string"==typeof e?k.lookupPath(e,{follow:!0}).node:e;if(!e.node_ops.setattr)throw new k.ErrnoError(63);if(k.isDir(e.mode))throw new k.ErrnoError(31);if(!k.isFile(e.mode))throw new k.ErrnoError(28);var t=k.nodePermissions(e,"w");if(t)throw new k.ErrnoError(t);e.node_ops.setattr(e,{size:r,timestamp:Date.now()})},ftruncate:(e,r)=>{e=k.getStream(e);if(!e)throw new k.ErrnoError(8);if(0==(2097155&e.flags))throw new k.ErrnoError(28);k.truncate(e.node,r)},utime:(e,r,t)=>{e=k.lookupPath(e,{follow:!0}).node;e.node_ops.setattr(e,{timestamp:Math.max(r,t)})},open:(e,r,t)=>{if(""===e)throw new k.ErrnoError(44);var n;if(t=void 0===t?438:t,t=64&(r="string"==typeof r?k.modeStringToFlags(r):r)?4095&t|32768:0,"object"==typeof e)n=e;else{e=b.normalize(e);try{n=k.lookupPath(e,{follow:!(131072&r)}).node}catch(e){}}var o=!1;if(64&r)if(n){if(128&r)throw new k.ErrnoError(20)}else n=k.mknod(e,t,0),o=!0;if(!n)throw new k.ErrnoError(44);if(k.isChrdev(n.mode)&&(r&=-513),65536&r&&!k.isDir(n.mode))throw new k.ErrnoError(54);if(!o){t=k.mayOpen(n,r);if(t)throw new k.ErrnoError(t)}512&r&&!o&&k.truncate(n,0),r&=-131713;t=k.createStream({node:n,path:k.getPath(n),flags:r,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return t.stream_ops.open&&t.stream_ops.open(t),!y.logReadFiles||1&r||(k.readFiles||(k.readFiles={}),e in k.readFiles||(k.readFiles[e]=1)),t},close:e=>{if(k.isClosed(e))throw new k.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{k.closeStream(e.fd)}e.fd=null},isClosed:e=>null===e.fd,llseek:(e,r,t)=>{if(k.isClosed(e))throw new k.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new k.ErrnoError(70);if(0!=t&&1!=t&&2!=t)throw new k.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read:(e,r,t,n,o)=>{if(n<0||o<0)throw new k.ErrnoError(28);if(k.isClosed(e))throw new k.ErrnoError(8);if(1==(2097155&e.flags))throw new k.ErrnoError(8);if(k.isDir(e.node.mode))throw new k.ErrnoError(31);if(!e.stream_ops.read)throw new k.ErrnoError(28);var i=void 0!==o;if(i){if(!e.seekable)throw new k.ErrnoError(70)}else o=e.position;r=e.stream_ops.read(e,r,t,n,o);return i||(e.position+=r),r},write:(e,r,t,n,o,i)=>{if(n<0||o<0)throw new k.ErrnoError(28);if(k.isClosed(e))throw new k.ErrnoError(8);if(0==(2097155&e.flags))throw new k.ErrnoError(8);if(k.isDir(e.node.mode))throw new k.ErrnoError(31);if(!e.stream_ops.write)throw new k.ErrnoError(28);e.seekable&&1024&e.flags&&k.llseek(e,0,2);var s=void 0!==o;if(s){if(!e.seekable)throw new k.ErrnoError(70)}else o=e.position;r=e.stream_ops.write(e,r,t,n,o,i);return s||(e.position+=r),r},allocate:(e,r,t)=>{if(k.isClosed(e))throw new k.ErrnoError(8);if(r<0||t<=0)throw new k.ErrnoError(28);if(0==(2097155&e.flags))throw new k.ErrnoError(8);if(!k.isFile(e.node.mode)&&!k.isDir(e.node.mode))throw new k.ErrnoError(43);if(!e.stream_ops.allocate)throw new k.ErrnoError(138);e.stream_ops.allocate(e,r,t)},mmap:(e,r,t,n,o)=>{if(0!=(2&n)&&0==(2&o)&&2!=(2097155&e.flags))throw new k.ErrnoError(2);if(1==(2097155&e.flags))throw new k.ErrnoError(2);if(e.stream_ops.mmap)return e.stream_ops.mmap(e,r,t,n,o);throw new k.ErrnoError(43)},msync:(e,r,t,n,o)=>e&&e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,o):0,munmap:e=>0,ioctl:(e,r,t)=>{if(e.stream_ops.ioctl)return e.stream_ops.ioctl(e,r,t);throw new k.ErrnoError(59)},readFile:function(e){let r=1k.currentPath,chdir:e=>{e=k.lookupPath(e,{follow:!0});if(null===e.node)throw new k.ErrnoError(44);if(!k.isDir(e.node.mode))throw new k.ErrnoError(54);var r=k.nodePermissions(e.node,"x");if(r)throw new k.ErrnoError(r);k.currentPath=e.path},createDefaultDirectories:()=>{k.mkdir("/tmp"),k.mkdir("/home"),k.mkdir("/home/web_user")},createDefaultDevices:()=>{k.mkdir("/dev"),k.registerDevice(k.makedev(1,3),{read:()=>0,write:(e,r,t,n,o)=>n}),k.mkdev("/dev/null",k.makedev(1,3)),o.register(k.makedev(5,0),o.default_tty_ops),o.register(k.makedev(6,0),o.default_tty1_ops),k.mkdev("/dev/tty",k.makedev(5,0)),k.mkdev("/dev/tty1",k.makedev(6,0));var e=function(){var e;if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues)return e=new Uint8Array(1),()=>(crypto.getRandomValues(e),e[0]);if(H)try{var r=Ar.default;return()=>r.randomBytes(1)[0]}catch(e){}return()=>v("randomDevice")}();k.createDevice("/dev","random",e),k.createDevice("/dev","urandom",e),k.mkdir("/dev/shm"),k.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{k.mkdir("/proc");var r=k.mkdir("/proc/self");k.mkdir("/proc/self/fd"),k.mount({mount:()=>{var e=k.createNode(r,"fd",16895,73);return e.node_ops={lookup:(e,r)=>{var t=k.getStream(+r);if(!t)throw new k.ErrnoError(8);r={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>t.path}};return r.parent=r}},e}},{},"/proc/self/fd")},createStandardStreams:()=>{y.stdin?k.createDevice("/dev","stdin",y.stdin):k.symlink("/dev/tty","/dev/stdin"),y.stdout?k.createDevice("/dev","stdout",null,y.stdout):k.symlink("/dev/tty","/dev/stdout"),y.stderr?k.createDevice("/dev","stderr",null,y.stderr):k.symlink("/dev/tty1","/dev/stderr"),k.open("/dev/stdin",0),k.open("/dev/stdout",1),k.open("/dev/stderr",1)},ensureErrnoError:()=>{k.ErrnoError||(k.ErrnoError=function(e,r){this.node=r,this.setErrno=function(e){this.errno=e},this.setErrno(e),this.message="FS error"},k.ErrnoError.prototype=new Error,k.ErrnoError.prototype.constructor=k.ErrnoError,[44].forEach(e=>{k.genericErrors[e]=new k.ErrnoError(e),k.genericErrors[e].stack=""}))},staticInit:()=>{k.ensureErrnoError(),k.nameTable=new Array(4096),k.mount(_,{},"/"),k.createDefaultDirectories(),k.createDefaultDevices(),k.createSpecialDirectories(),k.filesystems={MEMFS:_}},init:(e,r,t)=>{k.init.initialized=!0,k.ensureErrnoError(),y.stdin=e||y.stdin,y.stdout=r||y.stdout,y.stderr=t||y.stderr,k.createStandardStreams()},quit:()=>{k.init.initialized=!1;for(var e=0;e{var t=0;return e&&(t|=365),r&&(t|=146),t},findObject:(e,r)=>{e=k.analyzePath(e,r);return e.exists?e.object:null},analyzePath:(e,r)=>{try{e=(n=k.lookupPath(e,{follow:!r})).path}catch(e){}var t={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var n=k.lookupPath(e,{parent:!0});t.parentExists=!0,t.parentPath=n.path,t.parentObject=n.node,t.name=b.basename(e),n=k.lookupPath(e,{follow:!r}),t.exists=!0,t.path=n.path,t.object=n.node,t.name=n.node.name,t.isRoot="/"===n.path}catch(e){t.error=e.errno}return t},createPath:(e,r,t,n)=>{e="string"==typeof e?e:k.getPath(e);for(var o=r.split("/").reverse();o.length;){var i=o.pop();if(i){var s=b.join2(e,i);try{k.mkdir(s)}catch(e){}e=s}}return s},createFile:(e,r,t,n,o)=>{e=b.join2("string"==typeof e?e:k.getPath(e),r),r=k.getMode(n,o);return k.create(e,r)},createDataFile:(e,r,t,n,o,i)=>{var s=r,r=(e&&(e="string"==typeof e?e:k.getPath(e),s=r?b.join2(e,r):e),k.getMode(n,o)),e=k.create(s,r);if(t){if("string"==typeof t){for(var a=new Array(t.length),u=0,l=t.length;u{var e=b.join2("string"==typeof e?e:k.getPath(e),r),r=k.getMode(!!u,!!s),t=(k.createDevice.major||(k.createDevice.major=64),k.makedev(k.createDevice.major++,0));return k.registerDevice(t,{open:e=>{e.seekable=!1},close:e=>{s&&s.buffer&&s.buffer.length&&s(10)},read:(e,r,t,n,o)=>{for(var i,s=0,a=0;a{for(var i=0;i{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(!r)throw new Error("Cannot load without read() or XMLHttpRequest.");try{e.contents=pe(r(e.url),!0),e.usedBytes=e.contents.length}catch(e){throw new k.ErrnoError(29)}},createLazyFile:(e,r,s,t,n)=>{function o(){this.lengthKnown=!1,this.chunks=[]}if(o.prototype.get=function(e){var r;if(!(e>this.length-1||e<0))return r=e%this.chunkSize,e=e/this.chunkSize|0,this.getter(e)[r]},o.prototype.setDataGetter=function(e){this.getter=e},o.prototype.cacheLength=function(){var e=new XMLHttpRequest;if(e.open("HEAD",s,!1),e.send(null),!(200<=e.status&&e.status<300||304===e.status))throw new Error("Couldn't load "+s+". Status: "+e.status);var r,n=Number(e.getResponseHeader("Content-length")),t=(r=e.getResponseHeader("Accept-Ranges"))&&"bytes"===r,e=(r=e.getResponseHeader("Content-Encoding"))&&"gzip"===r,o=1048576,i=(t||(o=n),this);i.setDataGetter(e=>{var r=e*o,t=(e+1)*o-1,t=Math.min(t,n-1);if(void 0===i.chunks[e]&&(i.chunks[e]=((e,r)=>{if(r=i.length)return 0;var s=Math.min(i.length-o,n);if(i.slice)for(var a=0;a{var r=a.stream_ops[e];u[e]=function(){return k.forceLoadFile(a),r.apply(null,arguments)}}),u.read=(e,r,t,n,o)=>(k.forceLoadFile(a),l(e,r,t,n,o)),u.mmap=(e,r,t,n,o)=>{k.forceLoadFile(a);var i=he(r);if(i)return l(e,d,i,r,t),{ptr:i,allocated:!0};throw new k.ErrnoError(48)},a.stream_ops=u,a},createPreloadedFile:(t,n,e,o,i,s,a,u,l,c)=>{var r,d,f,p=n?E.resolve(b.join2(t,n)):t;function h(e){function r(e){c&&c(),u||k.createDataFile(t,n,e,o,i,l),s&&s(),ae()}Browser.handledByPreloadPlugin(e,p,r,()=>{a&&a(),ae()})||r(e)}se(),"string"==typeof e?(d=a,f="al "+(r=e),m(r,e=>{G(e,'Loading data file "'+r+'" failed (no arrayBuffer).'),h(new Uint8Array(e)),f&&ae()},e=>{if(!d)throw'Loading data file "'+r+'" failed.';d()}),f&&se()):h(e)},indexedDB:()=>window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,DB_NAME:()=>"EM_FS_"+window.location.pathname,DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:(s,a,u)=>{a=a||(()=>{}),u=u||(()=>{});var e=k.indexedDB();try{var l=e.open(k.DB_NAME(),k.DB_VERSION)}catch(s){return u(s)}l.onupgradeneeded=()=>{q("creating db"),l.result.createObjectStore(k.DB_STORE_NAME)},l.onsuccess=()=>{var e=l.result.transaction([k.DB_STORE_NAME],"readwrite"),r=e.objectStore(k.DB_STORE_NAME),t=0,n=0,o=s.length;function i(){(0==n?a:u)()}s.forEach(e=>{e=r.put(k.analyzePath(e).object.contents,e);e.onsuccess=()=>{++t+n==o&&i()},e.onerror=()=>{t+ ++n==o&&i()}}),e.onerror=u},l.onerror=u},loadFilesFromDB:(a,u,l)=>{u=u||(()=>{}),l=l||(()=>{});var e=k.indexedDB();try{var c=e.open(k.DB_NAME(),k.DB_VERSION)}catch(a){return l(a)}c.onupgradeneeded=l,c.onsuccess=()=>{var e=c.result;try{var r=e.transaction([k.DB_STORE_NAME],"readonly")}catch(e){return void l(e)}var t=r.objectStore(k.DB_STORE_NAME),n=0,o=0,i=a.length;function s(){(0==o?u:l)()}a.forEach(e=>{var r=t.get(e);r.onsuccess=()=>{k.analyzePath(e).exists&&k.unlink(e),k.createDataFile(b.dirname(e),b.basename(e),r.result,!0,!0,!0),++n+o==i&&s()},r.onerror=()=>{n+ ++o==i&&s()}}),r.onerror=l},c.onerror=l}},S={DEFAULT_POLLMASK:5,calculateAt:function(e,r,t){if(b.isAbs(r))return r;var n;if(-100===e)n=k.cwd();else{e=k.getStream(e);if(!e)throw new k.ErrnoError(8);n=e.path}if(0!=r.length)return b.join2(n,r);if(t)return n;throw new k.ErrnoError(44)},doStat:function(e,r,t){try{var n=e(r)}catch(e){if(e&&e.node&&b.normalize(r)!==b.normalize(k.getPath(e.node)))return-54;throw e}return l[t>>2]=n.dev,l[t+4>>2]=0,l[t+8>>2]=n.ino,l[t+12>>2]=n.mode,l[t+16>>2]=n.nlink,l[t+20>>2]=n.uid,l[t+24>>2]=n.gid,l[t+28>>2]=n.rdev,l[t+32>>2]=0,w=[n.size>>>0,(g=n.size,1<=+Math.abs(g)?0>>0:~~+Math.ceil((g-(~~g>>>0))/4294967296)>>>0:0)],l[t+40>>2]=w[0],l[t+44>>2]=w[1],l[t+48>>2]=4096,l[t+52>>2]=n.blocks,w=[Math.floor(n.atime.getTime()/1e3)>>>0,(g=Math.floor(n.atime.getTime()/1e3),1<=+Math.abs(g)?0>>0:~~+Math.ceil((g-(~~g>>>0))/4294967296)>>>0:0)],l[t+56>>2]=w[0],l[t+60>>2]=w[1],l[t+64>>2]=0,w=[Math.floor(n.mtime.getTime()/1e3)>>>0,(g=Math.floor(n.mtime.getTime()/1e3),1<=+Math.abs(g)?0>>0:~~+Math.ceil((g-(~~g>>>0))/4294967296)>>>0:0)],l[t+72>>2]=w[0],l[t+76>>2]=w[1],l[t+80>>2]=0,w=[Math.floor(n.ctime.getTime()/1e3)>>>0,(g=Math.floor(n.ctime.getTime()/1e3),1<=+Math.abs(g)?0>>0:~~+Math.ceil((g-(~~g>>>0))/4294967296)>>>0:0)],l[t+88>>2]=w[0],l[t+92>>2]=w[1],l[t+96>>2]=0,w=[n.ino>>>0,(g=n.ino,1<=+Math.abs(g)?0>>0:~~+Math.ceil((g-(~~g>>>0))/4294967296)>>>0:0)],l[t+104>>2]=w[0],l[t+108>>2]=w[1],0},doMsync:function(e,r,t,n,o){e=f.slice(e,e+t);k.msync(r,e,o,t,n)},varargs:void 0,get:function(){return S.varargs+=4,l[S.varargs-4>>2]},getStr:function(e){return ee(e)},getStreamFromFD:function(e){e=k.getStream(e);if(e)return e;throw new k.ErrnoError(8)}};function me(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+e)}}var ye=void 0;function P(e){for(var r="",t=e;f[t];)r+=ye[f[t++]];return r}var A={},T={},ge={};function we(e){if(void 0===e)return"_unknown";var r=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return 48<=r&&r<=57?"_"+e:e}function ve(e,r){return e=we(e),new Function("body","return function "+e+'() {\n "use strict"; return body.apply(this, arguments);\n};\n')(r)}function be(e,r){var t=ve(r,function(e){this.name=r,this.message=e;e=new Error(e).stack;void 0!==e&&(this.stack=this.toString()+"\n"+e.replace(/^Error(:[^\n]*)?\n/,""))});return t.prototype=Object.create(e.prototype),(t.prototype.constructor=t).prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message},t}var D=void 0;function F(e){throw new D(e)}var Ee=void 0;function _e(e){throw new Ee(e)}function ke(n,r,o){function t(e){var r=o(e);r.length!==n.length&&_e("Mismatched type converter count");for(var t=0;t{T.hasOwnProperty(e)?i[r]=T[e]:(s.push(e),A.hasOwnProperty(e)||(A[e]=[]),A[e].push(()=>{i[r]=T[e],++a===s.length&&t(i)}))}),0===s.length&&t(i)}function C(e,r,t){t=2e()))}function Se(e){F(e.$$.ptrType.registeredClass.name+" instance already deleted")}var Pe=!1;function Ae(e){}function Te(e){--e.count.value,0===e.count.value&&((e=e).smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr))}var De={};var Fe=[];function Ce(){for(;Fe.length;){var e=Fe.pop();e.$$.deleteScheduled=!1,e.delete()}}var Me=void 0;var $e={};function Re(e,r){return r.ptrType&&r.ptr||_e("makeClassHandle requires ptr and ptrType"),!!r.smartPtrType!=!!r.smartPtr&&_e("Both smartPtrType and smartPtr must be specified"),r.count={value:1},Oe(Object.create(e,{$$:{value:r}}))}function Oe(e){return"undefined"==typeof FinalizationRegistry?(Oe=e=>e,e):(Pe=new FinalizationRegistry(e=>{Te(e.$$)}),Ae=e=>Pe.unregister(e),(Oe=e=>{var r=e.$$;return r.smartPtr&&Pe.register(e,{$$:r},e),e})(e))}function M(){}function je(e,r,t){var n;void 0===e[r].overloadTable&&(n=e[r],e[r]=function(){return e[r].overloadTable.hasOwnProperty(arguments.length)||F("Function '"+t+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+e[r].overloadTable+")!"),e[r].overloadTable[arguments.length].apply(this,arguments)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n)}function xe(e,r,t,n,o,i,s,a){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=o,this.getActualType=i,this.upcast=s,this.downcast=a,this.pureVirtualFunctions=[]}function Ue(e,r,t){for(;r!==t;)r.upcast||F("Expected null or instance of "+t.name+", got an instance of "+r.name),e=r.upcast(e),r=r.baseClass;return e}function Be(e,r){if(null===r)return this.isReference&&F("null is not a valid "+this.name),0;r.$$||F('Cannot pass "'+er(r)+'" as a '+this.name),r.$$.ptr||F("Cannot pass deleted object as a pointer of type "+this.name);var t=r.$$.ptrType.registeredClass;return Ue(r.$$.ptr,t,this.registeredClass)}function We(e,r){if(null===r)return this.isReference&&F("null is not a valid "+this.name),this.isSmartPointer?(n=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,n),n):0;r.$$||F('Cannot pass "'+er(r)+'" as a '+this.name),r.$$.ptr||F("Cannot pass deleted object as a pointer of type "+this.name),!this.isConst&&r.$$.ptrType.isConst&&F("Cannot convert argument of type "+(r.$$.smartPtrType||r.$$.ptrType).name+" to parameter type "+this.name);var t,n,o=r.$$.ptrType.registeredClass;if(n=Ue(r.$$.ptr,o,this.registeredClass),this.isSmartPointer)switch(void 0===r.$$.smartPtr&&F("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?n=r.$$.smartPtr:F("Cannot convert argument of type "+(r.$$.smartPtrType||r.$$.ptrType).name+" to parameter type "+this.name);break;case 1:n=r.$$.smartPtr;break;case 2:r.$$.smartPtrType===this?n=r.$$.smartPtr:(t=r.clone(),n=this.rawShare(n,Ye.toHandle(function(){t.delete()})),null!==e&&e.push(this.rawDestructor,n));break;default:F("Unsupporting sharing policy")}return n}function ze(e,r){if(null===r)return this.isReference&&F("null is not a valid "+this.name),0;r.$$||F('Cannot pass "'+er(r)+'" as a '+this.name),r.$$.ptr||F("Cannot pass deleted object as a pointer of type "+this.name),r.$$.ptrType.isConst&&F("Cannot convert argument of type "+r.$$.ptrType.name+" to parameter type "+this.name);var t=r.$$.ptrType.registeredClass;return Ue(r.$$.ptr,t,this.registeredClass)}function Ie(e){return this.fromWireType(l[e>>2])}function $(e,r,t,n,o,i,s,a,u,l,c){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=o,this.pointeeType=i,this.sharingPolicy=s,this.rawGetPointee=a,this.rawConstructor=u,this.rawShare=l,this.rawDestructor=c,o||void 0!==r.baseClass?this.toWireType=We:(this.toWireType=n?Be:ze,this.destructorFunction=null)}var Le=[];function Ne(e){var r=Le[e];return r||(e>=Le.length&&(Le.length=e+1),Le[e]=r=Q.get(e)),r}function R(e,r){var o,i,s,t=(e=P(e)).includes("j")?(o=e,i=r,s=[],function(){return s.length=0,Object.assign(s,arguments),r=i,t=s,(e=o).includes("j")?(n=r,e=y["dynCall_"+e],t&&t.length?e.apply(null,[n].concat(t)):e.call(null,n)):Ne(r).apply(null,t);var e,r,t,n}):Ne(r);return"function"!=typeof t&&F("unknown function pointer with signature "+e+": "+r),t}var He=void 0;function qe(e){var e=wr(e),r=P(e);return j(e),r}function Ve(e,r){var t=[],n={};throw r.forEach(function e(r){n[r]||T[r]||(ge[r]?ge[r].forEach(e):(t.push(r),n[r]=!0))}),new He(e+": "+t.map(qe).join([", "]))}function Ge(e,r){for(var t=[],n=0;n>2]);return t}function Xe(e){for(;e.length;){var r=e.pop();e.pop()(r)}}function Je(e,r){if(!(e instanceof Function))throw new TypeError("new_ called with constructor type "+typeof e+" which is not a function");var t=ve(e.name||"unknownFunctionName",function(){}),t=(t.prototype=e.prototype,new t),e=e.apply(t,r);return e instanceof Object?e:t}function Ke(e,r,t,n,o){var i=r.length;i<2&&F("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var t=null!==r[1]&&null!==t,s=!1,a=1;a(e||F("Cannot use deleted val. handle = "+e),O[e].value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var r=Ze.length?Ze.pop():O.length;return O[r]={refcount:1,value:e},r}}};function er(e){if(null===e)return"null";var r=typeof e;return"object"==r||"array"==r||"function"==r?e.toString():""+e}var rr="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function tr(e,r){for(var t,n=e>>1,o=n+r/2;!(o<=n)&&J[n];)++n;if(32<(t=n<<1)-e&&rr)return rr.decode(f.subarray(e,t));for(var i="",s=0;!(r/2<=s);++s){var a=u[e+2*s>>1];if(0==a)break;i+=String.fromCharCode(a)}return i}function nr(e,r,t){if((t=void 0===t?2147483647:t)<2)return 0;for(var n=r,o=(t-=2)<2*e.length?t/2:e.length,i=0;i>1]=s,r+=2}return u[r>>1]=0,r-n}function or(e){return 2*e.length}function ir(e,r){for(var t=0,n="";!(r/4<=t);){var o,i=l[e+4*t>>2];if(0==i)break;++t,65536<=i?(o=i-65536,n+=String.fromCharCode(55296|o>>10,56320|1023&o)):n+=String.fromCharCode(i)}return n}function sr(e,r,t){if((t=void 0===t?2147483647:t)<4)return 0;for(var n=r,o=n+t-4,i=0;i>2]=s,(r+=4)+4>o)break}return l[r>>2]=0,r-n}function ar(e){for(var r=0,t=0;t>1]=2,0;case 16:case 8:default:return-28;case 9:return l[gr()>>2]=28,-1}}catch(e){if(void 0!==k&&e instanceof k.ErrnoError)return-e.errno;throw e}},w:function(e,r,t,n){S.varargs=n;try{r=S.getStr(r),r=S.calculateAt(e,r);var o=n?S.get():0;return k.open(r,t,o).fd}catch(e){if(void 0!==k&&e instanceof k.ErrnoError)return-e.errno;throw e}},u:function(e,r,t,n,o){},E:function(e,t,n,o,i){var s=me(n);C(e,{name:t=P(t),fromWireType:function(e){return!!e},toWireType:function(e,r){return r?o:i},argPackAdvance:8,readValueFromPointer:function(e){var r;if(1===n)r=d;else if(2===n)r=u;else{if(4!==n)throw new TypeError("Unknown boolean type size: "+t);r=l}return this.fromWireType(r[e>>s])},destructorFunction:null})},t:function(u,e,r,l,t,c,n,d,o,f,p,i,h){p=P(p),c=R(t,c),d=d&&R(n,d),f=f&&R(o,f),h=R(i,h);var s,m=we(p);t=m,n=function(){Ve("Cannot construct "+p+" due to unbound types",[l])},y.hasOwnProperty(t)?(F("Cannot register public name '"+t+"' twice"),je(y,t,t),y.hasOwnProperty(s)&&F("Cannot register multiple overloads of a function with the same number of arguments ("+s+")!"),y[t].overloadTable[s]=n):y[t]=n,ke([u,e,r],l?[l]:[],function(e){e=e[0],e=l?(s=e.registeredClass).instancePrototype:M.prototype;var r,t,n=ve(m,function(){if(Object.getPrototypeOf(this)!==o)throw new D("Use 'new' to construct "+p);if(void 0===i.constructor_body)throw new D(p+" has no accessible constructor");var e=i.constructor_body[arguments.length];if(void 0===e)throw new D("Tried to invoke ctor of "+p+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(i.constructor_body).toString()+") parameters instead!");return e.apply(this,arguments)}),o=Object.create(e,{constructor:{value:n}}),i=(n.prototype=o,new xe(p,n,o,h,s,c,d,f)),e=new $(p,i,!0,!1,!1),s=new $(p+"*",i,!1,!1,!1),a=new $(p+" const*",i,!1,!0,!1);return De[u]={pointerType:s,constPointerType:a},r=m,n=n,y.hasOwnProperty(r)||_e("Replacing nonexistant public symbol"),y[r].overloadTable,y[r]=n,y[r].argCount=t,[e,s,a]})},r:function(e,n,r,t,o,i){G(0{Ve("Cannot construct "+r.name+" due to unbound types",s)},ke([],s,function(e){return e.splice(1,0,null),r.registeredClass.constructor_body[n-1]=Ke(t,e,null,o,i),[]}),[]})},f:function(e,i,s,r,t,a,u,l){var c=Ge(s,r);i=P(i),a=R(t,a),ke([],[e],function(r){var t=(r=r[0]).name+"."+i;function e(){Ve("Cannot call "+t+" due to unbound types",c)}i.startsWith("@@")&&(i=Symbol[i.substring(2)]),l&&r.registeredClass.pureVirtualFunctions.push(i);var n=r.registeredClass.instancePrototype,o=n[i];return void 0===o||void 0===o.overloadTable&&o.className!==r.name&&o.argCount===s-2?(e.argCount=s-2,e.className=r.name,n[i]=e):(je(n,i,t),n[i].overloadTable[s-2]=e),ke([],c,function(e){e=Ke(t,e,r,a,u);return void 0===n[i].overloadTable?(e.argCount=s-2,n[i]=e):n[i].overloadTable[s-2]=e,[]}),[]})},D:function(e,r){C(e,{name:r=P(r),fromWireType:function(e){var r=Ye.toValue(e);return Qe(e),r},toWireType:function(e,r){return Ye.toHandle(r)},argPackAdvance:8,readValueFromPointer:Ie,destructorFunction:null})},n:function(e,r,t){t=me(t);C(e,{name:r=P(r),fromWireType:function(e){return e},toWireType:function(e,r){return r},argPackAdvance:8,readValueFromPointer:function(e,r){switch(r){case 2:return function(e){return this.fromWireType(K[e>>2])};case 3:return function(e){return this.fromWireType(Z[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}(r,t),destructorFunction:null})},c:function(e,r,t,n,o){r=P(r);var i,s=me(t),a=e=>e,t=(0===n&&(i=32-8*t,a=e=>e<>>i),r.includes("unsigned"));C(e,{name:r,fromWireType:a,toWireType:t?function(e,r){return this.name,r>>>0}:function(e,r){return this.name,r},argPackAdvance:8,readValueFromPointer:function(e,r,t){switch(r){case 0:return t?function(e){return d[e]}:function(e){return f[e]};case 1:return t?function(e){return u[e>>1]}:function(e){return J[e>>1]};case 2:return t?function(e){return l[e>>2]}:function(e){return p[e>>2]};default:throw new TypeError("Unknown integer type: "+e)}}(r,s,0!==n),destructorFunction:null})},b:function(e,r,t){var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][r];function o(e){var r=p,t=r[e>>=2],r=r[e+1];return new n(X,r,t)}C(e,{name:t=P(t),fromWireType:o,argPackAdvance:8,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0})},m:function(e,r){var l="std::string"===(r=P(r));C(e,{name:r,fromWireType:function(e){var r,t=p[e>>2],n=e+4;if(l)for(var o=n,i=0;i<=t;++i){var s,a=n+i;i!=t&&0!=f[a]||(s=ee(o,a-o),void 0===r?r=s:r=r+String.fromCharCode(0)+s,o=a+1)}else{for(var u=new Array(t),i=0;i>2]=t,l&&n)re(r,f,i,t+1);else if(n)for(var s=0;sJ,d=1):4===u&&(l=ir,i=sr,s=ar,c=()=>p,d=2),C(e,{name:o,fromWireType:function(e){for(var r,t=p[e>>2],n=c(),o=e+4,i=0;i<=t;++i){var s,a=e+4+i*u;i!=t&&0!=n[a>>d]||(s=l(o,a-o),void 0===r?r=s:r=r+String.fromCharCode(0)+s,o=a+u)}return j(e),r},toWireType:function(e,r){"string"!=typeof r&&F("Cannot pass non-string to C++ string type "+o);var t=s(r),n=br(4+t+u);return p[n>>2]=t>>d,i(r,n+4,t+u),null!==e&&e.push(j,n),n},argPackAdvance:8,readValueFromPointer:Ie,destructorFunction:function(e){j(e)}})},o:function(e,r){C(e,{isVoid:!0,name:r=P(r),argPackAdvance:0,fromWireType:function(){},toWireType:function(e,r){}})},h:function(){return Date.now()},d:function(e,r,t,n){(e=lr[e])(r=Ye.toValue(r),t=void 0===(r=ur[e=t])?P(e):r,null,n)},j:Qe,e:function(e,r){var t=function(e,r){for(var t,n,o=new Array(e),i=0;i>2],void 0===(n=T[t])&&F("parameter "+i+" has unknown type "+qe(t)),n);return o}(e,r),r=t[0],n=r.name+"_$"+t.slice(1).map(function(e){return e.name}).join("_")+"$",o=cr[n];if(void 0!==o)return o;for(var i=["retType"],s=[r],a="",u=0;u>2]=t,e),o=t,i=0;i>0]=n.charCodeAt(i);d[o>>0]=0,u+=e.length+1}),0},z:function(e,r){var t=fr(),n=(p[e>>2]=t.length,0);return t.forEach(function(e){n+=e.length+1}),p[r>>2]=n,0},l:function(e){try{var r=S.getStreamFromFD(e);return k.close(r),0}catch(e){if(void 0!==k&&e instanceof k.ErrnoError)return e.errno;throw e}},x:function(e,r){try{var t=S.getStreamFromFD(e),n=t.tty?2:k.isDir(t.mode)?3:k.isLink(t.mode)?7:4;return d[r>>0]=n,0}catch(e){if(void 0!==k&&e instanceof k.ErrnoError)return e.errno;throw e}},B:function(e,r,t,n){try{var o=function(e,r,t){for(var n=0,o=0;o>2],s=p[r+4>>2],i=(r+=8,k.read(e,d,i,s,void 0));if(i<0)return-1;if(n+=i,i>2]=o,0}catch(e){if(void 0!==k&&e instanceof k.ErrnoError)return e.errno;throw e}},s:function(e,r,t,n,o){try{var i=t+2097152>>>0<4194305-!!r?(r>>>0)+4294967296*t:NaN;if(isNaN(i))return 61;var s=S.getStreamFromFD(e);return k.llseek(s,i,n),w=[s.position>>>0,(g=s.position,1<=+Math.abs(g)?0>>0:~~+Math.ceil((g-(~~g>>>0))/4294967296)>>>0:0)],l[o>>2]=w[0],l[o+4>>2]=w[1],s.getdents&&0===i&&0===n&&(s.getdents=null),0}catch(e){if(void 0!==k&&e instanceof k.ErrnoError)return e.errno;throw e}},k:function(e,r,t,n){try{var o=function(e,r,t){for(var n=0,o=0;o>2],s=p[r+4>>2],i=(r+=8,k.write(e,d,i,s,void 0));if(i<0)return-1;n+=i}return n}(S.getStreamFromFD(e),r,t);return p[n>>2]=o,0}catch(e){if(void 0!==k&&e instanceof k.ErrnoError)return e.errno;throw e}},g:function(e){}},j=(!function(){var r={a:yr};function t(e,r){var e=e.exports;y.asm=e,e=y.asm.F.buffer,X=e,y.HEAP8=d=new Int8Array(e),y.HEAP16=u=new Int16Array(e),y.HEAP32=l=new Int32Array(e),y.HEAPU8=f=new Uint8Array(e),y.HEAPU16=J=new Uint16Array(e),y.HEAPU32=p=new Uint32Array(e),y.HEAPF32=K=new Float32Array(e),y.HEAPF64=Z=new Float64Array(e),Q=y.asm.I,e=y.asm.G,oe.unshift(e),ae()}function n(e){t(e.instance)}function o(e){return function(){if(!i&&(N||c)){if("function"==typeof fetch&&!le(h))return fetch(h,{credentials:"same-origin"}).then(function(e){if(e.ok)return e.arrayBuffer();throw"failed to load wasm binary file at '"+h+"'"}).catch(function(){return ce(h)});if(m)return new Promise(function(r,e){m(h,function(e){r(new Uint8Array(e))},e)})}return Promise.resolve().then(function(){return ce(h)})}().then(function(e){return WebAssembly.instantiate(e,r)}).then(function(e){return e}).then(e,function(e){a("failed to asynchronously prepare wasm: "+e),v(e)})}if(se(),y.instantiateWasm)try{return y.instantiateWasm(r,t)}catch(r){return a("Module.instantiateWasm callback failed with error: "+r)}i||"function"!=typeof WebAssembly.instantiateStreaming||ue(h)||le(h)||H||"function"!=typeof fetch?o(n):fetch(h,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,r).then(n,function(e){return a("wasm streaming compile failed: "+e),a("falling back to ArrayBuffer instantiation"),o(n)})})}(),y.___wasm_call_ctors=function(){return(y.___wasm_call_ctors=y.asm.G).apply(null,arguments)},y._free=function(){return(j=y._free=y.asm.H).apply(null,arguments)}),gr=y.___errno_location=function(){return(gr=y.___errno_location=y.asm.J).apply(null,arguments)},wr=y.___getTypeName=function(){return(wr=y.___getTypeName=y.asm.K).apply(null,arguments)};y.___embind_register_native_and_builtin_types=function(){return(y.___embind_register_native_and_builtin_types=y.asm.L).apply(null,arguments)};var vr,br=y._malloc=function(){return(br=y._malloc=y.asm.M).apply(null,arguments)},Er=y._emscripten_builtin_memalign=function(){return(Er=y._emscripten_builtin_memalign=y.asm.N).apply(null,arguments)},_r=y.___cxa_is_pointer_type=function(){return(_r=y.___cxa_is_pointer_type=y.asm.O).apply(null,arguments)};function kr(){function e(){if(!vr&&(vr=!0,y.calledRun=!0,!V)){if(y.noFSInit||k.init.initialized||k.init(),k.ignorePermissions=!1,de(oe),y.onRuntimeInitialized&&y.onRuntimeInitialized(),y.postRun)for("function"==typeof y.postRun&&(y.postRun=[y.postRun]);y.postRun.length;)e=y.postRun.shift(),ie.unshift(e);var e;de(ie)}}if(!(0>4===k&&e[1]===u}function A(){return(performance&&"function"==typeof performance.now?performance:Date).now()}o(function(e){var s,r,a,t,n;s="undefined"!=typeof window&&void 0!==window.document?window.document:{},r=e.exports,a=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"]],t=0,n=r.length,o={};t{this.reject=e,this.resolve=e=>{delete this.lastReadPromise,delete this.resolve,delete this.need,r(e)},this.demand(t,!0)||null==(e=this.pull)||e.call(this,t)})},new(a=(a=s=void 0)||Promise)(function(t,r){function n(e){try{i(u.next(e))}catch(e){r(e)}}function o(e){try{i(u.throw(e))}catch(e){r(e)}}function i(e){var r;e.done?t(e.value):((r=e.value)instanceof a?r:new a(function(e){e(r)})).then(n,o)}i((u=u.apply(e,s||[])).next())});var e,s,a,u}readU32(){return this.read(c)}readU16(){return this.read(d)}readU8(){return this.read(f)}close(){var e;this.g&&this.g.return(),this.buffer&&this.buffer.subarray(0,0),null!=(e=this.reject)&&e.call(this,new Error("EOF")),delete this.lastReadPromise}flush(){if(this.buffer&&this.need){let e=null;const n=this.buffer.subarray(this.consumed);let r=0;var t=e=>n.length<(r=e);if("number"==typeof this.need){if(t(this.need))return;e=n.subarray(0,r)}else if(this.need===c){if(t(4))return;e=n[0]<<24|n[1]<<16|n[2]<<8|n[3]}else if(this.need===d){if(t(2))return;e=n[0]<<8|n[1]}else if(this.need===f){if(t(1))return;e=n[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(t(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(n.subarray(0,r)),e=this.need}else if(this.g)return void this.g.throw(new Error("Unsupported type"))}else{if(t(this.need.byteLength))return;new Uint8Array(this.need).set(n.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){var r=this.buffer.length,t=r+e;if(t<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,t);else{const e=new Uint8Array(t);e.set(this.buffer),this.buffer=e}return this.buffer.subarray(r,t)}return this.buffer=new Uint8Array(e),this.buffer}}T.U32=c,T.U16=d,T.U8=f;class D{constructor(i){this.log=function(e){if(i._opt.debug&&i._opt.debugLevel==s){for(var r=i._opt.debugUuid?`[${i._opt.debugUuid}]`:"",t=arguments.length,n=new Array(1{var e=function(){{var t=g;let r="";if("object"==typeof t)try{r=JSON.stringify(t),r=JSON.parse(r)}catch(e){r=t}else r=t;return r}}();return{debug:e.debug,debugLevel:e.debugLevel,sampleRate:0,audioBufferSize:1024,videoBuffer:e.videoBuffer}},h={isDestroyed:!1,_opt:e(),init:function(){h.debug.log("audio worker","init and opt is",h._opt),h.stopId=setInterval(()=>{var e=(new Date).getTime(),e=e-(r=r||e);100h._opt.videoBuffer)){h.delay<0&&h.debug.warn("audio worker",`loop() do not decode and delay is ${h.delay}, bufferList is `+t.length);break}t.shift(),h.doDecode(e)}else-1!==h.delay&&h.debug.log("audio worker","loop() bufferList is empty and reset delay"),h.resetAllDelay()}r=(new Date).getTime()},10)},doDecode:function(e){e.decoder.decode(e.payload,e.ts,e.isIFrame,e.cts)},getDelay:function(e){return e?(h.preDelayTimestamp&&h.preDelayTimestamp>e?1e3 timestamp is ${e} more than ${h.preDelayTimestamp-e}ms`):h.firstTimestamp?e&&(r=Date.now()-h.startTimestamp,t=e-h.firstTimestamp,h.delay=t<=r?r-t:t-r):(h.firstTimestamp=e,h.startTimestamp=Date.now(),h.delay=-1),h.preDelayTimestamp=e,h.delay):-1;var r,t},resetAllDelay:function(){h.firstTimestamp=null,h.startTimestamp=null,h.delay=-1,h.preDelayTimestamp=null},close:function(){h.debug.log("audio worker","close"),h.isDestroyed=!0,h.stopId&&(clearInterval(h.stopId),h.stopId=null),m&&(m.clear&&m.clear(),m=null),s=null,h._opt=e(),t=[],l=[],n(),a=null,i&&(i.close(1e3,"Client disconnecting"),i=null),h.resetAllDelay(),c=!1,d=[],f=0,p=0,postMessage({cmd:"closeEnd"})},fetchStream:function(e,r){h.debug.log("audio worker","fetchStream, url is "+e,"options:",JSON.stringify(r)),s=function(t){let n=0,o=A();return e=>{var r;"[object Number]"===Object.prototype.toString.call(e)&&(n+=e,1e3<=(r=(e=A())-o)&&(t(n/r*1e3),o=e,n=0))}}(e=>{postMessage({cmd:v,type:"streamRate",value:e})}),2===r.protocol?(a=new T(h.demuxFlv()),fetch(e,{signal:o.signal}).then(e=>{if(!(e.ok&&200<=e.status&&e.status<=299))return h.debug.warn("audio worker",`fetch response status is ${e.status} and ok is ${e.ok} and emit error and next abort()`),n(),void postMessage({cmd:v,type:_,value:`fetch response status is ${e.status} and ok is `+e.ok});if(postMessage({cmd:v,type:E}),"undefined"!=typeof WritableStream)e.body.pipeTo(new WritableStream({write:e=>{s(e.byteLength),a.write(e)},close:()=>{a=null,n(),postMessage({cmd:v,type:b,value:y})},abort:e=>{a=null,e.name!==S&&(n(),postMessage({cmd:v,type:_,value:e.toString()}))}}));else{const r=e.body.getReader(),t=()=>{r.read().then(e=>{var{done:e,value:r}=e;if(e)return a=null,n(),void postMessage({cmd:v,type:b,value:y});s(r.byteLength),a.write(r),t()}).catch(e=>{a=null,e.name!==S&&(n(),postMessage({cmd:v,type:_,value:e.toString()}))})};t()}}).catch(e=>{e.name!==S&&(n(),postMessage({cmd:v,type:_,value:e.toString()}),a=null)})):1===r.protocol&&(r.isFlv&&(a=new T(h.demuxFlv())),(i=new WebSocket(e)).binaryType="arraybuffer",i.onopen=()=>{h.debug.log("audio worker","fetchStream, WebsocketStream socket open"),postMessage({cmd:v,type:E}),postMessage({cmd:v,type:"websocketOpen"})},i.onclose=e=>{h.debug.log("audio worker","fetchStream, WebsocketStream socket close and code is "+e.code),1006===e.code&&h.debug.warn("audio worker","fetchStream, WebsocketStream socket close abnormally and code is "+e.code),a=null,postMessage({cmd:v,type:b,value:"websocket"})},i.onerror=e=>{h.debug.error("audio worker","fetchStream, WebsocketStream socket error",e),a=null,postMessage({cmd:v,type:"websocketError",value:e.isTrusted?"websocket user aborted":"websocket error"})},i.onmessage=e=>{s(e.data.byteLength),r.isFlv?a.write(e.data):h.demuxM7s(e.data)})},demuxFlv:function*(){yield 9;const e=new ArrayBuffer(4),r=new Uint8Array(e),t=new Uint32Array(e);for(;;){r[3]=0;const e=yield 15,i=e[4];r[0]=e[7],r[1]=e[6],r[2]=e[5];var n=t[0],o=(r[0]=e[10],r[1]=e[9],r[2]=e[8],r[3]=e[11],t[0]),n=(yield n).slice();8===i&&h.decode(n,{type:1,ts:o})}},decode:function(e,r){postMessage({cmd:v,type:"streamAbps",value:e.byteLength}),h.pushBuffer(e,r.ts)},setCodecAudio:function(e){var r=e[0]>>4;if(P(e)||7==r||8==r){h.debug.log("audio worker","setCodecAudio: init audio codec, codeId is "+r);e=r===k?e.slice(2):e.slice(1);m.setCodec(r,h._opt.sampleRate,e),c=!0;{const e=Number("1")||1;setTimeout(()=>{h.close(),postMessage({cmd:"workerEnd"})},60*e*60*1e3)}}else h.debug.warn("audio worker","setCodecAudio: hasInitAudioCodec is false, codecId is ",r)},pushBuffer:function(e,r){P(e)?h.decodeAudio(e,r):t.push({ts:r,payload:e,decoder:{decode:h.decodeAudio},isIFrame:!1})},decodeAudio:function(e,r){var t=e[0]>>4;c?m.decode(t===k?e.slice(2):e.slice(1),r):h.setCodecAudio(e)},demuxM7s:function(e){const r=new DataView(e),t=r.getUint32(1,!1);1===r.getUint8(0)&&h.decode(new Uint8Array(e,5),{type:1,ts:t})},audioInfo:function(e,r,t){postMessage({cmd:"audioCode",code:e}),postMessage({cmd:"initAudio",sampleRate:r,channels:t}),p=t},pcmData:function(o,i,s){if(h.isDestroyed)h.debug.log("audio worker","pcmData, decoder is destroyed and return");else{let r=i,t=[],e=0,n=h._opt.audioBufferSize;for(let e=0;e<2;e++){var a=u.HEAPU32[(o>>2)+e]>>2;t[e]=u.HEAPF32.subarray(a,a+r)}if(f){if(!(r>=(i=n-f)))return f+=r,l[0]=Float32Array.of(...l[0],...t[0]),void(2==p&&(l[1]=Float32Array.of(...l[1],...t[1])));d[0]=Float32Array.of(...l[0],...t[0].subarray(0,i)),2==p&&(d[1]=Float32Array.of(...l[1],...t[1].subarray(0,i))),postMessage({cmd:w,buffer:d,delay:h.delay,ts:s},d.map(e=>e.buffer)),e=i,r-=i}for(f=r;f>=n;f-=n)d[0]=t[0].slice(e,e+=n),2==p&&(d[1]=t[1].slice(e-n,e)),postMessage({cmd:w,buffer:d,delay:h.delay,ts:s},d.map(e=>e.buffer));f&&(l[0]=t[0].slice(e),2==p&&(l[1]=t[1].slice(e)))}},sendWebsocketMessage:function(e){i?1===i.readyState?i.send(e):h.debug.error("audio worker","socket is not open"):h.debug.error("audio worker","socket is null")},timeEnd:function(){}},m=(h.debug=new D(h),null);u.AudioDecoder&&(m=new u.AudioDecoder(h)),postMessage({cmd:"init"}),self.onmessage=function(e){var r=e.data;switch(r.cmd){case"init":try{h._opt=Object.assign(h._opt,JSON.parse(r.opt))}catch(e){}h.init();break;case"fetchStream":h.fetchStream(r.url,JSON.parse(r.opt));break;case"close":h.close();break;case"updateConfig":h.debug.log("audio worker","updateConfig",r.key,r.value),h._opt[r.key]=r.value;break;case"sendWsMessage":h.sendWebsocketMessage(r.message)}}}Date.now||(Date.now=function(){return(new Date).getTime()}),i.postRun=function(){p(i)}});