@omnisat/lasereyes
Version:
Simplifies wallet interactions across various Bitcoin wallets, making it easy for developers to build dApps with Bitcoin support
1,752 lines (1,751 loc) • 5.01 MB
JavaScript
"use client";
import { createContext as $ve, useContext as Mve, useCallback as da, useMemo as A9, useState as qoe, useEffect as Woe } from "react";
import { jsx as We, jsxs as Pn } from "react/jsx-runtime";
var Rve = Object.defineProperty, Cve = (e, t, r) => t in e ? Rve(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, Wt = (e, t, r) => Cve(e, typeof t != "symbol" ? t + "" : t, r);
function Nve(e, t) {
for (var r = 0; r < t.length; r++) {
const n = t[r];
if (typeof n != "string" && !Array.isArray(n)) {
for (const i in n)
if (i !== "default" && !(i in e)) {
const o = Object.getOwnPropertyDescriptor(n, i);
o && Object.defineProperty(e, i, o.get ? o : {
enumerable: !0,
get: () => n[i]
});
}
}
}
return Object.freeze(Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }));
}
function Uve(e) {
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
var Voe = { exports: {} }, $o = Voe.exports = {}, zf, Lf;
function BF() {
throw new Error("setTimeout has not been defined");
}
function OF() {
throw new Error("clearTimeout has not been defined");
}
(function() {
try {
typeof setTimeout == "function" ? zf = setTimeout : zf = BF;
} catch {
zf = BF;
}
try {
typeof clearTimeout == "function" ? Lf = clearTimeout : Lf = OF;
} catch {
Lf = OF;
}
})();
function Goe(e) {
if (zf === setTimeout)
return setTimeout(e, 0);
if ((zf === BF || !zf) && setTimeout)
return zf = setTimeout, setTimeout(e, 0);
try {
return zf(e, 0);
} catch {
try {
return zf.call(null, e, 0);
} catch {
return zf.call(this, e, 0);
}
}
}
function jve(e) {
if (Lf === clearTimeout)
return clearTimeout(e);
if ((Lf === OF || !Lf) && clearTimeout)
return Lf = clearTimeout, clearTimeout(e);
try {
return Lf(e);
} catch {
try {
return Lf.call(null, e);
} catch {
return Lf.call(this, e);
}
}
}
var jd = [], b2 = !1, Ng, I9 = -1;
function Fve() {
!b2 || !Ng || (b2 = !1, Ng.length ? jd = Ng.concat(jd) : I9 = -1, jd.length && Zoe());
}
function Zoe() {
if (!b2) {
var e = Goe(Fve);
b2 = !0;
for (var t = jd.length; t; ) {
for (Ng = jd, jd = []; ++I9 < t; )
Ng && Ng[I9].run();
I9 = -1, t = jd.length;
}
Ng = null, b2 = !1, jve(e);
}
}
$o.nextTick = function(e) {
var t = new Array(arguments.length - 1);
if (arguments.length > 1)
for (var r = 1; r < arguments.length; r++)
t[r - 1] = arguments[r];
jd.push(new Xoe(e, t)), jd.length === 1 && !b2 && Goe(Zoe);
};
function Xoe(e, t) {
this.fun = e, this.array = t;
}
Xoe.prototype.run = function() {
this.fun.apply(null, this.array);
};
$o.title = "browser";
$o.browser = !0;
$o.env = {};
$o.argv = [];
$o.version = "";
$o.versions = {};
function rp() {
}
$o.on = rp;
$o.addListener = rp;
$o.once = rp;
$o.off = rp;
$o.removeListener = rp;
$o.removeAllListeners = rp;
$o.emit = rp;
$o.prependListener = rp;
$o.prependOnceListener = rp;
$o.listeners = function(e) {
return [];
};
$o.binding = function(e) {
throw new Error("process.binding is not supported");
};
$o.cwd = function() {
return "/";
};
$o.chdir = function(e) {
throw new Error("process.chdir is not supported");
};
$o.umask = function() {
return 0;
};
var zve = Voe.exports;
const Zi = /* @__PURE__ */ Uve(zve);
let PF = Symbol("clean"), wl = [], pp = 0;
const j5 = 4;
let $F = (e) => {
let t = [], r = {
get() {
return r.lc || r.listen(() => {
})(), r.value;
},
lc: 0,
listen(n) {
return r.lc = t.push(n), () => {
for (let o = pp + j5; o < wl.length; )
wl[o] === n ? wl.splice(o, j5) : o += j5;
let i = t.indexOf(n);
~i && (t.splice(i, 1), --r.lc || r.off());
};
},
notify(n, i) {
let o = !wl.length;
for (let a of t)
wl.push(
a,
r.value,
n,
i
);
if (o) {
for (pp = 0; pp < wl.length; pp += j5)
wl[pp](
wl[pp + 1],
wl[pp + 2],
wl[pp + 3]
);
wl.length = 0;
}
},
/* It will be called on last listener unsubscribing.
We will redefine it in onMount and onStop. */
off() {
},
set(n) {
let i = r.value;
i !== n && (r.value = n, r.notify(i));
},
subscribe(n) {
let i = r.listen(n);
return n(r.value), i;
},
value: e
};
return Zi.env.NODE_ENV !== "production" && (r[PF] = () => {
t = [], r.lc = 0, r.off();
}), r;
};
const Lve = 5, sy = 6, F5 = 10;
let Dve = (e, t, r, n) => (e.events = e.events || {}, e.events[r + F5] || (e.events[r + F5] = n((i) => {
e.events[r].reduceRight((o, a) => (a(o), o), {
shared: {},
...i
});
})), e.events[r] = e.events[r] || [], e.events[r].push(t), () => {
let i = e.events[r], o = i.indexOf(t);
i.splice(o, 1), i.length || (delete e.events[r], e.events[r + F5](), delete e.events[r + F5]);
}), Hve = 1e3, Kve = (e, t) => Dve(e, (r) => {
let n = t(r);
n && e.events[sy].push(n);
}, Lve, (r) => {
let n = e.listen;
e.listen = (...o) => (!e.lc && !e.active && (e.active = !0, r()), n(...o));
let i = e.off;
if (e.events[sy] = [], e.off = () => {
i(), setTimeout(() => {
if (e.active && !e.lc) {
e.active = !1;
for (let o of e.events[sy]) o();
e.events[sy] = [];
}
}, Hve);
}, Zi.env.NODE_ENV !== "production") {
let o = e[PF];
e[PF] = () => {
for (let a of e.events[sy]) a();
e.events[sy] = [], e.active = !1, o();
};
}
return () => {
e.listen = n, e.off = i;
};
}), qve = (e) => {
e.listen(() => {
});
};
function Ql(e, t, r) {
let n = new Set(t).add(void 0);
return e.listen((i, o, a) => {
n.has(a) && r(i, o, a);
});
}
let Yoe = (e = {}) => {
let t = $F(e);
return t.setKey = function(r, n) {
let i = t.value;
typeof n > "u" && r in t.value ? (t.value = { ...t.value }, delete t.value[r], t.notify(i, r)) : t.value[r] !== n && (t.value = {
...t.value,
[r]: n
}, t.notify(i, r));
}, t;
};
const r2 = "oyl", n2 = "unisat", i2 = "xverse", Bg = "phantom", k8 = "leather", d0 = "magic-eden", A8 = "okx", o2 = "wizz", Og = "orange", Pg = "op_net", a2 = "sparrow", D2 = "p2tr", Wve = "p2pkh", Vve = "p2sh-p2wpkh", MF = "p2wpkh", ayt = "p2psh", Gve = "p2wsh", b6 = "p2sh", syt = {
leather: {
name: "leather",
url: "https://leather.io/install-extension"
},
"magic-eden": {
name: "magic-eden",
url: "https://wallet.magiceden.io/"
},
okx: {
name: "okx",
url: "https://chromewebstore.google.com/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge"
},
op_net: {
name: "op_net",
url: "https://opnet.org/"
},
orange: {
name: "orange",
url: "https://www.orangewallet.com/"
},
oyl: {
name: "oyl",
url: "https://www.oyl.io/#get-wallet"
},
phantom: {
name: "phantom",
url: "https://phantom.app/download"
},
sparrow: {
name: "sparrow",
url: "https://sparrowwallet.com/"
},
unisat: {
name: "unisat",
url: "https://unisat.io/download"
},
wizz: {
name: "wizz",
url: "https://wizzwallet.io/#extension"
},
xverse: {
name: "xverse",
url: "https://www.xverse.app/download"
}
}, EM = "defaultWallet", ef = {
/**
* The message prefix used for signing Bitcoin messages.
*/
messagePrefix: `Bitcoin Signed Message:
`,
/**
* The Bech32 prefix used for Bitcoin addresses.
*/
bech32: "bc",
/**
* The BIP32 key prefixes for Bitcoin.
*/
bip32: {
/**
* The public key prefix for BIP32 extended public keys.
*/
public: 76067358,
/**
* The private key prefix for BIP32 extended private keys.
*/
private: 76066276
},
/**
* The prefix for Bitcoin public key hashes.
*/
pubKeyHash: 0,
/**
* The prefix for Bitcoin script hashes.
*/
scriptHash: 5,
/**
* The prefix for Bitcoin Wallet Import Format (WIF) private keys.
*/
wif: 128
}, Zve = {
messagePrefix: `Bitcoin Signed Message:
`,
bech32: "tb",
bip32: {
public: 70617039,
private: 70615956
},
pubKeyHash: 111,
scriptHash: 196,
wif: 239
};
function Xve(e) {
if (e.length < 8 || e.length > 72 || e[0] !== 48 || e[1] !== e.length - 2 || e[2] !== 2) return !1;
const t = e[3];
if (t === 0 || 5 + t >= e.length || e[4 + t] !== 2) return !1;
const r = e[5 + t];
return !(r === 0 || 6 + t + r !== e.length || e[4] & 128 || t > 1 && e[4] === 0 && !(e[5] & 128) || e[t + 6] & 128 || r > 1 && e[t + 6] === 0 && !(e[t + 7] & 128));
}
function Yve(e) {
if (e.length < 8) throw new Error("DER sequence length is too short");
if (e.length > 72) throw new Error("DER sequence length is too long");
if (e[0] !== 48) throw new Error("Expected DER sequence");
if (e[1] !== e.length - 2)
throw new Error("DER sequence length is invalid");
if (e[2] !== 2) throw new Error("Expected DER integer");
const t = e[3];
if (t === 0) throw new Error("R length is zero");
if (5 + t >= e.length) throw new Error("R length is too long");
if (e[4 + t] !== 2) throw new Error("Expected DER integer (2)");
const r = e[5 + t];
if (r === 0) throw new Error("S length is zero");
if (6 + t + r !== e.length) throw new Error("S length is invalid");
if (e[4] & 128) throw new Error("R value is negative");
if (t > 1 && e[4] === 0 && !(e[5] & 128))
throw new Error("R value excessively padded");
if (e[t + 6] & 128) throw new Error("S value is negative");
if (r > 1 && e[t + 6] === 0 && !(e[t + 7] & 128))
throw new Error("S value excessively padded");
return {
r: e.slice(4, 4 + t),
s: e.slice(6 + t)
};
}
function Jve(e, t) {
const r = e.length, n = t.length;
if (r === 0) throw new Error("R length is zero");
if (n === 0) throw new Error("S length is zero");
if (r > 33) throw new Error("R length is too long");
if (n > 33) throw new Error("S length is too long");
if (e[0] & 128) throw new Error("R value is negative");
if (t[0] & 128) throw new Error("S value is negative");
if (r > 1 && e[0] === 0 && !(e[1] & 128))
throw new Error("R value excessively padded");
if (n > 1 && t[0] === 0 && !(t[1] & 128))
throw new Error("S value excessively padded");
const i = new Uint8Array(6 + r + n);
return i[0] = 48, i[1] = i.length - 2, i[2] = 2, i[3] = e.length, i.set(e, 4), i[4 + r] = 2, i[5 + r] = t.length, i.set(t, 6 + r), i;
}
const $n = {
OP_FALSE: 0,
OP_0: 0,
OP_PUSHDATA1: 76,
OP_PUSHDATA2: 77,
OP_PUSHDATA4: 78,
OP_1NEGATE: 79,
OP_RESERVED: 80,
OP_TRUE: 81,
OP_1: 81,
OP_2: 82,
OP_3: 83,
OP_4: 84,
OP_5: 85,
OP_6: 86,
OP_7: 87,
OP_8: 88,
OP_9: 89,
OP_10: 90,
OP_11: 91,
OP_12: 92,
OP_13: 93,
OP_14: 94,
OP_15: 95,
OP_16: 96,
OP_NOP: 97,
OP_VER: 98,
OP_IF: 99,
OP_NOTIF: 100,
OP_VERIF: 101,
OP_VERNOTIF: 102,
OP_ELSE: 103,
OP_ENDIF: 104,
OP_VERIFY: 105,
OP_RETURN: 106,
OP_TOALTSTACK: 107,
OP_FROMALTSTACK: 108,
OP_2DROP: 109,
OP_2DUP: 110,
OP_3DUP: 111,
OP_2OVER: 112,
OP_2ROT: 113,
OP_2SWAP: 114,
OP_IFDUP: 115,
OP_DEPTH: 116,
OP_DROP: 117,
OP_DUP: 118,
OP_NIP: 119,
OP_OVER: 120,
OP_PICK: 121,
OP_ROLL: 122,
OP_ROT: 123,
OP_SWAP: 124,
OP_TUCK: 125,
OP_CAT: 126,
OP_SUBSTR: 127,
OP_LEFT: 128,
OP_RIGHT: 129,
OP_SIZE: 130,
OP_INVERT: 131,
OP_AND: 132,
OP_OR: 133,
OP_XOR: 134,
OP_EQUAL: 135,
OP_EQUALVERIFY: 136,
OP_RESERVED1: 137,
OP_RESERVED2: 138,
OP_1ADD: 139,
OP_1SUB: 140,
OP_2MUL: 141,
OP_2DIV: 142,
OP_NEGATE: 143,
OP_ABS: 144,
OP_NOT: 145,
OP_0NOTEQUAL: 146,
OP_ADD: 147,
OP_SUB: 148,
OP_MUL: 149,
OP_DIV: 150,
OP_MOD: 151,
OP_LSHIFT: 152,
OP_RSHIFT: 153,
OP_BOOLAND: 154,
OP_BOOLOR: 155,
OP_NUMEQUAL: 156,
OP_NUMEQUALVERIFY: 157,
OP_NUMNOTEQUAL: 158,
OP_LESSTHAN: 159,
OP_GREATERTHAN: 160,
OP_LESSTHANOREQUAL: 161,
OP_GREATERTHANOREQUAL: 162,
OP_MIN: 163,
OP_MAX: 164,
OP_WITHIN: 165,
OP_RIPEMD160: 166,
OP_SHA1: 167,
OP_SHA256: 168,
OP_HASH160: 169,
OP_HASH256: 170,
OP_CODESEPARATOR: 171,
OP_CHECKSIG: 172,
OP_CHECKSIGVERIFY: 173,
OP_CHECKMULTISIG: 174,
OP_CHECKMULTISIGVERIFY: 175,
OP_NOP1: 176,
OP_NOP2: 177,
OP_CHECKLOCKTIMEVERIFY: 177,
OP_NOP3: 178,
OP_CHECKSEQUENCEVERIFY: 178,
OP_NOP4: 179,
OP_NOP5: 180,
OP_NOP6: 181,
OP_NOP7: 182,
OP_NOP8: 183,
OP_NOP9: 184,
OP_NOP10: 185,
OP_CHECKSIGADD: 186,
OP_PUBKEYHASH: 253,
OP_PUBKEY: 254,
OP_INVALIDOPCODE: 255
}, Joe = {};
for (const e of Object.keys($n)) {
const t = $n[e];
Joe[t] = e;
}
const aE = "0123456789abcdefABCDEF", sE = aE.split("").map((e) => e.codePointAt(0)), uE = Array(256).fill(!0).map((e, t) => {
const r = String.fromCodePoint(t), n = aE.indexOf(r);
return n < 0 ? void 0 : n < 16 ? n : n - 6;
}), Qoe = new TextEncoder(), eae = new TextDecoder();
function Qve(e) {
return eae.decode(e);
}
function e3e(e) {
return Qoe.encode(e);
}
function ho(e) {
const t = e.reduce((i, o) => i + o.length, 0), r = new Uint8Array(t);
let n = 0;
for (const i of e)
r.set(i, n), n += i.length;
return r;
}
function Mr(e) {
const t = e || new Uint8Array();
return t.length > 512 ? r3e(t) : t3e(t);
}
function t3e(e) {
let t = "";
for (let r = 0; r < e.length; ++r)
t += aE[uE[sE[e[r] >> 4]]], t += aE[uE[sE[e[r] & 15]]];
return t;
}
function r3e(e) {
const t = new Uint8Array(e.length * 2);
for (let r = 0; r < e.length; ++r)
t[r * 2] = sE[e[r] >> 4], t[r * 2 + 1] = sE[e[r] & 15];
return eae.decode(t);
}
function np(e) {
const t = Qoe.encode(e || ""), r = new Uint8Array(Math.floor(t.length / 2));
let n;
for (n = 0; n < r.length; n++) {
const i = uE[t[n * 2]], o = uE[t[n * 2 + 1]];
if (i === void 0 || o === void 0)
break;
r[n] = i << 4 | o;
}
return n === r.length ? r : r.slice(0, n);
}
function n3e(e) {
return btoa(String.fromCharCode(...e));
}
function tae(e) {
const t = atob(e), r = new Uint8Array(t.length);
for (let n = 0; n < t.length; n++)
r[n] = t.charCodeAt(n);
return r;
}
function rr(e, t) {
const r = Math.min(e.length, t.length);
for (let n = 0; n < r; ++n)
if (e[n] !== t[n])
return e[n] < t[n] ? -1 : 1;
return e.length === t.length ? 0 : e.length > t.length ? 1 : -1;
}
function oc(e, t, r) {
if (t + 1 > e.length)
throw new Error("Offset is outside the bounds of Uint8Array");
if (r > 255)
throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 255. Received ${r}`);
return e[t] = r, t + 1;
}
function i3e(e, t, r, n) {
if (t + 2 > e.length)
throw new Error("Offset is outside the bounds of Uint8Array");
if (n = n.toUpperCase(), r > 65535)
throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${r}`);
return n === "LE" ? (e[t] = r & 255, e[t + 1] = r >> 8 & 255) : (e[t] = r >> 8 & 255, e[t + 1] = r & 255), t + 2;
}
function y6(e, t, r, n) {
if (t + 4 > e.length)
throw new Error("Offset is outside the bounds of Uint8Array");
if (n = n.toUpperCase(), r > 4294967295)
throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${4294967295}. Received ${r}`);
return n === "LE" ? (e[t] = r & 255, e[t + 1] = r >> 8 & 255, e[t + 2] = r >> 16 & 255, e[t + 3] = r >> 24 & 255) : (e[t] = r >> 24 & 255, e[t + 1] = r >> 16 & 255, e[t + 2] = r >> 8 & 255, e[t + 3] = r & 255), t + 4;
}
function o3e(e, t, r, n) {
if (t + 8 > e.length)
throw new Error("Offset is outside the bounds of Uint8Array");
if (n = n.toUpperCase(), r > 0xffffffffffffffffn)
throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${0xffffffffffffffffn}. Received ${r}`);
return n === "LE" ? (e[t] = Number(r & 0xffn), e[t + 1] = Number(r >> 8n & 0xffn), e[t + 2] = Number(r >> 16n & 0xffn), e[t + 3] = Number(r >> 24n & 0xffn), e[t + 4] = Number(r >> 32n & 0xffn), e[t + 5] = Number(r >> 40n & 0xffn), e[t + 6] = Number(r >> 48n & 0xffn), e[t + 7] = Number(r >> 56n & 0xffn)) : (e[t] = Number(r >> 56n & 0xffn), e[t + 1] = Number(r >> 48n & 0xffn), e[t + 2] = Number(r >> 40n & 0xffn), e[t + 3] = Number(r >> 32n & 0xffn), e[t + 4] = Number(r >> 24n & 0xffn), e[t + 5] = Number(r >> 16n & 0xffn), e[t + 6] = Number(r >> 8n & 0xffn), e[t + 7] = Number(r & 0xffn)), t + 8;
}
function Wd(e, t) {
if (t + 1 > e.length)
throw new Error("Offset is outside the bounds of Uint8Array");
return e[t];
}
function a3e(e, t, r) {
if (t + 2 > e.length)
throw new Error("Offset is outside the bounds of Uint8Array");
if (r = r.toUpperCase(), r === "LE") {
let n = 0;
return n = (n << 8) + e[t + 1], n = (n << 8) + e[t], n;
} else {
let n = 0;
return n = (n << 8) + e[t], n = (n << 8) + e[t + 1], n;
}
}
function Em(e, t, r) {
if (t + 4 > e.length)
throw new Error("Offset is outside the bounds of Uint8Array");
if (r = r.toUpperCase(), r === "LE") {
let n = 0;
return n = (n << 8) + e[t + 3] >>> 0, n = (n << 8) + e[t + 2] >>> 0, n = (n << 8) + e[t + 1] >>> 0, n = (n << 8) + e[t] >>> 0, n;
} else {
let n = 0;
return n = (n << 8) + e[t] >>> 0, n = (n << 8) + e[t + 1] >>> 0, n = (n << 8) + e[t + 2] >>> 0, n = (n << 8) + e[t + 3] >>> 0, n;
}
}
function rae(e, t, r, n) {
if (t + 4 > e.length)
throw new Error("Offset is outside the bounds of Uint8Array");
if (r > 2147483647 || r < -2147483648)
throw new Error(`The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received ${r}`);
return n = n.toUpperCase(), n === "LE" ? (e[t] = r & 255, e[t + 1] = r >> 8 & 255, e[t + 2] = r >> 16 & 255, e[t + 3] = r >> 24 & 255) : (e[t] = r >> 24 & 255, e[t + 1] = r >> 16 & 255, e[t + 2] = r >> 8 & 255, e[t + 3] = r & 255), t + 4;
}
function nae(e, t, r, n) {
if (t + 8 > e.length)
throw new Error("Offset is outside the bounds of Uint8Array");
if (r > 0x7fffffffffffffffn || r < -0x8000000000000000n)
throw new Error(`The value of "value" is out of range. It must be >= ${-0x8000000000000000n} and <= ${0x7fffffffffffffffn}. Received ${r}`);
return n = n.toUpperCase(), n === "LE" ? (e[t] = Number(r & 0xffn), e[t + 1] = Number(r >> 8n & 0xffn), e[t + 2] = Number(r >> 16n & 0xffn), e[t + 3] = Number(r >> 24n & 0xffn), e[t + 4] = Number(r >> 32n & 0xffn), e[t + 5] = Number(r >> 40n & 0xffn), e[t + 6] = Number(r >> 48n & 0xffn), e[t + 7] = Number(r >> 56n & 0xffn)) : (e[t] = Number(r >> 56n & 0xffn), e[t + 1] = Number(r >> 48n & 0xffn), e[t + 2] = Number(r >> 40n & 0xffn), e[t + 3] = Number(r >> 32n & 0xffn), e[t + 4] = Number(r >> 24n & 0xffn), e[t + 5] = Number(r >> 16n & 0xffn), e[t + 6] = Number(r >> 8n & 0xffn), e[t + 7] = Number(r & 0xffn)), t + 8;
}
function s3e(e, t, r) {
if (t + 4 > e.length)
throw new Error("Offset is outside the bounds of Uint8Array");
if (r = r.toUpperCase(), r === "LE") {
const n = e[t] + (e[t + 1] << 8) + (e[t + 2] << 16) + (e[t + 3] << 24 >>> 0);
return e[t + 3] <= 127 ? n : n - 4294967296;
} else {
const n = (e[t] << 24 >>> 0) + (e[t + 1] << 16) + (e[t + 2] << 8) + e[t + 3];
return e[t] <= 127 ? n : n - 4294967296;
}
}
function iae(e, t, r) {
if (t + 8 > e.length)
throw new Error("Offset is outside the bounds of Uint8Array");
r = r.toUpperCase();
let n = 0n;
if (r === "LE")
return n = (n << 8n) + BigInt(e[t + 7]), n = (n << 8n) + BigInt(e[t + 6]), n = (n << 8n) + BigInt(e[t + 5]), n = (n << 8n) + BigInt(e[t + 4]), n = (n << 8n) + BigInt(e[t + 3]), n = (n << 8n) + BigInt(e[t + 2]), n = (n << 8n) + BigInt(e[t + 1]), n = (n << 8n) + BigInt(e[t]), e[t + 7] <= 127 ? n : n - 0x10000000000000000n;
{
let i = 0n;
return i = (i << 8n) + BigInt(e[t]), i = (i << 8n) + BigInt(e[t + 1]), i = (i << 8n) + BigInt(e[t + 2]), i = (i << 8n) + BigInt(e[t + 3]), i = (i << 8n) + BigInt(e[t + 4]), i = (i << 8n) + BigInt(e[t + 5]), i = (i << 8n) + BigInt(e[t + 6]), i = (i << 8n) + BigInt(e[t + 7]), e[t] <= 127 ? i : i - 0x10000000000000000n;
}
}
function oae(e) {
return e < $n.OP_PUSHDATA1 ? 1 : e <= 255 ? 2 : e <= 65535 ? 3 : 5;
}
function u3e(e, t, r) {
const n = oae(t);
return n === 1 ? oc(e, r, t) : n === 2 ? (oc(e, r, $n.OP_PUSHDATA1), oc(e, r + 1, t)) : n === 3 ? (oc(e, r, $n.OP_PUSHDATA2), i3e(e, r + 1, t, "LE")) : (oc(e, r, $n.OP_PUSHDATA4), y6(e, r + 1, t, "LE")), n;
}
function c3e(e, t) {
const r = Wd(e, t);
let n, i;
if (r < $n.OP_PUSHDATA1)
n = r, i = 1;
else if (r === $n.OP_PUSHDATA1) {
if (t + 2 > e.length) return null;
n = Wd(e, t + 1), i = 2;
} else if (r === $n.OP_PUSHDATA2) {
if (t + 3 > e.length) return null;
n = a3e(e, t + 1, "LE"), i = 3;
} else {
if (t + 5 > e.length) return null;
if (r !== $n.OP_PUSHDATA4) throw new Error("Unexpected opcode");
n = Em(e, t + 1, "LE"), i = 5;
}
return {
opcode: r,
number: n,
size: i
};
}
function l3e(e) {
return e > 2147483647 ? 5 : e > 8388607 ? 4 : e > 32767 ? 3 : e > 127 ? 2 : e > 0 ? 1 : 0;
}
function f3e(e) {
let t = Math.abs(e);
const r = l3e(t), n = new Uint8Array(r), i = e < 0;
for (let o = 0; o < r; ++o)
oc(n, o, t & 255), t >>= 8;
return n[r - 1] & 128 ? oc(n, r - 1, i ? 128 : 0) : i && (n[r - 1] |= 128), n;
}
function h3e(e) {
return {
lang: (e == null ? void 0 : e.lang) ?? void 0,
message: e == null ? void 0 : e.message,
abortEarly: (e == null ? void 0 : e.abortEarly) ?? void 0,
abortPipeEarly: (e == null ? void 0 : e.abortPipeEarly) ?? void 0
};
}
function d3e(e, t) {
var r;
return (r = void 0) == null ? void 0 : r.get(t);
}
function e4(e) {
var t, r;
const n = typeof e;
return n === "string" ? `"${e}"` : n === "number" || n === "bigint" || n === "boolean" ? `${e}` : n === "object" || n === "function" ? (e && ((r = (t = Object.getPrototypeOf(e)) == null ? void 0 : t.constructor) == null ? void 0 : r.name)) ?? "null" : n;
}
function _s(e, t, r, n, i) {
const o = i && "input" in i ? i.input : r.value, a = (i == null ? void 0 : i.expected) ?? e.expects ?? null, s = (i == null ? void 0 : i.received) ?? e4(o), c = {
kind: e.kind,
type: e.type,
input: o,
expected: a,
received: s,
message: `Invalid ${t}: ${a ? `Expected ${a} but r` : "R"}eceived ${s}`,
// @ts-expect-error
requirement: e.requirement,
path: i == null ? void 0 : i.path,
issues: i == null ? void 0 : i.issues,
lang: n.lang,
abortEarly: n.abortEarly,
abortPipeEarly: n.abortPipeEarly
}, l = e.kind === "schema", u = (i == null ? void 0 : i.message) ?? // @ts-expect-error
e.message ?? d3e(e.reference, c.lang) ?? (l ? (c.lang, void 0) : null) ?? n.message ?? (c.lang, void 0);
u && (c.message = typeof u == "function" ? u(c) : u), l && (r.typed = !1), r.issues ? r.issues.push(c) : r.issues = [c];
}
function p3e(e, t) {
const r = [...new Set(e)];
return r.length > 1 ? `(${r.join(` ${t} `)})` : r[0] ?? "never";
}
var g3e = class extends Error {
/**
* Creates a Valibot error with useful information.
*
* @param issues The error issues.
*/
constructor(t) {
super(t[0].message), Wt(this, "issues"), this.name = "ValiError", this.issues = t;
}
};
function aae(e, t) {
return {
kind: "validation",
type: "every_item",
reference: aae,
async: !1,
expects: null,
requirement: e,
message: t,
_run(r, n) {
return r.typed && !r.value.every(this.requirement) && _s(this, "item", r, n), r;
}
};
}
function TD(e) {
return {
kind: "validation",
type: "integer",
reference: TD,
async: !1,
expects: null,
requirement: Number.isInteger,
message: e,
_run(t, r) {
return t.typed && !this.requirement(t.value) && _s(this, "integer", t, r), t;
}
};
}
function sae(e, t) {
return {
kind: "validation",
type: "length",
reference: sae,
async: !1,
expects: `${e}`,
requirement: e,
message: t,
_run(r, n) {
return r.typed && r.value.length !== this.requirement && _s(this, "length", r, n, {
received: `${r.value.length}`
}), r;
}
};
}
function g_(e, t) {
return {
kind: "validation",
type: "max_value",
reference: g_,
async: !1,
expects: `<=${e instanceof Date ? e.toJSON() : e4(e)}`,
requirement: e,
message: t,
_run(r, n) {
return r.typed && r.value > this.requirement && _s(this, "value", r, n, {
received: r.value instanceof Date ? r.value.toJSON() : e4(r.value)
}), r;
}
};
}
function b_(e, t) {
return {
kind: "validation",
type: "min_value",
reference: b_,
async: !1,
expects: `>=${e instanceof Date ? e.toJSON() : e4(e)}`,
requirement: e,
message: t,
_run(r, n) {
return r.typed && r.value < this.requirement && _s(this, "value", r, n, {
received: r.value instanceof Date ? r.value.toJSON() : e4(r.value)
}), r;
}
};
}
function uae(e, t) {
return {
kind: "validation",
type: "regex",
reference: uae,
async: !1,
expects: `${e}`,
requirement: e,
message: t,
_run(r, n) {
return r.typed && !this.requirement.test(r.value) && _s(this, "format", r, n), r;
}
};
}
function BD(e, t, r) {
return typeof e.default == "function" ? (
// @ts-expect-error
e.default(t, r)
) : (
// @ts-expect-error
e.default
);
}
function y_(e, t) {
return !e._run({ typed: !1, value: t }, { abortEarly: !0 }).issues;
}
function cae() {
return {
kind: "schema",
type: "any",
reference: cae,
expects: "any",
async: !1,
_run(e) {
return e.typed = !0, e;
}
};
}
function vu(e, t) {
return {
kind: "schema",
type: "array",
reference: vu,
expects: "Array",
async: !1,
item: e,
message: t,
_run(r, n) {
var i;
const o = r.value;
if (Array.isArray(o)) {
r.typed = !0, r.value = [];
for (let a = 0; a < o.length; a++) {
const s = o[a], c = this.item._run({ typed: !1, value: s }, n);
if (c.issues) {
const l = {
type: "array",
origin: "value",
input: o,
key: a,
value: s
};
for (const u of c.issues)
u.path ? u.path.unshift(l) : u.path = [l], (i = r.issues) == null || i.push(u);
if (r.issues || (r.issues = c.issues), n.abortEarly) {
r.typed = !1;
break;
}
}
c.typed || (r.typed = !1), r.value.push(c.value);
}
} else
_s(this, "type", r, n);
return r;
}
};
}
function lae(e) {
return {
kind: "schema",
type: "bigint",
reference: lae,
expects: "bigint",
async: !1,
message: e,
_run(t, r) {
return typeof t.value == "bigint" ? t.typed = !0 : _s(this, "type", t, r), t;
}
};
}
function Zl(e, t) {
return {
kind: "schema",
type: "custom",
reference: Zl,
expects: "unknown",
async: !1,
check: e,
message: t,
_run(r, n) {
return this.check(r.value) ? r.typed = !0 : _s(this, "type", r, n), r;
}
};
}
function m_(e, t) {
return {
kind: "schema",
type: "instance",
reference: m_,
expects: e.name,
async: !1,
class: e,
message: t,
_run(r, n) {
return r.value instanceof this.class ? r.typed = !0 : _s(this, "type", r, n), r;
}
};
}
function RF(e, ...t) {
const r = {
kind: "schema",
type: "nullable",
reference: RF,
expects: `(${e.expects} | null)`,
async: !1,
wrapped: e,
_run(n, i) {
return n.value === null && ("default" in this && (n.value = BD(
this,
n,
i
)), n.value === null) ? (n.typed = !0, n) : this.wrapped._run(n, i);
}
};
return 0 in t && (r.default = t[0]), r;
}
function fae(e, ...t) {
const r = {
kind: "schema",
type: "nullish",
reference: fae,
expects: `(${e.expects} | null | undefined)`,
async: !1,
wrapped: e,
_run(n, i) {
return (n.value === null || n.value === void 0) && ("default" in this && (n.value = BD(
this,
n,
i
)), n.value === null || n.value === void 0) ? (n.typed = !0, n) : this.wrapped._run(n, i);
}
};
return 0 in t && (r.default = t[0]), r;
}
function lu(e) {
return {
kind: "schema",
type: "number",
reference: lu,
expects: "number",
async: !1,
message: e,
_run(t, r) {
return typeof t.value == "number" && !isNaN(t.value) ? t.typed = !0 : _s(this, "type", t, r), t;
}
};
}
function zo(e, t) {
return {
kind: "schema",
type: "object",
reference: zo,
expects: "Object",
async: !1,
entries: e,
message: t,
_run(r, n) {
var i;
const o = r.value;
if (o && typeof o == "object") {
r.typed = !0, r.value = {};
for (const a in this.entries) {
const s = o[a], c = this.entries[a]._run(
{ typed: !1, value: s },
n
);
if (c.issues) {
const l = {
type: "object",
origin: "value",
input: o,
key: a,
value: s
};
for (const u of c.issues)
u.path ? u.path.unshift(l) : u.path = [l], (i = r.issues) == null || i.push(u);
if (r.issues || (r.issues = c.issues), n.abortEarly) {
r.typed = !1;
break;
}
}
c.typed || (r.typed = !1), (c.value !== void 0 || a in o) && (r.value[a] = c.value);
}
} else
_s(this, "type", r, n);
return r;
}
};
}
function cE(e, ...t) {
const r = {
kind: "schema",
type: "optional",
reference: cE,
expects: `(${e.expects} | undefined)`,
async: !1,
wrapped: e,
_run(n, i) {
return n.value === void 0 && ("default" in this && (n.value = BD(
this,
n,
i
)), n.value === void 0) ? (n.typed = !0, n) : this.wrapped._run(n, i);
}
};
return 0 in t && (r.default = t[0]), r;
}
function Pb(e) {
return {
kind: "schema",
type: "string",
reference: Pb,
expects: "string",
async: !1,
message: e,
_run(t, r) {
return typeof t.value == "string" ? t.typed = !0 : _s(this, "type", t, r), t;
}
};
}
function Df(e, t) {
return {
kind: "schema",
type: "tuple",
reference: Df,
expects: "Array",
async: !1,
items: e,
message: t,
_run(r, n) {
var i;
const o = r.value;
if (Array.isArray(o)) {
r.typed = !0, r.value = [];
for (let a = 0; a < this.items.length; a++) {
const s = o[a], c = this.items[a]._run(
{ typed: !1, value: s },
n
);
if (c.issues) {
const l = {
type: "array",
origin: "value",
input: o,
key: a,
value: s
};
for (const u of c.issues)
u.path ? u.path.unshift(l) : u.path = [l], (i = r.issues) == null || i.push(u);
if (r.issues || (r.issues = c.issues), n.abortEarly) {
r.typed = !1;
break;
}
}
c.typed || (r.typed = !1), r.value.push(c.value);
}
} else
_s(this, "type", r, n);
return r;
}
};
}
function nV(e) {
let t;
if (e)
for (const r of e)
t ? t.push(...r.issues) : t = r.issues;
return t;
}
function OD(e, t) {
return {
kind: "schema",
type: "union",
reference: OD,
expects: p3e(
e.map((r) => r.expects),
"|"
),
async: !1,
options: e,
message: t,
_run(r, n) {
let i, o, a;
for (const s of this.options) {
const c = s._run(
{ typed: !1, value: r.value },
n
);
if (c.typed)
if (c.issues)
o ? o.push(c) : o = [c];
else {
i = c;
break;
}
else
a ? a.push(c) : a = [c];
}
if (i)
return i;
if (o) {
if (o.length === 1)
return o[0];
_s(this, "type", r, n, {
issues: nV(o)
}), r.typed = !0;
} else {
if ((a == null ? void 0 : a.length) === 1)
return a[0];
_s(this, "type", r, n, {
issues: nV(a)
});
}
return r;
}
};
}
function io(e, t, r) {
const n = e._run(
{ typed: !1, value: t },
h3e(r)
);
if (n.issues)
throw new g3e(n.issues);
return n.value;
}
function B0(e, t) {
const r = {};
for (const n in e.entries)
r[n] = cE(e.entries[n]);
return { ...e, entries: r };
}
function Sm(...e) {
return {
...e[0],
pipe: e,
_run(t, r) {
for (const n of e)
if (n.kind !== "metadata") {
if (t.issues && (n.kind === "schema" || n.kind === "transformation")) {
t.typed = !1;
break;
}
(!t.issues || !r.abortEarly && !r.abortPipeEarly) && (t = n._run(t, r));
}
return t;
}
};
}
const iV = new Uint8Array(32), oV = np(
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"
), oa = (e) => Sm(m_(Uint8Array), sae(e));
function t4(e, t) {
return e.length !== t.length ? !1 : e.every((r, n) => rr(r, t[n]) === 0);
}
function Ll(e) {
if (!(e instanceof Uint8Array) || e.length < 33) return !1;
const t = e[0], r = e.slice(1, 33);
if (rr(iV, r) === 0 || rr(r, oV) >= 0) return !1;
if ((t === 2 || t === 3) && e.length === 33)
return !0;
const n = e.slice(33);
return rr(iV, n) === 0 || rr(n, oV) >= 0 ? !1 : t === 4 && e.length === 65;
}
const T9 = 254;
function PD(e) {
return !e || !("output" in e) || !(e.output instanceof Uint8Array) ? !1 : e.version !== void 0 ? (e.version & T9) === e.version : !0;
}
function hae(e) {
return Array.isArray(e) ? e.length !== 2 ? !1 : e.every((t) => hae(t)) : PD(e);
}
const b3e = oa(32), y3e = oa(20), aV = oa(32), ti = m_(Uint8Array);
Sm(Pb(), uae(/^([0-9a-f]{2})+$/i));
const m3e = Sm(
lu(),
TD(),
b_(0),
g_(255)
), Id = Sm(
lu(),
TD(),
b_(0),
g_(4294967295)
), SM = Sm(
lae(),
b_(0n),
g_(0x7fffffffffffffffn)
), sV = (e) => zo(
Object.entries(e).reduce(
(t, r) => ({ ...t, [r[0]]: fae(r[1]) }),
{}
)
), uV = new Uint8Array(1);
function cV(e) {
let t = 0;
for (; e[t] === 0; ) ++t;
return t === e.length ? uV : (e = e.slice(t), e[0] & 128 ? ho([uV, e]) : e);
}
function lV(e) {
e[0] === 0 && (e = e.slice(1));
const t = new Uint8Array(32), r = Math.max(0, 32 - e.length);
return t.set(e, r), t;
}
function w3e(e) {
const t = Wd(e, e.length - 1);
if (!MD(t))
throw new Error("Invalid hashType " + t);
const r = Yve(e.subarray(0, -1)), n = lV(r.r), i = lV(r.s);
return { signature: ho([n, i]), hashType: t };
}
function v3e(e, t) {
if (io(
zo({
signature: oa(64),
hashType: m3e
}),
{ signature: e, hashType: t }
), !MD(t))
throw new Error("Invalid hashType " + t);
const r = new Uint8Array(1);
oc(r, 0, t);
const n = cV(e.slice(0, 32)), i = cV(e.slice(32, 64));
return ho([Jve(n, i), r]);
}
const E3e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
decode: w3e,
encode: v3e
}, Symbol.toStringTag, { value: "Module" })), dae = $n.OP_RESERVED, pae = vu(OD([m_(Uint8Array), lu()]));
function S3e(e) {
return y_(lu(), e) && (e === $n.OP_0 || e >= $n.OP_1 && e <= $n.OP_16 || e === $n.OP_1NEGATE);
}
function gae(e) {
return y_(ti, e) || S3e(e);
}
function $D(e) {
return y_(Sm(cae(), aae(gae)), e);
}
function bae(e) {
return e.length - e.filter(gae).length;
}
function lE(e) {
if (e.length === 0) return $n.OP_0;
if (e.length === 1) {
if (e[0] >= 1 && e[0] <= 16) return dae + e[0];
if (e[0] === 129) return $n.OP_1NEGATE;
}
}
function yae(e) {
return e instanceof Uint8Array;
}
function _3e(e) {
return y_(pae, e);
}
function fE(e) {
return e instanceof Uint8Array;
}
function va(e) {
if (yae(e)) return e;
io(pae, e);
const t = e.reduce((i, o) => fE(o) ? o.length === 1 && lE(o) !== void 0 ? i + 1 : i + oae(o.length) + o.length : i + 1, 0), r = new Uint8Array(t);
let n = 0;
if (e.forEach((i) => {
if (fE(i)) {
const o = lE(i);
if (o !== void 0) {
oc(r, n, o), n += 1;
return;
}
n += u3e(r, i.length, n), r.set(i, n), n += i.length;
} else
oc(r, n, i), n += 1;
}), n !== r.length) throw new Error("Could not decode chunks");
return r;
}
function ao(e) {
if (_3e(e)) return e;
io(ti, e);
const t = [];
let r = 0;
for (; r < e.length; ) {
const n = e[r];
if (n > $n.OP_0 && n <= $n.OP_PUSHDATA4) {
const i = c3e(e, r);
if (i === null || (r += i.size, r + i.number > e.length)) return null;
const o = e.slice(r, r + i.number);
r += i.number;
const a = lE(o);
a !== void 0 ? t.push(a) : t.push(o);
} else
t.push(n), r += 1;
}
return t;
}
function x3e(e) {
if (yae(e) && (e = ao(e)), !e)
throw new Error("Could not convert invalid chunks to ASM");
return e.map((t) => {
if (fE(t)) {
const r = lE(t);
if (r === void 0) return Mr(t);
t = r;
}
return Joe[t];
}).join(" ");
}
function k3e(e) {
return e = ao(e), io(Zl($D), e), e.map((t) => fE(t) ? t : t === $n.OP_0 ? new Uint8Array(0) : f3e(t - dae));
}
function A3e(e) {
return Ll(e);
}
function MD(e) {
const t = e & -129;
return t > 0 && t < 4;
}
function Vd(e) {
return !(e instanceof Uint8Array) || !MD(e[e.length - 1]) ? !1 : Xve(e.slice(0, -1));
}
const I8 = E3e;
function kr(e, t, r) {
Object.defineProperty(e, t, {
configurable: !0,
enumerable: !0,
get() {
const n = r.call(this);
return this[t] = n, n;
},
set(n) {
Object.defineProperty(this, t, {
configurable: !0,
enumerable: !0,
value: n,
writable: !0
});
}
});
}
function Wc(e) {
let t;
return () => (t !== void 0 || (t = e()), t);
}
const Ky = $n, z5 = Ky.OP_RESERVED;
function w_(e, t) {
if (!e.input && !e.output && !(e.pubkeys && e.m !== void 0) && !e.signatures)
throw new TypeError("Not enough data");
t = Object.assign({ validate: !0 }, t || {});
function r(s) {
return Vd(s) || (t.allowIncomplete && s === Ky.OP_0) !== void 0;
}
io(
B0(
zo({
network: zo({}),
m: lu(),
n: lu(),
output: ti,
pubkeys: vu(Zl(Ll), "Received invalid pubkey"),
signatures: vu(
Zl(r),
"Expected signature to be of type isAcceptableSignature"
),
input: ti
})
),
e
);
const n = { network: e.network || ef };
let i = [], o = !1;
function a(s) {
o || (o = !0, i = ao(s), n.m = i[0] - z5, n.n = i[i.length - 2] - z5, n.pubkeys = i.slice(1, -2));
}
if (kr(n, "output", () => {
if (e.m && n.n && e.pubkeys)
return va(
[].concat(
z5 + e.m,
e.pubkeys,
z5 + n.n,
Ky.OP_CHECKMULTISIG
)
);
}), kr(n, "m", () => {
if (n.output)
return a(n.output), n.m;
}), kr(n, "n", () => {
if (n.pubkeys)
return n.pubkeys.length;
}), kr(n, "pubkeys", () => {
if (e.output)
return a(e.output), n.pubkeys;
}), kr(n, "signatures", () => {
if (e.input)
return ao(e.input).slice(1);
}), kr(n, "input", () => {
if (e.signatures)
return va([Ky.OP_0].concat(e.signatures));
}), kr(n, "witness", () => {
if (n.input)
return [];
}), kr(n, "name", () => {
if (!(!n.m || !n.n))
return `p2ms(${n.m} of ${n.n})`;
}), t.validate) {
if (e.output) {
if (a(e.output), io(lu(), i[0], { message: "Output is invalid" }), io(lu(), i[i.length - 2], {
message: "Output is invalid"
}), i[i.length - 1] !== Ky.OP_CHECKMULTISIG)
throw new TypeError("Output is invalid");
if (n.m <= 0 || n.n > 16 || n.m > n.n || n.n !== i.length - 3)
throw new TypeError("Output is invalid");
if (!n.pubkeys.every((s) => Ll(s)))
throw new TypeError("Output is invalid");
if (e.m !== void 0 && e.m !== n.m) throw new TypeError("m mismatch");
if (e.n !== void 0 && e.n !== n.n) throw new TypeError("n mismatch");
if (e.pubkeys && !t4(e.pubkeys, n.pubkeys))
throw new TypeError("Pubkeys mismatch");
}
if (e.pubkeys) {
if (e.n !== void 0 && e.n !== e.pubkeys.length)
throw new TypeError("Pubkey count mismatch");
if (n.n = e.pubkeys.length, n.n < n.m) throw new TypeError("Pubkey count cannot be less than m");
}
if (e.signatures) {
if (e.signatures.length < n.m)
throw new TypeError("Not enough signatures provided");
if (e.signatures.length > n.m)
throw new TypeError("Too many signatures provided");
}
if (e.input) {
if (e.input[0] !== Ky.OP_0) throw new TypeError("Input is invalid");
if (n.signatures.length === 0 || !n.signatures.every(r))
throw new TypeError("Input has invalid signature(s)");
if (e.signatures && !t4(e.signatures, n.signatures))
throw new TypeError("Signature mismatch");
if (e.m !== void 0 && e.m !== e.signatures.length)
throw new TypeError("Signature count mismatch");
}
}
return Object.assign(n, e);
}
const fV = $n;
function mae(e, t) {
if (!e.input && !e.output && !e.pubkey && !e.input && !e.signature)
throw new TypeError("Not enough data");
t = Object.assign({ validate: !0 }, t || {}), io(
B0(
zo({
network: zo({}),
output: ti,
pubkey: Zl(Ll, "invalid pubkey"),
signature: Zl(
Vd,
"Expected signature to be of type isCanonicalScriptSignature"
),
input: ti
})
),
e
);
const r = Wc(() => ao(e.input)), n = { name: "p2pk", network: e.network || ef };
if (kr(n, "output", () => {
if (e.pubkey)
return va([e.pubkey, fV.OP_CHECKSIG]);
}), kr(n, "pubkey", () => {
if (e.output)
return e.output.slice(1, -1);
}), kr(n, "signature", () => {
if (e.input)
return r()[0];
}), kr(n, "input", () => {
if (e.signature)
return va([e.signature]);
}), kr(n, "witness", () => {
if (n.input)
return [];
}), t.validate) {
if (e.output) {
if (e.output[e.output.length - 1] !== fV.OP_CHECKSIG)
throw new TypeError("Output is invalid");
if (!Ll(n.pubkey)) throw new TypeError("Output pubkey is invalid");
if (e.pubkey && rr(e.pubkey, n.pubkey) !== 0)
throw new TypeError("Pubkey mismatch");
}
if (e.signature && e.input && rr(e.input, n.input) !== 0)
throw new TypeError("Signature mismatch");
if (e.input) {
if (r().length !== 1) throw new TypeError("Input is invalid");
if (!Vd(n.signature))
throw new TypeError("Input has invalid signature");
}
}
return Object.assign(n, e);
}
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
function I3e(e) {
return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
}
function hV(e) {
if (!Number.isSafeInteger(e) || e < 0)
throw new Error("positive integer expected, got " + e);
}
function v_(e, ...t) {
if (!I3e(e))
throw new Error("Uint8Array expected");
if (t.length > 0 && !t.includes(e.length))
throw new Error("Uint8Array expected of length " + t + ", got length=" + e.length);
}
function T3e(e) {
if (typeof e != "function" || typeof e.create != "function")
throw new Error("Hash should be wrapped by utils.createHasher");
hV(e.outputLen), hV(e.blockLen);
}
function hE(e, t = !0) {
if (e.destroyed)
throw new Error("Hash instance has been destroyed");
if (t && e.finished)
throw new Error("Hash#digest() has already been called");
}
function B3e(e, t) {
v_(e);
const r = t.outputLen;
if (e.length < r)
throw new Error("digestInto() expects output buffer of length at least " + r);
}
function O0(...e) {
for (let t = 0; t < e.length; t++)
e[t].fill(0);
}
function _M(e) {
return new DataView(e.buffer, e.byteOffset, e.byteLength);
}
function lf(e, t) {
return e << 32 - t | e >>> t;
}
function L5(e, t) {
return e << t | e >>> 32 - t >>> 0;
}
function O3e(e) {
if (typeof e != "string")
throw new Error("string expected");
return new Uint8Array(new TextEncoder().encode(e));
}
function RD(e) {
return typeof e == "string" && (e = O3e(e)), v_(e), e;
}
let wae = class {
};
function CD(e) {
const t = (n) => e().update(RD(n)).digest(), r = e();
return t.outputLen = r.outputLen, t.blockLen = r.blockLen, t.create = () => e(), t;
}
function P3e(e, t, r, n) {
if (typeof e.setBigUint64 == "function")
return e.setBigUint64(t, r, n);
const i = BigInt(32), o = BigInt(4294967295), a = Number(r >> i & o), s = Number(r & o), c = n ? 4 : 0, l = n ? 0 : 4;
e.setUint32(t + c, a, n), e.setUint32(t + l, s, n);
}
function $3e(e, t, r) {
return e & t ^ ~e & r;
}
function M3e(e, t, r) {
return e & t ^ e & r ^ t & r;
}
let ND = class extends wae {
constructor(t, r, n, i) {
super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = t, this.outputLen = r, this.padOffset = n, this.isLE = i, this.buffer = new Uint8Array(t), this.view = _M(this.buffer);
}
update(t) {
hE(this), t = RD(t), v_(t);
const { view: r, buffer: n, blockLen: i } = this, o = t.length;
for (let a = 0; a < o; ) {
const s = Math.min(i - this.pos, o - a);
if (s === i) {
const c = _M(t);
for (; i <= o - a; a += i)
this.process(c, a);
continue;
}
n.set(t.subarray(a, a + s), this.pos), this.pos += s, a += s, this.pos === i && (this.process(r, 0), this.pos = 0);
}
return this.length += t.length, this.roundClean(), this;
}
digestInto(t) {
hE(this), B3e(t, this), this.finished = !0;
const { buffer: r, view: n, blockLen: i, isLE: o } = this;
let { pos: a } = this;
r[a++] = 128, O0(this.buffer.subarray(a)), this.padOffset > i - a && (this.process(n, 0), a = 0);
for (let h = a; h < i; h++)
r[h] = 0;
P3e(n, i - 8, BigInt(this.length * 8), o), this.process(n, 0);
const s = _M(t), c = this.outputLen;
if (c % 4)
throw new Error("_sha2: outputLen should be aligned to 32bit");
const l = c / 4, u = this.get();
if (l > u.length)
throw new Error("_sha2: outputLen bigger than state");
for (let h = 0; h < l; h++)
s.setUint32(4 * h, u[h], o);
}
digest() {
const { buffer: t, outputLen: r } = this;
this.digestInto(t);
const n = t.slice(0, r);
return this.destroy(), n;
}
_cloneInto(t) {
t || (t = new this.constructor()), t.set(...this.get());
const { blockLen: r, buffer: n, length: i, finished: o, destroyed: a, pos: s } = this;
return t.destroyed = a, t.finished = o, t.length = i, t.pos = s, i % r && t.buffer.set(n), t;
}
clone() {
return this._cloneInto();
}
};
const gp = /* @__PURE__ */ Uint32Array.from([
1779033703,
3144134277,
1013904242,
2773480762,
1359893119,
2600822924,
528734635,
1541459225
]), rs = /* @__PURE__ */ Uint32Array.from([
1779033703,
4089235720,
3144134277,
2227873595,
1013904242,
4271175723,
2773480762,
1595750129,
1359893119,
2917565137,
2600822924,
725511199,
528734635,
4215389547,
1541459225,
327033209
]), R3e = /* @__PURE__ */ Uint8Array.from([
7,
4,
13,
1,
10,
6,
15,
3,
12,
0,
9,
5,
2,
14,
11,
8
]), vae = Uint8Array.from(new Array(16).fill(0).map((e, t) => t)), C3e = vae.map((e) => (9 * e + 5) % 16), Eae = /* @__PURE__ */ (() => {
const e = [[vae], [C3e]];
for (let t = 0; t < 4; t++)
for (let r of e)
r.push(r[t].map((n) => R3e[n]));
return e;
})(), Sae = Eae[0], _ae = Eae[1], xae = /* @__PURE__ */ [
[11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],
[12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],
[13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],
[14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],
[15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5]
].map((e) => Uint8Array.from(e)), N3e = /* @__PURE__ */ Sae.map((e, t) => e.map((r) => xae[t][r])), U3e = /* @__PURE__ */ _ae.map((e, t) => e.map((r) => xae[t][r])), j3e = /* @__PURE__ */ Uint32Array.from([
0,
1518500249,
1859775393,
2400959708,
2840853838
]), F3e = /* @__PURE__ */ Uint32Array.from([
1352829926,
1548603684,
1836072691,
2053994217,
0
]);
function dV(e, t, r, n) {
return e === 0 ? t ^ r ^ n : e === 1 ? t & r | ~t & n : e === 2 ? (t | ~r) ^ n : e === 3 ? t & n | r & ~n : t ^ (r | ~n);
}
const D5 = /* @__PURE__ */ new Uint32Array(16);
let z3e = class extends ND {
constructor() {
super(64, 20, 8, !0), this.h0 = 1732584193, this.h1 = -271733879, this.h2 = -1732584194, this.h3 = 271733878, this.h4 = -1009589776;
}
get() {
const { h0: e, h1: t, h2: r, h3: n, h4: i } = this;
return [e, t, r, n, i];
}
set(e, t, r, n, i) {
this.h0 = e | 0, this.h1 = t | 0, this.h2 = r | 0, this.h3 = n | 0, this.h4 = i | 0;
}
process(e, t) {
for (let d = 0; d < 16; d++, t += 4)
D5[d] = e.getUint32(t, !0);
let r = this.h0 | 0, n = r, i = this.h1 | 0, o = i, a = this.h2 | 0, s = a, c = this.h3 | 0, l = c, u = this.h4 | 0, h = u;
for (let d = 0; d < 5; d++) {
const p = 4 - d, m = j3e[d], w = F3e[d], T = Sae[d], $ = _ae[d], A = N3e[d], P = U3e[d];
for (let x = 0; x < 16; x++) {
const K = L5(r + dV(d, i, a, c) + D5[T[x]] + m, A[x]) + u | 0;
r = u, u = c, c = L5(a, 10) | 0, a = i, i = K;