@rive-app/webgl2
Version:
Rive's webgl2 based web api.
1,652 lines (1,634 loc) • 342 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["rive"] = factory();
else
root["rive"] = factory();
})(this, () => {
return /******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ([
/* 0 */,
/* 1 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ Animation: () => (/* reexport safe */ _Animation__WEBPACK_IMPORTED_MODULE_0__.Animation)
/* harmony export */ });
/* harmony import */ var _Animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
/***/ }),
/* 2 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ Animation: () => (/* binding */ Animation)
/* harmony export */ });
/**
* Represents an animation that can be played on an Artboard.
* Wraps animations and instances from the runtime and keeps track of playback state.
*
* The `Animation` class manages the state and behavior of a single animation instance,
* including its current time, loop count, and ability to scrub to a specific time.
*
* The class provides methods to advance the animation, apply its interpolated keyframe
* values to the Artboard, and clean up the underlying animation instance when the
* animation is no longer needed.
*/
var Animation = /** @class */ (function () {
/**
* Constructs a new animation
* @constructor
* @param {any} animation: runtime animation object
* @param {any} instance: runtime animation instance object
*/
function Animation(animation, artboard, runtime, playing) {
this.animation = animation;
this.artboard = artboard;
this.playing = playing;
this.loopCount = 0;
/**
* The time to which the animation should move to on the next render.
* If not null, the animation will scrub to this time instead of advancing by the given time.
*/
this.scrubTo = null;
this.instance = new runtime.LinearAnimationInstance(animation, artboard);
}
Object.defineProperty(Animation.prototype, "name", {
/**
* Returns the animation's name
*/
get: function () {
return this.animation.name;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Animation.prototype, "time", {
/**
* Returns the animation's name
*/
get: function () {
return this.instance.time;
},
/**
* Sets the animation's current time
*/
set: function (value) {
this.instance.time = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Animation.prototype, "loopValue", {
/**
* Returns the animation's loop type
*/
get: function () {
return this.animation.loopValue;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Animation.prototype, "needsScrub", {
/**
* Indicates whether the animation needs to be scrubbed.
* @returns `true` if the animation needs to be scrubbed, `false` otherwise.
*/
get: function () {
return this.scrubTo !== null;
},
enumerable: false,
configurable: true
});
/**
* Advances the animation by the give time. If the animation needs scrubbing,
* time is ignored and the stored scrub value is used.
* @param time the time to advance the animation by if no scrubbing required
*/
Animation.prototype.advance = function (time) {
if (this.scrubTo === null) {
this.instance.advance(time);
}
else {
this.instance.time = 0;
this.instance.advance(this.scrubTo);
this.scrubTo = null;
}
};
/**
* Apply interpolated keyframe values to the artboard. This should be called after calling
* .advance() on an animation instance so that new values are applied to properties.
*
* Note: This does not advance the artboard, which updates all objects on the artboard
* @param mix - Mix value for the animation from 0 to 1
*/
Animation.prototype.apply = function (mix) {
this.instance.apply(mix);
};
/**
* Deletes the backing Wasm animation instance; once this is called, this
* animation is no more.
*/
Animation.prototype.cleanup = function () {
this.instance.delete();
};
return Animation;
}());
/***/ }),
/* 3 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ RuntimeLoader: () => (/* binding */ RuntimeLoader)
/* harmony export */ });
/* harmony import */ var _rive_advanced_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
/* harmony import */ var package_json__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
var __assign = (undefined && undefined.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
// Runtime singleton; use getInstance to provide a callback that returns the
// Rive runtime
var RuntimeLoader = /** @class */ (function () {
// Class is never instantiated
function RuntimeLoader() {
}
// Rejects all pending awaitInstance() promises and resets loading state so
// the next call to getInstance() / awaitInstance() can retry with a new URL.
RuntimeLoader.notifyError = function (error) {
var _a;
RuntimeLoader.isLoading = false;
while (RuntimeLoader.errorCallbackQueue.length > 0) {
(_a = RuntimeLoader.errorCallbackQueue.shift()) === null || _a === void 0 ? void 0 : _a(error);
}
RuntimeLoader.callBackQueue = [];
};
// Loads the runtime
RuntimeLoader.loadRuntime = function () {
// Capture the URL at call time so the catch closure always refers to the
// URL this particular attempt used, even if wasmURL is mutated for a retry.
var attemptedUrl = RuntimeLoader.wasmURL;
var wasmBinary = RuntimeLoader.wasmBinary;
if (RuntimeLoader.enablePerfMarks)
performance.mark('rive:wasm-init:start');
_rive_advanced_mjs__WEBPACK_IMPORTED_MODULE_0__["default"](__assign({
// Loads Wasm bundle
locateFile: function () { return attemptedUrl; } }, (wasmBinary ? { wasmBinary: wasmBinary } : {})))
.then(function (rive) {
var _a;
if (RuntimeLoader.enablePerfMarks) {
performance.mark('rive:wasm-init:end');
performance.measure('rive:wasm-init', 'rive:wasm-init:start', 'rive:wasm-init:end');
}
RuntimeLoader.runtime = rive;
RuntimeLoader.errorCallbackQueue = [];
// Fire all the callbacks
while (RuntimeLoader.callBackQueue.length > 0) {
(_a = RuntimeLoader.callBackQueue.shift()) === null || _a === void 0 ? void 0 : _a(RuntimeLoader.runtime);
}
})
.catch(function (error) {
// Capture specific error details
var errorDetails = {
message: (error === null || error === void 0 ? void 0 : error.message) || "Unknown error",
type: (error === null || error === void 0 ? void 0 : error.name) || "Error",
// Some browsers may provide additional WebAssembly-specific details
wasmError: error instanceof WebAssembly.CompileError ||
error instanceof WebAssembly.RuntimeError,
originalError: error,
};
// Log detailed error for debugging
console.debug("Rive WASM load error details:", errorDetails);
// In case the primary URL fails, or the wasm was not supported, try the
// fallback URL (a rive_fallback.wasm compiled for older architectures).
// The fallback can be customised or disabled via setWasmFallbackUrl().
// TODO: (Gordon): preemptively test browser support and load the correct wasm file. Then use the fallback only if the primary fails.
var fallbackUrl = RuntimeLoader.wasmFallbackURL;
var alreadyOnFallback = fallbackUrl !== null &&
attemptedUrl.toLowerCase() === fallbackUrl.toLowerCase();
if (fallbackUrl !== null && !alreadyOnFallback) {
console.warn("Failed to load WASM from ".concat(attemptedUrl, " (").concat(errorDetails.message, "), trying fallback URL: ").concat(fallbackUrl));
// Clear wasmBinary so the retry actually fetches via locateFile
// instead of re-using the same (failing) in-memory binary.
RuntimeLoader.wasmBinary = null;
RuntimeLoader.setWasmUrl(fallbackUrl);
RuntimeLoader.loadRuntime();
}
else {
// When alreadyOnFallback is true, wasmURL has already been overwritten
// with the fallback URL, so we can no longer recover the original
// primary URL here. The primary URL was logged in the earlier warning.
var triedUrls = alreadyOnFallback
? "the configured WASM URL or its fallback (".concat(fallbackUrl, ")")
: attemptedUrl;
var errorMessage = [
"Could not load Rive WASM file from ".concat(triedUrls, "."),
"Possible reasons:",
"- Network connection is down",
"- WebAssembly is not supported in this environment",
"- The WASM file is corrupted or incompatible",
"\nError details:",
"- Type: ".concat(errorDetails.type),
"- Message: ".concat(errorDetails.message),
"- WebAssembly-specific error: ".concat(errorDetails.wasmError),
"\nTo resolve, you may need to:",
"1. Check your network connection",
"2. Set a new WASM source via RuntimeLoader.setWasmUrl()",
"3. Call RuntimeLoader.awaitInstance() again",
].join("\n");
console.error(errorMessage);
RuntimeLoader.notifyError(new Error(errorMessage));
}
});
};
// Provides a runtime instance via a callback
RuntimeLoader.getInstance = function (callback, onError) {
// If it's not loading, start loading runtime
if (!RuntimeLoader.isLoading) {
RuntimeLoader.isLoading = true;
RuntimeLoader.loadRuntime();
}
if (!RuntimeLoader.runtime) {
RuntimeLoader.callBackQueue.push(callback);
if (onError) {
RuntimeLoader.errorCallbackQueue.push(onError);
}
}
else {
callback(RuntimeLoader.runtime);
}
};
// Provides a runtime instance via a promise; rejects if WASM fails to load.
RuntimeLoader.awaitInstance = function () {
return new Promise(function (resolve, reject) {
return RuntimeLoader.getInstance(resolve, reject);
});
};
// Manually sets the wasm url
RuntimeLoader.setWasmUrl = function (url) {
RuntimeLoader.wasmURL = url;
};
// Gets the current wasm url
RuntimeLoader.getWasmUrl = function () {
return RuntimeLoader.wasmURL;
};
/**
* Sets the URL used as a fallback when the primary WASM URL fails to load.
* Pass `null` to disable the fallback entirely.
*
* Defaults to pulling from the jsdelivr CDN.
*/
RuntimeLoader.setWasmFallbackUrl = function (url) {
RuntimeLoader.wasmFallbackURL = url;
};
// Gets the current fallback wasm url (null means fallback is disabled)
RuntimeLoader.getWasmFallbackUrl = function () {
return RuntimeLoader.wasmFallbackURL;
};
// Manually sets the wasm binary or clears it with null
RuntimeLoader.setWasmBinary = function (value) {
if ((value instanceof ArrayBuffer) || value === null) {
RuntimeLoader.wasmBinary = value;
return;
}
console.error("setWasmBinary expects an ArrayBuffer or null");
};
// Gets the current wasm build as ArrayBuffer or null
RuntimeLoader.getWasmBinary = function () {
return RuntimeLoader.wasmBinary;
};
// Flag to indicate that loading has started/completed
RuntimeLoader.isLoading = false;
// List of callbacks for the runtime that come in while loading
RuntimeLoader.callBackQueue = [];
// Path to the Wasm file; default path works for testing only;
// if embedded wasm is used then this is never used.
RuntimeLoader.wasmURL = "https://unpkg.com/".concat(package_json__WEBPACK_IMPORTED_MODULE_1__.name, "@").concat(package_json__WEBPACK_IMPORTED_MODULE_1__.version, "/rive.wasm");
// Fallback WASM URL tried when the primary URL fails. Set to null to disable
// the fallback entirely. Defaults to pulling from the jsdelivr CDN.
RuntimeLoader.wasmFallbackURL = "https://cdn.jsdelivr.net/npm/".concat(package_json__WEBPACK_IMPORTED_MODULE_1__.name, "@").concat(package_json__WEBPACK_IMPORTED_MODULE_1__.version, "/rive_fallback.wasm");
RuntimeLoader.wasmBinary = null;
// Error callbacks enqueued from .getInstance()
RuntimeLoader.errorCallbackQueue = [];
/**
* When true, performance.mark / performance.measure entries are emitted for
* WASM initialization.
*/
RuntimeLoader.enablePerfMarks = false;
return RuntimeLoader;
}());
/***/ }),
/* 4 */
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
var Rive = (() => {
var _scriptName = typeof document != 'undefined' ? document.currentScript?.src : undefined;
return (
function(moduleArg = {}) {
var moduleRtn;
var k = moduleArg, aa, ba, ca = new Promise((a, b) => {
aa = a;
ba = b;
}), da = "object" == typeof window, ea = "function" == typeof importScripts;
function fa() {
function a(g) {
const h = d;
c = b = 0;
d = new Map();
h.forEach(m => {
try {
m(g);
} catch (l) {
console.error(l);
}
});
this.fb();
e && e.Eb();
}
let b = 0, c = 0, d = new Map(), e = null, f = null;
this.requestAnimationFrame = function(g) {
b ||= requestAnimationFrame(a.bind(this));
const h = ++c;
d.set(h, g);
return h;
};
this.cancelAnimationFrame = function(g) {
d.delete(g);
b && 0 == d.size && (cancelAnimationFrame(b), b = 0);
};
this.Cb = function(g) {
f && (document.body.remove(f), f = null);
g || (f = document.createElement("div"), f.style.backgroundColor = "black", f.style.position = "fixed", f.style.right = 0, f.style.top = 0, f.style.color = "white", f.style.padding = "4px", f.innerHTML = "RIVE FPS", g = function(h) {
f.innerHTML = "RIVE FPS " + h.toFixed(1);
}, document.body.appendChild(f));
e = new function() {
let h = 0, m = 0;
this.Eb = function() {
var l = performance.now();
m ? (++h, l -= m, 1000 < l && (g(1000 * h / l), h = m = 0)) : (m = l, h = 0);
};
}();
};
this.fb = function() {
};
}
function ha() {
console.assert(!0);
const a = new Map();
let b = -Infinity;
this.push = function(c) {
c = c + 255 >> 8;
a.has(c) && clearTimeout(a.get(c));
a.set(c, setTimeout(function() {
a.delete(c);
0 == a.length ? b = -Infinity : c == b && (b = Math.max(...a.keys()), console.assert(b < c));
}, 1000));
b = Math.max(c, b);
return b << 8;
};
}
const ia = k.onRuntimeInitialized;
k.onRuntimeInitialized = function() {
ia && ia();
let a = k.decodeAudio;
k.decodeAudio = function(f, g) {
f = a(f);
g(f);
};
let b = k.decodeFont;
k.decodeFont = function(f, g) {
f = b(f);
g(f);
};
let c = k.setFallbackFontCb;
k.setFallbackFontCallback = "function" === typeof c ? function(f) {
c(f);
} : function() {
console.warn("Module.setFallbackFontCallback called, but text support is not enabled in this build.");
};
const d = k.FileAssetLoader;
k.ptrToAsset = f => {
let g = k.ptrToFileAsset(f);
return g.isImage ? k.ptrToImageAsset(f) : g.isFont ? k.ptrToFontAsset(f) : g.isAudio ? k.ptrToAudioAsset(f) : g;
};
k.CustomFileAssetLoader = d.extend("CustomFileAssetLoader", {__construct:function({loadContents:f}) {
this.__parent.__construct.call(this);
this.sb = f;
}, loadContents:function(f, g) {
f = k.ptrToAsset(f);
return this.sb(f, g);
},});
k.CDNFileAssetLoader = d.extend("CDNFileAssetLoader", {__construct:function() {
this.__parent.__construct.call(this);
}, loadContents:function(f) {
let g = k.ptrToAsset(f);
f = g.cdnUuid;
if ("" === f) {
return !1;
}
(function(h, m) {
var l = new XMLHttpRequest();
l.responseType = "arraybuffer";
l.onreadystatechange = function() {
4 == l.readyState && 200 == l.status && m(l);
};
l.open("GET", h, !0);
l.send(null);
})(g.cdnBaseUrl + "/" + f, h => {
g.decode(new Uint8Array(h.response));
});
return !0;
},});
k.FallbackFileAssetLoader = d.extend("FallbackFileAssetLoader", {__construct:function() {
this.__parent.__construct.call(this);
this.ab = [];
}, addLoader:function(f) {
this.ab.push(f);
}, loadContents:function(f, g) {
for (let h of this.ab) {
if (h.loadContents(f, g)) {
return !0;
}
}
return !1;
},});
let e = k.computeAlignment;
k.computeAlignment = function(f, g, h, m, l = 1.0) {
return e.call(this, f, g, h, m, l);
};
};
const ja = k.onRuntimeInitialized;
k.onRuntimeInitialized = function() {
function a(q) {
this.D = q;
this.rb = q.getContext("2d");
this.Sa = d;
this.O = [];
this.ga = 0;
this.clear = function() {
console.assert(0 == this.ga);
this.O = [];
e.delete(this);
};
this.save = function() {
++this.ga;
this.O.push(d.save.bind(d));
};
this.restore = function() {
0 < this.ga && (this.O.push(d.restore.bind(d)), --this.ga);
};
this.transform = function(t) {
this.O.push(d.transform.bind(d, t));
};
this.align = function(t, y, z, B, G = 1.0) {
this.O.push(d.align.bind(d, t, y, z, B, G));
};
this.flush = function() {
console.assert(0 == this.ga);
e.add(this);
d.Ra || c();
};
this.bindContext = function() {
const t = this.Sa;
t && t.W && ka(t.W);
};
this["delete"] = function() {
};
}
function b(q, t = !1) {
var y = {alpha:!0, depth:t, stencil:t, antialias:t, premultipliedAlpha:!0, preserveDrawingBuffer:0, powerPreference:"high-performance", failIfMajorPerformanceCaveat:0, enableExtensionsByDefault:!1, explicitSwapControl:0, renderViaOffscreenBackBuffer:0,};
t = q.getContext("webgl2", y);
if (!t) {
return null;
}
y = la(t, y);
ka(y);
const z = f(q.width, q.height);
z.W = y;
z.D = q;
z.Ia = q.width;
z.Ha = q.height;
z.P = t;
z.wb = function() {
this.W && ka(this.W);
};
var B = z.delete;
z.delete = function() {
this.wb();
B.call(this);
var G = this.W;
p === v[G] && (p = null);
"object" == typeof JSEvents && JSEvents.Gc(v[G].C.canvas);
v[G] && v[G].C.canvas && (v[G].C.canvas.qb = void 0);
this.W = this.D = this.Ia = this.Ha = this.P = v[G] = null;
};
return z;
}
function c() {
if (d) {
var q = d.ub, t = 0, y = 0, z = 0, B = Array(e.size), G = 0;
for (var I of e) {
I.ca = Math.min(I.D.width, q), I.ba = Math.min(I.D.height, q), I.Fa = I.ba * I.ca, t = Math.max(t, I.ca), y = Math.max(y, I.ba), z += I.Fa, B[G++] = I;
}
e.clear();
if (!(0 >= z)) {
t = 1 << (0 >= t ? 0 : 32 - Math.clz32(t - 1));
for (y = 1 << (0 >= y ? 0 : 32 - Math.clz32(y - 1)); y * t < z;) {
t <= y ? t *= 2 : y *= 2;
}
t = Math.min(t, q);
t = Math.min(y, q);
B.sort((Y, nb) => nb.Fa - Y.Fa);
z = new k.DynamicRectanizer(q);
for (I = 0; I < B.length;) {
z.reset(t, y);
for (G = I; G < B.length; ++G) {
var J = B[G], H = z.addRect(J.ca, J.ba);
if (0 > H) {
console.assert(G > I);
break;
}
J.ma = H & 65535;
J.na = H >> 16;
}
J = m.push(z.drawWidth());
H = l.push(z.drawHeight());
console.assert(J >= z.drawWidth());
console.assert(H >= z.drawHeight());
console.assert(J <= q);
console.assert(H <= q);
d.D.width != J && (d.D.width = J);
d.D.height != H && (d.D.height = H);
d.clear();
for (J = I; J < G; ++J) {
H = B[J];
d.saveClipRect(H.ma, H.na, H.ma + H.ca, H.na + H.ba);
let Y = new k.Mat2D();
Y.xx = H.ca / H.D.width;
Y.yy = H.ba / H.D.height;
Y.xy = Y.yx = 0;
Y.tx = H.ma;
Y.ty = H.na;
d.transform(Y);
for (const nb of H.O) {
nb();
}
d.restoreClipRect();
H.O = [];
}
for (d.flush(); I < G; ++I) {
J = B[I], H = J.rb, H.globalCompositeOperation = "copy", H.drawImage(d.D, J.ma, J.na, J.ca, J.ba, 0, 0, J.D.width, J.D.height);
}
I = G;
}
}
}
}
ja && ja();
let d = null;
const e = new Set(), f = k.makeRenderer;
k.makeRenderer = function(q, t) {
if (!d) {
function y(z) {
var B = document.createElement("canvas");
B.width = 1;
B.height = 1;
d = b(B, z);
if (!d) {
return null;
}
d.Ra = !!d.P.getExtension("WEBGL_shader_pixel_local_storage");
d.ub = Math.min(d.P.getParameter(d.P.MAX_RENDERBUFFER_SIZE), d.P.getParameter(d.P.MAX_TEXTURE_SIZE));
d.Ga = !d.Ra;
if (z = d.P.getExtension("WEBGL_debug_renderer_info")) {
B = d.P.getParameter(z.UNMASKED_RENDERER_WEBGL), d.P.getParameter(z.UNMASKED_VENDOR_WEBGL).includes("Google") && B.includes("ANGLE Metal Renderer") && (d.Ga = !1);
}
return d;
}
d = y(!0);
if (!d) {
throw "Unable to create WebGL context, your environment may not support WebGL. Try out @rive-app/canvas as an alternative.";
}
d.Ga || (d = y(!1));
}
return t ? new a(q) : b(q, d.Ga);
};
const g = k.Artboard.prototype["delete"];
k.Artboard.prototype["delete"] = function() {
this.vb = !0;
g.call(this);
};
const h = k.Artboard.prototype.draw;
k.Artboard.prototype.draw = function(q) {
q.O ? q.O.push(() => {
this.vb || h.call(this, q.Sa);
}) : h.call(this, q);
};
const m = new ha(), l = new ha(), r = new fa();
k.requestAnimationFrame = r.requestAnimationFrame.bind(r);
k.cancelAnimationFrame = r.cancelAnimationFrame.bind(r);
k.enableFPSCounter = r.Cb.bind(r);
r.fb = c;
k.resolveAnimationFrame = c;
let u = k.load;
k.load = function(q, t, y = !0) {
const z = new k.FallbackFileAssetLoader();
void 0 !== t && z.addLoader(t);
y && (t = new k.CDNFileAssetLoader(), z.addLoader(t));
return Promise.resolve(u(q, z));
};
const w = k.WebGL2Renderer.prototype.clear;
k.WebGL2Renderer.prototype.clear = function() {
ka(this.W);
const q = this.D;
if (this.Ia != q.width || this.Ha != q.height) {
this.resize(q.width, q.height), this.Ia = q.width, this.Ha = q.height;
}
w.call(this);
};
k.decodeImage = function(q, t) {
q = k.decodeWebGL2Image(q);
t(q);
};
let n = k.Renderer.prototype.align;
k.Renderer.prototype.align = function(q, t, y, z, B = 1.0) {
n.call(this, q, t, y, z, B);
};
};
var ma = Object.assign({}, k), na = "./this.program", x = "", oa, pa;
if (da || ea) {
ea ? x = self.location.href : "undefined" != typeof document && document.currentScript && (x = document.currentScript.src), _scriptName && (x = _scriptName), x.startsWith("blob:") ? x = "" : x = x.substr(0, x.replace(/[?#].*/, "").lastIndexOf("/") + 1), ea && (pa = a => {
var b = new XMLHttpRequest();
b.open("GET", a, !1);
b.responseType = "arraybuffer";
b.send(null);
return new Uint8Array(b.response);
}), oa = (a, b, c) => {
if (qa(a)) {
var d = new XMLHttpRequest();
d.open("GET", a, !0);
d.responseType = "arraybuffer";
d.onload = () => {
200 == d.status || 0 == d.status && d.response ? b(d.response) : c();
};
d.onerror = c;
d.send(null);
} else {
fetch(a, {credentials:"same-origin"}).then(e => e.ok ? e.arrayBuffer() : Promise.reject(Error(e.status + " : " + e.url))).then(b, c);
}
};
}
var ra = k.print || console.log.bind(console), A = k.printErr || console.error.bind(console);
Object.assign(k, ma);
ma = null;
k.thisProgram && (na = k.thisProgram);
var sa;
k.wasmBinary && (sa = k.wasmBinary);
var ta, ua = !1, C, D, E, va, F, K, wa, xa;
function ya() {
var a = ta.buffer;
k.HEAP8 = C = new Int8Array(a);
k.HEAP16 = E = new Int16Array(a);
k.HEAPU8 = D = new Uint8Array(a);
k.HEAPU16 = va = new Uint16Array(a);
k.HEAP32 = F = new Int32Array(a);
k.HEAPU32 = K = new Uint32Array(a);
k.HEAPF32 = wa = new Float32Array(a);
k.HEAPF64 = xa = new Float64Array(a);
}
var za = [], Aa = [], Ba = [];
function Ca() {
var a = k.preRun.shift();
za.unshift(a);
}
var Da = 0, Ea = null, Fa = null;
function Ga(a) {
k.onAbort?.(a);
a = "Aborted(" + a + ")";
A(a);
ua = !0;
a = new WebAssembly.RuntimeError(a + ". Build with -sASSERTIONS for more info.");
ba(a);
throw a;
}
var Ha = a => a.startsWith("data:application/octet-stream;base64,"), qa = a => a.startsWith("file://"), Ia;
function Ja(a) {
if (a == Ia && sa) {
return new Uint8Array(sa);
}
if (pa) {
return pa(a);
}
throw "both async and sync fetching of the wasm failed";
}
function Ka(a) {
return sa ? Promise.resolve().then(() => Ja(a)) : new Promise((b, c) => {
oa(a, d => b(new Uint8Array(d)), () => {
try {
b(Ja(a));
} catch (d) {
c(d);
}
});
});
}
function La(a, b, c) {
return Ka(a).then(d => WebAssembly.instantiate(d, b)).then(c, d => {
A(`failed to asynchronously prepare wasm: ${d}`);
Ga(d);
});
}
function Ma(a, b) {
var c = Ia;
return sa || "function" != typeof WebAssembly.instantiateStreaming || Ha(c) || qa(c) || "function" != typeof fetch ? La(c, a, b) : fetch(c, {credentials:"same-origin"}).then(d => WebAssembly.instantiateStreaming(d, a).then(b, function(e) {
A(`wasm streaming compile failed: ${e}`);
A("falling back to ArrayBuffer instantiation");
return La(c, a, b);
}));
}
var Na, Oa, Sa = {571903:(a, b, c, d, e) => {
if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
return 0;
}
if ("undefined" === typeof window.miniaudio) {
window.miniaudio = {referenceCount:0};
window.miniaudio.device_type = {};
window.miniaudio.device_type.playback = a;
window.miniaudio.device_type.capture = b;
window.miniaudio.device_type.duplex = c;
window.miniaudio.device_state = {};
window.miniaudio.device_state.stopped = d;
window.miniaudio.device_state.started = e;
let f = window.miniaudio;
f.devices = [];
f.track_device = function(g) {
for (var h = 0; h < f.devices.length; ++h) {
if (null == f.devices[h]) {
return f.devices[h] = g, h;
}
}
f.devices.push(g);
return f.devices.length - 1;
};
f.untrack_device_by_index = function(g) {
for (f.devices[g] = null; 0 < f.devices.length;) {
if (null == f.devices[f.devices.length - 1]) {
f.devices.pop();
} else {
break;
}
}
};
f.untrack_device = function(g) {
for (var h = 0; h < f.devices.length; ++h) {
if (f.devices[h] == g) {
return f.untrack_device_by_index(h);
}
}
};
f.get_device_by_index = function(g) {
return f.devices[g];
};
f.unlock_event_types = ["touchend", "click"];
f.unlock = function() {
for (var g = 0; g < f.devices.length; ++g) {
var h = f.devices[g];
null != h && null != h.H && h.state === f.device_state.started && h.H.resume().then(() => {
Pa(h.gb);
}, m => {
console.error("Failed to resume audiocontext", m);
});
}
f.unlock_event_types.map(function(m) {
document.removeEventListener(m, f.unlock, !0);
});
};
f.unlock_event_types.map(function(g) {
document.addEventListener(g, f.unlock, !0);
});
}
window.miniaudio.referenceCount += 1;
return 1;
}, 574081:() => {
"undefined" !== typeof window.miniaudio && (window.miniaudio.unlock_event_types.map(function(a) {
document.removeEventListener(a, window.miniaudio.unlock, !0);
}), --window.miniaudio.referenceCount, 0 === window.miniaudio.referenceCount && delete window.miniaudio);
}, 574385:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 574489:() => {
try {
var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
a.close();
return b;
} catch (c) {
return 0;
}
}, 574660:(a, b, c, d, e, f) => {
if ("undefined" === typeof window.miniaudio) {
return -1;
}
var g = {}, h = {};
a == window.miniaudio.device_type.playback && 0 != c && (h.sampleRate = c);
g.H = new (window.AudioContext || window.webkitAudioContext)(h);
g.H.suspend();
g.state = window.miniaudio.device_state.stopped;
c = 0;
a != window.miniaudio.device_type.playback && (c = b);
g.V = g.H.createScriptProcessor(d, c, b);
g.V.onaudioprocess = function(m) {
if (null == g.ra || 0 == g.ra.length) {
g.ra = new Float32Array(wa.buffer, e, d * b);
}
if (a == window.miniaudio.device_type.capture || a == window.miniaudio.device_type.duplex) {
for (var l = 0; l < b; l += 1) {
for (var r = m.inputBuffer.getChannelData(l), u = g.ra, w = 0; w < d; w += 1) {
u[w * b + l] = r[w];
}
}
Qa(f, d, e);
}
if (a == window.miniaudio.device_type.playback || a == window.miniaudio.device_type.duplex) {
for (Ra(f, d, e), l = 0; l < m.outputBuffer.numberOfChannels; ++l) {
for (r = m.outputBuffer.getChannelData(l), u = g.ra, w = 0; w < d; w += 1) {
r[w] = u[w * b + l];
}
}
} else {
for (l = 0; l < m.outputBuffer.numberOfChannels; ++l) {
m.outputBuffer.getChannelData(l).fill(0.0);
}
}
};
a != window.miniaudio.device_type.capture && a != window.miniaudio.device_type.duplex || navigator.mediaDevices.getUserMedia({audio:!0, video:!1}).then(function(m) {
g.Ba = g.H.createMediaStreamSource(m);
g.Ba.connect(g.V);
g.V.connect(g.H.destination);
}).catch(function(m) {
console.log("Failed to get user media: " + m);
});
a == window.miniaudio.device_type.playback && g.V.connect(g.H.destination);
g.gb = f;
return window.miniaudio.track_device(g);
}, 577537:a => window.miniaudio.get_device_by_index(a).H.sampleRate, 577610:a => {
a = window.miniaudio.get_device_by_index(a);
void 0 !== a.V && (a.V.onaudioprocess = function() {
}, a.V.disconnect(), a.V = void 0);
void 0 !== a.Ba && (a.Ba.disconnect(), a.Ba = void 0);
a.H.close();
a.H = void 0;
a.gb = void 0;
}, 578010:a => {
window.miniaudio.untrack_device_by_index(a);
}, 578060:a => {
a = window.miniaudio.get_device_by_index(a);
a.H.resume();
a.state = window.miniaudio.device_state.started;
}, 578199:a => {
a = window.miniaudio.get_device_by_index(a);
a.H.suspend();
a.state = window.miniaudio.device_state.stopped;
}}, Ta = a => {
for (; 0 < a.length;) {
a.shift()(k);
}
};
function Ua() {
var a = F[+Va >> 2];
Va += 4;
return a;
}
var Wa = (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;
}, Xa = a => {
var b = "/" === a.charAt(0), c = "/" === a.substr(-1);
(a = Wa(a.split("/").filter(d => !!d), !b).join("/")) || b || (a = ".");
a && c && (a += "/");
return (b ? "/" : "") + a;
}, Ya = a => {
var b = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);
a = b[0];
b = b[1];
if (!a && !b) {
return ".";
}
b &&= b.substr(0, b.length - 1);
return a + b;
}, Za = a => {
if ("/" === a) {
return "/";
}
a = Xa(a);
a = a.replace(/\/$/, "");
var b = a.lastIndexOf("/");
return -1 === b ? a : a.substr(b + 1);
}, $a = () => {
if ("object" == typeof crypto && "function" == typeof crypto.getRandomValues) {
return a => crypto.getRandomValues(a);
}
Ga("initRandomDevice");
}, ab = a => (ab = $a())(a), bb = (...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 = Wa(b.split("/").filter(e => !!e), !c).join("/");
return (c ? "/" : "") + b || ".";
}, cb = "undefined" != typeof TextDecoder ? new TextDecoder("utf8") : void 0, L = (a, b, c) => {
var d = b + c;
for (c = b; a[c] && !(c >= d);) {
++c;
}
if (16 < c - b && a.buffer && cb) {
return cb.decode(a.subarray(b, c));
}
for (d = ""; b < c;) {
var e = a[b++];
if (e & 128) {
var f = a[b++] & 63;
if (192 == (e & 224)) {
d += String.fromCharCode((e & 31) << 6 | f);
} else {
var g = a[b++] & 63;
e = 224 == (e & 240) ? (e & 15) << 12 | f << 6 | g : (e & 7) << 18 | f << 12 | g << 6 | a[b++] & 63;
65536 > e ? d += String.fromCharCode(e) : (e -= 65536, d += String.fromCharCode(55296 | e >> 10, 56320 | e & 1023));
}
} else {
d += String.fromCharCode(e);
}
}
return d;
}, db = [], eb = 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;
}, fb = (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.charCodeAt(f);
if (55296 <= g && 57343 >= g) {
var h = a.charCodeAt(++f);
g = 65536 + ((g & 1023) << 10) | h & 1023;
}
if (127 >= g) {
if (c >= d) {
break;
}
b[c++] = g;
} else {
if (2047 >= g) {
if (c + 1 >= d) {
break;
}
b[c++] = 192 | g >> 6;
} else {
if (65535 >= g) {
if (c + 2 >= d) {
break;
}
b[c++] = 224 | g >> 12;
} 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;
}
}
b[c] = 0;
return c - e;
};
function gb(a, b) {
var c = Array(eb(a) + 1);
a = fb(a, c, 0, c.length);
b && (c.length = a);
return c;
}
var hb = [];
function ib(a, b) {
hb[a] = {input:[], F:[], S:b};
jb(a, kb);
}
var kb = {open(a) {
var b = hb[a.node.Aa];
if (!b) {
throw new M(43);
}
a.o = b;
a.seekable = !1;
}, close(a) {
a.o.S.pa(a.o);
}, pa(a) {
a.o.S.pa(a.o);
}, read(a, b, c, d) {
if (!a.o || !a.o.S.$a) {
throw new M(60);
}
for (var e = 0, f = 0; f < d; f++) {
try {
var g = a.o.S.$a(a.o);
} catch (h) {
throw new M(29);
}
if (void 0 === g && 0 === e) {
throw new M(6);
}
if (null === g || void 0 === g) {
break;
}
e++;
b[c + f] = g;
}
e && (a.node.timestamp = Date.now());
return e;
}, write(a, b, c, d) {
if (!a.o || !a.o.S.Ma) {
throw new M(60);
}
try {
for (var e = 0; e < d; e++) {
a.o.S.Ma(a.o, b[c + e]);
}
} catch (f) {
throw new M(29);
}
d && (a.node.timestamp = Date.now());
return e;
},}, lb = {$a() {
a: {
if (!db.length) {
var a = null;
"undefined" != typeof window && "function" == typeof window.prompt && (a = window.prompt("Input: "), null !== a && (a += "\n"));
if (!a) {
a = null;
break a;
}
db = gb(a, !0);
}
a = db.shift();
}
return a;
}, Ma(a, b) {
null === b || 10 === b ? (ra(L(a.F, 0)), a.F = []) : 0 != b && a.F.push(b);
}, pa(a) {
a.F && 0 < a.F.length && (ra(L(a.F, 0)), a.F = []);
}, Nb() {
return {nc:25856, pc:5, mc:191, oc:35387, lc:[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,]};
}, Ob() {
return 0;
}, Pb() {
return [24, 80];
},}, mb = {Ma(a, b) {
null === b || 10 === b ? (A(L(a.F, 0)), a.F = []) : 0 != b && a.F.push(b);
}, pa(a) {
a.F && 0 < a.F.length && (A(L(a.F, 0)), a.F = []);
},};
function ob(a, b) {
var c = a.j ? a.j.length : 0;
c >= b || (b = Math.max(b, c * (1048576 > c ? 2.0 : 1.125) >>> 0), 0 != c && (b = Math.max(b, 256)), c = a.j, a.j = new Uint8Array(b), 0 < a.u && a.j.set(c.subarray(0, a.u), 0));
}
var N = {K:null, R() {
return N.createNode(null, "/", 16895, 0);
}, createNode(a, b, c, d) {
if (24576 === (c & 61440) || 4096 === (c & 61440)) {
throw new M(63);
}
N.K || (N.K = {dir:{node:{U:N.i.U, M:N.i.M, ha:N.i.ha, xa:N.i.xa, lb:N.i.lb, pb:N.i.pb, mb:N.i.mb, kb:N.i.kb, Ca:N.i.Ca}, stream:{Z:N.l.Z}}, file:{node:{U:N.i.U, M:N.i.M}, stream:{Z:N.l.Z, read:N.l.read, write:N.l.write, Ta:N.l.Ta, bb:N.l.bb, eb:N.l.eb}}, link:{node:{U:N.i.U, M:N.i.M, ia:N.i.ia}, stream:{}}, Ua:{node:{U:N.i.U, M:N.i.M}, stream:pb}});
c = qb(a, b, c, d);
16384 === (c.mode & 61440) ? (c.i = N.K.dir.node, c.l = N.K.dir.stream, c.j = {}) : 32768 === (c.mode & 61440) ? (c.i = N.K.file.node, c.l = N.K.file.stream, c.u = 0, c.j = null) : 40960 === (c.mode & 61440) ? (c.i = N.K.link.node, c.l = N.K.link.stream) : 8192 === (c.mode & 61440) && (c.i = N.K.Ua.node, c.l = N.K.Ua.stream);
c.timestamp = Date.now();
a && (a.j[b] = c, a.timestamp = c.timestamp);
return c;
}, vc(a) {
return a.j ? a.j.subarray ? a.j.subarray(0, a.u) : new Uint8Array(a.j) : new Uint8Array(0);
}, i:{U(a) {
var b = {};
b.sc = 8192 === (a.mode & 61440) ? a.id : 1;
b.xc = a.id;
b.mode = a.mode;
b.Dc = 1;
b.uid = 0;
b.wc = 0;
b.Aa = a.Aa;
16384 === (a.mode & 61440) ? b.size = 4096 : 32768 === (a.mode & 61440) ? b.size = a.u : 40960 === (a.mode & 61440) ? b.size = a.link.length : b.size = 0;
b.jc = new Date(a.timestamp);
b.Cc = new Date(a.timestamp);
b.qc = new Date(a.timestamp);
b.xb = 4096;
b.kc = Math.ceil(b.size / b.xb);
return b;
}, M(a, b) {
void 0 !== b.mode && (a.mode = b.mode);
void 0 !== b.timestamp && (a.timestamp = b.timestamp);
if (void 0 !== b.size && (b = b.size, a.u != b)) {
if (0 == b) {
a.j = null, a.u = 0;
} else {
var c = a.j;
a.j = new Uint8Array(b);
c && a.j.set(c.subarray(0, Math.min(b, a.u)));
a.u = b;
}
}
}, ha() {
throw rb[44];
}, xa(a, b, c, d) {
return N.createNode(a, b, c, d);
}, lb(a, b, c) {
if (16384 === (a.mode & 61440)) {
try {
var d = sb(b, c);
} catch (f) {
}
if (d) {
for (var e in d.j) {
throw new M(55);
}
}
}
delete a.parent.j[a.name];
a.parent.timestamp = Date.now();
a.name = c;
b.j[c] = a;
b.timestamp = a.parent.timestamp;
}, pb(a, b) {
delete a.j[b];
a.timestamp = Date.now();
}, mb(a, b) {
var c = sb(a, b), d;
for (d in c.j) {
throw new M(55);
}
delete a.j[b];
a.timestamp = Date.now();
}, kb(a) {
var b = [".", ".."], c;
for (c of Object.keys(a.j)) {
b.push(c);
}
return b;
}, Ca(a, b, c) {
a = N.createNode(a, b, 41471, 0);
a.link = c;
return a;
}, ia(a) {
if (40960 !== (a.mode & 61440)) {
throw new M(28);
}
return a.link;
},}, l:{read(a, b, c, d, e) {
var f = a.node.j;
if (e >= a.node.u) {
return 0;
}
a = Math.min(a.node.u - e, d);
if (8 < a && f.subarray) {
b.set(f.subarray(e, e + a), c);
} else {
for (d = 0; d < a; d++) {
b[c + d] = f[e + d];
}
}
return a;
}, write(a, b, c, d, e, f) {
b.buffer === C.buffer && (f = !1);
if (!d) {
return 0;
}
a = a.node;
a.timestamp = Date.now();
if (b.subarray && (!a.j || a.j.subarray)) {
if (f) {
return a.j = b.subarray(c, c + d), a.u = d;
}
if (0 === a.u && 0 === e) {
return a.j = b.slice(c, c + d), a.u = d;
}
if (e + d <= a.u) {
return a.j.set(b.subarray(c, c + d), e), d;
}
}
ob(a, e + d);
if (a.j.subarray && b.subarray) {
a.j.set(b.subarray(c, c + d), e);
} else {
for (f = 0; f < d; f++) {
a.j[e + f] = b[c + f];
}
}
a.u = Math.max(a.u, e + d);
return d;
}, Z(a, b, c) {
1 === c ? b += a.position : 2 === c && 32768 === (a.node.mode & 61440) && (b += a.node.u);
if (0 > b) {
throw new M(28);
}
return b;
}, Ta(a, b, c) {
ob(a.node, b + c);
a.node.u = Math.max(a.node.u, b + c);
}, bb(a, b, c, d, e) {
if (32768 !== (a.node.mode & 61440)) {
throw new M(43);
}
a = a.node.j;
if (e & 2 || a.buffer !== C.buffer) {
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 = !0;
Ga();
b = void 0;
if (!b) {
throw new M(48);
}
C.set(a, b);
} else {
c = !1, b = a.byteOffset;
}
return {m:b, ic:c};
}, eb(a, b, c, d) {
N.l.write(a, b, 0, d, c, !1);
return 0;
},},}, tb = (a, b) => {
var c = 0;
a && (c |= 365);
b && (c |= 146);
return c;
}, ub = null, vb = {}, wb = [], xb = 1, yb = null, zb = !0, M = class {
constructor(a) {
this.name = "ErrnoError";
this.Y = a;
}
}, rb = {}, Ab = class {
constructor() {
this.qa = {};
this.node = null;
}
get flags() {
return this.qa.flags;
}
set flags(a) {
this.qa.flags = a;
}
get position() {
return this.qa.position;
}
set position(a) {
this.qa.position = a;
}
}, Bb = class {
constructor(a, b, c, d) {
a ||= this;
this.parent = a;
this.R = a.R;
this.ya = null;
this.id = xb++;
this.name = b;
this.mode = c;
this.i = {};
this.l = {};
this.Aa = d;
}
get read() {
return 365 === (this.mode & 365);
}
set read(a) {
a ? this.mode |= 365 : this.mode &= -366;
}
get write() {
return 146 === (this.mode & 146);
}
set write(a) {
a ? this.mode |= 146 : this.mode &= -147;
}
};
function Cb(a, b = {}) {
a = bb(a);
if (!a) {
return {path:"", node:null};
}
b = Object.assign({Za:!0, Oa:0}, b);
if (8 < b.Oa) {
throw new M(32);
}
a = a.split("/").filter(g => !!g);
for (var c = ub, d = "/", e = 0; e < a.length; e++) {
var f = e === a.length - 1;
if (f && b.parent) {
break;
}
c = sb(c, a[e]);
d = Xa(d + "/" + a[e]);
c.ya && (!f || f && b.Za) && (c = c.ya.root);
if (!f || b.Ya) {
for (f = 0; 40960 === (c.mode & 61440);) {
if (c = Db(d), d = bb(Ya(d), c), c = Cb(d, {Oa:b.Oa + 1}).node, 40 < f++) {
throw new M(32);
}
}
}
}
return {path:d, node:c};
}
function Eb(a) {
for (var b;;) {
if (a === a.parent) {
return a = a.R.cb, b ? "/" !== a[a.length - 1] ? `${a}/${b}` : a + b : a;
}
b = b ? `${a.name}/${b}` : a.name;
a = a.parent;
}
}
function Fb(a, b) {
for (var c = 0, d = 0; d < b.length; d++) {
c = (c << 5) - c + b.charCodeAt(d) | 0;
}
return (a + c >>> 0) % yb.length;
}
function sb(a, b) {
var c = 16384 === (a.mode & 61440) ? (c = Gb(a, "x")) ? c : a.i.ha ? 0 : 2 : 54;
if (c) {
throw new M(c);
}
for (c = yb[Fb(a.id, b)]; c; c = c.Sb) {
var d = c.name;
if (c.parent.id === a.id && d === b) {
return c;
}
}
return a.i.ha(a, b);
}
function qb(a, b, c, d) {
a = new Bb(a, b, c, d);
b = Fb(a.parent.id, a.name);
a.Sb = yb[b];
return yb[b] = a;
}
function Hb(a) {
var b = ["r", "w", "rw"][a & 3];
a & 512 && (b += "w");
return b;
}
function Gb(a, b) {
if (zb) {
return 0;
}
if (!b.includes("r") || a.mode & 292) {
if (b.includes("w") && !(a.mode & 146) || b.includes("x") && !(a.mode & 73)) {
return 2;
}
} else {
return 2;
}
return 0;
}
function Ib(a, b) {
try {
return sb(a, b), 20;
} catch (c) {
}
return Gb(a, "wx");
}
function Jb(a) {
a = wb[a];
if (!a) {
throw new M(8);
}
return a;
}
function Kb(a, b = -1) {
a = Object.assign(new Ab(), a);
if (-1 == b) {
a: {
for (b = 0; 4096 >= b; b++) {
if (!wb[b]) {
break a;
}
}
throw new M(33);
}
}
a.T = b;
return wb[b] = a;
}
function Lb(a, b = -1) {
a = Kb(a, b);
a.l?.uc?.(a);
return a;
}
var pb = {open(a) {
a.l = vb[a.node.Aa].l;
a.l.open?.(a);
}, Z() {
throw new M(70);
},};
function jb(a, b) {
vb[a] = {l:b};
}
function Mb(a, b) {
var c = "/" === b;
if (c && ub) {
throw new M(10);
}
if (!c && b) {
var d = Cb(b, {Za:!1});
b = d.path;
d = d.node;
if (d.ya) {
throw new M(10);
}
if (16384 !== (d.mode & 61440)) {
throw new M(54);
}
}
b = {type:a, Fc:{}, cb:b, Qb:[]};
a = a.R(b);
a.R = b;
b.root = a;
c ? ub = a : d && (d.ya = b, d.R && d.R.Qb.push(b));
}
function Nb(a, b, c) {
var d = Cb(a, {parent:!0}).node;
a = Za(a);
if (!a || "." === a || ".." === a) {
throw new M(28);
}
var e = Ib(d, a);
if (e) {
throw new M(e);
}
if (!d.i.xa) {
throw new M(63);
}
return d.i.xa(d, a, b, c);
}
function Ob(a) {
return Nb(a, 16895, 0);
}
function Pb(a, b, c) {
"undefined" == typeof c && (c = b, b = 438);
Nb(a, b | 8192, c);
}
function Qb(a, b) {
if (!bb(a)) {
throw new M(44);
}
var c = Cb(b, {parent:!0}).node;
if (!c) {
throw new M(44);
}
b = Za(b);
var d = Ib(c, b);
if (d) {
throw new M(d);
}
if (!c.i.Ca) {
throw new M(63);
}
c.i.Ca(c, b, a);
}
function Db(a) {
a = Cb(a).node;
if (!a) {
throw new M(44);
}
if (!a.i.ia) {
throw new M(28);
}
return bb(Eb(a.parent), a.i.ia(a));
}
function Rb(a, b, c) {
if ("" === a) {
throw new M(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 ? ("undefined" == typeof c ? 438 : c) & 4095 | 32768 : 0;
if ("object" == typeof a) {
var e = a;
} else {
a = Xa(a);
try {
e = Cb(a, {Ya:!(b & 131072)}).node;
} catch (f) {
}
}
d = !1;
if (b & 64) {
if (e) {
if (b & 128) {
throw new M(20);
}
} else {
e = Nb(a, c, 0), d = !0;
}
}
if (!e) {
throw new M(44);
}
8192 === (e.mode & 61440) && (b &= -513);
if (b & 65536 && 16384 !== (e.mode & 61440)) {
throw new M(54);
}
if (!d && (c = e ? 40960 === (e.mode & 61440) ? 32 : 16384 === (e.mode & 61440) && ("r" !== Hb(b) || b & 512) ? 31 : Gb(e, Hb(b)) : 44)) {
throw new M(c);
}
if (b & 512 && !d) {
c = e;
c = "string" == typeof c ? Cb(c, {Ya:!0}).node : c;
if (!c.i.M) {
throw new M(63);
}
if (16384 === (c.mode & 61440)) {
throw new M(31);
}
if (32768 !== (c.mode & 61440)) {
throw new M(28);
}
if (d = Gb(c, "w")) {
throw new M(d);
}
c.i.M(c, {size:0, timestamp:Date.now()});
}
b &= -131713;
e = Kb({node:e, path:Eb(e), flags:b, seekable:!0, position:0, l:e.l, cc:[], error:!1});
e.l.open && e.l.open(e);
!k.logReadFiles || b & 1 || (Sb ||= {}, a in Sb || (Sb[a] = 1));
return e;
}
function Tb(a, b, c) {
if (null === a.T) {
throw new M(8);
}
if (!a.seekable || !a.l.Z) {
throw new M(70);
}
if (0 != c && 1 != c && 2 != c) {
throw new M(28);
}
a.position = a.l.Z(a, b, c);
a.cc = [];
}
var Ub;
function Vb(a, b, c) {
a = Xa("/dev/" + a);
var d = tb(!!b, !!c);
Wb ||= 64;
var e = Wb++ << 8 | 0;
jb(e, {open(f) {
f.seekable = !1;
}, close() {
c?.buffer?.length && c(10);
}, read(f, g, h, m) {
for (var l = 0, r = 0; r < m; r++) {
try {
var u = b();
} catch (w) {
throw new M(29);
}
if (void 0 === u && 0 === l) {
throw new M(6);
}
if (null ===