@areb0s/scip.js 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/scip.js CHANGED
@@ -67,23 +67,27 @@ var Module=moduleArg;var readyPromiseResolve,readyPromiseReject;Module["ready"]=
67
67
  return Status.UNKNOWN;
68
68
  }
69
69
 
70
- function parseSolution(output) {
70
+ function parseSolution(output, rawSolution) {
71
71
  var variables = {};
72
72
  var objective = { value: null };
73
73
 
74
- var objMatch = output.match(/objective value:\s*([\d.e+-]+)/i);
74
+ // Use rawSolution if available (more reliable)
75
+ var solText = rawSolution || output;
76
+
77
+ var objMatch = solText.match(/objective value:\s*([\d.e+-]+)/i);
75
78
  if (objMatch) {
76
79
  objective.value = parseFloat(objMatch[1]);
77
80
  }
78
81
 
79
- var varRegex = /^(\w+)\s+([\d.e+-]+)/gm;
82
+ // Match ZIMPL-style variable names: x$sun#0, effSum$star#1, b_sun_10, etc.
83
+ // Format: variableName value (obj:coef)
84
+ var varRegex = /^([\w$#]+)\s+([\d.e+-]+)/gm;
80
85
  var match;
81
- var solSection = output.split('solution:')[1] || output;
82
86
 
83
- while ((match = varRegex.exec(solSection)) !== null) {
87
+ while ((match = varRegex.exec(solText)) !== null) {
84
88
  var name = match[1];
85
89
  var value = parseFloat(match[2]);
86
- if (!isNaN(value) && name !== 'objective') {
90
+ if (!isNaN(value) && name !== 'objective' && name !== 'solution') {
87
91
  variables[name] = value;
88
92
  }
89
93
  }
@@ -122,22 +126,10 @@ var Module=moduleArg;var readyPromiseResolve,readyPromiseReject;Module["ready"]=
122
126
  initPromise = new Promise(function(resolve, reject) {
123
127
  try {
124
128
  var wasmPath = options.wasmPath || (__SCIP_SCRIPT_DIR__ + 'scip.wasm');
125
- console.log('[SCIP.js] __SCIP_SCRIPT_DIR__:', __SCIP_SCRIPT_DIR__);
126
- console.log('[SCIP.js] Loading WASM from:', wasmPath);
127
-
128
- // Verify WASM is accessible
129
- fetch(wasmPath, { method: 'HEAD' })
130
- .then(function(res) {
131
- console.log('[SCIP.js] WASM file check:', res.ok ? 'OK' : 'FAILED', res.status);
132
- })
133
- .catch(function(err) {
134
- console.error('[SCIP.js] WASM file check failed:', err);
135
- });
136
129
 
137
130
  createSCIP({
138
131
  locateFile: function(path) {
139
132
  if (path.endsWith('.wasm')) {
140
- console.log('[SCIP.js] locateFile called for:', path, '-> returning:', wasmPath);
141
133
  return wasmPath;
142
134
  }
143
135
  return path;
@@ -153,7 +145,6 @@ var Module=moduleArg;var readyPromiseResolve,readyPromiseReject;Module["ready"]=
153
145
  }
154
146
  }
155
147
  }).then(function(module) {
156
- console.log('[SCIP.js] WASM loaded successfully');
157
148
  scipModule = module;
158
149
 
159
150
  if (scipModule.FS) {
@@ -166,16 +157,11 @@ var Module=moduleArg;var readyPromiseResolve,readyPromiseReject;Module["ready"]=
166
157
  if (readyResolve) readyResolve();
167
158
  resolve();
168
159
  }).catch(function(err) {
169
- console.error('[SCIP.js] WASM loading failed:', err);
170
- console.error('[SCIP.js] Attempted WASM path:', wasmPath);
171
- console.error('[SCIP.js] Make sure the WASM file is accessible at this URL.');
172
- console.error('[SCIP.js] You can set window.SCIP_BASE_URL before loading this script to specify a custom path.');
173
- var error = new Error('SCIP WASM loading failed: ' + (err.message || err) + '. WASM path: ' + wasmPath);
160
+ var error = new Error('SCIP WASM loading failed: ' + (err.message || err));
174
161
  if (readyReject) readyReject(error);
175
162
  reject(error);
176
163
  });
177
164
  } catch (err) {
178
- console.error('[SCIP.js] Initialization error:', err);
179
165
  if (readyReject) readyReject(err);
180
166
  reject(err);
181
167
  }
@@ -240,15 +226,16 @@ var Module=moduleArg;var readyPromiseResolve,readyPromiseReject;Module["ready"]=
240
226
 
241
227
  var exitCode = scipModule.callMain(['-b', '/settings/commands.txt']);
242
228
 
243
- var status = parseStatus(stdout);
244
- var parsed = parseSolution(stdout);
245
- var statistics = parseStatistics(stdout);
246
-
229
+ // Read rawSolution first (more reliable for parsing)
247
230
  var rawSolution = null;
248
231
  try {
249
232
  rawSolution = scipModule.FS.readFile(solutionFile, { encoding: 'utf8' });
250
233
  } catch (e) {}
251
234
 
235
+ var status = parseStatus(stdout);
236
+ var parsed = parseSolution(stdout, rawSolution);
237
+ var statistics = parseStatistics(stdout);
238
+
252
239
  // Cleanup
253
240
  var cleanupFiles = [
254
241
  '/problems/problem.lp', '/problems/problem.mps',
package/dist/scip.min.js CHANGED
@@ -1,10 +1,10 @@
1
- (function(pe){"use strict";var _r=function(){if(typeof SCIP_BASE_URL<"u"&&SCIP_BASE_URL)return SCIP_BASE_URL+(SCIP_BASE_URL.endsWith("/")?"":"/");if(typeof document<"u"&&document.currentScript&&document.currentScript.src){var w=document.currentScript.src;return w.substring(0,w.lastIndexOf("/")+1)}return"https://cdn.jsdelivr.net/npm/@areb0s/scip.js@latest/dist/"}(),we=(()=>{var w=_r;return function(F={}){var u=F,L,k;u.ready=new Promise((r,e)=>{L=r,k=e});var C=Object.assign({},u),Q=[],X="./this.program",x=(r,e)=>{throw e},dr=typeof window=="object",tr=typeof importScripts=="function",Br=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",B="";function Er(r){return u.locateFile?u.locateFile(r,B):B+r}var j,ir,vr;(dr||tr)&&(tr?B=self.location.href:typeof document<"u"&&document.currentScript&&(B=document.currentScript.src),w&&(B=w),B.startsWith("blob:")?B="":B=B.substr(0,B.replace(/[?#].*/,"").lastIndexOf("/")+1),j=r=>{var e=new XMLHttpRequest;return e.open("GET",r,!1),e.send(null),e.responseText},tr&&(vr=r=>{var e=new XMLHttpRequest;return e.open("GET",r,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),ir=(r,e,t)=>{var o=new XMLHttpRequest;o.open("GET",r,!0),o.responseType="arraybuffer",o.onload=()=>{if(o.status==200||o.status==0&&o.response){e(o.response);return}t()},o.onerror=t,o.send(null)});var mr=u.print||console.log.bind(console),q=u.printErr||console.error.bind(console);Object.assign(u,C),C=null,u.arguments&&(Q=u.arguments),u.thisProgram&&(X=u.thisProgram),u.quit&&(x=u.quit);var Z;u.wasmBinary&&(Z=u.wasmBinary);var sr,lr=!1,nr,R,z,Sr,De,_,D,Me,Ae;function Hr(){var r=sr.buffer;u.HEAP8=R=new Int8Array(r),u.HEAP16=Sr=new Int16Array(r),u.HEAPU8=z=new Uint8Array(r),u.HEAPU16=De=new Uint16Array(r),u.HEAP32=_=new Int32Array(r),u.HEAPU32=D=new Uint32Array(r),u.HEAPF32=Me=new Float32Array(r),u.HEAPF64=Ae=new Float64Array(r)}var Wr=[],Yr=[],Re=[],Xr=[],Te=!1;function Ce(){if(u.preRun)for(typeof u.preRun=="function"&&(u.preRun=[u.preRun]);u.preRun.length;)ze(u.preRun.shift());br(Wr)}function Ie(){Te=!0,!u.noFSInit&&!n.init.initialized&&n.init(),n.ignorePermissions=!1,rr.init(),br(Yr)}function Ne(){br(Re)}function Le(){if(u.postRun)for(typeof u.postRun=="function"&&(u.postRun=[u.postRun]);u.postRun.length;)Ue(u.postRun.shift());br(Xr)}function ze(r){Wr.unshift(r)}function Oe(r){Yr.unshift(r)}function Ue(r){Xr.unshift(r)}var or=0,Cr=null,hr=null;function rn(r){return r}function kr(r){or++,u.monitorRunDependencies?.(or)}function pr(r){if(or--,u.monitorRunDependencies?.(or),or==0&&(Cr!==null&&(clearInterval(Cr),Cr=null),hr)){var e=hr;hr=null,e()}}function Ir(r){u.onAbort?.(r),r="Aborted("+r+")",q(r),lr=!0,nr=1,r+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(r);throw k(e),e}var je="data:application/octet-stream;base64,",qr=r=>r.startsWith(je),ar;u.locateFile?(ar="scip.wasm",qr(ar)||(ar=Er(ar))):ar=new URL("scip.wasm",_r).href;function $r(r){if(r==ar&&Z)return new Uint8Array(Z);if(vr)return vr(r);throw"both async and sync fetching of the wasm failed"}function xe(r){return!Z&&(dr||tr)&&typeof fetch=="function"?fetch(r,{credentials:"same-origin"}).then(e=>{if(!e.ok)throw`failed to load wasm binary file at '${r}'`;return e.arrayBuffer()}).catch(()=>$r(r)):Promise.resolve().then(()=>$r(r))}function Vr(r,e,t){return xe(r).then(o=>WebAssembly.instantiate(o,e)).then(t,o=>{q(`failed to asynchronously prepare wasm: ${o}`),Ir(o)})}function Be(r,e,t,o){return!r&&typeof WebAssembly.instantiateStreaming=="function"&&!qr(e)&&typeof fetch=="function"?fetch(e,{credentials:"same-origin"}).then(a=>{var i=WebAssembly.instantiateStreaming(a,t);return i.then(o,function(s){return q(`wasm streaming compile failed: ${s}`),q("falling back to ArrayBuffer instantiation"),Vr(e,t,o)})}):Vr(e,t,o)}function He(){var r={a:Wt};function e(o,a){return H=o.exports,sr=H.O,Hr(),Jr=H.R,Oe(H.P),pr("wasm-instantiate"),H}kr("wasm-instantiate");function t(o){e(o.instance)}if(u.instantiateWasm)try{return u.instantiateWasm(r,e)}catch(o){q(`Module.instantiateWasm callback failed with error: ${o}`),k(o)}return Be(Z,ar,r,t).catch(k),{}}var g,I;function Gr(r){this.name="ExitStatus",this.message=`Program terminated with exit(${r})`,this.status=r}var br=r=>{for(;r.length>0;)r.shift()(u)},Kr=u.noExitRuntime||!0,Fr=[],Jr,$=r=>{var e=Fr[r];return e||(r>=Fr.length&&(Fr.length=r+1),Fr[r]=e=Jr.get(r)),e},We=(r,e)=>$(r)(e);class Ye{constructor(e){this.excPtr=e,this.ptr=e-24}set_type(e){D[this.ptr+4>>2]=e}get_type(){return D[this.ptr+4>>2]}set_destructor(e){D[this.ptr+8>>2]=e}get_destructor(){return D[this.ptr+8>>2]}set_caught(e){e=e?1:0,R[this.ptr+12]=e}get_caught(){return R[this.ptr+12]!=0}set_rethrown(e){e=e?1:0,R[this.ptr+13]=e}get_rethrown(){return R[this.ptr+13]!=0}init(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t)}set_adjusted_ptr(e){D[this.ptr+16>>2]=e}get_adjusted_ptr(){return D[this.ptr+16>>2]}get_exception_ptr(){var e=de(this.get_type());if(e)return D[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}var Qr=0,Xe=0,qe=(r,e,t)=>{var o=new Ye(r);throw o.init(e,t),Qr=r,Xe++,Qr},P={isAbs:r=>r.charAt(0)==="/",splitPath:r=>{var e=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return e.exec(r).slice(1)},normalizeArray:(r,e)=>{for(var t=0,o=r.length-1;o>=0;o--){var a=r[o];a==="."?r.splice(o,1):a===".."?(r.splice(o,1),t++):t&&(r.splice(o,1),t--)}if(e)for(;t;t--)r.unshift("..");return r},normalize:r=>{var e=P.isAbs(r),t=r.substr(-1)==="/";return r=P.normalizeArray(r.split("/").filter(o=>!!o),!e).join("/"),!r&&!e&&(r="."),r&&t&&(r+="/"),(e?"/":"")+r},dirname:r=>{var e=P.splitPath(r),t=e[0],o=e[1];return!t&&!o?".":(o&&(o=o.substr(0,o.length-1)),t+o)},basename:r=>{if(r==="/")return"/";r=P.normalize(r),r=r.replace(/\/$/,"");var e=r.lastIndexOf("/");return e===-1?r:r.substr(e+1)},join:(...r)=>P.normalize(r.join("/")),join2:(r,e)=>P.normalize(r+"/"+e)},$e=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return r=>crypto.getRandomValues(r);Ir("initRandomDevice")},Zr=r=>(Zr=$e())(r),J={resolve:(...r)=>{for(var e="",t=!1,o=r.length-1;o>=-1&&!t;o--){var a=o>=0?r[o]:n.cwd();if(typeof a!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!a)return"";e=a+"/"+e,t=P.isAbs(a)}return e=P.normalizeArray(e.split("/").filter(i=>!!i),!t).join("/"),(t?"/":"")+e||"."},relative:(r,e)=>{r=J.resolve(r).substr(1),e=J.resolve(e).substr(1);function t(h){for(var S=0;S<h.length&&h[S]==="";S++);for(var b=h.length-1;b>=0&&h[b]==="";b--);return S>b?[]:h.slice(S,b-S+1)}for(var o=t(r.split("/")),a=t(e.split("/")),i=Math.min(o.length,a.length),s=i,l=0;l<i;l++)if(o[l]!==a[l]){s=l;break}for(var c=[],l=s;l<o.length;l++)c.push("..");return c=c.concat(a.slice(s)),c.join("/")}},re=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,ur=(r,e,t)=>{for(var o=e+t,a=e;r[a]&&!(a>=o);)++a;if(a-e>16&&r.buffer&&re)return re.decode(r.subarray(e,a));for(var i="";e<a;){var s=r[e++];if(!(s&128)){i+=String.fromCharCode(s);continue}var l=r[e++]&63;if((s&224)==192){i+=String.fromCharCode((s&31)<<6|l);continue}var c=r[e++]&63;if((s&240)==224?s=(s&15)<<12|l<<6|c:s=(s&7)<<18|l<<12|c<<6|r[e++]&63,s<65536)i+=String.fromCharCode(s);else{var h=s-65536;i+=String.fromCharCode(55296|h>>10,56320|h&1023)}}return i},Nr=[],Pr=r=>{for(var e=0,t=0;t<r.length;++t){var o=r.charCodeAt(t);o<=127?e++:o<=2047?e+=2:o>=55296&&o<=57343?(e+=4,++t):e+=3}return e},Lr=(r,e,t,o)=>{if(!(o>0))return 0;for(var a=t,i=t+o-1,s=0;s<r.length;++s){var l=r.charCodeAt(s);if(l>=55296&&l<=57343){var c=r.charCodeAt(++s);l=65536+((l&1023)<<10)|c&1023}if(l<=127){if(t>=i)break;e[t++]=l}else if(l<=2047){if(t+1>=i)break;e[t++]=192|l>>6,e[t++]=128|l&63}else if(l<=65535){if(t+2>=i)break;e[t++]=224|l>>12,e[t++]=128|l>>6&63,e[t++]=128|l&63}else{if(t+3>=i)break;e[t++]=240|l>>18,e[t++]=128|l>>12&63,e[t++]=128|l>>6&63,e[t++]=128|l&63}}return e[t]=0,t-a};function Dr(r,e,t){var o=t>0?t:Pr(r)+1,a=new Array(o),i=Lr(r,a,0,a.length);return e&&(a.length=i),a}var Ve=()=>{if(!Nr.length){var r=null;if(typeof window<"u"&&typeof window.prompt=="function"?(r=window.prompt("Input: "),r!==null&&(r+=`
1
+ (function(pe){"use strict";var Ar=function(){if(typeof SCIP_BASE_URL<"u"&&SCIP_BASE_URL)return SCIP_BASE_URL+(SCIP_BASE_URL.endsWith("/")?"":"/");if(typeof document<"u"&&document.currentScript&&document.currentScript.src){var y=document.currentScript.src;return y.substring(0,y.lastIndexOf("/")+1)}return"https://cdn.jsdelivr.net/npm/@areb0s/scip.js@latest/dist/"}(),we=(()=>{var y=Ar;return function(b={}){var l=b,H,F;l.ready=new Promise((r,e)=>{H=r,F=e});var I=Object.assign({},l),Q=[],X="./this.program",x=(r,e)=>{throw e},Z=typeof window=="object",tr=typeof importScripts=="function",jr=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",B="";function gr(r){return l.locateFile?l.locateFile(r,B):B+r}var U,ur,dr;(Z||tr)&&(tr?B=self.location.href:typeof document<"u"&&document.currentScript&&(B=document.currentScript.src),y&&(B=y),B.startsWith("blob:")?B="":B=B.substr(0,B.replace(/[?#].*/,"").lastIndexOf("/")+1),U=r=>{var e=new XMLHttpRequest;return e.open("GET",r,!1),e.send(null),e.responseText},tr&&(dr=r=>{var e=new XMLHttpRequest;return e.open("GET",r,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),ur=(r,e,t)=>{var o=new XMLHttpRequest;o.open("GET",r,!0),o.responseType="arraybuffer",o.onload=()=>{if(o.status==200||o.status==0&&o.response){e(o.response);return}t()},o.onerror=t,o.send(null)});var vr=l.print||console.log.bind(console),W=l.printErr||console.error.bind(console);Object.assign(l,I),I=null,l.arguments&&(Q=l.arguments),l.thisProgram&&(X=l.thisProgram),l.quit&&(x=l.quit);var nr;l.wasmBinary&&(nr=l.wasmBinary);var or,mr=!1,ar,R,z,Er,Pe,w,P,Me,Ae;function Hr(){var r=or.buffer;l.HEAP8=R=new Int8Array(r),l.HEAP16=Er=new Int16Array(r),l.HEAPU8=z=new Uint8Array(r),l.HEAPU16=Pe=new Uint16Array(r),l.HEAP32=w=new Int32Array(r),l.HEAPU32=P=new Uint32Array(r),l.HEAPF32=Me=new Float32Array(r),l.HEAPF64=Ae=new Float64Array(r)}var Wr=[],Yr=[],Re=[],Xr=[],Te=!1;function Ne(){if(l.preRun)for(typeof l.preRun=="function"&&(l.preRun=[l.preRun]);l.preRun.length;)Le(l.preRun.shift());Sr(Wr)}function Ce(){Te=!0,!l.noFSInit&&!n.init.initialized&&n.init(),n.ignorePermissions=!1,rr.init(),Sr(Yr)}function Ie(){Sr(Re)}function ze(){if(l.postRun)for(typeof l.postRun=="function"&&(l.postRun=[l.postRun]);l.postRun.length;)xe(l.postRun.shift());Sr(Xr)}function Le(r){Wr.unshift(r)}function Oe(r){Yr.unshift(r)}function xe(r){Xr.unshift(r)}var ir=0,Nr=null,hr=null;function rn(r){return r}function kr(r){ir++,l.monitorRunDependencies?.(ir)}function pr(r){if(ir--,l.monitorRunDependencies?.(ir),ir==0&&(Nr!==null&&(clearInterval(Nr),Nr=null),hr)){var e=hr;hr=null,e()}}function Cr(r){l.onAbort?.(r),r="Aborted("+r+")",W(r),mr=!0,ar=1,r+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(r);throw F(e),e}var Ue="data:application/octet-stream;base64,",$r=r=>r.startsWith(Ue),sr;l.locateFile?(sr="scip.wasm",$r(sr)||(sr=gr(sr))):sr=new URL("scip.wasm",Ar).href;function qr(r){if(r==sr&&nr)return new Uint8Array(nr);if(dr)return dr(r);throw"both async and sync fetching of the wasm failed"}function Be(r){return!nr&&(Z||tr)&&typeof fetch=="function"?fetch(r,{credentials:"same-origin"}).then(e=>{if(!e.ok)throw`failed to load wasm binary file at '${r}'`;return e.arrayBuffer()}).catch(()=>qr(r)):Promise.resolve().then(()=>qr(r))}function Vr(r,e,t){return Be(r).then(o=>WebAssembly.instantiate(o,e)).then(t,o=>{W(`failed to asynchronously prepare wasm: ${o}`),Cr(o)})}function je(r,e,t,o){return!r&&typeof WebAssembly.instantiateStreaming=="function"&&!$r(e)&&typeof fetch=="function"?fetch(e,{credentials:"same-origin"}).then(a=>{var i=WebAssembly.instantiateStreaming(a,t);return i.then(o,function(s){return W(`wasm streaming compile failed: ${s}`),W("falling back to ArrayBuffer instantiation"),Vr(e,t,o)})}):Vr(e,t,o)}function He(){var r={a:Wt};function e(o,a){return j=o.exports,or=j.O,Hr(),Jr=j.R,Oe(j.P),pr("wasm-instantiate"),j}kr("wasm-instantiate");function t(o){e(o.instance)}if(l.instantiateWasm)try{return l.instantiateWasm(r,e)}catch(o){W(`Module.instantiateWasm callback failed with error: ${o}`),F(o)}return je(nr,sr,r,t).catch(F),{}}var g,N;function Gr(r){this.name="ExitStatus",this.message=`Program terminated with exit(${r})`,this.status=r}var Sr=r=>{for(;r.length>0;)r.shift()(l)},Kr=l.noExitRuntime||!0,br=[],Jr,q=r=>{var e=br[r];return e||(r>=br.length&&(br.length=r+1),br[r]=e=Jr.get(r)),e},We=(r,e)=>q(r)(e);class Ye{constructor(e){this.excPtr=e,this.ptr=e-24}set_type(e){P[this.ptr+4>>2]=e}get_type(){return P[this.ptr+4>>2]}set_destructor(e){P[this.ptr+8>>2]=e}get_destructor(){return P[this.ptr+8>>2]}set_caught(e){e=e?1:0,R[this.ptr+12]=e}get_caught(){return R[this.ptr+12]!=0}set_rethrown(e){e=e?1:0,R[this.ptr+13]=e}get_rethrown(){return R[this.ptr+13]!=0}init(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t)}set_adjusted_ptr(e){P[this.ptr+16>>2]=e}get_adjusted_ptr(){return P[this.ptr+16>>2]}get_exception_ptr(){var e=de(this.get_type());if(e)return P[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}var Qr=0,Xe=0,$e=(r,e,t)=>{var o=new Ye(r);throw o.init(e,t),Qr=r,Xe++,Qr},D={isAbs:r=>r.charAt(0)==="/",splitPath:r=>{var e=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return e.exec(r).slice(1)},normalizeArray:(r,e)=>{for(var t=0,o=r.length-1;o>=0;o--){var a=r[o];a==="."?r.splice(o,1):a===".."?(r.splice(o,1),t++):t&&(r.splice(o,1),t--)}if(e)for(;t;t--)r.unshift("..");return r},normalize:r=>{var e=D.isAbs(r),t=r.substr(-1)==="/";return r=D.normalizeArray(r.split("/").filter(o=>!!o),!e).join("/"),!r&&!e&&(r="."),r&&t&&(r+="/"),(e?"/":"")+r},dirname:r=>{var e=D.splitPath(r),t=e[0],o=e[1];return!t&&!o?".":(o&&(o=o.substr(0,o.length-1)),t+o)},basename:r=>{if(r==="/")return"/";r=D.normalize(r),r=r.replace(/\/$/,"");var e=r.lastIndexOf("/");return e===-1?r:r.substr(e+1)},join:(...r)=>D.normalize(r.join("/")),join2:(r,e)=>D.normalize(r+"/"+e)},qe=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return r=>crypto.getRandomValues(r);Cr("initRandomDevice")},Zr=r=>(Zr=qe())(r),J={resolve:(...r)=>{for(var e="",t=!1,o=r.length-1;o>=-1&&!t;o--){var a=o>=0?r[o]:n.cwd();if(typeof a!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!a)return"";e=a+"/"+e,t=D.isAbs(a)}return e=D.normalizeArray(e.split("/").filter(i=>!!i),!t).join("/"),(t?"/":"")+e||"."},relative:(r,e)=>{r=J.resolve(r).substr(1),e=J.resolve(e).substr(1);function t(h){for(var k=0;k<h.length&&h[k]==="";k++);for(var S=h.length-1;S>=0&&h[S]==="";S--);return k>S?[]:h.slice(k,S-k+1)}for(var o=t(r.split("/")),a=t(e.split("/")),i=Math.min(o.length,a.length),s=i,u=0;u<i;u++)if(o[u]!==a[u]){s=u;break}for(var c=[],u=s;u<o.length;u++)c.push("..");return c=c.concat(a.slice(s)),c.join("/")}},re=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,lr=(r,e,t)=>{for(var o=e+t,a=e;r[a]&&!(a>=o);)++a;if(a-e>16&&r.buffer&&re)return re.decode(r.subarray(e,a));for(var i="";e<a;){var s=r[e++];if(!(s&128)){i+=String.fromCharCode(s);continue}var u=r[e++]&63;if((s&224)==192){i+=String.fromCharCode((s&31)<<6|u);continue}var c=r[e++]&63;if((s&240)==224?s=(s&15)<<12|u<<6|c:s=(s&7)<<18|u<<12|c<<6|r[e++]&63,s<65536)i+=String.fromCharCode(s);else{var h=s-65536;i+=String.fromCharCode(55296|h>>10,56320|h&1023)}}return i},Ir=[],Fr=r=>{for(var e=0,t=0;t<r.length;++t){var o=r.charCodeAt(t);o<=127?e++:o<=2047?e+=2:o>=55296&&o<=57343?(e+=4,++t):e+=3}return e},zr=(r,e,t,o)=>{if(!(o>0))return 0;for(var a=t,i=t+o-1,s=0;s<r.length;++s){var u=r.charCodeAt(s);if(u>=55296&&u<=57343){var c=r.charCodeAt(++s);u=65536+((u&1023)<<10)|c&1023}if(u<=127){if(t>=i)break;e[t++]=u}else if(u<=2047){if(t+1>=i)break;e[t++]=192|u>>6,e[t++]=128|u&63}else if(u<=65535){if(t+2>=i)break;e[t++]=224|u>>12,e[t++]=128|u>>6&63,e[t++]=128|u&63}else{if(t+3>=i)break;e[t++]=240|u>>18,e[t++]=128|u>>12&63,e[t++]=128|u>>6&63,e[t++]=128|u&63}}return e[t]=0,t-a};function Dr(r,e,t){var o=t>0?t:Fr(r)+1,a=new Array(o),i=zr(r,a,0,a.length);return e&&(a.length=i),a}var Ve=()=>{if(!Ir.length){var r=null;if(typeof window<"u"&&typeof window.prompt=="function"?(r=window.prompt("Input: "),r!==null&&(r+=`
2
2
  `)):typeof readline=="function"&&(r=readline(),r!==null&&(r+=`
3
- `)),!r)return null;Nr=Dr(r,!0)}return Nr.shift()},rr={ttys:[],init(){},shutdown(){},register(r,e){rr.ttys[r]={input:[],output:[],ops:e},n.registerDevice(r,rr.stream_ops)},stream_ops:{open(r){var e=rr.ttys[r.node.rdev];if(!e)throw new n.ErrnoError(43);r.tty=e,r.seekable=!1},close(r){r.tty.ops.fsync(r.tty)},fsync(r){r.tty.ops.fsync(r.tty)},read(r,e,t,o,a){if(!r.tty||!r.tty.ops.get_char)throw new n.ErrnoError(60);for(var i=0,s=0;s<o;s++){var l;try{l=r.tty.ops.get_char(r.tty)}catch{throw new n.ErrnoError(29)}if(l===void 0&&i===0)throw new n.ErrnoError(6);if(l==null)break;i++,e[t+s]=l}return i&&(r.node.timestamp=Date.now()),i},write(r,e,t,o,a){if(!r.tty||!r.tty.ops.put_char)throw new n.ErrnoError(60);try{for(var i=0;i<o;i++)r.tty.ops.put_char(r.tty,e[t+i])}catch{throw new n.ErrnoError(29)}return o&&(r.node.timestamp=Date.now()),i}},default_tty_ops:{get_char(r){return Ve()},put_char(r,e){e===null||e===10?(mr(ur(r.output,0)),r.output=[]):e!=0&&r.output.push(e)},fsync(r){r.output&&r.output.length>0&&(mr(ur(r.output,0)),r.output=[])},ioctl_tcgets(r){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(r,e,t){return 0},ioctl_tiocgwinsz(r){return[24,80]}},default_tty1_ops:{put_char(r,e){e===null||e===10?(q(ur(r.output,0)),r.output=[]):e!=0&&r.output.push(e)},fsync(r){r.output&&r.output.length>0&&(q(ur(r.output,0)),r.output=[])}}},Ge=(r,e)=>(z.fill(0,r,r+e),r),Ke=(r,e)=>Math.ceil(r/e)*e,ee=r=>{r=Ke(r,65536);var e=ce(65536,r);return e?Ge(e,r):0},p={ops_table:null,mount(r){return p.createNode(null,"/",16895,0)},createNode(r,e,t,o){if(n.isBlkdev(t)||n.isFIFO(t))throw new n.ErrnoError(63);p.ops_table||(p.ops_table={dir:{node:{getattr:p.node_ops.getattr,setattr:p.node_ops.setattr,lookup:p.node_ops.lookup,mknod:p.node_ops.mknod,rename:p.node_ops.rename,unlink:p.node_ops.unlink,rmdir:p.node_ops.rmdir,readdir:p.node_ops.readdir,symlink:p.node_ops.symlink},stream:{llseek:p.stream_ops.llseek}},file:{node:{getattr:p.node_ops.getattr,setattr:p.node_ops.setattr},stream:{llseek:p.stream_ops.llseek,read:p.stream_ops.read,write:p.stream_ops.write,allocate:p.stream_ops.allocate,mmap:p.stream_ops.mmap,msync:p.stream_ops.msync}},link:{node:{getattr:p.node_ops.getattr,setattr:p.node_ops.setattr,readlink:p.node_ops.readlink},stream:{}},chrdev:{node:{getattr:p.node_ops.getattr,setattr:p.node_ops.setattr},stream:n.chrdev_stream_ops}});var a=n.createNode(r,e,t,o);return n.isDir(a.mode)?(a.node_ops=p.ops_table.dir.node,a.stream_ops=p.ops_table.dir.stream,a.contents={}):n.isFile(a.mode)?(a.node_ops=p.ops_table.file.node,a.stream_ops=p.ops_table.file.stream,a.usedBytes=0,a.contents=null):n.isLink(a.mode)?(a.node_ops=p.ops_table.link.node,a.stream_ops=p.ops_table.link.stream):n.isChrdev(a.mode)&&(a.node_ops=p.ops_table.chrdev.node,a.stream_ops=p.ops_table.chrdev.stream),a.timestamp=Date.now(),r&&(r.contents[e]=a,r.timestamp=a.timestamp),a},getFileDataAsTypedArray(r){return r.contents?r.contents.subarray?r.contents.subarray(0,r.usedBytes):new Uint8Array(r.contents):new Uint8Array(0)},expandFileStorage(r,e){var t=r.contents?r.contents.length:0;if(!(t>=e)){var o=1024*1024;e=Math.max(e,t*(t<o?2:1.125)>>>0),t!=0&&(e=Math.max(e,256));var a=r.contents;r.contents=new Uint8Array(e),r.usedBytes>0&&r.contents.set(a.subarray(0,r.usedBytes),0)}},resizeFileStorage(r,e){if(r.usedBytes!=e)if(e==0)r.contents=null,r.usedBytes=0;else{var t=r.contents;r.contents=new Uint8Array(e),t&&r.contents.set(t.subarray(0,Math.min(e,r.usedBytes))),r.usedBytes=e}},node_ops:{getattr(r){var e={};return e.dev=n.isChrdev(r.mode)?r.id:1,e.ino=r.id,e.mode=r.mode,e.nlink=1,e.uid=0,e.gid=0,e.rdev=r.rdev,n.isDir(r.mode)?e.size=4096:n.isFile(r.mode)?e.size=r.usedBytes:n.isLink(r.mode)?e.size=r.link.length:e.size=0,e.atime=new Date(r.timestamp),e.mtime=new Date(r.timestamp),e.ctime=new Date(r.timestamp),e.blksize=4096,e.blocks=Math.ceil(e.size/e.blksize),e},setattr(r,e){e.mode!==void 0&&(r.mode=e.mode),e.timestamp!==void 0&&(r.timestamp=e.timestamp),e.size!==void 0&&p.resizeFileStorage(r,e.size)},lookup(r,e){throw n.genericErrors[44]},mknod(r,e,t,o){return p.createNode(r,e,t,o)},rename(r,e,t){if(n.isDir(r.mode)){var o;try{o=n.lookupNode(e,t)}catch{}if(o)for(var a in o.contents)throw new n.ErrnoError(55)}delete r.parent.contents[r.name],r.parent.timestamp=Date.now(),r.name=t,e.contents[t]=r,e.timestamp=r.parent.timestamp,r.parent=e},unlink(r,e){delete r.contents[e],r.timestamp=Date.now()},rmdir(r,e){var t=n.lookupNode(r,e);for(var o in t.contents)throw new n.ErrnoError(55);delete r.contents[e],r.timestamp=Date.now()},readdir(r){var e=[".",".."];for(var t of Object.keys(r.contents))e.push(t);return e},symlink(r,e,t){var o=p.createNode(r,e,41471,0);return o.link=t,o},readlink(r){if(!n.isLink(r.mode))throw new n.ErrnoError(28);return r.link}},stream_ops:{read(r,e,t,o,a){var i=r.node.contents;if(a>=r.node.usedBytes)return 0;var s=Math.min(r.node.usedBytes-a,o);if(s>8&&i.subarray)e.set(i.subarray(a,a+s),t);else for(var l=0;l<s;l++)e[t+l]=i[a+l];return s},write(r,e,t,o,a,i){if(e.buffer===R.buffer&&(i=!1),!o)return 0;var s=r.node;if(s.timestamp=Date.now(),e.subarray&&(!s.contents||s.contents.subarray)){if(i)return s.contents=e.subarray(t,t+o),s.usedBytes=o,o;if(s.usedBytes===0&&a===0)return s.contents=e.slice(t,t+o),s.usedBytes=o,o;if(a+o<=s.usedBytes)return s.contents.set(e.subarray(t,t+o),a),o}if(p.expandFileStorage(s,a+o),s.contents.subarray&&e.subarray)s.contents.set(e.subarray(t,t+o),a);else for(var l=0;l<o;l++)s.contents[a+l]=e[t+l];return s.usedBytes=Math.max(s.usedBytes,a+o),o},llseek(r,e,t){var o=e;if(t===1?o+=r.position:t===2&&n.isFile(r.node.mode)&&(o+=r.node.usedBytes),o<0)throw new n.ErrnoError(28);return o},allocate(r,e,t){p.expandFileStorage(r.node,e+t),r.node.usedBytes=Math.max(r.node.usedBytes,e+t)},mmap(r,e,t,o,a){if(!n.isFile(r.node.mode))throw new n.ErrnoError(43);var i,s,l=r.node.contents;if(!(a&2)&&l.buffer===R.buffer)s=!1,i=l.byteOffset;else{if((t>0||t+e<l.length)&&(l.subarray?l=l.subarray(t,t+e):l=Array.prototype.slice.call(l,t,t+e)),s=!0,i=ee(e),!i)throw new n.ErrnoError(48);R.set(l,i)}return{ptr:i,allocated:s}},msync(r,e,t,o,a){return p.stream_ops.write(r,e,0,o,t,!1),0}}},Je=(r,e,t,o)=>{var a=o?"":`al ${r}`;ir(r,i=>{e(new Uint8Array(i)),a&&pr(a)},i=>{if(t)t();else throw`Loading data file "${r}" failed.`}),a&&kr(a)},Qe=(r,e,t,o,a,i)=>{n.createDataFile(r,e,t,o,a,i)},Ze=u.preloadPlugins||[],rt=(r,e,t,o)=>{typeof Browser<"u"&&Browser.init();var a=!1;return Ze.forEach(i=>{a||i.canHandle(e)&&(i.handle(r,e,t,o),a=!0)}),a},et=(r,e,t,o,a,i,s,l,c,h)=>{var S=e?J.resolve(P.join2(r,e)):r,b=`cp ${S}`;function m(v){function E(O){h?.(),l||Qe(r,e,O,o,a,c),i?.(),pr(b)}rt(v,S,E,()=>{s?.(),pr(b)})||E(v)}kr(b),typeof t=="string"?Je(t,m,s):m(t)},tt=r=>{var e={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},t=e[r];if(typeof t>"u")throw new Error(`Unknown file open mode: ${r}`);return t},zr=(r,e)=>{var t=0;return r&&(t|=365),e&&(t|=146),t},n={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:class{constructor(r){this.name="ErrnoError",this.errno=r}},genericErrors:{},filesystems:null,syncFSRequests:0,FSStream:class{constructor(){this.shared={}}get object(){return this.node}set object(r){this.node=r}get isRead(){return(this.flags&2097155)!==1}get isWrite(){return(this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(r){this.shared.flags=r}get position(){return this.shared.position}set position(r){this.shared.position=r}},FSNode:class{constructor(r,e,t,o){r||(r=this),this.parent=r,this.mount=r.mount,this.mounted=null,this.id=n.nextInode++,this.name=e,this.mode=t,this.node_ops={},this.stream_ops={},this.rdev=o,this.readMode=365,this.writeMode=146}get read(){return(this.mode&this.readMode)===this.readMode}set read(r){r?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(r){r?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return n.isDir(this.mode)}get isDevice(){return n.isChrdev(this.mode)}},lookupPath(r,e={}){if(r=J.resolve(r),!r)return{path:"",node:null};var t={follow_mount:!0,recurse_count:0};if(e=Object.assign(t,e),e.recurse_count>8)throw new n.ErrnoError(32);for(var o=r.split("/").filter(b=>!!b),a=n.root,i="/",s=0;s<o.length;s++){var l=s===o.length-1;if(l&&e.parent)break;if(a=n.lookupNode(a,o[s]),i=P.join2(i,o[s]),n.isMountpoint(a)&&(!l||l&&e.follow_mount)&&(a=a.mounted.root),!l||e.follow)for(var c=0;n.isLink(a.mode);){var h=n.readlink(i);i=J.resolve(P.dirname(i),h);var S=n.lookupPath(i,{recurse_count:e.recurse_count+1});if(a=S.node,c++>40)throw new n.ErrnoError(32)}}return{path:i,node:a}},getPath(r){for(var e;;){if(n.isRoot(r)){var t=r.mount.mountpoint;return e?t[t.length-1]!=="/"?`${t}/${e}`:t+e:t}e=e?`${r.name}/${e}`:r.name,r=r.parent}},hashName(r,e){for(var t=0,o=0;o<e.length;o++)t=(t<<5)-t+e.charCodeAt(o)|0;return(r+t>>>0)%n.nameTable.length},hashAddNode(r){var e=n.hashName(r.parent.id,r.name);r.name_next=n.nameTable[e],n.nameTable[e]=r},hashRemoveNode(r){var e=n.hashName(r.parent.id,r.name);if(n.nameTable[e]===r)n.nameTable[e]=r.name_next;else for(var t=n.nameTable[e];t;){if(t.name_next===r){t.name_next=r.name_next;break}t=t.name_next}},lookupNode(r,e){var t=n.mayLookup(r);if(t)throw new n.ErrnoError(t);for(var o=n.hashName(r.id,e),a=n.nameTable[o];a;a=a.name_next){var i=a.name;if(a.parent.id===r.id&&i===e)return a}return n.lookup(r,e)},createNode(r,e,t,o){var a=new n.FSNode(r,e,t,o);return n.hashAddNode(a),a},destroyNode(r){n.hashRemoveNode(r)},isRoot(r){return r===r.parent},isMountpoint(r){return!!r.mounted},isFile(r){return(r&61440)===32768},isDir(r){return(r&61440)===16384},isLink(r){return(r&61440)===40960},isChrdev(r){return(r&61440)===8192},isBlkdev(r){return(r&61440)===24576},isFIFO(r){return(r&61440)===4096},isSocket(r){return(r&49152)===49152},flagsToPermissionString(r){var e=["r","w","rw"][r&3];return r&512&&(e+="w"),e},nodePermissions(r,e){return n.ignorePermissions?0:e.includes("r")&&!(r.mode&292)||e.includes("w")&&!(r.mode&146)||e.includes("x")&&!(r.mode&73)?2:0},mayLookup(r){if(!n.isDir(r.mode))return 54;var e=n.nodePermissions(r,"x");return e||(r.node_ops.lookup?0:2)},mayCreate(r,e){try{var t=n.lookupNode(r,e);return 20}catch{}return n.nodePermissions(r,"wx")},mayDelete(r,e,t){var o;try{o=n.lookupNode(r,e)}catch(i){return i.errno}var a=n.nodePermissions(r,"wx");if(a)return a;if(t){if(!n.isDir(o.mode))return 54;if(n.isRoot(o)||n.getPath(o)===n.cwd())return 10}else if(n.isDir(o.mode))return 31;return 0},mayOpen(r,e){return r?n.isLink(r.mode)?32:n.isDir(r.mode)&&(n.flagsToPermissionString(e)!=="r"||e&512)?31:n.nodePermissions(r,n.flagsToPermissionString(e)):44},MAX_OPEN_FDS:4096,nextfd(){for(var r=0;r<=n.MAX_OPEN_FDS;r++)if(!n.streams[r])return r;throw new n.ErrnoError(33)},getStreamChecked(r){var e=n.getStream(r);if(!e)throw new n.ErrnoError(8);return e},getStream:r=>n.streams[r],createStream(r,e=-1){return r=Object.assign(new n.FSStream,r),e==-1&&(e=n.nextfd()),r.fd=e,n.streams[e]=r,r},closeStream(r){n.streams[r]=null},dupStream(r,e=-1){var t=n.createStream(r,e);return t.stream_ops?.dup?.(t),t},chrdev_stream_ops:{open(r){var e=n.getDevice(r.node.rdev);r.stream_ops=e.stream_ops,r.stream_ops.open?.(r)},llseek(){throw new n.ErrnoError(70)}},major:r=>r>>8,minor:r=>r&255,makedev:(r,e)=>r<<8|e,registerDevice(r,e){n.devices[r]={stream_ops:e}},getDevice:r=>n.devices[r],getMounts(r){for(var e=[],t=[r];t.length;){var o=t.pop();e.push(o),t.push(...o.mounts)}return e},syncfs(r,e){typeof r=="function"&&(e=r,r=!1),n.syncFSRequests++,n.syncFSRequests>1&&q(`warning: ${n.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=n.getMounts(n.root.mount),o=0;function a(s){return n.syncFSRequests--,e(s)}function i(s){if(s)return i.errored?void 0:(i.errored=!0,a(s));++o>=t.length&&a(null)}t.forEach(s=>{if(!s.type.syncfs)return i(null);s.type.syncfs(s,r,i)})},mount(r,e,t){var o=t==="/",a=!t,i;if(o&&n.root)throw new n.ErrnoError(10);if(!o&&!a){var s=n.lookupPath(t,{follow_mount:!1});if(t=s.path,i=s.node,n.isMountpoint(i))throw new n.ErrnoError(10);if(!n.isDir(i.mode))throw new n.ErrnoError(54)}var l={type:r,opts:e,mountpoint:t,mounts:[]},c=r.mount(l);return c.mount=l,l.root=c,o?n.root=c:i&&(i.mounted=l,i.mount&&i.mount.mounts.push(l)),c},unmount(r){var e=n.lookupPath(r,{follow_mount:!1});if(!n.isMountpoint(e.node))throw new n.ErrnoError(28);var t=e.node,o=t.mounted,a=n.getMounts(o);Object.keys(n.nameTable).forEach(s=>{for(var l=n.nameTable[s];l;){var c=l.name_next;a.includes(l.mount)&&n.destroyNode(l),l=c}}),t.mounted=null;var i=t.mount.mounts.indexOf(o);t.mount.mounts.splice(i,1)},lookup(r,e){return r.node_ops.lookup(r,e)},mknod(r,e,t){var o=n.lookupPath(r,{parent:!0}),a=o.node,i=P.basename(r);if(!i||i==="."||i==="..")throw new n.ErrnoError(28);var s=n.mayCreate(a,i);if(s)throw new n.ErrnoError(s);if(!a.node_ops.mknod)throw new n.ErrnoError(63);return a.node_ops.mknod(a,i,e,t)},create(r,e){return e=e!==void 0?e:438,e&=4095,e|=32768,n.mknod(r,e,0)},mkdir(r,e){return e=e!==void 0?e:511,e&=1023,e|=16384,n.mknod(r,e,0)},mkdirTree(r,e){for(var t=r.split("/"),o="",a=0;a<t.length;++a)if(t[a]){o+="/"+t[a];try{n.mkdir(o,e)}catch(i){if(i.errno!=20)throw i}}},mkdev(r,e,t){return typeof t>"u"&&(t=e,e=438),e|=8192,n.mknod(r,e,t)},symlink(r,e){if(!J.resolve(r))throw new n.ErrnoError(44);var t=n.lookupPath(e,{parent:!0}),o=t.node;if(!o)throw new n.ErrnoError(44);var a=P.basename(e),i=n.mayCreate(o,a);if(i)throw new n.ErrnoError(i);if(!o.node_ops.symlink)throw new n.ErrnoError(63);return o.node_ops.symlink(o,a,r)},rename(r,e){var t=P.dirname(r),o=P.dirname(e),a=P.basename(r),i=P.basename(e),s,l,c;if(s=n.lookupPath(r,{parent:!0}),l=s.node,s=n.lookupPath(e,{parent:!0}),c=s.node,!l||!c)throw new n.ErrnoError(44);if(l.mount!==c.mount)throw new n.ErrnoError(75);var h=n.lookupNode(l,a),S=J.relative(r,o);if(S.charAt(0)!==".")throw new n.ErrnoError(28);if(S=J.relative(e,t),S.charAt(0)!==".")throw new n.ErrnoError(55);var b;try{b=n.lookupNode(c,i)}catch{}if(h!==b){var m=n.isDir(h.mode),v=n.mayDelete(l,a,m);if(v)throw new n.ErrnoError(v);if(v=b?n.mayDelete(c,i,m):n.mayCreate(c,i),v)throw new n.ErrnoError(v);if(!l.node_ops.rename)throw new n.ErrnoError(63);if(n.isMountpoint(h)||b&&n.isMountpoint(b))throw new n.ErrnoError(10);if(c!==l&&(v=n.nodePermissions(l,"w"),v))throw new n.ErrnoError(v);n.hashRemoveNode(h);try{l.node_ops.rename(h,c,i)}catch(E){throw E}finally{n.hashAddNode(h)}}},rmdir(r){var e=n.lookupPath(r,{parent:!0}),t=e.node,o=P.basename(r),a=n.lookupNode(t,o),i=n.mayDelete(t,o,!0);if(i)throw new n.ErrnoError(i);if(!t.node_ops.rmdir)throw new n.ErrnoError(63);if(n.isMountpoint(a))throw new n.ErrnoError(10);t.node_ops.rmdir(t,o),n.destroyNode(a)},readdir(r){var e=n.lookupPath(r,{follow:!0}),t=e.node;if(!t.node_ops.readdir)throw new n.ErrnoError(54);return t.node_ops.readdir(t)},unlink(r){var e=n.lookupPath(r,{parent:!0}),t=e.node;if(!t)throw new n.ErrnoError(44);var o=P.basename(r),a=n.lookupNode(t,o),i=n.mayDelete(t,o,!1);if(i)throw new n.ErrnoError(i);if(!t.node_ops.unlink)throw new n.ErrnoError(63);if(n.isMountpoint(a))throw new n.ErrnoError(10);t.node_ops.unlink(t,o),n.destroyNode(a)},readlink(r){var e=n.lookupPath(r),t=e.node;if(!t)throw new n.ErrnoError(44);if(!t.node_ops.readlink)throw new n.ErrnoError(28);return J.resolve(n.getPath(t.parent),t.node_ops.readlink(t))},stat(r,e){var t=n.lookupPath(r,{follow:!e}),o=t.node;if(!o)throw new n.ErrnoError(44);if(!o.node_ops.getattr)throw new n.ErrnoError(63);return o.node_ops.getattr(o)},lstat(r){return n.stat(r,!0)},chmod(r,e,t){var o;if(typeof r=="string"){var a=n.lookupPath(r,{follow:!t});o=a.node}else o=r;if(!o.node_ops.setattr)throw new n.ErrnoError(63);o.node_ops.setattr(o,{mode:e&4095|o.mode&-4096,timestamp:Date.now()})},lchmod(r,e){n.chmod(r,e,!0)},fchmod(r,e){var t=n.getStreamChecked(r);n.chmod(t.node,e)},chown(r,e,t,o){var a;if(typeof r=="string"){var i=n.lookupPath(r,{follow:!o});a=i.node}else a=r;if(!a.node_ops.setattr)throw new n.ErrnoError(63);a.node_ops.setattr(a,{timestamp:Date.now()})},lchown(r,e,t){n.chown(r,e,t,!0)},fchown(r,e,t){var o=n.getStreamChecked(r);n.chown(o.node,e,t)},truncate(r,e){if(e<0)throw new n.ErrnoError(28);var t;if(typeof r=="string"){var o=n.lookupPath(r,{follow:!0});t=o.node}else t=r;if(!t.node_ops.setattr)throw new n.ErrnoError(63);if(n.isDir(t.mode))throw new n.ErrnoError(31);if(!n.isFile(t.mode))throw new n.ErrnoError(28);var a=n.nodePermissions(t,"w");if(a)throw new n.ErrnoError(a);t.node_ops.setattr(t,{size:e,timestamp:Date.now()})},ftruncate(r,e){var t=n.getStreamChecked(r);if(!(t.flags&2097155))throw new n.ErrnoError(28);n.truncate(t.node,e)},utime(r,e,t){var o=n.lookupPath(r,{follow:!0}),a=o.node;a.node_ops.setattr(a,{timestamp:Math.max(e,t)})},open(r,e,t){if(r==="")throw new n.ErrnoError(44);e=typeof e=="string"?tt(e):e,t=typeof t>"u"?438:t,e&64?t=t&4095|32768:t=0;var o;if(typeof r=="object")o=r;else{r=P.normalize(r);try{var a=n.lookupPath(r,{follow:!(e&131072)});o=a.node}catch{}}var i=!1;if(e&64)if(o){if(e&128)throw new n.ErrnoError(20)}else o=n.mknod(r,t,0),i=!0;if(!o)throw new n.ErrnoError(44);if(n.isChrdev(o.mode)&&(e&=-513),e&65536&&!n.isDir(o.mode))throw new n.ErrnoError(54);if(!i){var s=n.mayOpen(o,e);if(s)throw new n.ErrnoError(s)}e&512&&!i&&n.truncate(o,0),e&=-131713;var l=n.createStream({node:o,path:n.getPath(o),flags:e,seekable:!0,position:0,stream_ops:o.stream_ops,ungotten:[],error:!1});return l.stream_ops.open&&l.stream_ops.open(l),u.logReadFiles&&!(e&1)&&(n.readFiles||(n.readFiles={}),r in n.readFiles||(n.readFiles[r]=1)),l},close(r){if(n.isClosed(r))throw new n.ErrnoError(8);r.getdents&&(r.getdents=null);try{r.stream_ops.close&&r.stream_ops.close(r)}catch(e){throw e}finally{n.closeStream(r.fd)}r.fd=null},isClosed(r){return r.fd===null},llseek(r,e,t){if(n.isClosed(r))throw new n.ErrnoError(8);if(!r.seekable||!r.stream_ops.llseek)throw new n.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new n.ErrnoError(28);return r.position=r.stream_ops.llseek(r,e,t),r.ungotten=[],r.position},read(r,e,t,o,a){if(o<0||a<0)throw new n.ErrnoError(28);if(n.isClosed(r))throw new n.ErrnoError(8);if((r.flags&2097155)===1)throw new n.ErrnoError(8);if(n.isDir(r.node.mode))throw new n.ErrnoError(31);if(!r.stream_ops.read)throw new n.ErrnoError(28);var i=typeof a<"u";if(!i)a=r.position;else if(!r.seekable)throw new n.ErrnoError(70);var s=r.stream_ops.read(r,e,t,o,a);return i||(r.position+=s),s},write(r,e,t,o,a,i){if(o<0||a<0)throw new n.ErrnoError(28);if(n.isClosed(r))throw new n.ErrnoError(8);if(!(r.flags&2097155))throw new n.ErrnoError(8);if(n.isDir(r.node.mode))throw new n.ErrnoError(31);if(!r.stream_ops.write)throw new n.ErrnoError(28);r.seekable&&r.flags&1024&&n.llseek(r,0,2);var s=typeof a<"u";if(!s)a=r.position;else if(!r.seekable)throw new n.ErrnoError(70);var l=r.stream_ops.write(r,e,t,o,a,i);return s||(r.position+=l),l},allocate(r,e,t){if(n.isClosed(r))throw new n.ErrnoError(8);if(e<0||t<=0)throw new n.ErrnoError(28);if(!(r.flags&2097155))throw new n.ErrnoError(8);if(!n.isFile(r.node.mode)&&!n.isDir(r.node.mode))throw new n.ErrnoError(43);if(!r.stream_ops.allocate)throw new n.ErrnoError(138);r.stream_ops.allocate(r,e,t)},mmap(r,e,t,o,a){if(o&2&&!(a&2)&&(r.flags&2097155)!==2)throw new n.ErrnoError(2);if((r.flags&2097155)===1)throw new n.ErrnoError(2);if(!r.stream_ops.mmap)throw new n.ErrnoError(43);return r.stream_ops.mmap(r,e,t,o,a)},msync(r,e,t,o,a){return r.stream_ops.msync?r.stream_ops.msync(r,e,t,o,a):0},ioctl(r,e,t){if(!r.stream_ops.ioctl)throw new n.ErrnoError(59);return r.stream_ops.ioctl(r,e,t)},readFile(r,e={}){if(e.flags=e.flags||0,e.encoding=e.encoding||"binary",e.encoding!=="utf8"&&e.encoding!=="binary")throw new Error(`Invalid encoding type "${e.encoding}"`);var t,o=n.open(r,e.flags),a=n.stat(r),i=a.size,s=new Uint8Array(i);return n.read(o,s,0,i,0),e.encoding==="utf8"?t=ur(s,0):e.encoding==="binary"&&(t=s),n.close(o),t},writeFile(r,e,t={}){t.flags=t.flags||577;var o=n.open(r,t.flags,t.mode);if(typeof e=="string"){var a=new Uint8Array(Pr(e)+1),i=Lr(e,a,0,a.length);n.write(o,a,0,i,void 0,t.canOwn)}else if(ArrayBuffer.isView(e))n.write(o,e,0,e.byteLength,void 0,t.canOwn);else throw new Error("Unsupported data type");n.close(o)},cwd:()=>n.currentPath,chdir(r){var e=n.lookupPath(r,{follow:!0});if(e.node===null)throw new n.ErrnoError(44);if(!n.isDir(e.node.mode))throw new n.ErrnoError(54);var t=n.nodePermissions(e.node,"x");if(t)throw new n.ErrnoError(t);n.currentPath=e.path},createDefaultDirectories(){n.mkdir("/tmp"),n.mkdir("/home"),n.mkdir("/home/web_user")},createDefaultDevices(){n.mkdir("/dev"),n.registerDevice(n.makedev(1,3),{read:()=>0,write:(o,a,i,s,l)=>s}),n.mkdev("/dev/null",n.makedev(1,3)),rr.register(n.makedev(5,0),rr.default_tty_ops),rr.register(n.makedev(6,0),rr.default_tty1_ops),n.mkdev("/dev/tty",n.makedev(5,0)),n.mkdev("/dev/tty1",n.makedev(6,0));var r=new Uint8Array(1024),e=0,t=()=>(e===0&&(e=Zr(r).byteLength),r[--e]);n.createDevice("/dev","random",t),n.createDevice("/dev","urandom",t),n.mkdir("/dev/shm"),n.mkdir("/dev/shm/tmp")},createSpecialDirectories(){n.mkdir("/proc");var r=n.mkdir("/proc/self");n.mkdir("/proc/self/fd"),n.mount({mount(){var e=n.createNode(r,"fd",16895,73);return e.node_ops={lookup(t,o){var a=+o,i=n.getStreamChecked(a),s={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>i.path}};return s.parent=s,s}},e}},{},"/proc/self/fd")},createStandardStreams(){u.stdin?n.createDevice("/dev","stdin",u.stdin):n.symlink("/dev/tty","/dev/stdin"),u.stdout?n.createDevice("/dev","stdout",null,u.stdout):n.symlink("/dev/tty","/dev/stdout"),u.stderr?n.createDevice("/dev","stderr",null,u.stderr):n.symlink("/dev/tty1","/dev/stderr");var r=n.open("/dev/stdin",0),e=n.open("/dev/stdout",1),t=n.open("/dev/stderr",1)},staticInit(){[44].forEach(r=>{n.genericErrors[r]=new n.ErrnoError(r),n.genericErrors[r].stack="<generic error, no stack>"}),n.nameTable=new Array(4096),n.mount(p,{},"/"),n.createDefaultDirectories(),n.createDefaultDevices(),n.createSpecialDirectories(),n.filesystems={MEMFS:p}},init(r,e,t){n.init.initialized=!0,u.stdin=r||u.stdin,u.stdout=e||u.stdout,u.stderr=t||u.stderr,n.createStandardStreams()},quit(){n.init.initialized=!1;for(var r=0;r<n.streams.length;r++){var e=n.streams[r];e&&n.close(e)}},findObject(r,e){var t=n.analyzePath(r,e);return t.exists?t.object:null},analyzePath(r,e){try{var t=n.lookupPath(r,{follow:!e});r=t.path}catch{}var o={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var t=n.lookupPath(r,{parent:!0});o.parentExists=!0,o.parentPath=t.path,o.parentObject=t.node,o.name=P.basename(r),t=n.lookupPath(r,{follow:!e}),o.exists=!0,o.path=t.path,o.object=t.node,o.name=t.node.name,o.isRoot=t.path==="/"}catch(a){o.error=a.errno}return o},createPath(r,e,t,o){r=typeof r=="string"?r:n.getPath(r);for(var a=e.split("/").reverse();a.length;){var i=a.pop();if(i){var s=P.join2(r,i);try{n.mkdir(s)}catch{}r=s}}return s},createFile(r,e,t,o,a){var i=P.join2(typeof r=="string"?r:n.getPath(r),e),s=zr(o,a);return n.create(i,s)},createDataFile(r,e,t,o,a,i){var s=e;r&&(r=typeof r=="string"?r:n.getPath(r),s=e?P.join2(r,e):r);var l=zr(o,a),c=n.create(s,l);if(t){if(typeof t=="string"){for(var h=new Array(t.length),S=0,b=t.length;S<b;++S)h[S]=t.charCodeAt(S);t=h}n.chmod(c,l|146);var m=n.open(c,577);n.write(m,t,0,t.length,0,i),n.close(m),n.chmod(c,l)}},createDevice(r,e,t,o){var a=P.join2(typeof r=="string"?r:n.getPath(r),e),i=zr(!!t,!!o);n.createDevice.major||(n.createDevice.major=64);var s=n.makedev(n.createDevice.major++,0);return n.registerDevice(s,{open(l){l.seekable=!1},close(l){o?.buffer?.length&&o(10)},read(l,c,h,S,b){for(var m=0,v=0;v<S;v++){var E;try{E=t()}catch{throw new n.ErrnoError(29)}if(E===void 0&&m===0)throw new n.ErrnoError(6);if(E==null)break;m++,c[h+v]=E}return m&&(l.node.timestamp=Date.now()),m},write(l,c,h,S,b){for(var m=0;m<S;m++)try{o(c[h+m])}catch{throw new n.ErrnoError(29)}return S&&(l.node.timestamp=Date.now()),m}}),n.mkdev(a,i,s)},forceLoadFile(r){if(r.isDevice||r.isFolder||r.link||r.contents)return!0;if(typeof XMLHttpRequest<"u")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(j)try{r.contents=Dr(j(r.url),!0),r.usedBytes=r.contents.length}catch{throw new n.ErrnoError(29)}else throw new Error("Cannot load without read() or XMLHttpRequest.")},createLazyFile(r,e,t,o,a){class i{constructor(){this.lengthKnown=!1,this.chunks=[]}get(v){if(!(v>this.length-1||v<0)){var E=v%this.chunkSize,O=v/this.chunkSize|0;return this.getter(O)[E]}}setDataGetter(v){this.getter=v}cacheLength(){var v=new XMLHttpRequest;if(v.open("HEAD",t,!1),v.send(null),!(v.status>=200&&v.status<300||v.status===304))throw new Error("Couldn't load "+t+". Status: "+v.status);var E=Number(v.getResponseHeader("Content-length")),O,W=(O=v.getResponseHeader("Accept-Ranges"))&&O==="bytes",U=(O=v.getResponseHeader("Content-Encoding"))&&O==="gzip",f=1024*1024;W||(f=E);var d=(M,Y)=>{if(M>Y)throw new Error("invalid range ("+M+", "+Y+") or no bytes requested!");if(Y>E-1)throw new Error("only "+E+" bytes available! programmer error!");var T=new XMLHttpRequest;if(T.open("GET",t,!1),E!==f&&T.setRequestHeader("Range","bytes="+M+"-"+Y),T.responseType="arraybuffer",T.overrideMimeType&&T.overrideMimeType("text/plain; charset=x-user-defined"),T.send(null),!(T.status>=200&&T.status<300||T.status===304))throw new Error("Couldn't load "+t+". Status: "+T.status);return T.response!==void 0?new Uint8Array(T.response||[]):Dr(T.responseText||"",!0)},N=this;N.setDataGetter(M=>{var Y=M*f,T=(M+1)*f-1;if(T=Math.min(T,E-1),typeof N.chunks[M]>"u"&&(N.chunks[M]=d(Y,T)),typeof N.chunks[M]>"u")throw new Error("doXHR failed!");return N.chunks[M]}),(U||!E)&&(f=E=1,E=this.getter(0).length,f=E,mr("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=E,this._chunkSize=f,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(typeof XMLHttpRequest<"u"){if(!tr)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var s=new i,l={isDevice:!1,contents:s}}else var l={isDevice:!1,url:t};var c=n.createFile(r,e,l,o,a);l.contents?c.contents=l.contents:l.url&&(c.contents=null,c.url=l.url),Object.defineProperties(c,{usedBytes:{get:function(){return this.contents.length}}});var h={},S=Object.keys(c.stream_ops);S.forEach(m=>{var v=c.stream_ops[m];h[m]=(...E)=>(n.forceLoadFile(c),v(...E))});function b(m,v,E,O,W){var U=m.node.contents;if(W>=U.length)return 0;var f=Math.min(U.length-W,O);if(U.slice)for(var d=0;d<f;d++)v[E+d]=U[W+d];else for(var d=0;d<f;d++)v[E+d]=U.get(W+d);return f}return h.read=(m,v,E,O,W)=>(n.forceLoadFile(c),b(m,v,E,O,W)),h.mmap=(m,v,E,O,W)=>{n.forceLoadFile(c);var U=ee(v);if(!U)throw new n.ErrnoError(48);return b(m,R,U,v,E),{ptr:U,allocated:!0}},c.stream_ops=h,c}},Or=(r,e)=>r?ur(z,r,e):"",y={DEFAULT_POLLMASK:5,calculateAt(r,e,t){if(P.isAbs(e))return e;var o;if(r===-100)o=n.cwd();else{var a=y.getStreamFromFD(r);o=a.path}if(e.length==0){if(!t)throw new n.ErrnoError(44);return o}return P.join2(o,e)},doStat(r,e,t){var o=r(e);_[t>>2]=o.dev,_[t+4>>2]=o.mode,D[t+8>>2]=o.nlink,_[t+12>>2]=o.uid,_[t+16>>2]=o.gid,_[t+20>>2]=o.rdev,I=[o.size>>>0,(g=o.size,+Math.abs(g)>=1?g>0?+Math.floor(g/4294967296)>>>0:~~+Math.ceil((g-+(~~g>>>0))/4294967296)>>>0:0)],_[t+24>>2]=I[0],_[t+28>>2]=I[1],_[t+32>>2]=4096,_[t+36>>2]=o.blocks;var a=o.atime.getTime(),i=o.mtime.getTime(),s=o.ctime.getTime();return I=[Math.floor(a/1e3)>>>0,(g=Math.floor(a/1e3),+Math.abs(g)>=1?g>0?+Math.floor(g/4294967296)>>>0:~~+Math.ceil((g-+(~~g>>>0))/4294967296)>>>0:0)],_[t+40>>2]=I[0],_[t+44>>2]=I[1],D[t+48>>2]=a%1e3*1e3,I=[Math.floor(i/1e3)>>>0,(g=Math.floor(i/1e3),+Math.abs(g)>=1?g>0?+Math.floor(g/4294967296)>>>0:~~+Math.ceil((g-+(~~g>>>0))/4294967296)>>>0:0)],_[t+56>>2]=I[0],_[t+60>>2]=I[1],D[t+64>>2]=i%1e3*1e3,I=[Math.floor(s/1e3)>>>0,(g=Math.floor(s/1e3),+Math.abs(g)>=1?g>0?+Math.floor(g/4294967296)>>>0:~~+Math.ceil((g-+(~~g>>>0))/4294967296)>>>0:0)],_[t+72>>2]=I[0],_[t+76>>2]=I[1],D[t+80>>2]=s%1e3*1e3,I=[o.ino>>>0,(g=o.ino,+Math.abs(g)>=1?g>0?+Math.floor(g/4294967296)>>>0:~~+Math.ceil((g-+(~~g>>>0))/4294967296)>>>0:0)],_[t+88>>2]=I[0],_[t+92>>2]=I[1],0},doMsync(r,e,t,o,a){if(!n.isFile(e.node.mode))throw new n.ErrnoError(43);if(o&2)return 0;var i=z.slice(r,r+t);n.msync(e,i,a,t,o)},varargs:void 0,get(){var r=_[+y.varargs>>2];return y.varargs+=4,r},getp(){return y.get()},getStr(r){var e=Or(r);return e},getStreamFromFD(r){var e=n.getStreamChecked(r);return e}};function nt(r){try{return r=y.getStr(r),n.chdir(r),0}catch(e){if(typeof n>"u"||e.name!=="ErrnoError")throw e;return-e.errno}}function ot(r,e,t,o){try{if(e=y.getStr(e),e=y.calculateAt(r,e),t&-8)return-28;var a=n.lookupPath(e,{follow:!0}),i=a.node;if(!i)return-44;var s="";return t&4&&(s+="r"),t&2&&(s+="w"),t&1&&(s+="x"),s&&n.nodePermissions(i,s)?-2:0}catch(l){if(typeof n>"u"||l.name!=="ErrnoError")throw l;return-l.errno}}function at(r,e,t){y.varargs=t;try{var o=y.getStreamFromFD(r);switch(e){case 0:{var a=y.get();if(a<0)return-28;for(;n.streams[a];)a++;var i;return i=n.dupStream(o,a),i.fd}case 1:case 2:return 0;case 3:return o.flags;case 4:{var a=y.get();return o.flags|=a,0}case 12:{var a=y.getp(),s=0;return Sr[a+s>>1]=2,0}case 13:case 14:return 0}return-28}catch(l){if(typeof n>"u"||l.name!=="ErrnoError")throw l;return-l.errno}}function it(r,e){try{var t=y.getStreamFromFD(r);return y.doStat(n.stat,t.path,e)}catch(o){if(typeof n>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}var te=(r,e,t)=>Lr(r,z,e,t);function st(r,e){try{if(e===0)return-28;var t=n.cwd(),o=Pr(t)+1;return e<o?-68:(te(t,r,e),o)}catch(a){if(typeof n>"u"||a.name!=="ErrnoError")throw a;return-a.errno}}function lt(r,e,t){y.varargs=t;try{var o=y.getStreamFromFD(r);switch(e){case 21509:return o.tty?0:-59;case 21505:{if(!o.tty)return-59;if(o.tty.ops.ioctl_tcgets){var a=o.tty.ops.ioctl_tcgets(o),i=y.getp();_[i>>2]=a.c_iflag||0,_[i+4>>2]=a.c_oflag||0,_[i+8>>2]=a.c_cflag||0,_[i+12>>2]=a.c_lflag||0;for(var s=0;s<32;s++)R[i+s+17]=a.c_cc[s]||0;return 0}return 0}case 21510:case 21511:case 21512:return o.tty?0:-59;case 21506:case 21507:case 21508:{if(!o.tty)return-59;if(o.tty.ops.ioctl_tcsets){for(var i=y.getp(),l=_[i>>2],c=_[i+4>>2],h=_[i+8>>2],S=_[i+12>>2],b=[],s=0;s<32;s++)b.push(R[i+s+17]);return o.tty.ops.ioctl_tcsets(o.tty,e,{c_iflag:l,c_oflag:c,c_cflag:h,c_lflag:S,c_cc:b})}return 0}case 21519:{if(!o.tty)return-59;var i=y.getp();return _[i>>2]=0,0}case 21520:return o.tty?-28:-59;case 21531:{var i=y.getp();return n.ioctl(o,e,i)}case 21523:{if(!o.tty)return-59;if(o.tty.ops.ioctl_tiocgwinsz){var m=o.tty.ops.ioctl_tiocgwinsz(o.tty),i=y.getp();Sr[i>>1]=m[0],Sr[i+2>>1]=m[1]}return 0}case 21524:return o.tty?0:-59;case 21515:return o.tty?0:-59;default:return-28}}catch(v){if(typeof n>"u"||v.name!=="ErrnoError")throw v;return-v.errno}}function ut(r,e,t,o){try{e=y.getStr(e);var a=o&256,i=o&4096;return o=o&-6401,e=y.calculateAt(r,e,i),y.doStat(a?n.lstat:n.stat,e,t)}catch(s){if(typeof n>"u"||s.name!=="ErrnoError")throw s;return-s.errno}}function ft(r,e,t,o){y.varargs=o;try{e=y.getStr(e),e=y.calculateAt(r,e);var a=o?y.get():0;return n.open(e,t,a).fd}catch(i){if(typeof n>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function ct(r,e){try{return r=y.getStr(r),y.doStat(n.stat,r,e)}catch(t){if(typeof n>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}var dt=1,vt=()=>dt,mt=()=>{Kr=!1,ae=0},ht=()=>{throw 1/0},Ur=(r,e)=>e+2097152>>>0<4194305-!!r?(r>>>0)+e*4294967296:NaN;function pt(r,e,t,o,a,i,s,l){var c=Ur(a,i);try{if(isNaN(c))return 61;var h=y.getStreamFromFD(o),S=n.mmap(h,r,c,e,t),b=S.ptr;return _[s>>2]=S.allocated,D[l>>2]=b,0}catch(m){if(typeof n>"u"||m.name!=="ErrnoError")throw m;return-m.errno}}function wt(r,e,t,o,a,i,s){var l=Ur(i,s);try{var c=y.getStreamFromFD(a);t&2&&y.doMsync(r,c,e,o,l)}catch(h){if(typeof n>"u"||h.name!=="ErrnoError")throw h;return-h.errno}}var _t=()=>{Ir("")},yt=()=>Date.now(),ne=()=>2147483648,gt=()=>ne(),oe;oe=()=>performance.now();var Et=(r,e,t)=>z.copyWithin(r,e,e+t),St=r=>{var e=sr.buffer,t=(r-e.byteLength+65535)/65536;try{return sr.grow(t),Hr(),1}catch{}},kt=r=>{var e=z.length;r>>>=0;var t=ne();if(r>t)return!1;for(var o=(c,h)=>c+(h-c%h)%h,a=1;a<=4;a*=2){var i=e*(1+.2/a);i=Math.min(i,r+100663296);var s=Math.min(t,o(Math.max(r,i),65536)),l=St(s);if(l)return!0}return!1},jr={},bt=()=>X||"./this.program",wr=()=>{if(!wr.strings){var r=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:r,_:bt()};for(var t in jr)jr[t]===void 0?delete e[t]:e[t]=jr[t];var o=[];for(var t in e)o.push(`${t}=${e[t]}`);wr.strings=o}return wr.strings},Ft=(r,e)=>{for(var t=0;t<r.length;++t)R[e++]=r.charCodeAt(t);R[e]=0},Pt=(r,e)=>{var t=0;return wr().forEach((o,a)=>{var i=e+t;D[r+a*4>>2]=i,Ft(o,i),t+=o.length+1}),0},Dt=(r,e)=>{var t=wr();D[r>>2]=t.length;var o=0;return t.forEach(a=>o+=a.length+1),D[e>>2]=o,0},ae=0,Mt=()=>Kr||ae>0,ie=r=>{nr=r,Mt()||(u.onExit?.(r),lr=!0),x(r,new Gr(r))},se=(r,e)=>{nr=r,ie(r)},At=se;function Rt(r){try{var e=y.getStreamFromFD(r);return n.close(e),0}catch(t){if(typeof n>"u"||t.name!=="ErrnoError")throw t;return t.errno}}var Tt=(r,e,t,o)=>{for(var a=0,i=0;i<t;i++){var s=D[e>>2],l=D[e+4>>2];e+=8;var c=n.read(r,R,s,l,o);if(c<0)return-1;if(a+=c,c<l)break;typeof o<"u"&&(o+=c)}return a};function Ct(r,e,t,o){try{var a=y.getStreamFromFD(r),i=Tt(a,e,t);return D[o>>2]=i,0}catch(s){if(typeof n>"u"||s.name!=="ErrnoError")throw s;return s.errno}}function It(r,e,t,o,a){var i=Ur(e,t);try{if(isNaN(i))return 61;var s=y.getStreamFromFD(r);return n.llseek(s,i,o),I=[s.position>>>0,(g=s.position,+Math.abs(g)>=1?g>0?+Math.floor(g/4294967296)>>>0:~~+Math.ceil((g-+(~~g>>>0))/4294967296)>>>0:0)],_[a>>2]=I[0],_[a+4>>2]=I[1],s.getdents&&i===0&&o===0&&(s.getdents=null),0}catch(l){if(typeof n>"u"||l.name!=="ErrnoError")throw l;return l.errno}}var Nt=(r,e,t,o)=>{for(var a=0,i=0;i<t;i++){var s=D[e>>2],l=D[e+4>>2];e+=8;var c=n.write(r,R,s,l,o);if(c<0)return-1;a+=c,typeof o<"u"&&(o+=c)}return a};function Lt(r,e,t,o){try{var a=y.getStreamFromFD(r),i=Nt(a,e,t);return D[o>>2]=i,0}catch(s){if(typeof n>"u"||s.name!=="ErrnoError")throw s;return s.errno}}var Mr=r=>r%4===0&&(r%100!==0||r%400===0),zt=(r,e)=>{for(var t=0,o=0;o<=e;t+=r[o++]);return t},le=[31,29,31,30,31,30,31,31,30,31,30,31],ue=[31,28,31,30,31,30,31,31,30,31,30,31],Ot=(r,e)=>{for(var t=new Date(r.getTime());e>0;){var o=Mr(t.getFullYear()),a=t.getMonth(),i=(o?le:ue)[a];if(e>i-t.getDate())e-=i-t.getDate()+1,t.setDate(1),a<11?t.setMonth(a+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1));else return t.setDate(t.getDate()+e),t}return t},Ut=(r,e)=>{R.set(r,e)},jt=(r,e,t,o)=>{var a=D[o+40>>2],i={tm_sec:_[o>>2],tm_min:_[o+4>>2],tm_hour:_[o+8>>2],tm_mday:_[o+12>>2],tm_mon:_[o+16>>2],tm_year:_[o+20>>2],tm_wday:_[o+24>>2],tm_yday:_[o+28>>2],tm_isdst:_[o+32>>2],tm_gmtoff:_[o+36>>2],tm_zone:a?Or(a):""},s=Or(t),l={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var c in l)s=s.replace(new RegExp(c,"g"),l[c]);var h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],S=["January","February","March","April","May","June","July","August","September","October","November","December"];function b(f,d,N){for(var M=typeof f=="number"?f.toString():f||"";M.length<d;)M=N[0]+M;return M}function m(f,d){return b(f,d,"0")}function v(f,d){function N(Y){return Y<0?-1:Y>0?1:0}var M;return(M=N(f.getFullYear()-d.getFullYear()))===0&&(M=N(f.getMonth()-d.getMonth()))===0&&(M=N(f.getDate()-d.getDate())),M}function E(f){switch(f.getDay()){case 0:return new Date(f.getFullYear()-1,11,29);case 1:return f;case 2:return new Date(f.getFullYear(),0,3);case 3:return new Date(f.getFullYear(),0,2);case 4:return new Date(f.getFullYear(),0,1);case 5:return new Date(f.getFullYear()-1,11,31);case 6:return new Date(f.getFullYear()-1,11,30)}}function O(f){var d=Ot(new Date(f.tm_year+1900,0,1),f.tm_yday),N=new Date(d.getFullYear(),0,4),M=new Date(d.getFullYear()+1,0,4),Y=E(N),T=E(M);return v(Y,d)<=0?v(T,d)<=0?d.getFullYear()+1:d.getFullYear():d.getFullYear()-1}var W={"%a":f=>h[f.tm_wday].substring(0,3),"%A":f=>h[f.tm_wday],"%b":f=>S[f.tm_mon].substring(0,3),"%B":f=>S[f.tm_mon],"%C":f=>{var d=f.tm_year+1900;return m(d/100|0,2)},"%d":f=>m(f.tm_mday,2),"%e":f=>b(f.tm_mday,2," "),"%g":f=>O(f).toString().substring(2),"%G":O,"%H":f=>m(f.tm_hour,2),"%I":f=>{var d=f.tm_hour;return d==0?d=12:d>12&&(d-=12),m(d,2)},"%j":f=>m(f.tm_mday+zt(Mr(f.tm_year+1900)?le:ue,f.tm_mon-1),3),"%m":f=>m(f.tm_mon+1,2),"%M":f=>m(f.tm_min,2),"%n":()=>`
4
- `,"%p":f=>f.tm_hour>=0&&f.tm_hour<12?"AM":"PM","%S":f=>m(f.tm_sec,2),"%t":()=>" ","%u":f=>f.tm_wday||7,"%U":f=>{var d=f.tm_yday+7-f.tm_wday;return m(Math.floor(d/7),2)},"%V":f=>{var d=Math.floor((f.tm_yday+7-(f.tm_wday+6)%7)/7);if((f.tm_wday+371-f.tm_yday-2)%7<=2&&d++,d){if(d==53){var M=(f.tm_wday+371-f.tm_yday)%7;M!=4&&(M!=3||!Mr(f.tm_year))&&(d=1)}}else{d=52;var N=(f.tm_wday+7-f.tm_yday-1)%7;(N==4||N==5&&Mr(f.tm_year%400-1))&&d++}return m(d,2)},"%w":f=>f.tm_wday,"%W":f=>{var d=f.tm_yday+7-(f.tm_wday+6)%7;return m(Math.floor(d/7),2)},"%y":f=>(f.tm_year+1900).toString().substring(2),"%Y":f=>f.tm_year+1900,"%z":f=>{var d=f.tm_gmtoff,N=d>=0;return d=Math.abs(d)/60,d=d/60*100+d%60,(N?"+":"-")+("0000"+d).slice(-4)},"%Z":f=>f.tm_zone,"%%":()=>"%"};s=s.replace(/%%/g,"\0\0");for(var c in W)s.includes(c)&&(s=s.replace(new RegExp(c,"g"),W[c](i)));s=s.replace(/\0\0/g,"%");var U=Dr(s,!1);return U.length>e?0:(Ut(U,r),U.length-1)},xt=(r,e,t,o,a)=>jt(r,e,t,o),Bt=r=>{if(r instanceof Gr||r=="unwind")return nr;x(1,r)},Ht=r=>{var e=Pr(r)+1,t=xr(e);return te(r,t,e),t};n.createPreloadedFile=et,n.staticInit(),u.FS_createPath=n.createPath,u.FS_createDataFile=n.createDataFile,u.FS_createPreloadedFile=n.createPreloadedFile,u.FS_unlink=n.unlink,u.FS_createLazyFile=n.createLazyFile,u.FS_createDevice=n.createDevice;var Wt={y:We,a:qe,L:nt,M:ot,q:at,G:it,D:st,N:lt,E:ut,n:ft,F:ct,I:vt,A:mt,v:ht,r:pt,s:wt,b:_t,J:yt,x:gt,H:oe,K:Et,w:kt,B:Pt,C:Dt,j:At,l:Rt,p:Ct,t:It,o:Lt,h:Kt,k:$t,d:Xt,e:qt,m:Jt,c:Vt,f:Gt,i:Zt,g:Qt,z:ie,u:xt},H=He(),Yt=()=>(Yt=H.P)(),fe=u._main=(r,e)=>(fe=u._main=H.Q)(r,e),ce=(r,e)=>(ce=H.S)(r,e),V=(r,e)=>(V=H.T)(r,e),G=()=>(G=H.U)(),K=r=>(K=H.V)(r),xr=r=>(xr=H.W)(r),de=r=>(de=H.X)(r);function Xt(r,e,t,o){var a=G();try{return $(r)(e,t,o)}catch(i){if(K(a),i!==i+0)throw i;V(1,0)}}function qt(r,e,t,o,a){var i=G();try{return $(r)(e,t,o,a)}catch(s){if(K(i),s!==s+0)throw s;V(1,0)}}function $t(r,e,t){var o=G();try{return $(r)(e,t)}catch(a){if(K(o),a!==a+0)throw a;V(1,0)}}function Vt(r){var e=G();try{$(r)()}catch(t){if(K(e),t!==t+0)throw t;V(1,0)}}function Gt(r,e){var t=G();try{$(r)(e)}catch(o){if(K(t),o!==o+0)throw o;V(1,0)}}function Kt(r){var e=G();try{return $(r)()}catch(t){if(K(e),t!==t+0)throw t;V(1,0)}}function Jt(r,e,t,o,a,i){var s=G();try{return $(r)(e,t,o,a,i)}catch(l){if(K(s),l!==l+0)throw l;V(1,0)}}function Qt(r,e,t,o){var a=G();try{$(r)(e,t,o)}catch(i){if(K(a),i!==i+0)throw i;V(1,0)}}function Zt(r,e,t){var o=G();try{$(r)(e,t)}catch(a){if(K(o),a!==a+0)throw a;V(1,0)}}u.addRunDependency=kr,u.removeRunDependency=pr,u.FS_createPath=n.createPath,u.FS_createLazyFile=n.createLazyFile,u.FS_createDevice=n.createDevice,u.callMain=ve,u.FS_createPreloadedFile=n.createPreloadedFile,u.FS=n,u.FS_createDataFile=n.createDataFile,u.FS_unlink=n.unlink;var Ar;hr=function r(){Ar||me(),Ar||(hr=r)};function ve(r=[]){var e=fe;r.unshift(X);var t=r.length,o=xr((t+1)*4),a=o;r.forEach(s=>{D[a>>2]=Ht(s),a+=4}),D[a>>2]=0;try{var i=e(t,o);return se(i,!0),i}catch(s){return Bt(s)}}function me(r=Q){if(or>0||(Ce(),or>0))return;function e(){Ar||(Ar=!0,u.calledRun=!0,!lr&&(Ie(),Ne(),L(u),u.onRuntimeInitialized&&u.onRuntimeInitialized(),he&&ve(r),Le()))}u.setStatus?(u.setStatus("Running..."),setTimeout(function(){setTimeout(function(){u.setStatus("")},1),e()},1)):e()}if(u.preInit)for(typeof u.preInit=="function"&&(u.preInit=[u.preInit]);u.preInit.length>0;)u.preInit.pop()();var he=!1;return u.noInitialRun&&(he=!1),me(),F.ready}})(),A=null,fr=!1,yr=null,Rr=null,cr=null,_e=new Promise(function(w,F){Rr=w,cr=F}),er={OPTIMAL:"optimal",INFEASIBLE:"infeasible",UNBOUNDED:"unbounded",TIME_LIMIT:"timelimit",UNKNOWN:"unknown",ERROR:"error"};function ye(w){return w.includes("optimal solution found")?er.OPTIMAL:w.includes("problem is infeasible")?er.INFEASIBLE:w.includes("problem is unbounded")?er.UNBOUNDED:w.includes("time limit reached")?er.TIME_LIMIT:er.UNKNOWN}function ge(w){var F={},u={value:null},L=w.match(/objective value:\s*([\d.e+-]+)/i);L&&(u.value=parseFloat(L[1]));for(var k=/^(\w+)\s+([\d.e+-]+)/gm,C,Q=w.split("solution:")[1]||w;(C=k.exec(Q))!==null;){var X=C[1],x=parseFloat(C[2]);!isNaN(x)&&X!=="objective"&&(F[X]=x)}return{variables:F,objective:u}}function Ee(w){var F={solvingTime:null,nodes:null,iterations:null,gap:null},u=w.match(/Solving Time \(sec\)\s*:\s*([\d.]+)/);u&&(F.solvingTime=parseFloat(u[1]));var L=w.match(/Nodes\s*:\s*(\d+)/);L&&(F.nodes=parseInt(L[1]));var k=w.match(/LP Iterations\s*:\s*(\d+)/);k&&(F.iterations=parseInt(k[1]));var C=w.match(/Gap\s*:\s*([\d.]+)\s*%/);return C&&(F.gap=parseFloat(C[1])),F}function gr(w){return w=w||{},fr?Promise.resolve():yr||(yr=new Promise(function(F,u){try{var L=w.wasmPath||_r+"scip.wasm";console.log("[SCIP.js] __SCIP_SCRIPT_DIR__:",_r),console.log("[SCIP.js] Loading WASM from:",L),fetch(L,{method:"HEAD"}).then(function(k){console.log("[SCIP.js] WASM file check:",k.ok?"OK":"FAILED",k.status)}).catch(function(k){console.error("[SCIP.js] WASM file check failed:",k)}),we({locateFile:function(k){return k.endsWith(".wasm")?(console.log("[SCIP.js] locateFile called for:",k,"-> returning:",L),L):k},print:function(k){A&&A.onStdout&&A.onStdout(k)},printErr:function(k){A&&A.onStderr&&A.onStderr(k)}}).then(function(k){if(console.log("[SCIP.js] WASM loaded successfully"),A=k,A.FS){try{A.FS.mkdir("/problems")}catch{}try{A.FS.mkdir("/solutions")}catch{}try{A.FS.mkdir("/settings")}catch{}}fr=!0,Rr&&Rr(),F()}).catch(function(k){console.error("[SCIP.js] WASM loading failed:",k),console.error("[SCIP.js] Attempted WASM path:",L),console.error("[SCIP.js] Make sure the WASM file is accessible at this URL."),console.error("[SCIP.js] You can set window.SCIP_BASE_URL before loading this script to specify a custom path.");var C=new Error("SCIP WASM loading failed: "+(k.message||k)+". WASM path: "+L);cr&&cr(C),u(C)})}catch(k){console.error("[SCIP.js] Initialization error:",k),cr&&cr(k),u(k)}}),yr)}function Tr(w,F){F=F||{};var u=function(){var L=F.format||"lp",k=F.timeLimit||3600,C=F.gap||null,Q=F.verbose||!1,X=F.parameters||{},x="",dr="";A.onStdout=function(z){x+=z+`
5
- `,Q&&console.log("[SCIP]",z)},A.onStderr=function(z){dr+=z+`
6
- `,Q&&console.error("[SCIP Error]",z)};try{var tr={mps:"mps",zpl:"zpl",cip:"cip",lp:"lp"},Br=tr[L]||"lp",B="/problems/problem."+Br,Er="/solutions/solution.sol";A.FS.writeFile(B,w);var j=[];j.push("set limits time "+k),C!==null&&j.push("set limits gap "+C);for(var ir in X)X.hasOwnProperty(ir)&&j.push("set "+ir+" "+X[ir]);j.push("read "+B),j.push("optimize"),j.push("display solution"),j.push("write solution "+Er),j.push("display statistics"),j.push("quit");var vr=j.join(`
7
- `);A.FS.writeFile("/settings/commands.txt",vr);var mr=A.callMain(["-b","/settings/commands.txt"]),q=ye(x),Z=ge(x),sr=Ee(x),lr=null;try{lr=A.FS.readFile(Er,{encoding:"utf8"})}catch{}for(var nr=["/problems/problem.lp","/problems/problem.mps","/problems/problem.zpl","/problems/problem.cip","/solutions/solution.sol","/settings/commands.txt"],R=0;R<nr.length;R++)try{A.FS.unlink(nr[R])}catch{}return{status:q,objective:Z.objective.value,variables:Z.variables,statistics:sr,exitCode:mr,output:Q?x:void 0,rawSolution:lr}}catch(z){return{status:er.ERROR,error:z.message,output:x+dr}}};return fr?Promise.resolve(u()):gr(F).then(u)}function Se(w,F){return w.toLowerCase().includes("minimize")||(w=`Minimize
8
- `+w),Tr(w,F)}function ke(w,F){return w.toLowerCase().includes("maximize")||(w=`Maximize
9
- `+w),Tr(w,F)}function be(){var w=function(){var F="";return A.onStdout=function(u){F+=u+`
10
- `},A.callMain(["--version"]),F.trim()};return fr?Promise.resolve(w()):gr().then(w)}function Fe(){return fr}var Pe={init:gr,ready:_e,isReady:Fe,solve:Tr,minimize:Se,maximize:ke,version:be,Status:er};pe.SCIP=Pe,gr().catch(function(w){console.error("[SCIP.js] Auto-initialization failed:",w.message)})})(typeof self<"u"?self:typeof window<"u"?window:globalThis);
3
+ `)),!r)return null;Ir=Dr(r,!0)}return Ir.shift()},rr={ttys:[],init(){},shutdown(){},register(r,e){rr.ttys[r]={input:[],output:[],ops:e},n.registerDevice(r,rr.stream_ops)},stream_ops:{open(r){var e=rr.ttys[r.node.rdev];if(!e)throw new n.ErrnoError(43);r.tty=e,r.seekable=!1},close(r){r.tty.ops.fsync(r.tty)},fsync(r){r.tty.ops.fsync(r.tty)},read(r,e,t,o,a){if(!r.tty||!r.tty.ops.get_char)throw new n.ErrnoError(60);for(var i=0,s=0;s<o;s++){var u;try{u=r.tty.ops.get_char(r.tty)}catch{throw new n.ErrnoError(29)}if(u===void 0&&i===0)throw new n.ErrnoError(6);if(u==null)break;i++,e[t+s]=u}return i&&(r.node.timestamp=Date.now()),i},write(r,e,t,o,a){if(!r.tty||!r.tty.ops.put_char)throw new n.ErrnoError(60);try{for(var i=0;i<o;i++)r.tty.ops.put_char(r.tty,e[t+i])}catch{throw new n.ErrnoError(29)}return o&&(r.node.timestamp=Date.now()),i}},default_tty_ops:{get_char(r){return Ve()},put_char(r,e){e===null||e===10?(vr(lr(r.output,0)),r.output=[]):e!=0&&r.output.push(e)},fsync(r){r.output&&r.output.length>0&&(vr(lr(r.output,0)),r.output=[])},ioctl_tcgets(r){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(r,e,t){return 0},ioctl_tiocgwinsz(r){return[24,80]}},default_tty1_ops:{put_char(r,e){e===null||e===10?(W(lr(r.output,0)),r.output=[]):e!=0&&r.output.push(e)},fsync(r){r.output&&r.output.length>0&&(W(lr(r.output,0)),r.output=[])}}},Ge=(r,e)=>(z.fill(0,r,r+e),r),Ke=(r,e)=>Math.ceil(r/e)*e,ee=r=>{r=Ke(r,65536);var e=ce(65536,r);return e?Ge(e,r):0},p={ops_table:null,mount(r){return p.createNode(null,"/",16895,0)},createNode(r,e,t,o){if(n.isBlkdev(t)||n.isFIFO(t))throw new n.ErrnoError(63);p.ops_table||(p.ops_table={dir:{node:{getattr:p.node_ops.getattr,setattr:p.node_ops.setattr,lookup:p.node_ops.lookup,mknod:p.node_ops.mknod,rename:p.node_ops.rename,unlink:p.node_ops.unlink,rmdir:p.node_ops.rmdir,readdir:p.node_ops.readdir,symlink:p.node_ops.symlink},stream:{llseek:p.stream_ops.llseek}},file:{node:{getattr:p.node_ops.getattr,setattr:p.node_ops.setattr},stream:{llseek:p.stream_ops.llseek,read:p.stream_ops.read,write:p.stream_ops.write,allocate:p.stream_ops.allocate,mmap:p.stream_ops.mmap,msync:p.stream_ops.msync}},link:{node:{getattr:p.node_ops.getattr,setattr:p.node_ops.setattr,readlink:p.node_ops.readlink},stream:{}},chrdev:{node:{getattr:p.node_ops.getattr,setattr:p.node_ops.setattr},stream:n.chrdev_stream_ops}});var a=n.createNode(r,e,t,o);return n.isDir(a.mode)?(a.node_ops=p.ops_table.dir.node,a.stream_ops=p.ops_table.dir.stream,a.contents={}):n.isFile(a.mode)?(a.node_ops=p.ops_table.file.node,a.stream_ops=p.ops_table.file.stream,a.usedBytes=0,a.contents=null):n.isLink(a.mode)?(a.node_ops=p.ops_table.link.node,a.stream_ops=p.ops_table.link.stream):n.isChrdev(a.mode)&&(a.node_ops=p.ops_table.chrdev.node,a.stream_ops=p.ops_table.chrdev.stream),a.timestamp=Date.now(),r&&(r.contents[e]=a,r.timestamp=a.timestamp),a},getFileDataAsTypedArray(r){return r.contents?r.contents.subarray?r.contents.subarray(0,r.usedBytes):new Uint8Array(r.contents):new Uint8Array(0)},expandFileStorage(r,e){var t=r.contents?r.contents.length:0;if(!(t>=e)){var o=1024*1024;e=Math.max(e,t*(t<o?2:1.125)>>>0),t!=0&&(e=Math.max(e,256));var a=r.contents;r.contents=new Uint8Array(e),r.usedBytes>0&&r.contents.set(a.subarray(0,r.usedBytes),0)}},resizeFileStorage(r,e){if(r.usedBytes!=e)if(e==0)r.contents=null,r.usedBytes=0;else{var t=r.contents;r.contents=new Uint8Array(e),t&&r.contents.set(t.subarray(0,Math.min(e,r.usedBytes))),r.usedBytes=e}},node_ops:{getattr(r){var e={};return e.dev=n.isChrdev(r.mode)?r.id:1,e.ino=r.id,e.mode=r.mode,e.nlink=1,e.uid=0,e.gid=0,e.rdev=r.rdev,n.isDir(r.mode)?e.size=4096:n.isFile(r.mode)?e.size=r.usedBytes:n.isLink(r.mode)?e.size=r.link.length:e.size=0,e.atime=new Date(r.timestamp),e.mtime=new Date(r.timestamp),e.ctime=new Date(r.timestamp),e.blksize=4096,e.blocks=Math.ceil(e.size/e.blksize),e},setattr(r,e){e.mode!==void 0&&(r.mode=e.mode),e.timestamp!==void 0&&(r.timestamp=e.timestamp),e.size!==void 0&&p.resizeFileStorage(r,e.size)},lookup(r,e){throw n.genericErrors[44]},mknod(r,e,t,o){return p.createNode(r,e,t,o)},rename(r,e,t){if(n.isDir(r.mode)){var o;try{o=n.lookupNode(e,t)}catch{}if(o)for(var a in o.contents)throw new n.ErrnoError(55)}delete r.parent.contents[r.name],r.parent.timestamp=Date.now(),r.name=t,e.contents[t]=r,e.timestamp=r.parent.timestamp,r.parent=e},unlink(r,e){delete r.contents[e],r.timestamp=Date.now()},rmdir(r,e){var t=n.lookupNode(r,e);for(var o in t.contents)throw new n.ErrnoError(55);delete r.contents[e],r.timestamp=Date.now()},readdir(r){var e=[".",".."];for(var t of Object.keys(r.contents))e.push(t);return e},symlink(r,e,t){var o=p.createNode(r,e,41471,0);return o.link=t,o},readlink(r){if(!n.isLink(r.mode))throw new n.ErrnoError(28);return r.link}},stream_ops:{read(r,e,t,o,a){var i=r.node.contents;if(a>=r.node.usedBytes)return 0;var s=Math.min(r.node.usedBytes-a,o);if(s>8&&i.subarray)e.set(i.subarray(a,a+s),t);else for(var u=0;u<s;u++)e[t+u]=i[a+u];return s},write(r,e,t,o,a,i){if(e.buffer===R.buffer&&(i=!1),!o)return 0;var s=r.node;if(s.timestamp=Date.now(),e.subarray&&(!s.contents||s.contents.subarray)){if(i)return s.contents=e.subarray(t,t+o),s.usedBytes=o,o;if(s.usedBytes===0&&a===0)return s.contents=e.slice(t,t+o),s.usedBytes=o,o;if(a+o<=s.usedBytes)return s.contents.set(e.subarray(t,t+o),a),o}if(p.expandFileStorage(s,a+o),s.contents.subarray&&e.subarray)s.contents.set(e.subarray(t,t+o),a);else for(var u=0;u<o;u++)s.contents[a+u]=e[t+u];return s.usedBytes=Math.max(s.usedBytes,a+o),o},llseek(r,e,t){var o=e;if(t===1?o+=r.position:t===2&&n.isFile(r.node.mode)&&(o+=r.node.usedBytes),o<0)throw new n.ErrnoError(28);return o},allocate(r,e,t){p.expandFileStorage(r.node,e+t),r.node.usedBytes=Math.max(r.node.usedBytes,e+t)},mmap(r,e,t,o,a){if(!n.isFile(r.node.mode))throw new n.ErrnoError(43);var i,s,u=r.node.contents;if(!(a&2)&&u.buffer===R.buffer)s=!1,i=u.byteOffset;else{if((t>0||t+e<u.length)&&(u.subarray?u=u.subarray(t,t+e):u=Array.prototype.slice.call(u,t,t+e)),s=!0,i=ee(e),!i)throw new n.ErrnoError(48);R.set(u,i)}return{ptr:i,allocated:s}},msync(r,e,t,o,a){return p.stream_ops.write(r,e,0,o,t,!1),0}}},Je=(r,e,t,o)=>{var a=o?"":`al ${r}`;ur(r,i=>{e(new Uint8Array(i)),a&&pr(a)},i=>{if(t)t();else throw`Loading data file "${r}" failed.`}),a&&kr(a)},Qe=(r,e,t,o,a,i)=>{n.createDataFile(r,e,t,o,a,i)},Ze=l.preloadPlugins||[],rt=(r,e,t,o)=>{typeof Browser<"u"&&Browser.init();var a=!1;return Ze.forEach(i=>{a||i.canHandle(e)&&(i.handle(r,e,t,o),a=!0)}),a},et=(r,e,t,o,a,i,s,u,c,h)=>{var k=e?J.resolve(D.join2(r,e)):r,S=`cp ${k}`;function m(v){function E(L){h?.(),u||Qe(r,e,L,o,a,c),i?.(),pr(S)}rt(v,k,E,()=>{s?.(),pr(S)})||E(v)}kr(S),typeof t=="string"?Je(t,m,s):m(t)},tt=r=>{var e={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},t=e[r];if(typeof t>"u")throw new Error(`Unknown file open mode: ${r}`);return t},Lr=(r,e)=>{var t=0;return r&&(t|=365),e&&(t|=146),t},n={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:class{constructor(r){this.name="ErrnoError",this.errno=r}},genericErrors:{},filesystems:null,syncFSRequests:0,FSStream:class{constructor(){this.shared={}}get object(){return this.node}set object(r){this.node=r}get isRead(){return(this.flags&2097155)!==1}get isWrite(){return(this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(r){this.shared.flags=r}get position(){return this.shared.position}set position(r){this.shared.position=r}},FSNode:class{constructor(r,e,t,o){r||(r=this),this.parent=r,this.mount=r.mount,this.mounted=null,this.id=n.nextInode++,this.name=e,this.mode=t,this.node_ops={},this.stream_ops={},this.rdev=o,this.readMode=365,this.writeMode=146}get read(){return(this.mode&this.readMode)===this.readMode}set read(r){r?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(r){r?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return n.isDir(this.mode)}get isDevice(){return n.isChrdev(this.mode)}},lookupPath(r,e={}){if(r=J.resolve(r),!r)return{path:"",node:null};var t={follow_mount:!0,recurse_count:0};if(e=Object.assign(t,e),e.recurse_count>8)throw new n.ErrnoError(32);for(var o=r.split("/").filter(S=>!!S),a=n.root,i="/",s=0;s<o.length;s++){var u=s===o.length-1;if(u&&e.parent)break;if(a=n.lookupNode(a,o[s]),i=D.join2(i,o[s]),n.isMountpoint(a)&&(!u||u&&e.follow_mount)&&(a=a.mounted.root),!u||e.follow)for(var c=0;n.isLink(a.mode);){var h=n.readlink(i);i=J.resolve(D.dirname(i),h);var k=n.lookupPath(i,{recurse_count:e.recurse_count+1});if(a=k.node,c++>40)throw new n.ErrnoError(32)}}return{path:i,node:a}},getPath(r){for(var e;;){if(n.isRoot(r)){var t=r.mount.mountpoint;return e?t[t.length-1]!=="/"?`${t}/${e}`:t+e:t}e=e?`${r.name}/${e}`:r.name,r=r.parent}},hashName(r,e){for(var t=0,o=0;o<e.length;o++)t=(t<<5)-t+e.charCodeAt(o)|0;return(r+t>>>0)%n.nameTable.length},hashAddNode(r){var e=n.hashName(r.parent.id,r.name);r.name_next=n.nameTable[e],n.nameTable[e]=r},hashRemoveNode(r){var e=n.hashName(r.parent.id,r.name);if(n.nameTable[e]===r)n.nameTable[e]=r.name_next;else for(var t=n.nameTable[e];t;){if(t.name_next===r){t.name_next=r.name_next;break}t=t.name_next}},lookupNode(r,e){var t=n.mayLookup(r);if(t)throw new n.ErrnoError(t);for(var o=n.hashName(r.id,e),a=n.nameTable[o];a;a=a.name_next){var i=a.name;if(a.parent.id===r.id&&i===e)return a}return n.lookup(r,e)},createNode(r,e,t,o){var a=new n.FSNode(r,e,t,o);return n.hashAddNode(a),a},destroyNode(r){n.hashRemoveNode(r)},isRoot(r){return r===r.parent},isMountpoint(r){return!!r.mounted},isFile(r){return(r&61440)===32768},isDir(r){return(r&61440)===16384},isLink(r){return(r&61440)===40960},isChrdev(r){return(r&61440)===8192},isBlkdev(r){return(r&61440)===24576},isFIFO(r){return(r&61440)===4096},isSocket(r){return(r&49152)===49152},flagsToPermissionString(r){var e=["r","w","rw"][r&3];return r&512&&(e+="w"),e},nodePermissions(r,e){return n.ignorePermissions?0:e.includes("r")&&!(r.mode&292)||e.includes("w")&&!(r.mode&146)||e.includes("x")&&!(r.mode&73)?2:0},mayLookup(r){if(!n.isDir(r.mode))return 54;var e=n.nodePermissions(r,"x");return e||(r.node_ops.lookup?0:2)},mayCreate(r,e){try{var t=n.lookupNode(r,e);return 20}catch{}return n.nodePermissions(r,"wx")},mayDelete(r,e,t){var o;try{o=n.lookupNode(r,e)}catch(i){return i.errno}var a=n.nodePermissions(r,"wx");if(a)return a;if(t){if(!n.isDir(o.mode))return 54;if(n.isRoot(o)||n.getPath(o)===n.cwd())return 10}else if(n.isDir(o.mode))return 31;return 0},mayOpen(r,e){return r?n.isLink(r.mode)?32:n.isDir(r.mode)&&(n.flagsToPermissionString(e)!=="r"||e&512)?31:n.nodePermissions(r,n.flagsToPermissionString(e)):44},MAX_OPEN_FDS:4096,nextfd(){for(var r=0;r<=n.MAX_OPEN_FDS;r++)if(!n.streams[r])return r;throw new n.ErrnoError(33)},getStreamChecked(r){var e=n.getStream(r);if(!e)throw new n.ErrnoError(8);return e},getStream:r=>n.streams[r],createStream(r,e=-1){return r=Object.assign(new n.FSStream,r),e==-1&&(e=n.nextfd()),r.fd=e,n.streams[e]=r,r},closeStream(r){n.streams[r]=null},dupStream(r,e=-1){var t=n.createStream(r,e);return t.stream_ops?.dup?.(t),t},chrdev_stream_ops:{open(r){var e=n.getDevice(r.node.rdev);r.stream_ops=e.stream_ops,r.stream_ops.open?.(r)},llseek(){throw new n.ErrnoError(70)}},major:r=>r>>8,minor:r=>r&255,makedev:(r,e)=>r<<8|e,registerDevice(r,e){n.devices[r]={stream_ops:e}},getDevice:r=>n.devices[r],getMounts(r){for(var e=[],t=[r];t.length;){var o=t.pop();e.push(o),t.push(...o.mounts)}return e},syncfs(r,e){typeof r=="function"&&(e=r,r=!1),n.syncFSRequests++,n.syncFSRequests>1&&W(`warning: ${n.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=n.getMounts(n.root.mount),o=0;function a(s){return n.syncFSRequests--,e(s)}function i(s){if(s)return i.errored?void 0:(i.errored=!0,a(s));++o>=t.length&&a(null)}t.forEach(s=>{if(!s.type.syncfs)return i(null);s.type.syncfs(s,r,i)})},mount(r,e,t){var o=t==="/",a=!t,i;if(o&&n.root)throw new n.ErrnoError(10);if(!o&&!a){var s=n.lookupPath(t,{follow_mount:!1});if(t=s.path,i=s.node,n.isMountpoint(i))throw new n.ErrnoError(10);if(!n.isDir(i.mode))throw new n.ErrnoError(54)}var u={type:r,opts:e,mountpoint:t,mounts:[]},c=r.mount(u);return c.mount=u,u.root=c,o?n.root=c:i&&(i.mounted=u,i.mount&&i.mount.mounts.push(u)),c},unmount(r){var e=n.lookupPath(r,{follow_mount:!1});if(!n.isMountpoint(e.node))throw new n.ErrnoError(28);var t=e.node,o=t.mounted,a=n.getMounts(o);Object.keys(n.nameTable).forEach(s=>{for(var u=n.nameTable[s];u;){var c=u.name_next;a.includes(u.mount)&&n.destroyNode(u),u=c}}),t.mounted=null;var i=t.mount.mounts.indexOf(o);t.mount.mounts.splice(i,1)},lookup(r,e){return r.node_ops.lookup(r,e)},mknod(r,e,t){var o=n.lookupPath(r,{parent:!0}),a=o.node,i=D.basename(r);if(!i||i==="."||i==="..")throw new n.ErrnoError(28);var s=n.mayCreate(a,i);if(s)throw new n.ErrnoError(s);if(!a.node_ops.mknod)throw new n.ErrnoError(63);return a.node_ops.mknod(a,i,e,t)},create(r,e){return e=e!==void 0?e:438,e&=4095,e|=32768,n.mknod(r,e,0)},mkdir(r,e){return e=e!==void 0?e:511,e&=1023,e|=16384,n.mknod(r,e,0)},mkdirTree(r,e){for(var t=r.split("/"),o="",a=0;a<t.length;++a)if(t[a]){o+="/"+t[a];try{n.mkdir(o,e)}catch(i){if(i.errno!=20)throw i}}},mkdev(r,e,t){return typeof t>"u"&&(t=e,e=438),e|=8192,n.mknod(r,e,t)},symlink(r,e){if(!J.resolve(r))throw new n.ErrnoError(44);var t=n.lookupPath(e,{parent:!0}),o=t.node;if(!o)throw new n.ErrnoError(44);var a=D.basename(e),i=n.mayCreate(o,a);if(i)throw new n.ErrnoError(i);if(!o.node_ops.symlink)throw new n.ErrnoError(63);return o.node_ops.symlink(o,a,r)},rename(r,e){var t=D.dirname(r),o=D.dirname(e),a=D.basename(r),i=D.basename(e),s,u,c;if(s=n.lookupPath(r,{parent:!0}),u=s.node,s=n.lookupPath(e,{parent:!0}),c=s.node,!u||!c)throw new n.ErrnoError(44);if(u.mount!==c.mount)throw new n.ErrnoError(75);var h=n.lookupNode(u,a),k=J.relative(r,o);if(k.charAt(0)!==".")throw new n.ErrnoError(28);if(k=J.relative(e,t),k.charAt(0)!==".")throw new n.ErrnoError(55);var S;try{S=n.lookupNode(c,i)}catch{}if(h!==S){var m=n.isDir(h.mode),v=n.mayDelete(u,a,m);if(v)throw new n.ErrnoError(v);if(v=S?n.mayDelete(c,i,m):n.mayCreate(c,i),v)throw new n.ErrnoError(v);if(!u.node_ops.rename)throw new n.ErrnoError(63);if(n.isMountpoint(h)||S&&n.isMountpoint(S))throw new n.ErrnoError(10);if(c!==u&&(v=n.nodePermissions(u,"w"),v))throw new n.ErrnoError(v);n.hashRemoveNode(h);try{u.node_ops.rename(h,c,i)}catch(E){throw E}finally{n.hashAddNode(h)}}},rmdir(r){var e=n.lookupPath(r,{parent:!0}),t=e.node,o=D.basename(r),a=n.lookupNode(t,o),i=n.mayDelete(t,o,!0);if(i)throw new n.ErrnoError(i);if(!t.node_ops.rmdir)throw new n.ErrnoError(63);if(n.isMountpoint(a))throw new n.ErrnoError(10);t.node_ops.rmdir(t,o),n.destroyNode(a)},readdir(r){var e=n.lookupPath(r,{follow:!0}),t=e.node;if(!t.node_ops.readdir)throw new n.ErrnoError(54);return t.node_ops.readdir(t)},unlink(r){var e=n.lookupPath(r,{parent:!0}),t=e.node;if(!t)throw new n.ErrnoError(44);var o=D.basename(r),a=n.lookupNode(t,o),i=n.mayDelete(t,o,!1);if(i)throw new n.ErrnoError(i);if(!t.node_ops.unlink)throw new n.ErrnoError(63);if(n.isMountpoint(a))throw new n.ErrnoError(10);t.node_ops.unlink(t,o),n.destroyNode(a)},readlink(r){var e=n.lookupPath(r),t=e.node;if(!t)throw new n.ErrnoError(44);if(!t.node_ops.readlink)throw new n.ErrnoError(28);return J.resolve(n.getPath(t.parent),t.node_ops.readlink(t))},stat(r,e){var t=n.lookupPath(r,{follow:!e}),o=t.node;if(!o)throw new n.ErrnoError(44);if(!o.node_ops.getattr)throw new n.ErrnoError(63);return o.node_ops.getattr(o)},lstat(r){return n.stat(r,!0)},chmod(r,e,t){var o;if(typeof r=="string"){var a=n.lookupPath(r,{follow:!t});o=a.node}else o=r;if(!o.node_ops.setattr)throw new n.ErrnoError(63);o.node_ops.setattr(o,{mode:e&4095|o.mode&-4096,timestamp:Date.now()})},lchmod(r,e){n.chmod(r,e,!0)},fchmod(r,e){var t=n.getStreamChecked(r);n.chmod(t.node,e)},chown(r,e,t,o){var a;if(typeof r=="string"){var i=n.lookupPath(r,{follow:!o});a=i.node}else a=r;if(!a.node_ops.setattr)throw new n.ErrnoError(63);a.node_ops.setattr(a,{timestamp:Date.now()})},lchown(r,e,t){n.chown(r,e,t,!0)},fchown(r,e,t){var o=n.getStreamChecked(r);n.chown(o.node,e,t)},truncate(r,e){if(e<0)throw new n.ErrnoError(28);var t;if(typeof r=="string"){var o=n.lookupPath(r,{follow:!0});t=o.node}else t=r;if(!t.node_ops.setattr)throw new n.ErrnoError(63);if(n.isDir(t.mode))throw new n.ErrnoError(31);if(!n.isFile(t.mode))throw new n.ErrnoError(28);var a=n.nodePermissions(t,"w");if(a)throw new n.ErrnoError(a);t.node_ops.setattr(t,{size:e,timestamp:Date.now()})},ftruncate(r,e){var t=n.getStreamChecked(r);if(!(t.flags&2097155))throw new n.ErrnoError(28);n.truncate(t.node,e)},utime(r,e,t){var o=n.lookupPath(r,{follow:!0}),a=o.node;a.node_ops.setattr(a,{timestamp:Math.max(e,t)})},open(r,e,t){if(r==="")throw new n.ErrnoError(44);e=typeof e=="string"?tt(e):e,t=typeof t>"u"?438:t,e&64?t=t&4095|32768:t=0;var o;if(typeof r=="object")o=r;else{r=D.normalize(r);try{var a=n.lookupPath(r,{follow:!(e&131072)});o=a.node}catch{}}var i=!1;if(e&64)if(o){if(e&128)throw new n.ErrnoError(20)}else o=n.mknod(r,t,0),i=!0;if(!o)throw new n.ErrnoError(44);if(n.isChrdev(o.mode)&&(e&=-513),e&65536&&!n.isDir(o.mode))throw new n.ErrnoError(54);if(!i){var s=n.mayOpen(o,e);if(s)throw new n.ErrnoError(s)}e&512&&!i&&n.truncate(o,0),e&=-131713;var u=n.createStream({node:o,path:n.getPath(o),flags:e,seekable:!0,position:0,stream_ops:o.stream_ops,ungotten:[],error:!1});return u.stream_ops.open&&u.stream_ops.open(u),l.logReadFiles&&!(e&1)&&(n.readFiles||(n.readFiles={}),r in n.readFiles||(n.readFiles[r]=1)),u},close(r){if(n.isClosed(r))throw new n.ErrnoError(8);r.getdents&&(r.getdents=null);try{r.stream_ops.close&&r.stream_ops.close(r)}catch(e){throw e}finally{n.closeStream(r.fd)}r.fd=null},isClosed(r){return r.fd===null},llseek(r,e,t){if(n.isClosed(r))throw new n.ErrnoError(8);if(!r.seekable||!r.stream_ops.llseek)throw new n.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new n.ErrnoError(28);return r.position=r.stream_ops.llseek(r,e,t),r.ungotten=[],r.position},read(r,e,t,o,a){if(o<0||a<0)throw new n.ErrnoError(28);if(n.isClosed(r))throw new n.ErrnoError(8);if((r.flags&2097155)===1)throw new n.ErrnoError(8);if(n.isDir(r.node.mode))throw new n.ErrnoError(31);if(!r.stream_ops.read)throw new n.ErrnoError(28);var i=typeof a<"u";if(!i)a=r.position;else if(!r.seekable)throw new n.ErrnoError(70);var s=r.stream_ops.read(r,e,t,o,a);return i||(r.position+=s),s},write(r,e,t,o,a,i){if(o<0||a<0)throw new n.ErrnoError(28);if(n.isClosed(r))throw new n.ErrnoError(8);if(!(r.flags&2097155))throw new n.ErrnoError(8);if(n.isDir(r.node.mode))throw new n.ErrnoError(31);if(!r.stream_ops.write)throw new n.ErrnoError(28);r.seekable&&r.flags&1024&&n.llseek(r,0,2);var s=typeof a<"u";if(!s)a=r.position;else if(!r.seekable)throw new n.ErrnoError(70);var u=r.stream_ops.write(r,e,t,o,a,i);return s||(r.position+=u),u},allocate(r,e,t){if(n.isClosed(r))throw new n.ErrnoError(8);if(e<0||t<=0)throw new n.ErrnoError(28);if(!(r.flags&2097155))throw new n.ErrnoError(8);if(!n.isFile(r.node.mode)&&!n.isDir(r.node.mode))throw new n.ErrnoError(43);if(!r.stream_ops.allocate)throw new n.ErrnoError(138);r.stream_ops.allocate(r,e,t)},mmap(r,e,t,o,a){if(o&2&&!(a&2)&&(r.flags&2097155)!==2)throw new n.ErrnoError(2);if((r.flags&2097155)===1)throw new n.ErrnoError(2);if(!r.stream_ops.mmap)throw new n.ErrnoError(43);return r.stream_ops.mmap(r,e,t,o,a)},msync(r,e,t,o,a){return r.stream_ops.msync?r.stream_ops.msync(r,e,t,o,a):0},ioctl(r,e,t){if(!r.stream_ops.ioctl)throw new n.ErrnoError(59);return r.stream_ops.ioctl(r,e,t)},readFile(r,e={}){if(e.flags=e.flags||0,e.encoding=e.encoding||"binary",e.encoding!=="utf8"&&e.encoding!=="binary")throw new Error(`Invalid encoding type "${e.encoding}"`);var t,o=n.open(r,e.flags),a=n.stat(r),i=a.size,s=new Uint8Array(i);return n.read(o,s,0,i,0),e.encoding==="utf8"?t=lr(s,0):e.encoding==="binary"&&(t=s),n.close(o),t},writeFile(r,e,t={}){t.flags=t.flags||577;var o=n.open(r,t.flags,t.mode);if(typeof e=="string"){var a=new Uint8Array(Fr(e)+1),i=zr(e,a,0,a.length);n.write(o,a,0,i,void 0,t.canOwn)}else if(ArrayBuffer.isView(e))n.write(o,e,0,e.byteLength,void 0,t.canOwn);else throw new Error("Unsupported data type");n.close(o)},cwd:()=>n.currentPath,chdir(r){var e=n.lookupPath(r,{follow:!0});if(e.node===null)throw new n.ErrnoError(44);if(!n.isDir(e.node.mode))throw new n.ErrnoError(54);var t=n.nodePermissions(e.node,"x");if(t)throw new n.ErrnoError(t);n.currentPath=e.path},createDefaultDirectories(){n.mkdir("/tmp"),n.mkdir("/home"),n.mkdir("/home/web_user")},createDefaultDevices(){n.mkdir("/dev"),n.registerDevice(n.makedev(1,3),{read:()=>0,write:(o,a,i,s,u)=>s}),n.mkdev("/dev/null",n.makedev(1,3)),rr.register(n.makedev(5,0),rr.default_tty_ops),rr.register(n.makedev(6,0),rr.default_tty1_ops),n.mkdev("/dev/tty",n.makedev(5,0)),n.mkdev("/dev/tty1",n.makedev(6,0));var r=new Uint8Array(1024),e=0,t=()=>(e===0&&(e=Zr(r).byteLength),r[--e]);n.createDevice("/dev","random",t),n.createDevice("/dev","urandom",t),n.mkdir("/dev/shm"),n.mkdir("/dev/shm/tmp")},createSpecialDirectories(){n.mkdir("/proc");var r=n.mkdir("/proc/self");n.mkdir("/proc/self/fd"),n.mount({mount(){var e=n.createNode(r,"fd",16895,73);return e.node_ops={lookup(t,o){var a=+o,i=n.getStreamChecked(a),s={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>i.path}};return s.parent=s,s}},e}},{},"/proc/self/fd")},createStandardStreams(){l.stdin?n.createDevice("/dev","stdin",l.stdin):n.symlink("/dev/tty","/dev/stdin"),l.stdout?n.createDevice("/dev","stdout",null,l.stdout):n.symlink("/dev/tty","/dev/stdout"),l.stderr?n.createDevice("/dev","stderr",null,l.stderr):n.symlink("/dev/tty1","/dev/stderr");var r=n.open("/dev/stdin",0),e=n.open("/dev/stdout",1),t=n.open("/dev/stderr",1)},staticInit(){[44].forEach(r=>{n.genericErrors[r]=new n.ErrnoError(r),n.genericErrors[r].stack="<generic error, no stack>"}),n.nameTable=new Array(4096),n.mount(p,{},"/"),n.createDefaultDirectories(),n.createDefaultDevices(),n.createSpecialDirectories(),n.filesystems={MEMFS:p}},init(r,e,t){n.init.initialized=!0,l.stdin=r||l.stdin,l.stdout=e||l.stdout,l.stderr=t||l.stderr,n.createStandardStreams()},quit(){n.init.initialized=!1;for(var r=0;r<n.streams.length;r++){var e=n.streams[r];e&&n.close(e)}},findObject(r,e){var t=n.analyzePath(r,e);return t.exists?t.object:null},analyzePath(r,e){try{var t=n.lookupPath(r,{follow:!e});r=t.path}catch{}var o={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var t=n.lookupPath(r,{parent:!0});o.parentExists=!0,o.parentPath=t.path,o.parentObject=t.node,o.name=D.basename(r),t=n.lookupPath(r,{follow:!e}),o.exists=!0,o.path=t.path,o.object=t.node,o.name=t.node.name,o.isRoot=t.path==="/"}catch(a){o.error=a.errno}return o},createPath(r,e,t,o){r=typeof r=="string"?r:n.getPath(r);for(var a=e.split("/").reverse();a.length;){var i=a.pop();if(i){var s=D.join2(r,i);try{n.mkdir(s)}catch{}r=s}}return s},createFile(r,e,t,o,a){var i=D.join2(typeof r=="string"?r:n.getPath(r),e),s=Lr(o,a);return n.create(i,s)},createDataFile(r,e,t,o,a,i){var s=e;r&&(r=typeof r=="string"?r:n.getPath(r),s=e?D.join2(r,e):r);var u=Lr(o,a),c=n.create(s,u);if(t){if(typeof t=="string"){for(var h=new Array(t.length),k=0,S=t.length;k<S;++k)h[k]=t.charCodeAt(k);t=h}n.chmod(c,u|146);var m=n.open(c,577);n.write(m,t,0,t.length,0,i),n.close(m),n.chmod(c,u)}},createDevice(r,e,t,o){var a=D.join2(typeof r=="string"?r:n.getPath(r),e),i=Lr(!!t,!!o);n.createDevice.major||(n.createDevice.major=64);var s=n.makedev(n.createDevice.major++,0);return n.registerDevice(s,{open(u){u.seekable=!1},close(u){o?.buffer?.length&&o(10)},read(u,c,h,k,S){for(var m=0,v=0;v<k;v++){var E;try{E=t()}catch{throw new n.ErrnoError(29)}if(E===void 0&&m===0)throw new n.ErrnoError(6);if(E==null)break;m++,c[h+v]=E}return m&&(u.node.timestamp=Date.now()),m},write(u,c,h,k,S){for(var m=0;m<k;m++)try{o(c[h+m])}catch{throw new n.ErrnoError(29)}return k&&(u.node.timestamp=Date.now()),m}}),n.mkdev(a,i,s)},forceLoadFile(r){if(r.isDevice||r.isFolder||r.link||r.contents)return!0;if(typeof XMLHttpRequest<"u")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(U)try{r.contents=Dr(U(r.url),!0),r.usedBytes=r.contents.length}catch{throw new n.ErrnoError(29)}else throw new Error("Cannot load without read() or XMLHttpRequest.")},createLazyFile(r,e,t,o,a){class i{constructor(){this.lengthKnown=!1,this.chunks=[]}get(v){if(!(v>this.length-1||v<0)){var E=v%this.chunkSize,L=v/this.chunkSize|0;return this.getter(L)[E]}}setDataGetter(v){this.getter=v}cacheLength(){var v=new XMLHttpRequest;if(v.open("HEAD",t,!1),v.send(null),!(v.status>=200&&v.status<300||v.status===304))throw new Error("Couldn't load "+t+". Status: "+v.status);var E=Number(v.getResponseHeader("Content-length")),L,Y=(L=v.getResponseHeader("Accept-Ranges"))&&L==="bytes",O=(L=v.getResponseHeader("Content-Encoding"))&&L==="gzip",f=1024*1024;Y||(f=E);var d=(M,$)=>{if(M>$)throw new Error("invalid range ("+M+", "+$+") or no bytes requested!");if($>E-1)throw new Error("only "+E+" bytes available! programmer error!");var T=new XMLHttpRequest;if(T.open("GET",t,!1),E!==f&&T.setRequestHeader("Range","bytes="+M+"-"+$),T.responseType="arraybuffer",T.overrideMimeType&&T.overrideMimeType("text/plain; charset=x-user-defined"),T.send(null),!(T.status>=200&&T.status<300||T.status===304))throw new Error("Couldn't load "+t+". Status: "+T.status);return T.response!==void 0?new Uint8Array(T.response||[]):Dr(T.responseText||"",!0)},C=this;C.setDataGetter(M=>{var $=M*f,T=(M+1)*f-1;if(T=Math.min(T,E-1),typeof C.chunks[M]>"u"&&(C.chunks[M]=d($,T)),typeof C.chunks[M]>"u")throw new Error("doXHR failed!");return C.chunks[M]}),(O||!E)&&(f=E=1,E=this.getter(0).length,f=E,vr("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=E,this._chunkSize=f,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(typeof XMLHttpRequest<"u"){if(!tr)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var s=new i,u={isDevice:!1,contents:s}}else var u={isDevice:!1,url:t};var c=n.createFile(r,e,u,o,a);u.contents?c.contents=u.contents:u.url&&(c.contents=null,c.url=u.url),Object.defineProperties(c,{usedBytes:{get:function(){return this.contents.length}}});var h={},k=Object.keys(c.stream_ops);k.forEach(m=>{var v=c.stream_ops[m];h[m]=(...E)=>(n.forceLoadFile(c),v(...E))});function S(m,v,E,L,Y){var O=m.node.contents;if(Y>=O.length)return 0;var f=Math.min(O.length-Y,L);if(O.slice)for(var d=0;d<f;d++)v[E+d]=O[Y+d];else for(var d=0;d<f;d++)v[E+d]=O.get(Y+d);return f}return h.read=(m,v,E,L,Y)=>(n.forceLoadFile(c),S(m,v,E,L,Y)),h.mmap=(m,v,E,L,Y)=>{n.forceLoadFile(c);var O=ee(v);if(!O)throw new n.ErrnoError(48);return S(m,R,O,v,E),{ptr:O,allocated:!0}},c.stream_ops=h,c}},Or=(r,e)=>r?lr(z,r,e):"",_={DEFAULT_POLLMASK:5,calculateAt(r,e,t){if(D.isAbs(e))return e;var o;if(r===-100)o=n.cwd();else{var a=_.getStreamFromFD(r);o=a.path}if(e.length==0){if(!t)throw new n.ErrnoError(44);return o}return D.join2(o,e)},doStat(r,e,t){var o=r(e);w[t>>2]=o.dev,w[t+4>>2]=o.mode,P[t+8>>2]=o.nlink,w[t+12>>2]=o.uid,w[t+16>>2]=o.gid,w[t+20>>2]=o.rdev,N=[o.size>>>0,(g=o.size,+Math.abs(g)>=1?g>0?+Math.floor(g/4294967296)>>>0:~~+Math.ceil((g-+(~~g>>>0))/4294967296)>>>0:0)],w[t+24>>2]=N[0],w[t+28>>2]=N[1],w[t+32>>2]=4096,w[t+36>>2]=o.blocks;var a=o.atime.getTime(),i=o.mtime.getTime(),s=o.ctime.getTime();return N=[Math.floor(a/1e3)>>>0,(g=Math.floor(a/1e3),+Math.abs(g)>=1?g>0?+Math.floor(g/4294967296)>>>0:~~+Math.ceil((g-+(~~g>>>0))/4294967296)>>>0:0)],w[t+40>>2]=N[0],w[t+44>>2]=N[1],P[t+48>>2]=a%1e3*1e3,N=[Math.floor(i/1e3)>>>0,(g=Math.floor(i/1e3),+Math.abs(g)>=1?g>0?+Math.floor(g/4294967296)>>>0:~~+Math.ceil((g-+(~~g>>>0))/4294967296)>>>0:0)],w[t+56>>2]=N[0],w[t+60>>2]=N[1],P[t+64>>2]=i%1e3*1e3,N=[Math.floor(s/1e3)>>>0,(g=Math.floor(s/1e3),+Math.abs(g)>=1?g>0?+Math.floor(g/4294967296)>>>0:~~+Math.ceil((g-+(~~g>>>0))/4294967296)>>>0:0)],w[t+72>>2]=N[0],w[t+76>>2]=N[1],P[t+80>>2]=s%1e3*1e3,N=[o.ino>>>0,(g=o.ino,+Math.abs(g)>=1?g>0?+Math.floor(g/4294967296)>>>0:~~+Math.ceil((g-+(~~g>>>0))/4294967296)>>>0:0)],w[t+88>>2]=N[0],w[t+92>>2]=N[1],0},doMsync(r,e,t,o,a){if(!n.isFile(e.node.mode))throw new n.ErrnoError(43);if(o&2)return 0;var i=z.slice(r,r+t);n.msync(e,i,a,t,o)},varargs:void 0,get(){var r=w[+_.varargs>>2];return _.varargs+=4,r},getp(){return _.get()},getStr(r){var e=Or(r);return e},getStreamFromFD(r){var e=n.getStreamChecked(r);return e}};function nt(r){try{return r=_.getStr(r),n.chdir(r),0}catch(e){if(typeof n>"u"||e.name!=="ErrnoError")throw e;return-e.errno}}function ot(r,e,t,o){try{if(e=_.getStr(e),e=_.calculateAt(r,e),t&-8)return-28;var a=n.lookupPath(e,{follow:!0}),i=a.node;if(!i)return-44;var s="";return t&4&&(s+="r"),t&2&&(s+="w"),t&1&&(s+="x"),s&&n.nodePermissions(i,s)?-2:0}catch(u){if(typeof n>"u"||u.name!=="ErrnoError")throw u;return-u.errno}}function at(r,e,t){_.varargs=t;try{var o=_.getStreamFromFD(r);switch(e){case 0:{var a=_.get();if(a<0)return-28;for(;n.streams[a];)a++;var i;return i=n.dupStream(o,a),i.fd}case 1:case 2:return 0;case 3:return o.flags;case 4:{var a=_.get();return o.flags|=a,0}case 12:{var a=_.getp(),s=0;return Er[a+s>>1]=2,0}case 13:case 14:return 0}return-28}catch(u){if(typeof n>"u"||u.name!=="ErrnoError")throw u;return-u.errno}}function it(r,e){try{var t=_.getStreamFromFD(r);return _.doStat(n.stat,t.path,e)}catch(o){if(typeof n>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}var te=(r,e,t)=>zr(r,z,e,t);function st(r,e){try{if(e===0)return-28;var t=n.cwd(),o=Fr(t)+1;return e<o?-68:(te(t,r,e),o)}catch(a){if(typeof n>"u"||a.name!=="ErrnoError")throw a;return-a.errno}}function ut(r,e,t){_.varargs=t;try{var o=_.getStreamFromFD(r);switch(e){case 21509:return o.tty?0:-59;case 21505:{if(!o.tty)return-59;if(o.tty.ops.ioctl_tcgets){var a=o.tty.ops.ioctl_tcgets(o),i=_.getp();w[i>>2]=a.c_iflag||0,w[i+4>>2]=a.c_oflag||0,w[i+8>>2]=a.c_cflag||0,w[i+12>>2]=a.c_lflag||0;for(var s=0;s<32;s++)R[i+s+17]=a.c_cc[s]||0;return 0}return 0}case 21510:case 21511:case 21512:return o.tty?0:-59;case 21506:case 21507:case 21508:{if(!o.tty)return-59;if(o.tty.ops.ioctl_tcsets){for(var i=_.getp(),u=w[i>>2],c=w[i+4>>2],h=w[i+8>>2],k=w[i+12>>2],S=[],s=0;s<32;s++)S.push(R[i+s+17]);return o.tty.ops.ioctl_tcsets(o.tty,e,{c_iflag:u,c_oflag:c,c_cflag:h,c_lflag:k,c_cc:S})}return 0}case 21519:{if(!o.tty)return-59;var i=_.getp();return w[i>>2]=0,0}case 21520:return o.tty?-28:-59;case 21531:{var i=_.getp();return n.ioctl(o,e,i)}case 21523:{if(!o.tty)return-59;if(o.tty.ops.ioctl_tiocgwinsz){var m=o.tty.ops.ioctl_tiocgwinsz(o.tty),i=_.getp();Er[i>>1]=m[0],Er[i+2>>1]=m[1]}return 0}case 21524:return o.tty?0:-59;case 21515:return o.tty?0:-59;default:return-28}}catch(v){if(typeof n>"u"||v.name!=="ErrnoError")throw v;return-v.errno}}function lt(r,e,t,o){try{e=_.getStr(e);var a=o&256,i=o&4096;return o=o&-6401,e=_.calculateAt(r,e,i),_.doStat(a?n.lstat:n.stat,e,t)}catch(s){if(typeof n>"u"||s.name!=="ErrnoError")throw s;return-s.errno}}function ft(r,e,t,o){_.varargs=o;try{e=_.getStr(e),e=_.calculateAt(r,e);var a=o?_.get():0;return n.open(e,t,a).fd}catch(i){if(typeof n>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function ct(r,e){try{return r=_.getStr(r),_.doStat(n.stat,r,e)}catch(t){if(typeof n>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}var dt=1,vt=()=>dt,mt=()=>{Kr=!1,ae=0},ht=()=>{throw 1/0},xr=(r,e)=>e+2097152>>>0<4194305-!!r?(r>>>0)+e*4294967296:NaN;function pt(r,e,t,o,a,i,s,u){var c=xr(a,i);try{if(isNaN(c))return 61;var h=_.getStreamFromFD(o),k=n.mmap(h,r,c,e,t),S=k.ptr;return w[s>>2]=k.allocated,P[u>>2]=S,0}catch(m){if(typeof n>"u"||m.name!=="ErrnoError")throw m;return-m.errno}}function wt(r,e,t,o,a,i,s){var u=xr(i,s);try{var c=_.getStreamFromFD(a);t&2&&_.doMsync(r,c,e,o,u)}catch(h){if(typeof n>"u"||h.name!=="ErrnoError")throw h;return-h.errno}}var yt=()=>{Cr("")},_t=()=>Date.now(),ne=()=>2147483648,gt=()=>ne(),oe;oe=()=>performance.now();var Et=(r,e,t)=>z.copyWithin(r,e,e+t),kt=r=>{var e=or.buffer,t=(r-e.byteLength+65535)/65536;try{return or.grow(t),Hr(),1}catch{}},St=r=>{var e=z.length;r>>>=0;var t=ne();if(r>t)return!1;for(var o=(c,h)=>c+(h-c%h)%h,a=1;a<=4;a*=2){var i=e*(1+.2/a);i=Math.min(i,r+100663296);var s=Math.min(t,o(Math.max(r,i),65536)),u=kt(s);if(u)return!0}return!1},Ur={},bt=()=>X||"./this.program",wr=()=>{if(!wr.strings){var r=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:r,_:bt()};for(var t in Ur)Ur[t]===void 0?delete e[t]:e[t]=Ur[t];var o=[];for(var t in e)o.push(`${t}=${e[t]}`);wr.strings=o}return wr.strings},Ft=(r,e)=>{for(var t=0;t<r.length;++t)R[e++]=r.charCodeAt(t);R[e]=0},Dt=(r,e)=>{var t=0;return wr().forEach((o,a)=>{var i=e+t;P[r+a*4>>2]=i,Ft(o,i),t+=o.length+1}),0},Pt=(r,e)=>{var t=wr();P[r>>2]=t.length;var o=0;return t.forEach(a=>o+=a.length+1),P[e>>2]=o,0},ae=0,Mt=()=>Kr||ae>0,ie=r=>{ar=r,Mt()||(l.onExit?.(r),mr=!0),x(r,new Gr(r))},se=(r,e)=>{ar=r,ie(r)},At=se;function Rt(r){try{var e=_.getStreamFromFD(r);return n.close(e),0}catch(t){if(typeof n>"u"||t.name!=="ErrnoError")throw t;return t.errno}}var Tt=(r,e,t,o)=>{for(var a=0,i=0;i<t;i++){var s=P[e>>2],u=P[e+4>>2];e+=8;var c=n.read(r,R,s,u,o);if(c<0)return-1;if(a+=c,c<u)break;typeof o<"u"&&(o+=c)}return a};function Nt(r,e,t,o){try{var a=_.getStreamFromFD(r),i=Tt(a,e,t);return P[o>>2]=i,0}catch(s){if(typeof n>"u"||s.name!=="ErrnoError")throw s;return s.errno}}function Ct(r,e,t,o,a){var i=xr(e,t);try{if(isNaN(i))return 61;var s=_.getStreamFromFD(r);return n.llseek(s,i,o),N=[s.position>>>0,(g=s.position,+Math.abs(g)>=1?g>0?+Math.floor(g/4294967296)>>>0:~~+Math.ceil((g-+(~~g>>>0))/4294967296)>>>0:0)],w[a>>2]=N[0],w[a+4>>2]=N[1],s.getdents&&i===0&&o===0&&(s.getdents=null),0}catch(u){if(typeof n>"u"||u.name!=="ErrnoError")throw u;return u.errno}}var It=(r,e,t,o)=>{for(var a=0,i=0;i<t;i++){var s=P[e>>2],u=P[e+4>>2];e+=8;var c=n.write(r,R,s,u,o);if(c<0)return-1;a+=c,typeof o<"u"&&(o+=c)}return a};function zt(r,e,t,o){try{var a=_.getStreamFromFD(r),i=It(a,e,t);return P[o>>2]=i,0}catch(s){if(typeof n>"u"||s.name!=="ErrnoError")throw s;return s.errno}}var Pr=r=>r%4===0&&(r%100!==0||r%400===0),Lt=(r,e)=>{for(var t=0,o=0;o<=e;t+=r[o++]);return t},ue=[31,29,31,30,31,30,31,31,30,31,30,31],le=[31,28,31,30,31,30,31,31,30,31,30,31],Ot=(r,e)=>{for(var t=new Date(r.getTime());e>0;){var o=Pr(t.getFullYear()),a=t.getMonth(),i=(o?ue:le)[a];if(e>i-t.getDate())e-=i-t.getDate()+1,t.setDate(1),a<11?t.setMonth(a+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1));else return t.setDate(t.getDate()+e),t}return t},xt=(r,e)=>{R.set(r,e)},Ut=(r,e,t,o)=>{var a=P[o+40>>2],i={tm_sec:w[o>>2],tm_min:w[o+4>>2],tm_hour:w[o+8>>2],tm_mday:w[o+12>>2],tm_mon:w[o+16>>2],tm_year:w[o+20>>2],tm_wday:w[o+24>>2],tm_yday:w[o+28>>2],tm_isdst:w[o+32>>2],tm_gmtoff:w[o+36>>2],tm_zone:a?Or(a):""},s=Or(t),u={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var c in u)s=s.replace(new RegExp(c,"g"),u[c]);var h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],k=["January","February","March","April","May","June","July","August","September","October","November","December"];function S(f,d,C){for(var M=typeof f=="number"?f.toString():f||"";M.length<d;)M=C[0]+M;return M}function m(f,d){return S(f,d,"0")}function v(f,d){function C($){return $<0?-1:$>0?1:0}var M;return(M=C(f.getFullYear()-d.getFullYear()))===0&&(M=C(f.getMonth()-d.getMonth()))===0&&(M=C(f.getDate()-d.getDate())),M}function E(f){switch(f.getDay()){case 0:return new Date(f.getFullYear()-1,11,29);case 1:return f;case 2:return new Date(f.getFullYear(),0,3);case 3:return new Date(f.getFullYear(),0,2);case 4:return new Date(f.getFullYear(),0,1);case 5:return new Date(f.getFullYear()-1,11,31);case 6:return new Date(f.getFullYear()-1,11,30)}}function L(f){var d=Ot(new Date(f.tm_year+1900,0,1),f.tm_yday),C=new Date(d.getFullYear(),0,4),M=new Date(d.getFullYear()+1,0,4),$=E(C),T=E(M);return v($,d)<=0?v(T,d)<=0?d.getFullYear()+1:d.getFullYear():d.getFullYear()-1}var Y={"%a":f=>h[f.tm_wday].substring(0,3),"%A":f=>h[f.tm_wday],"%b":f=>k[f.tm_mon].substring(0,3),"%B":f=>k[f.tm_mon],"%C":f=>{var d=f.tm_year+1900;return m(d/100|0,2)},"%d":f=>m(f.tm_mday,2),"%e":f=>S(f.tm_mday,2," "),"%g":f=>L(f).toString().substring(2),"%G":L,"%H":f=>m(f.tm_hour,2),"%I":f=>{var d=f.tm_hour;return d==0?d=12:d>12&&(d-=12),m(d,2)},"%j":f=>m(f.tm_mday+Lt(Pr(f.tm_year+1900)?ue:le,f.tm_mon-1),3),"%m":f=>m(f.tm_mon+1,2),"%M":f=>m(f.tm_min,2),"%n":()=>`
4
+ `,"%p":f=>f.tm_hour>=0&&f.tm_hour<12?"AM":"PM","%S":f=>m(f.tm_sec,2),"%t":()=>" ","%u":f=>f.tm_wday||7,"%U":f=>{var d=f.tm_yday+7-f.tm_wday;return m(Math.floor(d/7),2)},"%V":f=>{var d=Math.floor((f.tm_yday+7-(f.tm_wday+6)%7)/7);if((f.tm_wday+371-f.tm_yday-2)%7<=2&&d++,d){if(d==53){var M=(f.tm_wday+371-f.tm_yday)%7;M!=4&&(M!=3||!Pr(f.tm_year))&&(d=1)}}else{d=52;var C=(f.tm_wday+7-f.tm_yday-1)%7;(C==4||C==5&&Pr(f.tm_year%400-1))&&d++}return m(d,2)},"%w":f=>f.tm_wday,"%W":f=>{var d=f.tm_yday+7-(f.tm_wday+6)%7;return m(Math.floor(d/7),2)},"%y":f=>(f.tm_year+1900).toString().substring(2),"%Y":f=>f.tm_year+1900,"%z":f=>{var d=f.tm_gmtoff,C=d>=0;return d=Math.abs(d)/60,d=d/60*100+d%60,(C?"+":"-")+("0000"+d).slice(-4)},"%Z":f=>f.tm_zone,"%%":()=>"%"};s=s.replace(/%%/g,"\0\0");for(var c in Y)s.includes(c)&&(s=s.replace(new RegExp(c,"g"),Y[c](i)));s=s.replace(/\0\0/g,"%");var O=Dr(s,!1);return O.length>e?0:(xt(O,r),O.length-1)},Bt=(r,e,t,o,a)=>Ut(r,e,t,o),jt=r=>{if(r instanceof Gr||r=="unwind")return ar;x(1,r)},Ht=r=>{var e=Fr(r)+1,t=Br(e);return te(r,t,e),t};n.createPreloadedFile=et,n.staticInit(),l.FS_createPath=n.createPath,l.FS_createDataFile=n.createDataFile,l.FS_createPreloadedFile=n.createPreloadedFile,l.FS_unlink=n.unlink,l.FS_createLazyFile=n.createLazyFile,l.FS_createDevice=n.createDevice;var Wt={y:We,a:$e,L:nt,M:ot,q:at,G:it,D:st,N:ut,E:lt,n:ft,F:ct,I:vt,A:mt,v:ht,r:pt,s:wt,b:yt,J:_t,x:gt,H:oe,K:Et,w:St,B:Dt,C:Pt,j:At,l:Rt,p:Nt,t:Ct,o:zt,h:Kt,k:qt,d:Xt,e:$t,m:Jt,c:Vt,f:Gt,i:Zt,g:Qt,z:ie,u:Bt},j=He(),Yt=()=>(Yt=j.P)(),fe=l._main=(r,e)=>(fe=l._main=j.Q)(r,e),ce=(r,e)=>(ce=j.S)(r,e),V=(r,e)=>(V=j.T)(r,e),G=()=>(G=j.U)(),K=r=>(K=j.V)(r),Br=r=>(Br=j.W)(r),de=r=>(de=j.X)(r);function Xt(r,e,t,o){var a=G();try{return q(r)(e,t,o)}catch(i){if(K(a),i!==i+0)throw i;V(1,0)}}function $t(r,e,t,o,a){var i=G();try{return q(r)(e,t,o,a)}catch(s){if(K(i),s!==s+0)throw s;V(1,0)}}function qt(r,e,t){var o=G();try{return q(r)(e,t)}catch(a){if(K(o),a!==a+0)throw a;V(1,0)}}function Vt(r){var e=G();try{q(r)()}catch(t){if(K(e),t!==t+0)throw t;V(1,0)}}function Gt(r,e){var t=G();try{q(r)(e)}catch(o){if(K(t),o!==o+0)throw o;V(1,0)}}function Kt(r){var e=G();try{return q(r)()}catch(t){if(K(e),t!==t+0)throw t;V(1,0)}}function Jt(r,e,t,o,a,i){var s=G();try{return q(r)(e,t,o,a,i)}catch(u){if(K(s),u!==u+0)throw u;V(1,0)}}function Qt(r,e,t,o){var a=G();try{q(r)(e,t,o)}catch(i){if(K(a),i!==i+0)throw i;V(1,0)}}function Zt(r,e,t){var o=G();try{q(r)(e,t)}catch(a){if(K(o),a!==a+0)throw a;V(1,0)}}l.addRunDependency=kr,l.removeRunDependency=pr,l.FS_createPath=n.createPath,l.FS_createLazyFile=n.createLazyFile,l.FS_createDevice=n.createDevice,l.callMain=ve,l.FS_createPreloadedFile=n.createPreloadedFile,l.FS=n,l.FS_createDataFile=n.createDataFile,l.FS_unlink=n.unlink;var Mr;hr=function r(){Mr||me(),Mr||(hr=r)};function ve(r=[]){var e=fe;r.unshift(X);var t=r.length,o=Br((t+1)*4),a=o;r.forEach(s=>{P[a>>2]=Ht(s),a+=4}),P[a>>2]=0;try{var i=e(t,o);return se(i,!0),i}catch(s){return jt(s)}}function me(r=Q){if(ir>0||(Ne(),ir>0))return;function e(){Mr||(Mr=!0,l.calledRun=!0,!mr&&(Ce(),Ie(),H(l),l.onRuntimeInitialized&&l.onRuntimeInitialized(),he&&ve(r),ze()))}l.setStatus?(l.setStatus("Running..."),setTimeout(function(){setTimeout(function(){l.setStatus("")},1),e()},1)):e()}if(l.preInit)for(typeof l.preInit=="function"&&(l.preInit=[l.preInit]);l.preInit.length>0;)l.preInit.pop()();var he=!1;return l.noInitialRun&&(he=!1),me(),b.ready}})(),A=null,fr=!1,yr=null,Rr=null,cr=null,ye=new Promise(function(y,b){Rr=y,cr=b}),er={OPTIMAL:"optimal",INFEASIBLE:"infeasible",UNBOUNDED:"unbounded",TIME_LIMIT:"timelimit",UNKNOWN:"unknown",ERROR:"error"};function _e(y){return y.includes("optimal solution found")?er.OPTIMAL:y.includes("problem is infeasible")?er.INFEASIBLE:y.includes("problem is unbounded")?er.UNBOUNDED:y.includes("time limit reached")?er.TIME_LIMIT:er.UNKNOWN}function ge(y,b){var l={},H={value:null},F=b||y,I=F.match(/objective value:\s*([\d.e+-]+)/i);I&&(H.value=parseFloat(I[1]));for(var Q=/^([\w$#]+)\s+([\d.e+-]+)/gm,X;(X=Q.exec(F))!==null;){var x=X[1],Z=parseFloat(X[2]);!isNaN(Z)&&x!=="objective"&&x!=="solution"&&(l[x]=Z)}return{variables:l,objective:H}}function Ee(y){var b={solvingTime:null,nodes:null,iterations:null,gap:null},l=y.match(/Solving Time \(sec\)\s*:\s*([\d.]+)/);l&&(b.solvingTime=parseFloat(l[1]));var H=y.match(/Nodes\s*:\s*(\d+)/);H&&(b.nodes=parseInt(H[1]));var F=y.match(/LP Iterations\s*:\s*(\d+)/);F&&(b.iterations=parseInt(F[1]));var I=y.match(/Gap\s*:\s*([\d.]+)\s*%/);return I&&(b.gap=parseFloat(I[1])),b}function _r(y){return y=y||{},fr?Promise.resolve():yr||(yr=new Promise(function(b,l){try{var H=y.wasmPath||Ar+"scip.wasm";we({locateFile:function(F){return F.endsWith(".wasm")?H:F},print:function(F){A&&A.onStdout&&A.onStdout(F)},printErr:function(F){A&&A.onStderr&&A.onStderr(F)}}).then(function(F){if(A=F,A.FS){try{A.FS.mkdir("/problems")}catch{}try{A.FS.mkdir("/solutions")}catch{}try{A.FS.mkdir("/settings")}catch{}}fr=!0,Rr&&Rr(),b()}).catch(function(F){var I=new Error("SCIP WASM loading failed: "+(F.message||F));cr&&cr(I),l(I)})}catch(F){cr&&cr(F),l(F)}}),yr)}function Tr(y,b){b=b||{};var l=function(){var H=b.format||"lp",F=b.timeLimit||3600,I=b.gap||null,Q=b.verbose||!1,X=b.parameters||{},x="",Z="";A.onStdout=function(z){x+=z+`
5
+ `,Q&&console.log("[SCIP]",z)},A.onStderr=function(z){Z+=z+`
6
+ `,Q&&console.error("[SCIP Error]",z)};try{var tr={mps:"mps",zpl:"zpl",cip:"cip",lp:"lp"},jr=tr[H]||"lp",B="/problems/problem."+jr,gr="/solutions/solution.sol";A.FS.writeFile(B,y);var U=[];U.push("set limits time "+F),I!==null&&U.push("set limits gap "+I);for(var ur in X)X.hasOwnProperty(ur)&&U.push("set "+ur+" "+X[ur]);U.push("read "+B),U.push("optimize"),U.push("display solution"),U.push("write solution "+gr),U.push("display statistics"),U.push("quit");var dr=U.join(`
7
+ `);A.FS.writeFile("/settings/commands.txt",dr);var vr=A.callMain(["-b","/settings/commands.txt"]),W=null;try{W=A.FS.readFile(gr,{encoding:"utf8"})}catch{}for(var nr=_e(x),or=ge(x,W),mr=Ee(x),ar=["/problems/problem.lp","/problems/problem.mps","/problems/problem.zpl","/problems/problem.cip","/solutions/solution.sol","/settings/commands.txt"],R=0;R<ar.length;R++)try{A.FS.unlink(ar[R])}catch{}return{status:nr,objective:or.objective.value,variables:or.variables,statistics:mr,exitCode:vr,output:Q?x:void 0,rawSolution:W}}catch(z){return{status:er.ERROR,error:z.message,output:x+Z}}};return fr?Promise.resolve(l()):_r(b).then(l)}function ke(y,b){return y.toLowerCase().includes("minimize")||(y=`Minimize
8
+ `+y),Tr(y,b)}function Se(y,b){return y.toLowerCase().includes("maximize")||(y=`Maximize
9
+ `+y),Tr(y,b)}function be(){var y=function(){var b="";return A.onStdout=function(l){b+=l+`
10
+ `},A.callMain(["--version"]),b.trim()};return fr?Promise.resolve(y()):_r().then(y)}function Fe(){return fr}var De={init:_r,ready:ye,isReady:Fe,solve:Tr,minimize:ke,maximize:Se,version:be,Status:er};pe.SCIP=De,_r().catch(function(y){console.error("[SCIP.js] Auto-initialization failed:",y.message)})})(typeof self<"u"?self:typeof window<"u"?window:globalThis);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@areb0s/scip.js",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "SCIP Optimization Solver compiled to WebAssembly - LP, MIP, and MINLP support",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",