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