var __bare_os_bundle_exports__ = (() => { var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // ../../node_modules/b4a/index.js var require_b4a = __commonJS({ "../../node_modules/b4a/index.js"(exports, module) { function isBuffer(value) { return Buffer.isBuffer(value) || value instanceof Uint8Array; } function isEncoding(encoding) { return Buffer.isEncoding(encoding); } function alloc(size, fill2, encoding) { return Buffer.alloc(size, fill2, encoding); } function allocUnsafe(size) { return Buffer.allocUnsafe(size); } function allocUnsafeSlow(size) { return Buffer.allocUnsafeSlow(size); } function byteLength(string, encoding) { return Buffer.byteLength(string, encoding); } function compare(a, b) { return Buffer.compare(a, b); } function concat(buffers, totalLength) { return Buffer.concat(buffers, totalLength); } function copy(source, target, targetStart, start, end) { return toBuffer(source).copy(target, targetStart, start, end); } function equals(a, b) { return toBuffer(a).equals(b); } function fill(buffer, value, offset, end, encoding) { return toBuffer(buffer).fill(value, offset, end, encoding); } function from(value, encodingOrOffset, length) { return Buffer.from(value, encodingOrOffset, length); } function includes(buffer, value, byteOffset, encoding) { return toBuffer(buffer).includes(value, byteOffset, encoding); } function indexOf(buffer, value, byfeOffset, encoding) { return toBuffer(buffer).indexOf(value, byfeOffset, encoding); } function lastIndexOf(buffer, value, byteOffset, encoding) { return toBuffer(buffer).lastIndexOf(value, byteOffset, encoding); } function swap16(buffer) { return toBuffer(buffer).swap16(); } function swap32(buffer) { return toBuffer(buffer).swap32(); } function swap64(buffer) { return toBuffer(buffer).swap64(); } function toBuffer(buffer) { if (Buffer.isBuffer(buffer)) return buffer; return Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength); } function toString(buffer, encoding, start, end) { return toBuffer(buffer).toString(encoding, start, end); } function write(buffer, string, offset, length, encoding) { return toBuffer(buffer).write(string, offset, length, encoding); } function readDoubleBE(buffer, offset) { return toBuffer(buffer).readDoubleBE(offset); } function readDoubleLE(buffer, offset) { return toBuffer(buffer).readDoubleLE(offset); } function readFloatBE(buffer, offset) { return toBuffer(buffer).readFloatBE(offset); } function readFloatLE(buffer, offset) { return toBuffer(buffer).readFloatLE(offset); } function readInt32BE(buffer, offset) { return toBuffer(buffer).readInt32BE(offset); } function readInt32LE(buffer, offset) { return toBuffer(buffer).readInt32LE(offset); } function readUInt32BE(buffer, offset) { return toBuffer(buffer).readUInt32BE(offset); } function readUInt32LE(buffer, offset) { return toBuffer(buffer).readUInt32LE(offset); } function writeDoubleBE(buffer, value, offset) { return toBuffer(buffer).writeDoubleBE(value, offset); } function writeDoubleLE(buffer, value, offset) { return toBuffer(buffer).writeDoubleLE(value, offset); } function writeFloatBE(buffer, value, offset) { return toBuffer(buffer).writeFloatBE(value, offset); } function writeFloatLE(buffer, value, offset) { return toBuffer(buffer).writeFloatLE(value, offset); } function writeInt32BE(buffer, value, offset) { return toBuffer(buffer).writeInt32BE(value, offset); } function writeInt32LE(buffer, value, offset) { return toBuffer(buffer).writeInt32LE(value, offset); } function writeUInt32BE(buffer, value, offset) { return toBuffer(buffer).writeUInt32BE(value, offset); } function writeUInt32LE(buffer, value, offset) { return toBuffer(buffer).writeUInt32LE(value, offset); } module.exports = { isBuffer, isEncoding, alloc, allocUnsafe, allocUnsafeSlow, byteLength, compare, concat, copy, equals, fill, from, includes, indexOf, lastIndexOf, swap16, swap32, swap64, toBuffer, toString, write, readDoubleBE, readDoubleLE, readFloatBE, readFloatLE, readInt32BE, readInt32LE, readUInt32BE, readUInt32LE, writeDoubleBE, writeDoubleLE, writeFloatBE, writeFloatLE, writeInt32BE, writeInt32LE, writeUInt32BE, writeUInt32LE }; } }); // ../../node_modules/compact-encoding/endian.js var require_endian = __commonJS({ "../../node_modules/compact-encoding/endian.js"(exports) { var LE = exports.LE = new Uint8Array(new Uint16Array([255]).buffer)[0] === 255; exports.BE = !LE; } }); // ../../node_modules/compact-encoding/raw.js var require_raw = __commonJS({ "../../node_modules/compact-encoding/raw.js"(exports, module) { var b4a = require_b4a(); var { BE } = require_endian(); exports = module.exports = { preencode(state, b) { state.end += b.byteLength; }, encode(state, b) { state.buffer.set(b, state.start); state.start += b.byteLength; }, decode(state) { const b = state.buffer.subarray(state.start, state.end); state.start = state.end; return b; } }; var buffer = exports.buffer = { preencode(state, b) { if (b) uint8array.preencode(state, b); else state.end++; }, encode(state, b) { if (b) uint8array.encode(state, b); else state.buffer[state.start++] = 0; }, decode(state) { const b = state.buffer.subarray(state.start); if (b.byteLength === 0) return null; state.start = state.end; return b; } }; exports.binary = { ...buffer, preencode(state, b) { if (typeof b === "string") utf8.preencode(state, b); else buffer.preencode(state, b); }, encode(state, b) { if (typeof b === "string") utf8.encode(state, b); else buffer.encode(state, b); } }; exports.arraybuffer = { preencode(state, b) { state.end += b.byteLength; }, encode(state, b) { const view = new Uint8Array(b); state.buffer.set(view, state.start); state.start += b.byteLength; }, decode(state) { const b = new ArrayBuffer(state.end - state.start); const view = new Uint8Array(b); view.set(state.buffer.subarray(state.start)); state.start = state.end; return b; } }; function typedarray(TypedArray, swap) { const n = TypedArray.BYTES_PER_ELEMENT; return { preencode(state, b) { state.end += b.byteLength; }, encode(state, b) { const view = new Uint8Array(b.buffer, b.byteOffset, b.byteLength); if (BE && swap) swap(view); state.buffer.set(view, state.start); state.start += b.byteLength; }, decode(state) { let b = state.buffer.subarray(state.start); if (b.byteOffset % n !== 0) b = new Uint8Array(b); if (BE && swap) swap(b); state.start = state.end; return new TypedArray(b.buffer, b.byteOffset, b.byteLength / n); } }; } var uint8array = exports.uint8array = typedarray(Uint8Array); exports.uint16array = typedarray(Uint16Array, b4a.swap16); exports.uint32array = typedarray(Uint32Array, b4a.swap32); exports.int8array = typedarray(Int8Array); exports.int16array = typedarray(Int16Array, b4a.swap16); exports.int32array = typedarray(Int32Array, b4a.swap32); exports.biguint64array = typedarray(BigUint64Array, b4a.swap64); exports.bigint64array = typedarray(BigInt64Array, b4a.swap64); exports.float32array = typedarray(Float32Array, b4a.swap32); exports.float64array = typedarray(Float64Array, b4a.swap64); function string(encoding) { return { preencode(state, s) { state.end += b4a.byteLength(s, encoding); }, encode(state, s) { state.start += b4a.write(state.buffer, s, state.start, encoding); }, decode(state) { const s = b4a.toString(state.buffer, encoding, state.start); state.start = state.end; return s; } }; } var utf8 = exports.string = exports.utf8 = string("utf-8"); exports.ascii = string("ascii"); exports.hex = string("hex"); exports.base64 = string("base64"); exports.ucs2 = exports.utf16le = string("utf16le"); exports.array = function array(enc) { return { preencode(state, list) { for (const value of list) enc.preencode(state, value); }, encode(state, list) { for (const value of list) enc.encode(state, value); }, decode(state) { const arr = []; while (state.start < state.end) arr.push(enc.decode(state)); return arr; } }; }; exports.json = { preencode(state, v) { utf8.preencode(state, JSON.stringify(v)); }, encode(state, v) { utf8.encode(state, JSON.stringify(v)); }, decode(state) { return JSON.parse(utf8.decode(state)); } }; exports.ndjson = { preencode(state, v) { utf8.preencode(state, JSON.stringify(v) + "\n"); }, encode(state, v) { utf8.encode(state, JSON.stringify(v) + "\n"); }, decode(state) { return JSON.parse(utf8.decode(state)); } }; } }); // ../../node_modules/compact-encoding/lexint.js var require_lexint = __commonJS({ "../../node_modules/compact-encoding/lexint.js"(exports, module) { module.exports = { preencode, encode, decode }; function preencode(state, num) { if (num < 251) { state.end++; } else if (num < 256) { state.end += 2; } else if (num < 65536) { state.end += 3; } else if (num < 16777216) { state.end += 4; } else if (num < 4294967296) { state.end += 5; } else { state.end++; const exp = Math.floor(Math.log(num) / Math.log(2)) - 32; preencode(state, exp); state.end += 6; } } function encode(state, num) { const max = 251; const x = num - max; if (num < max) { state.buffer[state.start++] = num; } else if (num < 256) { state.buffer[state.start++] = max; state.buffer[state.start++] = x; } else if (num < 65536) { state.buffer[state.start++] = max + 1; state.buffer[state.start++] = x >> 8 & 255; state.buffer[state.start++] = x & 255; } else if (num < 16777216) { state.buffer[state.start++] = max + 2; state.buffer[state.start++] = x >> 16; state.buffer[state.start++] = x >> 8 & 255; state.buffer[state.start++] = x & 255; } else if (num < 4294967296) { state.buffer[state.start++] = max + 3; state.buffer[state.start++] = x >> 24; state.buffer[state.start++] = x >> 16 & 255; state.buffer[state.start++] = x >> 8 & 255; state.buffer[state.start++] = x & 255; } else { const exp = Math.floor(Math.log(x) / Math.log(2)) - 32; state.buffer[state.start++] = 255; encode(state, exp); const rem = x / Math.pow(2, exp - 11); for (let i = 5; i >= 0; i--) { state.buffer[state.start++] = rem / Math.pow(2, 8 * i) & 255; } } } function decode(state) { const max = 251; if (state.end - state.start < 1) throw new Error("Out of bounds"); const flag = state.buffer[state.start++]; if (flag < max) return flag; if (state.end - state.start < flag - max + 1) { throw new Error("Out of bounds."); } if (flag < 252) { return state.buffer[state.start++] + max; } if (flag < 253) { return (state.buffer[state.start++] << 8) + state.buffer[state.start++] + max; } if (flag < 254) { return (state.buffer[state.start++] << 16) + (state.buffer[state.start++] << 8) + state.buffer[state.start++] + max; } if (flag < 255) { return state.buffer[state.start++] * 16777216 + (state.buffer[state.start++] << 16) + (state.buffer[state.start++] << 8) + state.buffer[state.start++] + max; } const exp = decode(state); if (state.end - state.start < 6) throw new Error("Out of bounds"); let rem = 0; for (let i = 5; i >= 0; i--) { rem += state.buffer[state.start++] * Math.pow(2, 8 * i); } return rem * Math.pow(2, exp - 11) + max; } } }); // ../../node_modules/compact-encoding/index.js var require_compact_encoding = __commonJS({ "../../node_modules/compact-encoding/index.js"(exports) { var b4a = require_b4a(); var { BE } = require_endian(); exports.state = function(start = 0, end = 0, buffer2 = null) { return { start, end, buffer: buffer2 }; }; var raw = exports.raw = require_raw(); var uint = exports.uint = { preencode(state, n) { state.end += n <= 252 ? 1 : n <= 65535 ? 3 : n <= 4294967295 ? 5 : 9; }, encode(state, n) { if (n <= 252) uint8.encode(state, n); else if (n <= 65535) { state.buffer[state.start++] = 253; uint16.encode(state, n); } else if (n <= 4294967295) { state.buffer[state.start++] = 254; uint32.encode(state, n); } else { state.buffer[state.start++] = 255; uint64.encode(state, n); } }, decode(state) { const a = uint8.decode(state); if (a <= 252) return a; if (a === 253) return uint16.decode(state); if (a === 254) return uint32.decode(state); return uint64.decode(state); } }; var uint8 = exports.uint8 = { preencode(state, n) { state.end += 1; }, encode(state, n) { validateUint(n); state.buffer[state.start++] = n; }, decode(state) { if (state.start >= state.end) throw new Error("Out of bounds"); return state.buffer[state.start++]; } }; var uint16 = exports.uint16 = { preencode(state, n) { state.end += 2; }, encode(state, n) { validateUint(n); state.buffer[state.start++] = n; state.buffer[state.start++] = n >>> 8; }, decode(state) { if (state.end - state.start < 2) throw new Error("Out of bounds"); return state.buffer[state.start++] + state.buffer[state.start++] * 256; } }; var uint24 = exports.uint24 = { preencode(state, n) { state.end += 3; }, encode(state, n) { validateUint(n); state.buffer[state.start++] = n; state.buffer[state.start++] = n >>> 8; state.buffer[state.start++] = n >>> 16; }, decode(state) { if (state.end - state.start < 3) throw new Error("Out of bounds"); return state.buffer[state.start++] + state.buffer[state.start++] * 256 + state.buffer[state.start++] * 65536; } }; var uint32 = exports.uint32 = { preencode(state, n) { state.end += 4; }, encode(state, n) { validateUint(n); state.buffer[state.start++] = n; state.buffer[state.start++] = n >>> 8; state.buffer[state.start++] = n >>> 16; state.buffer[state.start++] = n >>> 24; }, decode(state) { if (state.end - state.start < 4) throw new Error("Out of bounds"); return state.buffer[state.start++] + state.buffer[state.start++] * 256 + state.buffer[state.start++] * 65536 + state.buffer[state.start++] * 16777216; } }; var uint40 = exports.uint40 = { preencode(state, n) { state.end += 5; }, encode(state, n) { validateUint(n); const r = Math.floor(n / 256); uint8.encode(state, n); uint32.encode(state, r); }, decode(state) { if (state.end - state.start < 5) throw new Error("Out of bounds"); return uint8.decode(state) + 256 * uint32.decode(state); } }; var uint48 = exports.uint48 = { preencode(state, n) { state.end += 6; }, encode(state, n) { validateUint(n); const r = Math.floor(n / 65536); uint16.encode(state, n); uint32.encode(state, r); }, decode(state) { if (state.end - state.start < 6) throw new Error("Out of bounds"); return uint16.decode(state) + 65536 * uint32.decode(state); } }; var uint56 = exports.uint56 = { preencode(state, n) { state.end += 7; }, encode(state, n) { validateUint(n); const r = Math.floor(n / 16777216); uint24.encode(state, n); uint32.encode(state, r); }, decode(state) { if (state.end - state.start < 7) throw new Error("Out of bounds"); return uint24.decode(state) + 16777216 * uint32.decode(state); } }; var uint64 = exports.uint64 = { preencode(state, n) { state.end += 8; }, encode(state, n) { validateUint(n); const r = Math.floor(n / 4294967296); uint32.encode(state, n); uint32.encode(state, r); }, decode(state) { if (state.end - state.start < 8) throw new Error("Out of bounds"); return uint32.decode(state) + 4294967296 * uint32.decode(state); } }; var int = exports.int = zigZagInt(uint); exports.int8 = zigZagInt(uint8); exports.int16 = zigZagInt(uint16); exports.int24 = zigZagInt(uint24); exports.int32 = zigZagInt(uint32); exports.int40 = zigZagInt(uint40); exports.int48 = zigZagInt(uint48); exports.int56 = zigZagInt(uint56); exports.int64 = zigZagInt(uint64); var biguint64 = exports.biguint64 = { preencode(state, n) { state.end += 8; }, encode(state, n) { const view = new DataView( state.buffer.buffer, state.start + state.buffer.byteOffset, 8 ); view.setBigUint64(0, n, true); state.start += 8; }, decode(state) { if (state.end - state.start < 8) throw new Error("Out of bounds"); const view = new DataView( state.buffer.buffer, state.start + state.buffer.byteOffset, 8 ); const n = view.getBigUint64(0, true); state.start += 8; return n; } }; exports.bigint64 = zigZagBigInt(biguint64); var biguint = exports.biguint = { preencode(state, n) { let len = 0; for (let m = n; m; m = m >> 64n) len++; uint.preencode(state, len); state.end += 8 * len; }, encode(state, n) { let len = 0; for (let m = n; m; m = m >> 64n) len++; uint.encode(state, len); const view = new DataView( state.buffer.buffer, state.start + state.buffer.byteOffset, 8 * len ); for (let m = n, i = 0; m; m = m >> 64n, i += 8) { view.setBigUint64(i, BigInt.asUintN(64, m), true); } state.start += 8 * len; }, decode(state) { const len = uint.decode(state); if (state.end - state.start < 8 * len) throw new Error("Out of bounds"); const view = new DataView( state.buffer.buffer, state.start + state.buffer.byteOffset, 8 * len ); let n = 0n; for (let i = len - 1; i >= 0; i--) n = (n << 64n) + view.getBigUint64(i * 8, true); state.start += 8 * len; return n; } }; exports.bigint = zigZagBigInt(biguint); exports.lexint = require_lexint(); exports.float32 = { preencode(state, n) { state.end += 4; }, encode(state, n) { const view = new DataView( state.buffer.buffer, state.start + state.buffer.byteOffset, 4 ); view.setFloat32(0, n, true); state.start += 4; }, decode(state) { if (state.end - state.start < 4) throw new Error("Out of bounds"); const view = new DataView( state.buffer.buffer, state.start + state.buffer.byteOffset, 4 ); const float = view.getFloat32(0, true); state.start += 4; return float; } }; exports.float64 = { preencode(state, n) { state.end += 8; }, encode(state, n) { const view = new DataView( state.buffer.buffer, state.start + state.buffer.byteOffset, 8 ); view.setFloat64(0, n, true); state.start += 8; }, decode(state) { if (state.end - state.start < 8) throw new Error("Out of bounds"); const view = new DataView( state.buffer.buffer, state.start + state.buffer.byteOffset, 8 ); const float = view.getFloat64(0, true); state.start += 8; return float; } }; var buffer = exports.buffer = { preencode(state, b) { if (b) uint8array.preencode(state, b); else state.end++; }, encode(state, b) { if (b) uint8array.encode(state, b); else state.buffer[state.start++] = 0; }, decode(state) { const len = uint.decode(state); if (len === 0) return null; if (state.end - state.start < len) throw new Error("Out of bounds"); return state.buffer.subarray(state.start, state.start += len); } }; exports.binary = { ...buffer, preencode(state, b) { if (typeof b === "string") utf8.preencode(state, b); else buffer.preencode(state, b); }, encode(state, b) { if (typeof b === "string") utf8.encode(state, b); else buffer.encode(state, b); } }; exports.arraybuffer = { preencode(state, b) { uint.preencode(state, b.byteLength); state.end += b.byteLength; }, encode(state, b) { uint.encode(state, b.byteLength); const view = new Uint8Array(b); state.buffer.set(view, state.start); state.start += b.byteLength; }, decode(state) { const len = uint.decode(state); const b = new ArrayBuffer(len); const view = new Uint8Array(b); view.set(state.buffer.subarray(state.start, state.start += len)); return b; } }; function typedarray(TypedArray, swap) { const n = TypedArray.BYTES_PER_ELEMENT; return { preencode(state, b) { uint.preencode(state, b.length); state.end += b.byteLength; }, encode(state, b) { uint.encode(state, b.length); const view = new Uint8Array(b.buffer, b.byteOffset, b.byteLength); if (BE && swap) swap(view); state.buffer.set(view, state.start); state.start += b.byteLength; }, decode(state) { const len = uint.decode(state); let b = state.buffer.subarray(state.start, state.start += len * n); if (b.byteLength !== len * n) throw new Error("Out of bounds"); if (b.byteOffset % n !== 0) b = new Uint8Array(b); if (BE && swap) swap(b); return new TypedArray(b.buffer, b.byteOffset, b.byteLength / n); } }; } var uint8array = exports.uint8array = typedarray(Uint8Array); exports.uint16array = typedarray(Uint16Array, b4a.swap16); exports.uint32array = typedarray(Uint32Array, b4a.swap32); exports.int8array = typedarray(Int8Array); exports.int16array = typedarray(Int16Array, b4a.swap16); exports.int32array = typedarray(Int32Array, b4a.swap32); exports.biguint64array = typedarray(BigUint64Array, b4a.swap64); exports.bigint64array = typedarray(BigInt64Array, b4a.swap64); exports.float32array = typedarray(Float32Array, b4a.swap32); exports.float64array = typedarray(Float64Array, b4a.swap64); function string(encoding) { return { preencode(state, s) { const len = b4a.byteLength(s, encoding); uint.preencode(state, len); state.end += len; }, encode(state, s) { const len = b4a.byteLength(s, encoding); uint.encode(state, len); b4a.write(state.buffer, s, state.start, encoding); state.start += len; }, decode(state) { const len = uint.decode(state); if (state.end - state.start < len) throw new Error("Out of bounds"); return b4a.toString( state.buffer, encoding, state.start, state.start += len ); }, fixed(n) { return { preencode(state) { state.end += n; }, encode(state, s) { b4a.write(state.buffer, s, state.start, n, encoding); state.start += n; }, decode(state) { if (state.end - state.start < n) throw new Error("Out of bounds"); return b4a.toString( state.buffer, encoding, state.start, state.start += n ); } }; } }; } var utf8 = exports.string = exports.utf8 = string("utf-8"); exports.ascii = string("ascii"); exports.hex = string("hex"); exports.base64 = string("base64"); exports.ucs2 = exports.utf16le = string("utf16le"); exports.bool = { preencode(state, b) { state.end++; }, encode(state, b) { state.buffer[state.start++] = b ? 1 : 0; }, decode(state) { if (state.start >= state.end) throw Error("Out of bounds"); return state.buffer[state.start++] === 1; } }; var fixed = exports.fixed = function fixed2(n) { return { preencode(state, s) { if (s.byteLength !== n) throw new Error("Incorrect buffer size"); state.end += n; }, encode(state, s) { state.buffer.set(s, state.start); state.start += n; }, decode(state) { if (state.end - state.start < n) throw new Error("Out of bounds"); return state.buffer.subarray(state.start, state.start += n); } }; }; exports.fixed32 = fixed(32); exports.fixed64 = fixed(64); exports.array = function array(enc) { return { preencode(state, list) { uint.preencode(state, list.length); for (let i = 0; i < list.length; i++) enc.preencode(state, list[i]); }, encode(state, list) { uint.encode(state, list.length); for (let i = 0; i < list.length; i++) enc.encode(state, list[i]); }, decode(state) { const len = uint.decode(state); if (len > 1048576) throw new Error("Array is too big"); const arr = new Array(len); for (let i = 0; i < len; i++) arr[i] = enc.decode(state); return arr; } }; }; exports.frame = function frame(enc) { const dummy = exports.state(); return { preencode(state, m) { const end = state.end; enc.preencode(state, m); uint.preencode(state, state.end - end); }, encode(state, m) { dummy.end = 0; enc.preencode(dummy, m); uint.encode(state, dummy.end); enc.encode(state, m); }, decode(state) { const end = state.end; const len = uint.decode(state); state.end = state.start + len; const m = enc.decode(state); state.start = state.end; state.end = end; return m; } }; }; exports.date = { preencode(state, d) { int.preencode(state, d.getTime()); }, encode(state, d) { int.encode(state, d.getTime()); }, decode(state, d) { return new Date(int.decode(state)); } }; exports.json = { preencode(state, v) { utf8.preencode(state, JSON.stringify(v)); }, encode(state, v) { utf8.encode(state, JSON.stringify(v)); }, decode(state) { return JSON.parse(utf8.decode(state)); } }; exports.ndjson = { preencode(state, v) { utf8.preencode(state, JSON.stringify(v) + "\n"); }, encode(state, v) { utf8.encode(state, JSON.stringify(v) + "\n"); }, decode(state) { return JSON.parse(utf8.decode(state)); } }; exports.none = { preencode(state, n) { }, encode(state, n) { }, decode(state) { return null; } }; var anyArray = { preencode(state, arr) { uint.preencode(state, arr.length); for (let i = 0; i < arr.length; i++) { any.preencode(state, arr[i]); } }, encode(state, arr) { uint.encode(state, arr.length); for (let i = 0; i < arr.length; i++) { any.encode(state, arr[i]); } }, decode(state) { const arr = []; let len = uint.decode(state); while (len-- > 0) { arr.push(any.decode(state)); } return arr; } }; var anyObject = { preencode(state, o) { const keys = Object.keys(o); uint.preencode(state, keys.length); for (const key of keys) { utf8.preencode(state, key); any.preencode(state, o[key]); } }, encode(state, o) { const keys = Object.keys(o); uint.encode(state, keys.length); for (const key of keys) { utf8.encode(state, key); any.encode(state, o[key]); } }, decode(state) { let len = uint.decode(state); const o = {}; while (len-- > 0) { const key = utf8.decode(state); o[key] = any.decode(state); } return o; } }; var anyTypes = [ exports.none, exports.bool, exports.string, exports.buffer, exports.uint, exports.int, exports.float64, anyArray, anyObject, exports.date ]; var any = exports.any = { preencode(state, o) { const t = getType(o); uint.preencode(state, t); anyTypes[t].preencode(state, o); }, encode(state, o) { const t = getType(o); uint.encode(state, t); anyTypes[t].encode(state, o); }, decode(state) { const t = uint.decode(state); if (t >= anyTypes.length) throw new Error("Unknown type: " + t); return anyTypes[t].decode(state); } }; var port = exports.port = uint16; var address = (host, family) => { return { preencode(state, m) { host.preencode(state, m.host); port.preencode(state, m.port); }, encode(state, m) { host.encode(state, m.host); port.encode(state, m.port); }, decode(state) { return { host: host.decode(state), family, port: port.decode(state) }; } }; }; var ipv4 = exports.ipv4 = { preencode(state) { state.end += 4; }, encode(state, string2) { const start = state.start; const end = start + 4; let i = 0; while (i < string2.length) { let n = 0; let c; while (i < string2.length && (c = string2.charCodeAt(i++)) !== /* . */ 46) { n = n * 10 + (c - /* 0 */ 48); } state.buffer[state.start++] = n; } state.start = end; }, decode(state) { if (state.end - state.start < 4) throw new Error("Out of bounds"); return state.buffer[state.start++] + "." + state.buffer[state.start++] + "." + state.buffer[state.start++] + "." + state.buffer[state.start++]; } }; exports.ipv4Address = address(ipv4, 4); var ipv6 = exports.ipv6 = { preencode(state) { state.end += 16; }, encode(state, string2) { const start = state.start; const end = start + 16; let i = 0; let split = null; while (i < string2.length) { let n = 0; let c; while (i < string2.length && (c = string2.charCodeAt(i++)) !== /* : */ 58) { if (c >= 48 && c <= 57) n = n * 16 + (c - /* 0 */ 48); else if (c >= 65 && c <= 70) n = n * 16 + (c - /* A */ 65 + 10); else if (c >= 97 && c <= 102) n = n * 16 + (c - /* a */ 97 + 10); } state.buffer[state.start++] = n >>> 8; state.buffer[state.start++] = n; if (i < string2.length && string2.charCodeAt(i) === /* : */ 58) { i++; split = state.start; } } if (split !== null) { const offset = end - state.start; state.buffer.copyWithin(split + offset, split).fill(0, split, split + offset); } state.start = end; }, decode(state) { if (state.end - state.start < 16) throw new Error("Out of bounds"); return (state.buffer[state.start++] * 256 + state.buffer[state.start++]).toString(16) + ":" + (state.buffer[state.start++] * 256 + state.buffer[state.start++]).toString(16) + ":" + (state.buffer[state.start++] * 256 + state.buffer[state.start++]).toString(16) + ":" + (state.buffer[state.start++] * 256 + state.buffer[state.start++]).toString(16) + ":" + (state.buffer[state.start++] * 256 + state.buffer[state.start++]).toString(16) + ":" + (state.buffer[state.start++] * 256 + state.buffer[state.start++]).toString(16) + ":" + (state.buffer[state.start++] * 256 + state.buffer[state.start++]).toString(16) + ":" + (state.buffer[state.start++] * 256 + state.buffer[state.start++]).toString(16); } }; exports.ipv6Address = address(ipv6, 6); var ip = exports.ip = { preencode(state, string2) { const family = string2.includes(":") ? 6 : 4; uint8.preencode(state, family); if (family === 4) ipv4.preencode(state); else ipv6.preencode(state); }, encode(state, string2) { const family = string2.includes(":") ? 6 : 4; uint8.encode(state, family); if (family === 4) ipv4.encode(state, string2); else ipv6.encode(state, string2); }, decode(state) { const family = uint8.decode(state); if (family === 4) return ipv4.decode(state); else return ipv6.decode(state); } }; exports.ipAddress = { preencode(state, m) { ip.preencode(state, m.host); port.preencode(state, m.port); }, encode(state, m) { ip.encode(state, m.host); port.encode(state, m.port); }, decode(state) { const family = uint8.decode(state); return { host: family === 4 ? ipv4.decode(state) : ipv6.decode(state), family, port: port.decode(state) }; } }; var record = exports.record = function(keyEncoding, valueEncoding) { return { preencode(state, v) { const keys = Object.keys(v); uint.preencode(state, keys.length); for (const k of keys) { keyEncoding.preencode(state, k); valueEncoding.preencode(state, v[k]); } }, encode(state, v) { const keys = Object.keys(v); uint.encode(state, keys.length); for (const k of keys) { keyEncoding.encode(state, k); valueEncoding.encode(state, v[k]); } }, decode(state) { const out = /* @__PURE__ */ Object.create(null); const keys = uint.decode(state); for (let i = 0; i < keys; i++) { out[keyEncoding.decode(state)] = valueEncoding.decode(state); } return out; } }; }; exports.stringRecord = record(utf8, utf8); function getType(o) { if (o === null || o === void 0) return 0; if (typeof o === "boolean") return 1; if (typeof o === "string") return 2; if (b4a.isBuffer(o)) return 3; if (typeof o === "number") { if (Number.isInteger(o)) return o >= 0 ? 4 : 5; return 6; } if (Array.isArray(o)) return 7; if (o instanceof Date) return 9; if (typeof o === "object") return 8; throw new Error("Unsupported type for " + o); } exports.from = function from(enc) { if (typeof enc === "string") return fromNamed(enc); if (enc.preencode) return enc; if (enc.encodingLength) return fromAbstractEncoder(enc); return fromCodec(enc); }; function fromNamed(enc) { switch (enc) { case "ascii": return raw.ascii; case "utf-8": case "utf8": return raw.utf8; case "hex": return raw.hex; case "base64": return raw.base64; case "utf16-le": case "utf16le": case "ucs-2": case "ucs2": return raw.ucs2; case "ndjson": return raw.ndjson; case "json": return raw.json; case "binary": default: return raw.binary; } } function fromCodec(enc) { let tmpM = null; let tmpBuf = null; return { preencode(state, m) { tmpM = m; tmpBuf = enc.encode(m); state.end += tmpBuf.byteLength; }, encode(state, m) { raw.encode(state, m === tmpM ? tmpBuf : enc.encode(m)); tmpM = tmpBuf = null; }, decode(state) { return enc.decode(raw.decode(state)); } }; } function fromAbstractEncoder(enc) { return { preencode(state, m) { state.end += enc.encodingLength(m); }, encode(state, m) { enc.encode(m, state.buffer, state.start); state.start += enc.encode.bytes; }, decode(state) { const m = enc.decode(state.buffer, state.start, state.end); state.start += enc.decode.bytes; return m; } }; } exports.encode = function encode(enc, m) { const state = exports.state(); enc.preencode(state, m); state.buffer = b4a.allocUnsafe(state.end); enc.encode(state, m); return state.buffer; }; exports.decode = function decode(enc, buffer2) { return enc.decode(exports.state(0, buffer2.byteLength, buffer2)); }; function zigZagInt(enc) { return { preencode(state, n) { enc.preencode(state, zigZagEncodeInt(n)); }, encode(state, n) { enc.encode(state, zigZagEncodeInt(n)); }, decode(state) { return zigZagDecodeInt(enc.decode(state)); } }; } function zigZagDecodeInt(n) { return n === 0 ? n : (n & 1) === 0 ? n / 2 : -(n + 1) / 2; } function zigZagEncodeInt(n) { return n < 0 ? 2 * -n - 1 : n === 0 ? 0 : 2 * n; } function zigZagBigInt(enc) { return { preencode(state, n) { enc.preencode(state, zigZagEncodeBigInt(n)); }, encode(state, n) { enc.encode(state, zigZagEncodeBigInt(n)); }, decode(state) { return zigZagDecodeBigInt(enc.decode(state)); } }; } function zigZagDecodeBigInt(n) { return n === 0n ? n : (n & 1n) === 0n ? n / 2n : -(n + 1n) / 2n; } function zigZagEncodeBigInt(n) { return n < 0n ? 2n * -n - 1n : n === 0n ? 0n : 2n * n; } function validateUint(n) { if (n >= 0 === false) throw new Error("uint must be positive"); } } }); // ../../bare-lib-entry-compactEncoding.js var bare_lib_entry_compactEncoding_exports = {}; __export(bare_lib_entry_compactEncoding_exports, { default: () => bare_lib_entry_compactEncoding_default }); var import_compact_encoding = __toESM(require_compact_encoding()); var bare_lib_entry_compactEncoding_default = import_compact_encoding.default; return __toCommonJS(bare_lib_entry_compactEncoding_exports); })(); ;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};var e=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;var v=e!=null&&typeof e==="object"&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;g[s]["compactEncoding"]=v;})();