@jlongster/sql.js
Version:
SQLite library with support for opening and writing databases, prepared statements, and more. This SQLite library is in pure javascript (compiled with emscripten).
170 lines (157 loc) • 69.9 kB
JavaScript
// We are modularizing this manually because the current modularize setting in Emscripten has some issues:
// https://github.com/kripken/emscripten/issues/5820
// In addition, When you use emcc's modularization, it still expects to export a global object called `Module`,
// which is able to be used/called before the WASM is loaded.
// The modularization below exports a promise that loads and resolves to the actual sql.js module.
// That way, this module can't be used before the WASM is finished loading.
// We are going to define a function that a user will call to start loading initializing our Sql.js library
// However, that function might be called multiple times, and on subsequent calls, we don't actually want it to instantiate a new instance of the Module
// Instead, we want to return the previously loaded module
// TODO: Make this not declare a global if used in the browser
var initSqlJsPromise = undefined;
var initSqlJs = function (moduleConfig) {
if (initSqlJsPromise){
return initSqlJsPromise;
}
// If we're here, we've never called this function before
initSqlJsPromise = new Promise(function (resolveModule, reject) {
// We are modularizing this manually because the current modularize setting in Emscripten has some issues:
// https://github.com/kripken/emscripten/issues/5820
// The way to affect the loading of emcc compiled modules is to create a variable called `Module` and add
// properties to it, like `preRun`, `postRun`, etc
// We are using that to get notified when the WASM has finished loading.
// Only then will we return our promise
// If they passed in a moduleConfig object, use that
// Otherwise, initialize Module to the empty object
var Module = typeof moduleConfig !== 'undefined' ? moduleConfig : {};
// EMCC only allows for a single onAbort function (not an array of functions)
// So if the user defined their own onAbort function, we remember it and call it
var originalOnAbortFunction = Module['onAbort'];
Module['onAbort'] = function (errorThatCausedAbort) {
reject(new Error(errorThatCausedAbort));
if (originalOnAbortFunction){
originalOnAbortFunction(errorThatCausedAbort);
}
};
Module['postRun'] = Module['postRun'] || [];
Module['postRun'].push(function () {
// When Emscripted calls postRun, this promise resolves with the built Module
resolveModule(Module);
});
// There is a section of code in the emcc-generated code below that looks like this:
// (Note that this is lowercase `module`)
// if (typeof module !== 'undefined') {
// module['exports'] = Module;
// }
// When that runs, it's going to overwrite our own modularization export efforts in shell-post.js!
// The only way to tell emcc not to emit it is to pass the MODULARIZE=1 or MODULARIZE_INSTANCE=1 flags,
// but that carries with it additional unnecessary baggage/bugs we don't want either.
// So, we have three options:
// 1) We undefine `module`
// 2) We remember what `module['exports']` was at the beginning of this function and we restore it later
// 3) We write a script to remove those lines of code as part of the Make process.
//
// Since those are the only lines of code that care about module, we will undefine it. It's the most straightforward
// of the options, and has the side effect of reducing emcc's efforts to modify the module if its output were to change in the future.
// That's a nice side effect since we're handling the modularization efforts ourselves
module = undefined;
// The emcc-generated code and shell-post.js code goes below,
// meaning that all of it runs inside of this promise. If anything throws an exception, our promise will abort
var Module;Module||(Module=typeof Module !== 'undefined' ? Module : {});null;
Module.onRuntimeInitialized=function(){function a(h,n){this.Qa=h;this.db=n;this.Pa=1;this.wb=[]}function b(h,n){this.db=n;n=d(h)+1;this.hb=aa(n);if(null===this.hb)throw Error("Unable to allocate memory for the SQL string");p(h,u,this.hb,n);this.sb=this.hb;this.eb=this.Mb=null}function c(h,{filename:n=!1}={}){!1===n?(this.filename="dbfile_"+(4294967295*Math.random()>>>0),this.Xc=!0,null!=h&&w.zb("/",this.filename,h,!0,!0)):this.filename=h;this.handleError(g(this.filename,e));this.db=z(e,"i32");Cb(this.db);
this.nb={};this.Xa={}}var e=C(4),f=Module.cwrap,g=f("sqlite3_open","number",["string","number"]),k=f("sqlite3_close_v2","number",["number"]),l=f("sqlite3_exec","number",["number","string","number","number","number"]),q=f("sqlite3_changes","number",["number"]),m=f("sqlite3_prepare_v2","number",["number","string","number","number","number"]),r=f("sqlite3_sql","string",["number"]),x=f("sqlite3_normalized_sql","string",["number"]),B=f("sqlite3_prepare_v2","number",["number","number","number","number",
"number"]),E=f("sqlite3_bind_text","number",["number","number","number","number","number"]),A=f("sqlite3_bind_blob","number",["number","number","number","number","number"]),J=f("sqlite3_bind_double","number",["number","number","number"]),Z=f("sqlite3_bind_int","number",["number","number","number"]),U=f("sqlite3_bind_parameter_index","number",["number","string"]),Ka=f("sqlite3_step","number",["number"]),G=f("sqlite3_errmsg","string",["number"]),Db=f("sqlite3_column_count","number",["number"]),Eb=f("sqlite3_data_count",
"number",["number"]),Fb=f("sqlite3_column_double","number",["number","number"]),Gb=f("sqlite3_column_text","string",["number","number"]),Hb=f("sqlite3_column_blob","number",["number","number"]),Ib=f("sqlite3_column_bytes","number",["number","number"]),Jb=f("sqlite3_column_type","number",["number","number"]),Kb=f("sqlite3_column_name","string",["number","number"]),Lb=f("sqlite3_reset","number",["number"]),Mb=f("sqlite3_clear_bindings","number",["number"]),Nb=f("sqlite3_finalize","number",["number"]),
Ob=f("sqlite3_create_function_v2","number","number string number number number number number number number".split(" ")),Pb=f("sqlite3_value_type","number",["number"]),Qb=f("sqlite3_value_bytes","number",["number"]),Rb=f("sqlite3_value_text","string",["number"]),Sb=f("sqlite3_value_blob","number",["number"]),Tb=f("sqlite3_value_double","number",["number"]),Ub=f("sqlite3_result_double","",["number","number"]),db=f("sqlite3_result_null","",["number"]),Vb=f("sqlite3_result_text","",["number","string",
"number","number"]),Wb=f("sqlite3_result_blob","",["number","number","number","number"]),Xb=f("sqlite3_result_int","",["number","number"]),eb=f("sqlite3_result_error","",["number","string","number"]),Cb=f("RegisterExtensionFunctions","number",["number"]);a.prototype.bind=function(h){if(!this.Qa)throw"Statement closed";this.reset();return Array.isArray(h)?this.vc(h):null!=h&&"object"===typeof h?this.wc(h):!0};a.prototype.step=function(){if(!this.Qa)throw"Statement closed";this.Pa=1;var h=Ka(this.Qa);
switch(h){case 100:return!0;case 101:return!1;default:throw this.db.handleError(h);}};a.prototype.Pc=function(h){null==h&&(h=this.Pa,this.Pa+=1);return Fb(this.Qa,h)};a.prototype.Qc=function(h){null==h&&(h=this.Pa,this.Pa+=1);return Gb(this.Qa,h)};a.prototype.getBlob=function(h){null==h&&(h=this.Pa,this.Pa+=1);var n=Ib(this.Qa,h);h=Hb(this.Qa,h);for(var t=new Uint8Array(n),v=0;v<n;v+=1)t[v]=D[h+v];return t};a.prototype.get=function(h){null!=h&&this.bind(h)&&this.step();h=[];for(var n=Eb(this.Qa),
t=0;t<n;t+=1)switch(Jb(this.Qa,t)){case 1:case 2:h.push(this.Pc(t));break;case 3:h.push(this.Qc(t));break;case 4:h.push(this.getBlob(t));break;default:h.push(null)}return h};a.prototype.getColumnNames=function(){for(var h=[],n=Db(this.Qa),t=0;t<n;t+=1)h.push(Kb(this.Qa,t));return h};a.prototype.getAsObject=function(h){h=this.get(h);for(var n=this.getColumnNames(),t={},v=0;v<n.length;v+=1)t[n[v]]=h[v];return t};a.prototype.getSQL=function(){return r(this.Qa)};a.prototype.getNormalizedSQL=function(){return x(this.Qa)};
a.prototype.run=function(h){null!=h&&this.bind(h);this.step();return this.reset()};a.prototype.zc=function(h,n){null==n&&(n=this.Pa,this.Pa+=1);h=ba(h);var t=ca(h);this.wb.push(t);this.db.handleError(E(this.Qa,n,t,h.length-1,0))};a.prototype.uc=function(h,n){null==n&&(n=this.Pa,this.Pa+=1);var t=ca(h);this.wb.push(t);this.db.handleError(A(this.Qa,n,t,h.length,0))};a.prototype.yc=function(h,n){null==n&&(n=this.Pa,this.Pa+=1);this.db.handleError((h===(h|0)?Z:J)(this.Qa,n,h))};a.prototype.xc=function(h){null==
h&&(h=this.Pa,this.Pa+=1);A(this.Qa,h,0,0,0)};a.prototype.Tb=function(h,n){null==n&&(n=this.Pa,this.Pa+=1);switch(typeof h){case "string":this.zc(h,n);return;case "number":case "boolean":this.yc(h+0,n);return;case "object":if(null===h){this.xc(n);return}if(null!=h.length){this.uc(h,n);return}}throw"Wrong API use : tried to bind a value of an unknown type ("+h+").";};a.prototype.wc=function(h){var n=this;Object.keys(h).forEach(function(t){var v=U(n.Qa,t);0!==v&&n.Tb(h[t],v)});return!0};a.prototype.vc=
function(h){for(var n=0;n<h.length;n+=1)this.Tb(h[n],n+1);return!0};a.prototype.reset=function(){return 0===Mb(this.Qa)&&0===Lb(this.Qa)};a.prototype.freemem=function(){for(var h;void 0!==(h=this.wb.pop());)da(h)};a.prototype.free=function(){var h=0===Nb(this.Qa);delete this.db.nb[this.Qa];this.Qa=0;return h};b.prototype.next=function(){if(null===this.hb)return{done:!0};null!==this.eb&&(this.eb.free(),this.eb=null);if(!this.db.db)throw this.Bb(),Error("Database closed");var h=ha(),n=C(4);ia(e);ia(n);
try{this.db.handleError(B(this.db.db,this.sb,-1,e,n));this.sb=z(n,"i32");var t=z(e,"i32");if(0===t)return this.Bb(),{done:!0};this.eb=new a(t,this.db);this.db.nb[t]=this.eb;return{value:this.eb,done:!1}}catch(v){throw this.Mb=F(this.sb),this.Bb(),v;}finally{ja(h)}};b.prototype.Bb=function(){da(this.hb);this.hb=null};b.prototype.getRemainingSQL=function(){return null!==this.Mb?this.Mb:F(this.sb)};"function"===typeof Symbol&&"symbol"===typeof Symbol.iterator&&(b.prototype[Symbol.iterator]=function(){return this});
c.prototype.run=function(h,n){if(!this.db)throw"Database closed";if(n){h=this.prepare(h,n);try{h.step()}finally{h.free()}}else this.handleError(l(this.db,h,0,0,e));return this};c.prototype.exec=function(h,n){if(!this.db)throw"Database closed";var t=ha(),v=null;try{var y=d(h)+1,N=C(y);p(h,D,N,y);var H=N;var ea=C(4);for(h=[];0!==z(H,"i8");){ia(e);ia(ea);this.handleError(B(this.db,H,-1,e,ea));var fa=z(e,"i32");H=z(ea,"i32");if(0!==fa){y=null;v=new a(fa,this);for(null!=n&&v.bind(n);v.step();)null===y&&
(y={columns:v.getColumnNames(),values:[]},h.push(y)),y.values.push(v.get());v.free()}}return h}catch(I){throw v&&v.free(),I;}finally{ja(t)}};c.prototype.each=function(h,n,t,v){"function"===typeof n&&(v=t,t=n,n=void 0);h=this.prepare(h,n);try{for(;h.step();)t(h.getAsObject())}finally{h.free()}if("function"===typeof v)return v()};c.prototype.prepare=function(h,n){ia(e);this.handleError(m(this.db,h,-1,e,0));h=z(e,"i32");if(0===h)throw"Nothing to prepare";var t=new a(h,this);null!=n&&t.bind(n);return this.nb[h]=
t};c.prototype.iterateStatements=function(h){return new b(h,this)};c.prototype["export"]=function(){Object.values(this.nb).forEach(function(n){n.free()});Object.values(this.Xa).forEach(ka);this.Xa={};this.handleError(k(this.db));var h=w.readFile(this.filename,{encoding:"binary"});this.handleError(g(this.filename,e));this.db=z(e,"i32");return h};c.prototype.close=function(){null!==this.db&&(Object.values(this.nb).forEach(function(h){h.free()}),Object.values(this.Xa).forEach(ka),this.Xa={},this.handleError(k(this.db)),
this.Xc&&w.unlink("/"+this.filename),this.db=null)};c.prototype.handleError=function(h){if(0===h)return null;h=G(this.db);throw Error(h);};c.prototype.getRowsModified=function(){return q(this.db)};c.prototype.create_function=function(h,n){Object.prototype.hasOwnProperty.call(this.Xa,h)&&(ka(this.Xa[h]),delete this.Xa[h]);var t=la(function(v,y,N){for(var H,ea=[],fa=0;fa<y;fa+=1){var I=z(N+4*fa,"i32"),S=Pb(I);if(1===S||2===S)I=Tb(I);else if(3===S)I=Rb(I);else if(4===S){S=I;I=Qb(S);S=Sb(S);for(var fb=
new Uint8Array(I),Aa=0;Aa<I;Aa+=1)fb[Aa]=D[S+Aa];I=fb}else I=null;ea.push(I)}try{H=n.apply(null,ea)}catch(Yb){eb(v,Yb,-1);return}switch(typeof H){case "boolean":Xb(v,H?1:0);break;case "number":Ub(v,H);break;case "string":Vb(v,H,-1,-1);break;case "object":null===H?db(v):null!=H.length?(y=ca(H),Wb(v,y,H.length,-1),da(y)):eb(v,"Wrong API use : tried to return a value of an unknown type ("+H+").",-1);break;default:db(v)}},"viii");this.Xa[h]=t;this.handleError(Ob(this.db,h,n.length,1,0,t,0,0,0));return this};
Module.Database=c;var ra=new Map;Module.register_for_idb=h=>{let n=la(function(y,N){y=ra.get(y);return h.lock(y,N)?0:5},"iii"),t=la(function(y,N){y=ra.get(y);h.unlock(y,N);return 0},"iii"),v=la(function(y,N){y=F(y);ra.set(N,y)},"vii");Module._register_for_idb(n,t,v)};Module.cleanup_file=h=>{let n=[...ra.entries()].find(t=>t[1]===h);ra.delete(n[0])};Module.reset_filesystem=()=>{w.root=null;w.lc()}};var ma={},K;for(K in Module)Module.hasOwnProperty(K)&&(ma[K]=Module[K]);
var na="./this.program",oa="object"===typeof window,pa="function"===typeof importScripts,qa="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node,L="",sa,ta,ua,va,wa;
if(qa)L=pa?require("path").dirname(L)+"/":__dirname+"/",sa=function(a,b){va||(va=require("fs"));wa||(wa=require("path"));a=wa.normalize(a);return va.readFileSync(a,b?null:"utf8")},ua=function(a){a=sa(a,!0);a.buffer||(a=new Uint8Array(a));assert(a.buffer);return a},ta=function(a,b,c){va||(va=require("fs"));wa||(wa=require("path"));a=wa.normalize(a);va.readFile(a,function(e,f){e?c(e):b(f.buffer)})},1<process.argv.length&&(na=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),"undefined"!==typeof module&&
(module.exports=Module),Module.inspect=function(){return"[Emscripten Module object]"};else if(oa||pa)pa?L=self.location.href:"undefined"!==typeof document&&document.currentScript&&(L=document.currentScript.src),L=0!==L.indexOf("blob:")?L.substr(0,L.lastIndexOf("/")+1):"",sa=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},pa&&(ua=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)}),
ta=function(a,b,c){var e=new XMLHttpRequest;e.open("GET",a,!0);e.responseType="arraybuffer";e.onload=function(){200==e.status||0==e.status&&e.response?b(e.response):c()};e.onerror=c;e.send(null)};var xa=Module.print||console.log.bind(console),M=Module.printErr||console.warn.bind(console);for(K in ma)ma.hasOwnProperty(K)&&(Module[K]=ma[K]);ma=null;Module.thisProgram&&(na=Module.thisProgram);var ya=[],za;function ka(a){za.delete(O.get(a));ya.push(a)}
function la(a,b){if(!za){za=new WeakMap;for(var c=0;c<O.length;c++){var e=O.get(c);e&&za.set(e,c)}}if(za.has(a))a=za.get(a);else{if(ya.length)c=ya.pop();else{try{O.grow(1)}catch(l){if(!(l instanceof RangeError))throw l;throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.";}c=O.length-1}try{O.set(c,a)}catch(l){if(!(l instanceof TypeError))throw l;if("function"===typeof WebAssembly.Function){var f={i:"i32",j:"i64",f:"f32",d:"f64"},g={parameters:[],results:"v"==b[0]?[]:[f[b[0]]]};for(e=1;e<b.length;++e)g.parameters.push(f[b[e]]);
b=new WebAssembly.Function(g,a)}else{f=[1,0,1,96];g=b.slice(0,1);b=b.slice(1);var k={i:127,j:126,f:125,d:124};f.push(b.length);for(e=0;e<b.length;++e)f.push(k[b[e]]);"v"==g?f.push(0):f=f.concat([1,k[g]]);f[1]=f.length-2;b=new Uint8Array([0,97,115,109,1,0,0,0].concat(f,[2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0]));b=new WebAssembly.Module(b);b=(new WebAssembly.Instance(b,{e:{f:a}})).exports.f}O.set(c,b)}za.set(a,c);a=c}return a}var Ba;Module.wasmBinary&&(Ba=Module.wasmBinary);
var noExitRuntime=Module.noExitRuntime||!0;"object"!==typeof WebAssembly&&P("no native wasm support detected");
function ia(a){var b="i32";"*"===b.charAt(b.length-1)&&(b="i32");switch(b){case "i1":D[a>>0]=0;break;case "i8":D[a>>0]=0;break;case "i16":Ca[a>>1]=0;break;case "i32":Q[a>>2]=0;break;case "i64":R=[0,(T=0,1<=+Math.abs(T)?0<T?(Math.min(+Math.floor(T/4294967296),4294967295)|0)>>>0:~~+Math.ceil((T-+(~~T>>>0))/4294967296)>>>0:0)];Q[a>>2]=R[0];Q[a+4>>2]=R[1];break;case "float":Da[a>>2]=0;break;case "double":Ea[a>>3]=0;break;default:P("invalid type for setValue: "+b)}}
function z(a,b){b=b||"i8";"*"===b.charAt(b.length-1)&&(b="i32");switch(b){case "i1":return D[a>>0];case "i8":return D[a>>0];case "i16":return Ca[a>>1];case "i32":return Q[a>>2];case "i64":return Q[a>>2];case "float":return Da[a>>2];case "double":return Ea[a>>3];default:P("invalid type for getValue: "+b)}return null}var Fa,Ga=!1;function assert(a,b){a||P("Assertion failed: "+b)}function Ha(a){var b=Module["_"+a];assert(b,"Cannot call unknown function "+a+", make sure it is exported");return b}
function Ia(a,b,c,e){var f={string:function(m){var r=0;if(null!==m&&void 0!==m&&0!==m){var x=(m.length<<2)+1;r=C(x);p(m,u,r,x)}return r},array:function(m){var r=C(m.length);D.set(m,r);return r}},g=Ha(a),k=[];a=0;if(e)for(var l=0;l<e.length;l++){var q=f[c[l]];q?(0===a&&(a=ha()),k[l]=q(e[l])):k[l]=e[l]}c=g.apply(null,k);c=function(m){return"string"===b?F(m):"boolean"===b?!!m:m}(c);0!==a&&ja(a);return c}var Ja=0,La=1;
function ca(a){var b=Ja==La?C(a.length):aa(a.length);a.subarray||a.slice?u.set(a,b):u.set(new Uint8Array(a),b);return b}var Ma="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
function Na(a,b,c){var e=b+c;for(c=b;a[c]&&!(c>=e);)++c;if(16<c-b&&a.subarray&&Ma)return Ma.decode(a.subarray(b,c));for(e="";b<c;){var f=a[b++];if(f&128){var g=a[b++]&63;if(192==(f&224))e+=String.fromCharCode((f&31)<<6|g);else{var k=a[b++]&63;f=224==(f&240)?(f&15)<<12|g<<6|k:(f&7)<<18|g<<12|k<<6|a[b++]&63;65536>f?e+=String.fromCharCode(f):(f-=65536,e+=String.fromCharCode(55296|f>>10,56320|f&1023))}}else e+=String.fromCharCode(f)}return e}function F(a,b){return a?Na(u,a,b):""}
function p(a,b,c,e){if(!(0<e))return 0;var f=c;e=c+e-1;for(var g=0;g<a.length;++g){var k=a.charCodeAt(g);if(55296<=k&&57343>=k){var l=a.charCodeAt(++g);k=65536+((k&1023)<<10)|l&1023}if(127>=k){if(c>=e)break;b[c++]=k}else{if(2047>=k){if(c+1>=e)break;b[c++]=192|k>>6}else{if(65535>=k){if(c+2>=e)break;b[c++]=224|k>>12}else{if(c+3>=e)break;b[c++]=240|k>>18;b[c++]=128|k>>12&63}b[c++]=128|k>>6&63}b[c++]=128|k&63}}b[c]=0;return c-f}
function d(a){for(var b=0,c=0;c<a.length;++c){var e=a.charCodeAt(c);55296<=e&&57343>=e&&(e=65536+((e&1023)<<10)|a.charCodeAt(++c)&1023);127>=e?++b:b=2047>=e?b+2:65535>=e?b+3:b+4}return b}function Oa(a){var b=d(a)+1,c=aa(b);c&&p(a,D,c,b);return c}var Pa,D,u,Ca,Q,Da,Ea;
function Qa(){var a=Fa.buffer;Pa=a;Module.HEAP8=D=new Int8Array(a);Module.HEAP16=Ca=new Int16Array(a);Module.HEAP32=Q=new Int32Array(a);Module.HEAPU8=u=new Uint8Array(a);Module.HEAPU16=new Uint16Array(a);Module.HEAPU32=new Uint32Array(a);Module.HEAPF32=Da=new Float32Array(a);Module.HEAPF64=Ea=new Float64Array(a)}var O,Ra=[],Sa=[],Ta=[];function Ua(){var a=Module.preRun.shift();Ra.unshift(a)}var Va=0,Wa=null,Xa=null;
function Ya(){Va++;Module.monitorRunDependencies&&Module.monitorRunDependencies(Va)}function Za(){Va--;Module.monitorRunDependencies&&Module.monitorRunDependencies(Va);if(0==Va&&(null!==Wa&&(clearInterval(Wa),Wa=null),Xa)){var a=Xa;Xa=null;a()}}Module.preloadedImages={};Module.preloadedAudios={};function P(a){if(Module.onAbort)Module.onAbort(a);M(a);Ga=!0;throw new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");}
function $a(){return V.startsWith("data:application/octet-stream;base64,")}var V;V="sql-wasm.wasm";if(!$a()){var ab=V;V=Module.locateFile?Module.locateFile(ab,L):L+ab}function bb(){var a=V;try{if(a==V&&Ba)return new Uint8Array(Ba);if(ua)return ua(a);throw"both async and sync fetching of the wasm failed";}catch(b){P(b)}}
function cb(){if(!Ba&&(oa||pa)){if("function"===typeof fetch&&!V.startsWith("file://"))return fetch(V,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+V+"'";return a.arrayBuffer()}).catch(function(){return bb()});if(ta)return new Promise(function(a,b){ta(V,function(c){a(new Uint8Array(c))},b)})}return Promise.resolve().then(function(){return bb()})}var T,R;
function gb(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(Module);else{var c=b.pd;"number"===typeof c?void 0===b.yb?O.get(c)():O.get(c)(b.yb):c(void 0===b.yb?null:b.yb)}}}function hb(a){return a.replace(/\b_Z[\w\d_]+/g,function(b){return b===b?b:b+" ["+b+"]"})}
function ib(){function a(k){return(k=k.toTimeString().match(/\(([A-Za-z ]+)\)$/))?k[1]:"GMT"}if(!jb){jb=!0;var b=(new Date).getFullYear(),c=new Date(b,0,1),e=new Date(b,6,1);b=c.getTimezoneOffset();var f=e.getTimezoneOffset(),g=Math.max(b,f);Q[kb()>>2]=60*g;Q[lb()>>2]=Number(b!=f);c=a(c);e=a(e);c=Oa(c);e=Oa(e);f<b?(Q[mb()>>2]=c,Q[mb()+4>>2]=e):(Q[mb()>>2]=e,Q[mb()+4>>2]=c)}}var jb;
function nb(a,b){for(var c=0,e=a.length-1;0<=e;e--){var f=a[e];"."===f?a.splice(e,1):".."===f?(a.splice(e,1),c++):c&&(a.splice(e,1),c--)}if(b)for(;c;c--)a.unshift("..");return a}function ob(a){var b="/"===a.charAt(0),c="/"===a.substr(-1);(a=nb(a.split("/").filter(function(e){return!!e}),!b).join("/"))||b||(a=".");a&&c&&(a+="/");return(b?"/":"")+a}
function pb(a){var b=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);a=b[0];b=b[1];if(!a&&!b)return".";b&&(b=b.substr(0,b.length-1));return a+b}function W(a){if("/"===a)return"/";a=ob(a);a=a.replace(/\/$/,"");var b=a.lastIndexOf("/");return-1===b?a:a.substr(b+1)}function qb(a,b){return ob(a+"/"+b)}
function rb(){if("object"===typeof crypto&&"function"===typeof crypto.getRandomValues){var a=new Uint8Array(1);return function(){crypto.getRandomValues(a);return a[0]}}if(qa)try{var b=require("crypto");return function(){return b.randomBytes(1)[0]}}catch(c){}return function(){P("randomDevice")}}
function sb(){for(var a="",b=!1,c=arguments.length-1;-1<=c&&!b;c--){b=0<=c?arguments[c]:w.cwd();if("string"!==typeof b)throw new TypeError("Arguments to path.resolve must be strings");if(!b)return"";a=b+"/"+a;b="/"===b.charAt(0)}a=nb(a.split("/").filter(function(e){return!!e}),!b).join("/");return(b?"/":"")+a||"."}
function tb(a,b){function c(k){for(var l=0;l<k.length&&""===k[l];l++);for(var q=k.length-1;0<=q&&""===k[q];q--);return l>q?[]:k.slice(l,q-l+1)}a=sb(a).substr(1);b=sb(b).substr(1);a=c(a.split("/"));b=c(b.split("/"));for(var e=Math.min(a.length,b.length),f=e,g=0;g<e;g++)if(a[g]!==b[g]){f=g;break}e=[];for(g=f;g<a.length;g++)e.push("..");e=e.concat(b.slice(f));return e.join("/")}var ub=[];function vb(a,b){ub[a]={input:[],output:[],gb:b};w.Qb(a,wb)}
var wb={open:function(a){var b=ub[a.node.rdev];if(!b)throw new w.ErrnoError(43);a.tty=b;a.seekable=!1},close:function(a){a.tty.gb.flush(a.tty)},flush:function(a){a.tty.gb.flush(a.tty)},read:function(a,b,c,e){if(!a.tty||!a.tty.gb.cc)throw new w.ErrnoError(60);for(var f=0,g=0;g<e;g++){try{var k=a.tty.gb.cc(a.tty)}catch(l){throw new w.ErrnoError(29);}if(void 0===k&&0===f)throw new w.ErrnoError(6);if(null===k||void 0===k)break;f++;b[c+g]=k}f&&(a.node.timestamp=Date.now());return f},write:function(a,b,
c,e){if(!a.tty||!a.tty.gb.Nb)throw new w.ErrnoError(60);try{for(var f=0;f<e;f++)a.tty.gb.Nb(a.tty,b[c+f])}catch(g){throw new w.ErrnoError(29);}e&&(a.node.timestamp=Date.now());return f}},xb={cc:function(a){if(!a.input.length){var b=null;if(qa){var c=Buffer.alloc(256),e=0;try{e=va.readSync(process.stdin.fd,c,0,256,null)}catch(f){if(f.toString().includes("EOF"))e=0;else throw f;}0<e?b=c.slice(0,e).toString("utf-8"):b=null}else"undefined"!=typeof window&&"function"==typeof window.prompt?(b=window.prompt("Input: "),
null!==b&&(b+="\n")):"function"==typeof readline&&(b=readline(),null!==b&&(b+="\n"));if(!b)return null;a.input=ba(b,!0)}return a.input.shift()},Nb:function(a,b){null===b||10===b?(xa(Na(a.output,0)),a.output=[]):0!=b&&a.output.push(b)},flush:function(a){a.output&&0<a.output.length&&(xa(Na(a.output,0)),a.output=[])}},yb={Nb:function(a,b){null===b||10===b?(M(Na(a.output,0)),a.output=[]):0!=b&&a.output.push(b)},flush:function(a){a.output&&0<a.output.length&&(M(Na(a.output,0)),a.output=[])}};
function zb(a){a=65536*Math.ceil(a/65536);var b=Ab(65536,a);if(!b)return 0;u.fill(0,b,b+a);return b}
var X={Va:null,mount:function(){return X.createNode(null,"/",16895,0)},createNode:function(a,b,c,e){if(w.Rc(c)||w.isFIFO(c))throw new w.ErrnoError(63);X.Va||(X.Va={dir:{node:{getattr:X.node_ops.getattr,setattr:X.node_ops.setattr,lookup:X.node_ops.lookup,mknod:X.node_ops.mknod,rename:X.node_ops.rename,unlink:X.node_ops.unlink,rmdir:X.node_ops.rmdir,readdir:X.node_ops.readdir,symlink:X.node_ops.symlink},stream:{llseek:X.stream_ops.llseek}},file:{node:{getattr:X.node_ops.getattr,setattr:X.node_ops.setattr},
stream:{llseek:X.stream_ops.llseek,read:X.stream_ops.read,write:X.stream_ops.write,allocate:X.stream_ops.allocate,mmap:X.stream_ops.mmap,msync:X.stream_ops.msync}},link:{node:{getattr:X.node_ops.getattr,setattr:X.node_ops.setattr,readlink:X.node_ops.readlink},stream:{}},Vb:{node:{getattr:X.node_ops.getattr,setattr:X.node_ops.setattr},stream:w.Cc}});c=w.createNode(a,b,c,e);w.isDir(c.mode)?(c.node_ops=X.Va.dir.node,c.stream_ops=X.Va.dir.stream,c.Na={}):w.isFile(c.mode)?(c.node_ops=X.Va.file.node,c.stream_ops=
X.Va.file.stream,c.Ra=0,c.Na=null):w.fb(c.mode)?(c.node_ops=X.Va.link.node,c.stream_ops=X.Va.link.stream):w.pb(c.mode)&&(c.node_ops=X.Va.Vb.node,c.stream_ops=X.Va.Vb.stream);c.timestamp=Date.now();a&&(a.Na[b]=c,a.timestamp=c.timestamp);return c},qd:function(a){return a.Na?a.Na.subarray?a.Na.subarray(0,a.Ra):new Uint8Array(a.Na):new Uint8Array(0)},Zb:function(a,b){var c=a.Na?a.Na.length:0;c>=b||(b=Math.max(b,c*(1048576>c?2:1.125)>>>0),0!=c&&(b=Math.max(b,256)),c=a.Na,a.Na=new Uint8Array(b),0<a.Ra&&
a.Na.set(c.subarray(0,a.Ra),0))},gd:function(a,b){if(a.Ra!=b)if(0==b)a.Na=null,a.Ra=0;else{var c=a.Na;a.Na=new Uint8Array(b);c&&a.Na.set(c.subarray(0,Math.min(b,a.Ra)));a.Ra=b}},node_ops:{getattr:function(a){var b={};b.dev=w.pb(a.mode)?a.id:1;b.ino=a.id;b.mode=a.mode;b.nlink=1;b.uid=0;b.gid=0;b.rdev=a.rdev;w.isDir(a.mode)?b.size=4096:w.isFile(a.mode)?b.size=a.Ra:w.fb(a.mode)?b.size=a.link.length:b.size=0;b.atime=new Date(a.timestamp);b.mtime=new Date(a.timestamp);b.ctime=new Date(a.timestamp);b.Ac=
4096;b.blocks=Math.ceil(b.size/b.Ac);return b},setattr:function(a,b){void 0!==b.mode&&(a.mode=b.mode);void 0!==b.timestamp&&(a.timestamp=b.timestamp);void 0!==b.size&&X.gd(a,b.size)},lookup:function(){throw w.Db[44];},mknod:function(a,b,c,e){return X.createNode(a,b,c,e)},rename:function(a,b,c){if(w.isDir(a.mode)){try{var e=w.lookupNode(b,c)}catch(g){}if(e)for(var f in e.Na)throw new w.ErrnoError(55);}delete a.parent.Na[a.name];a.parent.timestamp=Date.now();a.name=c;b.Na[c]=a;b.timestamp=a.parent.timestamp;
a.parent=b},unlink:function(a,b){delete a.Na[b];a.timestamp=Date.now()},rmdir:function(a,b){var c=w.lookupNode(a,b),e;for(e in c.Na)throw new w.ErrnoError(55);delete a.Na[b];a.timestamp=Date.now()},readdir:function(a){var b=[".",".."],c;for(c in a.Na)a.Na.hasOwnProperty(c)&&b.push(c);return b},symlink:function(a,b,c){a=X.createNode(a,b,41471,0);a.link=c;return a},readlink:function(a){if(!w.fb(a.mode))throw new w.ErrnoError(28);return a.link}},stream_ops:{read:function(a,b,c,e,f){var g=a.node.Na;if(f>=
a.node.Ra)return 0;a=Math.min(a.node.Ra-f,e);if(8<a&&g.subarray)b.set(g.subarray(f,f+a),c);else for(e=0;e<a;e++)b[c+e]=g[f+e];return a},write:function(a,b,c,e,f,g){b.buffer===D.buffer&&(g=!1);if(!e)return 0;a=a.node;a.timestamp=Date.now();if(b.subarray&&(!a.Na||a.Na.subarray)){if(g)return a.Na=b.subarray(c,c+e),a.Ra=e;if(0===a.Ra&&0===f)return a.Na=b.slice(c,c+e),a.Ra=e;if(f+e<=a.Ra)return a.Na.set(b.subarray(c,c+e),f),e}X.Zb(a,f+e);if(a.Na.subarray&&b.subarray)a.Na.set(b.subarray(c,c+e),f);else for(g=
0;g<e;g++)a.Na[f+g]=b[c+g];a.Ra=Math.max(a.Ra,f+e);return e},llseek:function(a,b,c){1===c?b+=a.position:2===c&&w.isFile(a.node.mode)&&(b+=a.node.Ra);if(0>b)throw new w.ErrnoError(28);return b},allocate:function(a,b,c){X.Zb(a.node,b+c);a.node.Ra=Math.max(a.node.Ra,b+c)},mmap:function(a,b,c,e,f,g){if(0!==b)throw new w.ErrnoError(28);if(!w.isFile(a.node.mode))throw new w.ErrnoError(43);a=a.node.Na;if(g&2||a.buffer!==Pa){if(0<e||e+c<a.length)a.subarray?a=a.subarray(e,e+c):a=Array.prototype.slice.call(a,
e,e+c);e=!0;c=zb(c);if(!c)throw new w.ErrnoError(48);D.set(a,c)}else e=!1,c=a.byteOffset;return{ed:c,vb:e}},msync:function(a,b,c,e,f){if(!w.isFile(a.node.mode))throw new w.ErrnoError(43);if(f&2)return 0;X.stream_ops.write(a,b,0,e,c,!1);return 0}}};function Bb(a,b,c){var e="al "+a;ta(a,function(f){assert(f,'Loading data file "'+a+'" failed (no arrayBuffer).');b(new Uint8Array(f));e&&Za()},function(){if(c)c();else throw'Loading data file "'+a+'" failed.';});e&&Ya()}
var w={root:null,mb:[],Xb:{},streams:[],Zc:1,Ua:null,Wb:"/",Hb:!1,hc:!0,Sa:{},nc:{kc:{qc:1,rc:2}},ErrnoError:null,Db:{},Lc:null,tb:0,lookupPath:function(a,b){a=sb(w.cwd(),a);b=b||{};if(!a)return{path:"",node:null};var c={Cb:!0,Pb:0},e;for(e in c)void 0===b[e]&&(b[e]=c[e]);if(8<b.Pb)throw new w.ErrnoError(32);a=nb(a.split("/").filter(function(k){return!!k}),!1);var f=w.root;c="/";for(e=0;e<a.length;e++){var g=e===a.length-1;if(g&&b.parent)break;f=w.lookupNode(f,a[e]);c=qb(c,a[e]);w.ab(f)&&(!g||g&&
b.Cb)&&(f=f.lb.root);if(!g||b.Ta)for(g=0;w.fb(f.mode);)if(f=w.readlink(c),c=sb(pb(c),f),f=w.lookupPath(c,{Pb:b.Pb}).node,40<g++)throw new w.ErrnoError(32);}return{path:c,node:f}},Ya:function(a){for(var b;;){if(w.isRoot(a))return a=a.mount.jc,b?"/"!==a[a.length-1]?a+"/"+b:a+b:a;b=b?a.name+"/"+b:a.name;a=a.parent}},Gb:function(a,b){for(var c=0,e=0;e<b.length;e++)c=(c<<5)-c+b.charCodeAt(e)|0;return(a+c>>>0)%w.Ua.length},ec:function(a){var b=w.Gb(a.parent.id,a.name);a.cb=w.Ua[b];w.Ua[b]=a},fc:function(a){var b=
w.Gb(a.parent.id,a.name);if(w.Ua[b]===a)w.Ua[b]=a.cb;else for(b=w.Ua[b];b;){if(b.cb===a){b.cb=a.cb;break}b=b.cb}},lookupNode:function(a,b){var c=w.Vc(a);if(c)throw new w.ErrnoError(c,a);for(c=w.Ua[w.Gb(a.id,b)];c;c=c.cb){var e=c.name;if(c.parent.id===a.id&&e===b)return c}return w.lookup(a,b)},createNode:function(a,b,c,e){a=new w.FSNode(a,b,c,e);w.ec(a);return a},Ab:function(a){w.fc(a)},isRoot:function(a){return a===a.parent},ab:function(a){return!!a.lb},isFile:function(a){return 32768===(a&61440)},
isDir:function(a){return 16384===(a&61440)},fb:function(a){return 40960===(a&61440)},pb:function(a){return 8192===(a&61440)},Rc:function(a){return 24576===(a&61440)},isFIFO:function(a){return 4096===(a&61440)},isSocket:function(a){return 49152===(a&49152)},Mc:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},Yc:function(a){var b=w.Mc[a];if("undefined"===typeof b)throw Error("Unknown file open mode: "+a);return b},$b:function(a){var b=["r","w","rw"][a&3];a&512&&(b+="w");return b},Za:function(a,b){if(w.hc)return 0;
if(!b.includes("r")||a.mode&292){if(b.includes("w")&&!(a.mode&146)||b.includes("x")&&!(a.mode&73))return 2}else return 2;return 0},Vc:function(a){var b=w.Za(a,"x");return b?b:a.node_ops.lookup?0:2},Lb:function(a,b){try{return w.lookupNode(a,b),20}catch(c){}return w.Za(a,"wx")},qb:function(a,b,c){try{var e=w.lookupNode(a,b)}catch(f){return f.Oa}if(a=w.Za(a,"wx"))return a;if(c){if(!w.isDir(e.mode))return 54;if(w.isRoot(e)||w.Ya(e)===w.cwd())return 10}else if(w.isDir(e.mode))return 31;return 0},Wc:function(a,
b){return a?w.fb(a.mode)?32:w.isDir(a.mode)&&("r"!==w.$b(b)||b&512)?31:w.Za(a,w.$b(b)):44},oc:4096,$c:function(a,b){b=b||w.oc;for(a=a||0;a<=b;a++)if(!w.streams[a])return a;throw new w.ErrnoError(33);},$a:function(a){return w.streams[a]},Jc:function(a,b,c){w.ub||(w.ub=function(){},w.ub.prototype={object:{get:function(){return this.node},set:function(g){this.node=g}}});var e=new w.ub,f;for(f in a)e[f]=a[f];a=e;b=w.$c(b,c);a.fd=b;return w.streams[b]=a},Dc:function(a){w.streams[a]=null},Cc:{open:function(a){a.stream_ops=
w.Oc(a.node.rdev).stream_ops;a.stream_ops.open&&a.stream_ops.open(a)},llseek:function(){throw new w.ErrnoError(70);}},Kb:function(a){return a>>8},sd:function(a){return a&255},bb:function(a,b){return a<<8|b},Qb:function(a,b){w.Xb[a]={stream_ops:b}},Oc:function(a){return w.Xb[a]},bc:function(a){var b=[];for(a=[a];a.length;){var c=a.pop();b.push(c);a.push.apply(a,c.mb)}return b},mc:function(a,b){function c(k){w.tb--;return b(k)}function e(k){if(k){if(!e.Kc)return e.Kc=!0,c(k)}else++g>=f.length&&c(null)}
"function"===typeof a&&(b=a,a=!1);w.tb++;1<w.tb&&M("warning: "+w.tb+" FS.syncfs operations in flight at once, probably just doing extra work");var f=w.bc(w.root.mount),g=0;f.forEach(function(k){if(!k.type.mc)return e(null);k.type.mc(k,a,e)})},mount:function(a,b,c){var e="/"===c,f=!c;if(e&&w.root)throw new w.ErrnoError(10);if(!e&&!f){var g=w.lookupPath(c,{Cb:!1});c=g.path;g=g.node;if(w.ab(g))throw new w.ErrnoError(10);if(!w.isDir(g.mode))throw new w.ErrnoError(54);}b={type:a,vd:b,jc:c,mb:[]};a=a.mount(b);
a.mount=b;b.root=a;e?w.root=a:g&&(g.lb=b,g.mount&&g.mount.mb.push(b));return a},yd:function(a){a=w.lookupPath(a,{Cb:!1});if(!w.ab(a.node))throw new w.ErrnoError(28);a=a.node;var b=a.lb,c=w.bc(b);Object.keys(w.Ua).forEach(function(e){for(e=w.Ua[e];e;){var f=e.cb;c.includes(e.mount)&&w.Ab(e);e=f}});a.lb=null;a.mount.mb.splice(a.mount.mb.indexOf(b),1)},lookup:function(a,b){return a.node_ops.lookup(a,b)},mknod:function(a,b,c){var e=w.lookupPath(a,{parent:!0}).node;a=W(a);if(!a||"."===a||".."===a)throw new w.ErrnoError(28);
var f=w.Lb(e,a);if(f)throw new w.ErrnoError(f);if(!e.node_ops.mknod)throw new w.ErrnoError(63);return e.node_ops.mknod(e,a,b,c)},create:function(a,b){return w.mknod(a,(void 0!==b?b:438)&4095|32768,0)},mkdir:function(a,b){return w.mknod(a,(void 0!==b?b:511)&1023|16384,0)},td:function(a,b){a=a.split("/");for(var c="",e=0;e<a.length;++e)if(a[e]){c+="/"+a[e];try{w.mkdir(c,b)}catch(f){if(20!=f.Oa)throw f;}}},rb:function(a,b,c){"undefined"===typeof c&&(c=b,b=438);return w.mknod(a,b|8192,c)},symlink:function(a,
b){if(!sb(a))throw new w.ErrnoError(44);var c=w.lookupPath(b,{parent:!0}).node;if(!c)throw new w.ErrnoError(44);b=W(b);var e=w.Lb(c,b);if(e)throw new w.ErrnoError(e);if(!c.node_ops.symlink)throw new w.ErrnoError(63);return c.node_ops.symlink(c,b,a)},rename:function(a,b){var c=pb(a),e=pb(b),f=W(a),g=W(b);var k=w.lookupPath(a,{parent:!0});var l=k.node;k=w.lookupPath(b,{parent:!0});k=k.node;if(!l||!k)throw new w.ErrnoError(44);if(l.mount!==k.mount)throw new w.ErrnoError(75);var q=w.lookupNode(l,f);e=
tb(a,e);if("."!==e.charAt(0))throw new w.ErrnoError(28);e=tb(b,c);if("."!==e.charAt(0))throw new w.ErrnoError(55);try{var m=w.lookupNode(k,g)}catch(r){}if(q!==m){c=w.isDir(q.mode);if(f=w.qb(l,f,c))throw new w.ErrnoError(f);if(f=m?w.qb(k,g,c):w.Lb(k,g))throw new w.ErrnoError(f);if(!l.node_ops.rename)throw new w.ErrnoError(63);if(w.ab(q)||m&&w.ab(m))throw new w.ErrnoError(10);if(k!==l&&(f=w.Za(l,"w")))throw new w.ErrnoError(f);try{w.Sa.willMovePath&&w.Sa.willMovePath(a,b)}catch(r){M("FS.trackingDelegate['willMovePath']('"+
a+"', '"+b+"') threw an exception: "+r.message)}w.fc(q);try{l.node_ops.rename(q,k,g)}catch(r){throw r;}finally{w.ec(q)}try{if(w.Sa.onMovePath)w.Sa.onMovePath(a,b)}catch(r){M("FS.trackingDelegate['onMovePath']('"+a+"', '"+b+"') threw an exception: "+r.message)}}},rmdir:function(a){var b=w.lookupPath(a,{parent:!0}).node,c=W(a),e=w.lookupNode(b,c),f=w.qb(b,c,!0);if(f)throw new w.ErrnoError(f);if(!b.node_ops.rmdir)throw new w.ErrnoError(63);if(w.ab(e))throw new w.ErrnoError(10);try{w.Sa.willDeletePath&&
w.Sa.willDeletePath(a)}catch(g){M("FS.trackingDelegate['willDeletePath']('"+a+"') threw an exception: "+g.message)}b.node_ops.rmdir(b,c);w.Ab(e);try{if(w.Sa.onDeletePath)w.Sa.onDeletePath(a)}catch(g){M("FS.trackingDelegate['onDeletePath']('"+a+"') threw an exception: "+g.message)}},readdir:function(a){a=w.lookupPath(a,{Ta:!0}).node;if(!a.node_ops.readdir)throw new w.ErrnoError(54);return a.node_ops.readdir(a)},unlink:function(a){var b=w.lookupPath(a,{parent:!0}).node,c=W(a),e=w.lookupNode(b,c),f=
w.qb(b,c,!1);if(f)throw new w.ErrnoError(f);if(!b.node_ops.unlink)throw new w.ErrnoError(63);if(w.ab(e))throw new w.ErrnoError(10);try{w.Sa.willDeletePath&&w.Sa.willDeletePath(a)}catch(g){M("FS.trackingDelegate['willDeletePath']('"+a+"') threw an exception: "+g.message)}b.node_ops.unlink(b,c);w.Ab(e);try{if(w.Sa.onDeletePath)w.Sa.onDeletePath(a)}catch(g){M("FS.trackingDelegate['onDeletePath']('"+a+"') threw an exception: "+g.message)}},readlink:function(a){a=w.lookupPath(a).node;if(!a)throw new w.ErrnoError(44);
if(!a.node_ops.readlink)throw new w.ErrnoError(28);return sb(w.Ya(a.parent),a.node_ops.readlink(a))},stat:function(a,b){a=w.lookupPath(a,{Ta:!b}).node;if(!a)throw new w.ErrnoError(44);if(!a.node_ops.getattr)throw new w.ErrnoError(63);return a.node_ops.getattr(a)},lstat:function(a){return w.stat(a,!0)},chmod:function(a,b,c){a="string"===typeof a?w.lookupPath(a,{Ta:!c}).node:a;if(!a.node_ops.setattr)throw new w.ErrnoError(63);a.node_ops.setattr(a,{mode:b&4095|a.mode&-4096,timestamp:Date.now()})},lchmod:function(a,
b){w.chmod(a,b,!0)},fchmod:function(a,b){a=w.$a(a);if(!a)throw new w.ErrnoError(8);w.chmod(a.node,b)},chown:function(a,b,c,e){a="string"===typeof a?w.lookupPath(a,{Ta:!e}).node:a;if(!a.node_ops.setattr)throw new w.ErrnoError(63);a.node_ops.setattr(a,{timestamp:Date.now()})},lchown:function(a,b,c){w.chown(a,b,c,!0)},fchown:function(a,b,c){a=w.$a(a);if(!a)throw new w.ErrnoError(8);w.chown(a.node,b,c)},truncate:function(a,b){if(0>b)throw new w.ErrnoError(28);a="string"===typeof a?w.lookupPath(a,{Ta:!0}).node:
a;if(!a.node_ops.setattr)throw new w.ErrnoError(63);if(w.isDir(a.mode))throw new w.ErrnoError(31);if(!w.isFile(a.mode))throw new w.ErrnoError(28);var c=w.Za(a,"w");if(c)throw new w.ErrnoError(c);a.node_ops.setattr(a,{size:b,timestamp:Date.now()})},Nc:function(a,b){a=w.$a(a);if(!a)throw new w.ErrnoError(8);if(0===(a.flags&2097155))throw new w.ErrnoError(28);w.truncate(a.node,b)},kd:function(a,b,c){a=w.lookupPath(a,{Ta:!0}).node;a.node_ops.setattr(a,{timestamp:Math.max(b,c)})},open:function(a,b,c,e,
f){if(""===a)throw new w.ErrnoError(44);b="string"===typeof b?w.Yc(b):b;c=b&64?("undefined"===typeof c?438:c)&4095|32768:0;if("object"===typeof a)var g=a;else{a=ob(a);try{g=w.lookupPath(a,{Ta:!(b&131072)}).node}catch(l){}}var k=!1;if(b&64)if(g){if(b&128)throw new w.ErrnoError(20);}else g=w.mknod(a,c,0),k=!0;if(!g)throw new w.ErrnoError(44);w.pb(g.mode)&&(b&=-513);if(b&65536&&!w.isDir(g.mode))throw new w.ErrnoError(54);if(!k&&(c=w.Wc(g,b)))throw new w.ErrnoError(c);b&512&&w.truncate(g,0);b&=-131713;
e=w.Jc({node:g,path:w.Ya(g),flags:b,seekable:!0,position:0,stream_ops:g.stream_ops,jd:[],error:!1},e,f);e.stream_ops.open&&e.stream_ops.open(e);!Module.logReadFiles||b&1||(w.Ob||(w.Ob={}),a in w.Ob||(w.Ob[a]=1,M("FS.trackingDelegate error on read file: "+a)));try{w.Sa.onOpenFile&&(f=0,1!==(b&2097155)&&(f|=w.nc.kc.qc),0!==(b&2097155)&&(f|=w.nc.kc.rc),w.Sa.onOpenFile(a,f))}catch(l){M("FS.trackingDelegate['onOpenFile']('"+a+"', flags) threw an exception: "+l.message)}return e},close:function(a){if(w.kb(a))throw new w.ErrnoError(8);
a.Fb&&(a.Fb=null);try{a.stream_ops.close&&a.stream_ops.close(a)}catch(b){throw b;}finally{w.Dc(a.fd)}a.fd=null},kb:function(a){return null===a.fd},llseek:function(a,b,c){if(w.kb(a))throw new w.ErrnoError(8);if(!a.seekable||!a.stream_ops.llseek)throw new w.ErrnoError(70);if(0!=c&&1!=c&&2!=c)throw new w.ErrnoError(28);a.position=a.stream_ops.llseek(a,b,c);a.jd=[];return a.position},read:function(a,b,c,e,f){if(0>e||0>f)throw new w.ErrnoError(28);if(w.kb(a))throw new w.ErrnoError(8);if(1===(a.flags&2097155))throw new w.ErrnoError(8);
if(w.isDir(a.node.mode))throw new w.ErrnoError(31);if(!a.stream_ops.read)throw new w.ErrnoError(28);var g="undefined"!==typeof f;if(!g)f=a.position;else if(!a.seekable)throw new w.ErrnoError(70);b=a.stream_ops.read(a,b,c,e,f);g||(a.position+=b);return b},write:function(a,b,c,e,f,g){if(0>e||0>f)throw new w.ErrnoError(28);if(w.kb(a))throw new w.ErrnoError(8);if(0===(a.flags&2097155))throw new w.ErrnoError(8);if(w.isDir(a.node.mode))throw new w.ErrnoError(31);if(!a.stream_ops.write)throw new w.ErrnoError(28);
a.seekable&&a.flags&1024&&w.llseek(a,0,2);var k="undefined"!==typeof f;if(!k)f=a.position;else if(!a.seekable)throw new w.ErrnoError(70);b=a.stream_ops.write(a,b,c,e,f,g);k||(a.position+=b);try{if(a.path&&w.Sa.onWriteToFile)w.Sa.onWriteToFile(a.path)}catch(l){M("FS.trackingDelegate['onWriteToFile']('"+a.path+"') threw an exception: "+l.message)}return b},allocate:function(a,b,c){if(w.kb(a))throw new w.ErrnoError(8);if(0>b||0>=c)throw new w.ErrnoError(28);if(0===(a.flags&2097155))throw new w.ErrnoError(8);
if(!w.isFile(a.node.mode)&&!w.isDir(a.node.mode))throw new w.ErrnoError(43);if(!a.stream_ops.allocate)throw new w.ErrnoError(138);a.stream_ops.allocate(a,b,c)},mmap:function(a,b,c,e,f,g){if(0!==(f&2)&&0===(g&2)&&2!==(a.flags&2097155))throw new w.ErrnoError(2);if(1===(a.flags&2097155))throw new w.ErrnoError(2);if(!a.stream_ops.mmap)throw new w.ErrnoError(43);return a.stream_ops.mmap(a,b,c,e,f,g)},msync:function(a,b,c,e,f){return a&&a.stream_ops.msync?a.stream_ops.msync(a,b,c,e,f):0},ud:function(){return 0},
ic:function(a,b,c){if(!a.stream_ops.ic)throw new w.ErrnoError(59);return a.stream_ops.ic(a,b,c)},readFile:function(a,b){b=b||{};b.flags=b.flags||0;b.encoding=b.encoding||"binary";if("utf8"!==b.encoding&&"binary"!==b.encoding)throw Error('Invalid encoding type "'+b.encoding+'"');var c,e=w.open(a,b.flags);a=w.stat(a).size;var f=new Uint8Array(a);w.read(e,f,0,a,0);"utf8"===b.encoding?c=Na(f,0):"binary"===b.encoding&&(c=f);w.close(e);return c},writeFile:function(a,b,c){c=c||{};c.flags=c.flags||577;a=
w.open(a,c.flags,c.mode);if("string"===typeof b){var e=new Uint8Array(d(b)+1);b=p(b,e,0,e.length);w.write(a,e,0,b,void 0,c.Bc)}else if(ArrayBuffer.isView(b))w.write(a,b,0,b.byteLength,void 0,c.Bc);else throw Error("Unsupported data type");w.close(a)},cwd:function(){return w.Wb},chdir:function(a){a=w.lookupPath(a,{Ta:!0});if(null===a.node)throw new w.ErrnoError(44);if(!w.isDir(a.node.mode))throw new w.ErrnoError(54);var b=w.Za(a.node,"x");if(b)throw new w.ErrnoError(b);w.Wb=a.path},Fc:function(){w.mkdir("/tmp");
w.mkdir("/home");w.mkdir("/home/web_user")},Ec:function(){w.mkdir("/dev");w.Qb(w.bb(1,3),{read:function(){return 0},write:function(b,c,e,f){return f}});w.rb("/dev/null",w.bb(1,3));vb(w.bb(5,0),xb);vb(w.bb(6,0),yb);w.rb("/dev/tty",w.bb(5,0));w.rb("/dev/tty1",w.bb(6,0));var a=rb();w.Wa("/dev","random",a);w.Wa("/dev","urandom",a);w.mkdir("/dev/shm");w.mkdir("/dev/shm/tmp")},Hc:function(){w.mkdir("/proc");var a=w.mkdir("/proc/self");w.mkdir("/proc/self/fd");w.mount({mount:function(){var b=w.createNode(a,
"fd",16895,73);b.node_ops={lookup:function(c,e){var f=w.$a(+e);if(!f)throw new w.ErrnoError(8);c={parent:null,mount:{jc:"fake"},node_ops:{readlink:function(){return f.path}}};return c.parent=c}};return b}},{},"/proc/self/fd")},Ic:function(){Module.stdin?w.Wa("/dev","stdin",Module.stdin):w.symlink("/dev/tty","/dev/stdin");Module.stdout?w.Wa("/dev","stdout",null,Module.stdout):w.symlink("/dev/tty","/dev/stdout");Module.stderr?w.Wa("/dev","stderr",null,Module.stderr):w.symlink("/dev/tty1","/dev/stderr");
w.open("/dev/stdin",0);w.open("/dev/stdout",1);w.open("/dev/stderr",1)},Yb:function(){w.ErrnoError||(w.ErrnoError=function(a,b){this.node=b;this.hd=function(c){this.Oa=c};this.hd(a);this.message="FS error"},w.ErrnoError.prototype=Error(),w.ErrnoError.prototype.constructor=w.ErrnoError,[44].forEach(function(a){w.Db[a]=new w.ErrnoError(a);w.Db[a].stack="<generic error, no stack>"}))},lc:function(){w.Yb();w.Ua=Array(4096);w.mount(X,{},"/");w.Fc();w.Ec();w.Hc();w.Lc={MEMFS:X}},jb:function(a,b,c){w.jb.Hb=
!0;w.Yb();Module.stdin=a||Module.stdin;Module.stdout=b||Module.stdout;Module.stderr=c||Module.stderr;w.Ic()},wd:function(){w.jb.Hb=!1;var a=Module._fflush;a&&a(0);for(a=0;a<w.streams.length;a++){var b=w.streams[a];b&&w.close(b)}},Eb:function(a,b){var c=0;a&&(c|=365);b&&(c|=146);return c},od:function(a,b){a=w.xb(a,b);return a.exists?a.object:null},xb:function(a,b){try{var c=w.lookupPath(a,{Ta:!b});a=c.path}catch(f){}var e={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,ad:!1,cd:null,bd:null};
try{c=w.lookupPath(a,{parent:!0}),e.ad=!0,e.cd=c.path,e.bd=c.node,e.name=W(a),c=w.lookupPath(a,{Ta:!b}),e.exists=!0,e.path=c.path,e.object=c.node,e.name=c.node.name,e.isRoot="/"===c.path}catch(f){e.error=f.Oa}return e},md:function(a,b){a="string"===typeof a?a:w.Ya(a);for(b=b.split("/").reverse();b.length;){var c=b.pop();if(c){var e=qb(a,c);try{w.mkdir(e)}catch(f){}a=e}}return e},Gc:function(a,b,c,e,f){a=qb("string"===typeof a?a:w.Ya(a),b);return w.create(a,w.Eb(e,f))},zb:function(a,b,c,e,f,g){a=b?
qb("string"===typeof a?a:w.Ya(a),b):a;e=w.Eb(e,f);f=w.create(a,e);if(c){if("string"===typeof c){a=Array(c.length);b=0;for(var k=c.length;b<k;++b)a[b]=c.charCodeAt(b);c=a}w.chmod(f,e|146);a=w.open(f,577);w.write(a,c,0,c.length,0,g);w.close(a);w.chmod(f,e)}return f},Wa:function(a,b,c,e){a=qb("string"===typeof a?a:w.Ya(a),b);b=w.Eb(!!c,!!e);w.Wa.Kb||(w.Wa.Kb=64);var f=w.bb(w.Wa.Kb++,0);w.Qb(f,{open:function(g){g.seekable=!1},close:function(){e&&e.buffer&&e.buffer.length&&e(10)},read:function(g,k,l,q){for(var m=
0,r=0;r<q;r++){try{var x=c()}catch(B){throw new w.ErrnoError(29);}if(void 0===x&&0===m)throw new w.ErrnoError(6);if(null===x||void 0===x)break;m++;k[l+r]=x}m&&(g.node.timestamp=Date.now());return m},write:function(g,k,l,q){for(var m=0;m<q;m++)try{e(k[l+m])}catch(r){throw new w.ErrnoError(29);}q&&(g.node.timestamp=Date.now());return m}});return w.rb(a,b,f)},ac:function(a){if(a.Ib||a.Sc||a.link||a.Na)return!0;if("undefined"!==typeof XMLHttpRequest)throw 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(sa)try{a.Na=ba(sa(a.url),!0),a.Ra=a.Na.length}catch(b){throw new w.ErrnoError(29);}else throw Error("Cannot load without read() or XMLHttpRequest.");},ld:function(a,b,c,e,f){function g(){this.Jb=!1;this.ob=[]}g.prototype.get=function(m){if(!(m>this.length-1||0>m)){var r=m%this.chunkSize;return this.dc(m/this.chunkSize|0)[r]}};g.prototype.pc=function(m){this.dc=m};g.prototype.Ub=function(){var m=new XMLHttpRequest;m.open("HEAD",c,!1);m.send(null);if(!(200<=m.status&&300>m.status||304===m.status))throw Error("Couldn't load "+
c+". Status: "+m.status);var r=Number(m.getResponseHeader("Content-length")),x,B=(x=m.getResponseHeader("Accept-Ranges"))&&"bytes"===x;m=(x=m.getResponseHeader("Content-Encoding"))&&"gzip"===x;var E=1048576;B||(E=r);var A=this;A.pc(function(J){var Z=J*E,U=(J+1)*E-1;U=Math.min(U,r-1);if("undefined"===typeof A.ob[J]){var Ka=A.ob;if(Z>U)throw Error("invalid range ("+Z+", "+U+") or no bytes requested!");if(U>r-1)throw Error("only "+r+" bytes available! programmer error!");var G=new XMLHttpRequest;G.open("GET",
c,!1);r!==E&&G.setRequestHeader("Range","bytes="+Z+"-"+U);"undefined"!=typeof Uint8Array&&(G.responseType="arraybuffer");G.overrideMimeType&&G.overrideMimeType("text/plain; charset=x-user-defined");G.send(null);if(!(200<=G.status&&300>G.status||304===G.status))throw Error("Couldn't load "+c+". Status: "+G.status);Z=void 0!==G.response?new Uint8Array(G.response||[]):ba(G.responseText||"",!0);Ka[J]=Z}if("undefined"===typeof A.ob[J])throw Error("doXHR failed!");return A.ob[J]});if(m||!r)E=r=1,E=r=this.dc(0).length,
xa("LazyFiles on gzip forces download of the whole file when length is accessed");this.tc=r;this.sc=E;this.Jb=!0};if("undefined"!==typeof XMLHttpRequest){if(!pa)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var k=new g;Object.defineProperties(k,{length:{get:function(){this.Jb||this.Ub();return this.tc}},chunkSize:{get:function(){this.Jb||this.Ub();return this.sc}}});k={Ib:!1,Na:k}}else k={Ib:!1,url:c};var l=w.Gc(a,b,k,e,
f);k.Na?l.Na=k.Na:k.url&&(l.Na=null,l.url=k.url);Object.defineProperties(l,{Ra:{get:function(){return this.Na.length}}});var q={};Object.keys(l.stream_ops).forEach(function(m){var r=l.stream_ops[m];q[m]=function(){w.ac(l);return r.apply(null,arguments)}});q.read=function(m,r,x,B,E){w.ac(l);m=m.node.Na;if(E>=m.length)return 0;B=Math.min(m.length-E,B);if(m.slice)for(var A=0;A<B;A++)r[x+A]=m[E+A];else for(A=0;A<B;A++)r[x+A]=m.get(E+A);return B};l.stream_ops=q;return l},nd:function(a,b,c,e,f,g,k,l,q,
m){function r(B){function E(J){m&&m();l||w.zb(a,b,J,e,f,q);g&&g();Za()}var A=!1;Module.preloadPlugins.forEach(function(J){!A&&J.canHandle(x)&&(J.handle(B,x,E,function(){k&&k();Za()}),A=!0)});A||E(B)}Zb.jb();var x=b?sb(qb(a,b)):a;Ya();"string"==typeof c?Bb(c,function(B){r(B)},k):r(c)},indexedDB:function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},Rb:function(){return"EM_FS_"+window.location.pathname},Sb:20,ib:"FILE_DATA",xd:function(a,b,c){b=b||function(){};
c=c||function(){};var e=w.indexedDB();try{var f=e.open(w.Rb(),w.Sb)}catch(g){return c(g)}f.onupgradeneeded=function(){xa("creating db");f.result.createObjectStore(w.ib)};f.onsuccess=function(){var g=f.result.transaction([w.ib],"readwrite"),k=g.objectStore(w.ib),l=0,q=0,m=a.length;a.forEach(function(r){r=k.put(w.xb(r).object.Na,r);r.onsuccess=function(){l++;l+q==m&&(0==q?b():c())};r.onerror=function(){q++;l+q==m&&(0==q?b():c())}});g.onerror=c};f.onerror=c},rd:function(a,b,c){b=b||function(){};c=c||
function(){};var e=w.indexedDB();try{var f=e.open(w.Rb(),w.Sb)}catch(g){return c(g)}f.onupgradeneeded=c;f.onsuccess=function(){var g=f.result;try{var k=g.transaction([w.ib],"readonly")}catch(x){c(x);return}var l=k.objectStore(w.ib),q=0,m=0,r=a.length;a.forEach(function(x){var B=l.get(x);B.onsuccess=function(){w.xb(x).exists&&w.unlink(x);w.zb(pb(x),W(x),B.result,!0,!0,!0);q++;q+m==r&&(0==m?b():c())};B.onerror=function(){m++