nodehammer-web 0.2.0rc3__py3-none-any.whl

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.
@@ -0,0 +1,79 @@
1
+ """The nodehammer web viewer runtime, and where it is.
2
+
3
+ This package is one directory of WebAssembly and a function that returns its
4
+ path. Nothing here imports :mod:`nodehammer`, and nothing here runs the viewer:
5
+ serving it is the library's job, and this only answers the question the library
6
+ cannot answer for itself.
7
+
8
+ That question is worth spelling out, because it is the whole reason this package
9
+ exists as a separate distribution. ``nodehammer viewer --web`` needs a directory
10
+ of Emscripten output, and it finds one by walking a ladder --- ``--web-assets``,
11
+ then ``NODEHAMMER_WEB_ASSETS``, then whatever the calling program supplies, then
12
+ ``<executable>/../share/nodehammer/web``. Under a wheel the last rung is wrong:
13
+ the running executable is the interpreter, and in a virtualenv the platform call
14
+ behind it resolves the ``bin/python`` symlink to the *base* interpreter, so the
15
+ search lands in the wrong prefix entirely. The rung above it is the one
16
+ :mod:`nodehammer.cli` fills, with :func:`runtime_dir` below.
17
+
18
+ Installing this package is therefore what makes the GUI work from Python, and
19
+ uninstalling it is what makes a headless install 7 MB smaller. Both are
20
+ supported; the library reports the absence as one rung of a search rather than
21
+ as a fault.
22
+ """
23
+
24
+ from __future__ import annotations
25
+
26
+ from importlib.metadata import PackageNotFoundError, version
27
+ from importlib.resources import files
28
+ from pathlib import Path
29
+
30
+ __all__ = ["runtime_dir"]
31
+
32
+ try:
33
+ __version__ = version("nodehammer-web")
34
+ except PackageNotFoundError: # running from a source checkout, never installed
35
+ __version__ = "0.0.0"
36
+
37
+
38
+ def runtime_dir() -> Path:
39
+ """The directory holding the viewer shell, the worker script and the bundles.
40
+
41
+ :returns: an existing directory containing ``index.html``,
42
+ ``compute_worker.js``, ``nh_runtime.json`` and the three
43
+ ``nodehammer-*.{js,wasm}`` bundle pairs.
44
+
45
+ :raises RuntimeError: if the payload is missing, which means a broken
46
+ install rather than a supported configuration --- there is no version of
47
+ this package whose purpose survives the runtime not being in it.
48
+
49
+ The contents are deliberately *not* checked here beyond the directory
50
+ existing. ``nh_runtime.json`` carries the schema id the bundles were built
51
+ against, and comparing it to the one compiled into the library is the check
52
+ that matters; doing it in C++ means every front door gets it, including the
53
+ ones that never touch Python. Duplicating a weaker version of it here would
54
+ add a second answer to a question that already has one.
55
+ """
56
+ # `files()` rather than `__file__` for the usual reason, but with the result
57
+ # narrowed to a real path: the payload is 7 MB, and the Traversable API's
58
+ # general answer for a non-filesystem package is to extract it to a
59
+ # temporary directory that vanishes when the context manager exits --- which
60
+ # is neither what a server wants to be handed nor something worth doing
61
+ # silently. Wheels install unpacked, so this is the ordinary case; a zipped
62
+ # install is refused rather than worked around.
63
+ root = files(__package__)
64
+ if not isinstance(root, Path):
65
+ msg = (
66
+ f"{__package__} must be installed unpacked, not as a zip import: "
67
+ "the viewer runtime is served from disk"
68
+ )
69
+ raise RuntimeError(msg)
70
+
71
+ runtime = root / "runtime"
72
+ if not runtime.is_dir():
73
+ msg = (
74
+ f"{__package__} carries no runtime at {runtime}. "
75
+ "The wheel is built by staging a wasm build into it, so this is a "
76
+ "broken install rather than a configuration."
77
+ )
78
+ raise RuntimeError(msg)
79
+ return runtime
@@ -0,0 +1,116 @@
1
+ // compute_worker.js — Web Worker host for the headless nodehammer compute module.
2
+ //
3
+ // Runs tessellation + the wedge cut off the main thread. The viewer (main
4
+ // thread) posts build requests; this worker owns a *separate* wasm instance
5
+ // (nodehammer-compute.js, its own heap) and replies with NHR8 render bytes.
6
+ // Nothing is shared: scene bytes come in copied, render bytes go back
7
+ // transferred. No SharedArrayBuffer → no COOP/COEP headers required.
8
+ //
9
+ // Must be created as a classic worker (`new Worker('compute_worker.js')`) so
10
+ // importScripts is available.
11
+ //
12
+ // Protocol (main -> worker):
13
+ // { nh:'build', epoch, sceneBytes?:ArrayBuffer, configToml?:string,
14
+ // wedge?:{ startDeg, endDeg, margin } }
15
+ // sceneBytes/configToml may be omitted when `epoch` matches the last scene
16
+ // already shipped to the wasm cache (e.g. re-aiming the wedge).
17
+ //
18
+ // Protocol (worker -> main):
19
+ // { nh:'progress', phase, processed, total } (emitted from wasm via EM_JS)
20
+ // { nh:'error', message } (emitted from wasm via EM_JS)
21
+ // { nh:'result', epoch, buffer:ArrayBuffer } (NHR8 render bytes, transferred)
22
+
23
+ // The MODULARIZEd loader defines the global NodehammerCompute factory.
24
+ importScripts('nodehammer-compute.js');
25
+
26
+ let modulePromise = null;
27
+ function getModule() {
28
+ if (!modulePromise) {
29
+ modulePromise = NodehammerCompute();
30
+ }
31
+ return modulePromise;
32
+ }
33
+
34
+ // Kick off module instantiation immediately so the wasm loads in parallel with
35
+ // the app's scene fetch rather than lazily on the first build. A load failure is
36
+ // surfaced (fatal) so the main thread can fall back to the cooperative path.
37
+ getModule().catch(function (err) {
38
+ self.postMessage({ nh: 'error', message: 'compute: module load failed: ' + err, fatal: true });
39
+ });
40
+
41
+ // Epoch whose scene bytes are already resident in the wasm cache. Lets re-aim
42
+ // requests skip re-sending (and re-deserializing) the scene.
43
+ let loadedEpoch = -1;
44
+
45
+ self.onmessage = async function (e) {
46
+ const msg = e.data || {};
47
+ if (msg.nh !== 'build') {
48
+ return;
49
+ }
50
+
51
+ let mod;
52
+ try {
53
+ mod = await getModule();
54
+ } catch (err) {
55
+ self.postMessage({ nh: 'error', message: 'compute: module load failed: ' + err, fatal: true });
56
+ return;
57
+ }
58
+
59
+ const epoch = msg.epoch >>> 0;
60
+ const wedge = msg.wedge || null;
61
+
62
+ // Stage scene bytes into the wasm heap only when this epoch isn't cached.
63
+ let scenePtr = 0;
64
+ let sceneLen = 0;
65
+ const sendBytes = !!msg.sceneBytes && epoch !== loadedEpoch;
66
+ if (sendBytes) {
67
+ const bytes = new Uint8Array(msg.sceneBytes);
68
+ sceneLen = bytes.length;
69
+ scenePtr = mod._malloc(sceneLen);
70
+ mod.HEAPU8.set(bytes, scenePtr);
71
+ }
72
+
73
+ const lenPtr = mod._malloc(4);
74
+ let dataPtr = 0;
75
+ try {
76
+ dataPtr = mod.ccall(
77
+ 'nh_compute_build',
78
+ 'number',
79
+ ['number', 'number', 'number', 'string', 'number', 'number', 'number', 'number', 'number'],
80
+ [
81
+ epoch,
82
+ scenePtr,
83
+ sceneLen,
84
+ sendBytes ? (msg.configToml || '') : null,
85
+ wedge ? 1 : 0,
86
+ wedge ? wedge.startDeg : 0,
87
+ wedge ? wedge.endDeg : 0,
88
+ wedge ? (wedge.margin != null ? wedge.margin : 2.0) : 0,
89
+ lenPtr,
90
+ ]
91
+ );
92
+ } finally {
93
+ if (scenePtr) {
94
+ mod._free(scenePtr);
95
+ }
96
+ }
97
+
98
+ if (!dataPtr) {
99
+ // The module already posted an { nh:'error' } message via EM_JS.
100
+ mod._free(lenPtr);
101
+ return;
102
+ }
103
+
104
+ // Re-read the heap views after the build (growth may have moved them).
105
+ const len = mod.HEAPU32[lenPtr >> 2];
106
+ mod._free(lenPtr);
107
+
108
+ // Copy out of the wasm heap into a standalone buffer we can transfer, then
109
+ // free the wasm-side copy.
110
+ const out = new Uint8Array(len);
111
+ out.set(mod.HEAPU8.subarray(dataPtr, dataPtr + len));
112
+ mod._free(dataPtr);
113
+
114
+ loadedEpoch = epoch;
115
+ self.postMessage({ nh: 'result', epoch: epoch, buffer: out.buffer }, [out.buffer]);
116
+ };
@@ -0,0 +1,228 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>nodehammer viewer</title>
6
+ <style>
7
+ html, body {
8
+ margin: 0;
9
+ padding: 0;
10
+ background: #1a1f25;
11
+ color: #c5cdd9;
12
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
13
+ overflow: hidden;
14
+ height: 100%;
15
+ }
16
+ #canvas {
17
+ display: block;
18
+ width: 100vw;
19
+ height: 100vh;
20
+ outline: none;
21
+ }
22
+ #status {
23
+ position: fixed;
24
+ left: 12px;
25
+ bottom: 12px;
26
+ font-size: 12px;
27
+ opacity: 0.6;
28
+ pointer-events: none;
29
+ }
30
+ </style>
31
+ </head>
32
+ <body>
33
+ <canvas id="canvas" tabindex="-1" oncontextmenu="event.preventDefault()"></canvas>
34
+ <div id="status">loading…</div>
35
+ <script>
36
+ // Two viewer postures share this single shell, branched on the sidecar:
37
+ // - Viewer mode: a sibling `nh_manifest.json` names a `.nhproj`
38
+ // archive. The viewer fetches its bytes and opens a content-locked,
39
+ // reload-from-source presentation.
40
+ // - Application mode: no sidecar (404) — the viewer comes up empty and
41
+ // restores your last project from IndexedDB; drag a `.nhproj` (or
42
+ // loose files) onto the canvas, or use the file picker.
43
+ // Per-page query params override the sidecar: `?archive=…` picks the
44
+ // archive URL, `?lock=0` unlocks, and steer params (?pbr=1&…) apply.
45
+ //
46
+ // Sidecar (nh_manifest.json) schema (all fields optional):
47
+ // {
48
+ // "archive": "project.abc123.nhproj", // relative to this file
49
+ // "lock": true, // content-immutable (default)
50
+ // "title": "Open Data Detector",
51
+ // "defaults": { "pbr": true, "autoOrbit": false, ... }
52
+ // }
53
+ // `defaults` keys mirror the query-param names parsed below; they
54
+ // are merged into params before parsing, so query params always win.
55
+ // Directory of the current document, including trailing slash. Used
56
+ // for the manifest fetch (browser-relative) and stripped of its
57
+ // trailing slash to form `--asset-base` for the C++ side, which
58
+ // prepends it to MEMFS paths at fetch time only. This lets the
59
+ // viewer host under arbitrary sub-paths (e.g. /foo/bar/) while the
60
+ // MEMFS layout (and config-include resolution) stays rooted at /.
61
+ var basePath = window.location.pathname.replace(/[^/]*$/, '');
62
+ var assetBase = basePath.replace(/\/$/, '');
63
+
64
+ fetch(basePath + 'nh_manifest.json', { cache: 'no-store' })
65
+ .then(function (r) { return r.ok ? r.json() : null; })
66
+ .catch(function () { return null; })
67
+ .then(function (manifest) { boot(manifest || {}); });
68
+
69
+ function boot(manifest) {
70
+ var params = new URLSearchParams(window.location.search);
71
+
72
+ // Manifest defaults appear as virtual query params; explicit
73
+ // URL params still take precedence.
74
+ if (manifest.defaults) {
75
+ Object.keys(manifest.defaults).forEach(function (k) {
76
+ if (!params.has(k)) {
77
+ params.set(k, String(manifest.defaults[k]));
78
+ }
79
+ });
80
+ }
81
+
82
+ // Viewer mode when an archive is named (query wins over sidecar).
83
+ // Resolve a relative ref against this document's directory.
84
+ var archiveRef = params.get('archive') || manifest.archive || '';
85
+ var archiveUrl = archiveRef ? new URL(archiveRef, window.location.href).href : '';
86
+ // Content lock defaults to on for a viewer-mode publication.
87
+ var lockParam = params.get('lock');
88
+ var lock = lockParam !== null
89
+ ? !(lockParam === '0' || lockParam === 'false' || lockParam === 'off' || lockParam === 'no')
90
+ : (manifest.lock !== undefined ? !!manifest.lock : true);
91
+
92
+ if (manifest.title) {
93
+ document.title = manifest.title;
94
+ }
95
+
96
+ function queryBool(name) {
97
+ var value = params.get(name);
98
+ if (value === null) return null;
99
+ value = value.toLowerCase();
100
+ return !(value === '0' || value === 'false' || value === 'off' || value === 'no');
101
+ }
102
+
103
+ function setBoolOpt(opts, queryName, optKey) {
104
+ var value = queryBool(queryName);
105
+ if (value !== null) {
106
+ opts[optKey] = value;
107
+ }
108
+ }
109
+
110
+ function setNumberOpt(opts, queryName, optKey) {
111
+ var value = params.get(queryName);
112
+ if (value !== null && value !== '') {
113
+ var n = Number(value);
114
+ if (!Number.isNaN(n)) {
115
+ opts[optKey] = n;
116
+ }
117
+ }
118
+ }
119
+
120
+ function setStringOpt(opts, queryName, optKey) {
121
+ var value = params.get(queryName);
122
+ if (value !== null && value !== '') {
123
+ opts[optKey] = value;
124
+ }
125
+ }
126
+
127
+ // Scene building runs in a Web Worker (off the main thread) when
128
+ // one is available; otherwise it falls back to a cooperative
129
+ // main-thread build. Force the main-thread path with ?compute=main
130
+ // (read directly by the C++ worker probe — no JS plumbing needed).
131
+ //
132
+ // Backend selection: WebGPU when available, WebGL2 otherwise.
133
+ // Force a specific backend with ?backend=wgpu/webgpu or
134
+ // ?backend=gles3/webgl2.
135
+ var forced = (params.get('backend') || '').toLowerCase();
136
+ var useWGPU;
137
+ if (forced === 'wgpu' || forced === 'webgpu') {
138
+ useWGPU = true;
139
+ } else if (forced === 'gles3' || forced === 'webgl2' || forced === 'webgl') {
140
+ useWGPU = false;
141
+ } else {
142
+ if (forced) {
143
+ console.warn('unknown backend "' + forced + '", using auto-detect');
144
+ }
145
+ useWGPU = !!navigator.gpu;
146
+ }
147
+ var bundleBase = useWGPU ? 'nodehammer-wgpu' : 'nodehammer-gles3';
148
+
149
+ // Options object mirroring the native CLI's `viewer` flags,
150
+ // serialised to JSON and handed to the wasm `nh_viewer_start`
151
+ // export below. Keys match src/web/viewer_main.cpp's reader.
152
+ var viewerOpts = {};
153
+ if (archiveUrl) {
154
+ viewerOpts.archive = archiveUrl;
155
+ viewerOpts.lock = lock;
156
+ }
157
+ setBoolOpt(viewerOpts, 'cullBack', 'cullBack');
158
+ setBoolOpt(viewerOpts, 'pauseWhenUnfocused', 'pauseWhenUnfocused');
159
+ setBoolOpt(viewerOpts, 'autoOrbit', 'autoOrbit');
160
+ setNumberOpt(viewerOpts, 'orbitSpeed', 'orbitSpeed');
161
+ setBoolOpt(viewerOpts, 'angleCut', 'angleCut');
162
+ setBoolOpt(viewerOpts, 'shaderAngleCut', 'shaderAngleCut');
163
+ setNumberOpt(viewerOpts, 'cutStart', 'cutStart');
164
+ setNumberOpt(viewerOpts, 'cutEnd', 'cutEnd');
165
+ setBoolOpt(viewerOpts, 'pbr', 'pbr');
166
+
167
+ // Camera state survives only when all six fields are present
168
+ // (matches the C++ reader's mutual-requirement check).
169
+ var camera = {};
170
+ setNumberOpt(camera, 'cameraTargetX', 'targetX');
171
+ setNumberOpt(camera, 'cameraTargetY', 'targetY');
172
+ setNumberOpt(camera, 'cameraTargetZ', 'targetZ');
173
+ setNumberOpt(camera, 'cameraDistance', 'distance');
174
+ setNumberOpt(camera, 'cameraYaw', 'yawDeg');
175
+ setNumberOpt(camera, 'cameraPitch', 'pitchDeg');
176
+ setStringOpt(camera, 'cameraProjection', 'projection');
177
+ if (camera.targetX !== undefined && camera.targetY !== undefined &&
178
+ camera.targetZ !== undefined && camera.distance !== undefined &&
179
+ camera.yawDeg !== undefined && camera.pitchDeg !== undefined) {
180
+ viewerOpts.camera = camera;
181
+ }
182
+
183
+ var statusEl = document.getElementById('status');
184
+ window.Module = {
185
+ canvas: document.getElementById('canvas'),
186
+ print: function (msg) { console.log(msg); },
187
+ printErr: function (msg) { console.error(msg); },
188
+ setStatus: function (text) {
189
+ if (text) {
190
+ statusEl.textContent = text;
191
+ statusEl.style.display = 'block';
192
+ } else {
193
+ statusEl.style.display = 'none';
194
+ }
195
+ },
196
+ // Tell emscripten where to fetch the .wasm sidecar (the
197
+ // loader emits its own filename otherwise, which is fine —
198
+ // but with two bundles in the same dir we want to be
199
+ // explicit).
200
+ locateFile: function (path) {
201
+ if (path.endsWith('.wasm')) return bundleBase + '.wasm';
202
+ return path;
203
+ },
204
+ // No preRun preloads — assets are fetched from C++ via
205
+ // emscripten_fetch after the viewer starts so imgui can
206
+ // render a progress UI instead of blocking startup.
207
+ onRuntimeInitialized: function () {
208
+ Module.ccall('nh_viewer_start', 'number', ['string'],
209
+ [JSON.stringify(viewerOpts)]);
210
+ },
211
+ };
212
+ window.Module.setStatus('loading ' + bundleBase + '…');
213
+ window.onerror = function (msg) {
214
+ window.Module.setStatus('error — see console');
215
+ console.error(msg);
216
+ };
217
+
218
+ // Inject the matching loader script. Emscripten's loader picks
219
+ // up the global `Module` object set above and starts the wasm
220
+ // fetch (via locateFile) as soon as it executes.
221
+ var s = document.createElement('script');
222
+ s.src = bundleBase + '.js';
223
+ s.async = true;
224
+ document.body.appendChild(s);
225
+ }
226
+ </script>
227
+ </body>
228
+ </html>
@@ -0,0 +1,4 @@
1
+ {
2
+ "schema": 1,
3
+ "version": "0.2.0rc3"
4
+ }
@@ -0,0 +1,50 @@
1
+ async function NodehammerCompute(moduleArg={}){var moduleRtn;var h=moduleArg,aa=!!globalThis.window,ba=!!globalThis.WorkerGlobalScope,k=globalThis.process?.versions?.node&&"renderer"!=globalThis.process?.type,ca=[],m="./this.program",da=(a,b)=>{throw b;},ea;"undefined"!=typeof __filename?ea=__filename:ba&&(ea=self.location.href);var r="",fa,t;
2
+ if(k){var fs=require("node:fs");r=__dirname+"/";t=a=>{a=ha(a)?new URL(a):a;return fs.readFileSync(a)};fa=async a=>{a=ha(a)?new URL(a):a;return fs.readFileSync(a,void 0)};1<process.argv.length&&(m=process.argv[1].replace(/\\/g,"/"));ca=process.argv.slice(2);da=(a,b)=>{process.exitCode=a;throw b;}}else if(aa||ba){try{r=(new URL(".",ea)).href}catch{}ba&&(t=a=>{var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)});fa=async a=>{a=await fetch(a,
3
+ {credentials:"same-origin"});if(a.ok)return a.arrayBuffer();throw Error(a.status+" : "+a.url);}}var ia=console.log.bind(console),w=console.error.bind(console),x,y=!1,A,ha=a=>a.startsWith("file://"),ja,ka,la=!1;function ma(){var a=B.buffer;C=new Int8Array(a);D=new Int16Array(a);h.HEAPU8=E=new Uint8Array(a);new Uint16Array(a);F=new Int32Array(a);h.HEAPU32=G=new Uint32Array(a);new Float32Array(a);new Float64Array(a);na=new BigInt64Array(a);new BigUint64Array(a)}
4
+ function oa(a){h.onAbort?.(a);a=`Aborted(${a})`;w(a);y=!0;a+=". Build with -sASSERTIONS for more info.";la&&pa();a=new WebAssembly.RuntimeError(a);ka?.(a);throw a;}var qa;async function ra(a){if(!x)try{var b=await fa(a);return new Uint8Array(b)}catch{}if(a==qa&&x)a=new Uint8Array(x);else if(t)a=t(a);else throw"both async and sync fetching of the wasm failed";return a}
5
+ async function sa(a,b){try{var c=await ra(a);return await WebAssembly.instantiate(c,b)}catch(d){w(`failed to asynchronously prepare wasm: ${d}`),oa(d)}}async function ta(a){var b=qa;if(!x&&!k)try{var c=fetch(b,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(c,a)}catch(d){w(`wasm streaming compile failed: ${d}`),w("falling back to ArrayBuffer instantiation")}return sa(b,a)}
6
+ class ua{name="ExitStatus";constructor(a){this.message=`Program terminated with exit(${a})`;this.status=a}}
7
+ var D,F,na,C,G,E,va=a=>{for(;0<a.length;)a.shift()(h)},wa=[],xa=[],ya=()=>{var a=h.preRun.shift();xa.push(a)},I=!0,K=()=>{var a=F[+J>>2];J+=4;return a},za=(a,b)=>{for(var c=0,d=a.length-1;0<=d;d--){var e=a[d];"."===e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c;c--)a.unshift("..");return a},Aa=a=>{var b="/"===a.charAt(0),c="/"===a.slice(-1);(a=za(a.split("/").filter(d=>!!d),!b).join("/"))||b||(a=".");a&&c&&(a+="/");return(b?"/":"")+a},Ba=a=>{var b=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);
8
+ a=b[0];b=b[1];if(!a&&!b)return".";b&&=b.slice(0,-1);return a+b},Ca=()=>{if(k){var a=require("node:crypto");return b=>a.randomFillSync(b)}return b=>(crypto.getRandomValues(b),0)},Da=a=>(Da=Ca())(a),Fa=(...a)=>{for(var b="",c=!1,d=a.length-1;-1<=d&&!c;d--){c=0<=d?a[d]:"/";if("string"!=typeof c)throw new TypeError("Arguments to path.resolve must be strings");if(!c)return"";b=c+"/"+b;c="/"===c.charAt(0)}b=za(b.split("/").filter(e=>!!e),!c).join("/");return(c?"/":"")+b||"."},Ga=new TextDecoder,Ha=(a,b)=>
9
+ {for(var c=b+void 0;a[b]&&!(b>=c);)++b;return b},Ia=a=>{var b=Ha(a,0);return Ga.decode(a.buffer?a.subarray(0,b):new Uint8Array(a.slice(0,b)))},Ja=[],L=a=>{for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);127>=d?b++:2047>=d?b+=2:55296<=d&&57343>=d?(b+=4,++c):b+=3}return b},M=(a,b,c,d)=>{if(!(0<d))return 0;var e=c;d=c+d-1;for(var f=0;f<a.length;++f){var g=a.codePointAt(f);if(127>=g){if(c>=d)break;b[c++]=g}else if(2047>=g){if(c+1>=d)break;b[c++]=192|g>>6;b[c++]=128|g&63}else if(65535>=g){if(c+2>=
10
+ d)break;b[c++]=224|g>>12;b[c++]=128|g>>6&63;b[c++]=128|g&63}else{if(c+3>=d)break;b[c++]=240|g>>18;b[c++]=128|g>>12&63;b[c++]=128|g>>6&63;b[c++]=128|g&63;f++}}b[c]=0;return c-e},Ka=[];function La(a,b){Ka[a]={input:[],output:[],O:b};Ma(a,Na)}
11
+ var Na={open(a){var b=Ka[a.node.rdev];if(!b)throw new N(43);a.tty=b;a.seekable=!1},close(a){a.tty.O.fsync(a.tty)},fsync(a){a.tty.O.fsync(a.tty)},read(a,b,c,d){if(!a.tty||!a.tty.O.aa)throw new N(60);for(var e=0,f=0;f<d;f++){try{var g=a.tty.O.aa(a.tty)}catch(n){throw new N(29);}if(void 0===g&&0===e)throw new N(6);if(null===g||void 0===g)break;e++;b[c+f]=g}e&&(a.node.atime=Date.now());return e},write(a,b,c,d){if(!a.tty||!a.tty.O.Z)throw new N(60);try{for(var e=0;e<d;e++)a.tty.O.Z(a.tty,b[c+e])}catch(f){throw new N(29);
12
+ }d&&(a.node.mtime=a.node.ctime=Date.now());return e}},Oa={aa(){a:{if(!Ja.length){var a=null;if(k){var b=Buffer.alloc(256),c=0,d=process.stdin.fd;try{c=fs.readSync(d,b,0,256)}catch(e){if(e.toString().includes("EOF"))c=0;else throw e;}0<c&&(a=b.slice(0,c).toString("utf-8"))}if(!a){a=null;break a}b=Array(L(a)+1);a=M(a,b,0,b.length);b.length=a;Ja=b}a=Ja.shift()}return a},Z(a,b){null===b||10===b?(ia(Ia(a.output)),a.output=[]):0!=b&&a.output.push(b)},fsync(a){0<a.output?.length&&(ia(Ia(a.output)),a.output=
13
+ [])},ia(){return{ra:25856,ta:5,qa:191,sa:35387,pa:[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]}},ja(){return 0},ka(){return[24,80]}},Pa={Z(a,b){null===b||10===b?(w(Ia(a.output)),a.output=[]):0!=b&&a.output.push(b)},fsync(a){0<a.output?.length&&(w(Ia(a.output)),a.output=[])}},R={L:null,N(){return R.createNode(null,"/",16895,0)},createNode(a,b,c,d){if(24576===(c&61440)||4096===(c&61440))throw new N(63);R.L||(R.L={dir:{node:{P:R.F.P,M:R.F.M,lookup:R.F.lookup,T:R.F.T,rename:R.F.rename,
14
+ unlink:R.F.unlink,rmdir:R.F.rmdir,readdir:R.F.readdir,symlink:R.F.symlink},stream:{K:R.G.K}},file:{node:{P:R.F.P,M:R.F.M},stream:{K:R.G.K,read:R.G.read,write:R.G.write,da:R.G.da,fa:R.G.fa}},link:{node:{P:R.F.P,M:R.F.M,readlink:R.F.readlink},stream:{}},$:{node:{P:R.F.P,M:R.F.M},stream:Qa}});c=Ra(a,b,c,d);16384===(c.mode&61440)?(c.F=R.L.dir.node,c.G=R.L.dir.stream,c.H={}):32768===(c.mode&61440)?(c.F=R.L.file.node,c.G=R.L.file.stream,c.I=0,c.H=R.ga??(R.ga=new Uint8Array(0))):40960===(c.mode&61440)?(c.F=
15
+ R.L.link.node,c.G=R.L.link.stream):8192===(c.mode&61440)&&(c.F=R.L.$.node,c.G=R.L.$.stream);c.atime=c.mtime=c.ctime=Date.now();a&&(a.H[b]=c,a.atime=a.mtime=a.ctime=c.atime);return c},F:{P(a){var b={};b.dev=8192===(a.mode&61440)?a.id:1;b.ino=a.id;b.mode=a.mode;b.nlink=1;b.uid=0;b.gid=0;b.rdev=a.rdev;16384===(a.mode&61440)?b.size=4096:32768===(a.mode&61440)?b.size=a.I:40960===(a.mode&61440)?b.size=a.link.length:b.size=0;b.atime=new Date(a.atime);b.mtime=new Date(a.mtime);b.ctime=new Date(a.ctime);b.blksize=
16
+ 4096;b.blocks=Math.ceil(b.size/b.blksize);return b},M(a,b){for(var c of["mode","atime","mtime","ctime"])null!=b[c]&&(a[c]=b[c]);void 0!==b.size&&(b=b.size,a.I!=b&&(c=a.H,a.H=new Uint8Array(b),a.H.set(c.subarray(0,Math.min(b,a.I))),a.I=b))},lookup(){R.V||(R.V=new N(44),R.V.stack="<generic error, no stack>");throw R.V;},T(a,b,c,d){return R.createNode(a,b,c,d)},rename(a,b,c){try{var d=Sa(b,c)}catch(f){}if(d){if(16384===(a.mode&61440))for(var e in d.H)throw new N(55);e=Ta(d.parent.id,d.name);if(S[e]===
17
+ d)S[e]=d.R;else for(e=S[e];e;){if(e.R===d){e.R=d.R;break}e=e.R}}delete a.parent.H[a.name];b.H[c]=a;a.name=c;b.ctime=b.mtime=a.parent.ctime=a.parent.mtime=Date.now()},unlink(a,b){delete a.H[b];a.ctime=a.mtime=Date.now()},rmdir(a,b){var c=Sa(a,b),d;for(d in c.H)throw new N(55);delete a.H[b];a.ctime=a.mtime=Date.now()},readdir(a){return[".","..",...Object.keys(a.H)]},symlink(a,b,c){a=R.createNode(a,b,41471,0);a.link=c;return a},readlink(a){if(40960!==(a.mode&61440))throw new N(28);return a.link}},G:{read(a,
18
+ b,c,d,e){if(e>=a.node.I)return 0;d=Math.min(a.node.I-e,d);b.set(a.node.H.subarray(e,e+d),c);return d},write(a,b,c,d,e,f){b.buffer===C.buffer&&(f=!1);if(!d)return 0;a=a.node;a.mtime=a.ctime=Date.now();if(f)a.H=b.subarray(c,c+d),a.I=d;else if(0===a.I&&0===e)a.H=b.slice(c,c+d),a.I=d;else{f=e+d;var g=a.H.length;g>=f||(f=Math.max(f,g*(1048576>g?2:1.125)>>>0),g&&(f=Math.max(f,256)),g=a.H.subarray(0,a.I),a.H=new Uint8Array(f),a.H.set(g));a.H.set(b.subarray(c,c+d),e);a.I=Math.max(a.I,e+d)}return d},K(a,b,
19
+ c){1===c?b+=a.position:2===c&&32768===(a.node.mode&61440)&&(b+=a.node.I);if(0>b)throw new N(28);return b},da(a,b,c,d,e){if(32768!==(a.node.mode&61440))throw new N(43);a=a.node.H;if(e&2||a.buffer!==C.buffer){d=!0;oa();e=void 0;if(!e)throw new N(48);if(a){if(0<c||c+b<a.length)a.subarray?a=a.subarray(c,c+b):a=Array.prototype.slice.call(a,c,c+b);C.set(a,e)}}else d=!1,e=a.byteOffset;return{xa:e,oa:d}},fa(a,b,c,d){R.G.write(a,b,0,d,c,!1);return 0}}},Ua=(a,b)=>{var c=0;a&&(c|=365);b&&(c|=146);return c},
20
+ Va=null,Wa={},T=[],Xa=1,S=null,Ya=!1,Za=!0,N=class{name="ErrnoError";constructor(a){this.J=a}},$a=class{S={};node=null;get flags(){return this.S.flags}set flags(a){this.S.flags=a}get position(){return this.S.position}set position(a){this.S.position=a}},ab=class{F={};G={};U=null;constructor(a,b,c,d){a||=this;this.parent=a;this.N=a.N;this.id=Xa++;this.name=b;this.mode=c;this.rdev=d;this.atime=this.mtime=this.ctime=Date.now()}get read(){return 365===(this.mode&365)}set read(a){a?this.mode|=365:this.mode&=
21
+ -366}get write(){return 146===(this.mode&146)}set write(a){a?this.mode|=146:this.mode&=-147}};
22
+ function U(a,b={}){if(!a)throw new N(44);b.X??(b.X=!0);"/"===a.charAt(0)||(a="//"+a);var c=0;a:for(;40>c;c++){a=a.split("/").filter(n=>!!n);for(var d=Va,e="/",f=0;f<a.length;f++){var g=f===a.length-1;if(g&&b.parent)break;if("."!==a[f])if(".."===a[f])if(e=Ba(e),d===d.parent){a=e+"/"+a.slice(f+1).join("/");c--;continue a}else d=d.parent;else{e=Aa(e+"/"+a[f]);try{d=Sa(d,a[f])}catch(n){if(44===n?.J&&g&&b.ma)return{path:e};throw n;}!d.U||g&&!b.X||(d=d.U.root);if(40960===(d.mode&61440)&&(!g||b.W)){if(!d.F.readlink)throw new N(52);
23
+ d=d.F.readlink(d);"/"===d.charAt(0)||(d=Ba(e)+"/"+d);a=d+"/"+a.slice(f+1).join("/");continue a}}}return{path:e,node:d}}throw new N(32);}function Ta(a,b){for(var c=0,d=0;d<b.length;d++)c=(c<<5)-c+b.charCodeAt(d)|0;return(a+c>>>0)%S.length}function Sa(a,b){var c=16384===(a.mode&61440)?(c=bb(a,"x"))?c:a.F.lookup?0:2:54;if(c)throw new N(c);for(c=S[Ta(a.id,b)];c;c=c.R){var d=c.name;if(c.parent.id===a.id&&d===b)return c}return a.F.lookup(a,b)}
24
+ function Ra(a,b,c,d){a=new ab(a,b,c,d);b=Ta(a.parent.id,a.name);a.R=S[b];return S[b]=a}function bb(a,b){return Za?0:b.includes("r")&&!(a.mode&292)||b.includes("w")&&!(a.mode&146)||b.includes("x")&&!(a.mode&73)?2:0}function cb(a,b){if(16384!==(a.mode&61440))return 54;try{return Sa(a,b),20}catch(c){}return bb(a,"wx")}function V(a){a=T[a];if(!a)throw new N(8);return a}
25
+ function db(a,b=-1){a=Object.assign(new $a,a);if(-1==b)a:{for(b=0;4096>=b;b++)if(!T[b])break a;throw new N(33);}a.fd=b;return T[b]=a}function eb(a,b=-1){a=db(a,b);a.G?.va?.(a);return a}function fb(a,b){var c=null?.G.M,d=c?null:a;c??=a.F.M;if(!c)throw new N(63);c(d,b)}var Qa={open(a){a.G=Wa[a.node.rdev].G;a.G.open?.(a)},K(){throw new N(70);}};function Ma(a,b){Wa[a]={G:b}}
26
+ function gb(a,b){var c="/"===b;if(c&&Va)throw new N(10);if(!c&&b){var d=U(b,{X:!1});b=d.path;d=d.node;if(d.U)throw new N(10);if(16384!==(d.mode&61440))throw new N(54);}b={type:a,wa:{},ea:b,la:[]};a=a.N(b);a.N=b;b.root=a;c?Va=a:d&&(d.U=b,d.N&&d.N.la.push(b))}function hb(a,b,c){var d=U(a,{parent:!0}).node;a=a&&a.match(/([^\/]+|\/)\/*$/)[1];if(!a)throw new N(28);if("."===a||".."===a)throw new N(20);var e=cb(d,a);if(e)throw new N(e);if(!d.F.T)throw new N(63);return d.F.T(d,a,b,c)}
27
+ function W(a){return hb(a,16895,0)}function ib(a,b,c){"undefined"==typeof c&&(c=b,b=438);hb(a,b|8192,c)}function jb(a,b){if(!Fa(a))throw new N(44);var c=U(b,{parent:!0}).node;if(!c)throw new N(44);b=b&&b.match(/([^\/]+|\/)\/*$/)[1];var d=cb(c,b);if(d)throw new N(d);if(!c.F.symlink)throw new N(63);c.F.symlink(c,b,a)}
28
+ function kb(a,b,c=438){if(""===a)throw new N(44);if("string"==typeof b){var d={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[b];if("undefined"==typeof d)throw Error(`Unknown file open mode: ${b}`);b=d}c=b&64?c&4095|32768:0;if("object"==typeof a)d=a;else{var e=a.endsWith("/");var f=U(a,{W:!(b&131072),ma:!0});d=f.node;a=f.path}f=!1;if(b&64)if(d){if(b&128)throw new N(20);}else{if(e)throw new N(31);d=hb(a,c|511,0);f=!0}if(!d)throw new N(44);8192===(d.mode&61440)&&(b&=-513);if(b&65536&&16384!==(d.mode&61440))throw new N(54);
29
+ if(!f&&(d?40960===(d.mode&61440)?e=32:(e=["r","w","rw"][b&3],b&512&&(e+="w"),e=16384===(d.mode&61440)&&("r"!==e||b&576)?31:bb(d,e)):e=44,e))throw new N(e);if(b&512&&!f){e=d;e="string"==typeof e?U(e,{W:!0}).node:e;if(16384===(e.mode&61440))throw new N(31);if(32768!==(e.mode&61440))throw new N(28);if(a=bb(e,"w"))throw new N(a);fb(e,{size:0,timestamp:Date.now()})}a:for(e=d;;){if(e===e.parent){e=e.N.ea;var g=g?"/"!==e[e.length-1]?`${e}/${g}`:e+g:e;break a}g=g?`${e.name}/${g}`:e.name;e=e.parent}b=db({node:d,
30
+ path:g,flags:b&-131713,seekable:!0,position:0,G:d.G,na:[],error:!1});b.G.open&&b.G.open(b);f&&(c&=511,d="string"==typeof d?U(d,{W:!0}).node:d,fb(d,{mode:c&4095|d.mode&-4096,ctime:Date.now(),ua:void 0}));return b}function lb(a,b,c){if(null===a.fd)throw new N(8);if(!a.seekable||!a.G.K)throw new N(70);if(0!=c&&1!=c&&2!=c)throw new N(28);a.position=a.G.K(a,b,c);a.na=[]}
31
+ function X(a,b,c){a=Aa("/dev/"+a);var d=Ua(!!b,!!c);X.ba??(X.ba=64);var e=X.ba++<<8|0;Ma(e,{open(f){f.seekable=!1},close(){c?.buffer?.length&&c(10)},read(f,g,n,p){for(var l=0,q=0;q<p;q++){try{var u=b()}catch(v){throw new N(29);}if(void 0===u&&0===l)throw new N(6);if(null===u||void 0===u)break;l++;g[n+q]=u}l&&(f.node.atime=Date.now());return l},write(f,g,n,p){for(var l=0;l<p;l++)try{c(g[n+l])}catch(q){throw new N(29);}p&&(f.node.mtime=f.node.ctime=Date.now());return l}});ib(a,d,e)}
32
+ var Y={},mb=a=>a?Ga.decode(E.subarray(a,Ha(E,a))):"";function nb(a,b){if("/"===b.charAt(0))return b;a=-100===a?"/":V(a).path;if(0==b.length)throw new N(44);return a+"/"+b}
33
+ var J=void 0,ob=0,Z={},pb=a=>{a instanceof ua||"unwind"==a||da(1,a)},qb=a=>{A=a;I||0<ob||(h.onExit?.(a),y=!0);da(a,new ua(a))},rb=a=>{if(!y)try{a()}catch(b){pb(b)}finally{if(!(I||0<ob))try{A=a=A,qb(a)}catch(b){pb(b)}}},sb={},ub=()=>{if(!tb){var a={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:m||"./this.program"},b;for(b in sb)void 0===sb[b]?delete a[b]:a[b]=sb[b];var c=[];for(b in a)c.push(`${b}=${a[b]}`);
34
+ tb=c}return tb},tb,wb=a=>{var b=L(a)+1,c=vb(b);M(a,E,c,b);return c};S=Array(4096);gb(R,"/");W("/tmp");W("/home");W("/home/web_user");(function(){W("/dev");Ma(259,{read:()=>0,write:(d,e,f,g)=>g,K:()=>0});ib("/dev/null",259);La(1280,Oa);La(1536,Pa);ib("/dev/tty",1280);ib("/dev/tty1",1536);var a=new Uint8Array(1024),b=0,c=()=>{0===b&&(Da(a),b=a.byteLength);return a[--b]};X("random",c);X("urandom",c);W("/dev/shm");W("/dev/shm/tmp")})();
35
+ (function(){W("/proc");var a=W("/proc/self");W("/proc/self/fd");gb({N(){var b=Ra(a,"fd",16895,73);b.G={K:R.G.K};b.F={lookup(c,d){c=+d;var e=V(c);c={parent:null,N:{ea:"fake"},F:{readlink:()=>e.path},id:c+1};return c.parent=c},readdir(){return Array.from(T.entries()).filter(([,c])=>c).map(([c])=>c.toString())}};return b}},"/proc/self/fd")})();h.noExitRuntime&&(I=h.noExitRuntime);h.print&&(ia=h.print);h.printErr&&(w=h.printErr);h.wasmBinary&&(x=h.wasmBinary);h.arguments&&(ca=h.arguments);
36
+ h.thisProgram&&(m=h.thisProgram);if(h.preInit)for("function"==typeof h.preInit&&(h.preInit=[h.preInit]);0<h.preInit.length;)h.preInit.shift()();h.ccall=(a,b,c,d)=>{var e={string:l=>{var q=0;null!==l&&void 0!==l&&0!==l&&(q=wb(l));return q},array:l=>{var q=vb(l.length);C.set(l,q);return q}};a=h["_"+a];var f=[],g=0;if(d)for(var n=0;n<d.length;n++){var p=e[c[n]];p?(0===g&&(g=xb()),f[n]=p(d[n])):f[n]=d[n]}c=a(...f);return c=function(l){0!==g&&yb(g);return"string"===b?mb(l):"boolean"===b?!!l:l}(c)};
37
+ var zb,Ab,pa,yb,vb,xb,B,Bb={d:function(a,b,c){J=c;try{var d=V(a);switch(b){case 0:var e=K();if(0>e)break;for(;T[e];)e++;return eb(d,e).fd;case 1:case 2:return 0;case 3:return d.flags;case 4:return e=K(),d.flags|=e,0;case 12:return e=K(),D[e+0>>1]=2,0;case 13:case 14:return 0}return-28}catch(f){if("undefined"==typeof Y||"ErrnoError"!==f.name)throw f;return-f.J}},n:function(a,b){try{if(0===b)return-28;var c=L("/")+1;if(b<c)return-68;M("/",E,a,b);return c}catch(d){if("undefined"==typeof Y||"ErrnoError"!==
38
+ d.name)throw d;return-d.J}},s:function(a,b,c){J=c;try{var d=V(a);switch(b){case 21509:return d.tty?0:-59;case 21505:if(!d.tty)return-59;if(d.tty.O.ia){a=[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];var e=K();F[e>>2]=25856;F[e+4>>2]=5;F[e+8>>2]=191;F[e+12>>2]=35387;for(var f=0;32>f;f++)C[e+f+17]=a[f]||0}return 0;case 21510:case 21511:case 21512:return d.tty?0:-59;case 21506:case 21507:case 21508:if(!d.tty)return-59;if(d.tty.O.ja)for(e=K(),a=[],f=0;32>f;f++)a.push(C[e+
39
+ f+17]);return 0;case 21519:if(!d.tty)return-59;e=K();return F[e>>2]=0;case 21520:return d.tty?-28:-59;case 21537:case 21531:e=K();if(!d.G.ha)throw new N(59);return d.G.ha(d,b,e);case 21523:if(!d.tty)return-59;d.tty.O.ka&&(f=[24,80],e=K(),D[e>>1]=f[0],D[e+2>>1]=f[1]);return 0;case 21524:return d.tty?0:-59;case 21515:return d.tty?0:-59;default:return-28}}catch(g){if("undefined"==typeof Y||"ErrnoError"!==g.name)throw g;return-g.J}},e:function(a,b,c,d){J=d;try{b=mb(b);b=nb(a,b);var e=d?K():0;return kb(b,
40
+ c,e).fd}catch(f){if("undefined"==typeof Y||"ErrnoError"!==f.name)throw f;return-f.J}},o:function(a,b,c,d){try{b=mb(b);b=nb(a,b);if(0>=d)return-28;var e=U(b).node;if(!e)throw new N(44);if(!e.F.readlink)throw new N(28);var f=e.F.readlink(e);var g=Math.min(d,L(f)),n=C[c+g];M(f,E,c,d+1);C[c+g]=n;return g}catch(p){if("undefined"==typeof Y||"ErrnoError"!==p.name)throw p;return-p.J}},j:()=>oa(""),i:()=>{I=!1;ob=0},m:(a,b)=>{Z[a]&&(clearTimeout(Z[a].id),delete Z[a]);if(!b)return 0;var c=setTimeout(()=>{delete Z[a];
41
+ rb(()=>Ab(a,performance.now()))},b);Z[a]={id:c,ya:b};return 0},f:function(a,b,c){if(!(0<=a&&3>=a))return 28;na[c>>3]=BigInt(Math.round(1E6*(0===a?Date.now():performance.now())));return 0},g:a=>{var b=E.length;a>>>=0;if(2147483648<a)return!1;for(var c=1;4>=c;c*=2){var d=b*(1+.2/c);d=Math.min(d,a+100663296);a:{d=(Math.min(2147483648,65536*Math.ceil(Math.max(a,d)/65536))-B.buffer.byteLength+65535)/65536|0;try{B.grow(d);ma();var e=1;break a}catch(f){}e=void 0}if(e)return!0}return!1},k:(a,b)=>{var c=0,
42
+ d=0,e;for(e of ub()){var f=b+c;G[a+d>>2]=f;c+=M(e,E,f,Infinity)+1;d+=4}return 0},l:(a,b)=>{var c=ub();G[a>>2]=c.length;a=0;for(var d of c)a+=L(d)+1;G[b>>2]=a;return 0},c:function(a){try{var b=V(a);if(null===b.fd)throw new N(8);b.Y&&(b.Y=null);try{b.G.close&&b.G.close(b)}catch(c){throw c;}finally{T[b.fd]=null}b.fd=null;return 0}catch(c){if("undefined"==typeof Y||"ErrnoError"!==c.name)throw c;return c.J}},r:function(a,b,c,d){try{a:{var e=V(a);a=b;for(var f,g=b=0;g<c;g++){var n=G[a>>2],p=G[a+4>>2];a+=
43
+ 8;var l=e,q=n,u=p,v=f,Ea=C;if(0>u||0>v)throw new N(28);if(null===l.fd)throw new N(8);if(1===(l.flags&2097155))throw new N(8);if(16384===(l.node.mode&61440))throw new N(31);if(!l.G.read)throw new N(28);var O="undefined"!=typeof v;if(!O)v=l.position;else if(!l.seekable)throw new N(70);var P=l.G.read(l,Ea,q,u,v);O||(l.position+=P);var z=P;if(0>z){var Q=-1;break a}b+=z;if(z<p)break;"undefined"!=typeof f&&(f+=z)}Q=b}G[d>>2]=Q;return 0}catch(H){if("undefined"==typeof Y||"ErrnoError"!==H.name)throw H;return H.J}},
44
+ p:function(a,b,c,d){b=-9007199254740992>b||9007199254740992<b?NaN:Number(b);try{if(isNaN(b))return 61;var e=V(a);lb(e,b,c);na[d>>3]=BigInt(e.position);e.Y&&0===b&&0===c&&(e.Y=null);return 0}catch(f){if("undefined"==typeof Y||"ErrnoError"!==f.name)throw f;return f.J}},q:function(a,b,c,d){try{a:{var e=V(a);a=b;for(var f,g=b=0;g<c;g++){var n=G[a>>2],p=G[a+4>>2];a+=8;var l=e,q=n,u=p,v=f,Ea=C;if(0>u||0>v)throw new N(28);if(null===l.fd)throw new N(8);if(0===(l.flags&2097155))throw new N(8);if(16384===(l.node.mode&
45
+ 61440))throw new N(31);if(!l.G.write)throw new N(28);l.seekable&&l.flags&1024&&lb(l,0,2);var O="undefined"!=typeof v;if(!O)v=l.position;else if(!l.seekable)throw new N(70);var P=l.G.write(l,Ea,q,u,v,void 0);O||(l.position+=P);var z=P;if(0>z){var Q=-1;break a}b+=z;if(z<p)break;"undefined"!=typeof f&&(f+=z)}Q=b}G[d>>2]=Q;return 0}catch(H){if("undefined"==typeof Y||"ErrnoError"!==H.name)throw H;return H.J}},b:function(a){"function"===typeof postMessage&&postMessage({nh:"error",message:mb(a)})},a:function(a,
46
+ b,c){"function"===typeof postMessage&&postMessage({nh:"progress",phase:a,processed:b,total:c})},h:qb};function Cb(a=[]){var b=zb;a.unshift(m);var c=a.length,d=vb(4*(c+1)),e=d,f;for(f of a)G[e>>2]=wb(f),e+=4;G[e>>2]=0;try{var g=b(c,d);A=g;qb(g)}catch(n){pb(n)}}var Db;
47
+ Db=await (async function(){function a(c){c=Db=c.exports;h._nh_compute_build=c.v;h._malloc=c.w;zb=h._main=c.x;h._free=c.y;Ab=c.z;pa=c.A;yb=c.B;vb=c.C;xb=c.D;B=c.t;ma();return Db}var b={a:Bb};if(h.instantiateWasm)return new Promise(c=>{h.instantiateWasm(b,(d,e)=>{c(a(d,e))})});qa??=h.locateFile?h.locateFile("nodehammer-compute.wasm",r):r+"nodehammer-compute.wasm";return a((await ta(b)).instance)}());
48
+ (function(a=ca){function b(){h.calledRun=!0;if(!y){la=!0;if(!h.noFSInit&&!Ya){var c,d;Ya=!0;c??=h.stdin;d??=h.stdout;e??=h.stderr;c?X("stdin",c):jb("/dev/tty","/dev/stdin");d?X("stdout",null,d):jb("/dev/tty","/dev/stdout");e?X("stderr",null,e):jb("/dev/tty1","/dev/stderr");kb("/dev/stdin",0);kb("/dev/stdout",1);kb("/dev/stderr",1)}Db.u();Za=!1;ja?.(h);h.onRuntimeInitialized?.();h.noInitialRun||Cb(a);if(h.postRun)for("function"==typeof h.postRun&&(h.postRun=[h.postRun]);h.postRun.length;){var e=h.postRun.shift();
49
+ wa.push(e)}va(wa)}}if(h.preRun)for("function"==typeof h.preRun&&(h.preRun=[h.preRun]);h.preRun.length;)ya();va(xa);h.setStatus?(h.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>h.setStatus(""),1);b()},1)):b()})();la?moduleRtn=h:moduleRtn=new Promise((a,b)=>{ja=a;ka=b});
50
+ ;return moduleRtn}if(typeof exports==="object"&&typeof module==="object"){module.exports=NodehammerCompute;module.exports.default=NodehammerCompute}else if(typeof define==="function"&&define["amd"])define([],()=>NodehammerCompute);