UNPKG

@designcombo/frames

Version:
1,462 lines 249 kB
var He = Object.defineProperty; var pe = (l) => { throw TypeError(l); }; var Ye = (l, r, h) => r in l ? He(l, r, { enumerable: !0, configurable: !0, writable: !0, value: h }) : l[r] = h; var R = (l, r, h) => Ye(l, typeof r != "symbol" ? r + "" : r, h), _e = (l, r, h) => r.has(l) || pe("Cannot " + h); var m = (l, r, h) => (_e(l, r, "read from private field"), h ? h.call(l) : r.get(l)), A = (l, r, h) => r.has(l) ? pe("Cannot add the same private member more than once") : r instanceof WeakSet ? r.add(l) : r.set(l, h), E = (l, r, h, a) => (_e(l, r, "write to private field"), a ? a.call(l, h) : r.set(l, h), h); function Ve(l) { return document.createElement(l); } function We(l, r) { const h = Ve("pre"); h.style.cssText = `margin: 0; ${r}; visibility: hidden; position: fixed;`, h.textContent = l, document.body.appendChild(h); const { width: a, height: f } = h.getBoundingClientRect(); h.remove(), h.style.visibility = "visible"; const d = new Image(); d.width = a, d.height = f; const p = ` <svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${f}"> <foreignObject width="100%" height="100%"> <div xmlns="http://www.w3.org/1999/xhtml">${h.outerHTML}</div> </foreignObject> </svg> `.replace(/\t/g, "").replace(/#/g, "%23"); return d.src = `data:image/svg+xml;charset=utf-8,${p}`, d; } async function tn(l, r) { const h = We(l, r); await new Promise((d) => { h.onload = d; }); const a = new OffscreenCanvas(h.width, h.height), f = a.getContext("2d"); return f == null || f.drawImage(h, 0, 0, h.width, h.height), await createImageBitmap(a); } var Be = (l) => { throw TypeError(l); }, Fe = (l, r, h) => r.has(l) || Be("Cannot " + h), I = (l, r, h) => (Fe(l, r, "read from private field"), h ? h.call(l) : r.get(l)), N = (l, r, h) => r.has(l) ? Be("Cannot add the same private member more than once") : r instanceof WeakSet ? r.add(l) : r.set(l, h), M = (l, r, h, a) => (Fe(l, r, "write to private field"), r.set(l, h), h); const Ie = "KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIHUobil7aWYobj09PSIvIilyZXR1cm57cGFyZW50Om51bGwsbmFtZToiIn07Y29uc3QgZT1uLnNwbGl0KCIvIikuZmlsdGVyKGk9PmkubGVuZ3RoPjApO2lmKGUubGVuZ3RoPT09MCl0aHJvdyBFcnJvcigiSW52YWxpZCBwYXRoIik7Y29uc3QgYT1lW2UubGVuZ3RoLTFdLHI9Ii8iK2Uuc2xpY2UoMCwtMSkuam9pbigiLyIpO3JldHVybntuYW1lOmEscGFyZW50OnJ9fWFzeW5jIGZ1bmN0aW9uIHcobixlKXtjb25zdHtwYXJlbnQ6YSxuYW1lOnJ9PXUobik7aWYoYT09bnVsbClyZXR1cm4gYXdhaXQgbmF2aWdhdG9yLnN0b3JhZ2UuZ2V0RGlyZWN0b3J5KCk7Y29uc3QgaT1hLnNwbGl0KCIvIikuZmlsdGVyKHQ9PnQubGVuZ3RoPjApO3RyeXtsZXQgdD1hd2FpdCBuYXZpZ2F0b3Iuc3RvcmFnZS5nZXREaXJlY3RvcnkoKTtmb3IoY29uc3QgcyBvZiBpKXQ9YXdhaXQgdC5nZXREaXJlY3RvcnlIYW5kbGUocyx7Y3JlYXRlOmUuY3JlYXRlfSk7aWYoZS5pc0ZpbGUpcmV0dXJuIGF3YWl0IHQuZ2V0RmlsZUhhbmRsZShyLHtjcmVhdGU6ZS5jcmVhdGV9KX1jYXRjaCh0KXtpZih0Lm5hbWU9PT0iTm90Rm91bmRFcnJvciIpcmV0dXJuIG51bGw7dGhyb3cgdH19Y29uc3QgZj17fTtzZWxmLm9ubWVzc2FnZT1hc3luYyBuPT57dmFyIGk7Y29uc3R7ZXZ0VHlwZTplLGFyZ3M6YX09bi5kYXRhO2xldCByPWZbYS5maWxlSWRdO3RyeXtsZXQgdDtjb25zdCBzPVtdO2lmKGU9PT0icmVnaXN0ZXIiKXtjb25zdCBsPWF3YWl0IHcoYS5maWxlUGF0aCx7Y3JlYXRlOiEwLGlzRmlsZTohMH0pO2lmKGw9PW51bGwpdGhyb3cgRXJyb3IoYG5vdCBmb3VuZCBmaWxlOiAke2EuZmlsZUlkfWApO3I9YXdhaXQgbC5jcmVhdGVTeW5jQWNjZXNzSGFuZGxlKHttb2RlOmEubW9kZX0pLGZbYS5maWxlSWRdPXJ9ZWxzZSBpZihlPT09ImNsb3NlIilhd2FpdCByLmNsb3NlKCksZGVsZXRlIGZbYS5maWxlSWRdO2Vsc2UgaWYoZT09PSJ0cnVuY2F0ZSIpYXdhaXQgci50cnVuY2F0ZShhLm5ld1NpemUpO2Vsc2UgaWYoZT09PSJ3cml0ZSIpe2NvbnN0e2RhdGE6bCxvcHRzOm99PW4uZGF0YS5hcmdzO3Q9YXdhaXQgci53cml0ZShsLG8pfWVsc2UgaWYoZT09PSJyZWFkIil7Y29uc3R7b2Zmc2V0Omwsc2l6ZTpvfT1uLmRhdGEuYXJncyxnPW5ldyBVaW50OEFycmF5KG8pLGQ9YXdhaXQgci5yZWFkKGcse2F0Omx9KSxjPWcuYnVmZmVyO3Q9ZD09PW8/YzooKGk9Yy50cmFuc2Zlcik9PW51bGw/dm9pZCAwOmkuY2FsbChjLGQpKT8/Yy5zbGljZSgwLGQpLHMucHVzaCh0KX1lbHNlIGU9PT0iZ2V0U2l6ZSI/dD1hd2FpdCByLmdldFNpemUoKTplPT09ImZsdXNoIiYmYXdhaXQgci5mbHVzaCgpO3NlbGYucG9zdE1lc3NhZ2Uoe2V2dFR5cGU6ImNhbGxiYWNrIixjYklkOm4uZGF0YS5jYklkLHJldHVyblZhbDp0fSxzKX1jYXRjaCh0KXtjb25zdCBzPXQ7c2VsZi5wb3N0TWVzc2FnZSh7ZXZ0VHlwZToidGhyb3dFcnJvciIsY2JJZDpuLmRhdGEuY2JJZCxlcnJNc2c6cy5uYW1lKyI6ICIrcy5tZXNzYWdlK2AKYCtKU09OLnN0cmluZ2lmeShuLmRhdGEpfSl9fX0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPW9wZnMtd29ya2VyLUY0UldscWNfLmpzLm1hcAo=", Ze = (l) => Uint8Array.from(atob(l), (r) => r.charCodeAt(0)), ge = typeof self < "u" && self.Blob && new Blob([Ze(Ie)], { type: "text/javascript;charset=utf-8" }); function Xe(l) { let r; try { if (r = ge && (self.URL || self.webkitURL).createObjectURL(ge), !r) throw ""; const h = new Worker(r, { name: l == null ? void 0 : l.name }); return h.addEventListener("error", () => { (self.URL || self.webkitURL).revokeObjectURL(r); }), h; } catch { return new Worker( "data:text/javascript;base64," + Ie, { name: l == null ? void 0 : l.name } ); } finally { r && (self.URL || self.webkitURL).revokeObjectURL(r); } } async function je(l, r, h) { const a = Ke(); return await a("register", { fileId: l, filePath: r, mode: h }), { read: async (f, d) => await a("read", { fileId: l, offset: f, size: d }), write: async (f, d) => await a( "write", { fileId: l, data: f, opts: d }, [ArrayBuffer.isView(f) ? f.buffer : f] ), close: async () => await a("close", { fileId: l }), truncate: async (f) => await a("truncate", { fileId: l, newSize: f }), getSize: async () => await a("getSize", { fileId: l }), flush: async () => await a("flush", { fileId: l }) }; } const Yt = []; let ie = 0; function Ke() { if (Yt.length < 3) { const r = l(); return Yt.push(r), r; } else { const r = Yt[ie]; return ie = (ie + 1) % Yt.length, r; } function l() { const r = new Xe(); let h = 0, a = {}; return r.onmessage = ({ data: f }) => { var d, p; f.evtType === "callback" ? (d = a[f.cbId]) == null || d.resolve(f.returnVal) : f.evtType === "throwError" && ((p = a[f.cbId]) == null || p.reject(Error(f.errMsg))), delete a[f.cbId]; }, async function(f, d, p = []) { h += 1; const n = new Promise((v, b) => { a[h] = { resolve: v, reject: b }; }); return r.postMessage( { cbId: h, evtType: f, args: d }, p ), n; }; } } function te(l) { if (l === "/") return { parent: null, name: "" }; const r = l.split("/").filter((f) => f.length > 0); if (r.length === 0) throw Error("Invalid path"); const h = r[r.length - 1], a = "/" + r.slice(0, -1).join("/"); return { name: h, parent: a }; } async function ot(l, r) { const { parent: h, name: a } = te(l); if (h == null) return await navigator.storage.getDirectory(); const f = h.split("/").filter((d) => d.length > 0); try { let d = await navigator.storage.getDirectory(); for (const p of f) d = await d.getDirectoryHandle(p, { create: r.create }); return r.isFile ? await d.getFileHandle(a, { create: r.create }) : await d.getDirectoryHandle(a, { create: r.create }); } catch (d) { if (d.name === "NotFoundError") return null; throw d; } } async function Ce(l) { const { parent: r, name: h } = te(l); if (r == null) { const f = await navigator.storage.getDirectory(); for await (const d of f.keys()) await f.removeEntry(d, { recursive: !0 }); return; } const a = await ot(r, { create: !1, isFile: !1 }); a != null && await a.removeEntry(h, { recursive: !0 }); } function se(l, r) { return `${l}/${r}`.replace("//", "/"); } function vt(l) { return new ze(l); } var H, Vt, At; class ze { constructor(r) { N(this, H), N(this, Vt), N(this, At), M(this, H, r); const { parent: h, name: a } = te(r); M(this, Vt, a), M(this, At, h); } get kind() { return "dir"; } get name() { return I(this, Vt); } get path() { return I(this, H); } get parent() { return I(this, At) == null ? null : vt(I(this, At)); } /** * Creates the directory. * return A promise that resolves when the directory is created. */ async create() { return await ot(I(this, H), { create: !0, isFile: !1 }), vt(I(this, H)); } /** * Checks if the directory exists. * return A promise that resolves to true if the directory exists, otherwise false. */ async exists() { return await ot(I(this, H), { create: !1, isFile: !1 }) instanceof FileSystemDirectoryHandle; } /** * Removes the directory. * return A promise that resolves when the directory is removed. */ async remove() { for (const r of await this.children()) try { await r.remove(); } catch (h) { console.warn(h); } try { await Ce(I(this, H)); } catch (r) { console.warn(r); } } /** * Retrieves the children of the directory. * return A promise that resolves to an array of objects representing the children. */ async children() { const r = await ot(I(this, H), { create: !1, isFile: !1 }); if (r == null) return []; const h = []; for await (const a of r.values()) h.push((a.kind === "file" ? _t : vt)(se(I(this, H), a.name))); return h; } /** * If the dest folder exists, copy the current directory into the dest folder; * if the dest folder does not exist, rename the current directory to dest name. */ async copyTo(r) { if (!await this.exists()) throw Error(`dir ${this.path} not exists`); const h = await r.exists() ? vt(se(r.path, this.name)) : r; return await h.create(), await Promise.all((await this.children()).map((a) => a.copyTo(h))), h; } /** * move directory, copy then remove current */ async moveTo(r) { const h = await this.copyTo(r); return await this.remove(), h; } } H = /* @__PURE__ */ new WeakMap(), Vt = /* @__PURE__ */ new WeakMap(), At = /* @__PURE__ */ new WeakMap(); const ye = /* @__PURE__ */ new Map(); function _t(l, r = "rw") { if (r === "rw") { const h = ye.get(l) ?? new jt(l, r); return ye.set(l, h), h; } return new jt(l, r); } async function Ct(l, r, h = { overwrite: !0 }) { if (r instanceof jt) { await Ct(l, await r.stream(), h); return; } const a = await (l instanceof jt ? l : _t(l, "rw")).createWriter(); try { if (h.overwrite && await a.truncate(0), r instanceof ReadableStream) { const f = r.getReader(); for (; ; ) { const { done: d, value: p } = await f.read(); if (d) break; await a.write(p); } } else await a.write(r); } catch (f) { throw f; } finally { await a.close(); } } let Qe = 0; const Je = () => ++Qe; var Y, Bt, Wt, Ft, Zt, it, Xt, It; const $e = class Te { constructor(r, h) { N(this, Y), N(this, Bt), N(this, Wt), N(this, Ft), N(this, Zt), N(this, it, 0), N(this, Xt, /* @__PURE__ */ (() => { let d = null; return () => (M(this, it, I(this, it) + 1), d ?? (d = new Promise(async (p, n) => { try { const v = await je( I(this, Zt), I(this, Y), I(this, Ft) ); p([ v, async () => { M(this, it, I(this, it) - 1), !(I(this, it) > 0) && (d = null, await v.close()); } ]); } catch (v) { n(v); } }))); })()), N(this, It, !1), M(this, Zt, Je()), M(this, Y, r), M(this, Ft, { r: "read-only", rw: "readwrite", "rw-unsafe": "readwrite-unsafe" }[h]); const { parent: a, name: f } = te(r); M(this, Wt, f), M(this, Bt, a); } get kind() { return "file"; } get path() { return I(this, Y); } get name() { return I(this, Wt); } get parent() { return I(this, Bt) == null ? null : vt(I(this, Bt)); } /** * Random write to file */ async createWriter() { if (I(this, Ft) === "read-only") throw Error("file is read-only"); if (I(this, It)) throw Error("Other writer have not been closed"); M(this, It, !0); const r = new TextEncoder(), [h, a] = await I(this, Xt).call(this); let f = await h.getSize(), d = !1; return { write: async (p, n = {}) => { if (d) throw Error("Writer is closed"); const v = typeof p == "string" ? r.encode(p) : p, b = n.at ?? f, y = v.byteLength; return f = b + y, await h.write(v, { at: b }); }, truncate: async (p) => { if (d) throw Error("Writer is closed"); await h.truncate(p), f > p && (f = p); }, flush: async () => { if (d) throw Error("Writer is closed"); await h.flush(); }, close: async () => { if (d) throw Error("Writer is closed"); d = !0, M(this, It, !1), await a(); } }; } /** * Random access to file */ async createReader() { const [r, h] = await I(this, Xt).call(this); let a = !1, f = 0; return { read: async (d, p = {}) => { if (a) throw Error("Reader is closed"); const n = p.at ?? f, v = await r.read(n, d); return f = n + v.byteLength, v; }, getSize: async () => { if (a) throw Error("Reader is closed"); return await r.getSize(); }, close: async () => { a || (a = !0, await h()); } }; } async text() { return new TextDecoder().decode(await this.arrayBuffer()); } async arrayBuffer() { const r = await ot(I(this, Y), { create: !1, isFile: !0 }); return r == null ? new ArrayBuffer(0) : (await r.getFile()).arrayBuffer(); } async stream() { const r = await this.getOriginFile(); return r == null ? new ReadableStream({ pull: (h) => { h.close(); } }) : r.stream(); } async getOriginFile() { var r; return (r = await ot(I(this, Y), { create: !1, isFile: !0 })) == null ? void 0 : r.getFile(); } async getSize() { const r = await ot(I(this, Y), { create: !1, isFile: !0 }); return r == null ? 0 : (await r.getFile()).size; } async exists() { return await ot(I(this, Y), { create: !1, isFile: !0 }) instanceof FileSystemFileHandle; } async remove() { if (I(this, it)) throw Error("exists unclosed reader/writer"); await Ce(I(this, Y)); } /** * If the target is a file, use current overwrite the target; * if the target is a folder, copy the current file into that folder. */ async copyTo(r) { if (!await this.exists()) throw Error(`file ${this.path} not exists`); if (r instanceof Te) return _t(r.path) === this ? this : (await Ct(r.path, this), _t(r.path)); if (r instanceof ze) return await this.copyTo(_t(se(r.path, this.name))); throw Error("Illegal target type"); } /** * move file, copy then remove current */ async moveTo(r) { const h = await this.copyTo(r); return await this.remove(), h; } }; Y = /* @__PURE__ */ new WeakMap(), Bt = /* @__PURE__ */ new WeakMap(), Wt = /* @__PURE__ */ new WeakMap(), Ft = /* @__PURE__ */ new WeakMap(), Zt = /* @__PURE__ */ new WeakMap(), it = /* @__PURE__ */ new WeakMap(), Xt = /* @__PURE__ */ new WeakMap(), It = /* @__PURE__ */ new WeakMap(); let jt = $e; const he = "/.opfs-tools-temp-dir"; async function Pe(l) { try { if (l.kind === "file") { if (!await l.exists()) return !0; const r = await l.createWriter(); await r.truncate(0), await r.close(), await l.remove(); } else await l.remove(); return !0; } catch (r) { return console.warn(r), !1; } } function qe() { setInterval(async () => { for (const l of await vt(he).children()) { const r = /^\d+-(\d+)$/.exec(l.name); (r == null || Date.now() - Number(r[1]) > 2592e5) && await Pe(l); } }, 60 * 1e3); } const re = []; let me = !1; async function ti() { if (globalThis.localStorage == null) return; const l = "OPFS_TOOLS_EXPIRES_TMP_FILES"; me || (me = !0, globalThis.addEventListener("unload", () => { re.length !== 0 && localStorage.setItem( l, `${localStorage.getItem(l) ?? ""},${re.join(",")}` ); })); let r = localStorage.getItem(l) ?? ""; for (const h of r.split(",")) h.length !== 0 && await Pe(_t(`${he}/${h}`)) && (r = r.replace(h, "")); localStorage.setItem(l, r.replace(/,{2,}/g, ",")); } (async function() { var l; globalThis.__opfs_tools_tmpfile_init__ !== !0 && (globalThis.__opfs_tools_tmpfile_init__ = !0, !(globalThis.FileSystemDirectoryHandle == null || globalThis.FileSystemFileHandle == null || ((l = globalThis.navigator) == null ? void 0 : l.storage.getDirectory) == null) && (qe(), await ti())); })(); function Kt() { const l = `${Math.random().toString().slice(2)}-${Date.now()}`; return re.push(l), _t(`${he}/${l}`); } function ei(l) { return l instanceof Error ? String(l) : typeof l == "object" ? JSON.stringify(l, (r, h) => h instanceof Error ? String(h) : h) : String(l); } function ii() { const l = /* @__PURE__ */ new Date(); return `${l.getHours()}:${l.getMinutes()}:${l.getSeconds()}.${l.getMilliseconds()}`; } let Le = 1; const ke = Kt(); let gt = null; const ve = ["debug", "info", "warn", "error"].reduce( (l, r, h) => Object.assign(l, { [r]: (...a) => { Le <= h && (console[r](...a), gt == null || gt.write( `[${r}][${ii()}] ${a.map((f) => ei(f)).join(" ")} ` )); } }), {} ), Gt = /* @__PURE__ */ new Map(), z = { setLogLevel: (l) => { Le = Gt.get(l) ?? 1; }, ...ve, create: (l) => Object.fromEntries( Object.entries(ve).map(([r, h]) => [ r, (...a) => h(l, ...a) ]) ), async dump() { return await si, await (gt == null ? void 0 : gt.flush()), await ke.text(); } }; Gt.set(z.debug, 0); Gt.set(z.info, 1); Gt.set(z.warn, 2); Gt.set(z.error, 3); async function ni() { try { gt = await ke.createWriter(), z.info(navigator.userAgent), z.info("date: " + (/* @__PURE__ */ new Date()).toLocaleDateString()); } catch (l) { if (!(l instanceof Error)) throw l; if (l.message.includes("createSyncAccessHandle is not a function")) console.warn(l); else throw l; } } const si = globalThis.navigator == null ? null : ni(), ri = () => { let l, r = 16.6; self.onmessage = (h) => { h.data.event === "start" && (self.clearInterval(l), l = self.setInterval(() => { self.postMessage({}); }, r)), h.data.event === "stop" && self.clearInterval(l); }; }, ai = () => { const l = new Blob([`(${ri.toString()})()`]), r = URL.createObjectURL(l); return new Worker(r); }, mt = /* @__PURE__ */ new Map(); let ae = 1, nt = null; globalThis.Worker != null && (nt = ai(), nt.onmessage = () => { ae += 1; for (const [l, r] of mt) if (ae % l === 0) for (const h of r) h(); }); const De = (l, r) => { const h = Math.round(r / 16.6), a = mt.get(h) ?? /* @__PURE__ */ new Set(); return a.add(l), mt.set(h, a), mt.size === 1 && a.size === 1 && (nt == null || nt.postMessage({ event: "start" })), () => { a.delete(l), a.size === 0 && mt.delete(h), mt.size === 0 && (ae = 0, nt == null || nt.postMessage({ event: "stop" })); }; }; class oi { /** * @param {number} scaleFrom the length of the original array. * @param {number} scaleTo The length of the new array. * @param {?Object} details The extra configuration, if needed. */ constructor(r, h, a) { this.length_ = r, this.scaleFactor_ = (r - 1) / h, this.interpolate = this.cubic, a.method === "point" ? this.interpolate = this.point : a.method === "linear" ? this.interpolate = this.linear : a.method === "sinc" && (this.interpolate = this.sinc), this.tangentFactor_ = 1 - Math.max(0, Math.min(1, a.tension || 0)), this.sincFilterSize_ = a.sincFilterSize || 1, this.kernel_ = li(a.sincWindow || hi); } /** * @param {number} t The index to interpolate. * @param {Array|TypedArray} samples the original array. * @return {number} The interpolated value. */ point(r, h) { return this.getClippedInput_(Math.round(this.scaleFactor_ * r), h); } /** * @param {number} t The index to interpolate. * @param {Array|TypedArray} samples the original array. * @return {number} The interpolated value. */ linear(r, h) { r = this.scaleFactor_ * r; let a = Math.floor(r); return r -= a, (1 - r) * this.getClippedInput_(a, h) + r * this.getClippedInput_(a + 1, h); } /** * @param {number} t The index to interpolate. * @param {Array|TypedArray} samples the original array. * @return {number} The interpolated value. */ cubic(r, h) { r = this.scaleFactor_ * r; let a = Math.floor(r), f = [this.getTangent_(a, h), this.getTangent_(a + 1, h)], d = [ this.getClippedInput_(a, h), this.getClippedInput_(a + 1, h) ]; r -= a; let p = r * r, n = r * p; return (2 * n - 3 * p + 1) * d[0] + (n - 2 * p + r) * f[0] + (-2 * n + 3 * p) * d[1] + (n - p) * f[1]; } /** * @param {number} t The index to interpolate. * @param {Array|TypedArray} samples the original array. * @return {number} The interpolated value. */ sinc(r, h) { r = this.scaleFactor_ * r; let a = Math.floor(r), f = a - this.sincFilterSize_ + 1, d = a + this.sincFilterSize_, p = 0; for (let n = f; n <= d; n++) p += this.kernel_(r - n) * this.getClippedInput_(n, h); return p; } /** * @param {number} k The scaled index to interpolate. * @param {Array|TypedArray} samples the original array. * @return {number} The tangent. * @private */ getTangent_(r, h) { return this.tangentFactor_ * (this.getClippedInput_(r + 1, h) - this.getClippedInput_(r - 1, h)) / 2; } /** * @param {number} t The scaled index to interpolate. * @param {Array|TypedArray} samples the original array. * @return {number} The interpolated value. * @private */ getClippedInput_(r, h) { return 0 <= r && r < this.length_ ? h[r] : 0; } } function hi(l) { return Math.exp(-l / 2 * l / 2); } function li(l) { return function(r) { return fi(r) * l(r); }; } function fi(l) { return l === 0 ? 1 : Math.sin(Math.PI * l) / (Math.PI * l); } class di { /** * @param {number} order The order of the filter. * @param {number} sampleRate The sample rate. * @param {number} cutOff The cut off frequency. */ constructor(r, h, a) { let f = 2 * Math.PI * a / h, d = 0; this.filters = []; for (let p = 0; p <= r; p++) p - r / 2 === 0 ? this.filters[p] = f : (this.filters[p] = Math.sin(f * (p - r / 2)) / (p - r / 2), this.filters[p] *= 0.54 - 0.46 * Math.cos(2 * Math.PI * p / r)), d = d + this.filters[p]; for (let p = 0; p <= r; p++) this.filters[p] /= d; this.z = this.initZ_(); } /** * @param {number} sample A sample of a sequence. * @return {number} */ filter(r) { this.z.buf[this.z.pointer] = r; let h = 0; for (let a = 0, f = this.z.buf.length; a < f; a++) h += this.filters[a] * this.z.buf[(this.z.pointer + a) % this.z.buf.length]; return this.z.pointer = (this.z.pointer + 1) % this.z.buf.length, h; } /** * Reset the filter. */ reset() { this.z = this.initZ_(); } /** * Return the default value for z. * @private */ initZ_() { let r = []; for (let h = 0; h < this.filters.length - 1; h++) r.push(0); return { buf: r, pointer: 0 }; } } class ci { /** * @param {number} order The order of the filter. * @param {number} sampleRate The sample rate. * @param {number} cutOff The cut off frequency. */ constructor(r, h, a) { let f = []; for (let d = 0; d < r; d++) f.push(this.getCoeffs_({ Fs: h, Fc: a, Q: 0.5 / Math.sin(Math.PI / (r * 2) * (d + 0.5)) })); this.stages = []; for (let d = 0; d < f.length; d++) this.stages[d] = { b0: f[d].b[0], b1: f[d].b[1], b2: f[d].b[2], a1: f[d].a[0], a2: f[d].a[1], k: f[d].k, z: [0, 0] }; } /** * @param {number} sample A sample of a sequence. * @return {number} */ filter(r) { let h = r; for (let a = 0, f = this.stages.length; a < f; a++) h = this.runStage_(a, h); return h; } getCoeffs_(r) { let h = {}; h.z = [0, 0], h.a = [], h.b = []; let a = this.preCalc_(r, h); return h.k = 1, h.b.push((1 - a.cw) / (2 * a.a0)), h.b.push(2 * h.b[0]), h.b.push(h.b[0]), h; } preCalc_(r, h) { let a = {}, f = 2 * Math.PI * r.Fc / r.Fs; return a.alpha = Math.sin(f) / (2 * r.Q), a.cw = Math.cos(f), a.a0 = 1 + a.alpha, h.a0 = a.a0, h.a.push(-2 * a.cw / a.a0), h.k = 1, h.a.push((1 - a.alpha) / a.a0), a; } runStage_(r, h) { let a = h * this.stages[r].k - this.stages[r].a1 * this.stages[r].z[0] - this.stages[r].a2 * this.stages[r].z[1], f = this.stages[r].b0 * a + this.stages[r].b1 * this.stages[r].z[0] + this.stages[r].b2 * this.stages[r].z[1]; return this.stages[r].z[1] = this.stages[r].z[0], this.stages[r].z[0] = a, f; } /** * Reset the filter. */ reset() { for (let r = 0; r < this.stages.length; r++) this.stages[r].z = [0, 0]; } } const ui = { point: !1, linear: !1, cubic: !0, sinc: !0 }, we = { IIR: 16, FIR: 71 }, pi = { IIR: ci, FIR: di }; function _i(l, r, h, a = {}) { let f = (h - r) / r + 1, d = new Float64Array(l.length * f); a.method = a.method || "cubic"; let p = new oi( l.length, d.length, { method: a.method, tension: a.tension || 0, sincFilterSize: a.sincFilterSize || 6, sincWindow: a.sincWindow || void 0 } ); if (a.LPF === void 0 && (a.LPF = ui[a.method]), a.LPF) { a.LPFType = a.LPFType || "IIR"; const n = pi[a.LPFType]; if (h > r) { let v = new n( a.LPFOrder || we[a.LPFType], h, r / 2 ); gi( l, d, p, v ); } else { let v = new n( a.LPFOrder || we[a.LPFType], r, h / 2 ); yi( l, d, p, v ); } } else Re(l, d, p); return d; } function Re(l, r, h) { for (let a = 0, f = r.length; a < f; a++) r[a] = h.interpolate(a, l); } function gi(l, r, h, a) { for (let f = 0, d = r.length; f < d; f++) r[f] = a.filter(h.interpolate(f, l)); a.reset(); for (let f = r.length - 1; f >= 0; f--) r[f] = a.filter(r[f]); } function yi(l, r, h, a) { for (let f = 0, d = l.length; f < d; f++) l[f] = a.filter(l[f]); a.reset(); for (let f = l.length - 1; f >= 0; f--) l[f] = a.filter(l[f]); Re(l, r, h); } function Me(l) { const r = new Float32Array( l.map((a) => a.length).reduce((a, f) => a + f) ); let h = 0; for (const a of l) r.set(a, h), h += a.length; return r; } function mi(l) { const r = []; for (let h = 0; h < l.length; h += 1) for (let a = 0; a < l[h].length; a += 1) r[a] == null && (r[a] = []), r[a].push(l[h][a]); return r.map(Me); } function le(l) { if (l.format === "f32-planar") { const r = []; for (let h = 0; h < l.numberOfChannels; h += 1) { const a = l.allocationSize({ planeIndex: h }), f = new ArrayBuffer(a); l.copyTo(f, { planeIndex: h }), r.push(new Float32Array(f)); } return r; } else if (l.format === "f32") { const r = new ArrayBuffer(l.allocationSize({ planeIndex: 0 })); return l.copyTo(r, { planeIndex: 0 }), wi(new Float32Array(r), l.numberOfChannels); } else if (l.format === "s16") { const r = new ArrayBuffer(l.allocationSize({ planeIndex: 0 })); return l.copyTo(r, { planeIndex: 0 }), vi(new Int16Array(r), l.numberOfChannels); } throw Error("Unsupported audio data format"); } function vi(l, r) { const h = l.length / r, a = Array.from( { length: r }, () => new Float32Array(h) ); for (let f = 0; f < h; f++) for (let d = 0; d < r; d++) { const p = l[f * r + d]; a[d][f] = p / 32768; } return a; } function wi(l, r) { const h = l.length / r, a = Array.from( { length: r }, () => new Float32Array(h) ); for (let f = 0; f < h; f++) for (let d = 0; d < r; d++) a[d][f] = l[f * r + d]; return a; } function Oe(l) { return Array(l.numberOfChannels).fill(0).map((r, h) => l.getChannelData(h)); } function en(l, r) { const h = new Float32Array( Me(le(l)) ).map((f) => f * r), a = new AudioData({ sampleRate: l.sampleRate, numberOfChannels: l.numberOfChannels, timestamp: l.timestamp, format: l.format, numberOfFrames: l.numberOfFrames, data: h }); return l.close(), a; } async function nn(l, r) { var p; const h = { type: r, data: l }, a = new ImageDecoder(h); await Promise.all([a.completed, a.tracks.ready]); let f = ((p = a.tracks.selectedTrack) == null ? void 0 : p.frameCount) ?? 1; const d = []; for (let n = 0; n < f; n += 1) d.push((await a.decode({ frameIndex: n })).image); return d; } function be(l) { var a, f; const r = Math.max(...l.map((d) => { var p; return ((p = d[0]) == null ? void 0 : p.length) ?? 0; })), h = new Float32Array(r * 2); for (let d = 0; d < r; d++) { let p = 0, n = 0; for (let v = 0; v < l.length; v++) { const b = ((a = l[v][0]) == null ? void 0 : a[d]) ?? 0, y = ((f = l[v][1]) == null ? void 0 : f[d]) ?? b; p += b, n += y; } h[d] = p, h[d + r] = n; } return h; } async function bi(l, r, h) { const a = l.length, f = Array(h.chanCount).fill(0).map(() => new Float32Array(0)); if (a === 0) return f; const d = Math.max(...l.map((b) => b.length)); if (d === 0) return f; if (globalThis.OfflineAudioContext == null) return l.map( (b) => new Float32Array( _i(b, r, h.rate, { method: "sinc", LPF: !1 }) ) ); const p = new globalThis.OfflineAudioContext( h.chanCount, d * h.rate / r, h.rate ), n = p.createBufferSource(), v = p.createBuffer(a, d, r); return l.forEach((b, y) => v.copyToChannel(b, y)), n.buffer = v, n.connect(p.destination), n.start(), Oe(await p.startRendering()); } function Ne(l) { return new Promise((r) => { const h = De(() => { h(), r(); }, l); }); } function Si(l, r, h) { const a = h - r, f = new Float32Array(a); let d = 0; for (; d < a; ) f[d] = l[(r + d) % l.length], d += 1; return f; } function fe(l, r) { let h = !1; async function a() { const f = l.getReader(); for (; !h; ) { const { value: d, done: p } = await f.read(); if (p) { r.onDone(); return; } await r.onChunk(d); } f.releaseLock(), await l.cancel(); } return a().catch(z.error), () => { h = !0; }; } function xi(l) { return l && l.__esModule && Object.prototype.hasOwnProperty.call(l, "default") ? l.default : l; } var Ge = {}; (function(l) { var r = /* @__PURE__ */ function() { var t = /* @__PURE__ */ new Date(), e = 4, i = 3, s = 2, o = 1, c = e, u = { setLogLevel: function(_) { _ == this.debug ? c = o : _ == this.info ? c = s : _ == this.warn ? c = i : (_ == this.error, c = e); }, debug: function(_, g) { console.debug === void 0 && (console.debug = console.log), o >= c && console.debug("[" + r.getDurationString(/* @__PURE__ */ new Date() - t, 1e3) + "]", "[" + _ + "]", g); }, log: function(_, g) { this.debug(_.msg); }, info: function(_, g) { s >= c && console.info("[" + r.getDurationString(/* @__PURE__ */ new Date() - t, 1e3) + "]", "[" + _ + "]", g); }, warn: function(_, g) { i >= c && console.warn("[" + r.getDurationString(/* @__PURE__ */ new Date() - t, 1e3) + "]", "[" + _ + "]", g); }, error: function(_, g) { e >= c && console.error("[" + r.getDurationString(/* @__PURE__ */ new Date() - t, 1e3) + "]", "[" + _ + "]", g); } }; return u; }(); r.getDurationString = function(t, e) { var i; function s(w, S) { for (var U = "" + w, C = U.split("."); C[0].length < S; ) C[0] = "0" + C[0]; return C.join("."); } t < 0 ? (i = !0, t = -t) : i = !1; var o = e || 1, c = t / o, u = Math.floor(c / 3600); c -= u * 3600; var _ = Math.floor(c / 60); c -= _ * 60; var g = c * 1e3; return c = Math.floor(c), g -= c * 1e3, g = Math.floor(g), (i ? "-" : "") + u + ":" + s(_, 2) + ":" + s(c, 2) + "." + s(g, 3); }, r.printRanges = function(t) { var e = t.length; if (e > 0) { for (var i = "", s = 0; s < e; s++) s > 0 && (i += ","), i += "[" + r.getDurationString(t.start(s)) + "," + r.getDurationString(t.end(s)) + "]"; return i; } else return "(empty)"; }, l.Log = r; var h = function(t) { if (t instanceof ArrayBuffer) this.buffer = t, this.dataview = new DataView(t); else throw "Needs an array buffer"; this.position = 0; }; h.prototype.getPosition = function() { return this.position; }, h.prototype.getEndPosition = function() { return this.buffer.byteLength; }, h.prototype.getLength = function() { return this.buffer.byteLength; }, h.prototype.seek = function(t) { var e = Math.max(0, Math.min(this.buffer.byteLength, t)); return this.position = isNaN(e) || !isFinite(e) ? 0 : e, !0; }, h.prototype.isEos = function() { return this.getPosition() >= this.getEndPosition(); }, h.prototype.readAnyInt = function(t, e) { var i = 0; if (this.position + t <= this.buffer.byteLength) { switch (t) { case 1: e ? i = this.dataview.getInt8(this.position) : i = this.dataview.getUint8(this.position); break; case 2: e ? i = this.dataview.getInt16(this.position) : i = this.dataview.getUint16(this.position); break; case 3: if (e) throw "No method for reading signed 24 bits values"; i = this.dataview.getUint8(this.position) << 16, i |= this.dataview.getUint8(this.position + 1) << 8, i |= this.dataview.getUint8(this.position + 2); break; case 4: e ? i = this.dataview.getInt32(this.position) : i = this.dataview.getUint32(this.position); break; case 8: if (e) throw "No method for reading signed 64 bits values"; i = this.dataview.getUint32(this.position) << 32, i |= this.dataview.getUint32(this.position + 4); break; default: throw "readInt method not implemented for size: " + t; } return this.position += t, i; } else throw "Not enough bytes in buffer"; }, h.prototype.readUint8 = function() { return this.readAnyInt(1, !1); }, h.prototype.readUint16 = function() { return this.readAnyInt(2, !1); }, h.prototype.readUint24 = function() { return this.readAnyInt(3, !1); }, h.prototype.readUint32 = function() { return this.readAnyInt(4, !1); }, h.prototype.readUint64 = function() { return this.readAnyInt(8, !1); }, h.prototype.readString = function(t) { if (this.position + t <= this.buffer.byteLength) { for (var e = "", i = 0; i < t; i++) e += String.fromCharCode(this.readUint8()); return e; } else throw "Not enough bytes in buffer"; }, h.prototype.readCString = function() { for (var t = []; ; ) { var e = this.readUint8(); if (e !== 0) t.push(e); else break; } return String.fromCharCode.apply(null, t); }, h.prototype.readInt8 = function() { return this.readAnyInt(1, !0); }, h.prototype.readInt16 = function() { return this.readAnyInt(2, !0); }, h.prototype.readInt32 = function() { return this.readAnyInt(4, !0); }, h.prototype.readInt64 = function() { return this.readAnyInt(8, !1); }, h.prototype.readUint8Array = function(t) { for (var e = new Uint8Array(t), i = 0; i < t; i++) e[i] = this.readUint8(); return e; }, h.prototype.readInt16Array = function(t) { for (var e = new Int16Array(t), i = 0; i < t; i++) e[i] = this.readInt16(); return e; }, h.prototype.readUint16Array = function(t) { for (var e = new Int16Array(t), i = 0; i < t; i++) e[i] = this.readUint16(); return e; }, h.prototype.readUint32Array = function(t) { for (var e = new Uint32Array(t), i = 0; i < t; i++) e[i] = this.readUint32(); return e; }, h.prototype.readInt32Array = function(t) { for (var e = new Int32Array(t), i = 0; i < t; i++) e[i] = this.readInt32(); return e; }, l.MP4BoxStream = h; var a = function(t, e, i) { this._byteOffset = e || 0, t instanceof ArrayBuffer ? this.buffer = t : typeof t == "object" ? (this.dataView = t, e && (this._byteOffset += e)) : this.buffer = new ArrayBuffer(t || 0), this.position = 0, this.endianness = i ?? a.LITTLE_ENDIAN; }; a.prototype = {}, a.prototype.getPosition = function() { return this.position; }, a.prototype._realloc = function(t) { if (this._dynamicSize) { var e = this._byteOffset + this.position + t, i = this._buffer.byteLength; if (e <= i) { e > this._byteLength && (this._byteLength = e); return; } for (i < 1 && (i = 1); e > i; ) i *= 2; var s = new ArrayBuffer(i), o = new Uint8Array(this._buffer), c = new Uint8Array(s, 0, o.length); c.set(o), this.buffer = s, this._byteLength = e; } }, a.prototype._trimAlloc = function() { if (this._byteLength != this._buffer.byteLength) { var t = new ArrayBuffer(this._byteLength), e = new Uint8Array(t), i = new Uint8Array(this._buffer, 0, e.length); e.set(i), this.buffer = t; } }, a.BIG_ENDIAN = !1, a.LITTLE_ENDIAN = !0, a.prototype._byteLength = 0, Object.defineProperty( a.prototype, "byteLength", { get: function() { return this._byteLength - this._byteOffset; } } ), Object.defineProperty( a.prototype, "buffer", { get: function() { return this._trimAlloc(), this._buffer; }, set: function(t) { this._buffer = t, this._dataView = new DataView(this._buffer, this._byteOffset), this._byteLength = this._buffer.byteLength; } } ), Object.defineProperty( a.prototype, "byteOffset", { get: function() { return this._byteOffset; }, set: function(t) { this._byteOffset = t, this._dataView = new DataView(this._buffer, this._byteOffset), this._byteLength = this._buffer.byteLength; } } ), Object.defineProperty( a.prototype, "dataView", { get: function() { return this._dataView; }, set: function(t) { this._byteOffset = t.byteOffset, this._buffer = t.buffer, this._dataView = new DataView(this._buffer, this._byteOffset), this._byteLength = this._byteOffset + t.byteLength; } } ), a.prototype.seek = function(t) { var e = Math.max(0, Math.min(this.byteLength, t)); this.position = isNaN(e) || !isFinite(e) ? 0 : e; }, a.prototype.isEof = function() { return this.position >= this._byteLength; }, a.prototype.mapUint8Array = function(t) { this._realloc(t * 1); var e = new Uint8Array(this._buffer, this.byteOffset + this.position, t); return this.position += t * 1, e; }, a.prototype.readInt32Array = function(t, e) { t = t ?? this.byteLength - this.position / 4; var i = new Int32Array(t); return a.memcpy( i.buffer, 0, this.buffer, this.byteOffset + this.position, t * i.BYTES_PER_ELEMENT ), a.arrayToNative(i, e ?? this.endianness), this.position += i.byteLength, i; }, a.prototype.readInt16Array = function(t, e) { t = t ?? this.byteLength - this.position / 2; var i = new Int16Array(t); return a.memcpy( i.buffer, 0, this.buffer, this.byteOffset + this.position, t * i.BYTES_PER_ELEMENT ), a.arrayToNative(i, e ?? this.endianness), this.position += i.byteLength, i; }, a.prototype.readInt8Array = function(t) { t = t ?? this.byteLength - this.position; var e = new Int8Array(t); return a.memcpy( e.buffer, 0, this.buffer, this.byteOffset + this.position, t * e.BYTES_PER_ELEMENT ), this.position += e.byteLength, e; }, a.prototype.readUint32Array = function(t, e) { t = t ?? this.byteLength - this.position / 4; var i = new Uint32Array(t); return a.memcpy( i.buffer, 0, this.buffer, this.byteOffset + this.position, t * i.BYTES_PER_ELEMENT ), a.arrayToNative(i, e ?? this.endianness), this.position += i.byteLength, i; }, a.prototype.readUint16Array = function(t, e) { t = t ?? this.byteLength - this.position / 2; var i = new Uint16Array(t); return a.memcpy( i.buffer, 0, this.buffer, this.byteOffset + this.position, t * i.BYTES_PER_ELEMENT ), a.arrayToNative(i, e ?? this.endianness), this.position += i.byteLength, i; }, a.prototype.readUint8Array = function(t) { t = t ?? this.byteLength - this.position; var e = new Uint8Array(t); return a.memcpy( e.buffer, 0, this.buffer, this.byteOffset + this.position, t * e.BYTES_PER_ELEMENT ), this.position += e.byteLength, e; }, a.prototype.readFloat64Array = function(t, e) { t = t ?? this.byteLength - this.position / 8; var i = new Float64Array(t); return a.memcpy( i.buffer, 0, this.buffer, this.byteOffset + this.position, t * i.BYTES_PER_ELEMENT ), a.arrayToNative(i, e ?? this.endianness), this.position += i.byteLength, i; }, a.prototype.readFloat32Array = function(t, e) { t = t ?? this.byteLength - this.position / 4; var i = new Float32Array(t); return a.memcpy( i.buffer, 0, this.buffer, this.byteOffset + this.position, t * i.BYTES_PER_ELEMENT ), a.arrayToNative(i, e ?? this.endianness), this.position += i.byteLength, i; }, a.prototype.readInt32 = function(t) { var e = this._dataView.getInt32(this.position, t ?? this.endianness); return this.position += 4, e; }, a.prototype.readInt16 = function(t) { var e = this._dataView.getInt16(this.position, t ?? this.endianness); return this.position += 2, e; }, a.prototype.readInt8 = function() { var t = this._dataView.getInt8(this.position); return this.position += 1, t; }, a.prototype.readUint32 = function(t) { var e = this._dataView.getUint32(this.position, t ?? this.endianness); return this.position += 4, e; }, a.prototype.readUint16 = function(t) { var e = this._dataView.getUint16(this.position, t ?? this.endianness); return this.position += 2, e; }, a.prototype.readUint8 = function() { var t = this._dataView.getUint8(this.position); return this.position += 1, t; }, a.prototype.readFloat32 = function(t) { var e = this._dataView.getFloat32(this.position, t ?? this.endianness); return this.position += 4, e; }, a.prototype.readFloat64 = function(t) { var e = this._dataView.getFloat64(this.position, t ?? this.endianness); return this.position += 8, e; }, a.endianness = new Int8Array(new Int16Array([1]).buffer)[0] > 0, a.memcpy = function(t, e, i, s, o) { var c = new Uint8Array(t, e, o), u = new Uint8Array(i, s, o); c.set(u); }, a.arrayToNative = function(t, e) { return e == this.endianness ? t : this.flipArrayEndianness(t); }, a.nativeToEndian = function(t, e) { return this.endianness == e ? t : this.flipArrayEndianness(t); }, a.flipArrayEndianness = function(t) { for (var e = new Uint8Array(t.buffer, t.byteOffset, t.byteLength), i = 0; i < t.byteLength; i += t.BYTES_PER_ELEMENT) for (var s = i + t.BYTES_PER_ELEMENT - 1, o = i; s > o; s--, o++) { var c = e[o]; e[o] = e[s], e[s] = c; } return t; }, a.prototype.failurePosition = 0, String.fromCharCodeUint8 = function(t) { for (var e = [], i = 0; i < t.length; i++) e[i] = t[i]; return String.fromCharCode.apply(null, e); }, a.prototype.readString = function(t, e) { return e == null || e == "ASCII" ? String.fromCharCodeUint8.apply(null, [this.mapUint8Array(t ?? this.byteLength - this.position)]) : new TextDecoder(e).decode(this.mapUint8Array(t)); }, a.prototype.readCString = function(t) { var e = this.byteLength - this.position, i = new Uint8Array(this._buffer, this._byteOffset + this.position), s = e; t != null && (s = Math.min(t, e)); for (var o = 0; o < s && i[o] !== 0; o++) ; var c = String.fromCharCodeUint8.apply(null, [this.mapUint8Array(o)]); return t != null ? this.position += s - o : o != e && (this.position += 1), c; }; var f = Math.pow(2, 32); a.prototype.readInt64 = function() { return this.readInt32() * f + this.readUint32(); }, a.prototype.readUint64 = function() { return this.readUint32() * f + this.readUint32(); }, a.prototype.readInt64 = function() { return this.readUint32() * f + this.readUint32(); }, a.prototype.readUint24 = function() { return (this.readUint8() << 16) + (this.readUint8() << 8) + this.readUint8(); }, l.DataStream = a, a.prototype.save = function(t) { var e = new Blob([this.buffer]); if (window.URL && URL.createObjectURL) { var i = window.URL.createObjectURL(e), s = document.createElement("a"); document.body.appendChild(s), s.setAttribute("href", i), s.setAttribute("download", t), s.setAttribute("target", "_self"), s.click(), window.URL.revokeObjectURL(i); } else throw "DataStream.save: Can't create object URL."; }, a.prototype._dynamicSize = !0, Object.defineProperty( a.prototype, "dynamicSize", { get: function() { return this._dynamicSize; }, set: function(t) { t || this._trimAlloc(), this._dynamicSize = t; } } ), a.prototype.shift = function(t) { var e = new ArrayBuffer(this._byteLength - t), i = new Uint8Array(e), s = new Uint8Array(this._buffer, t, i.length); i.set(s), this.buffer = e, this.position -= t; }, a.prototype.writeInt32Array = function(t, e) { if (this._realloc(t.length * 4), t instanceof Int32Array && this.byteOffset + this.position % t.BYTES_PER_ELEMENT === 0) a.memcpy( this._buffer, this.byteOffset + this.position, t.buffer, 0, t.byteLength ), this.mapInt32Array(t.length, e); else for (var i = 0; i < t.length; i++) this.writeInt32(t[i], e); }, a.prototype.writeInt16Array = function(t, e) { if (this._realloc(t.length * 2), t instanceof Int16Array && this.byteOffset + this.position % t.BYTES_PER_ELEMENT === 0) a.memcpy( this._buffer, this.byteOffset + this.position, t.buffer, 0, t.byteLength ), this.mapInt16Array(t.length, e); else for (var i = 0; i < t.length; i++) this.writeInt16(t[i], e); }, a.prototype.writeInt8Array = function(t) { if (this._realloc(t.length * 1), t instanceof Int8Array && this.byteOffset + this.position % t.BYTES_PER_ELEMENT === 0) a.memcpy( this._buffer, this.byteOffset + this.position, t.buffer, 0, t.byteLength ), this.mapInt8Array(t.length); else for (var e = 0; e < t.length; e++) this.writeInt8(t[e]); }, a.prototype.writeUint32Array = function(t, e) { if (this._realloc(t.length * 4), t instanceof Uint32Array && this.byteOffset + this.position % t.BYTES_PER_ELEMENT === 0) a.memcpy( this._buffer, this.byteOffset + this.position, t.buffer, 0, t.byteLength ), this.mapUint32Array(t.length, e); else for (var i = 0; i < t.length; i++) this.writeUint32(t[i], e); }, a.prototype.writeUint16Array = function(t, e) { if (this._realloc(t.length * 2), t instanceof Uint16Array && this.byteOffset + this.position % t.BYTES_PER_ELEMENT === 0) a.memcpy( this._buffer, this.byteOffset + this.position, t.buffer, 0, t.byteLength ), this.mapUint16Array(t.length, e); else for (var i = 0; i < t.length; i++) this.writeUint16(t[i], e); }, a.prototype.writeUint8Array = function(t) { if (this._realloc(t.length * 1), t instanceof Uint8Array && this.byteOffset + this.position % t.BYTES_PER_ELEMENT === 0) a.memcpy( this._buffer, this.byteOffset + this.position, t.buffer, 0, t.byteLength ), this.mapUint8Array(t.length); else for (var e = 0; e < t.length; e++) this.writeUint8(t[e]); }, a.prototype.writeFloat64Array = function(t, e) { if (this._realloc(t.length * 8), t instanceof Float64Array && this.byteOffset + this.position % t.BYTES_PER_ELEMENT === 0) a.memcpy( this._buffer, this.byteOffset + this.position, t.buffer, 0, t.byteLength ), this.mapFloat64Array(t.length, e); else for (var i = 0; i < t.length; i++) this.writeFloat64(t[i], e); }, a.prototype.writeFloat32Array = function(t, e) { if (this._realloc(t.length * 4), t instanceof Float32Array && this.byteOffset + this.position % t.BYTES_PER_ELEMENT === 0) a.memcpy( this._buffer, this.byteOffset + this.position, t.buffer, 0, t.byteLength ), this.mapFloat32Array(t.length, e); else for (var i = 0; i < t.length; i++) this.writeFloat32(t[i], e); }, a.prototype.writeInt32 = function(t, e) { this._realloc(4), this._dataView.setInt32(this.position, t, e ?? this.endianness), this.position += 4; }, a.prototype.writeInt16 = function(t, e) { this._realloc(2), this._dataView.setInt16(this.position, t, e ?? this.endianness), this.position += 2; }, a.prototype.writeInt8 = function(t) { this._realloc(1), this._dataView.setInt8(this.position, t), this.posi