#if STRICT_JS
"use strict";
#endif
#if MODULARIZE
#if MODULARIZE == 'instance'
var Module = {};
#else
var Module = moduleArg;
#endif
#elif USE_CLOSURE_COMPILER
var Module;
if (!Module) Module = {"__EMSCRIPTEN_PRIVATE_MODULE_EXPORT_NAME_SUBSTITUTION__":1};
#elif AUDIO_WORKLET
var Module = globalThis.Module || (typeof {{{ EXPORT_NAME }}} != 'undefined' ? {{{ EXPORT_NAME }}} : {});
#else
var Module = typeof {{{ EXPORT_NAME }}} != 'undefined' ? {{{ EXPORT_NAME }}} : {};
#endif
#if POLYFILL
#if WASM_BIGINT && MIN_SAFARI_VERSION < 150000
#include "polyfill/bigint64array.js"
#endif
#endif
#if WASM_WORKERS
var ENVIRONMENT_IS_WASM_WORKER = globalThis.name == 'em-ww';
#endif
#if AUDIO_WORKLET
var ENVIRONMENT_IS_AUDIO_WORKLET = typeof AudioWorkletGlobalScope !== 'undefined';
if (ENVIRONMENT_IS_AUDIO_WORKLET) ENVIRONMENT_IS_WASM_WORKER = true;
#endif
#if ENVIRONMENT.length == 1
var ENVIRONMENT_IS_WEB = {{{ ENVIRONMENT[0] === 'web' }}};
#if PTHREADS && ENVIRONMENT_MAY_BE_NODE
var ENVIRONMENT_IS_WORKER = typeof WorkerGlobalScope != 'undefined';
#else
var ENVIRONMENT_IS_WORKER = {{{ ENVIRONMENT[0] === 'worker' }}};
#endif
var ENVIRONMENT_IS_NODE = {{{ ENVIRONMENT[0] === 'node' }}};
var ENVIRONMENT_IS_SHELL = {{{ ENVIRONMENT[0] === 'shell' }}};
#else
var ENVIRONMENT_IS_WEB = typeof window == 'object';
var ENVIRONMENT_IS_WORKER = typeof WorkerGlobalScope != 'undefined';
var ENVIRONMENT_IS_NODE = {{{ nodeDetectionCode() }}};
#if AUDIO_WORKLET
var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER && !ENVIRONMENT_IS_AUDIO_WORKLET;
#else
var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
#endif
#endif
#if PTHREADS
var ENVIRONMENT_IS_PTHREAD = ENVIRONMENT_IS_WORKER && self.name?.startsWith('em-pthread');
#if MODULARIZE && ASSERTIONS
if (ENVIRONMENT_IS_PTHREAD) {
assert(!globalThis.moduleLoaded, 'module should only be loaded once on each pthread worker');
globalThis.moduleLoaded = true;
}
#endif
#endif
#if ENVIRONMENT_MAY_BE_NODE && (EXPORT_ES6 || PTHREADS || WASM_WORKERS)
if (ENVIRONMENT_IS_NODE) {
#if EXPORT_ES6
const { createRequire } = await import('module');
var require = createRequire(import.meta.url);
#endif
#if PTHREADS || WASM_WORKERS
var worker_threads = require('worker_threads');
global.Worker = worker_threads.Worker;
ENVIRONMENT_IS_WORKER = !worker_threads.isMainThread;
#if PTHREADS
ENVIRONMENT_IS_PTHREAD = ENVIRONMENT_IS_WORKER && worker_threads['workerData'] == 'em-pthread'
#endif
#if WASM_WORKERS
ENVIRONMENT_IS_WASM_WORKER = ENVIRONMENT_IS_WORKER && worker_threads['workerData'] == 'em-ww'
#endif
#endif
}
#endif
{{{ preJS() }}}
var arguments_ = [];
var thisProgram = './this.program';
var quit_ = (status, toThrow) => {
throw toThrow;
};
#if EXPORT_ES6
var _scriptName = import.meta.url;
#else
#if ENVIRONMENT_MAY_BE_WEB
#if !MODULARIZE
#if SINGLE_FILE && OUTPUT_FORMAT == 'HTML'
var _scriptName = typeof document != 'undefined' ? URL.createObjectURL(new Blob([document.getElementById('mainScript').textContent], { "type" : "text/javascript" })) : undefined;
#else
var _scriptName = typeof document != 'undefined' ? document.currentScript?.src : undefined;
#endif
#endif
#elif ENVIRONMENT_MAY_BE_NODE || ENVIRONMENT_MAY_BE_WORKER
var _scriptName;
#endif
#if ENVIRONMENT_MAY_BE_NODE
if (typeof __filename != 'undefined') {
_scriptName = __filename;
} else
#endif
#if ENVIRONMENT_MAY_BE_WORKER
if (ENVIRONMENT_IS_WORKER) {
_scriptName = self.location.href;
}
#elif ENVIRONMENT_MAY_BE_NODE
{}
#endif
#endif
var scriptDirectory = '';
function locateFile(path) {
#if RUNTIME_DEBUG
dbg('locateFile:', path, 'scriptDirectory:', scriptDirectory);
#endif
#if expectToReceiveOnModule('locateFile')
if (Module['locateFile']) {
return Module['locateFile'](path, scriptDirectory);
}
#endif
return scriptDirectory + path;
}
var readAsync, readBinary;
#if ENVIRONMENT_MAY_BE_NODE
if (ENVIRONMENT_IS_NODE) {
#if ENVIRONMENT.length && ASSERTIONS
const isNode = {{{ nodeDetectionCode() }}};
if (!isNode) throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
#endif
#if ASSERTIONS
var nodeVersion = process.versions.node;
var numericVersion = nodeVersion.split('.').slice(0, 3);
numericVersion = (numericVersion[0] * 10000) + (numericVersion[1] * 100) + (numericVersion[2].split('-')[0] * 1);
if (numericVersion < {{{ MIN_NODE_VERSION }}}) {
throw new Error('This emscripten-generated code requires node {{{ formattedMinNodeVersion() }}} (detected v' + nodeVersion + ')');
}
#endif
var fs = require('fs');
#if EXPORT_ES6
if (_scriptName.startsWith('file:')) {
scriptDirectory = require('path').dirname(require('url').fileURLToPath(_scriptName)) + '/';
}
#else
scriptDirectory = __dirname + '/';
#endif
#include "node_shell_read.js"
if (process.argv.length > 1) {
thisProgram = process.argv[1].replace(/\\/g, '/');
}
arguments_ = process.argv.slice(2);
#if !MODULARIZE
if (typeof module != 'undefined') {
module['exports'] = Module;
}
#endif
#if NODEJS_CATCH_EXIT
process.on('uncaughtException', (ex) => {
#if RUNTIME_DEBUG
dbg(`node: uncaughtException: ${ex}`)
#endif
if (ex !== 'unwind' && !(ex instanceof ExitStatus) && !(ex.context instanceof ExitStatus)) {
throw ex;
}
});
#endif
#if NODEJS_CATCH_REJECTION
var nodeMajor = process.versions.node.split(".")[0];
if (nodeMajor < 15) {
process.on('unhandledRejection', (reason) => { throw reason; });
}
#endif
quit_ = (status, toThrow) => {
process.exitCode = status;
throw toThrow;
};
#if WASM == 2
if (typeof WebAssembly == 'undefined') {
eval(fs.readFileSync(locateFile('{{{ TARGET_BASENAME }}}.wasm.js'))+'');
}
#endif
} else
#endif
#if ENVIRONMENT_MAY_BE_SHELL || ASSERTIONS
if (ENVIRONMENT_IS_SHELL) {
#if ENVIRONMENT.length && ASSERTIONS
const isNode = {{{ nodeDetectionCode() }}};
if (isNode || typeof window == 'object' || typeof WorkerGlobalScope != 'undefined') throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
#endif
#if ENVIRONMENT_MAY_BE_SHELL
readBinary = (f) => {
if (typeof readbuffer == 'function') {
return new Uint8Array(readbuffer(f));
}
let data = read(f, 'binary');
assert(typeof data == 'object');
return data;
};
readAsync = async (f) => readBinary(f);
globalThis.clearTimeout ??= (id) => {};
globalThis.setTimeout ??= (f) => f();
arguments_ = globalThis.arguments || globalThis.scriptArgs;
if (typeof quit == 'function') {
quit_ = (status, toThrow) => {
setTimeout(() => {
if (!(toThrow instanceof ExitStatus)) {
let toLog = toThrow;
if (toThrow && typeof toThrow == 'object' && toThrow.stack) {
toLog = [toThrow, toThrow.stack];
}
err(`exiting due to exception: ${toLog}`);
}
quit(status);
});
throw toThrow;
};
}
if (typeof print != 'undefined') {
globalThis.console ??= ({});
console.log = (print);
console.warn = console.error = (globalThis.printErr ?? print);
}
#if WASM == 2
if (typeof WebAssembly == 'undefined') {
eval(read(locateFile('{{{ TARGET_BASENAME }}}.wasm.js'))+'');
}
#endif
#endif
} else
#endif
#if ENVIRONMENT_MAY_BE_WEB || ENVIRONMENT_MAY_BE_WORKER
if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
try {
scriptDirectory = new URL('.', _scriptName).href;
} catch {
}
#if ENVIRONMENT.length && ASSERTIONS
if (!(typeof window == 'object' || typeof WorkerGlobalScope != 'undefined')) throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
#endif
#if PTHREADS && ENVIRONMENT_MAY_BE_NODE
if (!ENVIRONMENT_IS_NODE)
#endif
{
#include "web_or_worker_shell_read.js"
}
} else
#endif
#if AUDIO_WORKLET && ASSERTIONS
if (!ENVIRONMENT_IS_AUDIO_WORKLET)
#endif
{
#if ASSERTIONS
throw new Error('environment detection error');
#endif
}
#if ENVIRONMENT_MAY_BE_NODE && (PTHREADS || WASM_WORKERS)
var defaultPrint = console.log.bind(console);
var defaultPrintErr = console.error.bind(console);
if (ENVIRONMENT_IS_NODE) {
var utils = require('util');
var stringify = (a) => typeof a == 'object' ? utils.inspect(a) : a;
defaultPrint = (...args) => fs.writeSync(1, args.map(stringify).join(' ') + '\n');
defaultPrintErr = (...args) => fs.writeSync(2, args.map(stringify).join(' ') + '\n');
}
{{{ makeModuleReceiveWithVar('out', 'print', 'defaultPrint') }}}
{{{ makeModuleReceiveWithVar('err', 'printErr', 'defaultPrintErr') }}}
#else
{{{ makeModuleReceiveWithVar('out', 'print', 'console.log.bind(console)') }}}
{{{ makeModuleReceiveWithVar('err', 'printErr', 'console.error.bind(console)') }}}
#endif
#if ASSERTIONS
{{{ makeRemovedFSAssert('IDBFS') }}}
{{{ makeRemovedFSAssert('PROXYFS') }}}
{{{ makeRemovedFSAssert('WORKERFS') }}}
{{{ makeRemovedFSAssert('FETCHFS') }}}
{{{ makeRemovedFSAssert('ICASEFS') }}}
{{{ makeRemovedFSAssert('JSFILEFS') }}}
{{{ makeRemovedFSAssert('OPFS') }}}
#if !NODERAWFS
{{{ makeRemovedFSAssert('NODEFS') }}}
#endif
#if PTHREADS
assert(
#if AUDIO_WORKLET
ENVIRONMENT_IS_AUDIO_WORKLET ||
#endif
ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER || ENVIRONMENT_IS_NODE, 'Pthreads do not work in this environment yet (need Web Workers, or an alternative to them)');
#else
#endif
#if !ENVIRONMENT_MAY_BE_WEB
assert(!ENVIRONMENT_IS_WEB, 'web environment detected but not enabled at build time. Add `web` to `-sENVIRONMENT` to enable.');
#endif
#if !ENVIRONMENT_MAY_BE_WORKER
assert(!ENVIRONMENT_IS_WORKER, 'worker environment detected but not enabled at build time. Add `worker` to `-sENVIRONMENT` to enable.');
#endif
#if !ENVIRONMENT_MAY_BE_NODE
assert(!ENVIRONMENT_IS_NODE, 'node environment detected but not enabled at build time. Add `node` to `-sENVIRONMENT` to enable.');
#endif
#if !ENVIRONMENT_MAY_BE_SHELL
assert(!ENVIRONMENT_IS_SHELL, 'shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable.');
#endif
#endif