const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["chunks/cardano_serialization_lib-BCNxyBHd.js","chunks/__vite-plugin-wasm-helper-D7K_KhUE.js"])))=>i.map(i=>d[i]);
import { _ as an, x as Ke } from "./request-fingerprint-BANtRL63.js";
let Oe, rt, Tr, Vt, Qo, X, je, hn, Et, Se, Fe, Ee, He, pe, me, cn, Q, Fo, Zo, Yo, Xo, gr, ui, ci, ai, fi, li, Yr, Ct, fo, di, oi, Ro, jo, pn, Go, yn, ct, fr, bo, tt, at, or, Do, Qn, zt, hi, mn, Xr, ar, bt, vn, It, mt, yt, Ze, ue, Ge, si, Gr, At, Fr, Pr, dr, dn, ni, Zt, ii, Fn, Yt, ri, ti;
let __tla = (async ()=>{
    const Ae = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
    rt = function(t) {
        return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
    };
    Se = function(t) {
        if (!Number.isSafeInteger(t) || t < 0) throw new Error("positive integer expected, got " + t);
    };
    me = function(t, ...e) {
        if (!rt(t)) throw new Error("Uint8Array expected");
        if (e.length > 0 && !e.includes(t.length)) throw new Error("Uint8Array expected of length " + e + ", got length=" + t.length);
    };
    ar = function(t) {
        if (typeof t != "function" || typeof t.create != "function") throw new Error("Hash should be wrapped by utils.createHasher");
        Se(t.outputLen), Se(t.blockLen);
    };
    He = function(t, e = !0) {
        if (t.destroyed) throw new Error("Hash instance has been destroyed");
        if (e && t.finished) throw new Error("Hash#digest() has already been called");
    };
    cn = function(t, e) {
        me(t);
        const n = e.outputLen;
        if (t.length < n) throw new Error("digestInto() expects output buffer of length at least " + n);
    };
    Fe = function(t) {
        return new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4));
    };
    Q = function(...t) {
        for(let e = 0; e < t.length; e++)t[e].fill(0);
    };
    ct = function(t) {
        return new DataView(t.buffer, t.byteOffset, t.byteLength);
    };
    function Z(t, e) {
        return t << 32 - e | t >>> e;
    }
    Go = function(t, e) {
        return t << e | t >>> 32 - e >>> 0;
    };
    const ln = new Uint8Array(new Uint32Array([
        287454020
    ]).buffer)[0] === 68;
    function fn(t) {
        return t << 24 & 4278190080 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 255;
    }
    const W = ln ? (t)=>t : (t)=>fn(t);
    function cr(t) {
        for(let e = 0; e < t.length; e++)t[e] = fn(t[e]);
        return t;
    }
    let un, lr;
    Ee = ln ? (t)=>t : cr;
    un = typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function";
    lr = Array.from({
        length: 256
    }, (t, e)=>e.toString(16).padStart(2, "0"));
    At = function(t) {
        if (me(t), un) return t.toHex();
        let e = "";
        for(let n = 0; n < t.length; n++)e += lr[t[n]];
        return e;
    };
    const Y = {
        _0: 48,
        _9: 57,
        A: 65,
        F: 70,
        a: 97,
        f: 102
    };
    function jt(t) {
        if (t >= Y._0 && t <= Y._9) return t - Y._0;
        if (t >= Y.A && t <= Y.F) return t - (Y.A - 10);
        if (t >= Y.a && t <= Y.f) return t - (Y.a - 10);
    }
    dn = function(t) {
        if (typeof t != "string") throw new Error("hex string expected, got " + typeof t);
        if (un) return Uint8Array.fromHex(t);
        const e = t.length, n = e / 2;
        if (e % 2) throw new Error("hex string expected, got unpadded hex of length " + e);
        const r = new Uint8Array(n);
        for(let s = 0, o = 0; s < n; s++, o += 2){
            const i = jt(t.charCodeAt(o)), c = jt(t.charCodeAt(o + 1));
            if (i === void 0 || c === void 0) {
                const a = t[o] + t[o + 1];
                throw new Error('hex string expected, got non-hex character "' + a + '" at index ' + o);
            }
            r[s] = i * 16 + c;
        }
        return r;
    };
    fr = function(t) {
        if (typeof t != "string") throw new Error("string expected");
        return new Uint8Array(new TextEncoder().encode(t));
    };
    pe = function(t) {
        return typeof t == "string" && (t = fr(t)), me(t), t;
    };
    bt = function(...t) {
        let e = 0;
        for(let r = 0; r < t.length; r++){
            const s = t[r];
            me(s), e += s.length;
        }
        const n = new Uint8Array(e);
        for(let r = 0, s = 0; r < t.length; r++){
            const o = t[r];
            n.set(o, s), s += o.length;
        }
        return n;
    };
    Et = class {
    };
    hn = function(t) {
        const e = (r)=>t().update(pe(r)).digest(), n = t();
        return e.outputLen = n.outputLen, e.blockLen = n.blockLen, e.create = ()=>t(), e;
    };
    function ur(t) {
        const e = (r, s)=>t(s).update(pe(r)).digest(), n = t({});
        return e.outputLen = n.outputLen, e.blockLen = n.blockLen, e.create = (r)=>t(r), e;
    }
    dr = function(t = 32) {
        if (Ae && typeof Ae.getRandomValues == "function") return Ae.getRandomValues(new Uint8Array(t));
        if (Ae && typeof Ae.randomBytes == "function") return Uint8Array.from(Ae.randomBytes(t));
        throw new Error("crypto.getRandomValues must be defined");
    };
    const hr = Uint8Array.from([
        0,
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        14,
        10,
        4,
        8,
        9,
        15,
        13,
        6,
        1,
        12,
        0,
        2,
        11,
        7,
        5,
        3,
        11,
        8,
        12,
        0,
        5,
        2,
        15,
        13,
        10,
        14,
        3,
        6,
        7,
        1,
        9,
        4,
        7,
        9,
        3,
        1,
        13,
        12,
        11,
        14,
        2,
        6,
        5,
        10,
        4,
        0,
        15,
        8,
        9,
        0,
        5,
        7,
        2,
        4,
        10,
        15,
        14,
        1,
        11,
        12,
        6,
        8,
        3,
        13,
        2,
        12,
        6,
        10,
        0,
        11,
        8,
        3,
        4,
        13,
        7,
        5,
        15,
        14,
        1,
        9,
        12,
        5,
        1,
        15,
        14,
        13,
        4,
        10,
        0,
        7,
        6,
        3,
        9,
        2,
        8,
        11,
        13,
        11,
        7,
        14,
        12,
        1,
        3,
        9,
        5,
        0,
        15,
        4,
        8,
        6,
        2,
        10,
        6,
        15,
        14,
        9,
        11,
        3,
        0,
        8,
        12,
        2,
        13,
        7,
        1,
        4,
        10,
        5,
        10,
        2,
        8,
        4,
        7,
        6,
        1,
        5,
        15,
        11,
        9,
        14,
        3,
        12,
        13,
        0,
        0,
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        11,
        12,
        13,
        14,
        15,
        14,
        10,
        4,
        8,
        9,
        15,
        13,
        6,
        1,
        12,
        0,
        2,
        11,
        7,
        5,
        3,
        11,
        8,
        12,
        0,
        5,
        2,
        15,
        13,
        10,
        14,
        3,
        6,
        7,
        1,
        9,
        4,
        7,
        9,
        3,
        1,
        13,
        12,
        11,
        14,
        2,
        6,
        5,
        10,
        4,
        0,
        15,
        8,
        9,
        0,
        5,
        7,
        2,
        4,
        10,
        15,
        14,
        1,
        11,
        12,
        6,
        8,
        3,
        13,
        2,
        12,
        6,
        10,
        0,
        11,
        8,
        3,
        4,
        13,
        7,
        5,
        15,
        14,
        1,
        9
    ]);
    function pr(t, e, n, r) {
        if (typeof t.setBigUint64 == "function") return t.setBigUint64(e, n, r);
        const s = BigInt(32), o = BigInt(4294967295), i = Number(n >> s & o), c = Number(n & o), a = r ? 4 : 0, u = r ? 0 : 4;
        t.setUint32(e + a, i, r), t.setUint32(e + u, c, r);
    }
    function br(t, e, n) {
        return t & e ^ ~t & n;
    }
    function mr(t, e, n) {
        return t & e ^ t & n ^ e & n;
    }
    pn = class extends Et {
        constructor(e, n, r, s){
            super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = e, this.outputLen = n, this.padOffset = r, this.isLE = s, this.buffer = new Uint8Array(e), this.view = ct(this.buffer);
        }
        update(e) {
            He(this), e = pe(e), me(e);
            const { view: n, buffer: r, blockLen: s } = this, o = e.length;
            for(let i = 0; i < o;){
                const c = Math.min(s - this.pos, o - i);
                if (c === s) {
                    const a = ct(e);
                    for(; s <= o - i; i += s)this.process(a, i);
                    continue;
                }
                r.set(e.subarray(i, i + c), this.pos), this.pos += c, i += c, this.pos === s && (this.process(n, 0), this.pos = 0);
            }
            return this.length += e.length, this.roundClean(), this;
        }
        digestInto(e) {
            He(this), cn(e, this), this.finished = !0;
            const { buffer: n, view: r, blockLen: s, isLE: o } = this;
            let { pos: i } = this;
            n[i++] = 128, Q(this.buffer.subarray(i)), this.padOffset > s - i && (this.process(r, 0), i = 0);
            for(let f = i; f < s; f++)n[f] = 0;
            pr(r, s - 8, BigInt(this.length * 8), o), this.process(r, 0);
            const c = ct(e), a = this.outputLen;
            if (a % 4) throw new Error("_sha2: outputLen should be aligned to 32bit");
            const u = a / 4, h = this.get();
            if (u > h.length) throw new Error("_sha2: outputLen bigger than state");
            for(let f = 0; f < u; f++)c.setUint32(4 * f, h[f], o);
        }
        digest() {
            const { buffer: e, outputLen: n } = this;
            this.digestInto(e);
            const r = e.slice(0, n);
            return this.destroy(), r;
        }
        _cloneInto(e) {
            e || (e = new this.constructor), e.set(...this.get());
            const { blockLen: n, buffer: r, length: s, finished: o, destroyed: i, pos: c } = this;
            return e.destroyed = i, e.finished = o, e.length = s, e.pos = c, s % n && e.buffer.set(r), e;
        }
        clone() {
            return this._cloneInto();
        }
    };
    const ee = Uint32Array.from([
        1779033703,
        3144134277,
        1013904242,
        2773480762,
        1359893119,
        2600822924,
        528734635,
        1541459225
    ]), j = Uint32Array.from([
        1779033703,
        4089235720,
        3144134277,
        2227873595,
        1013904242,
        4271175723,
        2773480762,
        1595750129,
        1359893119,
        2917565137,
        2600822924,
        725511199,
        528734635,
        4215389547,
        1541459225,
        327033209
    ]), Me = BigInt(2 ** 32 - 1), Kt = BigInt(32);
    function bn(t, e = !1) {
        return e ? {
            h: Number(t & Me),
            l: Number(t >> Kt & Me)
        } : {
            h: Number(t >> Kt & Me) | 0,
            l: Number(t & Me) | 0
        };
    }
    gr = function(t, e = !1) {
        const n = t.length;
        let r = new Uint32Array(n), s = new Uint32Array(n);
        for(let o = 0; o < n; o++){
            const { h: i, l: c } = bn(t[o], e);
            [r[o], s[o]] = [
                i,
                c
            ];
        }
        return [
            r,
            s
        ];
    };
    let Mt, Gt, de, he, Te, Ne, yr, wr;
    Mt = (t, e, n)=>t >>> n;
    Gt = (t, e, n)=>t << 32 - n | e >>> n;
    de = (t, e, n)=>t >>> n | e << 32 - n;
    he = (t, e, n)=>t << 32 - n | e >>> n;
    Te = (t, e, n)=>t << 64 - n | e >>> n - 32;
    Ne = (t, e, n)=>t >>> n - 32 | e << 64 - n;
    yr = (t, e)=>e;
    wr = (t, e)=>t;
    Zo = (t, e, n)=>t << n | e >>> 32 - n;
    Xo = (t, e, n)=>e << n | t >>> 32 - n;
    Fo = (t, e, n)=>e << n - 32 | t >>> 64 - n;
    Yo = (t, e, n)=>t << n - 32 | e >>> 64 - n;
    function P(t, e, n, r) {
        const s = (e >>> 0) + (r >>> 0);
        return {
            h: t + n + (s / 2 ** 32 | 0) | 0,
            l: s | 0
        };
    }
    const Bt = (t, e, n)=>(t >>> 0) + (e >>> 0) + (n >>> 0), kt = (t, e, n, r)=>e + n + r + (t / 2 ** 32 | 0) | 0, xr = (t, e, n, r)=>(t >>> 0) + (e >>> 0) + (n >>> 0) + (r >>> 0), vr = (t, e, n, r, s)=>e + n + r + s + (t / 2 ** 32 | 0) | 0, _r = (t, e, n, r, s)=>(t >>> 0) + (e >>> 0) + (n >>> 0) + (r >>> 0) + (s >>> 0), Ar = (t, e, n, r, s, o)=>e + n + r + s + o + (t / 2 ** 32 | 0) | 0, z = Uint32Array.from([
        4089235720,
        1779033703,
        2227873595,
        3144134277,
        4271175723,
        1013904242,
        1595750129,
        2773480762,
        2917565137,
        1359893119,
        725511199,
        2600822924,
        4215389547,
        528734635,
        327033209,
        1541459225
    ]), x = new Uint32Array(32);
    function te(t, e, n, r, s, o) {
        const i = s[o], c = s[o + 1];
        let a = x[2 * t], u = x[2 * t + 1], h = x[2 * e], f = x[2 * e + 1], l = x[2 * n], d = x[2 * n + 1], p = x[2 * r], m = x[2 * r + 1], w = Bt(a, h, i);
        u = kt(w, u, f, c), a = w | 0, { Dh: m, Dl: p } = {
            Dh: m ^ u,
            Dl: p ^ a
        }, { Dh: m, Dl: p } = {
            Dh: yr(m, p),
            Dl: wr(m)
        }, { h: d, l } = P(d, l, m, p), { Bh: f, Bl: h } = {
            Bh: f ^ d,
            Bl: h ^ l
        }, { Bh: f, Bl: h } = {
            Bh: de(f, h, 24),
            Bl: he(f, h, 24)
        }, x[2 * t] = a, x[2 * t + 1] = u, x[2 * e] = h, x[2 * e + 1] = f, x[2 * n] = l, x[2 * n + 1] = d, x[2 * r] = p, x[2 * r + 1] = m;
    }
    function ne(t, e, n, r, s, o) {
        const i = s[o], c = s[o + 1];
        let a = x[2 * t], u = x[2 * t + 1], h = x[2 * e], f = x[2 * e + 1], l = x[2 * n], d = x[2 * n + 1], p = x[2 * r], m = x[2 * r + 1], w = Bt(a, h, i);
        u = kt(w, u, f, c), a = w | 0, { Dh: m, Dl: p } = {
            Dh: m ^ u,
            Dl: p ^ a
        }, { Dh: m, Dl: p } = {
            Dh: de(m, p, 16),
            Dl: he(m, p, 16)
        }, { h: d, l } = P(d, l, m, p), { Bh: f, Bl: h } = {
            Bh: f ^ d,
            Bl: h ^ l
        }, { Bh: f, Bl: h } = {
            Bh: Te(f, h, 63),
            Bl: Ne(f, h, 63)
        }, x[2 * t] = a, x[2 * t + 1] = u, x[2 * e] = h, x[2 * e + 1] = f, x[2 * n] = l, x[2 * n + 1] = d, x[2 * r] = p, x[2 * r + 1] = m;
    }
    function Er(t, e = {}, n, r, s) {
        if (Se(n), t < 0 || t > n) throw new Error("outputLen bigger than keyLen");
        const { key: o, salt: i, personalization: c } = e;
        if (o !== void 0 && (o.length < 1 || o.length > n)) throw new Error("key length must be undefined or 1.." + n);
        if (i !== void 0 && i.length !== r) throw new Error("salt must be undefined or " + r);
        if (c !== void 0 && c.length !== s) throw new Error("personalization must be undefined or " + s);
    }
    class Br extends Et {
        constructor(e, n){
            super(), this.finished = !1, this.destroyed = !1, this.length = 0, this.pos = 0, Se(e), Se(n), this.blockLen = e, this.outputLen = n, this.buffer = new Uint8Array(e), this.buffer32 = Fe(this.buffer);
        }
        update(e) {
            He(this), e = pe(e), me(e);
            const { blockLen: n, buffer: r, buffer32: s } = this, o = e.length, i = e.byteOffset, c = e.buffer;
            for(let a = 0; a < o;){
                this.pos === n && (Ee(s), this.compress(s, 0, !1), Ee(s), this.pos = 0);
                const u = Math.min(n - this.pos, o - a), h = i + a;
                if (u === n && !(h % 4) && a + u < o) {
                    const f = new Uint32Array(c, h, Math.floor((o - a) / 4));
                    Ee(f);
                    for(let l = 0; a + n < o; l += s.length, a += n)this.length += n, this.compress(f, l, !1);
                    Ee(f);
                    continue;
                }
                r.set(e.subarray(a, a + u), this.pos), this.pos += u, this.length += u, a += u;
            }
            return this;
        }
        digestInto(e) {
            He(this), cn(e, this);
            const { pos: n, buffer32: r } = this;
            this.finished = !0, Q(this.buffer.subarray(n)), Ee(r), this.compress(r, 0, !0), Ee(r);
            const s = Fe(e);
            this.get().forEach((o, i)=>s[i] = W(o));
        }
        digest() {
            const { buffer: e, outputLen: n } = this;
            this.digestInto(e);
            const r = e.slice(0, n);
            return this.destroy(), r;
        }
        _cloneInto(e) {
            const { buffer: n, length: r, finished: s, destroyed: o, outputLen: i, pos: c } = this;
            return e || (e = new this.constructor({
                dkLen: i
            })), e.set(...this.get()), e.buffer.set(n), e.destroyed = o, e.finished = s, e.length = r, e.pos = c, e.outputLen = i, e;
        }
        clone() {
            return this._cloneInto();
        }
    }
    class kr extends Br {
        constructor(e = {}){
            const n = e.dkLen === void 0 ? 64 : e.dkLen;
            super(128, n), this.v0l = z[0] | 0, this.v0h = z[1] | 0, this.v1l = z[2] | 0, this.v1h = z[3] | 0, this.v2l = z[4] | 0, this.v2h = z[5] | 0, this.v3l = z[6] | 0, this.v3h = z[7] | 0, this.v4l = z[8] | 0, this.v4h = z[9] | 0, this.v5l = z[10] | 0, this.v5h = z[11] | 0, this.v6l = z[12] | 0, this.v6h = z[13] | 0, this.v7l = z[14] | 0, this.v7h = z[15] | 0, Er(n, e, 64, 16, 16);
            let { key: r, personalization: s, salt: o } = e, i = 0;
            if (r !== void 0 && (r = pe(r), i = r.length), this.v0l ^= this.outputLen | i << 8 | 65536 | 1 << 24, o !== void 0) {
                o = pe(o);
                const c = Fe(o);
                this.v4l ^= W(c[0]), this.v4h ^= W(c[1]), this.v5l ^= W(c[2]), this.v5h ^= W(c[3]);
            }
            if (s !== void 0) {
                s = pe(s);
                const c = Fe(s);
                this.v6l ^= W(c[0]), this.v6h ^= W(c[1]), this.v7l ^= W(c[2]), this.v7h ^= W(c[3]);
            }
            if (r !== void 0) {
                const c = new Uint8Array(this.blockLen);
                c.set(r), this.update(c);
            }
        }
        get() {
            let { v0l: e, v0h: n, v1l: r, v1h: s, v2l: o, v2h: i, v3l: c, v3h: a, v4l: u, v4h: h, v5l: f, v5h: l, v6l: d, v6h: p, v7l: m, v7h: w } = this;
            return [
                e,
                n,
                r,
                s,
                o,
                i,
                c,
                a,
                u,
                h,
                f,
                l,
                d,
                p,
                m,
                w
            ];
        }
        set(e, n, r, s, o, i, c, a, u, h, f, l, d, p, m, w) {
            this.v0l = e | 0, this.v0h = n | 0, this.v1l = r | 0, this.v1h = s | 0, this.v2l = o | 0, this.v2h = i | 0, this.v3l = c | 0, this.v3h = a | 0, this.v4l = u | 0, this.v4h = h | 0, this.v5l = f | 0, this.v5h = l | 0, this.v6l = d | 0, this.v6h = p | 0, this.v7l = m | 0, this.v7h = w | 0;
        }
        compress(e, n, r) {
            this.get().forEach((a, u)=>x[u] = a), x.set(z, 16);
            let { h: s, l: o } = bn(BigInt(this.length));
            x[24] = z[8] ^ o, x[25] = z[9] ^ s, r && (x[28] = ~x[28], x[29] = ~x[29]);
            let i = 0;
            const c = hr;
            for(let a = 0; a < 12; a++)te(0, 4, 8, 12, e, n + 2 * c[i++]), ne(0, 4, 8, 12, e, n + 2 * c[i++]), te(1, 5, 9, 13, e, n + 2 * c[i++]), ne(1, 5, 9, 13, e, n + 2 * c[i++]), te(2, 6, 10, 14, e, n + 2 * c[i++]), ne(2, 6, 10, 14, e, n + 2 * c[i++]), te(3, 7, 11, 15, e, n + 2 * c[i++]), ne(3, 7, 11, 15, e, n + 2 * c[i++]), te(0, 5, 10, 15, e, n + 2 * c[i++]), ne(0, 5, 10, 15, e, n + 2 * c[i++]), te(1, 6, 11, 12, e, n + 2 * c[i++]), ne(1, 6, 11, 12, e, n + 2 * c[i++]), te(2, 7, 8, 13, e, n + 2 * c[i++]), ne(2, 7, 8, 13, e, n + 2 * c[i++]), te(3, 4, 9, 14, e, n + 2 * c[i++]), ne(3, 4, 9, 14, e, n + 2 * c[i++]);
            this.v0l ^= x[0] ^ x[16], this.v0h ^= x[1] ^ x[17], this.v1l ^= x[2] ^ x[18], this.v1h ^= x[3] ^ x[19], this.v2l ^= x[4] ^ x[20], this.v2h ^= x[5] ^ x[21], this.v3l ^= x[6] ^ x[22], this.v3h ^= x[7] ^ x[23], this.v4l ^= x[8] ^ x[24], this.v4h ^= x[9] ^ x[25], this.v5l ^= x[10] ^ x[26], this.v5h ^= x[11] ^ x[27], this.v6l ^= x[12] ^ x[28], this.v6h ^= x[13] ^ x[29], this.v7l ^= x[14] ^ x[30], this.v7h ^= x[15] ^ x[31], Q(x);
        }
        destroy() {
            this.destroyed = !0, Q(this.buffer32), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
        }
    }
    let Sr, Hr, re;
    Sr = ur((t)=>new kr(t));
    mn = Sr;
    Hr = Uint32Array.from([
        1116352408,
        1899447441,
        3049323471,
        3921009573,
        961987163,
        1508970993,
        2453635748,
        2870763221,
        3624381080,
        310598401,
        607225278,
        1426881987,
        1925078388,
        2162078206,
        2614888103,
        3248222580,
        3835390401,
        4022224774,
        264347078,
        604807628,
        770255983,
        1249150122,
        1555081692,
        1996064986,
        2554220882,
        2821834349,
        2952996808,
        3210313671,
        3336571891,
        3584528711,
        113926993,
        338241895,
        666307205,
        773529912,
        1294757372,
        1396182291,
        1695183700,
        1986661051,
        2177026350,
        2456956037,
        2730485921,
        2820302411,
        3259730800,
        3345764771,
        3516065817,
        3600352804,
        4094571909,
        275423344,
        430227734,
        506948616,
        659060556,
        883997877,
        958139571,
        1322822218,
        1537002063,
        1747873779,
        1955562222,
        2024104815,
        2227730452,
        2361852424,
        2428436474,
        2756734187,
        3204031479,
        3329325298
    ]);
    re = new Uint32Array(64);
    let Ir = class extends pn {
        constructor(e = 32){
            super(64, e, 8, !1), this.A = ee[0] | 0, this.B = ee[1] | 0, this.C = ee[2] | 0, this.D = ee[3] | 0, this.E = ee[4] | 0, this.F = ee[5] | 0, this.G = ee[6] | 0, this.H = ee[7] | 0;
        }
        get() {
            const { A: e, B: n, C: r, D: s, E: o, F: i, G: c, H: a } = this;
            return [
                e,
                n,
                r,
                s,
                o,
                i,
                c,
                a
            ];
        }
        set(e, n, r, s, o, i, c, a) {
            this.A = e | 0, this.B = n | 0, this.C = r | 0, this.D = s | 0, this.E = o | 0, this.F = i | 0, this.G = c | 0, this.H = a | 0;
        }
        process(e, n) {
            for(let f = 0; f < 16; f++, n += 4)re[f] = e.getUint32(n, !1);
            for(let f = 16; f < 64; f++){
                const l = re[f - 15], d = re[f - 2], p = Z(l, 7) ^ Z(l, 18) ^ l >>> 3, m = Z(d, 17) ^ Z(d, 19) ^ d >>> 10;
                re[f] = m + re[f - 7] + p + re[f - 16] | 0;
            }
            let { A: r, B: s, C: o, D: i, E: c, F: a, G: u, H: h } = this;
            for(let f = 0; f < 64; f++){
                const l = Z(c, 6) ^ Z(c, 11) ^ Z(c, 25), d = h + l + br(c, a, u) + Hr[f] + re[f] | 0, m = (Z(r, 2) ^ Z(r, 13) ^ Z(r, 22)) + mr(r, s, o) | 0;
                h = u, u = a, a = c, c = i + d | 0, i = o, o = s, s = r, r = d + m | 0;
            }
            r = r + this.A | 0, s = s + this.B | 0, o = o + this.C | 0, i = i + this.D | 0, c = c + this.E | 0, a = a + this.F | 0, u = u + this.G | 0, h = h + this.H | 0, this.set(r, s, o, i, c, a, u, h);
        }
        roundClean() {
            Q(re);
        }
        destroy() {
            this.set(0, 0, 0, 0, 0, 0, 0, 0), Q(this.buffer);
        }
    };
    const gn = gr([
        "0x428a2f98d728ae22",
        "0x7137449123ef65cd",
        "0xb5c0fbcfec4d3b2f",
        "0xe9b5dba58189dbbc",
        "0x3956c25bf348b538",
        "0x59f111f1b605d019",
        "0x923f82a4af194f9b",
        "0xab1c5ed5da6d8118",
        "0xd807aa98a3030242",
        "0x12835b0145706fbe",
        "0x243185be4ee4b28c",
        "0x550c7dc3d5ffb4e2",
        "0x72be5d74f27b896f",
        "0x80deb1fe3b1696b1",
        "0x9bdc06a725c71235",
        "0xc19bf174cf692694",
        "0xe49b69c19ef14ad2",
        "0xefbe4786384f25e3",
        "0x0fc19dc68b8cd5b5",
        "0x240ca1cc77ac9c65",
        "0x2de92c6f592b0275",
        "0x4a7484aa6ea6e483",
        "0x5cb0a9dcbd41fbd4",
        "0x76f988da831153b5",
        "0x983e5152ee66dfab",
        "0xa831c66d2db43210",
        "0xb00327c898fb213f",
        "0xbf597fc7beef0ee4",
        "0xc6e00bf33da88fc2",
        "0xd5a79147930aa725",
        "0x06ca6351e003826f",
        "0x142929670a0e6e70",
        "0x27b70a8546d22ffc",
        "0x2e1b21385c26c926",
        "0x4d2c6dfc5ac42aed",
        "0x53380d139d95b3df",
        "0x650a73548baf63de",
        "0x766a0abb3c77b2a8",
        "0x81c2c92e47edaee6",
        "0x92722c851482353b",
        "0xa2bfe8a14cf10364",
        "0xa81a664bbc423001",
        "0xc24b8b70d0f89791",
        "0xc76c51a30654be30",
        "0xd192e819d6ef5218",
        "0xd69906245565a910",
        "0xf40e35855771202a",
        "0x106aa07032bbd1b8",
        "0x19a4c116b8d2d0c8",
        "0x1e376c085141ab53",
        "0x2748774cdf8eeb99",
        "0x34b0bcb5e19b48a8",
        "0x391c0cb3c5c95a63",
        "0x4ed8aa4ae3418acb",
        "0x5b9cca4f7763e373",
        "0x682e6ff3d6b2b8a3",
        "0x748f82ee5defb2fc",
        "0x78a5636f43172f60",
        "0x84c87814a1f0ab72",
        "0x8cc702081a6439ec",
        "0x90befffa23631e28",
        "0xa4506cebde82bde9",
        "0xbef9a3f7b2c67915",
        "0xc67178f2e372532b",
        "0xca273eceea26619c",
        "0xd186b8c721c0c207",
        "0xeada7dd6cde0eb1e",
        "0xf57d4f7fee6ed178",
        "0x06f067aa72176fba",
        "0x0a637dc5a2c898a6",
        "0x113f9804bef90dae",
        "0x1b710b35131c471b",
        "0x28db77f523047d84",
        "0x32caab7b40c72493",
        "0x3c9ebe0a15c9bebc",
        "0x431d67c49c100d4c",
        "0x4cc5d4becb3e42b6",
        "0x597f299cfc657e2a",
        "0x5fcb6fab3ad6faec",
        "0x6c44198c4a475817"
    ].map((t)=>BigInt(t))), Cr = gn[0], Lr = gn[1], se = new Uint32Array(80), oe = new Uint32Array(80);
    let Ur = class extends pn {
        constructor(e = 64){
            super(128, e, 16, !1), this.Ah = j[0] | 0, this.Al = j[1] | 0, this.Bh = j[2] | 0, this.Bl = j[3] | 0, this.Ch = j[4] | 0, this.Cl = j[5] | 0, this.Dh = j[6] | 0, this.Dl = j[7] | 0, this.Eh = j[8] | 0, this.El = j[9] | 0, this.Fh = j[10] | 0, this.Fl = j[11] | 0, this.Gh = j[12] | 0, this.Gl = j[13] | 0, this.Hh = j[14] | 0, this.Hl = j[15] | 0;
        }
        get() {
            const { Ah: e, Al: n, Bh: r, Bl: s, Ch: o, Cl: i, Dh: c, Dl: a, Eh: u, El: h, Fh: f, Fl: l, Gh: d, Gl: p, Hh: m, Hl: w } = this;
            return [
                e,
                n,
                r,
                s,
                o,
                i,
                c,
                a,
                u,
                h,
                f,
                l,
                d,
                p,
                m,
                w
            ];
        }
        set(e, n, r, s, o, i, c, a, u, h, f, l, d, p, m, w) {
            this.Ah = e | 0, this.Al = n | 0, this.Bh = r | 0, this.Bl = s | 0, this.Ch = o | 0, this.Cl = i | 0, this.Dh = c | 0, this.Dl = a | 0, this.Eh = u | 0, this.El = h | 0, this.Fh = f | 0, this.Fl = l | 0, this.Gh = d | 0, this.Gl = p | 0, this.Hh = m | 0, this.Hl = w | 0;
        }
        process(e, n) {
            for(let b = 0; b < 16; b++, n += 4)se[b] = e.getUint32(n), oe[b] = e.getUint32(n += 4);
            for(let b = 16; b < 80; b++){
                const E = se[b - 15] | 0, B = oe[b - 15] | 0, I = de(E, B, 1) ^ de(E, B, 8) ^ Mt(E, B, 7), C = he(E, B, 1) ^ he(E, B, 8) ^ Gt(E, B, 7), k = se[b - 2] | 0, g = oe[b - 2] | 0, v = de(k, g, 19) ^ Te(k, g, 61) ^ Mt(k, g, 6), A = he(k, g, 19) ^ Ne(k, g, 61) ^ Gt(k, g, 6), S = xr(C, A, oe[b - 7], oe[b - 16]), $ = vr(S, I, v, se[b - 7], se[b - 16]);
                se[b] = $ | 0, oe[b] = S | 0;
            }
            let { Ah: r, Al: s, Bh: o, Bl: i, Ch: c, Cl: a, Dh: u, Dl: h, Eh: f, El: l, Fh: d, Fl: p, Gh: m, Gl: w, Hh: y, Hl: _ } = this;
            for(let b = 0; b < 80; b++){
                const E = de(f, l, 14) ^ de(f, l, 18) ^ Te(f, l, 41), B = he(f, l, 14) ^ he(f, l, 18) ^ Ne(f, l, 41), I = f & d ^ ~f & m, C = l & p ^ ~l & w, k = _r(_, B, C, Lr[b], oe[b]), g = Ar(k, y, E, I, Cr[b], se[b]), v = k | 0, A = de(r, s, 28) ^ Te(r, s, 34) ^ Te(r, s, 39), S = he(r, s, 28) ^ Ne(r, s, 34) ^ Ne(r, s, 39), $ = r & o ^ r & c ^ o & c, U = s & i ^ s & a ^ i & a;
                y = m | 0, _ = w | 0, m = d | 0, w = p | 0, d = f | 0, p = l | 0, { h: f, l } = P(u | 0, h | 0, g | 0, v | 0), u = c | 0, h = a | 0, c = o | 0, a = i | 0, o = r | 0, i = s | 0;
                const T = Bt(v, S, U);
                r = kt(T, g, A, $), s = T | 0;
            }
            ({ h: r, l: s } = P(this.Ah | 0, this.Al | 0, r | 0, s | 0)), { h: o, l: i } = P(this.Bh | 0, this.Bl | 0, o | 0, i | 0), { h: c, l: a } = P(this.Ch | 0, this.Cl | 0, c | 0, a | 0), { h: u, l: h } = P(this.Dh | 0, this.Dl | 0, u | 0, h | 0), { h: f, l } = P(this.Eh | 0, this.El | 0, f | 0, l | 0), { h: d, l: p } = P(this.Fh | 0, this.Fl | 0, d | 0, p | 0), { h: m, l: w } = P(this.Gh | 0, this.Gl | 0, m | 0, w | 0), { h: y, l: _ } = P(this.Hh | 0, this.Hl | 0, y | 0, _ | 0), this.set(r, s, o, i, c, a, u, h, f, l, d, p, m, w, y, _);
        }
        roundClean() {
            Q(se, oe);
        }
        destroy() {
            Q(this.buffer), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
        }
    };
    Qo = hn(()=>new Ir);
    yn = hn(()=>new Ur);
    let wn = class extends Et {
        constructor(e, n){
            super(), this.finished = !1, this.destroyed = !1, ar(e);
            const r = pe(n);
            if (this.iHash = e.create(), typeof this.iHash.update != "function") throw new Error("Expected instance of class which extends utils.Hash");
            this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
            const s = this.blockLen, o = new Uint8Array(s);
            o.set(r.length > s ? e.create().update(r).digest() : r);
            for(let i = 0; i < o.length; i++)o[i] ^= 54;
            this.iHash.update(o), this.oHash = e.create();
            for(let i = 0; i < o.length; i++)o[i] ^= 106;
            this.oHash.update(o), Q(o);
        }
        update(e) {
            return He(this), this.iHash.update(e), this;
        }
        digestInto(e) {
            He(this), me(e, this.outputLen), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();
        }
        digest() {
            const e = new Uint8Array(this.oHash.outputLen);
            return this.digestInto(e), e;
        }
        _cloneInto(e) {
            e || (e = Object.create(Object.getPrototypeOf(this), {}));
            const { oHash: n, iHash: r, finished: s, destroyed: o, blockLen: i, outputLen: c } = this;
            return e = e, e.finished = s, e.destroyed = o, e.blockLen = i, e.outputLen = c, e.oHash = n._cloneInto(e.oHash), e.iHash = r._cloneInto(e.iHash), e;
        }
        clone() {
            return this._cloneInto();
        }
        destroy() {
            this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
        }
    };
    mt = (t, e, n)=>new wn(t, e).update(n).digest();
    mt.create = (t, e)=>new wn(t, e);
    const St = BigInt(0), gt = BigInt(1);
    yt = function(t, e = "") {
        if (typeof t != "boolean") {
            const n = e && `"${e}"`;
            throw new Error(n + "expected boolean, got type=" + typeof t);
        }
        return t;
    };
    Ze = function(t, e, n = "") {
        const r = rt(t), s = t?.length, o = e !== void 0;
        if (!r || o && s !== e) {
            const i = n && `"${n}" `, c = o ? ` of length ${e}` : "", a = r ? `length=${s}` : `type=${typeof t}`;
            throw new Error(i + "expected Uint8Array" + c + ", got " + a);
        }
        return t;
    };
    ti = function(t) {
        const e = t.toString(16);
        return e.length & 1 ? "0" + e : e;
    };
    function xn(t) {
        if (typeof t != "string") throw new Error("hex string expected, got " + typeof t);
        return t === "" ? St : BigInt("0x" + t);
    }
    vn = function(t) {
        return xn(At(t));
    };
    function De(t) {
        return me(t), xn(At(Uint8Array.from(t).reverse()));
    }
    function Ht(t, e) {
        return dn(t.toString(16).padStart(e * 2, "0"));
    }
    function _n(t, e) {
        return Ht(t, e).reverse();
    }
    ue = function(t, e, n) {
        let r;
        if (typeof e == "string") try {
            r = dn(e);
        } catch (o) {
            throw new Error(t + " must be hex string or Uint8Array, cause: " + o);
        }
        else if (rt(e)) r = Uint8Array.from(e);
        else throw new Error(t + " must be hex string or Uint8Array");
        const s = r.length;
        if (typeof n == "number" && s !== n) throw new Error(t + " of length " + n + " expected, got " + s);
        return r;
    };
    function Pt(t) {
        return Uint8Array.from(t);
    }
    const lt = (t)=>typeof t == "bigint" && St <= t;
    function $r(t, e, n) {
        return lt(t) && lt(e) && lt(n) && e <= t && t < n;
    }
    Vt = function(t, e, n, r) {
        if (!$r(e, n, r)) throw new Error("expected valid " + t + ": " + n + " <= n < " + r + ", got " + e);
    };
    Tr = function(t) {
        let e;
        for(e = 0; t > St; t >>= gt, e += 1);
        return e;
    };
    It = (t)=>(gt << BigInt(t)) - gt;
    ni = function(t, e, n) {
        if (typeof t != "number" || t < 2) throw new Error("hashLen must be a number");
        if (typeof e != "number" || e < 2) throw new Error("qByteLen must be a number");
        if (typeof n != "function") throw new Error("hmacFn must be a function");
        const r = (d)=>new Uint8Array(d), s = (d)=>Uint8Array.of(d);
        let o = r(t), i = r(t), c = 0;
        const a = ()=>{
            o.fill(1), i.fill(0), c = 0;
        }, u = (...d)=>n(i, o, ...d), h = (d = r(0))=>{
            i = u(s(0), d), o = u(), d.length !== 0 && (i = u(s(1), d), o = u());
        }, f = ()=>{
            if (c++ >= 1e3) throw new Error("drbg: tried 1000 values");
            let d = 0;
            const p = [];
            for(; d < e;){
                o = u();
                const m = o.slice();
                p.push(m), d += o.length;
            }
            return bt(...p);
        };
        return (d, p)=>{
            a(), h(d);
            let m;
            for(; !(m = p(f()));)h();
            return a(), m;
        };
    };
    Ct = function(t, e, n = {}) {
        if (!t || typeof t != "object") throw new Error("expected valid options object");
        function r(s, o, i) {
            const c = t[s];
            if (i && c === void 0) return;
            const a = typeof c;
            if (a !== o || c === null) throw new Error(`param "${s}" is invalid: expected ${o}, got ${a}`);
        }
        Object.entries(e).forEach(([s, o])=>r(s, o, !1)), Object.entries(n).forEach(([s, o])=>r(s, o, !0));
    };
    Zt = function(t) {
        const e = new WeakMap;
        return (n, ...r)=>{
            const s = e.get(n);
            if (s !== void 0) return s;
            const o = t(n, ...r);
            return e.set(n, o), o;
        };
    };
    const M = BigInt(0), q = BigInt(1), ge = BigInt(2), An = BigInt(3), En = BigInt(4), Bn = BigInt(5), Nr = BigInt(7), kn = BigInt(8), Rr = BigInt(9), Sn = BigInt(16);
    function D(t, e) {
        const n = t % e;
        return n >= M ? n : e + n;
    }
    X = function(t, e, n) {
        let r = t;
        for(; e-- > M;)r *= r, r %= n;
        return r;
    };
    function Xt(t, e) {
        if (t === M) throw new Error("invert: expected non-zero number");
        if (e <= M) throw new Error("invert: expected positive modulus, got " + e);
        let n = D(t, e), r = e, s = M, o = q;
        for(; n !== M;){
            const c = r / n, a = r % n, u = s - o * c;
            r = n, n = a, s = o, o = u;
        }
        if (r !== q) throw new Error("invert: does not exist");
        return D(s, e);
    }
    function Lt(t, e, n) {
        if (!t.eql(t.sqr(e), n)) throw new Error("Cannot find square root");
    }
    function Hn(t, e) {
        const n = (t.ORDER + q) / En, r = t.pow(e, n);
        return Lt(t, r, e), r;
    }
    function Dr(t, e) {
        const n = (t.ORDER - Bn) / kn, r = t.mul(e, ge), s = t.pow(r, n), o = t.mul(e, s), i = t.mul(t.mul(o, ge), s), c = t.mul(o, t.sub(i, t.ONE));
        return Lt(t, c, e), c;
    }
    function zr(t) {
        const e = je(t), n = In(t), r = n(e, e.neg(e.ONE)), s = n(e, r), o = n(e, e.neg(r)), i = (t + Nr) / Sn;
        return (c, a)=>{
            let u = c.pow(a, i), h = c.mul(u, r);
            const f = c.mul(u, s), l = c.mul(u, o), d = c.eql(c.sqr(h), a), p = c.eql(c.sqr(f), a);
            u = c.cmov(u, h, d), h = c.cmov(l, f, p);
            const m = c.eql(c.sqr(h), a), w = c.cmov(u, h, m);
            return Lt(c, w, a), w;
        };
    }
    function In(t) {
        if (t < An) throw new Error("sqrt is not defined for small field");
        let e = t - q, n = 0;
        for(; e % ge === M;)e /= ge, n++;
        let r = ge;
        const s = je(t);
        for(; Ft(s, r) === 1;)if (r++ > 1e3) throw new Error("Cannot find square root: probably non-prime P");
        if (n === 1) return Hn;
        let o = s.pow(r, e);
        const i = (e + q) / ge;
        return function(a, u) {
            if (a.is0(u)) return u;
            if (Ft(a, u) !== 1) throw new Error("Cannot find square root");
            let h = n, f = a.mul(a.ONE, o), l = a.pow(u, e), d = a.pow(u, i);
            for(; !a.eql(l, a.ONE);){
                if (a.is0(l)) return a.ZERO;
                let p = 1, m = a.sqr(l);
                for(; !a.eql(m, a.ONE);)if (p++, m = a.sqr(m), p === h) throw new Error("Cannot find square root");
                const w = q << BigInt(h - p - 1), y = a.pow(f, w);
                h = p, f = a.sqr(y), l = a.mul(l, f), d = a.mul(d, y);
            }
            return d;
        };
    }
    function Or(t) {
        return t % En === An ? Hn : t % kn === Bn ? Dr : t % Sn === Rr ? zr(t) : In(t);
    }
    const qr = (t, e)=>(D(t, e) & q) === q, jr = [
        "create",
        "isValid",
        "is0",
        "neg",
        "inv",
        "sqrt",
        "sqr",
        "eql",
        "add",
        "sub",
        "mul",
        "pow",
        "div",
        "addN",
        "subN",
        "mulN",
        "sqrN"
    ];
    function Kr(t) {
        const e = {
            ORDER: "bigint",
            MASK: "bigint",
            BYTES: "number",
            BITS: "number"
        }, n = jr.reduce((r, s)=>(r[s] = "function", r), e);
        return Ct(t, n), t;
    }
    function Mr(t, e, n) {
        if (n < M) throw new Error("invalid exponent, negatives unsupported");
        if (n === M) return t.ONE;
        if (n === q) return e;
        let r = t.ONE, s = e;
        for(; n > M;)n & q && (r = t.mul(r, s)), s = t.sqr(s), n >>= q;
        return r;
    }
    function Cn(t, e, n = !1) {
        const r = new Array(e.length).fill(n ? t.ZERO : void 0), s = e.reduce((i, c, a)=>t.is0(c) ? i : (r[a] = i, t.mul(i, c)), t.ONE), o = t.inv(s);
        return e.reduceRight((i, c, a)=>t.is0(c) ? i : (r[a] = t.mul(i, r[a]), t.mul(i, c)), o), r;
    }
    function Ft(t, e) {
        const n = (t.ORDER - q) / ge, r = t.pow(e, n), s = t.eql(r, t.ONE), o = t.eql(r, t.ZERO), i = t.eql(r, t.neg(t.ONE));
        if (!s && !o && !i) throw new Error("invalid Legendre symbol result");
        return s ? 1 : o ? 0 : -1;
    }
    Gr = function(t, e) {
        e !== void 0 && Se(e);
        const n = e !== void 0 ? e : t.toString(2).length, r = Math.ceil(n / 8);
        return {
            nBitLength: n,
            nByteLength: r
        };
    };
    je = function(t, e, n = !1, r = {}) {
        if (t <= M) throw new Error("invalid field: expected ORDER > 0, got " + t);
        let s, o, i = !1, c;
        if (typeof e == "object" && e != null) {
            if (r.sqrt || n) throw new Error("cannot specify opts in two arguments");
            const l = e;
            l.BITS && (s = l.BITS), l.sqrt && (o = l.sqrt), typeof l.isLE == "boolean" && (n = l.isLE), typeof l.modFromBytes == "boolean" && (i = l.modFromBytes), c = l.allowedLengths;
        } else typeof e == "number" && (s = e), r.sqrt && (o = r.sqrt);
        const { nBitLength: a, nByteLength: u } = Gr(t, s);
        if (u > 2048) throw new Error("invalid field: expected ORDER of <= 2048 bytes");
        let h;
        const f = Object.freeze({
            ORDER: t,
            isLE: n,
            BITS: a,
            BYTES: u,
            MASK: It(a),
            ZERO: M,
            ONE: q,
            allowedLengths: c,
            create: (l)=>D(l, t),
            isValid: (l)=>{
                if (typeof l != "bigint") throw new Error("invalid field element: expected bigint, got " + typeof l);
                return M <= l && l < t;
            },
            is0: (l)=>l === M,
            isValidNot0: (l)=>!f.is0(l) && f.isValid(l),
            isOdd: (l)=>(l & q) === q,
            neg: (l)=>D(-l, t),
            eql: (l, d)=>l === d,
            sqr: (l)=>D(l * l, t),
            add: (l, d)=>D(l + d, t),
            sub: (l, d)=>D(l - d, t),
            mul: (l, d)=>D(l * d, t),
            pow: (l, d)=>Mr(f, l, d),
            div: (l, d)=>D(l * Xt(d, t), t),
            sqrN: (l)=>l * l,
            addN: (l, d)=>l + d,
            subN: (l, d)=>l - d,
            mulN: (l, d)=>l * d,
            inv: (l)=>Xt(l, t),
            sqrt: o || ((l)=>(h || (h = Or(t)), h(f, l))),
            toBytes: (l)=>n ? _n(l, u) : Ht(l, u),
            fromBytes: (l, d = !0)=>{
                if (c) {
                    if (!c.includes(l.length) || l.length > u) throw new Error("Field.fromBytes: expected " + c + " bytes, got " + l.length);
                    const m = new Uint8Array(u);
                    m.set(l, n ? 0 : m.length - l.length), l = m;
                }
                if (l.length !== u) throw new Error("Field.fromBytes: expected " + u + " bytes, got " + l.length);
                let p = n ? De(l) : vn(l);
                if (i && (p = D(p, t)), !d && !f.isValid(p)) throw new Error("invalid field element: outside of range 0..ORDER");
                return p;
            },
            invertBatch: (l)=>Cn(f, l),
            cmov: (l, d, p)=>p ? d : l
        });
        return Object.freeze(f);
    };
    function Ln(t) {
        if (typeof t != "bigint") throw new Error("field order must be bigint");
        const e = t.toString(2).length;
        return Math.ceil(e / 8);
    }
    Pr = function(t) {
        const e = Ln(t);
        return e + Math.ceil(e / 2);
    };
    ri = function(t, e, n = !1) {
        const r = t.length, s = Ln(e), o = Pr(e);
        if (r < 16 || r < o || r > 1024) throw new Error("expected " + o + "-1024 bytes of input, got " + r);
        const i = n ? De(t) : vn(t), c = D(i, e - q) + q;
        return n ? _n(c, s) : Ht(c, s);
    };
    const Ie = BigInt(0), ye = BigInt(1);
    Yt = function(t, e) {
        const n = e.negate();
        return t ? n : e;
    };
    Ge = function(t, e) {
        const n = Cn(t.Fp, e.map((r)=>r.Z));
        return e.map((r, s)=>t.fromAffine(r.toAffine(n[s])));
    };
    function Un(t, e) {
        if (!Number.isSafeInteger(t) || t <= 0 || t > e) throw new Error("invalid window size, expected [1.." + e + "], got W=" + t);
    }
    function ft(t, e) {
        Un(t, e);
        const n = Math.ceil(e / t) + 1, r = 2 ** (t - 1), s = 2 ** t, o = It(t), i = BigInt(t);
        return {
            windows: n,
            windowSize: r,
            mask: o,
            maxNumber: s,
            shiftBy: i
        };
    }
    function Wt(t, e, n) {
        const { windowSize: r, mask: s, maxNumber: o, shiftBy: i } = n;
        let c = Number(t & s), a = t >> i;
        c > r && (c -= o, a += ye);
        const u = e * r, h = u + Math.abs(c) - 1, f = c === 0, l = c < 0, d = e % 2 !== 0;
        return {
            nextN: a,
            offset: h,
            isZero: f,
            isNeg: l,
            isNegF: d,
            offsetF: u
        };
    }
    function Vr(t, e) {
        if (!Array.isArray(t)) throw new Error("array expected");
        t.forEach((n, r)=>{
            if (!(n instanceof e)) throw new Error("invalid point at index " + r);
        });
    }
    function Zr(t, e) {
        if (!Array.isArray(t)) throw new Error("array of scalars expected");
        t.forEach((n, r)=>{
            if (!e.isValid(n)) throw new Error("invalid scalar at index " + r);
        });
    }
    const ut = new WeakMap, $n = new WeakMap;
    function dt(t) {
        return $n.get(t) || 1;
    }
    function Jt(t) {
        if (t !== Ie) throw new Error("invalid wNAF");
    }
    Xr = class {
        constructor(e, n){
            this.BASE = e.BASE, this.ZERO = e.ZERO, this.Fn = e.Fn, this.bits = n;
        }
        _unsafeLadder(e, n, r = this.ZERO) {
            let s = e;
            for(; n > Ie;)n & ye && (r = r.add(s)), s = s.double(), n >>= ye;
            return r;
        }
        precomputeWindow(e, n) {
            const { windows: r, windowSize: s } = ft(n, this.bits), o = [];
            let i = e, c = i;
            for(let a = 0; a < r; a++){
                c = i, o.push(c);
                for(let u = 1; u < s; u++)c = c.add(i), o.push(c);
                i = c.double();
            }
            return o;
        }
        wNAF(e, n, r) {
            if (!this.Fn.isValid(r)) throw new Error("invalid scalar");
            let s = this.ZERO, o = this.BASE;
            const i = ft(e, this.bits);
            for(let c = 0; c < i.windows; c++){
                const { nextN: a, offset: u, isZero: h, isNeg: f, isNegF: l, offsetF: d } = Wt(r, c, i);
                r = a, h ? o = o.add(Yt(l, n[d])) : s = s.add(Yt(f, n[u]));
            }
            return Jt(r), {
                p: s,
                f: o
            };
        }
        wNAFUnsafe(e, n, r, s = this.ZERO) {
            const o = ft(e, this.bits);
            for(let i = 0; i < o.windows && r !== Ie; i++){
                const { nextN: c, offset: a, isZero: u, isNeg: h } = Wt(r, i, o);
                if (r = c, !u) {
                    const f = n[a];
                    s = s.add(h ? f.negate() : f);
                }
            }
            return Jt(r), s;
        }
        getPrecomputes(e, n, r) {
            let s = ut.get(n);
            return s || (s = this.precomputeWindow(n, e), e !== 1 && (typeof r == "function" && (s = r(s)), ut.set(n, s))), s;
        }
        cached(e, n, r) {
            const s = dt(e);
            return this.wNAF(s, this.getPrecomputes(s, e, r), n);
        }
        unsafe(e, n, r, s) {
            const o = dt(e);
            return o === 1 ? this._unsafeLadder(e, n, s) : this.wNAFUnsafe(o, this.getPrecomputes(o, e, r), n, s);
        }
        createCache(e, n) {
            Un(n, this.bits), $n.set(e, n), ut.delete(e);
        }
        hasCache(e) {
            return dt(e) !== 1;
        }
    };
    si = function(t, e, n, r) {
        let s = e, o = t.ZERO, i = t.ZERO;
        for(; n > Ie || r > Ie;)n & ye && (o = o.add(s)), r & ye && (i = i.add(s)), s = s.double(), n >>= ye, r >>= ye;
        return {
            p1: o,
            p2: i
        };
    };
    Fr = function(t, e, n, r) {
        Vr(n, t), Zr(r, e);
        const s = n.length, o = r.length;
        if (s !== o) throw new Error("arrays of points and scalars must have equal length");
        const i = t.ZERO, c = Tr(BigInt(s));
        let a = 1;
        c > 12 ? a = c - 3 : c > 4 ? a = c - 2 : c > 0 && (a = 2);
        const u = It(a), h = new Array(Number(u) + 1).fill(i), f = Math.floor((e.BITS - 1) / a) * a;
        let l = i;
        for(let d = f; d >= 0; d -= a){
            h.fill(i);
            for(let m = 0; m < o; m++){
                const w = r[m], y = Number(w >> BigInt(d) & u);
                h[y] = h[y].add(n[m]);
            }
            let p = i;
            for(let m = h.length - 1, w = i; m > 0; m--)w = w.add(h[m]), p = p.add(w);
            if (l = l.add(p), d !== 0) for(let m = 0; m < a; m++)l = l.double();
        }
        return l;
    };
    function Qt(t, e, n) {
        if (e) {
            if (e.ORDER !== t) throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
            return Kr(e), e;
        } else return je(t, {
            isLE: n
        });
    }
    Yr = function(t, e, n = {}, r) {
        if (r === void 0 && (r = t === "edwards"), !e || typeof e != "object") throw new Error(`expected valid ${t} CURVE object`);
        for (const a of [
            "p",
            "n",
            "h"
        ]){
            const u = e[a];
            if (!(typeof u == "bigint" && u > Ie)) throw new Error(`CURVE.${a} must be positive bigint`);
        }
        const s = Qt(e.p, n.Fp, r), o = Qt(e.n, n.Fn, r), c = [
            "Gx",
            "Gy",
            "a",
            t === "weierstrass" ? "b" : "d"
        ];
        for (const a of c)if (!s.isValid(e[a])) throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);
        return e = Object.freeze(Object.assign({}, e)), {
            CURVE: e,
            Fp: s,
            Fn: o
        };
    };
    const ie = BigInt(0), O = BigInt(1), ht = BigInt(2), Wr = BigInt(8);
    function Jr(t, e, n, r) {
        const s = t.sqr(n), o = t.sqr(r), i = t.add(t.mul(e.a, s), o), c = t.add(t.ONE, t.mul(e.d, t.mul(s, o)));
        return t.eql(i, c);
    }
    function Qr(t, e = {}) {
        const n = Yr("edwards", t, e, e.FpFnLE), { Fp: r, Fn: s } = n;
        let o = n.CURVE;
        const { h: i } = o;
        Ct(e, {}, {
            uvRatio: "function"
        });
        const c = ht << BigInt(s.BYTES * 8) - O, a = (w)=>r.create(w), u = e.uvRatio || ((w, y)=>{
            try {
                return {
                    isValid: !0,
                    value: r.sqrt(r.div(w, y))
                };
            } catch  {
                return {
                    isValid: !1,
                    value: ie
                };
            }
        });
        if (!Jr(r, o, o.Gx, o.Gy)) throw new Error("bad curve params: generator point");
        function h(w, y, _ = !1) {
            const b = _ ? O : ie;
            return Vt("coordinate " + w, y, b, c), y;
        }
        function f(w) {
            if (!(w instanceof p)) throw new Error("ExtendedPoint expected");
        }
        const l = Zt((w, y)=>{
            const { X: _, Y: b, Z: E } = w, B = w.is0();
            y == null && (y = B ? Wr : r.inv(E));
            const I = a(_ * y), C = a(b * y), k = r.mul(E, y);
            if (B) return {
                x: ie,
                y: O
            };
            if (k !== O) throw new Error("invZ was invalid");
            return {
                x: I,
                y: C
            };
        }), d = Zt((w)=>{
            const { a: y, d: _ } = o;
            if (w.is0()) throw new Error("bad point: ZERO");
            const { X: b, Y: E, Z: B, T: I } = w, C = a(b * b), k = a(E * E), g = a(B * B), v = a(g * g), A = a(C * y), S = a(g * a(A + k)), $ = a(v + a(_ * a(C * k)));
            if (S !== $) throw new Error("bad point: equation left != right (1)");
            const U = a(b * E), T = a(B * I);
            if (U !== T) throw new Error("bad point: equation left != right (2)");
            return !0;
        });
        class p {
            constructor(y, _, b, E){
                this.X = h("x", y), this.Y = h("y", _), this.Z = h("z", b, !0), this.T = h("t", E), Object.freeze(this);
            }
            static CURVE() {
                return o;
            }
            static fromAffine(y) {
                if (y instanceof p) throw new Error("extended point not allowed");
                const { x: _, y: b } = y || {};
                return h("x", _), h("y", b), new p(_, b, O, a(_ * b));
            }
            static fromBytes(y, _ = !1) {
                const b = r.BYTES, { a: E, d: B } = o;
                y = Pt(Ze(y, b, "point")), yt(_, "zip215");
                const I = Pt(y), C = y[b - 1];
                I[b - 1] = C & -129;
                const k = De(I), g = _ ? c : r.ORDER;
                Vt("point.y", k, ie, g);
                const v = a(k * k), A = a(v - O), S = a(B * v - E);
                let { isValid: $, value: U } = u(A, S);
                if (!$) throw new Error("bad point: invalid y coordinate");
                const T = (U & O) === O, R = (C & 128) !== 0;
                if (!_ && U === ie && R) throw new Error("bad point: x=0 and x_0=1");
                return R !== T && (U = a(-U)), p.fromAffine({
                    x: U,
                    y: k
                });
            }
            static fromHex(y, _ = !1) {
                return p.fromBytes(ue("point", y), _);
            }
            get x() {
                return this.toAffine().x;
            }
            get y() {
                return this.toAffine().y;
            }
            precompute(y = 8, _ = !0) {
                return m.createCache(this, y), _ || this.multiply(ht), this;
            }
            assertValidity() {
                d(this);
            }
            equals(y) {
                f(y);
                const { X: _, Y: b, Z: E } = this, { X: B, Y: I, Z: C } = y, k = a(_ * C), g = a(B * E), v = a(b * C), A = a(I * E);
                return k === g && v === A;
            }
            is0() {
                return this.equals(p.ZERO);
            }
            negate() {
                return new p(a(-this.X), this.Y, this.Z, a(-this.T));
            }
            double() {
                const { a: y } = o, { X: _, Y: b, Z: E } = this, B = a(_ * _), I = a(b * b), C = a(ht * a(E * E)), k = a(y * B), g = _ + b, v = a(a(g * g) - B - I), A = k + I, S = A - C, $ = k - I, U = a(v * S), T = a(A * $), R = a(v * $), K = a(S * A);
                return new p(U, T, K, R);
            }
            add(y) {
                f(y);
                const { a: _, d: b } = o, { X: E, Y: B, Z: I, T: C } = this, { X: k, Y: g, Z: v, T: A } = y, S = a(E * k), $ = a(B * g), U = a(C * b * A), T = a(I * v), R = a((E + B) * (k + g) - S - $), K = T - U, N = T + U, L = a($ - _ * S), G = a(R * K), _e = a(N * L), Ce = a(R * L), Le = a(K * N);
                return new p(G, _e, Le, Ce);
            }
            subtract(y) {
                return this.add(y.negate());
            }
            multiply(y) {
                if (!s.isValidNot0(y)) throw new Error("invalid scalar: expected 1 <= sc < curve.n");
                const { p: _, f: b } = m.cached(this, y, (E)=>Ge(p, E));
                return Ge(p, [
                    _,
                    b
                ])[0];
            }
            multiplyUnsafe(y, _ = p.ZERO) {
                if (!s.isValid(y)) throw new Error("invalid scalar: expected 0 <= sc < curve.n");
                return y === ie ? p.ZERO : this.is0() || y === O ? this : m.unsafe(this, y, (b)=>Ge(p, b), _);
            }
            isSmallOrder() {
                return this.multiplyUnsafe(i).is0();
            }
            isTorsionFree() {
                return m.unsafe(this, o.n).is0();
            }
            toAffine(y) {
                return l(this, y);
            }
            clearCofactor() {
                return i === O ? this : this.multiplyUnsafe(i);
            }
            toBytes() {
                const { x: y, y: _ } = this.toAffine(), b = r.toBytes(_);
                return b[b.length - 1] |= y & O ? 128 : 0, b;
            }
            toHex() {
                return At(this.toBytes());
            }
            toString() {
                return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
            }
            get ex() {
                return this.X;
            }
            get ey() {
                return this.Y;
            }
            get ez() {
                return this.Z;
            }
            get et() {
                return this.T;
            }
            static normalizeZ(y) {
                return Ge(p, y);
            }
            static msm(y, _) {
                return Fr(p, s, y, _);
            }
            _setWindowSize(y) {
                this.precompute(y);
            }
            toRawBytes() {
                return this.toBytes();
            }
        }
        p.BASE = new p(o.Gx, o.Gy, O, a(o.Gx * o.Gy)), p.ZERO = new p(ie, O, O, ie), p.Fp = r, p.Fn = s;
        const m = new Xr(p, s.BITS);
        return p.BASE.precompute(8), p;
    }
    function es(t, e, n = {}) {
        if (typeof e != "function") throw new Error('"hash" function param is required');
        Ct(n, {}, {
            adjustScalarBytes: "function",
            randomBytes: "function",
            domain: "function",
            prehash: "function",
            mapToCurve: "function"
        });
        const { prehash: r } = n, { BASE: s, Fp: o, Fn: i } = t, c = n.randomBytes || dr, a = n.adjustScalarBytes || ((g)=>g), u = n.domain || ((g, v, A)=>{
            if (yt(A, "phflag"), v.length || A) throw new Error("Contexts/pre-hash are not supported");
            return g;
        });
        function h(g) {
            return i.create(De(g));
        }
        function f(g) {
            const v = b.secretKey;
            g = ue("private key", g, v);
            const A = ue("hashed private key", e(g), 2 * v), S = a(A.slice(0, v)), $ = A.slice(v, 2 * v), U = h(S);
            return {
                head: S,
                prefix: $,
                scalar: U
            };
        }
        function l(g) {
            const { head: v, prefix: A, scalar: S } = f(g), $ = s.multiply(S), U = $.toBytes();
            return {
                head: v,
                prefix: A,
                scalar: S,
                point: $,
                pointBytes: U
            };
        }
        function d(g) {
            return l(g).pointBytes;
        }
        function p(g = Uint8Array.of(), ...v) {
            const A = bt(...v);
            return h(e(u(A, ue("context", g), !!r)));
        }
        function m(g, v, A = {}) {
            g = ue("message", g), r && (g = r(g));
            const { prefix: S, scalar: $, pointBytes: U } = l(v), T = p(A.context, S, g), R = s.multiply(T).toBytes(), K = p(A.context, R, U, g), N = i.create(T + K * $);
            if (!i.isValid(N)) throw new Error("sign failed: invalid s");
            const L = bt(R, i.toBytes(N));
            return Ze(L, b.signature, "result");
        }
        const w = {
            zip215: !0
        };
        function y(g, v, A, S = w) {
            const { context: $, zip215: U } = S, T = b.signature;
            g = ue("signature", g, T), v = ue("message", v), A = ue("publicKey", A, b.publicKey), U !== void 0 && yt(U, "zip215"), r && (v = r(v));
            const R = T / 2, K = g.subarray(0, R), N = De(g.subarray(R, T));
            let L, G, _e;
            try {
                L = t.fromBytes(A, U), G = t.fromBytes(K, U), _e = s.multiplyUnsafe(N);
            } catch  {
                return !1;
            }
            if (!U && L.isSmallOrder()) return !1;
            const Ce = p($, G.toBytes(), L.toBytes(), v);
            return G.add(L.multiplyUnsafe(Ce)).subtract(_e).clearCofactor().is0();
        }
        const _ = o.BYTES, b = {
            secretKey: _,
            publicKey: _,
            signature: 2 * _,
            seed: _
        };
        function E(g = c(b.seed)) {
            return Ze(g, b.seed, "seed");
        }
        function B(g) {
            const v = k.randomSecretKey(g);
            return {
                secretKey: v,
                publicKey: d(v)
            };
        }
        function I(g) {
            return rt(g) && g.length === i.BYTES;
        }
        function C(g, v) {
            try {
                return !!t.fromBytes(g, v);
            } catch  {
                return !1;
            }
        }
        const k = {
            getExtendedPublicKey: l,
            randomSecretKey: E,
            isValidSecretKey: I,
            isValidPublicKey: C,
            toMontgomery (g) {
                const { y: v } = t.fromBytes(g), A = b.publicKey, S = A === 32;
                if (!S && A !== 57) throw new Error("only defined for 25519 and 448");
                const $ = S ? o.div(O + v, O - v) : o.div(v - O, v + O);
                return o.toBytes($);
            },
            toMontgomerySecret (g) {
                const v = b.secretKey;
                Ze(g, v);
                const A = e(g.subarray(0, v));
                return a(A).subarray(0, v);
            },
            randomPrivateKey: E,
            precompute (g = 8, v = t.BASE) {
                return v.precompute(g, !1);
            }
        };
        return Object.freeze({
            keygen: B,
            getPublicKey: d,
            sign: m,
            verify: y,
            utils: k,
            Point: t,
            lengths: b
        });
    }
    function ts(t) {
        const e = {
            a: t.a,
            d: t.d,
            p: t.Fp.ORDER,
            n: t.n,
            h: t.h,
            Gx: t.Gx,
            Gy: t.Gy
        }, n = t.Fp, r = je(e.n, t.nBitLength, !0), s = {
            Fp: n,
            Fn: r,
            uvRatio: t.uvRatio
        }, o = {
            randomBytes: t.randomBytes,
            adjustScalarBytes: t.adjustScalarBytes,
            domain: t.domain,
            prehash: t.prehash,
            mapToCurve: t.mapToCurve
        };
        return {
            CURVE: e,
            curveOpts: s,
            hash: t.hash,
            eddsaOpts: o
        };
    }
    function ns(t, e) {
        const n = e.Point;
        return Object.assign({}, e, {
            ExtendedPoint: n,
            CURVE: t,
            nBitLength: n.Fn.BITS,
            nByteLength: n.Fn.BYTES
        });
    }
    function rs(t) {
        const { CURVE: e, curveOpts: n, hash: r, eddsaOpts: s } = ts(t), o = Qr(e, n), i = es(o, r, s);
        return ns(t, i);
    }
    const ss = BigInt(1), en = BigInt(2);
    BigInt(3);
    const os = BigInt(5), is = BigInt(8), Ut = BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"), Tn = {
        p: Ut,
        n: BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),
        h: is,
        a: BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),
        d: BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),
        Gx: BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),
        Gy: BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")
    };
    function as(t) {
        const e = BigInt(10), n = BigInt(20), r = BigInt(40), s = BigInt(80), o = Ut, c = t * t % o * t % o, a = X(c, en, o) * c % o, u = X(a, ss, o) * t % o, h = X(u, os, o) * u % o, f = X(h, e, o) * h % o, l = X(f, n, o) * f % o, d = X(l, r, o) * l % o, p = X(d, s, o) * d % o, m = X(p, s, o) * d % o, w = X(m, e, o) * h % o;
        return {
            pow_p_5_8: X(w, en, o) * t % o,
            b2: c
        };
    }
    function cs(t) {
        return t[0] &= 248, t[31] &= 127, t[31] |= 64, t;
    }
    const tn = BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
    function ls(t, e) {
        const n = Ut, r = D(e * e * e, n), s = D(r * r * e, n), o = as(t * s).pow_p_5_8;
        let i = D(t * r * o, n);
        const c = D(e * i * i, n), a = i, u = D(i * tn, n), h = c === t, f = c === D(-t, n), l = c === D(-t * tn, n);
        return h && (i = a), (f || l) && (i = u), qr(i, n) && (i = D(-i, n)), {
            isValid: h || f,
            value: i
        };
    }
    const fs = je(Tn.p, {
        isLE: !0
    }), us = {
        ...Tn,
        Fp: fs,
        hash: yn,
        adjustScalarBytes: cs,
        uvRatio: ls
    }, ds = rs(us), nn = yn;
    function Re(t) {
        if (!Number.isSafeInteger(t) || t < 0) throw new Error(`positive integer expected, not ${t}`);
    }
    function hs(t) {
        return t instanceof Uint8Array || t != null && typeof t == "object" && t.constructor.name === "Uint8Array";
    }
    function st(t, ...e) {
        if (!hs(t)) throw new Error("Uint8Array expected");
        if (e.length > 0 && !e.includes(t.length)) throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`);
    }
    function Nn(t) {
        if (typeof t != "function" || typeof t.create != "function") throw new Error("Hash should be wrapped by utils.wrapConstructor");
        Re(t.outputLen), Re(t.blockLen);
    }
    function Ye(t, e = !0) {
        if (t.destroyed) throw new Error("Hash instance has been destroyed");
        if (e && t.finished) throw new Error("Hash#digest() has already been called");
    }
    function ps(t, e) {
        st(t);
        const n = e.outputLen;
        if (t.length < n) throw new Error(`digestInto() expects output buffer of length at least ${n}`);
    }
    const Xe = (t)=>new DataView(t.buffer, t.byteOffset, t.byteLength), F = (t, e)=>t << 32 - e | t >>> e;
    new Uint8Array(new Uint32Array([
        287454020
    ]).buffer)[0];
    function bs(t) {
        if (typeof t != "string") throw new Error(`utf8ToBytes expected string, got ${typeof t}`);
        return new Uint8Array(new TextEncoder().encode(t));
    }
    function ze(t) {
        return typeof t == "string" && (t = bs(t)), st(t), t;
    }
    class Rn {
        clone() {
            return this._cloneInto();
        }
    }
    const ms = {}.toString;
    function gs(t, e) {
        if (e !== void 0 && ms.call(e) !== "[object Object]") throw new Error("Options should be object or undefined");
        return Object.assign(t, e);
    }
    function Dn(t) {
        const e = (r)=>t().update(ze(r)).digest(), n = t();
        return e.outputLen = n.outputLen, e.blockLen = n.blockLen, e.create = ()=>t(), e;
    }
    class zn extends Rn {
        constructor(e, n){
            super(), this.finished = !1, this.destroyed = !1, Nn(e);
            const r = ze(n);
            if (this.iHash = e.create(), typeof this.iHash.update != "function") throw new Error("Expected instance of class which extends utils.Hash");
            this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
            const s = this.blockLen, o = new Uint8Array(s);
            o.set(r.length > s ? e.create().update(r).digest() : r);
            for(let i = 0; i < o.length; i++)o[i] ^= 54;
            this.iHash.update(o), this.oHash = e.create();
            for(let i = 0; i < o.length; i++)o[i] ^= 106;
            this.oHash.update(o), o.fill(0);
        }
        update(e) {
            return Ye(this), this.iHash.update(e), this;
        }
        digestInto(e) {
            Ye(this), st(e, this.outputLen), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();
        }
        digest() {
            const e = new Uint8Array(this.oHash.outputLen);
            return this.digestInto(e), e;
        }
        _cloneInto(e) {
            e || (e = Object.create(Object.getPrototypeOf(this), {}));
            const { oHash: n, iHash: r, finished: s, destroyed: o, blockLen: i, outputLen: c } = this;
            return e = e, e.finished = s, e.destroyed = o, e.blockLen = i, e.outputLen = c, e.oHash = n._cloneInto(e.oHash), e.iHash = r._cloneInto(e.iHash), e;
        }
        destroy() {
            this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
        }
    }
    const On = (t, e, n)=>new zn(t, e).update(n).digest();
    On.create = (t, e)=>new zn(t, e);
    function ys(t, e, n, r) {
        Nn(t);
        const s = gs({
            dkLen: 32,
            asyncTick: 10
        }, r), { c: o, dkLen: i, asyncTick: c } = s;
        if (Re(o), Re(i), Re(c), o < 1) throw new Error("PBKDF2: iterations (c) should be >= 1");
        const a = ze(e), u = ze(n), h = new Uint8Array(i), f = On.create(t, a), l = f._cloneInto().update(u);
        return {
            c: o,
            dkLen: i,
            asyncTick: c,
            DK: h,
            PRF: f,
            PRFSalt: l
        };
    }
    function ws(t, e, n, r, s) {
        return t.destroy(), e.destroy(), r && r.destroy(), s.fill(0), n;
    }
    function xs(t, e, n, r) {
        const { c: s, dkLen: o, DK: i, PRF: c, PRFSalt: a } = ys(t, e, n, r);
        let u;
        const h = new Uint8Array(4), f = Xe(h), l = new Uint8Array(c.outputLen);
        for(let d = 1, p = 0; p < o; d++, p += c.outputLen){
            const m = i.subarray(p, p + c.outputLen);
            f.setInt32(0, d, !1), (u = a._cloneInto(u)).update(h).digestInto(l), m.set(l.subarray(0, m.length));
            for(let w = 1; w < s; w++){
                c._cloneInto(u).update(l).digestInto(l);
                for(let y = 0; y < m.length; y++)m[y] ^= l[y];
            }
        }
        return ws(c, a, i, u, l);
    }
    function vs(t, e, n, r) {
        if (typeof t.setBigUint64 == "function") return t.setBigUint64(e, n, r);
        const s = BigInt(32), o = BigInt(4294967295), i = Number(n >> s & o), c = Number(n & o), a = r ? 4 : 0, u = r ? 0 : 4;
        t.setUint32(e + a, i, r), t.setUint32(e + u, c, r);
    }
    const _s = (t, e, n)=>t & e ^ ~t & n, As = (t, e, n)=>t & e ^ t & n ^ e & n;
    class qn extends Rn {
        constructor(e, n, r, s){
            super(), this.blockLen = e, this.outputLen = n, this.padOffset = r, this.isLE = s, this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.buffer = new Uint8Array(e), this.view = Xe(this.buffer);
        }
        update(e) {
            Ye(this);
            const { view: n, buffer: r, blockLen: s } = this;
            e = ze(e);
            const o = e.length;
            for(let i = 0; i < o;){
                const c = Math.min(s - this.pos, o - i);
                if (c === s) {
                    const a = Xe(e);
                    for(; s <= o - i; i += s)this.process(a, i);
                    continue;
                }
                r.set(e.subarray(i, i + c), this.pos), this.pos += c, i += c, this.pos === s && (this.process(n, 0), this.pos = 0);
            }
            return this.length += e.length, this.roundClean(), this;
        }
        digestInto(e) {
            Ye(this), ps(e, this), this.finished = !0;
            const { buffer: n, view: r, blockLen: s, isLE: o } = this;
            let { pos: i } = this;
            n[i++] = 128, this.buffer.subarray(i).fill(0), this.padOffset > s - i && (this.process(r, 0), i = 0);
            for(let f = i; f < s; f++)n[f] = 0;
            vs(r, s - 8, BigInt(this.length * 8), o), this.process(r, 0);
            const c = Xe(e), a = this.outputLen;
            if (a % 4) throw new Error("_sha2: outputLen should be aligned to 32bit");
            const u = a / 4, h = this.get();
            if (u > h.length) throw new Error("_sha2: outputLen bigger than state");
            for(let f = 0; f < u; f++)c.setUint32(4 * f, h[f], o);
        }
        digest() {
            const { buffer: e, outputLen: n } = this;
            this.digestInto(e);
            const r = e.slice(0, n);
            return this.destroy(), r;
        }
        _cloneInto(e) {
            e || (e = new this.constructor), e.set(...this.get());
            const { blockLen: n, buffer: r, length: s, finished: o, destroyed: i, pos: c } = this;
            return e.length = s, e.pos = c, e.finished = o, e.destroyed = i, s % n && e.buffer.set(r), e;
        }
    }
    const Es = new Uint32Array([
        1116352408,
        1899447441,
        3049323471,
        3921009573,
        961987163,
        1508970993,
        2453635748,
        2870763221,
        3624381080,
        310598401,
        607225278,
        1426881987,
        1925078388,
        2162078206,
        2614888103,
        3248222580,
        3835390401,
        4022224774,
        264347078,
        604807628,
        770255983,
        1249150122,
        1555081692,
        1996064986,
        2554220882,
        2821834349,
        2952996808,
        3210313671,
        3336571891,
        3584528711,
        113926993,
        338241895,
        666307205,
        773529912,
        1294757372,
        1396182291,
        1695183700,
        1986661051,
        2177026350,
        2456956037,
        2730485921,
        2820302411,
        3259730800,
        3345764771,
        3516065817,
        3600352804,
        4094571909,
        275423344,
        430227734,
        506948616,
        659060556,
        883997877,
        958139571,
        1322822218,
        1537002063,
        1747873779,
        1955562222,
        2024104815,
        2227730452,
        2361852424,
        2428436474,
        2756734187,
        3204031479,
        3329325298
    ]), ae = new Uint32Array([
        1779033703,
        3144134277,
        1013904242,
        2773480762,
        1359893119,
        2600822924,
        528734635,
        1541459225
    ]), ce = new Uint32Array(64);
    class Bs extends qn {
        constructor(){
            super(64, 32, 8, !1), this.A = ae[0] | 0, this.B = ae[1] | 0, this.C = ae[2] | 0, this.D = ae[3] | 0, this.E = ae[4] | 0, this.F = ae[5] | 0, this.G = ae[6] | 0, this.H = ae[7] | 0;
        }
        get() {
            const { A: e, B: n, C: r, D: s, E: o, F: i, G: c, H: a } = this;
            return [
                e,
                n,
                r,
                s,
                o,
                i,
                c,
                a
            ];
        }
        set(e, n, r, s, o, i, c, a) {
            this.A = e | 0, this.B = n | 0, this.C = r | 0, this.D = s | 0, this.E = o | 0, this.F = i | 0, this.G = c | 0, this.H = a | 0;
        }
        process(e, n) {
            for(let f = 0; f < 16; f++, n += 4)ce[f] = e.getUint32(n, !1);
            for(let f = 16; f < 64; f++){
                const l = ce[f - 15], d = ce[f - 2], p = F(l, 7) ^ F(l, 18) ^ l >>> 3, m = F(d, 17) ^ F(d, 19) ^ d >>> 10;
                ce[f] = m + ce[f - 7] + p + ce[f - 16] | 0;
            }
            let { A: r, B: s, C: o, D: i, E: c, F: a, G: u, H: h } = this;
            for(let f = 0; f < 64; f++){
                const l = F(c, 6) ^ F(c, 11) ^ F(c, 25), d = h + l + _s(c, a, u) + Es[f] + ce[f] | 0, m = (F(r, 2) ^ F(r, 13) ^ F(r, 22)) + As(r, s, o) | 0;
                h = u, u = a, a = c, c = i + d | 0, i = o, o = s, s = r, r = d + m | 0;
            }
            r = r + this.A | 0, s = s + this.B | 0, o = o + this.C | 0, i = i + this.D | 0, c = c + this.E | 0, a = a + this.F | 0, u = u + this.G | 0, h = h + this.H | 0, this.set(r, s, o, i, c, a, u, h);
        }
        roundClean() {
            ce.fill(0);
        }
        destroy() {
            this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);
        }
    }
    const ks = Dn(()=>new Bs), Pe = BigInt(2 ** 32 - 1), wt = BigInt(32);
    function jn(t, e = !1) {
        return e ? {
            h: Number(t & Pe),
            l: Number(t >> wt & Pe)
        } : {
            h: Number(t >> wt & Pe) | 0,
            l: Number(t & Pe) | 0
        };
    }
    function Ss(t, e = !1) {
        let n = new Uint32Array(t.length), r = new Uint32Array(t.length);
        for(let s = 0; s < t.length; s++){
            const { h: o, l: i } = jn(t[s], e);
            [n[s], r[s]] = [
                o,
                i
            ];
        }
        return [
            n,
            r
        ];
    }
    const Hs = (t, e)=>BigInt(t >>> 0) << wt | BigInt(e >>> 0), Is = (t, e, n)=>t >>> n, Cs = (t, e, n)=>t << 32 - n | e >>> n, Ls = (t, e, n)=>t >>> n | e << 32 - n, Us = (t, e, n)=>t << 32 - n | e >>> n, $s = (t, e, n)=>t << 64 - n | e >>> n - 32, Ts = (t, e, n)=>t >>> n - 32 | e << 64 - n, Ns = (t, e)=>e, Rs = (t, e)=>t, Ds = (t, e, n)=>t << n | e >>> 32 - n, zs = (t, e, n)=>e << n | t >>> 32 - n, Os = (t, e, n)=>e << n - 32 | t >>> 64 - n, qs = (t, e, n)=>t << n - 32 | e >>> 64 - n;
    function js(t, e, n, r) {
        const s = (e >>> 0) + (r >>> 0);
        return {
            h: t + n + (s / 2 ** 32 | 0) | 0,
            l: s | 0
        };
    }
    const Ks = (t, e, n)=>(t >>> 0) + (e >>> 0) + (n >>> 0), Ms = (t, e, n, r)=>e + n + r + (t / 2 ** 32 | 0) | 0, Gs = (t, e, n, r)=>(t >>> 0) + (e >>> 0) + (n >>> 0) + (r >>> 0), Ps = (t, e, n, r, s)=>e + n + r + s + (t / 2 ** 32 | 0) | 0, Vs = (t, e, n, r, s)=>(t >>> 0) + (e >>> 0) + (n >>> 0) + (r >>> 0) + (s >>> 0), Zs = (t, e, n, r, s, o)=>e + n + r + s + o + (t / 2 ** 32 | 0) | 0, H = {
        fromBig: jn,
        split: Ss,
        toBig: Hs,
        shrSH: Is,
        shrSL: Cs,
        rotrSH: Ls,
        rotrSL: Us,
        rotrBH: $s,
        rotrBL: Ts,
        rotr32H: Ns,
        rotr32L: Rs,
        rotlSH: Ds,
        rotlSL: zs,
        rotlBH: Os,
        rotlBL: qs,
        add: js,
        add3L: Ks,
        add3H: Ms,
        add4L: Gs,
        add4H: Ps,
        add5H: Zs,
        add5L: Vs
    }, [Xs, Fs] = H.split([
        "0x428a2f98d728ae22",
        "0x7137449123ef65cd",
        "0xb5c0fbcfec4d3b2f",
        "0xe9b5dba58189dbbc",
        "0x3956c25bf348b538",
        "0x59f111f1b605d019",
        "0x923f82a4af194f9b",
        "0xab1c5ed5da6d8118",
        "0xd807aa98a3030242",
        "0x12835b0145706fbe",
        "0x243185be4ee4b28c",
        "0x550c7dc3d5ffb4e2",
        "0x72be5d74f27b896f",
        "0x80deb1fe3b1696b1",
        "0x9bdc06a725c71235",
        "0xc19bf174cf692694",
        "0xe49b69c19ef14ad2",
        "0xefbe4786384f25e3",
        "0x0fc19dc68b8cd5b5",
        "0x240ca1cc77ac9c65",
        "0x2de92c6f592b0275",
        "0x4a7484aa6ea6e483",
        "0x5cb0a9dcbd41fbd4",
        "0x76f988da831153b5",
        "0x983e5152ee66dfab",
        "0xa831c66d2db43210",
        "0xb00327c898fb213f",
        "0xbf597fc7beef0ee4",
        "0xc6e00bf33da88fc2",
        "0xd5a79147930aa725",
        "0x06ca6351e003826f",
        "0x142929670a0e6e70",
        "0x27b70a8546d22ffc",
        "0x2e1b21385c26c926",
        "0x4d2c6dfc5ac42aed",
        "0x53380d139d95b3df",
        "0x650a73548baf63de",
        "0x766a0abb3c77b2a8",
        "0x81c2c92e47edaee6",
        "0x92722c851482353b",
        "0xa2bfe8a14cf10364",
        "0xa81a664bbc423001",
        "0xc24b8b70d0f89791",
        "0xc76c51a30654be30",
        "0xd192e819d6ef5218",
        "0xd69906245565a910",
        "0xf40e35855771202a",
        "0x106aa07032bbd1b8",
        "0x19a4c116b8d2d0c8",
        "0x1e376c085141ab53",
        "0x2748774cdf8eeb99",
        "0x34b0bcb5e19b48a8",
        "0x391c0cb3c5c95a63",
        "0x4ed8aa4ae3418acb",
        "0x5b9cca4f7763e373",
        "0x682e6ff3d6b2b8a3",
        "0x748f82ee5defb2fc",
        "0x78a5636f43172f60",
        "0x84c87814a1f0ab72",
        "0x8cc702081a6439ec",
        "0x90befffa23631e28",
        "0xa4506cebde82bde9",
        "0xbef9a3f7b2c67915",
        "0xc67178f2e372532b",
        "0xca273eceea26619c",
        "0xd186b8c721c0c207",
        "0xeada7dd6cde0eb1e",
        "0xf57d4f7fee6ed178",
        "0x06f067aa72176fba",
        "0x0a637dc5a2c898a6",
        "0x113f9804bef90dae",
        "0x1b710b35131c471b",
        "0x28db77f523047d84",
        "0x32caab7b40c72493",
        "0x3c9ebe0a15c9bebc",
        "0x431d67c49c100d4c",
        "0x4cc5d4becb3e42b6",
        "0x597f299cfc657e2a",
        "0x5fcb6fab3ad6faec",
        "0x6c44198c4a475817"
    ].map((t)=>BigInt(t))), le = new Uint32Array(80), fe = new Uint32Array(80);
    class Ys extends qn {
        constructor(){
            super(128, 64, 16, !1), this.Ah = 1779033703, this.Al = -205731576, this.Bh = -1150833019, this.Bl = -2067093701, this.Ch = 1013904242, this.Cl = -23791573, this.Dh = -1521486534, this.Dl = 1595750129, this.Eh = 1359893119, this.El = -1377402159, this.Fh = -1694144372, this.Fl = 725511199, this.Gh = 528734635, this.Gl = -79577749, this.Hh = 1541459225, this.Hl = 327033209;
        }
        get() {
            const { Ah: e, Al: n, Bh: r, Bl: s, Ch: o, Cl: i, Dh: c, Dl: a, Eh: u, El: h, Fh: f, Fl: l, Gh: d, Gl: p, Hh: m, Hl: w } = this;
            return [
                e,
                n,
                r,
                s,
                o,
                i,
                c,
                a,
                u,
                h,
                f,
                l,
                d,
                p,
                m,
                w
            ];
        }
        set(e, n, r, s, o, i, c, a, u, h, f, l, d, p, m, w) {
            this.Ah = e | 0, this.Al = n | 0, this.Bh = r | 0, this.Bl = s | 0, this.Ch = o | 0, this.Cl = i | 0, this.Dh = c | 0, this.Dl = a | 0, this.Eh = u | 0, this.El = h | 0, this.Fh = f | 0, this.Fl = l | 0, this.Gh = d | 0, this.Gl = p | 0, this.Hh = m | 0, this.Hl = w | 0;
        }
        process(e, n) {
            for(let b = 0; b < 16; b++, n += 4)le[b] = e.getUint32(n), fe[b] = e.getUint32(n += 4);
            for(let b = 16; b < 80; b++){
                const E = le[b - 15] | 0, B = fe[b - 15] | 0, I = H.rotrSH(E, B, 1) ^ H.rotrSH(E, B, 8) ^ H.shrSH(E, B, 7), C = H.rotrSL(E, B, 1) ^ H.rotrSL(E, B, 8) ^ H.shrSL(E, B, 7), k = le[b - 2] | 0, g = fe[b - 2] | 0, v = H.rotrSH(k, g, 19) ^ H.rotrBH(k, g, 61) ^ H.shrSH(k, g, 6), A = H.rotrSL(k, g, 19) ^ H.rotrBL(k, g, 61) ^ H.shrSL(k, g, 6), S = H.add4L(C, A, fe[b - 7], fe[b - 16]), $ = H.add4H(S, I, v, le[b - 7], le[b - 16]);
                le[b] = $ | 0, fe[b] = S | 0;
            }
            let { Ah: r, Al: s, Bh: o, Bl: i, Ch: c, Cl: a, Dh: u, Dl: h, Eh: f, El: l, Fh: d, Fl: p, Gh: m, Gl: w, Hh: y, Hl: _ } = this;
            for(let b = 0; b < 80; b++){
                const E = H.rotrSH(f, l, 14) ^ H.rotrSH(f, l, 18) ^ H.rotrBH(f, l, 41), B = H.rotrSL(f, l, 14) ^ H.rotrSL(f, l, 18) ^ H.rotrBL(f, l, 41), I = f & d ^ ~f & m, C = l & p ^ ~l & w, k = H.add5L(_, B, C, Fs[b], fe[b]), g = H.add5H(k, y, E, I, Xs[b], le[b]), v = k | 0, A = H.rotrSH(r, s, 28) ^ H.rotrBH(r, s, 34) ^ H.rotrBH(r, s, 39), S = H.rotrSL(r, s, 28) ^ H.rotrBL(r, s, 34) ^ H.rotrBL(r, s, 39), $ = r & o ^ r & c ^ o & c, U = s & i ^ s & a ^ i & a;
                y = m | 0, _ = w | 0, m = d | 0, w = p | 0, d = f | 0, p = l | 0, { h: f, l } = H.add(u | 0, h | 0, g | 0, v | 0), u = c | 0, h = a | 0, c = o | 0, a = i | 0, o = r | 0, i = s | 0;
                const T = H.add3L(v, S, U);
                r = H.add3H(T, g, A, $), s = T | 0;
            }
            ({ h: r, l: s } = H.add(this.Ah | 0, this.Al | 0, r | 0, s | 0)), { h: o, l: i } = H.add(this.Bh | 0, this.Bl | 0, o | 0, i | 0), { h: c, l: a } = H.add(this.Ch | 0, this.Cl | 0, c | 0, a | 0), { h: u, l: h } = H.add(this.Dh | 0, this.Dl | 0, u | 0, h | 0), { h: f, l } = H.add(this.Eh | 0, this.El | 0, f | 0, l | 0), { h: d, l: p } = H.add(this.Fh | 0, this.Fl | 0, d | 0, p | 0), { h: m, l: w } = H.add(this.Gh | 0, this.Gl | 0, m | 0, w | 0), { h: y, l: _ } = H.add(this.Hh | 0, this.Hl | 0, y | 0, _ | 0), this.set(r, s, o, i, c, a, u, h, f, l, d, p, m, w, y, _);
        }
        roundClean() {
            le.fill(0), fe.fill(0);
        }
        destroy() {
            this.buffer.fill(0), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
        }
    }
    const Ws = Dn(()=>new Ys);
    function We(t) {
        return t instanceof Uint8Array || t != null && typeof t == "object" && t.constructor.name === "Uint8Array";
    }
    function Js(...t) {
        const e = (o)=>o, n = (o, i)=>(c)=>o(i(c)), r = t.map((o)=>o.encode).reduceRight(n, e), s = t.map((o)=>o.decode).reduce(n, e);
        return {
            encode: r,
            decode: s
        };
    }
    function Qs(t) {
        return {
            encode: (e)=>{
                if (!Array.isArray(e) || e.length && typeof e[0] != "number") throw new Error("alphabet.encode input should be an array of numbers");
                return e.map((n)=>{
                    if (n < 0 || n >= t.length) throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${t.length})`);
                    return t[n];
                });
            },
            decode: (e)=>{
                if (!Array.isArray(e) || e.length && typeof e[0] != "string") throw new Error("alphabet.decode input should be array of strings");
                return e.map((n)=>{
                    if (typeof n != "string") throw new Error(`alphabet.decode: not string element=${n}`);
                    const r = t.indexOf(n);
                    if (r === -1) throw new Error(`Unknown letter: "${n}". Allowed: ${t}`);
                    return r;
                });
            }
        };
    }
    function eo(t = "") {
        if (typeof t != "string") throw new Error("join separator should be string");
        return {
            encode: (e)=>{
                if (!Array.isArray(e) || e.length && typeof e[0] != "string") throw new Error("join.encode input should be array of strings");
                for (let n of e)if (typeof n != "string") throw new Error(`join.encode: non-string input=${n}`);
                return e.join(t);
            },
            decode: (e)=>{
                if (typeof e != "string") throw new Error("join.decode input should be string");
                return e.split(t);
            }
        };
    }
    function to(t, e = "=") {
        if (typeof e != "string") throw new Error("padding chr should be string");
        return {
            encode (n) {
                if (!Array.isArray(n) || n.length && typeof n[0] != "string") throw new Error("padding.encode input should be array of strings");
                for (let r of n)if (typeof r != "string") throw new Error(`padding.encode: non-string input=${r}`);
                for(; n.length * t % 8;)n.push(e);
                return n;
            },
            decode (n) {
                if (!Array.isArray(n) || n.length && typeof n[0] != "string") throw new Error("padding.encode input should be array of strings");
                for (let s of n)if (typeof s != "string") throw new Error(`padding.decode: non-string input=${s}`);
                let r = n.length;
                if (r * t % 8) throw new Error("Invalid padding: string should have whole number of bytes");
                for(; r > 0 && n[r - 1] === e; r--)if (!((r - 1) * t % 8)) throw new Error("Invalid padding: string has too much padding");
                return n.slice(0, r);
            }
        };
    }
    function xt(t, e, n) {
        if (e < 2) throw new Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);
        if (n < 2) throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);
        if (!Array.isArray(t)) throw new Error("convertRadix: data should be array");
        if (!t.length) return [];
        let r = 0;
        const s = [], o = Array.from(t);
        for(o.forEach((i)=>{
            if (i < 0 || i >= e) throw new Error(`Wrong integer: ${i}`);
        });;){
            let i = 0, c = !0;
            for(let a = r; a < o.length; a++){
                const u = o[a], h = e * i + u;
                if (!Number.isSafeInteger(h) || e * i / e !== i || h - u !== e * i) throw new Error("convertRadix: carry overflow");
                i = h % n;
                const f = Math.floor(h / n);
                if (o[a] = f, !Number.isSafeInteger(f) || f * n + i !== h) throw new Error("convertRadix: carry overflow");
                if (c) f ? c = !1 : r = a;
                else continue;
            }
            if (s.push(i), c) break;
        }
        for(let i = 0; i < t.length - 1 && t[i] === 0; i++)s.push(0);
        return s.reverse();
    }
    const Kn = (t, e)=>e ? Kn(e, t % e) : t, Je = (t, e)=>t + (e - Kn(t, e));
    function vt(t, e, n, r) {
        if (!Array.isArray(t)) throw new Error("convertRadix2: data should be array");
        if (e <= 0 || e > 32) throw new Error(`convertRadix2: wrong from=${e}`);
        if (n <= 0 || n > 32) throw new Error(`convertRadix2: wrong to=${n}`);
        if (Je(e, n) > 32) throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${Je(e, n)}`);
        let s = 0, o = 0;
        const i = 2 ** n - 1, c = [];
        for (const a of t){
            if (a >= 2 ** e) throw new Error(`convertRadix2: invalid data word=${a} from=${e}`);
            if (s = s << e | a, o + e > 32) throw new Error(`convertRadix2: carry overflow pos=${o} from=${e}`);
            for(o += e; o >= n; o -= n)c.push((s >> o - n & i) >>> 0);
            s &= 2 ** o - 1;
        }
        if (s = s << n - o & i, !r && o >= e) throw new Error("Excess padding");
        if (!r && s) throw new Error(`Non-zero padding: ${s}`);
        return r && o > 0 && c.push(s >>> 0), c;
    }
    function no(t) {
        return {
            encode: (e)=>{
                if (!We(e)) throw new Error("radix.encode input should be Uint8Array");
                return xt(Array.from(e), 2 ** 8, t);
            },
            decode: (e)=>{
                if (!Array.isArray(e) || e.length && typeof e[0] != "number") throw new Error("radix.decode input should be array of numbers");
                return Uint8Array.from(xt(e, t, 2 ** 8));
            }
        };
    }
    function ro(t, e = !1) {
        if (t <= 0 || t > 32) throw new Error("radix2: bits should be in (0..32]");
        if (Je(8, t) > 32 || Je(t, 8) > 32) throw new Error("radix2: carry overflow");
        return {
            encode: (n)=>{
                if (!We(n)) throw new Error("radix2.encode input should be Uint8Array");
                return vt(Array.from(n), 8, t, !e);
            },
            decode: (n)=>{
                if (!Array.isArray(n) || n.length && typeof n[0] != "number") throw new Error("radix2.decode input should be array of numbers");
                return Uint8Array.from(vt(n, t, 8, e));
            }
        };
    }
    function so(t, e) {
        if (typeof e != "function") throw new Error("checksum fn should be function");
        return {
            encode (n) {
                if (!We(n)) throw new Error("checksum.encode: input should be Uint8Array");
                const r = e(n).slice(0, t), s = new Uint8Array(n.length + t);
                return s.set(n), s.set(r, n.length), s;
            },
            decode (n) {
                if (!We(n)) throw new Error("checksum.decode: input should be Uint8Array");
                const r = n.slice(0, -t), s = e(r).slice(0, t), o = n.slice(-t);
                for(let i = 0; i < t; i++)if (s[i] !== o[i]) throw new Error("Invalid checksum");
                return r;
            }
        };
    }
    const Ve = {
        alphabet: Qs,
        chain: Js,
        checksum: so,
        convertRadix: xt,
        convertRadix2: vt,
        radix: no,
        radix2: ro,
        join: eo,
        padding: to
    };
    const oo = (t)=>t[0] === "あいこくしん";
    function Mn(t) {
        if (typeof t != "string") throw new TypeError(`Invalid mnemonic type: ${typeof t}`);
        return t.normalize("NFKD");
    }
    function Gn(t) {
        const e = Mn(t), n = e.split(" ");
        if (![
            12,
            15,
            18,
            21,
            24
        ].includes(n.length)) throw new Error("Invalid mnemonic");
        return {
            nfkd: e,
            words: n
        };
    }
    function Pn(t) {
        st(t, 16, 20, 24, 28, 32);
    }
    const io = (t)=>{
        const e = 8 - t.length / 4;
        return new Uint8Array([
            ks(t)[0] >> e << e
        ]);
    };
    function Vn(t) {
        if (!Array.isArray(t) || t.length !== 2048 || typeof t[0] != "string") throw new Error("Wordlist: expected array of 2048 strings");
        return t.forEach((e)=>{
            if (typeof e != "string") throw new Error(`Wordlist: non-string element: ${e}`);
        }), Ve.chain(Ve.checksum(1, io), Ve.radix2(11, !0), Ve.alphabet(t));
    }
    function $t(t, e) {
        const { words: n } = Gn(t), r = Vn(e).decode(n);
        return Pn(r), r;
    }
    oi = function(t, e) {
        return Pn(t), Vn(e).encode(t).join(oo(e) ? "　" : " ");
    };
    ii = function(t, e) {
        try {
            $t(t, e);
        } catch  {
            return !1;
        }
        return !0;
    };
    const ao = (t)=>Mn(`mnemonic${t}`);
    ai = function(t, e = "") {
        return xs(Ws, Gn(t).nfkd, ao(e), {
            c: 2048,
            dkLen: 64
        });
    };
    const Tt = 6e5, Qe = 2, co = 16, lo = 12;
    function et(t) {
        const e = t instanceof Uint8Array ? t : new Uint8Array(t);
        let n = "";
        for(let r = 0; r < e.length; r++)n += String.fromCharCode(e[r]);
        return btoa(n);
    }
    Oe = function(t) {
        const e = atob(t), n = new Uint8Array(e.length);
        for(let r = 0; r < e.length; r++)n[r] = e.charCodeAt(r);
        return n;
    };
    async function Zn(t, e, n = Tt) {
        const r = typeof t == "string" ? new TextEncoder().encode(t) : new Uint8Array(t), s = await crypto.subtle.importKey("raw", r.buffer, "PBKDF2", !1, [
            "deriveKey"
        ]);
        return r.fill(0), crypto.subtle.deriveKey({
            name: "PBKDF2",
            salt: e.buffer,
            iterations: n,
            hash: "SHA-256"
        }, s, {
            name: "AES-GCM",
            length: 256
        }, !0, [
            "encrypt",
            "decrypt"
        ]);
    }
    async function Xn(t, e, n) {
        const r = new TextEncoder, s = crypto.getRandomValues(new Uint8Array(lo)), o = {
            name: "AES-GCM",
            iv: s.buffer
        };
        n && (o.additionalData = n.buffer);
        const i = r.encode(e), c = await crypto.subtle.encrypt(o, t, i);
        return i.fill(0), {
            iv: et(s),
            ciphertext: et(c)
        };
    }
    fo = async function(t, e, n, r) {
        const s = new TextDecoder, o = Oe(n), i = Oe(e), c = {
            name: "AES-GCM",
            iv: o.buffer
        };
        r && (c.additionalData = r.buffer);
        const a = await crypto.subtle.decrypt(c, t, i.buffer);
        return s.decode(a);
    };
    ci = async function(t) {
        const e = await crypto.subtle.exportKey("raw", t);
        return et(e);
    };
    li = async function(t, e = !1) {
        const n = Oe(t), r = await crypto.subtle.importKey("raw", n.buffer, {
            name: "AES-GCM",
            length: 256
        }, e, [
            "encrypt",
            "decrypt"
        ]);
        return n.fill(0), r;
    };
    function uo() {
        return crypto.getRandomValues(new Uint8Array(co));
    }
    function Nt(t, e) {
        const n = Oe(e), r = new Uint8Array(1 + n.length);
        return r[0] = t, r.set(n, 1), r;
    }
    fi = async function(t, e) {
        const n = uo(), r = await Zn(t, n, Tt), s = JSON.stringify(e), o = et(n), i = Nt(Qe, o), { iv: c, ciphertext: a } = await Xn(r, s, i);
        return {
            version: Qe,
            salt: o,
            iv: c,
            ciphertext: a
        };
    };
    ui = async function(t, e) {
        const n = Oe(e.salt), r = await Zn(t, n, Tt), s = Nt(e.version, e.salt), o = await fo(r, e.ciphertext, e.iv, s), i = JSON.parse(o);
        if (!i || typeof i.seed != "string" || typeof i.nightExternalKey != "string" || typeof i.zswapKeys != "string" || typeof i.dustKeys != "string") throw new Error("Invalid vault structure");
        return {
            contents: i,
            key: r
        };
    };
    di = async function(t, e, n) {
        const r = JSON.stringify(n), s = Nt(Qe, e), { iv: o, ciphertext: i } = await Xn(t, r, s);
        return {
            version: Qe,
            salt: e,
            iv: o,
            ciphertext: i
        };
    };
    let ho, ot, Yn, it, po, Wn, Jn;
    Fn = `abandon
ability
able
about
above
absent
absorb
abstract
absurd
abuse
access
accident
account
accuse
achieve
acid
acoustic
acquire
across
act
action
actor
actress
actual
adapt
add
addict
address
adjust
admit
adult
advance
advice
aerobic
affair
afford
afraid
again
age
agent
agree
ahead
aim
air
airport
aisle
alarm
album
alcohol
alert
alien
all
alley
allow
almost
alone
alpha
already
also
alter
always
amateur
amazing
among
amount
amused
analyst
anchor
ancient
anger
angle
angry
animal
ankle
announce
annual
another
answer
antenna
antique
anxiety
any
apart
apology
appear
apple
approve
april
arch
arctic
area
arena
argue
arm
armed
armor
army
around
arrange
arrest
arrive
arrow
art
artefact
artist
artwork
ask
aspect
assault
asset
assist
assume
asthma
athlete
atom
attack
attend
attitude
attract
auction
audit
august
aunt
author
auto
autumn
average
avocado
avoid
awake
aware
away
awesome
awful
awkward
axis
baby
bachelor
bacon
badge
bag
balance
balcony
ball
bamboo
banana
banner
bar
barely
bargain
barrel
base
basic
basket
battle
beach
bean
beauty
because
become
beef
before
begin
behave
behind
believe
below
belt
bench
benefit
best
betray
better
between
beyond
bicycle
bid
bike
bind
biology
bird
birth
bitter
black
blade
blame
blanket
blast
bleak
bless
blind
blood
blossom
blouse
blue
blur
blush
board
boat
body
boil
bomb
bone
bonus
book
boost
border
boring
borrow
boss
bottom
bounce
box
boy
bracket
brain
brand
brass
brave
bread
breeze
brick
bridge
brief
bright
bring
brisk
broccoli
broken
bronze
broom
brother
brown
brush
bubble
buddy
budget
buffalo
build
bulb
bulk
bullet
bundle
bunker
burden
burger
burst
bus
business
busy
butter
buyer
buzz
cabbage
cabin
cable
cactus
cage
cake
call
calm
camera
camp
can
canal
cancel
candy
cannon
canoe
canvas
canyon
capable
capital
captain
car
carbon
card
cargo
carpet
carry
cart
case
cash
casino
castle
casual
cat
catalog
catch
category
cattle
caught
cause
caution
cave
ceiling
celery
cement
census
century
cereal
certain
chair
chalk
champion
change
chaos
chapter
charge
chase
chat
cheap
check
cheese
chef
cherry
chest
chicken
chief
child
chimney
choice
choose
chronic
chuckle
chunk
churn
cigar
cinnamon
circle
citizen
city
civil
claim
clap
clarify
claw
clay
clean
clerk
clever
click
client
cliff
climb
clinic
clip
clock
clog
close
cloth
cloud
clown
club
clump
cluster
clutch
coach
coast
coconut
code
coffee
coil
coin
collect
color
column
combine
come
comfort
comic
common
company
concert
conduct
confirm
congress
connect
consider
control
convince
cook
cool
copper
copy
coral
core
corn
correct
cost
cotton
couch
country
couple
course
cousin
cover
coyote
crack
cradle
craft
cram
crane
crash
crater
crawl
crazy
cream
credit
creek
crew
cricket
crime
crisp
critic
crop
cross
crouch
crowd
crucial
cruel
cruise
crumble
crunch
crush
cry
crystal
cube
culture
cup
cupboard
curious
current
curtain
curve
cushion
custom
cute
cycle
dad
damage
damp
dance
danger
daring
dash
daughter
dawn
day
deal
debate
debris
decade
december
decide
decline
decorate
decrease
deer
defense
define
defy
degree
delay
deliver
demand
demise
denial
dentist
deny
depart
depend
deposit
depth
deputy
derive
describe
desert
design
desk
despair
destroy
detail
detect
develop
device
devote
diagram
dial
diamond
diary
dice
diesel
diet
differ
digital
dignity
dilemma
dinner
dinosaur
direct
dirt
disagree
discover
disease
dish
dismiss
disorder
display
distance
divert
divide
divorce
dizzy
doctor
document
dog
doll
dolphin
domain
donate
donkey
donor
door
dose
double
dove
draft
dragon
drama
drastic
draw
dream
dress
drift
drill
drink
drip
drive
drop
drum
dry
duck
dumb
dune
during
dust
dutch
duty
dwarf
dynamic
eager
eagle
early
earn
earth
easily
east
easy
echo
ecology
economy
edge
edit
educate
effort
egg
eight
either
elbow
elder
electric
elegant
element
elephant
elevator
elite
else
embark
embody
embrace
emerge
emotion
employ
empower
empty
enable
enact
end
endless
endorse
enemy
energy
enforce
engage
engine
enhance
enjoy
enlist
enough
enrich
enroll
ensure
enter
entire
entry
envelope
episode
equal
equip
era
erase
erode
erosion
error
erupt
escape
essay
essence
estate
eternal
ethics
evidence
evil
evoke
evolve
exact
example
excess
exchange
excite
exclude
excuse
execute
exercise
exhaust
exhibit
exile
exist
exit
exotic
expand
expect
expire
explain
expose
express
extend
extra
eye
eyebrow
fabric
face
faculty
fade
faint
faith
fall
false
fame
family
famous
fan
fancy
fantasy
farm
fashion
fat
fatal
father
fatigue
fault
favorite
feature
february
federal
fee
feed
feel
female
fence
festival
fetch
fever
few
fiber
fiction
field
figure
file
film
filter
final
find
fine
finger
finish
fire
firm
first
fiscal
fish
fit
fitness
fix
flag
flame
flash
flat
flavor
flee
flight
flip
float
flock
floor
flower
fluid
flush
fly
foam
focus
fog
foil
fold
follow
food
foot
force
forest
forget
fork
fortune
forum
forward
fossil
foster
found
fox
fragile
frame
frequent
fresh
friend
fringe
frog
front
frost
frown
frozen
fruit
fuel
fun
funny
furnace
fury
future
gadget
gain
galaxy
gallery
game
gap
garage
garbage
garden
garlic
garment
gas
gasp
gate
gather
gauge
gaze
general
genius
genre
gentle
genuine
gesture
ghost
giant
gift
giggle
ginger
giraffe
girl
give
glad
glance
glare
glass
glide
glimpse
globe
gloom
glory
glove
glow
glue
goat
goddess
gold
good
goose
gorilla
gospel
gossip
govern
gown
grab
grace
grain
grant
grape
grass
gravity
great
green
grid
grief
grit
grocery
group
grow
grunt
guard
guess
guide
guilt
guitar
gun
gym
habit
hair
half
hammer
hamster
hand
happy
harbor
hard
harsh
harvest
hat
have
hawk
hazard
head
health
heart
heavy
hedgehog
height
hello
helmet
help
hen
hero
hidden
high
hill
hint
hip
hire
history
hobby
hockey
hold
hole
holiday
hollow
home
honey
hood
hope
horn
horror
horse
hospital
host
hotel
hour
hover
hub
huge
human
humble
humor
hundred
hungry
hunt
hurdle
hurry
hurt
husband
hybrid
ice
icon
idea
identify
idle
ignore
ill
illegal
illness
image
imitate
immense
immune
impact
impose
improve
impulse
inch
include
income
increase
index
indicate
indoor
industry
infant
inflict
inform
inhale
inherit
initial
inject
injury
inmate
inner
innocent
input
inquiry
insane
insect
inside
inspire
install
intact
interest
into
invest
invite
involve
iron
island
isolate
issue
item
ivory
jacket
jaguar
jar
jazz
jealous
jeans
jelly
jewel
job
join
joke
journey
joy
judge
juice
jump
jungle
junior
junk
just
kangaroo
keen
keep
ketchup
key
kick
kid
kidney
kind
kingdom
kiss
kit
kitchen
kite
kitten
kiwi
knee
knife
knock
know
lab
label
labor
ladder
lady
lake
lamp
language
laptop
large
later
latin
laugh
laundry
lava
law
lawn
lawsuit
layer
lazy
leader
leaf
learn
leave
lecture
left
leg
legal
legend
leisure
lemon
lend
length
lens
leopard
lesson
letter
level
liar
liberty
library
license
life
lift
light
like
limb
limit
link
lion
liquid
list
little
live
lizard
load
loan
lobster
local
lock
logic
lonely
long
loop
lottery
loud
lounge
love
loyal
lucky
luggage
lumber
lunar
lunch
luxury
lyrics
machine
mad
magic
magnet
maid
mail
main
major
make
mammal
man
manage
mandate
mango
mansion
manual
maple
marble
march
margin
marine
market
marriage
mask
mass
master
match
material
math
matrix
matter
maximum
maze
meadow
mean
measure
meat
mechanic
medal
media
melody
melt
member
memory
mention
menu
mercy
merge
merit
merry
mesh
message
metal
method
middle
midnight
milk
million
mimic
mind
minimum
minor
minute
miracle
mirror
misery
miss
mistake
mix
mixed
mixture
mobile
model
modify
mom
moment
monitor
monkey
monster
month
moon
moral
more
morning
mosquito
mother
motion
motor
mountain
mouse
move
movie
much
muffin
mule
multiply
muscle
museum
mushroom
music
must
mutual
myself
mystery
myth
naive
name
napkin
narrow
nasty
nation
nature
near
neck
need
negative
neglect
neither
nephew
nerve
nest
net
network
neutral
never
news
next
nice
night
noble
noise
nominee
noodle
normal
north
nose
notable
note
nothing
notice
novel
now
nuclear
number
nurse
nut
oak
obey
object
oblige
obscure
observe
obtain
obvious
occur
ocean
october
odor
off
offer
office
often
oil
okay
old
olive
olympic
omit
once
one
onion
online
only
open
opera
opinion
oppose
option
orange
orbit
orchard
order
ordinary
organ
orient
original
orphan
ostrich
other
outdoor
outer
output
outside
oval
oven
over
own
owner
oxygen
oyster
ozone
pact
paddle
page
pair
palace
palm
panda
panel
panic
panther
paper
parade
parent
park
parrot
party
pass
patch
path
patient
patrol
pattern
pause
pave
payment
peace
peanut
pear
peasant
pelican
pen
penalty
pencil
people
pepper
perfect
permit
person
pet
phone
photo
phrase
physical
piano
picnic
picture
piece
pig
pigeon
pill
pilot
pink
pioneer
pipe
pistol
pitch
pizza
place
planet
plastic
plate
play
please
pledge
pluck
plug
plunge
poem
poet
point
polar
pole
police
pond
pony
pool
popular
portion
position
possible
post
potato
pottery
poverty
powder
power
practice
praise
predict
prefer
prepare
present
pretty
prevent
price
pride
primary
print
priority
prison
private
prize
problem
process
produce
profit
program
project
promote
proof
property
prosper
protect
proud
provide
public
pudding
pull
pulp
pulse
pumpkin
punch
pupil
puppy
purchase
purity
purpose
purse
push
put
puzzle
pyramid
quality
quantum
quarter
question
quick
quit
quiz
quote
rabbit
raccoon
race
rack
radar
radio
rail
rain
raise
rally
ramp
ranch
random
range
rapid
rare
rate
rather
raven
raw
razor
ready
real
reason
rebel
rebuild
recall
receive
recipe
record
recycle
reduce
reflect
reform
refuse
region
regret
regular
reject
relax
release
relief
rely
remain
remember
remind
remove
render
renew
rent
reopen
repair
repeat
replace
report
require
rescue
resemble
resist
resource
response
result
retire
retreat
return
reunion
reveal
review
reward
rhythm
rib
ribbon
rice
rich
ride
ridge
rifle
right
rigid
ring
riot
ripple
risk
ritual
rival
river
road
roast
robot
robust
rocket
romance
roof
rookie
room
rose
rotate
rough
round
route
royal
rubber
rude
rug
rule
run
runway
rural
sad
saddle
sadness
safe
sail
salad
salmon
salon
salt
salute
same
sample
sand
satisfy
satoshi
sauce
sausage
save
say
scale
scan
scare
scatter
scene
scheme
school
science
scissors
scorpion
scout
scrap
screen
script
scrub
sea
search
season
seat
second
secret
section
security
seed
seek
segment
select
sell
seminar
senior
sense
sentence
series
service
session
settle
setup
seven
shadow
shaft
shallow
share
shed
shell
sheriff
shield
shift
shine
ship
shiver
shock
shoe
shoot
shop
short
shoulder
shove
shrimp
shrug
shuffle
shy
sibling
sick
side
siege
sight
sign
silent
silk
silly
silver
similar
simple
since
sing
siren
sister
situate
six
size
skate
sketch
ski
skill
skin
skirt
skull
slab
slam
sleep
slender
slice
slide
slight
slim
slogan
slot
slow
slush
small
smart
smile
smoke
smooth
snack
snake
snap
sniff
snow
soap
soccer
social
sock
soda
soft
solar
soldier
solid
solution
solve
someone
song
soon
sorry
sort
soul
sound
soup
source
south
space
spare
spatial
spawn
speak
special
speed
spell
spend
sphere
spice
spider
spike
spin
spirit
split
spoil
sponsor
spoon
sport
spot
spray
spread
spring
spy
square
squeeze
squirrel
stable
stadium
staff
stage
stairs
stamp
stand
start
state
stay
steak
steel
stem
step
stereo
stick
still
sting
stock
stomach
stone
stool
story
stove
strategy
street
strike
strong
struggle
student
stuff
stumble
style
subject
submit
subway
success
such
sudden
suffer
sugar
suggest
suit
summer
sun
sunny
sunset
super
supply
supreme
sure
surface
surge
surprise
surround
survey
suspect
sustain
swallow
swamp
swap
swarm
swear
sweet
swift
swim
swing
switch
sword
symbol
symptom
syrup
system
table
tackle
tag
tail
talent
talk
tank
tape
target
task
taste
tattoo
taxi
teach
team
tell
ten
tenant
tennis
tent
term
test
text
thank
that
theme
then
theory
there
they
thing
this
thought
three
thrive
throw
thumb
thunder
ticket
tide
tiger
tilt
timber
time
tiny
tip
tired
tissue
title
toast
tobacco
today
toddler
toe
together
toilet
token
tomato
tomorrow
tone
tongue
tonight
tool
tooth
top
topic
topple
torch
tornado
tortoise
toss
total
tourist
toward
tower
town
toy
track
trade
traffic
tragic
train
transfer
trap
trash
travel
tray
treat
tree
trend
trial
tribe
trick
trigger
trim
trip
trophy
trouble
truck
true
truly
trumpet
trust
truth
try
tube
tuition
tumble
tuna
tunnel
turkey
turn
turtle
twelve
twenty
twice
twin
twist
two
type
typical
ugly
umbrella
unable
unaware
uncle
uncover
under
undo
unfair
unfold
unhappy
uniform
unique
unit
universe
unknown
unlock
until
unusual
unveil
update
upgrade
uphold
upon
upper
upset
urban
urge
usage
use
used
useful
useless
usual
utility
vacant
vacuum
vague
valid
valley
valve
van
vanish
vapor
various
vast
vault
vehicle
velvet
vendor
venture
venue
verb
verify
version
very
vessel
veteran
viable
vibrant
vicious
victory
video
view
village
vintage
violin
virtual
virus
visa
visit
visual
vital
vivid
vocal
voice
void
volcano
volume
vote
voyage
wage
wagon
wait
walk
wall
walnut
want
warfare
warm
warrior
wash
wasp
waste
water
wave
way
wealth
weapon
wear
weasel
weather
web
wedding
weekend
weird
welcome
west
wet
whale
what
wheat
wheel
when
where
whip
whisper
wide
width
wife
wild
will
win
window
wine
wing
wink
winner
winter
wire
wisdom
wise
wish
witness
wolf
woman
wonder
wood
wool
word
work
world
worry
worth
wrap
wreck
wrestle
wrist
write
wrong
yard
year
yellow
you
young
youth
zebra
zero
zone
zoo`.split(`
`);
    ho = {};
    ot = "0691b2fecca1ac4f53cb6dfb00b7013e561d1f34403b957cbb5af1fa";
    Yn = "73e4aea31b5b51d9b0ca386196fc6a4c422f74c5aea011e4b8bdf4e5";
    it = "4e49474854";
    tt = `${ot}${it}`;
    po = ho;
    Wn = po.WXT_CARDANO_PROXY_URL?.trim().replace(/\/$/, "");
    Jn = {
        mainnet: "https://api.1am.xyz/rpc/cardano",
        preview: "https://api-preview.1am.xyz/rpc/cardano",
        preprod: "https://api-preprod.1am.xyz/rpc/cardano"
    };
    bo = Wn || Jn.mainnet;
    function J(t = "mainnet") {
        return Wn || Jn[t];
    }
    Qn = function(t = "mainnet") {
        return t === "mainnet" ? 1 : 0;
    };
    const we = 2147483648;
    function Rt(t, e) {
        if (typeof t != "string" || !/^\d+$/.test(t)) throw new Error(`${e} must be an unsigned decimal string`);
        return t;
    }
    function Be(t, e) {
        if (typeof t == "string") return Rt(t, e);
        if (typeof t == "number" && Number.isSafeInteger(t) && t >= 0) return String(t);
        throw new Error(`${e} must be an unsigned decimal string`);
    }
    function $e(t, e, n, r) {
        const s = Rt(t, e), o = BigInt(s);
        if (o < n || o > r) throw new Error(`${e} is out of range`);
        return s;
    }
    function qe(t, e, n, r) {
        const s = typeof t == "string" ? Number(t) : typeof t == "number" ? t : Number.NaN;
        if (!Number.isInteger(s) || s < n || s > r) throw new Error(`${e} is out of range`);
        return s;
    }
    async function xe(t, e) {
        try {
            return await t.json();
        } catch  {
            throw new Error(`${e} returned invalid JSON`);
        }
    }
    function Dt(t, e) {
        if (!Array.isArray(t)) throw new Error(`${e} amount is not an array`);
        return t.map((n, r)=>{
            if (!n || typeof n != "object") throw new Error(`${e} amount[${r}] is invalid`);
            const s = n, o = typeof s.unit == "string" ? s.unit : "", i = Rt(s.quantity, `${e} amount[${r}].quantity`);
            if (!o) throw new Error(`${e} amount[${r}].unit is invalid`);
            return {
                unit: o,
                quantity: i
            };
        });
    }
    function mo(t) {
        if (!Array.isArray(t)) throw new Error("Cardano UTXO response is not an array");
        return t.map((e, n)=>{
            if (!e || typeof e != "object") throw new Error(`Cardano UTXO[${n}] is invalid`);
            const r = e, s = typeof r.tx_hash == "string" ? r.tx_hash : "";
            if (!/^[0-9a-fA-F]{64}$/.test(s)) throw new Error(`Cardano UTXO[${n}] has invalid tx_hash`);
            return {
                tx_hash: s.toLowerCase(),
                tx_index: qe(r.tx_index, `Cardano UTXO[${n}].tx_index`, 0, 65535),
                amount: Dt(r.amount, `Cardano UTXO[${n}]`)
            };
        });
    }
    function go(t) {
        if (!Array.isArray(t)) throw new Error("Cardano address transactions response is not an array");
        return t.map((e, n)=>{
            if (!e || typeof e != "object") throw new Error(`Cardano address transaction[${n}] is invalid`);
            const r = e, s = typeof r.tx_hash == "string" ? r.tx_hash : "";
            if (!/^[0-9a-fA-F]{64}$/.test(s)) throw new Error(`Cardano address transaction[${n}] has invalid tx_hash`);
            return {
                tx_hash: s.toLowerCase(),
                block_time: qe(r.block_time, `Cardano address transaction[${n}].block_time`, 1, 1e10)
            };
        });
    }
    function rn(t, e) {
        if (!Array.isArray(t)) throw new Error(`${e} is not an array`);
        return t.map((n, r)=>{
            if (!n || typeof n != "object") throw new Error(`${e}[${r}] is invalid`);
            const s = n, o = typeof s.address == "string" ? s.address : "";
            if (!o) throw new Error(`${e}[${r}].address is invalid`);
            return {
                address: o,
                amount: Dt(s.amount, `${e}[${r}]`)
            };
        });
    }
    function yo(t) {
        if (!t || typeof t != "object") throw new Error("Cardano tx UTXO response is invalid");
        const e = t;
        return {
            inputs: rn(e.inputs, "Cardano tx inputs"),
            outputs: rn(e.outputs, "Cardano tx outputs")
        };
    }
    function wo(t) {
        if (!t || typeof t != "object") throw new Error("Cardano tx response is invalid");
        return {
            fees: Be(t.fees, "Cardano tx fees")
        };
    }
    function xo(t) {
        if (!t || typeof t != "object") throw new Error("Protocol parameters response is invalid");
        const e = t, n = $e(Be(e.min_fee_a ?? e.minFeeA, "Protocol param min_fee_a"), "Protocol param min_fee_a", 1n, 10000n), r = $e(Be(e.min_fee_b ?? e.minFeeB, "Protocol param min_fee_b"), "Protocol param min_fee_b", 1n, 10000000n), s = $e(Be(e.pool_deposit ?? e.poolDeposit, "Protocol param pool_deposit"), "Protocol param pool_deposit", 0n, 10000000000n), o = $e(Be(e.key_deposit ?? e.keyDeposit, "Protocol param key_deposit"), "Protocol param key_deposit", 0n, 1000000000n), i = qe(e.max_val_size ?? e.maxValSize, "Protocol param max_val_size", 256, 1e5), c = qe(e.max_tx_size ?? e.maxTxSize, "Protocol param max_tx_size", 1024, 1e6), a = $e(Be(e.coins_per_utxo_size ?? e.coinsPerUtxoSize ?? e.coins_per_utxo_word, "Protocol param coins_per_utxo_size"), "Protocol param coins_per_utxo_size", 1n, 1000000n);
        if (BigInt(n) === 0n || BigInt(r) === 0n || BigInt(a) === 0n) throw new Error("Protocol parameters contain zero-valued fee settings");
        return {
            min_fee_a: n,
            min_fee_b: r,
            pool_deposit: s,
            key_deposit: o,
            max_val_size: i,
            max_tx_size: c,
            coins_per_utxo_size: a
        };
    }
    async function vo(t, e, n, r) {
        const s = await crypto.subtle.importKey("raw", t, "PBKDF2", !1, [
            "deriveBits"
        ]), o = await crypto.subtle.deriveBits({
            name: "PBKDF2",
            salt: e,
            iterations: n,
            hash: "SHA-512"
        }, s, r * 8);
        return new Uint8Array(o);
    }
    async function er(t) {
        const e = await vo(new Uint8Array(0), t, 4096, 96), n = e.slice(0, 32), r = e.slice(32, 64), s = e.slice(64, 96);
        return n[0] &= 248, n[31] &= 31, n[31] |= 64, {
            kL: n,
            kR: r,
            cc: s
        };
    }
    function _o(t) {
        const e = new Uint8Array(4);
        return e[0] = t & 255, e[1] = t >> 8 & 255, e[2] = t >> 16 & 255, e[3] = t >> 24 & 255, e;
    }
    function tr(t, e) {
        const n = new Uint8Array(32);
        let r = 0;
        for(let s = 0; s < 32; s++){
            const o = (t[s] || 0) + (e[s] || 0) + r;
            n[s] = o & 255, r = o >> 8;
        }
        return n;
    }
    function Ao(t, e) {
        const n = new Uint8Array(32);
        let r = 0;
        for(let s = 0; s < 28; s++){
            const o = t[s] << 3 | r;
            n[s] = o & 255, r = o >> 8;
        }
        return r && (n[28] = r), tr(n, e);
    }
    function Eo(t) {
        let e = 0n;
        for(let n = t.length - 1; n >= 0; n--)e = e << 8n | BigInt(t[n]);
        return e;
    }
    const Bo = 7237005577332262213973186563042994240857116359379907606001950938285454250989n;
    function ke(t) {
        const e = Eo(t) % Bo;
        return ds.Point.BASE.multiply(e).toBytes();
    }
    function ko(t, e) {
        const n = e >= we, r = _o(e), s = ke(t.kL);
        let o;
        n ? (o = new Uint8Array(69), o[0] = 0, o.set(t.kL, 1), o.set(t.kR, 33), o.set(r, 65)) : (o = new Uint8Array(37), o[0] = 2, o.set(s, 1), o.set(r, 33));
        const i = mt(nn, t.cc, o), c = i.slice(0, 32), a = i.slice(32, 64), u = Ao(c.slice(0, 28), t.kL), h = tr(a, t.kR);
        let f;
        n ? (f = new Uint8Array(69), f[0] = 1, f.set(t.kL, 1), f.set(t.kR, 33), f.set(r, 65)) : (f = new Uint8Array(37), f[0] = 3, f.set(s, 1), f.set(r, 33));
        const l = mt(nn, t.cc, f).slice(32, 64);
        return {
            kL: u,
            kR: h,
            cc: l
        };
    }
    function ve(t, e) {
        let n = t;
        for (const r of e){
            const s = n;
            n = ko(n, r), s !== t && (s.kL.fill(0), s.kR.fill(0), s.cc.fill(0));
        }
        return n;
    }
    function pt(t) {
        return mn(t, {
            dkLen: 28
        });
    }
    function So(t, e) {
        const n = ve(t, [
            0,
            0
        ]), r = ve(t, [
            1,
            0
        ]), s = ve(t, [
            2,
            0
        ]), o = pt(ke(n.kL)), i = pt(ke(r.kL)), c = ke(s.kL), a = pt(c), u = Qn(e), h = (l)=>{
            const d = new Uint8Array(57);
            return d[0] = u, d.set(l, 1), d.set(a, 29), Ke.encode(u === 1 ? "addr" : "addr_test", Ke.toWords(d), 1023);
        }, f = new Uint8Array(29);
        return f[0] = 224 | u, f.set(a, 1), n.kL.fill(0), n.kR.fill(0), n.cc.fill(0), r.kL.fill(0), r.kR.fill(0), r.cc.fill(0), s.kL.fill(0), s.kR.fill(0), s.cc.fill(0), c.fill(0), {
            baseAddress: h(o),
            changeAddress: h(i),
            rewardAddress: Ke.encode(u === 1 ? "stake" : "stake_test", Ke.toWords(f), 1023)
        };
    }
    at = async function(t, e = 0, n = "mainnet") {
        const r = $t(t, Fn), s = r instanceof Uint8Array ? r : new TextEncoder().encode(r), o = await er(s), i = ve(o, [
            1852 + we,
            1815 + we,
            e + we
        ]), c = So(i, n);
        return s.fill(0), o.kL.fill(0), o.kR.fill(0), o.cc.fill(0), i.kL.fill(0), i.kR.fill(0), i.cc.fill(0), c;
    };
    async function Ho(t, e = 0, n = "mainnet") {
        return (await at(t, e, n)).baseAddress;
    }
    async function Io(t, e = 0, n = "mainnet") {
        return (await at(t, e, n)).changeAddress;
    }
    async function Co(t, e = 0, n = "mainnet") {
        return (await at(t, e, n)).rewardAddress;
    }
    function be(t) {
        return t ? {
            "X-API-Key": t
        } : {};
    }
    async function Lo(t, e, n = "mainnet") {
        const r = await fetch(`${J(n)}/addresses/${encodeURIComponent(t)}`, {
            headers: be(e),
            signal: AbortSignal.timeout(15e3)
        });
        if (r.status === 404) return {
            lovelace: 0n,
            night: 0n
        };
        if (!r.ok) throw new Error(`Cardano proxy error: ${r.status} ${r.statusText}`);
        return To(await xe(r, "Cardano address response"));
    }
    const _t = new Map, sn = "cardanoTxCache:v2";
    let on = !1;
    async function Uo() {
        if (!on) {
            on = !0;
            try {
                const e = (await chrome.storage.session.get(sn))[sn];
                if (Array.isArray(e)) for (const [n, r] of e)r && (r.amount = BigInt(r.amount), r.fee && (r.fee = BigInt(r.fee))), _t.set(n, r);
            } catch  {}
        }
    }
    async function nr(t, e = [], n, r = "mainnet") {
        await Uo();
        const s = new Set(Array.from(e, (a)=>a.toLowerCase())), o = await fetch(`${J(r)}/addresses/${encodeURIComponent(t)}/transactions?order=desc&count=50&page=1`, {
            headers: be(n),
            signal: AbortSignal.timeout(15e3)
        });
        if (o.status === 404) return [];
        if (!o.ok) throw new Error(`Cardano transactions fetch failed: ${o.status} ${o.statusText}`);
        const i = go(await xe(o, "Cardano address transactions response")).filter((a)=>!s.has(a.tx_hash));
        return (await Promise.all(i.map(async (a)=>{
            const u = `${t}:${a.tx_hash}`, h = _t.get(u);
            if (h !== void 0) return h;
            const [f, l] = await Promise.all([
                fetch(`${J(r)}/txs/${a.tx_hash}/utxos`, {
                    headers: be(n),
                    signal: AbortSignal.timeout(15e3)
                }),
                fetch(`${J(r)}/txs/${a.tx_hash}`, {
                    headers: be(n),
                    signal: AbortSignal.timeout(15e3)
                })
            ]);
            if (!f.ok) throw new Error(`Cardano tx UTXO fetch failed: ${f.status} ${f.statusText}`);
            if (!l.ok) throw new Error(`Cardano tx fetch failed: ${l.status} ${l.statusText}`);
            const d = yo(await xe(f, "Cardano tx UTXO response")), p = wo(await xe(l, "Cardano tx response")), m = d.inputs.some((N)=>N.address === t), w = m;
            let y = 0n, _ = 0n, b = 0n, E = 0n;
            if (m) {
                for (const N of d.inputs)if (N.address === t) for (const L of N.amount)L.unit === "lovelace" ? y += BigInt(L.quantity) : L.unit === tt && (_ += BigInt(L.quantity));
            }
            for (const N of d.outputs)if (N.address === t) for (const L of N.amount)L.unit === "lovelace" ? b += BigInt(L.quantity) : L.unit === tt && (E += BigInt(L.quantity));
            let B = 0n, I = 0n;
            for (const N of d.inputs)for (const L of N.amount)L.unit === "lovelace" && (B += BigInt(L.quantity));
            for (const N of d.outputs)for (const L of N.amount)L.unit === "lovelace" && (I += BigInt(L.quantity));
            const C = B - I, k = BigInt(p.fees), g = k > 0n ? k : C > 0n ? C : 0n, v = E - _, A = b - y + (w ? g : 0n), S = v > 0n ? "receive" : v < 0n ? "send" : null, $ = A > 0n ? "receive" : A < 0n ? "send" : null, U = v < 0n ? -v : v, T = A < 0n ? -A : A;
            let R = null;
            return d.outputs.some((N)=>N.amount.some((L)=>L.unit !== "lovelace" && L.unit.startsWith(Yn))) ? R = {
                txHash: a.tx_hash,
                timestamp: a.block_time * 1e3,
                tokenType: "cNIGHT",
                amount: U > 0n ? U : 0n,
                direction: "dust_generation",
                ...g > 0n ? {
                    fee: g
                } : {}
            } : U > 0n && S ? R = {
                txHash: a.tx_hash,
                timestamp: a.block_time * 1e3,
                tokenType: "cNIGHT",
                amount: U,
                direction: S,
                ...g > 0n ? {
                    fee: g
                } : {}
            } : T > 0n && $ && (R = {
                txHash: a.tx_hash,
                timestamp: a.block_time * 1e3,
                tokenType: "ADA",
                amount: T,
                direction: $,
                ...g > 0n ? {
                    fee: g
                } : {}
            }), _t.set(u, R), R;
        }))).filter((a)=>a !== null);
    }
    async function $o(t, e = [], n, r = "mainnet") {
        return (await nr(t, e, n, r)).filter((o)=>o.direction !== "send").map(({ txHash: o, timestamp: i, tokenType: c, amount: a })=>({
                txHash: o,
                timestamp: i,
                tokenType: c,
                amount: a
            }));
    }
    function To(t) {
        let e = 0n, n = 0n;
        for (const r of Dt(t?.amount, "Cardano address response"))r.unit === "lovelace" ? e = BigInt(r.quantity) : r.unit === tt && (n = BigInt(r.quantity));
        return {
            lovelace: e,
            night: n
        };
    }
    function rr(t, e = 4) {
        if (t < 9007199254740992n) return (Number(t) / 1e6).toFixed(e);
        const n = t / 1000000n, r = t % 1000000n;
        if (e === 0) return n.toString();
        const s = r.toString().padStart(6, "0").slice(0, e);
        return `${n.toString()}.${s}`;
    }
    function No(t, e = 4) {
        return rr(t, e);
    }
    Ro = function(t, e = 4) {
        return rr(t, e);
    };
    function nt(t, e, n) {
        if (!e || !e.startsWith("addr1") && !e.startsWith("addr_test1")) throw new Error(`Invalid ${n} — must start with addr1 (mainnet) or addr_test1 (testnet)`);
        try {
            t.Address.from_bech32(e);
        } catch  {
            throw new Error(`Invalid ${n} — failed bech32 checksum validation`);
        }
    }
    zt = async function(t, e, n = "mainnet") {
        const r = await fetch(`${J(n)}/addresses/${encodeURIComponent(t)}/utxos`, {
            headers: be(e),
            signal: AbortSignal.timeout(15e3)
        });
        if (r.status === 404) throw new Error("Cardano sender address was not found");
        if (!r.ok) throw new Error(`Cardano UTXO fetch failed: ${r.status}`);
        return mo(await xe(r, "Cardano UTXO response"));
    };
    async function Ot(t, e = "mainnet") {
        const n = await fetch(`${J(e)}/epochs/latest/parameters`, {
            headers: be(t),
            signal: AbortSignal.timeout(15e3)
        });
        if (!n.ok) throw new Error(`Failed to fetch protocol params: ${n.status}`);
        return xo(await xe(n, "Protocol parameters response"));
    }
    async function qt(t, e = "mainnet") {
        const n = await fetch(`${J(e)}/blocks/latest`, {
            headers: be(t),
            signal: AbortSignal.timeout(15e3)
        });
        if (!n.ok) throw new Error(`Failed to fetch current slot: ${n.status}`);
        const r = await xe(n, "Latest block response");
        return qe(r?.slot, "Current slot", 1, 1e10);
    }
    async function sr(t, e, n = "mainnet") {
        const r = new Uint8Array(t).buffer, s = await fetch(`${J(n)}/tx/submit`, {
            method: "POST",
            headers: {
                "Content-Type": "application/cbor",
                ...be(e)
            },
            signal: AbortSignal.timeout(3e4),
            body: r
        });
        if (!s.ok) {
            const i = await s.text().catch(()=>"");
            throw new Error(`Tx submit failed: ${s.status} ${i}`);
        }
        const o = await s.text();
        try {
            const i = JSON.parse(o);
            return typeof i == "string" ? i : String(i);
        } catch  {
            const i = o.trim();
            if (!i) throw new Error("Tx submit succeeded but returned an empty body");
            return i;
        }
    }
    Do = async function(t, e, n = "mainnet") {
        return sr(V(t), e, n);
    };
    or = async function(t, e = 0) {
        const n = $t(t, Fn), r = n instanceof Uint8Array ? n : new TextEncoder().encode(n), s = await er(r), o = ve(s, [
            1852 + we,
            1815 + we,
            e + we
        ]), i = ve(o, [
            0,
            0
        ]), c = ve(o, [
            2,
            0
        ]), a = new Uint8Array(64);
        a.set(i.kL, 0), a.set(i.kR, 32);
        const u = new Uint8Array(64);
        u.set(c.kL, 0), u.set(c.kR, 32);
        const h = ke(i.kL), f = ke(c.kL);
        return r.fill(0), s.kL.fill(0), s.kR.fill(0), s.cc.fill(0), o.kL.fill(0), o.kR.fill(0), o.cc.fill(0), i.kL.fill(0), i.kR.fill(0), i.cc.fill(0), c.kL.fill(0), c.kR.fill(0), c.cc.fill(0), {
            paymentExtendedPrivateKey: a,
            paymentPublicKey: h,
            stakeExtendedPrivateKey: u,
            stakePublicKey: f
        };
    };
    async function ir(t, e = 0) {
        const { paymentExtendedPrivateKey: n, paymentPublicKey: r } = await or(t, e);
        return {
            extendedPrivateKey: n,
            publicKey: r
        };
    }
    const zo = [
        /required minimum ada for change output/i,
        /not enough funds to cover the required assets:\s*\{[^}]*lovelace/i
    ], Oo = [
        /all inputs are spent/i,
        /transaction has probably already been included/i
    ];
    function qo(t) {
        return zo.some((e)=>e.test(t)) ? "You may have ADA in your wallet, but not enough usable ADA in the right UTXOs to cover Cardano minimum output and fees. Try sending some ADA from this wallet back to the same wallet address, wait for confirmation, and then try again." : Oo.every((e)=>e.test(t)) ? "Your previous Cardano transaction is still settling. Please wait a bit and try again." : t;
    }
    jo = async function(t) {
        const e = await an(()=>import("./cardano_serialization_lib-BCNxyBHd.js").then(async (m)=>{
                await m.__tla;
                return m;
            }), __vite__mapDeps([0,1])), { fromAddress: n, toAddress: r, nightAmount: s, adaAmount: o, adaOnly: i, network: c = "mainnet" } = t;
        if (s < 0n) throw new Error("cNIGHT amount cannot be negative");
        if (o != null && o < 0n) throw new Error("ADA amount cannot be negative");
        if (!i && s === 0n) throw new Error("cNIGHT amount must be greater than zero");
        if (nt(e, n, "Cardano sender address"), nt(e, r, "Cardano recipient address"), n.startsWith("addr1") !== r.startsWith("addr1")) throw new Error("Sender and recipient Cardano addresses must be on the same network");
        const [a, u, h] = await Promise.all([
            zt(n, void 0, c),
            Ot(void 0, c),
            qt(void 0, c)
        ]);
        if (a.length === 0) throw new Error("No UTXOs found — wallet has no funds");
        const f = [], l = (d)=>(f.push(d), d);
        try {
            const d = l(e.Address.from_bech32(n)), p = l(e.Address.from_bech32(r)), m = l(e.TransactionBuilder.new(e.TransactionBuilderConfigBuilder.new().fee_algo(e.LinearFee.new(e.BigNum.from_str(u.min_fee_a), e.BigNum.from_str(u.min_fee_b))).pool_deposit(e.BigNum.from_str(u.pool_deposit)).key_deposit(e.BigNum.from_str(u.key_deposit)).max_value_size(u.max_val_size).max_tx_size(u.max_tx_size).coins_per_utxo_byte(e.BigNum.from_str(u.coins_per_utxo_size)).build()));
            for (const b of a){
                const E = e.TransactionInput.new(e.TransactionHash.from_bytes(V(b.tx_hash)), b.tx_index), B = e.Value.new(e.BigNum.from_str("0"));
                let I = "0";
                const C = e.MultiAsset.new();
                for (const k of b.amount)if (k.unit === "lovelace") I = k.quantity;
                else {
                    const g = k.unit.slice(0, 56), v = k.unit.slice(56), A = e.ScriptHash.from_bytes(V(g));
                    let S = C.get(A);
                    S || (S = e.Assets.new()), S.insert(e.AssetName.new(V(v)), e.BigNum.from_str(k.quantity)), C.insert(A, S);
                }
                B.set_coin(e.BigNum.from_str(I)), C.len() > 0 && B.set_multiasset(C), m.add_regular_input(d, E, B);
            }
            let w;
            if (i && o) w = e.Value.new(e.BigNum.from_str(o.toString()));
            else {
                const b = e.MultiAsset.new(), E = e.Assets.new();
                E.insert(e.AssetName.new(V(it)), e.BigNum.from_str(s.toString())), b.insert(e.ScriptHash.from_bytes(V(ot)), E), w = e.Value.new(e.BigNum.from_str(o?.toString() || "0")), w.set_multiasset(b);
                const B = e.DataCost.new_coins_per_byte(e.BigNum.from_str(u.coins_per_utxo_size)), I = e.min_ada_for_output(e.TransactionOutput.new(p, w), B), C = o && o > BigInt(I.to_str()) ? o : BigInt(I.to_str());
                w.set_coin(e.BigNum.from_str(C.toString()));
            }
            m.add_output(e.TransactionOutput.new(p, w)), m.set_ttl(h + 1800), m.add_change_if_needed(d);
            const y = l(m.build()), _ = l(y.fee());
            return BigInt(_.to_str());
        } finally{
            for (const d of f)try {
                d.free();
            } catch  {}
        }
    };
    async function Ko(t) {
        const e = await an(()=>import("./cardano_serialization_lib-BCNxyBHd.js").then(async (m)=>{
                await m.__tla;
                return m;
            }), __vite__mapDeps([0,1]));
        let { mnemonic: n, fromAddress: r, toAddress: s, nightAmount: o, adaAmount: i, adaOnly: c, signingKeys: a, accountIndex: u, network: h = "mainnet" } = t;
        if (o < 0n) throw new Error("cNIGHT amount cannot be negative");
        if (i != null && i < 0n) throw new Error("ADA amount cannot be negative");
        if (!c && o === 0n) throw new Error("cNIGHT amount must be greater than zero");
        if (!a && !n) throw new Error("Either signingKeys or mnemonic must be provided");
        if (nt(e, r, "Cardano sender address"), nt(e, s, "Cardano recipient address"), r.startsWith("addr1") !== s.startsWith("addr1")) throw new Error("Sender and recipient Cardano addresses must be on the same network");
        const f = a ? Promise.resolve({
            extendedPrivateKey: new Uint8Array(a.paymentExtendedPrivateKey),
            publicKey: a.paymentPublicKey
        }) : ir(n, u), [{ extendedPrivateKey: l }, d, p, m] = await Promise.all([
            f,
            zt(r, void 0, h),
            Ot(void 0, h),
            qt(void 0, h)
        ]);
        if (n = "", d.length === 0) throw new Error("No UTXOs found — wallet has no funds");
        let w = null;
        const y = [], _ = (b)=>(y.push(b), b);
        try {
            w = _(e.PrivateKey.from_extended_bytes(l));
            const b = _(e.TransactionBuilder.new(e.TransactionBuilderConfigBuilder.new().fee_algo(e.LinearFee.new(e.BigNum.from_str(p.min_fee_a), e.BigNum.from_str(p.min_fee_b))).pool_deposit(e.BigNum.from_str(p.pool_deposit)).key_deposit(e.BigNum.from_str(p.key_deposit)).max_value_size(p.max_val_size).max_tx_size(p.max_tx_size).coins_per_utxo_byte(e.BigNum.from_str(p.coins_per_utxo_size)).build())), E = _(w.to_public().hash());
            for (const T of d){
                const R = e.TransactionInput.new(e.TransactionHash.from_bytes(V(T.tx_hash)), T.tx_index), K = e.Value.new(e.BigNum.from_str("0"));
                let N = "0";
                const L = e.MultiAsset.new();
                for (const G of T.amount)if (G.unit === "lovelace") N = G.quantity;
                else {
                    const _e = G.unit.slice(0, 56), Ce = G.unit.slice(56), Le = e.ScriptHash.from_bytes(V(_e));
                    let Ue = L.get(Le);
                    Ue || (Ue = e.Assets.new()), Ue.insert(e.AssetName.new(V(Ce)), e.BigNum.from_str(G.quantity)), L.insert(Le, Ue);
                }
                K.set_coin(e.BigNum.from_str(N)), L.len() > 0 && K.set_multiasset(L), b.add_key_input(E, R, K);
            }
            let B;
            if (c && i) B = e.Value.new(e.BigNum.from_str(i.toString()));
            else {
                const T = e.MultiAsset.new(), R = e.Assets.new();
                R.insert(e.AssetName.new(V(it)), e.BigNum.from_str(o.toString())), T.insert(e.ScriptHash.from_bytes(V(ot)), R), B = e.Value.new(e.BigNum.from_str(i?.toString() || "0")), B.set_multiasset(T);
                const K = e.DataCost.new_coins_per_byte(e.BigNum.from_str(p.coins_per_utxo_size)), N = e.min_ada_for_output(e.TransactionOutput.new(e.Address.from_bech32(s), B), K), L = i && i > BigInt(N.to_str()) ? i : BigInt(N.to_str());
                B.set_coin(e.BigNum.from_str(L.toString()));
            }
            b.add_output(e.TransactionOutput.new(e.Address.from_bech32(s), B)), b.set_ttl(m + 1800), b.add_change_if_needed(e.Address.from_bech32(r));
            const I = _(b.build()), C = I.to_bytes(), k = mn(C, {
                dkLen: 32
            }), g = _(e.TransactionHash.from_bytes(k)), v = _(e.TransactionWitnessSet.new()), A = _(e.Vkeywitnesses.new());
            A.add(e.make_vkey_witness(g, w)), v.set_vkeys(A);
            const $ = _(e.Transaction.new(I, v)).to_bytes();
            return {
                txHash: await sr($, void 0, h)
            };
        } finally{
            l.fill(0);
            for (const b of y)try {
                b.free();
            } catch  {}
        }
    }
    function V(t) {
        if (t.length % 2 !== 0) throw new Error("Hex string must have an even number of characters");
        if (!/^[0-9a-fA-F]*$/.test(t)) throw new Error("Hex string contains invalid characters");
        const e = new Uint8Array(t.length / 2);
        for(let n = 0; n < t.length; n += 2)e[n / 2] = parseInt(t.substring(n, n + 2), 16);
        return e;
    }
    hi = Object.freeze(Object.defineProperty({
        __proto__: null,
        CARDANO_PROXY_URL: bo,
        DUST_REGISTRATION_POLICY_ID: Yn,
        NIGHT_ASSET_ID: tt,
        NIGHT_ASSET_NAME_HEX: it,
        NIGHT_POLICY_ID: ot,
        deriveCardanoAddress: Ho,
        deriveCardanoAddresses: at,
        deriveCardanoChangeAddress: Io,
        deriveCardanoRewardAddress: Co,
        deriveCardanoSigningKey: ir,
        deriveCardanoSigningKeys: or,
        estimateCardanoTransactionFee: jo,
        fetchCardanoCurrentSlot: qt,
        fetchCardanoNightBalance: Lo,
        fetchCardanoProtocolParams: Ot,
        fetchCardanoUtxos: zt,
        fetchRecentCardanoIncomingTransactions: $o,
        fetchRecentCardanoTransactions: nr,
        formatAda: Ro,
        formatCardanoNight: No,
        getCardanoCipNetworkId: Qn,
        getCardanoProxyUrl: J,
        normalizeCardanoSendErrorMessage: qo,
        sendCardanoTransaction: Ko,
        submitCardanoTxHex: Do
    }, Symbol.toStringTag, {
        value: "Module"
    }));
})();
export { Oe as $, rt as A, Tr as B, Vt as C, Qo as D, X as E, je as F, hn as G, Et as H, Se as I, Fe as J, Ee as K, He as L, pe as M, me as N, cn as O, Q as P, Fo as Q, Zo as R, Yo as S, Xo as T, gr as U, ui as V, ci as W, ai as X, fi as Y, li as Z, Yr as _, Ct as a, fo as a0, di as a1, oi as a2, Ro as a3, jo as a4, pn as a5, Go as a6, yn as a7, ct as a8, fr as a9, bo as aa, tt as ab, at as ac, or as ad, Do as ae, Qn as af, zt as ag, hi as ah, mn as b, Xr as c, ar as d, bt as e, vn as f, It as g, mt as h, yt as i, Ze as j, ue as k, Ge as l, si as m, Gr as n, At as o, Fr as p, Pr as q, dr as r, dn as s, ni as t, Zt as u, ii as v, Fn as w, Yt as x, ri as y, ti as z, __tla };
