/*!
 * hash-wasm (https://www.npmjs.com/package/hash-wasm)
 * (c) Dani Biro
 * @license MIT
 */

var name$l = "adler32";
var data$l = "AGFzbQEAAAABDANgAAF/YAAAYAF/AAMHBgABAgEAAgUEAQECAgYOAn8BQYCJBQt/AEGACAsHcAgGbWVtb3J5AgAOSGFzaF9HZXRCdWZmZXIAAAlIYXNoX0luaXQAAQtIYXNoX1VwZGF0ZQACCkhhc2hfRmluYWwAAw1IYXNoX0dldFN0YXRlAAQOSGFzaF9DYWxjdWxhdGUABQpTVEFURV9TSVpFAwEK6wkGBQBBgAkLCgBBAEEBNgKECAvjCAEHf0EAKAKECCIBQf//A3EhAiABQRB2IQMCQAJAIABBAUcNACACQQAtAIAJaiIBQY+AfGogASABQfD/A0sbIgEgA2oiBEEQdCIFQYCAPGogBSAEQfD/A0sbIAFyIQEMAQsCQAJAAkACQAJAIABBEEkNAEGACSEGIABBsCtJDQFBgAkhBgNAQQAhBQNAIAYgBWoiASgCACIEQf8BcSACaiICIANqIAIgBEEIdkH/AXFqIgJqIAIgBEEQdkH/AXFqIgJqIAIgBEEYdmoiAmogAiABQQRqKAIAIgRB/wFxaiICaiACIARBCHZB/wFxaiICaiACIARBEHZB/wFxaiICaiACIARBGHZqIgJqIAIgAUEIaigCACIEQf8BcWoiAmogAiAEQQh2Qf8BcWoiAmogAiAEQRB2Qf8BcWoiAmogAiAEQRh2aiIEaiAEIAFBDGooAgAiAUH/AXFqIgRqIAQgAUEIdkH/AXFqIgRqIAQgAUEQdkH/AXFqIgRqIAQgAUEYdmoiAmohAyAFQRBqIgVBsCtHDQALIANB8f8DcCEDIAJB8f8DcCECIAZBsCtqIQYgAEHQVGoiAEGvK0sNAAsgAEUNBCAAQQ9LDQEMAgsCQCAARQ0AAkACQCAAQQNxIgUNAEGACSEBIAAhBAwBCyAAQXxxIQRBACEBA0AgAiABQYAJai0AAGoiAiADaiEDIAUgAUEBaiIBRw0ACyAFQYAJaiEBCyAAQQRJDQADQCACIAEtAABqIgUgAS0AAWoiBiABLQACaiIAIAFBA2otAABqIgIgACAGIAUgA2pqamohAyABQQRqIQEgBEF8aiIEDQALCyACQY+AfGogAiACQfD/A0sbIANB8f8DcEEQdHIhAQwECwNAIAYoAgAiAUH/AXEgAmoiBCADaiAEIAFBCHZB/wFxaiIEaiAEIAFBEHZB/wFxaiIEaiAEIAFBGHZqIgRqIAQgBkEEaigCACIBQf8BcWoiBGogBCABQQh2Qf8BcWoiBGogBCABQRB2Qf8BcWoiBGogBCABQRh2aiIEaiAEIAZBCGooAgAiAUH/AXFqIgRqIAQgAUEIdkH/AXFqIgRqIAQgAUEQdkH/AXFqIgRqIAQgAUEYdmoiBGogBCAGQQxqKAIAIgFB/wFxaiIEaiAEIAFBCHZB/wFxaiIEaiAEIAFBEHZB/wFxaiIEaiAEIAFBGHZqIgJqIQMgBkEQaiEGIABBcGoiAEEPSw0ACyAARQ0BCyAAQX9qIQcCQCAAQQNxIgVFDQAgAEF8cSEAIAUhBCAGIQEDQCACIAEtAABqIgIgA2ohAyABQQFqIQEgBEF/aiIEDQALIAYgBWohBgsgB0EDSQ0AA0AgAiAGLQAAaiIBIAYtAAFqIgQgBi0AAmoiBSAGQQNqLQAAaiICIAUgBCABIANqampqIQMgBkEEaiEGIABBfGoiAA0ACwsgA0Hx/wNwIQMgAkHx/wNwIQILIAIgA0EQdHIhAQtBACABNgKECAsxAQF/QQBBACgChAgiAEEYdCAAQYD+A3FBCHRyIABBCHZBgP4DcSAAQRh2cnI2AoAJCwUAQYQICzsAQQBBATYChAggABACQQBBACgChAgiAEEYdCAAQYD+A3FBCHRyIABBCHZBgP4DcSAAQRh2cnI2AoAJCwsVAgBBgAgLBAQAAAAAQYQICwQBAAAA";
var hash$l = "02ddbd17";
var wasmJson$l = {
	name: name$l,
	data: data$l,
	hash: hash$l
};

/******************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */


function __awaiter(thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
}

typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
    var e = new Error(message);
    return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};

class Mutex {
    constructor() {
        this.mutex = Promise.resolve();
    }
    lock() {
        let begin = () => { };
        this.mutex = this.mutex.then(() => new Promise(begin));
        return new Promise((res) => {
            begin = res;
        });
    }
    dispatch(fn) {
        return __awaiter(this, void 0, void 0, function* () {
            const unlock = yield this.lock();
            try {
                return yield Promise.resolve(fn());
            }
            finally {
                unlock();
            }
        });
    }
}

var _a;
function getGlobal() {
    if (typeof globalThis !== "undefined")
        return globalThis;
    if (typeof self !== "undefined")
        return self;
    if (typeof window !== "undefined")
        return window;
    return global;
}
const globalObject = getGlobal();
const nodeBuffer = (_a = globalObject.Buffer) !== null && _a !== void 0 ? _a : null;
const textEncoder = globalObject.TextEncoder
    ? new globalObject.TextEncoder()
    : null;
function intArrayToString(arr, len) {
    return String.fromCharCode(...arr.subarray(0, len));
}
function hexCharCodesToInt(a, b) {
    return ((((a & 0xf) + ((a >> 6) | ((a >> 3) & 0x8))) << 4) |
        ((b & 0xf) + ((b >> 6) | ((b >> 3) & 0x8))));
}
function writeHexToUInt8(buf, str) {
    const size = str.length >> 1;
    for (let i = 0; i < size; i++) {
        const index = i << 1;
        buf[i] = hexCharCodesToInt(str.charCodeAt(index), str.charCodeAt(index + 1));
    }
}
function hexStringEqualsUInt8(str, buf) {
    if (str.length !== buf.length * 2) {
        return false;
    }
    for (let i = 0; i < buf.length; i++) {
        const strIndex = i << 1;
        if (buf[i] !==
            hexCharCodesToInt(str.charCodeAt(strIndex), str.charCodeAt(strIndex + 1))) {
            return false;
        }
    }
    return true;
}
const alpha = "a".charCodeAt(0) - 10;
const digit = "0".charCodeAt(0);
function getDigestHex(tmpBuffer, input, hashLength) {
    let p = 0;
    for (let i = 0; i < hashLength; i++) {
        let nibble = input[i] >>> 4;
        tmpBuffer[p++] = nibble > 9 ? nibble + alpha : nibble + digit;
        nibble = input[i] & 0xf;
        tmpBuffer[p++] = nibble > 9 ? nibble + alpha : nibble + digit;
    }
    return String.fromCharCode.apply(null, tmpBuffer);
}
const getUInt8Buffer = nodeBuffer !== null
    ? (data) => {
        if (typeof data === "string") {
            const buf = nodeBuffer.from(data, "utf8");
            return new Uint8Array(buf.buffer, buf.byteOffset, buf.length);
        }
        if (nodeBuffer.isBuffer(data)) {
            return new Uint8Array(data.buffer, data.byteOffset, data.length);
        }
        if (ArrayBuffer.isView(data)) {
            return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
        }
        throw new Error("Invalid data type!");
    }
    : (data) => {
        if (typeof data === "string") {
            return textEncoder.encode(data);
        }
        if (ArrayBuffer.isView(data)) {
            return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
        }
        throw new Error("Invalid data type!");
    };
const base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const base64Lookup = new Uint8Array(256);
for (let i = 0; i < base64Chars.length; i++) {
    base64Lookup[base64Chars.charCodeAt(i)] = i;
}
function encodeBase64(data, pad = true) {
    const len = data.length;
    const extraBytes = len % 3;
    const parts = [];
    const len2 = len - extraBytes;
    for (let i = 0; i < len2; i += 3) {
        const tmp = ((data[i] << 16) & 0xff0000) +
            ((data[i + 1] << 8) & 0xff00) +
            (data[i + 2] & 0xff);
        const triplet = base64Chars.charAt((tmp >> 18) & 0x3f) +
            base64Chars.charAt((tmp >> 12) & 0x3f) +
            base64Chars.charAt((tmp >> 6) & 0x3f) +
            base64Chars.charAt(tmp & 0x3f);
        parts.push(triplet);
    }
    if (extraBytes === 1) {
        const tmp = data[len - 1];
        const a = base64Chars.charAt(tmp >> 2);
        const b = base64Chars.charAt((tmp << 4) & 0x3f);
        parts.push(`${a}${b}`);
        if (pad) {
            parts.push("==");
        }
    }
    else if (extraBytes === 2) {
        const tmp = (data[len - 2] << 8) + data[len - 1];
        const a = base64Chars.charAt(tmp >> 10);
        const b = base64Chars.charAt((tmp >> 4) & 0x3f);
        const c = base64Chars.charAt((tmp << 2) & 0x3f);
        parts.push(`${a}${b}${c}`);
        if (pad) {
            parts.push("=");
        }
    }
    return parts.join("");
}
function getDecodeBase64Length(data) {
    let bufferLength = Math.floor(data.length * 0.75);
    const len = data.length;
    if (data[len - 1] === "=") {
        bufferLength -= 1;
        if (data[len - 2] === "=") {
            bufferLength -= 1;
        }
    }
    return bufferLength;
}
function decodeBase64(data) {
    const bufferLength = getDecodeBase64Length(data);
    const len = data.length;
    const bytes = new Uint8Array(bufferLength);
    let p = 0;
    for (let i = 0; i < len; i += 4) {
        const encoded1 = base64Lookup[data.charCodeAt(i)];
        const encoded2 = base64Lookup[data.charCodeAt(i + 1)];
        const encoded3 = base64Lookup[data.charCodeAt(i + 2)];
        const encoded4 = base64Lookup[data.charCodeAt(i + 3)];
        bytes[p] = (encoded1 << 2) | (encoded2 >> 4);
        p += 1;
        bytes[p] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
        p += 1;
        bytes[p] = ((encoded3 & 3) << 6) | (encoded4 & 63);
        p += 1;
    }
    return bytes;
}

const MAX_HEAP = 16 * 1024;
const WASM_FUNC_HASH_LENGTH = 4;
const wasmMutex = new Mutex();
const wasmModuleCache = new Map();
function WASMInterface(binary, hashLength) {
    return __awaiter(this, void 0, void 0, function* () {
        let wasmInstance = null;
        let memoryView = null;
        let initialized = false;
        if (typeof WebAssembly === "undefined") {
            throw new Error("WebAssembly is not supported in this environment!");
        }
        const writeMemory = (data, offset = 0) => {
            memoryView.set(data, offset);
        };
        const getMemory = () => memoryView;
        const getExports = () => wasmInstance.exports;
        const setMemorySize = (totalSize) => {
            wasmInstance.exports.Hash_SetMemorySize(totalSize);
            const arrayOffset = wasmInstance.exports.Hash_GetBuffer();
            const memoryBuffer = wasmInstance.exports.memory.buffer;
            memoryView = new Uint8Array(memoryBuffer, arrayOffset, totalSize);
        };
        const getStateSize = () => {
            const view = new DataView(wasmInstance.exports.memory.buffer);
            const stateSize = view.getUint32(wasmInstance.exports.STATE_SIZE, true);
            return stateSize;
        };
        const loadWASMPromise = wasmMutex.dispatch(() => __awaiter(this, void 0, void 0, function* () {
            if (!wasmModuleCache.has(binary.name)) {
                const asm = decodeBase64(binary.data);
                const promise = WebAssembly.compile(asm);
                wasmModuleCache.set(binary.name, promise);
            }
            const module = yield wasmModuleCache.get(binary.name);
            wasmInstance = yield WebAssembly.instantiate(module, {
            // env: {
            //   emscripten_memcpy_big: (dest, src, num) => {
            //     const memoryBuffer = wasmInstance.exports.memory.buffer;
            //     const memView = new Uint8Array(memoryBuffer, 0);
            //     memView.set(memView.subarray(src, src + num), dest);
            //   },
            //   print_memory: (offset, len) => {
            //     const memoryBuffer = wasmInstance.exports.memory.buffer;
            //     const memView = new Uint8Array(memoryBuffer, 0);
            //     console.log('print_int32', memView.subarray(offset, offset + len));
            //   },
            // },
            });
            // wasmInstance.exports._start();
        }));
        const setupInterface = () => __awaiter(this, void 0, void 0, function* () {
            if (!wasmInstance) {
                yield loadWASMPromise;
            }
            const arrayOffset = wasmInstance.exports.Hash_GetBuffer();
            const memoryBuffer = wasmInstance.exports.memory.buffer;
            memoryView = new Uint8Array(memoryBuffer, arrayOffset, MAX_HEAP);
        });
        const init = (bits = null) => {
            initialized = true;
            wasmInstance.exports.Hash_Init(bits);
        };
        const updateUInt8Array = (data) => {
            let read = 0;
            while (read < data.length) {
                const chunk = data.subarray(read, read + MAX_HEAP);
                read += chunk.length;
                memoryView.set(chunk);
                wasmInstance.exports.Hash_Update(chunk.length);
            }
        };
        const update = (data) => {
            if (!initialized) {
                throw new Error("update() called before init()");
            }
            const Uint8Buffer = getUInt8Buffer(data);
            updateUInt8Array(Uint8Buffer);
        };
        const digestChars = new Uint8Array(hashLength * 2);
        const digest = (outputType, padding = null) => {
            if (!initialized) {
                throw new Error("digest() called before init()");
            }
            initialized = false;
            wasmInstance.exports.Hash_Final(padding);
            if (outputType === "binary") {
                // the data is copied to allow GC of the original memory object
                return memoryView.slice(0, hashLength);
            }
            return getDigestHex(digestChars, memoryView, hashLength);
        };
        const save = () => {
            if (!initialized) {
                throw new Error("save() can only be called after init() and before digest()");
            }
            const stateOffset = wasmInstance.exports.Hash_GetState();
            const stateLength = getStateSize();
            const memoryBuffer = wasmInstance.exports.memory.buffer;
            const internalState = new Uint8Array(memoryBuffer, stateOffset, stateLength);
            // prefix is 4 bytes from SHA1 hash of the WASM binary
            // it is used to detect incompatible internal states between different versions of hash-wasm
            const prefixedState = new Uint8Array(WASM_FUNC_HASH_LENGTH + stateLength);
            writeHexToUInt8(prefixedState, binary.hash);
            prefixedState.set(internalState, WASM_FUNC_HASH_LENGTH);
            return prefixedState;
        };
        const load = (state) => {
            if (!(state instanceof Uint8Array)) {
                throw new Error("load() expects an Uint8Array generated by save()");
            }
            const stateOffset = wasmInstance.exports.Hash_GetState();
            const stateLength = getStateSize();
            const overallLength = WASM_FUNC_HASH_LENGTH + stateLength;
            const memoryBuffer = wasmInstance.exports.memory.buffer;
            if (state.length !== overallLength) {
                throw new Error(`Bad state length (expected ${overallLength} bytes, got ${state.length})`);
            }
            if (!hexStringEqualsUInt8(binary.hash, state.subarray(0, WASM_FUNC_HASH_LENGTH))) {
                throw new Error("This state was written by an incompatible hash implementation");
            }
            const internalState = state.subarray(WASM_FUNC_HASH_LENGTH);
            new Uint8Array(memoryBuffer, stateOffset, stateLength).set(internalState);
            initialized = true;
        };
        const isDataShort = (data) => {
            if (typeof data === "string") {
                // worst case is 4 bytes / char
                return data.length < MAX_HEAP / 4;
            }
            return data.byteLength < MAX_HEAP;
        };
        let canSimplify = isDataShort;
        switch (binary.name) {
            case "argon2":
            case "scrypt":
                canSimplify = () => true;
                break;
            case "blake2b":
            case "blake2s":
                // if there is a key at blake2 then cannot simplify
                canSimplify = (data, initParam) => initParam <= 512 && isDataShort(data);
                break;
            case "blake3":
                // if there is a key at blake3 then cannot simplify
                canSimplify = (data, initParam) => initParam === 0 && isDataShort(data);
                break;
            case "xxhash64": // cannot simplify
            case "xxhash3":
            case "xxhash128":
            case "crc64":
                canSimplify = () => false;
                break;
        }
        // shorthand for (init + update + digest) for better performance
        const calculate = (data, initParam = null, digestParam = null) => {
            if (!canSimplify(data, initParam)) {
                init(initParam);
                update(data);
                return digest("hex", digestParam);
            }
            const buffer = getUInt8Buffer(data);
            memoryView.set(buffer);
            wasmInstance.exports.Hash_Calculate(buffer.length, initParam, digestParam);
            return getDigestHex(digestChars, memoryView, hashLength);
        };
        yield setupInterface();
        return {
            getMemory,
            writeMemory,
            getExports,
            setMemorySize,
            init,
            update,
            digest,
            save,
            load,
            calculate,
            hashLength,
        };
    });
}

function lockedCreate(mutex, binary, hashLength) {
    return __awaiter(this, void 0, void 0, function* () {
        const unlock = yield mutex.lock();
        const wasm = yield WASMInterface(binary, hashLength);
        unlock();
        return wasm;
    });
}

const mutex$l = new Mutex();
let wasmCache$l = null;
/**
 * Calculates Adler-32 hash. The resulting 32-bit hash is stored in
 * network byte order (big-endian).
 *
 * @param data Input data (string, Buffer or TypedArray)
 * @returns Computed hash as a hexadecimal string
 */
function adler32(data) {
    if (wasmCache$l === null) {
        return lockedCreate(mutex$l, wasmJson$l, 4).then((wasm) => {
            wasmCache$l = wasm;
            return wasmCache$l.calculate(data);
        });
    }
    try {
        const hash = wasmCache$l.calculate(data);
        return Promise.resolve(hash);
    }
    catch (err) {
        return Promise.reject(err);
    }
}
/**
 * Creates a new Adler-32 hash instance
 */
function createAdler32() {
    return WASMInterface(wasmJson$l, 4).then((wasm) => {
        wasm.init();
        const obj = {
            init: () => {
                wasm.init();
                return obj;
            },
            update: (data) => {
                wasm.update(data);
                return obj;
            },
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
            digest: (outputType) => wasm.digest(outputType),
            save: () => wasm.save(),
            load: (data) => {
                wasm.load(data);
                return obj;
            },
            blockSize: 4,
            digestSize: 4,
        };
        return obj;
    });
}

var name$k = "argon2";
var data$k = "[encoded data, 8880 characters]";
var hash$k = "e4cdc523";
var wasmJson$k = {
	name: name$k,
	data: data$k,
	hash: hash$k
};

var name$j = "blake2b";
var data$j = "[encoded data, 9924 characters]";
var hash$j = "c6f286e6";
var wasmJson$j = {
	name: name$j,
	data: data$j,
	hash: hash$j
};

const mutex$k = new Mutex();
let wasmCache$k = null;
function validateBits$4(bits) {
    if (!Number.isInteger(bits) || bits < 8 || bits > 512 || bits % 8 !== 0) {
        return new Error("Invalid variant! Valid values: 8, 16, ..., 512");
    }
    return null;
}
function getInitParam$1(outputBits, keyBits) {
    return outputBits | (keyBits << 16);
}
/**
 * Calculates BLAKE2b hash
 * @param data Input data (string, Buffer or TypedArray)
 * @param bits Number of output bits, which has to be a number
 *             divisible by 8, between 8 and 512. Defaults to 512.
 * @param key Optional key (string, Buffer or TypedArray). Maximum length is 64 bytes.
 * @returns Computed hash as a hexadecimal string
 */
function blake2b(data, bits = 512, key = null) {
    if (validateBits$4(bits)) {
        return Promise.reject(validateBits$4(bits));
    }
    let keyBuffer = null;
    let initParam = bits;
    if (key !== null) {
        keyBuffer = getUInt8Buffer(key);
        if (keyBuffer.length > 64) {
            return Promise.reject(new Error("Max key length is 64 bytes"));
        }
        initParam = getInitParam$1(bits, keyBuffer.length);
    }
    const hashLength = bits / 8;
    if (wasmCache$k === null || wasmCache$k.hashLength !== hashLength) {
        return lockedCreate(mutex$k, wasmJson$j, hashLength).then((wasm) => {
            wasmCache$k = wasm;
            if (initParam > 512) {
                wasmCache$k.writeMemory(keyBuffer);
            }
            return wasmCache$k.calculate(data, initParam);
        });
    }
    try {
        if (initParam > 512) {
            wasmCache$k.writeMemory(keyBuffer);
        }
        const hash = wasmCache$k.calculate(data, initParam);
        return Promise.resolve(hash);
    }
    catch (err) {
        return Promise.reject(err);
    }
}
/**
 * Creates a new BLAKE2b hash instance
 * @param bits Number of output bits, which has to be a number
 *             divisible by 8, between 8 and 512. Defaults to 512.
 * @param key Optional key (string, Buffer or TypedArray). Maximum length is 64 bytes.
 */
function createBLAKE2b(bits = 512, key = null) {
    if (validateBits$4(bits)) {
        return Promise.reject(validateBits$4(bits));
    }
    let keyBuffer = null;
    let initParam = bits;
    if (key !== null) {
        keyBuffer = getUInt8Buffer(key);
        if (keyBuffer.length > 64) {
            return Promise.reject(new Error("Max key length is 64 bytes"));
        }
        initParam = getInitParam$1(bits, keyBuffer.length);
    }
    const outputSize = bits / 8;
    return WASMInterface(wasmJson$j, outputSize).then((wasm) => {
        if (initParam > 512) {
            wasm.writeMemory(keyBuffer);
        }
        wasm.init(initParam);
        const obj = {
            init: initParam > 512
                ? () => {
                    wasm.writeMemory(keyBuffer);
                    wasm.init(initParam);
                    return obj;
                }
                : () => {
                    wasm.init(initParam);
                    return obj;
                },
            update: (data) => {
                wasm.update(data);
                return obj;
            },
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
            digest: (outputType) => wasm.digest(outputType),
            save: () => wasm.save(),
            load: (data) => {
                wasm.load(data);
                return obj;
            },
            blockSize: 128,
            digestSize: outputSize,
        };
        return obj;
    });
}

function encodeResult(salt, options, res) {
    const parameters = [
        `m=${options.memorySize}`,
        `t=${options.iterations}`,
        `p=${options.parallelism}`,
    ].join(",");
    return `$argon2${options.hashType}$v=19$${parameters}$${encodeBase64(salt, false)}$${encodeBase64(res, false)}`;
}
const uint32View = new DataView(new ArrayBuffer(4));
function int32LE(x) {
    uint32View.setInt32(0, x, true);
    return new Uint8Array(uint32View.buffer);
}
function hashFunc(blake512, buf, len) {
    return __awaiter(this, void 0, void 0, function* () {
        if (len <= 64) {
            const blake = yield createBLAKE2b(len * 8);
            blake.update(int32LE(len));
            blake.update(buf);
            return blake.digest("binary");
        }
        const r = Math.ceil(len / 32) - 2;
        const ret = new Uint8Array(len);
        blake512.init();
        blake512.update(int32LE(len));
        blake512.update(buf);
        let vp = blake512.digest("binary");
        ret.set(vp.subarray(0, 32), 0);
        for (let i = 1; i < r; i++) {
            blake512.init();
            blake512.update(vp);
            vp = blake512.digest("binary");
            ret.set(vp.subarray(0, 32), i * 32);
        }
        const partialBytesNeeded = len - 32 * r;
        let blakeSmall;
        if (partialBytesNeeded === 64) {
            blakeSmall = blake512;
            blakeSmall.init();
        }
        else {
            blakeSmall = yield createBLAKE2b(partialBytesNeeded * 8);
        }
        blakeSmall.update(vp);
        vp = blakeSmall.digest("binary");
        ret.set(vp.subarray(0, partialBytesNeeded), r * 32);
        return ret;
    });
}
function getHashType(type) {
    switch (type) {
        case "d":
            return 0;
        case "i":
            return 1;
        default:
            return 2;
    }
}
function argon2Internal(options) {
    return __awaiter(this, void 0, void 0, function* () {
        var _a;
        const { parallelism, iterations, hashLength } = options;
        const password = getUInt8Buffer(options.password);
        const salt = getUInt8Buffer(options.salt);
        const version = 0x13;
        const hashType = getHashType(options.hashType);
        const { memorySize } = options; // in KB
        const secret = getUInt8Buffer((_a = options.secret) !== null && _a !== void 0 ? _a : "");
        const [argon2Interface, blake512] = yield Promise.all([
            WASMInterface(wasmJson$k, 1024),
            createBLAKE2b(512),
        ]);
        // last block is for storing the init vector
        argon2Interface.setMemorySize(memorySize * 1024 + 1024);
        const initVector = new Uint8Array(24);
        const initVectorView = new DataView(initVector.buffer);
        initVectorView.setInt32(0, parallelism, true);
        initVectorView.setInt32(4, hashLength, true);
        initVectorView.setInt32(8, memorySize, true);
        initVectorView.setInt32(12, iterations, true);
        initVectorView.setInt32(16, version, true);
        initVectorView.setInt32(20, hashType, true);
        argon2Interface.writeMemory(initVector, memorySize * 1024);
        blake512.init();
        blake512.update(initVector);
        blake512.update(int32LE(password.length));
        blake512.update(password);
        blake512.update(int32LE(salt.length));
        blake512.update(salt);
        blake512.update(int32LE(secret.length));
        blake512.update(secret);
        blake512.update(int32LE(0)); // associatedData length + associatedData
        const segments = Math.floor(memorySize / (parallelism * 4)); // length of each lane
        const lanes = segments * 4;
        const param = new Uint8Array(72);
        const H0 = blake512.digest("binary");
        param.set(H0);
        for (let lane = 0; lane < parallelism; lane++) {
            param.set(int32LE(0), 64);
            param.set(int32LE(lane), 68);
            let position = lane * lanes;
            let chunk = yield hashFunc(blake512, param, 1024);
            argon2Interface.writeMemory(chunk, position * 1024);
            position += 1;
            param.set(int32LE(1), 64);
            chunk = yield hashFunc(blake512, param, 1024);
            argon2Interface.writeMemory(chunk, position * 1024);
        }
        const C = new Uint8Array(1024);
        writeHexToUInt8(C, argon2Interface.calculate(new Uint8Array([]), memorySize));
        const res = yield hashFunc(blake512, C, hashLength);
        if (options.outputType === "hex") {
            const digestChars = new Uint8Array(hashLength * 2);
            return getDigestHex(digestChars, res, hashLength);
        }
        if (options.outputType === "encoded") {
            return encodeResult(salt, options, res);
        }
        // return binary format
        return res;
    });
}
const validateOptions$3 = (options) => {
    var _a;
    if (!options || typeof options !== "object") {
        throw new Error("Invalid options parameter. It requires an object.");
    }
    if (!options.password) {
        throw new Error("Password must be specified");
    }
    options.password = getUInt8Buffer(options.password);
    if (options.password.length < 1) {
        throw new Error("Password must be specified");
    }
    if (!options.salt) {
        throw new Error("Salt must be specified");
    }
    options.salt = getUInt8Buffer(options.salt);
    if (options.salt.length < 8) {
        throw new Error("Salt should be at least 8 bytes long");
    }
    options.secret = getUInt8Buffer((_a = options.secret) !== null && _a !== void 0 ? _a : "");
    if (!Number.isInteger(options.iterations) || options.iterations < 1) {
        throw new Error("Iterations should be a positive number");
    }
    if (!Number.isInteger(options.parallelism) || options.parallelism < 1) {
        throw new Error("Parallelism should be a positive number");
    }
    if (!Number.isInteger(options.hashLength) || options.hashLength < 4) {
        throw new Error("Hash length should be at least 4 bytes.");
    }
    if (!Number.isInteger(options.memorySize)) {
        throw new Error("Memory size should be specified.");
    }
    if (options.memorySize < 8 * options.parallelism) {
        throw new Error("Memory size should be at least 8 * parallelism.");
    }
    if (options.outputType === undefined) {
        options.outputType = "hex";
    }
    if (!["hex", "binary", "encoded"].includes(options.outputType)) {
        throw new Error(`Insupported output type ${options.outputType}. Valid values: ['hex', 'binary', 'encoded']`);
    }
};
/**
 * Calculates hash using the argon2i password-hashing function
 * @returns Computed hash
 */
function argon2i(options) {
    return __awaiter(this, void 0, void 0, function* () {
        validateOptions$3(options);
        return argon2Internal(Object.assign(Object.assign({}, options), { hashType: "i" }));
    });
}
/**
 * Calculates hash using the argon2id password-hashing function
 * @returns Computed hash
 */
function argon2id(options) {
    return __awaiter(this, void 0, void 0, function* () {
        validateOptions$3(options);
        return argon2Internal(Object.assign(Object.assign({}, options), { hashType: "id" }));
    });
}
/**
 * Calculates hash using the argon2d password-hashing function
 * @returns Computed hash
 */
function argon2d(options) {
    return __awaiter(this, void 0, void 0, function* () {
        validateOptions$3(options);
        return argon2Internal(Object.assign(Object.assign({}, options), { hashType: "d" }));
    });
}
const getHashParameters = (password, encoded, secret) => {
    const regex = /^\$argon2(id|i|d)\$v=([0-9]+)\$((?:[mtp]=[0-9]+,){2}[mtp]=[0-9]+)\$([A-Za-z0-9+/]+)\$([A-Za-z0-9+/]+)$/;
    const match = encoded.match(regex);
    if (!match) {
        throw new Error("Invalid hash");
    }
    const [, hashType, version, parameters, salt, hash] = match;
    if (version !== "19") {
        throw new Error(`Unsupported version: ${version}`);
    }
    const parsedParameters = {};
    const paramMap = { m: "memorySize", p: "parallelism", t: "iterations" };
    for (const x of parameters.split(",")) {
        const [n, v] = x.split("=");
        parsedParameters[paramMap[n]] = Number(v);
    }
    return Object.assign(Object.assign({}, parsedParameters), { password,
        secret, hashType: hashType, salt: decodeBase64(salt), hashLength: getDecodeBase64Length(hash), outputType: "encoded" });
};
const validateVerifyOptions$1 = (options) => {
    if (!options || typeof options !== "object") {
        throw new Error("Invalid options parameter. It requires an object.");
    }
    if (options.hash === undefined || typeof options.hash !== "string") {
        throw new Error("Hash should be specified");
    }
};
/**
 * Verifies password using the argon2 password-hashing function
 * @returns True if the encoded hash matches the password
 */
function argon2Verify(options) {
    return __awaiter(this, void 0, void 0, function* () {
        validateVerifyOptions$1(options);
        const params = getHashParameters(options.password, options.hash, options.secret);
        validateOptions$3(params);
        const hashStart = options.hash.lastIndexOf("$") + 1;
        const result = (yield argon2Internal(params));
        return result.substring(hashStart) === options.hash.substring(hashStart);
    });
}

var name$i = "blake2s";
var data$i = "[encoded data, 8872 characters]";
var hash$i = "5c0ff166";
var wasmJson$i = {
	name: name$i,
	data: data$i,
	hash: hash$i
};

const mutex$j = new Mutex();
let wasmCache$j = null;
function validateBits$3(bits) {
    if (!Number.isInteger(bits) || bits < 8 || bits > 256 || bits % 8 !== 0) {
        return new Error("Invalid variant! Valid values: 8, 16, ..., 256");
    }
    return null;
}
function getInitParam(outputBits, keyBits) {
    return outputBits | (keyBits << 16);
}
/**
 * Calculates BLAKE2s hash
 * @param data Input data (string, Buffer or TypedArray)
 * @param bits Number of output bits, which has to be a number
 *             divisible by 8, between 8 and 256. Defaults to 256.
 * @param key Optional key (string, Buffer or TypedArray). Maximum length is 32 bytes.
 * @returns Computed hash as a hexadecimal string
 */
function blake2s(data, bits = 256, key = null) {
    if (validateBits$3(bits)) {
        return Promise.reject(validateBits$3(bits));
    }
    let keyBuffer = null;
    let initParam = bits;
    if (key !== null) {
        keyBuffer = getUInt8Buffer(key);
        if (keyBuffer.length > 32) {
            return Promise.reject(new Error("Max key length is 32 bytes"));
        }
        initParam = getInitParam(bits, keyBuffer.length);
    }
    const hashLength = bits / 8;
    if (wasmCache$j === null || wasmCache$j.hashLength !== hashLength) {
        return lockedCreate(mutex$j, wasmJson$i, hashLength).then((wasm) => {
            wasmCache$j = wasm;
            if (initParam > 512) {
                wasmCache$j.writeMemory(keyBuffer);
            }
            return wasmCache$j.calculate(data, initParam);
        });
    }
    try {
        if (initParam > 512) {
            wasmCache$j.writeMemory(keyBuffer);
        }
        const hash = wasmCache$j.calculate(data, initParam);
        return Promise.resolve(hash);
    }
    catch (err) {
        return Promise.reject(err);
    }
}
/**
 * Creates a new BLAKE2s hash instance
 * @param bits Number of output bits, which has to be a number
 *             divisible by 8, between 8 and 256. Defaults to 256.
 * @param key Optional key (string, Buffer or TypedArray). Maximum length is 32 bytes.
 */
function createBLAKE2s(bits = 256, key = null) {
    if (validateBits$3(bits)) {
        return Promise.reject(validateBits$3(bits));
    }
    let keyBuffer = null;
    let initParam = bits;
    if (key !== null) {
        keyBuffer = getUInt8Buffer(key);
        if (keyBuffer.length > 32) {
            return Promise.reject(new Error("Max key length is 32 bytes"));
        }
        initParam = getInitParam(bits, keyBuffer.length);
    }
    const outputSize = bits / 8;
    return WASMInterface(wasmJson$i, outputSize).then((wasm) => {
        if (initParam > 512) {
            wasm.writeMemory(keyBuffer);
        }
        wasm.init(initParam);
        const obj = {
            init: initParam > 512
                ? () => {
                    wasm.writeMemory(keyBuffer);
                    wasm.init(initParam);
                    return obj;
                }
                : () => {
                    wasm.init(initParam);
                    return obj;
                },
            update: (data) => {
                wasm.update(data);
                return obj;
            },
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
            digest: (outputType) => wasm.digest(outputType),
            save: () => wasm.save(),
            load: (data) => {
                wasm.load(data);
                return obj;
            },
            blockSize: 64,
            digestSize: outputSize,
        };
        return obj;
    });
}

var name$h = "blake3";
var data$h = "[encoded data, 15856 characters]";
var hash$h = "215d875f";
var wasmJson$h = {
	name: name$h,
	data: data$h,
	hash: hash$h
};

const mutex$i = new Mutex();
let wasmCache$i = null;
function validateBits$2(bits) {
    if (!Number.isInteger(bits) || bits < 8 || bits % 8 !== 0) {
        return new Error("Invalid variant! Valid values: 8, 16, ...");
    }
    return null;
}
/**
 * Calculates BLAKE3 hash
 * @param data Input data (string, Buffer or TypedArray)
 * @param bits Number of output bits, which has to be a number
 *             divisible by 8. Defaults to 256.
 * @param key Optional key (string, Buffer or TypedArray). Length should be 32 bytes.
 * @returns Computed hash as a hexadecimal string
 */
function blake3(data, bits = 256, key = null) {
    if (validateBits$2(bits)) {
        return Promise.reject(validateBits$2(bits));
    }
    let keyBuffer = null;
    let initParam = 0; // key is empty by default
    if (key !== null) {
        keyBuffer = getUInt8Buffer(key);
        if (keyBuffer.length !== 32) {
            return Promise.reject(new Error("Key length must be exactly 32 bytes"));
        }
        initParam = 32;
    }
    const hashLength = bits / 8;
    const digestParam = hashLength;
    if (wasmCache$i === null || wasmCache$i.hashLength !== hashLength) {
        return lockedCreate(mutex$i, wasmJson$h, hashLength).then((wasm) => {
            wasmCache$i = wasm;
            if (initParam === 32) {
                wasmCache$i.writeMemory(keyBuffer);
            }
            return wasmCache$i.calculate(data, initParam, digestParam);
        });
    }
    try {
        if (initParam === 32) {
            wasmCache$i.writeMemory(keyBuffer);
        }
        const hash = wasmCache$i.calculate(data, initParam, digestParam);
        return Promise.resolve(hash);
    }
    catch (err) {
        return Promise.reject(err);
    }
}
/**
 * Creates a new BLAKE3 hash instance
 * @param bits Number of output bits, which has to be a number
 *             divisible by 8. Defaults to 256.
 * @param key Optional key (string, Buffer or TypedArray). Length should be 32 bytes.
 */
function createBLAKE3(bits = 256, key = null) {
    if (validateBits$2(bits)) {
        return Promise.reject(validateBits$2(bits));
    }
    let keyBuffer = null;
    let initParam = 0; // key is empty by default
    if (key !== null) {
        keyBuffer = getUInt8Buffer(key);
        if (keyBuffer.length !== 32) {
            return Promise.reject(new Error("Key length must be exactly 32 bytes"));
        }
        initParam = 32;
    }
    const outputSize = bits / 8;
    const digestParam = outputSize;
    return WASMInterface(wasmJson$h, outputSize).then((wasm) => {
        if (initParam === 32) {
            wasm.writeMemory(keyBuffer);
        }
        wasm.init(initParam);
        const obj = {
            init: initParam === 32
                ? () => {
                    wasm.writeMemory(keyBuffer);
                    wasm.init(initParam);
                    return obj;
                }
                : () => {
                    wasm.init(initParam);
                    return obj;
                },
            update: (data) => {
                wasm.update(data);
                return obj;
            },
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
            digest: (outputType) => wasm.digest(outputType, digestParam),
            save: () => wasm.save(),
            load: (data) => {
                wasm.load(data);
                return obj;
            },
            blockSize: 64,
            digestSize: outputSize,
        };
        return obj;
    });
}

var name$g = "crc32";
var data$g = "AGFzbQEAAAABEQRgAAF/YAF/AGAAAGACf38AAwgHAAEBAQIAAwUEAQECAgYOAn8BQZDJBQt/AEGACAsHcAgGbWVtb3J5AgAOSGFzaF9HZXRCdWZmZXIAAAlIYXNoX0luaXQAAgtIYXNoX1VwZGF0ZQADCkhhc2hfRmluYWwABA1IYXNoX0dldFN0YXRlAAUOSGFzaF9DYWxjdWxhdGUABgpTVEFURV9TSVpFAwEKkggHBQBBgAkLwwMBA39BgIkBIQFBACECA0AgAUEAQQBBAEEAQQBBAEEAQQAgAkEBcWsgAHEgAkEBdnMiA0EBcWsgAHEgA0EBdnMiA0EBcWsgAHEgA0EBdnMiA0EBcWsgAHEgA0EBdnMiA0EBcWsgAHEgA0EBdnMiA0EBcWsgAHEgA0EBdnMiA0EBcWsgAHEgA0EBdnMiA0EBcWsgAHEgA0EBdnM2AgAgAUEEaiEBIAJBAWoiAkGAAkcNAAtBACEAA0AgAEGEkQFqIABBhIkBaigCACICQf8BcUECdE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YCgAkLCwsBAEGACAsEBAAAAA==";
var hash$g = "d2eba587";
var wasmJson$g = {
	name: name$g,
	data: data$g,
	hash: hash$g
};

const mutex$h = new Mutex();
let wasmCache$h = null;
function validatePoly(poly) {
    if (!Number.isInteger(poly) || poly < 0 || poly > 0xffffffff) {
        return new Error("Polynomial must be a valid 32-bit long unsigned integer");
    }
    return null;
}
/**
 * Calculates CRC-32 hash
 * @param data Input data (string, Buffer or TypedArray)
 * @param polynomial Input polynomial (defaults to 0xedb88320, for CRC32C use 0x82f63b78)
 * @returns Computed hash as a hexadecimal string
 */
function crc32(data, polynomial = 0xedb88320) {
    if (validatePoly(polynomial)) {
        return Promise.reject(validatePoly(polynomial));
    }
    if (wasmCache$h === null) {
        return lockedCreate(mutex$h, wasmJson$g, 4).then((wasm) => {
            wasmCache$h = wasm;
            return wasmCache$h.calculate(data, polynomial);
        });
    }
    try {
        const hash = wasmCache$h.calculate(data, polynomial);
        return Promise.resolve(hash);
    }
    catch (err) {
        return Promise.reject(err);
    }
}
/**
 * Creates a new CRC-32 hash instance
 * @param polynomial Input polynomial (defaults to 0xedb88320, for CRC32C use 0x82f63b78)
 */
function createCRC32(polynomial = 0xedb88320) {
    if (validatePoly(polynomial)) {
        return Promise.reject(validatePoly(polynomial));
    }
    return WASMInterface(wasmJson$g, 4).then((wasm) => {
        wasm.init(polynomial);
        const obj = {
            init: () => {
                wasm.init(polynomial);
                return obj;
            },
            update: (data) => {
                wasm.update(data);
                return obj;
            },
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
            digest: (outputType) => wasm.digest(outputType),
            save: () => wasm.save(),
            load: (data) => {
                wasm.load(data);
                return obj;
            },
            blockSize: 4,
            digestSize: 4,
        };
        return obj;
    });
}

var name$f = "crc64";
var data$f = "AGFzbQEAAAABDANgAAF/YAAAYAF/AAMHBgABAgEAAQUEAQECAgYOAn8BQZCJBgt/AEGACAsHcAgGbWVtb3J5AgAOSGFzaF9HZXRCdWZmZXIAAAlIYXNoX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sLAkAgAEUNAAJAAkAgAEEBcQ0AIAAhAwwBCyABQv8BgyACMQAAhadBA3RBgIkBaikDACABQgiIhSEBIAJBAWohAiAAQX9qIQMLIABBAUYNAANAIAFC/wGDIAIxAACFp0EDdEGAiQFqKQMAIAFCCIiFIgFC/wGDIAJBAWoxAACFp0EDdEGAiQFqKQMAIAFCCIiFIQEgAkECaiECIANBfmoiAw0ACwtBACABQn+FNwOIiQILZAEBfkEAQQApA4iJAiIAQjiGIABCgP4Dg0IohoQgAEKAgPwHg0IYhiAAQoCAgPgPg0IIhoSEIABCCIhCgICA+A+DIABCGIhCgID8B4OEIABCKIhCgP4DgyAAQjiIhISENwOACQsGAEGIiQILAgALCwsBAEGACAsECAAAAA==";
var hash$f = "c5ac6c16";
var wasmJson$f = {
	name: name$f,
	data: data$f,
	hash: hash$f
};

const mutex$g = new Mutex();
let wasmCache$g = null;
const polyBuffer = new Uint8Array(8);
function parsePoly(poly) {
    const errText = "Polynomial must be provided as a 16 char long hex string";
    if (typeof poly !== "string" || poly.length !== 16) {
        return { hi: 0, lo: 0, err: new Error(errText) };
    }
    const hi = Number(`0x${poly.slice(0, 8)}`);
    const lo = Number(`0x${poly.slice(8)}`);
    if (Number.isNaN(hi) || Number.isNaN(lo)) {
        return { hi, lo, err: new Error(errText) };
    }
    return { hi, lo, err: null };
}
function writePoly(arr, lo, hi) {
    // write in little-endian format
    const buffer = new DataView(arr);
    buffer.setUint32(0, lo, true);
    buffer.setUint32(4, hi, true);
}
/**
 * Calculates CRC-64 hash
 * @param data Input data (string, Buffer or TypedArray)
 * @param polynomial Input polynomial (defaults to 'c96c5795d7870f42' - ECMA)
 * @returns Computed hash as a hexadecimal string
 */
function crc64(data, polynomial = "c96c5795d7870f42") {
    const { hi, lo, err } = parsePoly(polynomial);
    if (err !== null) {
        return Promise.reject(err);
    }
    if (wasmCache$g === null) {
        return lockedCreate(mutex$g, wasmJson$f, 8).then((wasm) => {
            wasmCache$g = wasm;
            writePoly(polyBuffer.buffer, lo, hi);
            wasmCache$g.writeMemory(polyBuffer);
            return wasmCache$g.calculate(data);
        });
    }
    try {
        writePoly(polyBuffer.buffer, lo, hi);
        wasmCache$g.writeMemory(polyBuffer);
        const hash = wasmCache$g.calculate(data);
        return Promise.resolve(hash);
    }
    catch (err) {
        return Promise.reject(err);
    }
}
/**
 * Creates a new CRC-64 hash instance
 * @param polynomial Input polynomial (defaults to 'c96c5795d7870f42' - ECMA)
 */
function createCRC64(polynomial = "c96c5795d7870f42") {
    const { hi, lo, err } = parsePoly(polynomial);
    if (err !== null) {
        return Promise.reject(err);
    }
    return WASMInterface(wasmJson$f, 8).then((wasm) => {
        const instanceBuffer = new Uint8Array(8);
        writePoly(instanceBuffer.buffer, lo, hi);
        wasm.writeMemory(instanceBuffer);
        wasm.init();
        const obj = {
            init: () => {
                wasm.writeMemory(instanceBuffer);
                wasm.init();
                return obj;
            },
            update: (data) => {
                wasm.update(data);
                return obj;
            },
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
            digest: (outputType) => wasm.digest(outputType),
            save: () => wasm.save(),
            load: (data) => {
                wasm.load(data);
                return obj;
            },
            blockSize: 8,
            digestSize: 8,
        };
        return obj;
    });
}

var name$e = "md4";
var data$e = "AGFzbQEAAAABEgRgAAF/YAAAYAF/AGACf38BfwMIBwABAgMBAAIFBAEBAgIGDgJ/AUGgigULfwBBgAgLB3AIBm1lbW9yeQIADkhhc2hfR2V0QnVmZmVyAAAJSGFzaF9Jbml0AAELSGFzaF9VcGRhdGUAAgpIYXNoX0ZpbmFsAAQNSGFzaF9HZXRTdGF0ZQAFDkhhc2hfQ2FsY3VsYXRlAAYKU1RBVEVfU0laRQMBCucUBwUAQYAJCy0AQQBC/rnrxemOlZkQNwKQiQFBAEKBxpS6lvHq5m83AoiJAUEAQgA3AoCJAQu+BQEHf0EAQQAoAoCJASIBIABqQf////8BcSICNgKAiQFBAEEAKAKEiQEgAiABSWogAEEddmo2AoSJAQJAAkACQAJAAkACQCABQT9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83AoiJAUEAQgA3AoCJASAAEAIQBAsLCwEAQYAICwSYAAAA";
var hash$e = "bd8ce7c7";
var wasmJson$e = {
	name: name$e,
	data: data$e,
	hash: hash$e
};

const mutex$f = new Mutex();
let wasmCache$f = null;
/**
 * Calculates MD4 hash
 * @param data Input data (string, Buffer or TypedArray)
 * @returns Computed hash as a hexadecimal string
 */
function md4(data) {
    if (wasmCache$f === null) {
        return lockedCreate(mutex$f, wasmJson$e, 16).then((wasm) => {
            wasmCache$f = wasm;
            return wasmCache$f.calculate(data);
        });
    }
    try {
        const hash = wasmCache$f.calculate(data);
        return Promise.resolve(hash);
    }
    catch (err) {
        return Promise.reject(err);
    }
}
/**
 * Creates a new MD4 hash instance
 */
function createMD4() {
    return WASMInterface(wasmJson$e, 16).then((wasm) => {
        wasm.init();
        const obj = {
            init: () => {
                wasm.init();
                return obj;
            },
            update: (data) => {
                wasm.update(data);
                return obj;
            },
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
            digest: (outputType) => wasm.digest(outputType),
            save: () => wasm.save(),
            load: (data) => {
                wasm.load(data);
                return obj;
            },
            blockSize: 64,
            digestSize: 16,
        };
        return obj;
    });
}

var name$d = "md5";
var data$d = "[encoded data, 4696 characters]";
var hash$d = "e6508e4b";
var wasmJson$d = {
	name: name$d,
	data: data$d,
	hash: hash$d
};

const mutex$e = new Mutex();
let wasmCache$e = null;
/**
 * Calculates MD5 hash
 * @param data Input data (string, Buffer or TypedArray)
 * @returns Computed hash as a hexadecimal string
 */
function md5(data) {
    if (wasmCache$e === null) {
        return lockedCreate(mutex$e, wasmJson$d, 16).then((wasm) => {
            wasmCache$e = wasm;
            return wasmCache$e.calculate(data);
        });
    }
    try {
        const hash = wasmCache$e.calculate(data);
        return Promise.resolve(hash);
    }
    catch (err) {
        return Promise.reject(err);
    }
}
/**
 * Creates a new MD5 hash instance
 */
function createMD5() {
    return WASMInterface(wasmJson$d, 16).then((wasm) => {
        wasm.init();
        const obj = {
            init: () => {
                wasm.init();
                return obj;
            },
            update: (data) => {
                wasm.update(data);
                return obj;
            },
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
            digest: (outputType) => wasm.digest(outputType),
            save: () => wasm.save(),
            load: (data) => {
                wasm.load(data);
                return obj;
            },
            blockSize: 64,
            digestSize: 16,
        };
        return obj;
    });
}

var name$c = "sha1";
var data$c = "[encoded data, 7456 characters]";
var hash$c = "6b530c24";
var wasmJson$c = {
	name: name$c,
	data: data$c,
	hash: hash$c
};

const mutex$d = new Mutex();
let wasmCache$d = null;
/**
 * Calculates SHA-1 hash
 * @param data Input data (string, Buffer or TypedArray)
 * @returns Computed hash as a hexadecimal string
 */
function sha1(data) {
    if (wasmCache$d === null) {
        return lockedCreate(mutex$d, wasmJson$c, 20).then((wasm) => {
            wasmCache$d = wasm;
            return wasmCache$d.calculate(data);
        });
    }
    try {
        const hash = wasmCache$d.calculate(data);
        return Promise.resolve(hash);
    }
    catch (err) {
        return Promise.reject(err);
    }
}
/**
 * Creates a new SHA-1 hash instance
 */
function createSHA1() {
    return WASMInterface(wasmJson$c, 20).then((wasm) => {
        wasm.init();
        const obj = {
            init: () => {
                wasm.init();
                return obj;
            },
            update: (data) => {
                wasm.update(data);
                return obj;
            },
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
            digest: (outputType) => wasm.digest(outputType),
            save: () => wasm.save(),
            load: (data) => {
                wasm.load(data);
                return obj;
            },
            blockSize: 64,
            digestSize: 20,
        };
        return obj;
    });
}

var name$b = "sha3";
var data$b = "[encoded data, 5360 characters]";
var hash$b = "fb24e536";
var wasmJson$b = {
	name: name$b,
	data: data$b,
	hash: hash$b
};

const mutex$c = new Mutex();
let wasmCache$c = null;
function validateBits$1(bits) {
    if (![224, 256, 384, 512].includes(bits)) {
        return new Error("Invalid variant! Valid values: 224, 256, 384, 512");
    }
    return null;
}
/**
 * Calculates SHA-3 hash
 * @param data Input data (string, Buffer or TypedArray)
 * @param bits Number of output bits. Valid values: 224, 256, 384, 512
 * @returns Computed hash as a hexadecimal string
 */
function sha3(data, bits = 512) {
    if (validateBits$1(bits)) {
        return Promise.reject(validateBits$1(bits));
    }
    const hashLength = bits / 8;
    if (wasmCache$c === null || wasmCache$c.hashLength !== hashLength) {
        return lockedCreate(mutex$c, wasmJson$b, hashLength).then((wasm) => {
            wasmCache$c = wasm;
            return wasmCache$c.calculate(data, bits, 0x06);
        });
    }
    try {
        const hash = wasmCache$c.calculate(data, bits, 0x06);
        return Promise.resolve(hash);
    }
    catch (err) {
        return Promise.reject(err);
    }
}
/**
 * Creates a new SHA-3 hash instance
 * @param bits Number of output bits. Valid values: 224, 256, 384, 512
 */
function createSHA3(bits = 512) {
    if (validateBits$1(bits)) {
        return Promise.reject(validateBits$1(bits));
    }
    const outputSize = bits / 8;
    return WASMInterface(wasmJson$b, outputSize).then((wasm) => {
        wasm.init(bits);
        const obj = {
            init: () => {
                wasm.init(bits);
                return obj;
            },
            update: (data) => {
                wasm.update(data);
                return obj;
            },
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
            digest: (outputType) => wasm.digest(outputType, 0x06),
            save: () => wasm.save(),
            load: (data) => {
                wasm.load(data);
                return obj;
            },
            blockSize: 200 - 2 * outputSize,
            digestSize: outputSize,
        };
        return obj;
    });
}

const mutex$b = new Mutex();
let wasmCache$b = null;
function validateBits(bits) {
    if (![224, 256, 384, 512].includes(bits)) {
        return new Error("Invalid variant! Valid values: 224, 256, 384, 512");
    }
    return null;
}
/**
 * Calculates Keccak hash
 * @param data Input data (string, Buffer or TypedArray)
 * @param bits Number of output bits. Valid values: 224, 256, 384, 512
 * @returns Computed hash as a hexadecimal string
 */
function keccak(data, bits = 512) {
    if (validateBits(bits)) {
        return Promise.reject(validateBits(bits));
    }
    const hashLength = bits / 8;
    if (wasmCache$b === null || wasmCache$b.hashLength !== hashLength) {
        return lockedCreate(mutex$b, wasmJson$b, hashLength).then((wasm) => {
            wasmCache$b = wasm;
            return wasmCache$b.calculate(data, bits, 0x01);
        });
    }
    try {
        const hash = wasmCache$b.calculate(data, bits, 0x01);
        return Promise.resolve(hash);
    }
    catch (err) {
        return Promise.reject(err);
    }
}
/**
 * Creates a new Keccak hash instance
 * @param bits Number of output bits. Valid values: 224, 256, 384, 512
 */
function createKeccak(bits = 512) {
    if (validateBits(bits)) {
        return Promise.reject(validateBits(bits));
    }
    const outputSize = bits / 8;
    return WASMInterface(wasmJson$b, outputSize).then((wasm) => {
        wasm.init(bits);
        const obj = {
            init: () => {
                wasm.init(bits);
                return obj;
            },
            update: (data) => {
                wasm.update(data);
                return obj;
            },
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
            digest: (outputType) => wasm.digest(outputType, 0x01),
            save: () => wasm.save(),
            load: (data) => {
                wasm.load(data);
                return obj;
            },
            blockSize: 200 - 2 * outputSize,
            digestSize: outputSize,
        };
        return obj;
    });
}

var name$a = "sha256";
var data$a = "[encoded data, 12920 characters]";
var hash$a = "8c18dd94";
var wasmJson$a = {
	name: name$a,
	data: data$a,
	hash: hash$a
};

const mutex$a = new Mutex();
let wasmCache$a = null;
/**
 * Calculates SHA-2 (SHA-224) hash
 * @param data Input data (string, Buffer or TypedArray)
 * @returns Computed hash as a hexadecimal string
 */
function sha224(data) {
    if (wasmCache$a === null) {
        return lockedCreate(mutex$a, wasmJson$a, 28).then((wasm) => {
            wasmCache$a = wasm;
            return wasmCache$a.calculate(data, 224);
        });
    }
    try {
        const hash = wasmCache$a.calculate(data, 224);
        return Promise.resolve(hash);
    }
    catch (err) {
        return Promise.reject(err);
    }
}
/**
 * Creates a new SHA-2 (SHA-224) hash instance
 */
function createSHA224() {
    return WASMInterface(wasmJson$a, 28).then((wasm) => {
        wasm.init(224);
        const obj = {
            init: () => {
                wasm.init(224);
                return obj;
            },
            update: (data) => {
                wasm.update(data);
                return obj;
            },
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
            digest: (outputType) => wasm.digest(outputType),
            save: () => wasm.save(),
            load: (data) => {
                wasm.load(data);
                return obj;
            },
            blockSize: 64,
            digestSize: 28,
        };
        return obj;
    });
}

const mutex$9 = new Mutex();
let wasmCache$9 = null;
/**
 * Calculates SHA-2 (SHA-256) hash
 * @param data Input data (string, Buffer or TypedArray)
 * @returns Computed hash as a hexadecimal string
 */
function sha256(data) {
    if (wasmCache$9 === null) {
        return lockedCreate(mutex$9, wasmJson$a, 32).then((wasm) => {
            wasmCache$9 = wasm;
            return wasmCache$9.calculate(data, 256);
        });
    }
    try {
        const hash = wasmCache$9.calculate(data, 256);
        return Promise.resolve(hash);
    }
    catch (err) {
        return Promise.reject(err);
    }
}
/**
 * Creates a new SHA-2 (SHA-256) hash instance
 */
function createSHA256() {
    return WASMInterface(wasmJson$a, 32).then((wasm) => {
        wasm.init(256);
        const obj = {
            init: () => {
                wasm.init(256);
                return obj;
            },
            update: (data) => {
                wasm.update(data);
                return obj;
            },
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
            digest: (outputType) => wasm.digest(outputType),
            save: () => wasm.save(),
            load: (data) => {
                wasm.load(data);
                return obj;
            },
            blockSize: 64,
            digestSize: 32,
        };
        return obj;
    });
}

var name$9 = "sha512";
var data$9 = "[encoded data, 18032 characters]";
var hash$9 = "f2e40eb1";
var wasmJson$9 = {
	name: name$9,
	data: data$9,
	hash: hash$9
};

const mutex$8 = new Mutex();
let wasmCache$8 = null;
/**
 * Calculates SHA-2 (SHA-384) hash
 * @param data Input data (string, Buffer or TypedArray)
 * @returns Computed hash as a hexadecimal string
 */
function sha384(data) {
    if (wasmCache$8 === null) {
        return lockedCreate(mutex$8, wasmJson$9, 48).then((wasm) => {
            wasmCache$8 = wasm;
            return wasmCache$8.calculate(data, 384);
        });
    }
    try {
        const hash = wasmCache$8.calculate(data, 384);
        return Promise.resolve(hash);
    }
    catch (err) {
        return Promise.reject(err);
    }
}
/**
 * Creates a new SHA-2 (SHA-384) hash instance
 */
function createSHA384() {
    return WASMInterface(wasmJson$9, 48).then((wasm) => {
        wasm.init(384);
        const obj = {
            init: () => {
                wasm.init(384);
                return obj;
            },
            update: (data) => {
                wasm.update(data);
                return obj;
            },
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
            digest: (outputType) => wasm.digest(outputType),
            save: () => wasm.save(),
            load: (data) => {
                wasm.load(data);
                return obj;
            },
            blockSize: 128,
            digestSize: 48,
        };
        return obj;
    });
}

const mutex$7 = new Mutex();
let wasmCache$7 = null;
/**
 * Calculates SHA-2 (SHA-512) hash
 * @param data Input data (string, Buffer or TypedArray)
 * @returns Computed hash as a hexadecimal string
 */
function sha512(data) {
    if (wasmCache$7 === null) {
        return lockedCreate(mutex$7, wasmJson$9, 64).then((wasm) => {
            wasmCache$7 = wasm;
            return wasmCache$7.calculate(data, 512);
        });
    }
    try {
        const hash = wasmCache$7.calculate(data, 512);
        return Promise.resolve(hash);
    }
    catch (err) {
        return Promise.reject(err);
    }
}
/**
 * Creates a new SHA-2 (SHA-512) hash instance
 */
function createSHA512() {
    return WASMInterface(wasmJson$9, 64).then((wasm) => {
        wasm.init(512);
        const obj = {
            init: () => {
                wasm.init(512);
                return obj;
            },
            update: (data) => {
                wasm.update(data);
                return obj;
            },
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
            digest: (outputType) => wasm.digest(outputType),
            save: () => wasm.save(),
            load: (data) => {
                wasm.load(data);
                return obj;
            },
            blockSize: 128,
            digestSize: 64,
        };
        return obj;
    });
}

var name$8 = "xxhash32";
var data$8 = "AGFzbQEAAAABEQRgAAF/YAF/AGAAAGACf38AAwcGAAEBAgADBQQBAQICBg4CfwFBsIkFC38AQYAICwdwCAZtZW1vcnkCAA5IYXNoX0dldEJ1ZmZlcgAACUhhc2hfSW5pdAABC0hhc2hfVXBkYXRlAAIKSGFzaF9GaW5hbAADDUhhc2hfR2V0U3RhdGUABA5IYXNoX0NhbGN1bGF0ZQAFClNUQVRFX1NJWkUDAQrvEQYFAEGACQtNAEEAQgA3A6iJAUEAIAA2AoiJAUEA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SABQRh2cnKtNwOACQsGAEGAiQEL0gQCAX4Ef0EAQgA3A6iJAUEAIAE2AoiJAUEAIAFBz4yijgZqNgKMiQFBACABQfeUr694ajYChIkBQQAgAUGoiI2hAmo2AoCJAUEAQQA2AqCJASAAEAJBACkDqIkBIgKnIQECQAJAIAJCEFQNAEEAKAKEiQFBB3dBACgCgIkBQQF3akEAKAKIiQFBDHdqQQAoAoyJAUESd2ohAAwBC0EAKAKIiQFBsc/ZsgFqIQALIAAgAWohAEGQiQEhA0GUiQEhAQJAQQAoAqCJASIEQZCJAWoiBUGUiQFJDQBBkIkBIQMCQCAEQXxqIgZBBHENAEEAKAKQiQFBvdzKlXxsIABqQRF3Qa/W074CbCEAQZiJASEBQZSJASEDIAZBBEkNAQsDQCABKAIAQb3cypV8bCADKAIAQb3cypV8bCAAakERd0Gv1tO+AmxqQRF3Qa/W074CbCEAIAFBBGohAyABQQhqIgEgBU0NAAsgAUF8aiEDCwJAIAMgBUYNACAEQY+JAWohBgJAAkAgBCADa0EBcQ0AIAMhAQwBCyADQQFqIQEgAy0AAEGxz9myAWwgAGpBC3dBsfPd8XlsIQALIAYgA0YNAANAIAFBAWotAABBsc/ZsgFsIAEtAABBsc/ZsgFsIABqQQt3QbHz3fF5bGpBC3dBsfPd8XlsIQAgAUECaiIBIAVHDQALC0EAIABBD3YgAHNB95Svr3hsIgFBDXYgAXNBvdzKlXxsIgFBEHYgAXMiAEEYdCAAQYD+A3FBCHRyIAFBCHZBgP4DcSABQRh2cnKtNwOACQsLCwEAQYAICwQwAAAA";
var hash$8 = "4bb12485";
var wasmJson$8 = {
	name: name$8,
	data: data$8,
	hash: hash$8
};

const mutex$6 = new Mutex();
let wasmCache$6 = null;
function validateSeed$3(seed) {
    if (!Number.isInteger(seed) || seed < 0 || seed > 0xffffffff) {
        return new Error("Seed must be a valid 32-bit long unsigned integer.");
    }
    return null;
}
/**
 * Calculates xxHash32 hash
 * @param data Input data (string, Buffer or TypedArray)
 * @param seed Number used to initialize the internal state of the algorithm (defaults to 0)
 * @returns Computed hash as a hexadecimal string
 */
function xxhash32(data, seed = 0) {
    if (validateSeed$3(seed)) {
        return Promise.reject(validateSeed$3(seed));
    }
    if (wasmCache$6 === null) {
        return lockedCreate(mutex$6, wasmJson$8, 4).then((wasm) => {
            wasmCache$6 = wasm;
            return wasmCache$6.calculate(data, seed);
        });
    }
    try {
        const hash = wasmCache$6.calculate(data, seed);
        return Promise.resolve(hash);
    }
    catch (err) {
        return Promise.reject(err);
    }
}
/**
 * Creates a new xxHash32 hash instance
 * @param data Input data (string, Buffer or TypedArray)
 * @param seed Number used to initialize the internal state of the algorithm (defaults to 0)
 */
function createXXHash32(seed = 0) {
    if (validateSeed$3(seed)) {
        return Promise.reject(validateSeed$3(seed));
    }
    return WASMInterface(wasmJson$8, 4).then((wasm) => {
        wasm.init(seed);
        const obj = {
            init: () => {
                wasm.init(seed);
                return obj;
            },
            update: (data) => {
                wasm.update(data);
                return obj;
            },
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
            digest: (outputType) => wasm.digest(outputType),
            save: () => wasm.save(),
            load: (data) => {
                wasm.load(data);
                return obj;
            },
            blockSize: 16,
            digestSize: 4,
        };
        return obj;
    });
}

var name$7 = "xxhash64";
var data$7 = "AGFzbQEAAAABDANgAAF/YAAAYAF/AAMHBgABAgEAAQUEAQECAgYOAn8BQdCJBQt/AEGACAsHcAgGbWVtb3J5AgAOSGFzaF9HZXRCdWZmZXIAAAlIYXNoX0luaXQAAQtIYXNoX1VwZGF0ZQACCkhhc2hfRmluYWwAAw1IYXNoX0dldFN0YXRlAAQOSGFzaF9DYWxjdWxhdGUABQpTVEFURV9TSVpFAwEKmxEGBQBBgAkLYwEBfkEAQgA3A8iJAUEAQQApA4AJIgA3A5CJAUEAIABC+erQ0OfJoeThAHw3A5iJAUEAIABCz9bTvtLHq9lCfDcDiIkBQQAgAELW64Lu6v2J9eAAfDcDgIkBQQBBADYCwIkBC70IAwV/BH4CfwJAIABFDQB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3whACAGQQhqIQUgBkEQaiIGIAhNDQALIAZBeGohBQsCQAJAIAVBBGoiCSAITQ0AIAUhCQwBCyAFNQIAQoeVr6+Ytt6bnn9+IACFQheJQs/W077Sx6vZQn5C+fPd8Zn2masWfCEACwJAIAkgCEYNACAHQZ+JAWohBQJAAkAgByAJa0EBcQ0AIAkhBgwBCyAJQQFqIQYgCTEAAELFz9my8eW66id+IACFQguJQoeVr6+Ytt6bnn9+IQALIAUgCUYNAANAIAZBAWoxAABCxc/ZsvHluuonfiAGMQAAQsXP2bLx5brqJ34gAIVCC4lCh5Wvr5i23puef36FQguJQoeVr6+Ytt6bnn9+IQAgBkECaiIGIAhHDQALC0EAIABCIYggAIVCz9bTvtLHq9lCfiIAQh2IIACFQvnz3fGZ9pmrFn4iAEIgiCAAhSIBQjiGIAFCgP4Dg0IohoQgAUKAgPwHg0IYhiABQoCAgPgPg0IIhoSEIABCCIhCgICA+A+DIABCGIhCgID8B4OEIABCKIhCgP4DgyAAQjiIhISENwOACQsGAEGAiQELAgALCwsBAEGACAsEUAAAAA==";
var hash$7 = "177fbfa3";
var wasmJson$7 = {
	name: name$7,
	data: data$7,
	hash: hash$7
};

const mutex$5 = new Mutex();
let wasmCache$5 = null;
const seedBuffer$2 = new Uint8Array(8);
function validateSeed$2(seed) {
    if (!Number.isInteger(seed) || seed < 0 || seed > 0xffffffff) {
        return new Error("Seed must be given as two valid 32-bit long unsigned integers (lo + high).");
    }
    return null;
}
function writeSeed$2(arr, low, high) {
    // write in little-endian format
    const buffer = new DataView(arr);
    buffer.setUint32(0, low, true);
    buffer.setUint32(4, high, true);
}
/**
 * Calculates xxHash64 hash
 * @param data Input data (string, Buffer or TypedArray)
 * @param seedLow Lower 32 bits of the number used to
 *  initialize the internal state of the algorithm (defaults to 0)
 * @param seedHigh Higher 32 bits of the number used to
 *  initialize the internal state of the algorithm (defaults to 0)
 * @returns Computed hash as a hexadecimal string
 */
function xxhash64(data, seedLow = 0, seedHigh = 0) {
    if (validateSeed$2(seedLow)) {
        return Promise.reject(validateSeed$2(seedLow));
    }
    if (validateSeed$2(seedHigh)) {
        return Promise.reject(validateSeed$2(seedHigh));
    }
    if (wasmCache$5 === null) {
        return lockedCreate(mutex$5, wasmJson$7, 8).then((wasm) => {
            wasmCache$5 = wasm;
            writeSeed$2(seedBuffer$2.buffer, seedLow, seedHigh);
            wasmCache$5.writeMemory(seedBuffer$2);
            return wasmCache$5.calculate(data);
        });
    }
    try {
        writeSeed$2(seedBuffer$2.buffer, seedLow, seedHigh);
        wasmCache$5.writeMemory(seedBuffer$2);
        const hash = wasmCache$5.calculate(data);
        return Promise.resolve(hash);
    }
    catch (err) {
        return Promise.reject(err);
    }
}
/**
 * Creates a new xxHash64 hash instance
 * @param seedLow Lower 32 bits of the number used to
 *  initialize the internal state of the algorithm (defaults to 0)
 * @param seedHigh Higher 32 bits of the number used to
 *  initialize the internal state of the algorithm (defaults to 0)
 */
function createXXHash64(seedLow = 0, seedHigh = 0) {
    if (validateSeed$2(seedLow)) {
        return Promise.reject(validateSeed$2(seedLow));
    }
    if (validateSeed$2(seedHigh)) {
        return Promise.reject(validateSeed$2(seedHigh));
    }
    return WASMInterface(wasmJson$7, 8).then((wasm) => {
        const instanceBuffer = new Uint8Array(8);
        writeSeed$2(instanceBuffer.buffer, seedLow, seedHigh);
        wasm.writeMemory(instanceBuffer);
        wasm.init();
        const obj = {
            init: () => {
                wasm.writeMemory(instanceBuffer);
                wasm.init();
                return obj;
            },
            update: (data) => {
                wasm.update(data);
                return obj;
            },
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
            digest: (outputType) => wasm.digest(outputType),
            save: () => wasm.save(),
            load: (data) => {
                wasm.load(data);
                return obj;
            },
            blockSize: 32,
            digestSize: 8,
        };
        return obj;
    });
}

var name$6 = "xxhash3";
var data$6 = "[encoded data, 11824 characters]";
var hash$6 = "5a2fbdbb";
var wasmJson$6 = {
	name: name$6,
	data: data$6,
	hash: hash$6
};

const mutex$4 = new Mutex();
let wasmCache$4 = null;
const seedBuffer$1 = new Uint8Array(8);
function validateSeed$1(seed) {
    if (!Number.isInteger(seed) || seed < 0 || seed > 0xffffffff) {
        return new Error("Seed must be given as two valid 32-bit long unsigned integers (lo + high).");
    }
    return null;
}
function writeSeed$1(arr, low, high) {
    // write in little-endian format
    const buffer = new DataView(arr);
    buffer.setUint32(0, low, true);
    buffer.setUint32(4, high, true);
}
/**
 * Calculates xxHash3 hash
 * @param data Input data (string, Buffer or TypedArray)
 * @param seedLow Lower 32 bits of the number used to
 *  initialize the internal state of the algorithm (defaults to 0)
 * @param seedHigh Higher 32 bits of the number used to
 *  initialize the internal state of the algorithm (defaults to 0)
 * @returns Computed hash as a hexadecimal string
 */
function xxhash3(data, seedLow = 0, seedHigh = 0) {
    if (validateSeed$1(seedLow)) {
        return Promise.reject(validateSeed$1(seedLow));
    }
    if (validateSeed$1(seedHigh)) {
        return Promise.reject(validateSeed$1(seedHigh));
    }
    if (wasmCache$4 === null) {
        return lockedCreate(mutex$4, wasmJson$6, 8).then((wasm) => {
            wasmCache$4 = wasm;
            writeSeed$1(seedBuffer$1.buffer, seedLow, seedHigh);
            wasmCache$4.writeMemory(seedBuffer$1);
            return wasmCache$4.calculate(data);
        });
    }
    try {
        writeSeed$1(seedBuffer$1.buffer, seedLow, seedHigh);
        wasmCache$4.writeMemory(seedBuffer$1);
        const hash = wasmCache$4.calculate(data);
        return Promise.resolve(hash);
    }
    catch (err) {
        return Promise.reject(err);
    }
}
/**
 * Creates a new xxHash3 hash instance
 * @param seedLow Lower 32 bits of the number used to
 *  initialize the internal state of the algorithm (defaults to 0)
 * @param seedHigh Higher 32 bits of the number used to
 *  initialize the internal state of the algorithm (defaults to 0)
 */
function createXXHash3(seedLow = 0, seedHigh = 0) {
    if (validateSeed$1(seedLow)) {
        return Promise.reject(validateSeed$1(seedLow));
    }
    if (validateSeed$1(seedHigh)) {
        return Promise.reject(validateSeed$1(seedHigh));
    }
    return WASMInterface(wasmJson$6, 8).then((wasm) => {
        const instanceBuffer = new Uint8Array(8);
        writeSeed$1(instanceBuffer.buffer, seedLow, seedHigh);
        wasm.writeMemory(instanceBuffer);
        wasm.init();
        const obj = {
            init: () => {
                wasm.writeMemory(instanceBuffer);
                wasm.init();
                return obj;
            },
            update: (data) => {
                wasm.update(data);
                return obj;
            },
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
            digest: (outputType) => wasm.digest(outputType),
            save: () => wasm.save(),
            load: (data) => {
                wasm.load(data);
                return obj;
            },
            blockSize: 512,
            digestSize: 8,
        };
        return obj;
    });
}

var name$5 = "xxhash128";
var data$5 = "[encoded data, 13736 characters]";
var hash$5 = "b9ab74e2";
var wasmJson$5 = {
	name: name$5,
	data: data$5,
	hash: hash$5
};

const mutex$3 = new Mutex();
let wasmCache$3 = null;
const seedBuffer = new Uint8Array(8);
function validateSeed(seed) {
    if (!Number.isInteger(seed) || seed < 0 || seed > 0xffffffff) {
        return new Error("Seed must be given as two valid 32-bit long unsigned integers (lo + high).");
    }
    return null;
}
function writeSeed(arr, low, high) {
    // write in little-endian format
    const buffer = new DataView(arr);
    buffer.setUint32(0, low, true);
    buffer.setUint32(4, high, true);
}
/**
 * Calculates xxHash128 hash
 * @param data Input data (string, Buffer or TypedArray)
 * @param seedLow Lower 32 bits of the number used to
 *  initialize the internal state of the algorithm (defaults to 0)
 * @param seedHigh Higher 32 bits of the number used to
 *  initialize the internal state of the algorithm (defaults to 0)
 * @returns Computed hash as a hexadecimal string
 */
function xxhash128(data, seedLow = 0, seedHigh = 0) {
    if (validateSeed(seedLow)) {
        return Promise.reject(validateSeed(seedLow));
    }
    if (validateSeed(seedHigh)) {
        return Promise.reject(validateSeed(seedHigh));
    }
    if (wasmCache$3 === null) {
        return lockedCreate(mutex$3, wasmJson$5, 16).then((wasm) => {
            wasmCache$3 = wasm;
            writeSeed(seedBuffer.buffer, seedLow, seedHigh);
            wasmCache$3.writeMemory(seedBuffer);
            return wasmCache$3.calculate(data);
        });
    }
    try {
        writeSeed(seedBuffer.buffer, seedLow, seedHigh);
        wasmCache$3.writeMemory(seedBuffer);
        const hash = wasmCache$3.calculate(data);
        return Promise.resolve(hash);
    }
    catch (err) {
        return Promise.reject(err);
    }
}
/**
 * Creates a new xxHash128 hash instance
 * @param seedLow Lower 32 bits of the number used to
 *  initialize the internal state of the algorithm (defaults to 0)
 * @param seedHigh Higher 32 bits of the number used to
 *  initialize the internal state of the algorithm (defaults to 0)
 */
function createXXHash128(seedLow = 0, seedHigh = 0) {
    if (validateSeed(seedLow)) {
        return Promise.reject(validateSeed(seedLow));
    }
    if (validateSeed(seedHigh)) {
        return Promise.reject(validateSeed(seedHigh));
    }
    return WASMInterface(wasmJson$5, 16).then((wasm) => {
        const instanceBuffer = new Uint8Array(8);
        writeSeed(instanceBuffer.buffer, seedLow, seedHigh);
        wasm.writeMemory(instanceBuffer);
        wasm.init();
        const obj = {
            init: () => {
                wasm.writeMemory(instanceBuffer);
                wasm.init();
                return obj;
            },
            update: (data) => {
                wasm.update(data);
                return obj;
            },
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
            digest: (outputType) => wasm.digest(outputType),
            save: () => wasm.save(),
            load: (data) => {
                wasm.load(data);
                return obj;
            },
            blockSize: 512,
            digestSize: 16,
        };
        return obj;
    });
}

var name$4 = "ripemd160";
var data$4 = "[encoded data, 9020 characters]";
var hash$4 = "6abbce74";
var wasmJson$4 = {
	name: name$4,
	data: data$4,
	hash: hash$4
};

const mutex$2 = new Mutex();
let wasmCache$2 = null;
/**
 * Calculates RIPEMD-160 hash
 * @param data Input data (string, Buffer or TypedArray)
 * @returns Computed hash as a hexadecimal string
 */
function ripemd160(data) {
    if (wasmCache$2 === null) {
        return lockedCreate(mutex$2, wasmJson$4, 20).then((wasm) => {
            wasmCache$2 = wasm;
            return wasmCache$2.calculate(data);
        });
    }
    try {
        const hash = wasmCache$2.calculate(data);
        return Promise.resolve(hash);
    }
    catch (err) {
        return Promise.reject(err);
    }
}
/**
 * Creates a new RIPEMD-160 hash instance
 */
function createRIPEMD160() {
    return WASMInterface(wasmJson$4, 20).then((wasm) => {
        wasm.init();
        const obj = {
            init: () => {
                wasm.init();
                return obj;
            },
            update: (data) => {
                wasm.update(data);
                return obj;
            },
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
            digest: (outputType) => wasm.digest(outputType),
            save: () => wasm.save(),
            load: (data) => {
                wasm.load(data);
                return obj;
            },
            blockSize: 64,
            digestSize: 20,
        };
        return obj;
    });
}

function calculateKeyBuffer(hasher, key) {
    const { blockSize } = hasher;
    const buf = getUInt8Buffer(key);
    if (buf.length > blockSize) {
        hasher.update(buf);
        const uintArr = hasher.digest("binary");
        hasher.init();
        return uintArr;
    }
    return new Uint8Array(buf.buffer, buf.byteOffset, buf.length);
}
function calculateHmac(hasher, key) {
    hasher.init();
    const { blockSize } = hasher;
    const keyBuf = calculateKeyBuffer(hasher, key);
    const keyBuffer = new Uint8Array(blockSize);
    keyBuffer.set(keyBuf);
    const opad = new Uint8Array(blockSize);
    for (let i = 0; i < blockSize; i++) {
        const v = keyBuffer[i];
        opad[i] = v ^ 0x5c;
        keyBuffer[i] = v ^ 0x36;
    }
    hasher.update(keyBuffer);
    const obj = {
        init: () => {
            hasher.init();
            hasher.update(keyBuffer);
            return obj;
        },
        update: (data) => {
            hasher.update(data);
            return obj;
        },
        digest: ((outputType) => {
            const uintArr = hasher.digest("binary");
            hasher.init();
            hasher.update(opad);
            hasher.update(uintArr);
            return hasher.digest(outputType);
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
        }),
        save: () => {
            throw new Error("save() not supported");
        },
        load: () => {
            throw new Error("load() not supported");
        },
        blockSize: hasher.blockSize,
        digestSize: hasher.digestSize,
    };
    return obj;
}
/**
 * Calculates HMAC hash
 * @param hash Hash algorithm to use. It has to be the return value of a function like createSHA1()
 * @param key Key (string, Buffer or TypedArray)
 */
function createHMAC(hash, key) {
    if (!hash || !hash.then) {
        throw new Error('Invalid hash function is provided! Usage: createHMAC(createMD5(), "key").');
    }
    return hash.then((hasher) => calculateHmac(hasher, key));
}

function calculatePBKDF2(digest, salt, iterations, hashLength, outputType) {
    return __awaiter(this, void 0, void 0, function* () {
        const DK = new Uint8Array(hashLength);
        const block1 = new Uint8Array(salt.length + 4);
        const block1View = new DataView(block1.buffer);
        const saltBuffer = getUInt8Buffer(salt);
        const saltUIntBuffer = new Uint8Array(saltBuffer.buffer, saltBuffer.byteOffset, saltBuffer.length);
        block1.set(saltUIntBuffer);
        let destPos = 0;
        const hLen = digest.digestSize;
        const l = Math.ceil(hashLength / hLen);
        let T = null;
        let U = null;
        for (let i = 1; i <= l; i++) {
            block1View.setUint32(salt.length, i);
            digest.init();
            digest.update(block1);
            T = digest.digest("binary");
            U = T.slice();
            for (let j = 1; j < iterations; j++) {
                digest.init();
                digest.update(U);
                U = digest.digest("binary");
                for (let k = 0; k < hLen; k++) {
                    T[k] ^= U[k];
                }
            }
            DK.set(T.subarray(0, hashLength - destPos), destPos);
            destPos += hLen;
        }
        if (outputType === "binary") {
            return DK;
        }
        const digestChars = new Uint8Array(hashLength * 2);
        return getDigestHex(digestChars, DK, hashLength);
    });
}
const validateOptions$2 = (options) => {
    if (!options || typeof options !== "object") {
        throw new Error("Invalid options parameter. It requires an object.");
    }
    if (!options.hashFunction || !options.hashFunction.then) {
        throw new Error('Invalid hash function is provided! Usage: pbkdf2("password", "salt", 1000, 32, createSHA1()).');
    }
    if (!Number.isInteger(options.iterations) || options.iterations < 1) {
        throw new Error("Iterations should be a positive number");
    }
    if (!Number.isInteger(options.hashLength) || options.hashLength < 1) {
        throw new Error("Hash length should be a positive number");
    }
    if (options.outputType === undefined) {
        options.outputType = "hex";
    }
    if (!["hex", "binary"].includes(options.outputType)) {
        throw new Error(`Insupported output type ${options.outputType}. Valid values: ['hex', 'binary']`);
    }
};
/**
 * Generates a new PBKDF2 hash for the supplied password
 */
function pbkdf2(options) {
    return __awaiter(this, void 0, void 0, function* () {
        validateOptions$2(options);
        const hmac = yield createHMAC(options.hashFunction, options.password);
        return calculatePBKDF2(hmac, options.salt, options.iterations, options.hashLength, options.outputType);
    });
}

var name$3 = "scrypt";
var data$3 = "[encoded data, 6800 characters]";
var hash$3 = "b32721f8";
var wasmJson$3 = {
	name: name$3,
	data: data$3,
	hash: hash$3
};

function scryptInternal(options) {
    return __awaiter(this, void 0, void 0, function* () {
        const { costFactor, blockSize, parallelism, hashLength } = options;
        const SHA256Hasher = createSHA256();
        const blockData = yield pbkdf2({
            password: options.password,
            salt: options.salt,
            iterations: 1,
            hashLength: 128 * blockSize * parallelism,
            hashFunction: SHA256Hasher,
            outputType: "binary",
        });
        const scryptInterface = yield WASMInterface(wasmJson$3, 0);
        // last block is for storing the temporary vectors
        const VSize = 128 * blockSize * costFactor;
        const XYSize = 256 * blockSize;
        scryptInterface.setMemorySize(blockData.length + VSize + XYSize);
        scryptInterface.writeMemory(blockData, 0);
        // mix blocks
        scryptInterface.getExports().scrypt(blockSize, costFactor, parallelism);
        const expensiveSalt = scryptInterface
            .getMemory()
            .subarray(0, 128 * blockSize * parallelism);
        const outputData = yield pbkdf2({
            password: options.password,
            salt: expensiveSalt,
            iterations: 1,
            hashLength,
            hashFunction: SHA256Hasher,
            outputType: "binary",
        });
        if (options.outputType === "hex") {
            const digestChars = new Uint8Array(hashLength * 2);
            return getDigestHex(digestChars, outputData, hashLength);
        }
        // return binary format
        return outputData;
    });
}
const isPowerOfTwo = (v) => v && !(v & (v - 1));
const validateOptions$1 = (options) => {
    if (!options || typeof options !== "object") {
        throw new Error("Invalid options parameter. It requires an object.");
    }
    if (!Number.isInteger(options.blockSize) || options.blockSize < 1) {
        throw new Error("Block size should be a positive number");
    }
    if (!Number.isInteger(options.costFactor) ||
        options.costFactor < 2 ||
        !isPowerOfTwo(options.costFactor)) {
        throw new Error("Cost factor should be a power of 2, greater than 1");
    }
    if (!Number.isInteger(options.parallelism) || options.parallelism < 1) {
        throw new Error("Parallelism should be a positive number");
    }
    if (!Number.isInteger(options.hashLength) || options.hashLength < 1) {
        throw new Error("Hash length should be a positive number.");
    }
    if (options.outputType === undefined) {
        options.outputType = "hex";
    }
    if (!["hex", "binary"].includes(options.outputType)) {
        throw new Error(`Insupported output type ${options.outputType}. Valid values: ['hex', 'binary']`);
    }
};
/**
 * Calculates hash using the scrypt password-based key derivation function
 * @returns Computed hash as a hexadecimal string or as
 *          Uint8Array depending on the outputType option
 */
function scrypt(options) {
    return __awaiter(this, void 0, void 0, function* () {
        validateOptions$1(options);
        return scryptInternal(options);
    });
}

var name$2 = "bcrypt";
var data$2 = "[encoded data, 22592 characters]";
var hash$2 = "8bd8822d";
var wasmJson$2 = {
	name: name$2,
	data: data$2,
	hash: hash$2
};

function bcryptInternal(options) {
    return __awaiter(this, void 0, void 0, function* () {
        const { costFactor, password, salt } = options;
        const bcryptInterface = yield WASMInterface(wasmJson$2, 0);
        bcryptInterface.writeMemory(getUInt8Buffer(salt), 0);
        const passwordBuffer = getUInt8Buffer(password);
        bcryptInterface.writeMemory(passwordBuffer, 16);
        const shouldEncode = options.outputType === "encoded" ? 1 : 0;
        bcryptInterface
            .getExports()
            .bcrypt(passwordBuffer.length, costFactor, shouldEncode);
        const memory = bcryptInterface.getMemory();
        if (options.outputType === "encoded") {
            return intArrayToString(memory, 60);
        }
        if (options.outputType === "hex") {
            const digestChars = new Uint8Array(24 * 2);
            return getDigestHex(digestChars, memory, 24);
        }
        // return binary format
        // the data is copied to allow GC of the original memory buffer
        return memory.slice(0, 24);
    });
}
const validateOptions = (options) => {
    if (!options || typeof options !== "object") {
        throw new Error("Invalid options parameter. It requires an object.");
    }
    if (!Number.isInteger(options.costFactor) ||
        options.costFactor < 4 ||
        options.costFactor > 31) {
        throw new Error("Cost factor should be a number between 4 and 31");
    }
    options.password = getUInt8Buffer(options.password);
    if (options.password.length < 1) {
        throw new Error("Password should be at least 1 byte long");
    }
    if (options.password.length > 72) {
        throw new Error("Password should be at most 72 bytes long");
    }
    options.salt = getUInt8Buffer(options.salt);
    if (options.salt.length !== 16) {
        throw new Error("Salt should be 16 bytes long");
    }
    if (options.outputType === undefined) {
        options.outputType = "encoded";
    }
    if (!["hex", "binary", "encoded"].includes(options.outputType)) {
        throw new Error(`Insupported output type ${options.outputType}. Valid values: ['hex', 'binary', 'encoded']`);
    }
};
/**
 * Calculates hash using the bcrypt password-hashing function
 * @returns Computed hash
 */
function bcrypt(options) {
    return __awaiter(this, void 0, void 0, function* () {
        validateOptions(options);
        return bcryptInternal(options);
    });
}
const validateHashCharacters = (hash) => {
    if (!/^\$2[axyb]\$[0-3][0-9]\$[./A-Za-z0-9]{53}$/.test(hash)) {
        return false;
    }
    if (hash[4] === "0" && Number(hash[5]) < 4) {
        return false;
    }
    if (hash[4] === "3" && Number(hash[5]) > 1) {
        return false;
    }
    return true;
};
const validateVerifyOptions = (options) => {
    if (!options || typeof options !== "object") {
        throw new Error("Invalid options parameter. It requires an object.");
    }
    if (options.hash === undefined || typeof options.hash !== "string") {
        throw new Error("Hash should be specified");
    }
    if (options.hash.length !== 60) {
        throw new Error("Hash should be 60 bytes long");
    }
    if (!validateHashCharacters(options.hash)) {
        throw new Error("Invalid hash");
    }
    options.password = getUInt8Buffer(options.password);
    if (options.password.length < 1) {
        throw new Error("Password should be at least 1 byte long");
    }
    if (options.password.length > 72) {
        throw new Error("Password should be at most 72 bytes long");
    }
};
/**
 * Verifies password using bcrypt password-hashing function
 * @returns True if the encoded hash matches the password
 */
function bcryptVerify(options) {
    return __awaiter(this, void 0, void 0, function* () {
        validateVerifyOptions(options);
        const { hash, password } = options;
        const bcryptInterface = yield WASMInterface(wasmJson$2, 0);
        bcryptInterface.writeMemory(getUInt8Buffer(hash), 0);
        const passwordBuffer = getUInt8Buffer(password);
        bcryptInterface.writeMemory(passwordBuffer, 60);
        return !!bcryptInterface.getExports().bcrypt_verify(passwordBuffer.length);
    });
}

var name$1 = "whirlpool";
var data$1 = "[encoded data, 7756 characters]";
var hash$1 = "8d8f6035";
var wasmJson$1 = {
	name: name$1,
	data: data$1,
	hash: hash$1
};

const mutex$1 = new Mutex();
let wasmCache$1 = null;
/**
 * Calculates Whirlpool hash
 * @param data Input data (string, Buffer or TypedArray)
 * @returns Computed hash as a hexadecimal string
 */
function whirlpool(data) {
    if (wasmCache$1 === null) {
        return lockedCreate(mutex$1, wasmJson$1, 64).then((wasm) => {
            wasmCache$1 = wasm;
            return wasmCache$1.calculate(data);
        });
    }
    try {
        const hash = wasmCache$1.calculate(data);
        return Promise.resolve(hash);
    }
    catch (err) {
        return Promise.reject(err);
    }
}
/**
 * Creates a new Whirlpool hash instance
 */
function createWhirlpool() {
    return WASMInterface(wasmJson$1, 64).then((wasm) => {
        wasm.init();
        const obj = {
            init: () => {
                wasm.init();
                return obj;
            },
            update: (data) => {
                wasm.update(data);
                return obj;
            },
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
            digest: (outputType) => wasm.digest(outputType),
            save: () => wasm.save(),
            load: (data) => {
                wasm.load(data);
                return obj;
            },
            blockSize: 64,
            digestSize: 64,
        };
        return obj;
    });
}

var name = "sm3";
var data = "[encoded data, 5408 characters]";
var hash = "b6fb4b8e";
var wasmJson = {
	name: name,
	data: data,
	hash: hash
};

const mutex = new Mutex();
let wasmCache = null;
/**
 * Calculates SM3 hash
 * @param data Input data (string, Buffer or TypedArray)
 * @returns Computed hash as a hexadecimal string
 */
function sm3(data) {
    if (wasmCache === null) {
        return lockedCreate(mutex, wasmJson, 32).then((wasm) => {
            wasmCache = wasm;
            return wasmCache.calculate(data);
        });
    }
    try {
        const hash = wasmCache.calculate(data);
        return Promise.resolve(hash);
    }
    catch (err) {
        return Promise.reject(err);
    }
}
/**
 * Creates a new SM3 hash instance
 */
function createSM3() {
    return WASMInterface(wasmJson, 32).then((wasm) => {
        wasm.init();
        const obj = {
            init: () => {
                wasm.init();
                return obj;
            },
            update: (data) => {
                wasm.update(data);
                return obj;
            },
            // biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
            digest: (outputType) => wasm.digest(outputType),
            save: () => wasm.save(),
            load: (data) => {
                wasm.load(data);
                return obj;
            },
            blockSize: 64,
            digestSize: 32,
        };
        return obj;
    });
}

export { adler32, argon2Verify, argon2d, argon2i, argon2id, bcrypt, bcryptVerify, blake2b, blake2s, blake3, crc32, crc64, createAdler32, createBLAKE2b, createBLAKE2s, createBLAKE3, createCRC32, createCRC64, createHMAC, createKeccak, createMD4, createMD5, createRIPEMD160, createSHA1, createSHA224, createSHA256, createSHA3, createSHA384, createSHA512, createSM3, createWhirlpool, createXXHash128, createXXHash3, createXXHash32, createXXHash64, keccak, md4, md5, pbkdf2, ripemd160, scrypt, sha1, sha224, sha256, sha3, sha384, sha512, sm3, whirlpool, xxhash128, xxhash3, xxhash32, xxhash64 };
