@rive-app/canvas-advanced
Version:
Rive's lightweight low-level canvas based web api.
1,770 lines (1,767 loc) • 97.6 kB
JavaScript
var Rive = (() => {
var _scriptName = typeof document != 'undefined' ? document.currentScript?.src : undefined;
return (
function(moduleArg = {}) {
var moduleRtn;
var k = moduleArg, ba, ca, da = new Promise((a, b) => {
ba = a;
ca = b;
}), ea = "object" == typeof window, ha = "function" == typeof importScripts;
function ia() {
function a(g) {
const h = d;
c = b = 0;
d = new Map();
h.forEach(n => {
try {
n(g);
} catch (m) {
console.error(m);
}
});
this.gb();
e && e.Hb();
}
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.Fb = 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, n = 0;
this.Hb = function() {
var m = performance.now();
n ? (++h, m -= n, 1000 < m && (g(1000 * h / m), h = n = 0)) : (n = m, h = 0);
};
}();
};
this.Cb = function() {
f && (document.body.remove(f), f = null);
e = null;
};
this.gb = function() {
};
}
function ja(a) {
console.assert(!0);
const b = new Map();
let c = -Infinity;
this.push = function(d) {
d = d + ((1 << a) - 1) >> a;
b.has(d) && clearTimeout(b.get(d));
b.set(d, setTimeout(function() {
b.delete(d);
0 == b.length ? c = -Infinity : d == c && (c = Math.max(...b.keys()), console.assert(c < d));
}, 1000));
c = Math.max(d, c);
return c << a;
};
}
const ka = k.onRuntimeInitialized;
k.onRuntimeInitialized = function() {
ka && ka();
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.ub = f;
}, loadContents:function(f, g) {
f = k.ptrToAsset(f);
return this.ub(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, n) {
var m = new XMLHttpRequest();
m.responseType = "arraybuffer";
m.onreadystatechange = function() {
4 == m.readyState && 200 == m.status && n(m);
};
m.open("GET", h, !0);
m.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.bb = [];
}, addLoader:function(f) {
this.bb.push(f);
}, loadContents:function(f, g) {
for (let h of this.bb) {
if (h.loadContents(f, g)) {
return !0;
}
}
return !1;
},});
let e = k.computeAlignment;
k.computeAlignment = function(f, g, h, n, m = 1.0) {
return e.call(this, f, g, h, n, m);
};
};
const la = "createConicGradient createImageData createLinearGradient createPattern createRadialGradient getContextAttributes getImageData getLineDash getTransform isContextLost isPointInPath isPointInStroke measureText".split(" "), ma = new function() {
function a() {
if (!b) {
var l = document.createElement("canvas"), t = {alpha:1, depth:0, stencil:0, antialias:0, premultipliedAlpha:1, preserveDrawingBuffer:0, powerPreference:"high-performance", failIfMajorPerformanceCaveat:0, enableExtensionsByDefault:1, explicitSwapControl:1, renderViaOffscreenBackBuffer:1,};
let q;
if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) {
if (q = l.getContext("webgl", t), c = 1, !q) {
return console.log("No WebGL support. Image mesh will not be drawn."), !1;
}
} else {
if (q = l.getContext("webgl2", t)) {
c = 2;
} else {
if (q = l.getContext("webgl", t)) {
c = 1;
} else {
return console.log("No WebGL support. Image mesh will not be drawn."), !1;
}
}
}
q = new Proxy(q, {get(H, v) {
if (H.isContextLost()) {
if (n || (console.error("Cannot render the mesh because the GL Context was lost. Tried to invoke ", v), n = !0), "function" === typeof H[v]) {
return function() {
};
}
} else {
return "function" === typeof H[v] ? function(...K) {
return H[v].apply(H, K);
} : H[v];
}
}, set(H, v, K) {
if (H.isContextLost()) {
n || (console.error("Cannot render the mesh because the GL Context was lost. Tried to set property " + v), n = !0);
} else {
return H[v] = K, !0;
}
},});
d = Math.min(q.getParameter(q.MAX_RENDERBUFFER_SIZE), q.getParameter(q.MAX_TEXTURE_SIZE));
function C(H, v, K) {
v = q.createShader(v);
q.shaderSource(v, K);
q.compileShader(v);
K = q.getShaderInfoLog(v);
if (0 < (K || "").length) {
throw K;
}
q.attachShader(H, v);
}
l = q.createProgram();
C(l, q.VERTEX_SHADER, "attribute vec2 vertex;\n attribute vec2 uv;\n uniform vec4 mat;\n uniform vec2 translate;\n varying vec2 st;\n void main() {\n st = uv;\n gl_Position = vec4(mat2(mat) * vertex + translate, 0, 1);\n }");
C(l, q.FRAGMENT_SHADER, "precision highp float;\n uniform sampler2D image;\n varying vec2 st;\n void main() {\n gl_FragColor = texture2D(image, st);\n }");
q.bindAttribLocation(l, 0, "vertex");
q.bindAttribLocation(l, 1, "uv");
q.linkProgram(l);
t = q.getProgramInfoLog(l);
if (0 < (t || "").trim().length) {
throw t;
}
e = q.getUniformLocation(l, "mat");
f = q.getUniformLocation(l, "translate");
q.useProgram(l);
q.bindBuffer(q.ARRAY_BUFFER, q.createBuffer());
q.enableVertexAttribArray(0);
q.enableVertexAttribArray(1);
q.bindBuffer(q.ELEMENT_ARRAY_BUFFER, q.createBuffer());
q.uniform1i(q.getUniformLocation(l, "image"), 0);
q.pixelStorei(q.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !0);
b = q;
}
return !0;
}
let b = null, c = 0, d = 0, e = null, f = null, g = 0, h = 0, n = !1;
a();
this.Tb = function() {
a();
return d;
};
this.Bb = function(l) {
b.deleteTexture && b.deleteTexture(l);
};
this.Ab = function(l) {
if (!a()) {
return null;
}
const t = b.createTexture();
if (!t) {
return null;
}
b.bindTexture(b.TEXTURE_2D, t);
b.texImage2D(b.TEXTURE_2D, 0, b.RGBA, b.RGBA, b.UNSIGNED_BYTE, l);
b.texParameteri(b.TEXTURE_2D, b.TEXTURE_WRAP_S, b.CLAMP_TO_EDGE);
b.texParameteri(b.TEXTURE_2D, b.TEXTURE_WRAP_T, b.CLAMP_TO_EDGE);
b.texParameteri(b.TEXTURE_2D, b.TEXTURE_MAG_FILTER, b.LINEAR);
2 == c ? (b.texParameteri(b.TEXTURE_2D, b.TEXTURE_MIN_FILTER, b.LINEAR_MIPMAP_LINEAR), b.generateMipmap(b.TEXTURE_2D)) : b.texParameteri(b.TEXTURE_2D, b.TEXTURE_MIN_FILTER, b.LINEAR);
return t;
};
const m = new ja(8), r = new ja(8), w = new ja(10), x = new ja(10);
this.Eb = function(l, t, q, C, H) {
if (a()) {
var v = m.push(l), K = r.push(t);
if (b.canvas) {
if (b.canvas.width != v || b.canvas.height != K) {
b.canvas.width = v, b.canvas.height = K;
}
b.viewport(0, K - t, l, t);
b.disable(b.SCISSOR_TEST);
b.clearColor(0, 0, 0, 0);
b.clear(b.COLOR_BUFFER_BIT);
b.enable(b.SCISSOR_TEST);
q.sort((J, Z) => Z.nb - J.nb);
v = w.push(C);
g != v && (b.bufferData(b.ARRAY_BUFFER, 8 * v, b.DYNAMIC_DRAW), g = v);
v = 0;
for (var Q of q) {
b.bufferSubData(b.ARRAY_BUFFER, v, Q.La), v += 4 * Q.La.length;
}
console.assert(v == 4 * C);
for (var U of q) {
b.bufferSubData(b.ARRAY_BUFFER, v, U.rb), v += 4 * U.rb.length;
}
console.assert(v == 8 * C);
v = x.push(H);
h != v && (b.bufferData(b.ELEMENT_ARRAY_BUFFER, 2 * v, b.DYNAMIC_DRAW), h = v);
Q = 0;
for (var pa of q) {
b.bufferSubData(b.ELEMENT_ARRAY_BUFFER, Q, pa.indices), Q += 2 * pa.indices.length;
}
console.assert(Q == 2 * H);
pa = 0;
U = !0;
v = Q = 0;
for (const J of q) {
J.image.Da != pa && (b.bindTexture(b.TEXTURE_2D, J.image.Ca || null), pa = J.image.Da);
J.Yb ? (b.scissor(J.Ra, K - J.Sa - J.ab, J.kc, J.ab), U = !0) : U && (b.scissor(0, K - t, l, t), U = !1);
q = 2 / l;
const Z = -2 / t;
b.uniform4f(e, J.da[0] * q * J.ua, J.da[1] * Z * J.va, J.da[2] * q * J.ua, J.da[3] * Z * J.va);
b.uniform2f(f, J.da[4] * q * J.ua + q * (J.Ra - J.Ub * J.ua) - 1, J.da[5] * Z * J.va + Z * (J.Sa - J.Vb * J.va) + 1);
b.vertexAttribPointer(0, 2, b.FLOAT, !1, 0, v);
b.vertexAttribPointer(1, 2, b.FLOAT, !1, 0, v + 4 * C);
b.drawElements(b.TRIANGLES, J.indices.length, b.UNSIGNED_SHORT, Q);
v += 4 * J.La.length;
Q += 2 * J.indices.length;
}
console.assert(v == 4 * C);
console.assert(Q == 2 * H);
}
}
};
this.canvas = function() {
return a() && b.canvas;
};
}(), na = k.onRuntimeInitialized;
k.onRuntimeInitialized = function() {
function a(p) {
switch(p) {
case m.srcOver:
return "source-over";
case m.screen:
return "screen";
case m.overlay:
return "overlay";
case m.darken:
return "darken";
case m.lighten:
return "lighten";
case m.colorDodge:
return "color-dodge";
case m.colorBurn:
return "color-burn";
case m.hardLight:
return "hard-light";
case m.softLight:
return "soft-light";
case m.difference:
return "difference";
case m.exclusion:
return "exclusion";
case m.multiply:
return "multiply";
case m.hue:
return "hue";
case m.saturation:
return "saturation";
case m.color:
return "color";
case m.luminosity:
return "luminosity";
}
}
function b(p) {
return "rgba(" + ((16711680 & p) >>> 16) + "," + ((65280 & p) >>> 8) + "," + ((255 & p) >>> 0) + "," + ((4278190080 & p) >>> 24) / 255 + ")";
}
function c() {
0 < K.length && (ma.Eb(v.drawWidth(), v.drawHeight(), K, Q, U), K = [], U = Q = 0, v.reset(512, 512));
for (const p of H) {
for (const u of p.G) {
u();
}
p.G = [];
}
H.clear();
}
na && na();
var d = k.RenderPaintStyle;
const e = k.RenderPath, f = k.RenderPaint, g = k.Renderer, h = k.StrokeCap, n = k.StrokeJoin, m = k.BlendMode, r = d.fill, w = d.stroke, x = k.FillRule.evenOdd;
let l = 1;
var t = k.RenderImage.extend("CanvasRenderImage", {__construct:function({ha:p, sa:u} = {}) {
this.__parent.__construct.call(this);
this.Da = l;
l = l + 1 & 2147483647 || 1;
this.ha = p;
this.sa = u;
}, __destruct:function() {
this.Ca && (ma.Bb(this.Ca), URL.revokeObjectURL(this.Oa));
this.__parent.__destruct.call(this);
}, decode:function(p) {
var u = this;
u.sa && u.sa(u);
var I = new Image();
u.Oa = URL.createObjectURL(new Blob([p], {type:"image/png",}));
I.onload = function() {
u.tb = I;
u.Ca = ma.Ab(I);
u.size(I.width, I.height);
u.ha && u.ha(u);
};
I.src = u.Oa;
},}), q = e.extend("CanvasRenderPath", {__construct:function() {
this.__parent.__construct.call(this);
this.R = new Path2D();
}, rewind:function() {
this.R = new Path2D();
}, addPath:function(p, u, I, F, z, G, D) {
var L = this.R, xa = L.addPath;
p = p.R;
const S = new DOMMatrix();
S.a = u;
S.b = I;
S.c = F;
S.d = z;
S.e = G;
S.f = D;
xa.call(L, p, S);
}, fillRule:function(p) {
this.Na = p;
}, moveTo:function(p, u) {
this.R.moveTo(p, u);
}, lineTo:function(p, u) {
this.R.lineTo(p, u);
}, cubicTo:function(p, u, I, F, z, G) {
this.R.bezierCurveTo(p, u, I, F, z, G);
}, close:function() {
this.R.closePath();
},}), C = f.extend("CanvasRenderPaint", {color:function(p) {
this.Pa = b(p);
}, thickness:function(p) {
this.xb = p;
}, join:function(p) {
switch(p) {
case n.miter:
this.Ba = "miter";
break;
case n.round:
this.Ba = "round";
break;
case n.bevel:
this.Ba = "bevel";
}
}, cap:function(p) {
switch(p) {
case h.butt:
this.Aa = "butt";
break;
case h.round:
this.Aa = "round";
break;
case h.square:
this.Aa = "square";
}
}, style:function(p) {
this.wb = p;
}, blendMode:function(p) {
this.sb = a(p);
}, clearGradient:function() {
this.fa = null;
}, linearGradient:function(p, u, I, F) {
this.fa = {ob:p, pb:u, Va:I, Wa:F, Ja:[],};
}, radialGradient:function(p, u, I, F) {
this.fa = {ob:p, pb:u, Va:I, Wa:F, Ja:[], Sb:!0,};
}, addStop:function(p, u) {
this.fa.Ja.push({color:p, stop:u,});
}, completeGradient:function() {
}, draw:function(p, u, I, F) {
let z = this.wb;
var G = this.Pa, D = this.fa;
const L = p.globalCompositeOperation, xa = p.globalAlpha;
p.globalCompositeOperation = this.sb;
p.globalAlpha = F;
if (null != D) {
G = D.ob;
const W = D.pb, fa = D.Va;
var S = D.Wa;
F = D.Ja;
D.Sb ? (D = fa - G, S -= W, G = p.createRadialGradient(G, W, 0, G, W, Math.sqrt(D * D + S * S))) : G = p.createLinearGradient(G, W, fa, S);
for (let X = 0, aa = F.length; X < aa; X++) {
D = F[X], G.addColorStop(D.stop, b(D.color));
}
this.Pa = G;
this.fa = null;
}
switch(z) {
case w:
p.strokeStyle = G;
p.lineWidth = this.xb;
p.lineCap = this.Aa;
p.lineJoin = this.Ba;
p.stroke(u);
break;
case r:
p.fillStyle = G, p.fill(u, I);
}
p.globalCompositeOperation = L;
p.globalAlpha = xa;
},});
const H = new Set();
let v = null, K = [], Q = 0, U = 0;
var pa = k.CanvasRenderer = g.extend("Renderer", {__construct:function(p) {
this.__parent.__construct.call(this);
this.P = [1, 0, 0, 1, 0, 0];
this.D = [1.0];
this.A = p.getContext("2d");
this.Ma = p;
this.G = [];
}, save:function() {
this.P.push(...this.P.slice(this.P.length - 6));
this.D.push(this.D[this.D.length - 1]);
this.G.push(this.A.save.bind(this.A));
}, restore:function() {
const p = this.P.length - 6;
if (6 > p) {
throw "restore() called without matching save().";
}
this.P.splice(p);
this.D.pop();
this.G.push(this.A.restore.bind(this.A));
}, transform:function(p, u, I, F, z, G) {
const D = this.P, L = D.length - 6;
D.splice(L, 6, D[L] * p + D[L + 2] * u, D[L + 1] * p + D[L + 3] * u, D[L] * I + D[L + 2] * F, D[L + 1] * I + D[L + 3] * F, D[L] * z + D[L + 2] * G + D[L + 4], D[L + 1] * z + D[L + 3] * G + D[L + 5]);
this.G.push(this.A.transform.bind(this.A, p, u, I, F, z, G));
}, rotate:function(p) {
const u = Math.sin(p);
p = Math.cos(p);
this.transform(p, u, -u, p, 0, 0);
}, modulateOpacity:function(p) {
this.D[this.D.length - 1] *= p;
}, _drawPath:function(p, u) {
this.G.push(u.draw.bind(u, this.A, p.R, p.Na === x ? "evenodd" : "nonzero", Math.max(0, this.D[this.D.length - 1])));
}, _drawRiveImage:function(p, u, I, F) {
var z = p.tb;
if (z) {
var G = this.A, D = a(I), L = Math.max(0, F * this.D[this.D.length - 1]);
this.G.push(function() {
G.globalCompositeOperation = D;
G.globalAlpha = L;
G.drawImage(z, 0, 0);
G.globalAlpha = 1;
});
}
}, _getMatrix:function(p) {
const u = this.P, I = u.length - 6;
for (let F = 0; 6 > F; ++F) {
p[F] = u[I + F];
}
}, _drawImageMesh:function(p, u, I, F, z, G, D, L, xa, S, W, fa, X, aa) {
let $b, ac, bc;
try {
$b = k.HEAPF32.slice(z >> 2, (z >> 2) + G), ac = k.HEAPF32.slice(D >> 2, (D >> 2) + L), bc = k.HEAPU16.slice(xa >> 1, (xa >> 1) + S);
} catch (sb) {
console.error("[Rive] _drawImageMesh: failed to read mesh data from WASM heap. Mesh skipped for this frame.");
return;
}
u = this.A.canvas.width;
z = this.A.canvas.height;
D = X - W;
L = aa - fa;
W = Math.max(W, 0);
fa = Math.max(fa, 0);
X = Math.min(X, u);
aa = Math.min(aa, z);
const Fa = X - W, Ga = aa - fa;
console.assert(Fa <= Math.min(D, u));
console.assert(Ga <= Math.min(L, z));
if (!(0 >= Fa || 0 >= Ga)) {
X = Fa < D || Ga < L;
u = aa = 1;
var qa = Math.ceil(Fa * aa), ra = Math.ceil(Ga * u);
z = ma.Tb();
qa > z && (aa *= z / qa, qa = z);
ra > z && (u *= z / ra, ra = z);
v || (v = new k.DynamicRectanizer(z), v.reset(512, 512));
z = v.addRect(qa, ra);
0 > z && (c(), H.add(this), z = v.addRect(qa, ra), console.assert(0 <= z));
var cc = z & 65535, dc = z >> 16;
K.push({da:this.P.slice(this.P.length - 6), image:p, Ra:cc, Sa:dc, Ub:W, Vb:fa, kc:qa, ab:ra, ua:aa, va:u, La:$b, rb:ac, indices:bc, Yb:X, nb:p.Da << 1 | (X ? 1 : 0),});
Q += G;
U += S;
var ya = this.A, qd = a(I), rd = Math.max(0, F * this.D[this.D.length - 1]);
this.G.push(function() {
ya.save();
ya.resetTransform();
ya.globalCompositeOperation = qd;
ya.globalAlpha = rd;
const sb = ma.canvas();
sb && ya.drawImage(sb, cc, dc, qa, ra, W, fa, Fa, Ga);
ya.restore();
});
}
}, _clipPath:function(p) {
this.G.push(this.A.clip.bind(this.A, p.R, p.Na === x ? "evenodd" : "nonzero"));
}, clear:function() {
H.add(this);
this.G.push(this.A.clearRect.bind(this.A, 0, 0, this.Ma.width, this.Ma.height));
}, flush:function() {
}, translate:function(p, u) {
this.transform(1, 0, 0, 1, p, u);
},});
k.makeRenderer = function(p) {
const u = new pa(p), I = u.A;
return new Proxy(u, {get(F, z) {
if ("function" === typeof F[z]) {
return function(...G) {
return F[z].apply(F, G);
};
}
if ("function" === typeof I[z]) {
if (-1 < la.indexOf(z)) {
throw Error("RiveException: Method call to '" + z + "()' is not allowed, as the renderer cannot immediately pass through the return values of any canvas 2d context methods.");
}
return function(...G) {
u.G.push(I[z].bind(I, ...G));
};
}
return F[z];
}, set(F, z, G) {
if (z in I) {
return u.G.push(() => {
I[z] = G;
}), !0;
}
},});
};
k.decodeImage = function(p, u) {
(new t({ha:u})).decode(p);
};
k.renderFactory = {makeRenderPaint:function() {
return new C();
}, makeRenderPath:function() {
return new q();
}, makeRenderImage:function() {
let p = Z;
return new t({sa:() => {
p.total++;
}, ha:() => {
p.loaded++;
if (p.loaded === p.total) {
const u = p.ready;
u && (u(), p.ready = null);
}
},});
},};
let J = k.load, Z = null;
k.load = function(p, u, I = !0) {
const F = new k.FallbackFileAssetLoader();
void 0 !== u && F.addLoader(u);
I && (u = new k.CDNFileAssetLoader(), F.addLoader(u));
return new Promise(function(z) {
let G = null;
Z = {total:0, loaded:0, ready:function() {
z(G);
},};
G = J(p, F);
0 == Z.total && z(G);
});
};
let sd = k.RendererWrapper.prototype.align;
k.RendererWrapper.prototype.align = function(p, u, I, F, z = 1.0) {
sd.call(this, p, u, I, F, z);
};
d = new ia();
k.requestAnimationFrame = d.requestAnimationFrame.bind(d);
k.cancelAnimationFrame = d.cancelAnimationFrame.bind(d);
k.enableFPSCounter = d.Fb.bind(d);
k.disableFPSCounter = d.Cb;
d.gb = c;
k.resolveAnimationFrame = c;
k.cleanup = function() {
v && v.delete();
};
};
var oa = Object.assign({}, k), sa = "./this.program", ta = "", ua, va;
if (ea || ha) {
ha ? ta = self.location.href : "undefined" != typeof document && document.currentScript && (ta = document.currentScript.src), _scriptName && (ta = _scriptName), ta.startsWith("blob:") ? ta = "" : ta = ta.substr(0, ta.replace(/[?#].*/, "").lastIndexOf("/") + 1), ha && (va = a => {
var b = new XMLHttpRequest();
b.open("GET", a, !1);
b.responseType = "arraybuffer";
b.send(null);
return new Uint8Array(b.response);
}), ua = (a, b, c) => {
if (wa(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 za = k.print || console.log.bind(console), Aa = k.printErr || console.error.bind(console);
Object.assign(k, oa);
oa = null;
k.thisProgram && (sa = k.thisProgram);
var Ba;
k.wasmBinary && (Ba = k.wasmBinary);
var Ca, Da = !1, y, A, Ea, Ha, B, E, Ia, Ja;
function Ka() {
var a = Ca.buffer;
k.HEAP8 = y = new Int8Array(a);
k.HEAP16 = Ea = new Int16Array(a);
k.HEAPU8 = A = new Uint8Array(a);
k.HEAPU16 = Ha = new Uint16Array(a);
k.HEAP32 = B = new Int32Array(a);
k.HEAPU32 = E = new Uint32Array(a);
k.HEAPF32 = Ia = new Float32Array(a);
k.HEAPF64 = Ja = new Float64Array(a);
}
var La = [], Ma = [], Na = [];
function Oa() {
var a = k.preRun.shift();
La.unshift(a);
}
var Pa = 0, Qa = null, Ra = null;
function Sa(a) {
k.onAbort?.(a);
a = "Aborted(" + a + ")";
Aa(a);
Da = !0;
a = new WebAssembly.RuntimeError(a + ". Build with -sASSERTIONS for more info.");
ca(a);
throw a;
}
var Ta = a => a.startsWith("data:application/octet-stream;base64,"), wa = a => a.startsWith("file://"), Ua;
function Va(a) {
if (a == Ua && Ba) {
return new Uint8Array(Ba);
}
if (va) {
return va(a);
}
throw "both async and sync fetching of the wasm failed";
}
function Wa(a) {
return Ba ? Promise.resolve().then(() => Va(a)) : new Promise((b, c) => {
ua(a, d => b(new Uint8Array(d)), () => {
try {
b(Va(a));
} catch (d) {
c(d);
}
});
});
}
function Xa(a, b, c) {
return Wa(a).then(d => WebAssembly.instantiate(d, b)).then(c, d => {
Aa(`failed to asynchronously prepare wasm: ${d}`);
Sa(d);
});
}
function Ya(a, b) {
var c = Ua;
return Ba || "function" != typeof WebAssembly.instantiateStreaming || Ta(c) || wa(c) || "function" != typeof fetch ? Xa(c, a, b) : fetch(c, {credentials:"same-origin"}).then(d => WebAssembly.instantiateStreaming(d, a).then(b, function(e) {
Aa(`wasm streaming compile failed: ${e}`);
Aa("falling back to ArrayBuffer instantiation");
return Xa(c, a, b);
}));
}
var Za, $a, db = {486221:(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.I && h.state === f.device_state.started && h.I.resume().then(() => {
ab(h.hb);
}, n => {
console.error("Failed to resume audiocontext", n);
});
}
f.unlock_event_types.map(function(n) {
document.removeEventListener(n, f.unlock, !0);
});
};
f.unlock_event_types.map(function(g) {
document.addEventListener(g, f.unlock, !0);
});
}
window.miniaudio.referenceCount += 1;
return 1;
}, 488399:() => {
"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);
}, 488703:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 488807:() => {
try {
var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
a.close();
return b;
} catch (c) {
return 0;
}
}, 488978:(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.I = new (window.AudioContext || window.webkitAudioContext)(h);
g.I.suspend();
g.state = window.miniaudio.device_state.stopped;
c = 0;
a != window.miniaudio.device_type.playback && (c = b);
g.W = g.I.createScriptProcessor(d, c, b);
g.W.onaudioprocess = function(n) {
if (null == g.na || 0 == g.na.length) {
g.na = new Float32Array(Ia.buffer, e, d * b);
}
if (a == window.miniaudio.device_type.capture || a == window.miniaudio.device_type.duplex) {
for (var m = 0; m < b; m += 1) {
for (var r = n.inputBuffer.getChannelData(m), w = g.na, x = 0; x < d; x += 1) {
w[x * b + m] = r[x];
}
}
bb(f, d, e);
}
if (a == window.miniaudio.device_type.playback || a == window.miniaudio.device_type.duplex) {
for (cb(f, d, e), m = 0; m < n.outputBuffer.numberOfChannels; ++m) {
for (r = n.outputBuffer.getChannelData(m), w = g.na, x = 0; x < d; x += 1) {
r[x] = w[x * b + m];
}
}
} else {
for (m = 0; m < n.outputBuffer.numberOfChannels; ++m) {
n.outputBuffer.getChannelData(m).fill(0.0);
}
}
};
a != window.miniaudio.device_type.capture && a != window.miniaudio.device_type.duplex || navigator.mediaDevices.getUserMedia({audio:!0, video:!1}).then(function(n) {
g.wa = g.I.createMediaStreamSource(n);
g.wa.connect(g.W);
g.W.connect(g.I.destination);
}).catch(function(n) {
console.log("Failed to get user media: " + n);
});
a == window.miniaudio.device_type.playback && g.W.connect(g.I.destination);
g.hb = f;
return window.miniaudio.track_device(g);
}, 491855:a => window.miniaudio.get_device_by_index(a).I.sampleRate, 491928:a => {
a = window.miniaudio.get_device_by_index(a);
void 0 !== a.W && (a.W.onaudioprocess = function() {
}, a.W.disconnect(), a.W = void 0);
void 0 !== a.wa && (a.wa.disconnect(), a.wa = void 0);
a.I.close();
a.I = void 0;
a.hb = void 0;
}, 492328:a => {
window.miniaudio.untrack_device_by_index(a);
}, 492378:a => {
a = window.miniaudio.get_device_by_index(a);
a.I.resume();
a.state = window.miniaudio.device_state.started;
}, 492517:a => {
a = window.miniaudio.get_device_by_index(a);
a.I.suspend();
a.state = window.miniaudio.device_state.stopped;
}}, eb = a => {
for (; 0 < a.length;) {
a.shift()(k);
}
};
function fb() {
var a = B[+gb >> 2];
gb += 4;
return a;
}
var hb = (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;
}, ib = a => {
var b = "/" === a.charAt(0), c = "/" === a.substr(-1);
(a = hb(a.split("/").filter(d => !!d), !b).join("/")) || b || (a = ".");
a && c && (a += "/");
return (b ? "/" : "") + a;
}, jb = 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;
}, kb = a => {
if ("/" === a) {
return "/";
}
a = ib(a);
a = a.replace(/\/$/, "");
var b = a.lastIndexOf("/");
return -1 === b ? a : a.substr(b + 1);
}, lb = () => {
if ("object" == typeof crypto && "function" == typeof crypto.getRandomValues) {
return a => crypto.getRandomValues(a);
}
Sa("initRandomDevice");
}, mb = a => (mb = lb())(a), nb = (...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 = hb(b.split("/").filter(e => !!e), !c).join("/");
return (c ? "/" : "") + b || ".";
}, ob = "undefined" != typeof TextDecoder ? new TextDecoder("utf8") : void 0, pb = (a, b, c) => {
var d = b + c;
for (c = b; a[c] && !(c >= d);) {
++c;
}
if (16 < c - b && a.buffer && ob) {
return ob.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;
}, qb = [], rb = 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;
}, tb = (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 ub(a, b) {
var c = Array(rb(a) + 1);
a = tb(a, c, 0, c.length);
b && (c.length = a);
return c;
}
var vb = [];
function wb(a, b) {
vb[a] = {input:[], F:[], T:b};
xb(a, yb);
}
var yb = {open(a) {
var b = vb[a.node.ta];
if (!b) {
throw new M(43);
}
a.o = b;
a.seekable = !1;
}, close(a) {
a.o.T.la(a.o);
}, la(a) {
a.o.T.la(a.o);
}, read(a, b, c, d) {
if (!a.o || !a.o.T.$a) {
throw new M(60);
}
for (var e = 0, f = 0; f < d; f++) {
try {
var g = a.o.T.$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.T.Ga) {
throw new M(60);
}
try {
for (var e = 0; e < d; e++) {
a.o.T.Ga(a.o, b[c + e]);
}
} catch (f) {
throw new M(29);
}
d && (a.node.timestamp = Date.now());
return e;
},}, zb = {$a() {
a: {
if (!qb.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;
}
qb = ub(a, !0);
}
a = qb.shift();
}
return a;
}, Ga(a, b) {
null === b || 10 === b ? (za(pb(a.F, 0)), a.F = []) : 0 != b && a.F.push(b);
}, la(a) {
a.F && 0 < a.F.length && (za(pb(a.F, 0)), a.F = []);
}, Pb() {
return {uc:25856, wc:5, tc:191, vc:35387, sc:[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,]};
}, Qb() {
return 0;
}, Rb() {
return [24, 80];
},}, Ab = {Ga(a, b) {
null === b || 10 === b ? (Aa(pb(a.F, 0)), a.F = []) : 0 != b && a.F.push(b);
}, la(a) {
a.F && 0 < a.F.length && (Aa(pb(a.F, 0)), a.F = []);
},};
function Bb(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 = {L:null, S() {
return N.createNode(null, "/", 16895, 0);
}, createNode(a, b, c, d) {
if (24576 === (c & 61440) || 4096 === (c & 61440)) {
throw new M(63);
}
N.L || (N.L = {dir:{node:{V:N.i.V, N:N.i.N, ga:N.i.ga, qa:N.i.qa, lb:N.i.lb, qb:N.i.qb, mb:N.i.mb, kb:N.i.kb, xa:N.i.xa}, stream:{Z:N.l.Z}}, file:{node:{V:N.i.V, N:N.i.N}, stream:{Z:N.l.Z, read:N.l.read, write:N.l.write, Qa:N.l.Qa, cb:N.l.cb, fb:N.l.fb}}, link:{node:{V:N.i.V, N:N.i.N, ia:N.i.ia}, stream:{}}, Ta:{node:{V:N.i.V, N:N.i.N}, stream:Cb}});
c = Db(a, b, c, d);
16384 === (c.mode & 61440) ? (c.i = N.L.dir.node, c.l = N.L.dir.stream, c.j = {}) : 32768 === (c.mode & 61440) ? (c.i = N.L.file.node, c.l = N.L.file.stream, c.u = 0, c.j = null) : 40960 === (c.mode & 61440) ? (c.i = N.L.link.node, c.l = N.L.link.stream) : 8192 === (c.mode & 61440) && (c.i = N.L.Ta.node, c.l = N.L.Ta.stream);
c.timestamp = Date.now();
a && (a.j[b] = c, a.timestamp = c.timestamp);
return c;
}, Ac(a) {
return a.j ? a.j.subarray ? a.j.subarray(0, a.u) : new Uint8Array(a.j) : new Uint8Array(0);
}, i:{V(a) {
var b = {};
b.yc = 8192 === (a.mode & 61440) ? a.id : 1;
b.Cc = a.id;
b.mode = a.mode;
b.Gc = 1;
b.uid = 0;
b.Bc = 0;
b.ta = a.ta;
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.qc = new Date(a.timestamp);
b.Fc = new Date(a.timestamp);
b.xc = new Date(a.timestamp);
b.yb = 4096;
b.rc = Math.ceil(b.size / b.yb);
return b;
}, N(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;
}
}
}, ga() {
throw Eb[44];
}, qa(a, b, c, d) {
return N.createNode(a, b, c, d);
}, lb(a, b, c) {
if (16384 === (a.mode & 61440)) {
try {
var d = Fb(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;
}, qb(a, b) {
delete a.j[b];
a.timestamp = Date.now();
}, mb(a, b) {
var c = Fb(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;
}, xa(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 === y.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;
}
}
Bb(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;
}, Qa(a, b, c) {
Bb(a.node, b + c);
a.node.u = Math.max(a.node.u, b + c);
}, cb(a, b, c, d, e) {
if (32768 !== (a.node.mode & 61440)) {
throw new M(43);
}
a = a.node.j;
if (e & 2 || a.buffer !== y.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;
Sa();
b = void 0;
if (!b) {
throw new M(48);
}
y.set(a, b);
} else {
c = !1, b = a.byteOffset;
}
return {m:b, pc:c};
}, fb(a, b, c, d) {
N.l.write(a, b, 0, d, c, !1);
return 0;
},},}, Gb = (a, b) => {
var c = 0;
a && (c |= 365);
b && (c |= 146);
return c;
}, Hb = null, Ib = {}, Jb = [], Kb = 1, Lb = null, Mb = !0, M = class {
constructor(a) {
this.name = "ErrnoError";
this.Y = a;
}
}, Eb = {}, Nb = class {
constructor() {
this.ma = {};
this.node = null;
}
get flags() {
return this.ma.flags;
}
set flags(a) {
this.ma.flags = a;
}
get position() {
return this.ma.position;
}
set position(a) {
this.ma.position = a;
}
}, Ob = class {
constructor(a, b, c, d) {
a ||= this;
this.parent = a;
this.S = a.S;
this.ra = null;
this.id = Kb++;
this.name = b;
this.mode = c;
this.i = {};
this.l = {};
this.ta = 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 Pb(a, b = {}) {
a = nb(a);
if (!a) {
return {path:"", node:null};
}
b = Object.assign({Za:!0, Ia:0}, b);
if (8 < b.Ia) {
throw new M(32);
}
a = a.split("/").filter(g => !!g);
for (var c = Hb, d = "/", e = 0; e < a.length; e++) {
var f = e === a.length - 1;
if (f && b.parent) {
break;
}
c = Fb(c, a[e]);
d = ib(d + "/" + a[e]);
c.ra && (!f || f && b.Za) && (c = c.ra.root);
if (!f || b.Ya) {
for (f = 0; 40960 === (c.mode & 61440);) {
if (c = Qb(d), d = nb(jb(d), c), c = Pb(d, {Ia:b.Ia + 1}).node, 40 < f++) {
throw new M(32);
}
}
}
}
return {path:d, node:c};
}
function Rb(a) {
for (var b;;) {
if (a === a.parent) {
return a = a.S.eb, b ? "/" !== a[a.length - 1] ? `${a}/${b}` : a + b : a;
}
b = b ? `${a.name}/${b}` : a.name;
a = a.parent;
}
}
function Sb(a, b) {
for (var c = 0, d = 0; d < b.length; d++) {
c = (c << 5) - c + b.charCodeAt(d) | 0;
}
return (a + c >>> 0) % Lb.length;
}
function Fb(a, b) {
var c = 16384 === (a.mode & 61440) ? (c = Tb(a, "x")) ? c : a.i.ga ? 0 : 2 : 54;
if (c) {
throw new M(c);
}
for (c = Lb[Sb(a.id, b)]; c; c = c.Xb) {
var d = c.name;
if (c.parent.id === a.id && d === b) {
return c;
}
}
return a.i.ga(a, b);
}
function Db(a, b, c, d) {
a = new Ob(a, b, c, d);
b = Sb(a.parent.id, a.name);
a.Xb = Lb[b];
return Lb[b] = a;
}
function Ub(a) {
var b = ["r", "w", "rw"][a & 3];
a & 512 && (b += "w");
return b;
}
function Tb(a, b) {
if (Mb) {
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 Vb(a, b) {
try {
return Fb(a, b), 20;
} catch (c) {
}
return Tb(a, "wx");
}
function Wb(a) {
a = Jb[a];
if (!a) {
throw new M(8);
}
return a;
}
function Xb(a, b = -1) {
a = Object.assign(new Nb(), a);
if (-1 == b) {
a: {
for (b = 0; 4096 >= b; b++) {
if (!Jb[b]) {
break a;
}
}
throw new M(33);
}
}
a.U = b;
return Jb[b] = a;
}
function Yb(a, b = -1) {
a = Xb(a, b);
a.l?.zc?.(a);
return a;
}
var Cb = {open(a) {
a.l = Ib[a.node.ta].l;
a.l.open?.(a);
}, Z() {
throw new M(70);
},};
function xb(a, b) {
Ib[a] = {l:b};
}
function Zb(a, b) {
var c = "/" === b;
if (c && Hb) {
throw new M(10);
}
if (!c && b) {
var d = Pb(b, {Za:!1});
b = d.path;
d = d.node;
if (d.ra) {
throw new M(10);
}
if (16384 !== (d.mode & 61440)) {
throw new M(54);
}
}
b = {type:a, Ic:{}, eb:b, Wb:[]};
a = a.S(b);
a.S = b;
b.root = a;
c ? Hb = a : d && (d.ra = b, d.S && d.S.Wb.push(b));
}
function ec(a, b, c) {
var d = Pb(a, {parent:!0}).node;
a = kb(a);
if (!a || "." === a || ".." === a) {
throw new M(28);
}
var e = Vb(d, a);
if (e) {
throw new M(e);
}
if (!d.i.qa) {
throw new M(63);
}
return d.i.qa(d, a, b, c);
}
function fc(a) {
return ec(a, 16895, 0);
}
function gc(a, b, c) {
"undefined" == typeof c && (c = b, b = 438);
ec(a, b | 8192, c);
}
function hc(a, b) {
if (!nb(a)) {
throw new M(44);
}
var c = Pb(b, {parent:!0}).node;
if (!c) {
throw new M(44);
}
b = kb(b);
var d = Vb(c, b);
if (d) {
throw new M(d);
}
if (!c.i.xa) {
throw new M(63);
}
c.i.xa(c, b, a);
}
function Qb(a) {
a = Pb(a).node;
if (!a) {
throw new M(44);
}
if (!a.i.ia) {
throw new M(28);
}
return nb(Rb(a.parent), a.i.ia(a));
}
function ic(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 = ib(a);
try {
e = Pb(a, {Ya:!(b & 131072)}).node;
} catch (f) {
}
}
d = !1;
if (b & 64) {
if (e) {
if (b & 128) {
throw new M(20);
}
} else {
e = ec(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" !== Ub(b) || b & 512) ? 31 : Tb(e, Ub(b)) : 44)) {
throw new M(c);
}
if (b & 512 && !d) {
c = e;
c = "string" == typeof c ? Pb(c, {Ya:!0}).node : c;
if (!c.i.N) {
throw new M(63);
}
if (16384 === (c.mode & 61440)) {
throw new M(31);
}
if (32768 !== (c.mode & 61440)) {
throw new M(28);
}
if (d = Tb(c, "w")) {
throw new M(d);
}
c.i.N(c, {size:0, timestamp:Date.now()});
}
b &= -131713;
e = Xb({node:e, path:Rb(e), flags:b, seekable:!0, position:0, l:e.l, jc:[], error:!1});
e.l.open && e.l.open(e);
!k.logReadFiles || b & 1 || (jc ||= {}, a in jc || (jc[a] = 1));
return e;
}
function kc(a, b, c) {
if (null === a.U) {
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.jc = [];
}
var lc;
function mc(a, b, c) {
a = ib("/dev/" + a);
var d = Gb(!!b, !!c);
nc ||= 64;
var e = nc++ << 8 | 0;
xb(e, {open(f) {
f.seekable = !1;
}, close() {
c?.buffer?.length && c(10);
}, read(f, g, h, n) {
for (var m = 0, r = 0; r < n; r++) {
try {
var w = b();
} catch (x) {
throw new M(29);
}
if (void 0 === w && 0 === m) {
throw new M(6);
}
if (null === w || void 0 === w) {
break;
}
m++;
g[h + r] = w;
}
m && (f.node.timestamp = Date.now());
return m;
}, write(f, g, h, n) {
for (var m = 0; m < n; m++) {
try {
c(g[h + m]);
} catch (r) {
throw new M(29);
}
}
n && (f.node.timestamp = Date.now());
return m;
}});
gc(a, d, e);
}
var nc, oc = {}, jc, gb = void 0, pc = (a, b) => Object.defineProperty(b, "name", {value:a}), qc = [], rc = [], O, P = a => {
if (!a) {
throw new O("Cannot use deleted val. handle = " + a);
}
return rc[a];
}, sc = a => {
switch(a) {
case void 0:
return 2;
case null:
return 4;
case !0:
return 6;
case !1:
return 8;
default:
const b = qc.pop() || rc.length;
rc[b] = a;
rc[b + 1] = 1;
return b;
}
}, tc = a => {
var b = Error, c = pc(a, function(d) {
this.name = a;
this.message = d;
d = Error(d).stack;
void 0 !== d && (this.stack = this.toString() + "\n" + d.replace(/^Error(:[^\n]*)?\n/, ""));
});
c.prototype = Object.create(b.prototype);
c.prototype.constructor = c;
c.prototype.toString = function() {
return void 0 === this.message ? this.name : `${this.name}: ${this.message}`;
};
return c;
}, uc, vc, R = a => {
for (var b = ""; A[a];) {
b += vc[A[a++]];
}
return b;
}, wc = [], xc = () => {
for (; wc.length;) {
var a = wc.pop();
a.g.ca = !1;
a["delete"]();
}
}, yc, zc = {}, Ac = (a, b) => {
if (void 0 === b) {
throw new O("ptr should not be undefined");
}
for (; a.B;) {
b = a.ja(b), a = a.B;
}
return b;
}, Bc = {}, Ec = a => {
a = Cc(a);
var b = R(a);
Dc(a);
return b;
}, Fc = (a, b) => {
var c = Bc[a];
if (void 0 === c) {
throw a = `${b} has unknown type ${Ec(a)}`, new O(a);
}
return c;
}, Gc = () => {
}, Hc = !1, Ic = (a, b, c) => {
if (b === c) {
return a;
}
if (void 0 === c.B) {
return null;
}
a = Ic(a, b, c.B);
return null === a ? null : c.Db(a);
}, Jc = {}, Kc = (a, b) => {
b = Ac(a, b);
return zc[b];
}, Lc, Nc = (a, b) => {
if (!b.s || !b.m) {
throw new Lc("makeClassHandle requires ptr and ptrType");
}
if (!!b.H !== !!b.C) {
throw new Lc("Both smartPtrType and smartPtr must be specified");
}
b.count = {value:1};
return Mc(Object.create(a, {g:{value:b, writable:!0,},}));
}, Mc = a => {
if ("undefined" === typeof FinalizationRegistry) {
return Mc = b => b, a;
}
Hc = new FinalizationRegistry(b => {
b = b.g;
--b.count.value;
0 === b.count.value && (b.C ? b.H.M(b.C) : b.s.h.M(b.m));
});
Mc = b => {
var c = b.g;
c.C && Hc.register(b, {g:c}, b);
return b;
};
Gc = b => {
Hc.unregister(b);
};
return Mc(a);
}, Oc = {}, Pc = a => {
for (; a.length;) {
var b = a.pop();
a.pop()(b);
}
};
function Qc(a) {
return this.fromWireType(E[a >> 2]);
}
var Rc = {}, Sc = {}, T = (a, b, c) => {
function d(h) {
h = c(h);
if (h.length !== a.length) {
throw new Lc("Mismatched type converter count");
}
for (var n = 0; n < a.length; ++n) {
Tc(a[n], h[n]);
}
}
a.forEach(function(h) {
Sc[h] = b;
});
var e = Array(b.length), f = [], g = 0;
b.forEach((h, n) => {
Bc.hasOwnProperty(h) ? e[n] = Bc[h] : (f.push(h), Rc.hasOwnProperty(h) || (Rc[h] = []), Rc[h].push(() => {
e[n] = Bc[h];
++g;
g === f.length && d(e);
}));
});
0 === f.length && d(e);
};
function Uc(a, b, c = {}) {
var d = b.name;
if (!a) {
throw new O(`type "${d}" must have a positive integer typeid pointer`);
}
if (Bc.