// Metro module 8883 (f8884). import * as _classCallCheck from "./_classCallCheck"; import * as __createClass from "./_createClass"; import { bytes } from "./bytes"; import * as _Module8885 from "./Module8885"; let c5794_5, c5794_6, toString; let env5794 = {}; export function isBytes(a0) { return a0 instanceof Uint8Array || a0 != null && typeof a0 === "object" && a0.constructor.name === "Uint8Array"; } export function byteSwap32(a0) { const length = a0.length; let r0 = 0; if (0 < length) { do { a0[r0] = (0, exports.byteSwap)(a0[r0]); r0 = r0 + 1; } while (r0 < a0.length); } } export function bytesToHex(a0) { let length2; (0, bytes)(a0); const length = a0.length; let r0 = 0; const r15 = 0 < length; let r6 = ""; let r16 = ""; if (r15) { do { r6 = r6 + c5794_5[a0[r0]]; r0 = r0 + 1; length2 = a0.length; r16 = r6; } while (r0 < length2); } return r16; } export function hexToBytes(a0) { if (typeof a0 !== "string") { throw new Error("hex string expected, got " + typeof a0); } const length = a0.length; const r10 = length / 2; if (length % 2) { throw new Error("padded hex string expected, got unpadded hex of length " + length); } const uint8Array = new Uint8Array(r10); let r1 = 0; let r3 = 0; if (0 < r10) { while (true) { const r21 = a0.charCodeAt(r1); const _0 = c5794_6._0; const r29 = r1; const r7 = r3; const r19 = r21 >= _0 && r21 <= c5794_6._9 ? r21 - c5794_6._0 : r21 >= c5794_6._A && r21 <= c5794_6._F ? r21 - (c5794_6._A - 10) : r21 >= c5794_6._a ? r21 <= c5794_6._f ? r21 - (c5794_6._a - 10) : void 0 : void 0; const charCodeAt = a0.charCodeAt; const r41 = r29 + 1; const r42 = charCodeAt.call(a0, r41); const r49 = r42 >= c5794_6._0 && r42 <= c5794_6._9 ? r42 - c5794_6._0 : r42 >= c5794_6._A && r42 <= c5794_6._F ? r42 - (c5794_6._A - 10) : r42 >= c5794_6._a ? r42 <= c5794_6._f ? r42 - (c5794_6._a - 10) : void 0 : void 0; if (r19 !== void 0 && r49 !== void 0) { uint8Array[r7] = 16 * r19 + r49; r3 = r7 + 1; r1 = r29 + 2; if (r3 < r10) { continue; } break; } throw new Error("hex string expected, got non-hex character \"" + (a0[r29] + a0[r41]) + "\" at index " + r29); } } return uint8Array; } export async function asyncLoop(c26305_0, c26305_1, c26305_2) { let c29993_0, c29993_1, c29993_2, c29993_3, c29993_4, c29993_5; L23: { L18: { c29993_0 = c26305_0; c29993_1 = c26305_1; c29993_2 = c26305_2; c29993_3 = void 0; c29993_4 = void 0; c29993_5 = void 0; c29993_3 = Date.now(); c29993_4 = 0; if (!(c29993_4 < c26305_0)) { break L23; } while (true) { (0, c29993_2)(c29993_4); c29993_5 = Date.now() - c29993_3; if (c29993_5 >= 0 && c29993_5 < c29993_1) { c29993_4 = c29993_4 + 1; if (!(c29993_4 < c29993_0)) { break L23; } } else { await (0, exports.nextTick)(); loop14: while (true) { c29993_3 = c29993_3 + c29993_5; while (true) { c29993_4 = c29993_4 + 1; if (!(c29993_4 < c29993_0)) { break L18; } (0, c29993_2)(c29993_4); c29993_5 = Date.now() - c29993_3; if (!(c29993_5 >= 0 && c29993_5 < c29993_1)) { await (0, exports.nextTick)(); continue loop14; } } } } } break L23; } return void 0; } } export function utf8ToBytes(a0) { if (typeof a0 !== "string") { throw new Error("utf8ToBytes expected string, got " + typeof a0); } return new Uint8Array(new TextEncoder().encode(a0)); } export function toBytes(a0) { let r2 = a0; if (typeof a0 === "string") { if (typeof a0 !== "string") { throw new Error("utf8ToBytes expected string, got " + typeof a0); } r2 = new Uint8Array(new TextEncoder().encode(a0)); } (0, bytes)(r2); return r2; } export function concatBytes(...args) { let length; const r5 = 0 < args.length; let r1 = 0; let r7 = 0; let r8 = 0; if (r5) { do { const r16 = args[r1]; (0, bytes)(r16); r7 = r7 + r16.length; r1 = r1 + 1; length = args.length; r8 = r7; } while (r1 < length); } const uint8Array = new Uint8Array(r8); const r30 = 0 < args.length; let r31 = 0; let r32 = 0; if (r30) { do { const r33 = args[r32]; uint8Array.set(r33, r31); r31 = r31 + r33.length; r32 = r32 + 1; } while (r32 < args.length); } return uint8Array; } export function checkOpts(a0, a1) { if (a1 !== void 0 && toString.call(a1) !== "[object Object]") { throw new Error("Options should be object or undefined"); } return Object.assign(a0, a1); } export function wrapConstructor(a0) { let c16844_0 = a0; const hashC2 = (a0) => { const r4 = c16844_0(); let r11 = a0; if (typeof a0 === "string") { if (typeof a0 !== "string") { throw new Error("utf8ToBytes expected string, got " + typeof a0); } r11 = new Uint8Array(new TextEncoder().encode(a0)); } (0, bytes)(r11); return r4.update(r11).digest(); }; const r5 = a0(); hashC2.outputLen = r5.outputLen; hashC2.blockLen = r5.blockLen; hashC2.create = () => c16844_0(); return hashC2; } export function wrapConstructorWithOpts(a0) { let c16845_0 = a0; const hashC2 = (a0, a1) => { const r4 = c16845_0(a1); let r12 = a0; if (typeof a0 === "string") { if (typeof a0 !== "string") { throw new Error("utf8ToBytes expected string, got " + typeof a0); } r12 = new Uint8Array(new TextEncoder().encode(a0)); } (0, bytes)(r12); return r4.update(r12).digest(); }; const r5 = a0({}); hashC2.outputLen = r5.outputLen; hashC2.blockLen = r5.blockLen; hashC2.create = (a0) => c16845_0(a0); return hashC2; } export function wrapXOFConstructorWithOpts(a0) { let c16846_0 = a0; const hashC2 = (a0, a1) => { const r4 = c16846_0(a1); let r12 = a0; if (typeof a0 === "string") { if (typeof a0 !== "string") { throw new Error("utf8ToBytes expected string, got " + typeof a0); } r12 = new Uint8Array(new TextEncoder().encode(a0)); } (0, bytes)(r12); return r4.update(r12).digest(); }; const r5 = a0({}); hashC2.outputLen = r5.outputLen; hashC2.blockLen = r5.blockLen; hashC2.create = (a0) => c16846_0(a0); return hashC2; } export function randomBytes(r6 = 32) { if (_Module8885.crypto && typeof _Module8885.crypto.getRandomValues === "function") { return _Module8885.crypto.getRandomValues(new Uint8Array(r6)); } if (_Module8885.crypto && typeof _Module8885.crypto.randomBytes === "function") { return _Module8885.crypto.randomBytes(r6); } throw new Error("crypto.getRandomValues must be defined"); } export const u8 = (a0) => new Uint8Array(a0.buffer, a0.byteOffset, a0.byteLength); export const u32 = (a0) => new Uint32Array(a0.buffer, a0.byteOffset, Math.floor(a0.byteLength / 4)); export const createView = (a0) => new DataView(a0.buffer, a0.byteOffset, a0.byteLength); export const rotr = (a0, a1) => a0 << 32 - a1 | a0 >>> a1; export const rotl = (a0, a1) => a0 << a1 | a0 >>> 32 - a1 >>> 0; exports.isLE = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68; export const byteSwap = (a0) => a0 << 24 & 4278190080 | a0 << 8 & 16711680 | a0 >>> 8 & 65280 | a0 >>> 24 & 255; const r55 = exports.isLE ? (a0) => a0 : (a0) => (0, exports.byteSwap)(a0); let c5795_0; let Hash; export { r55 as byteSwapIfBE }; c5794_5 = Array.from({ length: 256 }, (a0, a1) => a1.toString(16).padStart(2, "0")); c5794_6 = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 }; c5795_0 = void 0; c5795_0 = async () => {}; export function nextTick() { const apply = c5795_0.apply; return c5795_0.apply(this, arguments); } Hash = function Hash() { _classCallCheck(this, Hash); }; exports.Hash = __createClass(Hash, [{ key: "clone", value: function clone() { return this._cloneInto(); } }]); toString = ({}).toString;