diff --git a/vendor/bitlogin.integrity.json b/vendor/bitlogin.integrity.json index 0bb87036..3e287412 100644 --- a/vendor/bitlogin.integrity.json +++ b/vendor/bitlogin.integrity.json @@ -2,17 +2,25 @@ "package": "@bitlogin/widget", "version": "0.1.0", "files": { - "bitlogin-shared-QIBe5Omw.js": { - "sha256": "7ce4ed0a5c3c7f744e864f55745f7fa78482cbfa19cd30eb551f67a415f55191", - "bytes": 288275 + "bitlogin-shared-B2Rc9khL.js": { + "sha256": "6a9df1b27d73499d3bd488182b3134e0173c6b0bf1b5537cddc0e9ec4073d8e7", + "bytes": 288486 + }, + "bitlogin-shared-DxcpMAo3.js": { + "sha256": "b6cb73f3544a8c378416c50740a91eaea700c4af3e4f6b131bb3694e7c816758", + "bytes": 483718 + }, + "bitlogin-shared-IsyHQNSG.js": { + "sha256": "bd6d38087df246792cd61b82323f2997ecf478d3abcc3885235f45a925614131", + "bytes": 545712 }, "bitlogin.js": { - "sha256": "55312cef3462a2e41043b57bd3c87a80bad4e077dd6e529faf25fa55db4ba7a8", - "bytes": 67232 + "sha256": "0d118d599efd30d4c0d0c197d463fd64900e803aa1a84c7880e1780bed9f3aba", + "bytes": 85342 }, "cryptoWorker.js": { - "sha256": "49a421e1026ad94243ceb0653f3761820d4e98e19b8fbe469307cd692f9a8489", - "bytes": 79173 + "sha256": "4210e0d6e7c5fc33e4df2dd3eedbe9434439600d0e60fcb3cad90699c198d452", + "bytes": 104078 } } } diff --git a/vendor/bitlogin/bitlogin-shared-QIBe5Omw.js b/vendor/bitlogin/bitlogin-shared-B2Rc9khL.js similarity index 96% rename from vendor/bitlogin/bitlogin-shared-QIBe5Omw.js rename to vendor/bitlogin/bitlogin-shared-B2Rc9khL.js index 8f88c18b..66f4c01a 100644 --- a/vendor/bitlogin/bitlogin-shared-QIBe5Omw.js +++ b/vendor/bitlogin/bitlogin-shared-B2Rc9khL.js @@ -2,7 +2,7 @@ function Kr(e) { return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e; } var yt, or; -function En() { +function xn() { return or || (or = 1, yt = { 11111: "abacus", 11112: "abdomen", @@ -7782,15 +7782,15 @@ function En() { 66666: "zoom" }), yt; } -var xn = En(); -const sr = /* @__PURE__ */ Kr(xn), tt = Object.keys(sr).sort().map((e) => sr[e]); +var Dn = xn(); +const sr = /* @__PURE__ */ Kr(Dn), tt = Object.keys(sr).sort().map((e) => sr[e]); if (tt.length !== 7776) throw new Error(`EFF long wordlist must contain 7776 entries, found ${tt.length}.`); -function y1() { +function b1() { return tt; } -const b1 = Math.log2(tt.length); -function Dn() { +const w1 = Math.log2(tt.length); +function Sn() { const e = globalThis.crypto; if (!e || typeof e.getRandomValues != "function") throw new Error("No cryptographically secure random source available in this environment."); @@ -7798,18 +7798,18 @@ function Dn() { } function qe(e) { const t = new Uint8Array(e); - return Dn().getRandomValues(t), t; -} -function w1() { - return qe(16); + return Sn().getRandomValues(t), t; } function C1() { - return qe(12); -} -function k1() { return qe(16); } -function v1(e) { +function k1() { + return qe(12); +} +function v1() { + return qe(16); +} +function B1(e) { if (!Number.isInteger(e) || e <= 0 || e > 4294967296) throw new Error("randomUniformInt: maxExclusive must be an integer in (0, 2^32]."); const t = e <= 256 ? 1 : e <= 65536 ? 2 : 4, n = 256 ** t, r = n - n % e; @@ -7848,7 +7848,7 @@ function nt(e, t = !0) { if (t && e.finished) throw new Error("Hash#digest() has already been called"); } -function Sn(e, t) { +function Fn(e, t) { pe(e); const n = t.outputLen; if (e.length < n) @@ -7864,13 +7864,13 @@ function bt(e) { function re(e, t) { return e << 32 - t | e >>> t; } -const Or = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", Fn = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")); +const Or = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", Un = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")); function Ee(e) { if (pe(e), Or) return e.toHex(); let t = ""; for (let n = 0; n < e.length; n++) - t += Fn[e[n]]; + t += Un[e[n]]; return t; } const ie = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 }; @@ -7901,14 +7901,14 @@ function it(e) { } return r; } -const Un = async () => { +const Gn = async () => { }; -async function B1(e, t, n) { +async function Q1(e, t, n) { let r = Date.now(); for (let i = 0; i < e; i++) { n(i); const a = Date.now() - r; - a >= 0 && a < t || (await Un(), r += a); + a >= 0 && a < t || (await Gn(), r += a); } } function qt(e) { @@ -7919,7 +7919,7 @@ function qt(e) { function Me(e) { return typeof e == "string" && (e = qt(e)), pe(e), e; } -function Q1(e) { +function E1(e) { return typeof e == "string" && (e = qt(e)), pe(e), e; } function ne(...e) { @@ -7935,7 +7935,7 @@ function ne(...e) { } return n; } -function E1(e, t) { +function x1(e, t) { if (t !== void 0 && {}.toString.call(t) !== "[object Object]") throw new Error("options should be object or undefined"); return Object.assign(e, t); @@ -7953,16 +7953,16 @@ function ft(e = 32) { return Uint8Array.from(ve.randomBytes(e)); throw new Error("crypto.getRandomValues must be defined"); } -function Gn(e, t, n, r) { +function Hn(e, t, n, r) { if (typeof e.setBigUint64 == "function") return e.setBigUint64(t, n, r); const i = BigInt(32), a = BigInt(4294967295), o = Number(n >> i & a), s = Number(n & a), l = r ? 4 : 0, u = r ? 0 : 4; e.setUint32(t + l, o, r), e.setUint32(t + u, s, r); } -function Hn(e, t, n) { +function Nn(e, t, n) { return e & t ^ ~e & n; } -function Nn(e, t, n) { +function Kn(e, t, n) { return e & t ^ e & n ^ t & n; } class Jr extends Vr { @@ -7985,13 +7985,13 @@ class Jr extends Vr { return this.length += t.length, this.roundClean(), this; } digestInto(t) { - nt(this), Sn(t, this), this.finished = !0; + nt(this), Fn(t, this), this.finished = !0; const { buffer: n, view: r, blockLen: i, isLE: a } = this; let { pos: o } = this; n[o++] = 128, Ce(this.buffer.subarray(o)), this.padOffset > i - o && (this.process(r, 0), o = 0); for (let g = o; g < i; g++) n[g] = 0; - Gn(r, i - 8, BigInt(this.length * 8), a), this.process(r, 0); + Hn(r, i - 8, BigInt(this.length * 8), a), this.process(r, 0); const s = bt(t), l = this.outputLen; if (l % 4) throw new Error("_sha2: outputLen should be aligned to 32bit"); @@ -8043,14 +8043,14 @@ const de = /* @__PURE__ */ Uint32Array.from([ 1541459225, 327033209 ]), Pe = /* @__PURE__ */ BigInt(2 ** 32 - 1), cr = /* @__PURE__ */ BigInt(32); -function Kn(e, t = !1) { +function On(e, t = !1) { return t ? { h: Number(e & Pe), l: Number(e >> cr & Pe) } : { h: Number(e >> cr & Pe) | 0, l: Number(e & Pe) | 0 }; } -function On(e, t = !1) { +function Vn(e, t = !1) { const n = e.length; let r = new Uint32Array(n), i = new Uint32Array(n); for (let a = 0; a < n; a++) { - const { h: o, l: s } = Kn(e[a], t); + const { h: o, l: s } = On(e[a], t); [r[a], i[a]] = [o, s]; } return [r, i]; @@ -8060,7 +8060,7 @@ function ae(e, t, n, r) { const i = (t >>> 0) + (r >>> 0); return { h: e + n + (i / 2 ** 32 | 0) | 0, l: i | 0 }; } -const Vn = (e, t, n) => (e >>> 0) + (t >>> 0) + (n >>> 0), zn = (e, t, n, r) => t + n + r + (e / 2 ** 32 | 0) | 0, Jn = (e, t, n, r) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (r >>> 0), Yn = (e, t, n, r, i) => t + n + r + i + (e / 2 ** 32 | 0) | 0, Mn = (e, t, n, r, i) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (r >>> 0) + (i >>> 0), qn = (e, t, n, r, i, a) => t + n + r + i + a + (e / 2 ** 32 | 0) | 0, jn = /* @__PURE__ */ Uint32Array.from([ +const zn = (e, t, n) => (e >>> 0) + (t >>> 0) + (n >>> 0), Jn = (e, t, n, r) => t + n + r + (e / 2 ** 32 | 0) | 0, Yn = (e, t, n, r) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (r >>> 0), Mn = (e, t, n, r, i) => t + n + r + i + (e / 2 ** 32 | 0) | 0, qn = (e, t, n, r, i) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (r >>> 0) + (i >>> 0), jn = (e, t, n, r, i, a) => t + n + r + i + a + (e / 2 ** 32 | 0) | 0, Rn = /* @__PURE__ */ Uint32Array.from([ 1116352408, 1899447441, 3049323471, @@ -8126,7 +8126,7 @@ const Vn = (e, t, n) => (e >>> 0) + (t >>> 0) + (n >>> 0), zn = (e, t, n, r) => 3204031479, 3329325298 ]), ge = /* @__PURE__ */ new Uint32Array(64); -class Rn extends Jr { +class _n extends Jr { constructor(t = 32) { super(64, t, 8, !1), this.A = de[0] | 0, this.B = de[1] | 0, this.C = de[2] | 0, this.D = de[3] | 0, this.E = de[4] | 0, this.F = de[5] | 0, this.G = de[6] | 0, this.H = de[7] | 0; } @@ -8147,7 +8147,7 @@ class Rn extends Jr { } let { A: r, B: i, C: a, D: o, E: s, F: l, G: u, H: h } = this; for (let g = 0; g < 64; g++) { - const c = re(s, 6) ^ re(s, 11) ^ re(s, 25), d = h + c + Hn(s, l, u) + jn[g] + ge[g] | 0, m = (re(r, 2) ^ re(r, 13) ^ re(r, 22)) + Nn(r, i, a) | 0; + const c = re(s, 6) ^ re(s, 11) ^ re(s, 25), d = h + c + Nn(s, l, u) + Rn[g] + ge[g] | 0, m = (re(r, 2) ^ re(r, 13) ^ re(r, 22)) + Kn(r, i, a) | 0; h = u, u = l, l = s, s = o + d | 0, o = a, a = i, i = r, r = d + m | 0; } r = r + this.A | 0, i = i + this.B | 0, a = a + this.C | 0, o = o + this.D | 0, s = s + this.E | 0, l = l + this.F | 0, u = u + this.G | 0, h = h + this.H | 0, this.set(r, i, a, o, s, l, u, h); @@ -8159,7 +8159,7 @@ class Rn extends Jr { this.set(0, 0, 0, 0, 0, 0, 0, 0), Ce(this.buffer); } } -const Yr = On([ +const Yr = Vn([ "0x428a2f98d728ae22", "0x7137449123ef65cd", "0xb5c0fbcfec4d3b2f", @@ -8240,8 +8240,8 @@ const Yr = On([ "0x597f299cfc657e2a", "0x5fcb6fab3ad6faec", "0x6c44198c4a475817" -].map((e) => BigInt(e))), _n = Yr[0], Pn = Yr[1], Ae = /* @__PURE__ */ new Uint32Array(80), he = /* @__PURE__ */ new Uint32Array(80); -class Ln extends Jr { +].map((e) => BigInt(e))), Pn = Yr[0], Ln = Yr[1], Ae = /* @__PURE__ */ new Uint32Array(80), he = /* @__PURE__ */ new Uint32Array(80); +class Tn extends Jr { constructor(t = 64) { super(128, t, 16, !1), this.Ah = _[0] | 0, this.Al = _[1] | 0, this.Bh = _[2] | 0, this.Bl = _[3] | 0, this.Ch = _[4] | 0, this.Cl = _[5] | 0, this.Dh = _[6] | 0, this.Dl = _[7] | 0, this.Eh = _[8] | 0, this.El = _[9] | 0, this.Fh = _[10] | 0, this.Fl = _[11] | 0, this.Gh = _[12] | 0, this.Gl = _[13] | 0, this.Hh = _[14] | 0, this.Hl = _[15] | 0; } @@ -8258,15 +8258,15 @@ class Ln extends Jr { for (let b = 0; b < 16; b++, n += 4) Ae[b] = t.getUint32(n), he[b] = t.getUint32(n += 4); for (let b = 16; b < 80; b++) { - const N = Ae[b - 15] | 0, K = he[b - 15] | 0, C = Be(N, K, 1) ^ Be(N, K, 8) ^ ur(N, K, 7), D = Qe(N, K, 1) ^ Qe(N, K, 8) ^ dr(N, K, 7), G = Ae[b - 2] | 0, v = he[b - 2] | 0, P = Be(G, v, 19) ^ Le(G, v, 61) ^ ur(G, v, 6), Z = Qe(G, v, 19) ^ Te(G, v, 61) ^ dr(G, v, 6), U = Jn(D, Z, he[b - 7], he[b - 16]), p = Yn(U, C, P, Ae[b - 7], Ae[b - 16]); + const N = Ae[b - 15] | 0, K = he[b - 15] | 0, C = Be(N, K, 1) ^ Be(N, K, 8) ^ ur(N, K, 7), D = Qe(N, K, 1) ^ Qe(N, K, 8) ^ dr(N, K, 7), G = Ae[b - 2] | 0, v = he[b - 2] | 0, P = Be(G, v, 19) ^ Le(G, v, 61) ^ ur(G, v, 6), Z = Qe(G, v, 19) ^ Te(G, v, 61) ^ dr(G, v, 6), U = Yn(D, Z, he[b - 7], he[b - 16]), p = Mn(U, C, P, Ae[b - 7], Ae[b - 16]); Ae[b] = p | 0, he[b] = U | 0; } let { Ah: r, Al: i, Bh: a, Bl: o, Ch: s, Cl: l, Dh: u, Dl: h, Eh: g, El: c, Fh: d, Fl: I, Gh: m, Gl: B, Hh: S, Hl: j } = this; for (let b = 0; b < 80; b++) { - const N = Be(g, c, 14) ^ Be(g, c, 18) ^ Le(g, c, 41), K = Qe(g, c, 14) ^ Qe(g, c, 18) ^ Te(g, c, 41), C = g & d ^ ~g & m, D = c & I ^ ~c & B, G = Mn(j, K, D, Pn[b], he[b]), v = qn(G, S, N, C, _n[b], Ae[b]), P = G | 0, Z = Be(r, i, 28) ^ Le(r, i, 34) ^ Le(r, i, 39), U = Qe(r, i, 28) ^ Te(r, i, 34) ^ Te(r, i, 39), p = r & a ^ r & s ^ a & s, f = i & o ^ i & l ^ o & l; + const N = Be(g, c, 14) ^ Be(g, c, 18) ^ Le(g, c, 41), K = Qe(g, c, 14) ^ Qe(g, c, 18) ^ Te(g, c, 41), C = g & d ^ ~g & m, D = c & I ^ ~c & B, G = qn(j, K, D, Ln[b], he[b]), v = jn(G, S, N, C, Pn[b], Ae[b]), P = G | 0, Z = Be(r, i, 28) ^ Le(r, i, 34) ^ Le(r, i, 39), U = Qe(r, i, 28) ^ Te(r, i, 34) ^ Te(r, i, 39), p = r & a ^ r & s ^ a & s, f = i & o ^ i & l ^ o & l; S = m | 0, j = B | 0, m = d | 0, B = I | 0, d = g | 0, I = c | 0, { h: g, l: c } = ae(u | 0, h | 0, v | 0, P | 0), u = s | 0, h = l | 0, s = a | 0, l = o | 0, a = r | 0, o = i | 0; - const A = Vn(P, U, f); - r = zn(A, v, Z, p), i = A | 0; + const A = zn(P, U, f); + r = Jn(A, v, Z, p), i = A | 0; } ({ h: r, l: i } = ae(this.Ah | 0, this.Al | 0, r | 0, i | 0)), { h: a, l: o } = ae(this.Bh | 0, this.Bl | 0, a | 0, o | 0), { h: s, l } = ae(this.Ch | 0, this.Cl | 0, s | 0, l | 0), { h: u, l: h } = ae(this.Dh | 0, this.Dl | 0, u | 0, h | 0), { h: g, l: c } = ae(this.Eh | 0, this.El | 0, g | 0, c | 0), { h: d, l: I } = ae(this.Fh | 0, this.Fl | 0, d | 0, I | 0), { h: m, l: B } = ae(this.Gh | 0, this.Gl | 0, m | 0, B | 0), { h: S, l: j } = ae(this.Hh | 0, this.Hl | 0, S | 0, j | 0), this.set(r, i, a, o, s, l, u, h, g, c, d, I, m, B, S, j); } @@ -8277,7 +8277,7 @@ class Ln extends Jr { Ce(this.buffer), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); } } -const fe = /* @__PURE__ */ zr(() => new Rn()), x1 = /* @__PURE__ */ zr(() => new Ln()); +const fe = /* @__PURE__ */ zr(() => new _n()), D1 = /* @__PURE__ */ zr(() => new Tn()); class Mr extends Vr { constructor(t, n) { super(), this.finished = !1, this.destroyed = !1, ht(t); @@ -8318,11 +8318,11 @@ class Mr extends Vr { } const pt = (e, t, n) => new Mr(e, t).update(n).digest(); pt.create = (e, t) => new Mr(e, t); -function Tn(e, t, n) { +function Xn(e, t, n) { return ht(e), n === void 0 && (n = new Uint8Array(e.outputLen)), pt(e, Me(n), Me(t)); } const wt = /* @__PURE__ */ Uint8Array.from([0]), gr = /* @__PURE__ */ Uint8Array.of(); -function Xn(e, t, n, r = 32) { +function Zn(e, t, n, r = 32) { ht(e), rt(r); const i = e.outputLen; if (r > 255 * i) @@ -8349,7 +8349,7 @@ function Je(e) { return t; } const ee = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; -function D1(e) { +function S1(e) { let t = "", n = 0; for (; n + 2 < e.length; n += 3) { const i = e[n], a = e[n + 1], o = e[n + 2]; @@ -8365,17 +8365,17 @@ function D1(e) { } return t; } -const Zn = (() => { +const $n = (() => { const e = {}; for (let t = 0; t < ee.length; t++) e[ee[t]] = t; return e; })(); -function S1(e) { +function F1(e) { const t = e.replace(/=+$/u, ""), n = []; let r = 0, i = 0; for (const a of t) { - const o = Zn[a]; + const o = $n[a]; if (o === void 0) throw new Error("Invalid base64url character."); r = r << 6 | o, i += 6, i >= 8 && (i -= 8, n.push(r >> i & 255)); @@ -8385,7 +8385,7 @@ function S1(e) { function De(e) { return new TextEncoder().encode(e); } -function F1(e) { +function U1(e) { return new TextDecoder("utf-8", { fatal: !0 }).decode(e); } function qr(...e) { @@ -8395,7 +8395,7 @@ function qr(...e) { n.set(i, r), r += i.length; return n; } -function U1(e, t) { +function G1(e, t) { if (e.length !== t.length) return !1; let n = 0; @@ -8404,15 +8404,19 @@ function U1(e, t) { return n === 0; } function jr(e, t) { - return Tn(fe, t, e); + return Xn(fe, t, e); } function Rt(e, t, n) { const r = typeof t == "string" ? De(t) : t; - return Xn(fe, e, r, n); + return Zn(fe, e, r, n); } function Rr(e) { return fe(De(e)); } +function _r(...e) { + for (const t of e) + t && t.fill(0); +} /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ const _t = /* @__PURE__ */ BigInt(0), Gt = /* @__PURE__ */ BigInt(1); function at(e, t = "") { @@ -8434,21 +8438,21 @@ function Xe(e) { const t = e.toString(16); return t.length & 1 ? "0" + t : t; } -function _r(e) { +function Pr(e) { if (typeof e != "string") throw new Error("hex string expected, got " + typeof e); return e === "" ? _t : BigInt("0x" + e); } function Ge(e) { - return _r(Ee(e)); + return Pr(Ee(e)); } -function Pr(e) { - return pe(e), _r(Ee(Uint8Array.from(e).reverse())); +function Lr(e) { + return pe(e), Pr(Ee(Uint8Array.from(e).reverse())); } function It(e, t) { return it(e.toString(16).padStart(t * 2, "0")); } -function Lr(e, t) { +function Tr(e, t) { return It(e, t).reverse(); } function q(e, t, n) { @@ -8472,18 +8476,18 @@ const Ct = (e) => typeof e == "bigint" && _t <= e; function Ht(e, t, n) { return Ct(e) && Ct(t) && Ct(n) && t <= e && e < n; } -function $n(e, t, n, r) { +function Wn(e, t, n, r) { if (!Ht(t, n, r)) throw new Error("expected valid " + e + ": " + n + " <= n < " + r + ", got " + t); } -function Tr(e) { +function Xr(e) { let t; for (t = 0; e > _t; e >>= Gt, t += 1) ; return t; } const je = (e) => (Gt << BigInt(e)) - Gt; -function Wn(e, t, n) { +function ei(e, t, n) { if (typeof e != "number" || e < 2) throw new Error("hashLen must be a number"); if (typeof t != "number" || t < 2) @@ -8540,7 +8544,7 @@ function Ar(e) { }; } /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const X = BigInt(0), L = BigInt(1), me = /* @__PURE__ */ BigInt(2), Xr = /* @__PURE__ */ BigInt(3), Zr = /* @__PURE__ */ BigInt(4), $r = /* @__PURE__ */ BigInt(5), ei = /* @__PURE__ */ BigInt(7), Wr = /* @__PURE__ */ BigInt(8), ti = /* @__PURE__ */ BigInt(9), en = /* @__PURE__ */ BigInt(16); +const X = BigInt(0), L = BigInt(1), me = /* @__PURE__ */ BigInt(2), Zr = /* @__PURE__ */ BigInt(3), $r = /* @__PURE__ */ BigInt(4), Wr = /* @__PURE__ */ BigInt(5), ti = /* @__PURE__ */ BigInt(7), en = /* @__PURE__ */ BigInt(8), ri = /* @__PURE__ */ BigInt(9), tn = /* @__PURE__ */ BigInt(16); function W(e, t) { const n = e % t; return n >= X ? n : t + n; @@ -8569,16 +8573,16 @@ function Lt(e, t, n) { if (!e.eql(e.sqr(t), n)) throw new Error("Cannot find square root"); } -function tn(e, t) { - const n = (e.ORDER + L) / Zr, r = e.pow(t, n); +function rn(e, t) { + const n = (e.ORDER + L) / $r, r = e.pow(t, n); return Lt(e, r, t), r; } -function ri(e, t) { - const n = (e.ORDER - $r) / Wr, r = e.mul(t, me), i = e.pow(r, n), a = e.mul(t, i), o = e.mul(e.mul(a, me), i), s = e.mul(a, e.sub(o, e.ONE)); +function ni(e, t) { + const n = (e.ORDER - Wr) / en, r = e.mul(t, me), i = e.pow(r, n), a = e.mul(t, i), o = e.mul(e.mul(a, me), i), s = e.mul(a, e.sub(o, e.ONE)); return Lt(e, s, t), s; } -function ni(e) { - const t = Re(e), n = rn(e), r = n(t, t.neg(t.ONE)), i = n(t, r), a = n(t, t.neg(r)), o = (e + ei) / en; +function ii(e) { + const t = Re(e), n = nn(e), r = n(t, t.neg(t.ONE)), i = n(t, r), a = n(t, t.neg(r)), o = (e + ti) / tn; return (s, l) => { let u = s.pow(l, o), h = s.mul(u, r); const g = s.mul(u, i), c = s.mul(u, a), d = s.eql(s.sqr(h), l), I = s.eql(s.sqr(g), l); @@ -8587,8 +8591,8 @@ function ni(e) { return Lt(s, B, l), B; }; } -function rn(e) { - if (e < Xr) +function nn(e) { + if (e < Zr) throw new Error("sqrt is not defined for small field"); let t = e - L, n = 0; for (; t % me === X; ) @@ -8599,7 +8603,7 @@ function rn(e) { if (r++ > 1e3) throw new Error("Cannot find square root: probably non-prime P"); if (n === 1) - return tn; + return rn; let a = i.pow(r, t); const o = (t + L) / me; return function(l, u) { @@ -8621,10 +8625,10 @@ function rn(e) { return d; }; } -function ii(e) { - return e % Zr === Xr ? tn : e % Wr === $r ? ri : e % en === ti ? ni(e) : rn(e); +function ai(e) { + return e % $r === Zr ? rn : e % en === Wr ? ni : e % tn === ri ? ii(e) : nn(e); } -const ai = [ +const oi = [ "create", "isValid", "is0", @@ -8643,16 +8647,16 @@ const ai = [ "mulN", "sqrN" ]; -function oi(e) { +function si(e) { const t = { ORDER: "bigint", MASK: "bigint", BYTES: "number", BITS: "number" - }, n = ai.reduce((r, i) => (r[i] = "function", r), t); + }, n = oi.reduce((r, i) => (r[i] = "function", r), t); return Pt(e, n), e; } -function si(e, t, n) { +function li(e, t, n) { if (n < X) throw new Error("invalid exponent, negatives unsupported"); if (n === X) @@ -8664,7 +8668,7 @@ function si(e, t, n) { n & L && (r = e.mul(r, i)), i = e.sqr(i), n >>= L; return r; } -function nn(e, t, n = !1) { +function an(e, t, n = !1) { const r = new Array(t.length).fill(n ? e.ZERO : void 0), i = t.reduce((o, s, l) => e.is0(s) ? o : (r[l] = o, e.mul(o, s)), e.ONE), a = e.inv(i); return t.reduceRight((o, s, l) => e.is0(s) ? o : (r[l] = e.mul(o, r[l]), e.mul(o, s)), a), r; } @@ -8674,7 +8678,7 @@ function fr(e, t) { throw new Error("invalid Legendre symbol result"); return i ? 1 : a ? 0 : -1; } -function an(e, t) { +function on(e, t) { t !== void 0 && rt(t); const n = t !== void 0 ? t : e.toString(2).length, r = Math.ceil(n / 8); return { nBitLength: n, nByteLength: r }; @@ -8690,7 +8694,7 @@ function Re(e, t, n = !1, r = {}) { c.BITS && (i = c.BITS), c.sqrt && (a = c.sqrt), typeof c.isLE == "boolean" && (n = c.isLE), typeof c.modFromBytes == "boolean" && (o = c.modFromBytes), s = c.allowedLengths; } else typeof t == "number" && (i = t), r.sqrt && (a = r.sqrt); - const { nBitLength: l, nByteLength: u } = an(e, i); + const { nBitLength: l, nByteLength: u } = on(e, i); if (u > 2048) throw new Error("invalid field: expected ORDER of <= 2048 bytes"); let h; @@ -8719,7 +8723,7 @@ function Re(e, t, n = !1, r = {}) { add: (c, d) => W(c + d, e), sub: (c, d) => W(c - d, e), mul: (c, d) => W(c * d, e), - pow: (c, d) => si(g, c, d), + pow: (c, d) => li(g, c, d), div: (c, d) => W(c * hr(d, e), e), // Same as above, but doesn't normalize sqrN: (c) => c * c, @@ -8727,8 +8731,8 @@ function Re(e, t, n = !1, r = {}) { subN: (c, d) => c - d, mulN: (c, d) => c * d, inv: (c) => hr(c, e), - sqrt: a || ((c) => (h || (h = ii(e)), h(g, c))), - toBytes: (c) => n ? Lr(c, u) : It(c, u), + sqrt: a || ((c) => (h || (h = ai(e)), h(g, c))), + toBytes: (c) => n ? Tr(c, u) : It(c, u), fromBytes: (c, d = !0) => { if (s) { if (!s.includes(c.length) || c.length > u) @@ -8738,35 +8742,35 @@ function Re(e, t, n = !1, r = {}) { } if (c.length !== u) throw new Error("Field.fromBytes: expected " + u + " bytes, got " + c.length); - let I = n ? Pr(c) : Ge(c); + let I = n ? Lr(c) : Ge(c); if (o && (I = W(I, e)), !d && !g.isValid(I)) throw new Error("invalid field element: outside of range 0..ORDER"); return I; }, // TODO: we don't need it here, move out to separate fn - invertBatch: (c) => nn(g, c), + invertBatch: (c) => an(g, c), // We can't move this out because Fp6, Fp12 implement it // and it's unclear what to return in there. cmov: (c, d, I) => I ? d : c }); return Object.freeze(g); } -function on(e) { +function sn(e) { if (typeof e != "bigint") throw new Error("field order must be bigint"); const t = e.toString(2).length; return Math.ceil(t / 8); } -function sn(e) { - const t = on(e); +function ln(e) { + const t = sn(e); return t + Math.ceil(t / 2); } -function ln(e, t, n = !1) { - const r = e.length, i = on(t), a = sn(t); +function cn(e, t, n = !1) { + const r = e.length, i = sn(t), a = ln(t); if (r < 16 || r < a || r > 1024) throw new Error("expected " + a + "-1024 bytes of input, got " + r); - const o = n ? Pr(e) : Ge(e), s = W(o, t - L) + L; - return n ? Lr(s, i) : It(s, i); + const o = n ? Lr(e) : Ge(e), s = W(o, t - L) + L; + return n ? Tr(s, i) : It(s, i); } /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ const Se = BigInt(0), ye = BigInt(1); @@ -8775,15 +8779,15 @@ function ot(e, t) { return e ? n : t; } function kt(e, t) { - const n = nn(e.Fp, t.map((r) => r.Z)); + const n = an(e.Fp, t.map((r) => r.Z)); return t.map((r, i) => e.fromAffine(r.toAffine(n[i]))); } -function cn(e, t) { +function un(e, t) { if (!Number.isSafeInteger(e) || e <= 0 || e > t) throw new Error("invalid window size, expected [1.." + t + "], got W=" + e); } function vt(e, t) { - cn(e, t); + un(e, t); const n = Math.ceil(t / e) + 1, r = 2 ** (e - 1), i = 2 ** e, a = je(e), o = BigInt(e); return { windows: n, windowSize: r, mask: a, maxNumber: i, shiftBy: o }; } @@ -8794,7 +8798,7 @@ function pr(e, t, n) { const u = t * r, h = u + Math.abs(s) - 1, g = s === 0, c = s < 0, d = t % 2 !== 0; return { nextN: l, offset: h, isZero: g, isNeg: c, isNegF: d, offsetF: u }; } -function li(e, t) { +function ci(e, t) { if (!Array.isArray(e)) throw new Error("array expected"); e.forEach((n, r) => { @@ -8802,7 +8806,7 @@ function li(e, t) { throw new Error("invalid point at index " + r); }); } -function ci(e, t) { +function ui(e, t) { if (!Array.isArray(e)) throw new Error("array of scalars expected"); e.forEach((n, r) => { @@ -8810,15 +8814,15 @@ function ci(e, t) { throw new Error("invalid scalar at index " + r); }); } -const Bt = /* @__PURE__ */ new WeakMap(), un = /* @__PURE__ */ new WeakMap(); +const Bt = /* @__PURE__ */ new WeakMap(), dn = /* @__PURE__ */ new WeakMap(); function Qt(e) { - return un.get(e) || 1; + return dn.get(e) || 1; } function Ir(e) { if (e !== Se) throw new Error("invalid wNAF"); } -class ui { +class di { // Parametrized with a given Point class (not individual point) constructor(t, n) { this.BASE = t.BASE, this.ZERO = t.ZERO, this.Fn = t.Fn, this.bits = n; @@ -8902,24 +8906,24 @@ class ui { // using windowed method. This specifies window size and // stores precomputed values. Usually only base point would be precomputed. createCache(t, n) { - cn(n, this.bits), un.set(t, n), Bt.delete(t); + un(n, this.bits), dn.set(t, n), Bt.delete(t); } hasCache(t) { return Qt(t) !== 1; } } -function di(e, t, n, r) { +function gi(e, t, n, r) { let i = t, a = e.ZERO, o = e.ZERO; for (; n > Se || r > Se; ) n & ye && (a = a.add(i)), r & ye && (o = o.add(i)), i = i.double(), n >>= ye, r >>= ye; return { p1: a, p2: o }; } -function gi(e, t, n, r) { - li(n, e), ci(r, t); +function Ai(e, t, n, r) { + ci(n, e), ui(r, t); const i = n.length, a = r.length; if (i !== a) throw new Error("arrays of points and scalars must have equal length"); - const o = e.ZERO, s = Tr(BigInt(i)); + const o = e.ZERO, s = Xr(BigInt(i)); let l = 1; s > 12 ? l = s - 3 : s > 4 ? l = s - 2 : s > 0 && (l = 2); const u = je(l), h = new Array(Number(u) + 1).fill(o), g = Math.floor((t.BITS - 1) / l) * l; @@ -8943,11 +8947,11 @@ function mr(e, t, n) { if (t) { if (t.ORDER !== e) throw new Error("Field.ORDER must match order: Fp == p, Fn == n"); - return oi(t), t; + return si(t), t; } else return Re(e, { isLE: n }); } -function Ai(e, t, n = {}, r) { +function hi(e, t, n = {}, r) { if (r === void 0 && (r = e === "edwards"), !t || typeof t != "object") throw new Error(`expected valid ${e} CURVE object`); for (const l of ["p", "n", "h"]) { @@ -8962,13 +8966,13 @@ function Ai(e, t, n = {}, r) { return t = Object.freeze(Object.assign({}, t)), { CURVE: t, Fp: i, Fn: a }; } /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const yr = (e, t) => (e + (e >= 0 ? t : -t) / dn) / t; -function hi(e, t, n) { +const yr = (e, t) => (e + (e >= 0 ? t : -t) / gn) / t; +function fi(e, t, n) { const [[r, i], [a, o]] = t, s = yr(o * e, n), l = yr(-i * e, n); let u = e - s * r - l * a, h = -s * i - l * o; const g = u < ce, c = h < ce; g && (u = -u), c && (h = -h); - const d = je(Math.ceil(Tr(n) / 2)) + xe; + const d = je(Math.ceil(Xr(n) / 2)) + xe; if (u < ce || u >= d || h < ce || h >= d) throw new Error("splitScalar (endomorphism): failed, k=" + e); return { k1neg: g, k1: u, k2neg: c, k2: h }; @@ -8984,14 +8988,14 @@ function Et(e, t) { n[r] = e[r] === void 0 ? t[r] : e[r]; return at(n.lowS, "lowS"), at(n.prehash, "prehash"), n.format !== void 0 && Nt(n.format), n; } -class fi extends Error { +class pi extends Error { constructor(t = "") { super(t); } } const le = { // asn.1 DER encoding utils - Err: fi, + Err: pi, // Basic building block is TLV (Tag-Length-Value) _tlv: { encode: (e, t) => { @@ -9076,7 +9080,7 @@ const le = { const { _tlv: t, _int: n } = le, r = t.encode(2, n.encode(e.r)), i = t.encode(2, n.encode(e.s)), a = r + i; return t.encode(48, a); } -}, ce = BigInt(0), xe = BigInt(1), dn = BigInt(2), Ze = BigInt(3), pi = BigInt(4); +}, ce = BigInt(0), xe = BigInt(1), gn = BigInt(2), Ze = BigInt(3), Ii = BigInt(4); function be(e, t) { const { BYTES: n } = e; let r; @@ -9094,8 +9098,8 @@ function be(e, t) { throw new Error("invalid private key: out of range [1..N-1]"); return r; } -function Ii(e, t = {}) { - const n = Ai("weierstrass", e, t), { Fp: r, Fn: i } = n; +function mi(e, t = {}) { + const n = hi("weierstrass", e, t), { Fp: r, Fn: i } = n; let a = n.CURVE; const { h: o, n: s } = a; Pt(t, {}, { @@ -9110,7 +9114,7 @@ function Ii(e, t = {}) { const { endo: l } = t; if (l && (!r.is0(a.a) || typeof l.beta != "bigint" || !Array.isArray(l.basises))) throw new Error('invalid endo: expected "beta": bigint and "basises": array'); - const u = An(r, i); + const u = hn(r, i); function h() { if (!r.isOdd) throw new Error("compression is not supported: Field does not have .isOdd()"); @@ -9120,7 +9124,7 @@ function Ii(e, t = {}) { if (at(f, "isCompressed"), f) { h(); const E = !r.isOdd(y); - return ne(gn(E), w); + return ne(An(E), w); } else return ne(Uint8Array.of(4), w, r.toBytes(y)); } @@ -9161,7 +9165,7 @@ function Ii(e, t = {}) { } if (!B(a.Gx, a.Gy)) throw new Error("bad curve params: generator point"); - const S = r.mul(r.pow(a.a, Ze), pi), j = r.mul(r.sqr(a.b), BigInt(27)); + const S = r.mul(r.pow(a.a, Ze), Ii), j = r.mul(r.sqr(a.b), BigInt(27)); if (r.is0(r.add(S, j))) throw new Error("bad curve params: a or b"); function b(U, p, f = !1) { @@ -9176,7 +9180,7 @@ function Ii(e, t = {}) { function K(U) { if (!l || !l.basises) throw new Error("no endo"); - return hi(U, l.basises, i.ORDER); + return fi(U, l.basises, i.ORDER); } const C = Ar((U, p) => { const { X: f, Y: A, Z: y } = U; @@ -9337,7 +9341,7 @@ function Ii(e, t = {}) { if (Z.hasCache(this)) return this.multiply(p); if (f) { - const { k1neg: y, k1: w, k2neg: E, k2: Q } = K(p), { p1: k, p2: x } = di(v, A, w, Q); + const { k1neg: y, k1: w, k2neg: E, k2: Q } = K(p), { p1: k, p2: x } = gi(v, A, w, Q); return G(f.beta, k, x, y, E); } else return Z.unsafe(A, p); @@ -9397,20 +9401,20 @@ function Ii(e, t = {}) { return kt(v, p); } static msm(p, f) { - return gi(v, i, p, f); + return Ai(v, i, p, f); } static fromPrivateKey(p) { return v.BASE.multiply(be(i, p)); } } v.BASE = new v(a.Gx, a.Gy, r.ONE), v.ZERO = new v(r.ZERO, r.ONE, r.ZERO), v.Fp = r, v.Fn = i; - const P = i.BITS, Z = new ui(v, t.endo ? Math.ceil(P / 2) : P); + const P = i.BITS, Z = new di(v, t.endo ? Math.ceil(P / 2) : P); return v.BASE.precompute(8), v; } -function gn(e) { +function An(e) { return Uint8Array.of(e ? 2 : 3); } -function An(e, t) { +function hn(e, t) { return { secretKey: t.BYTES, publicKey: 1 + e.BYTES, @@ -9419,8 +9423,8 @@ function An(e, t) { signature: 2 * t.BYTES }; } -function mi(e, t = {}) { - const { Fn: n } = e, r = t.randomBytes || ft, i = Object.assign(An(e.Fp, n), { seed: sn(n.ORDER) }); +function yi(e, t = {}) { + const { Fn: n } = e, r = t.randomBytes || ft, i = Object.assign(hn(e.Fp, n), { seed: ln(n.ORDER) }); function a(d) { try { return !!be(n, d); @@ -9438,7 +9442,7 @@ function mi(e, t = {}) { } } function s(d = r(i.seed)) { - return ln(Ie(d, i.seed, "seed"), n.ORDER); + return cn(Ie(d, i.seed, "seed"), n.ORDER); } function l(d, I = !0) { return e.BASE.multiply(be(n, d)).toBytes(I); @@ -9479,7 +9483,7 @@ function mi(e, t = {}) { } }, lengths: i }); } -function yi(e, t, n = {}) { +function bi(e, t, n = {}) { ht(t), Pt(n, {}, { hmac: "function", lowS: "boolean", @@ -9487,7 +9491,7 @@ function yi(e, t, n = {}) { bits2int: "function", bits2int_modN: "function" }); - const r = n.randomBytes || ft, i = n.hmac || ((f, ...A) => pt(t, f, ne(...A))), { Fp: a, Fn: o } = e, { ORDER: s, BITS: l } = o, { keygen: u, getPublicKey: h, getSharedSecret: g, utils: c, lengths: d } = mi(e, n), I = { + const r = n.randomBytes || ft, i = n.hmac || ((f, ...A) => pt(t, f, ne(...A))), { Fp: a, Fn: o } = e, { ORDER: s, BITS: l } = o, { keygen: u, getPublicKey: h, getSharedSecret: g, utils: c, lengths: d } = yi(e, n), I = { prehash: !1, lowS: typeof n.lowS == "boolean" ? n.lowS : !1, format: void 0, @@ -9533,12 +9537,12 @@ function yi(e, t, n = {}) { const y = a.ORDER, { r: w, s: E, recovery: Q } = this; if (Q == null || ![0, 1, 2, 3].includes(Q)) throw new Error("recovery id invalid"); - if (s * dn < y && Q > 1) + if (s * gn < y && Q > 1) throw new Error("recovery id is ambiguous for h>1 curve"); const x = Q === 2 || Q === 3 ? w + s : w; if (!a.isValid(x)) throw new Error("recovery id 2 or 3 invalid"); - const F = a.toBytes(x), Y = e.fromBytes(ne(gn((Q & 1) === 0), F)), O = o.inv(x), H = K(q("msgHash", A)), z = o.create(-H * O), M = o.create(E * O), T = e.BASE.multiplyUnsafe(z).add(Y.multiplyUnsafe(M)); + const F = a.toBytes(x), Y = e.fromBytes(ne(An((Q & 1) === 0), F)), O = o.inv(x), H = K(q("msgHash", A)), z = o.create(-H * O), M = o.create(E * O), T = e.BASE.multiplyUnsafe(z).add(Y.multiplyUnsafe(M)); if (T.is0()) throw new Error("point at infinify"); return T.assertValidity(), T; @@ -9595,7 +9599,7 @@ function yi(e, t, n = {}) { return o.create(N(A)); }, C = je(l); function D(f) { - return $n("num < 2^" + l, f, ce, C), o.toBytes(f); + return Wn("num < 2^" + l, f, ce, C), o.toBytes(f); } function G(f, A) { return Ie(f, void 0, "message"), A ? Ie(t(f), void 0, "prehashed message") : f; @@ -9629,7 +9633,7 @@ function yi(e, t, n = {}) { function P(f, A, y = {}) { f = q("message", f); const { seed: w, k2sig: E } = v(f, A, y); - return Wn(t.outputLen, o.BYTES, i)(w, E); + return ei(t.outputLen, o.BYTES, i)(w, E); } function Z(f) { let A; @@ -9689,7 +9693,7 @@ function yi(e, t, n = {}) { hash: t }); } -function bi(e) { +function wi(e) { const t = { a: e.a, b: e.b, @@ -9716,8 +9720,8 @@ function bi(e) { }; return { CURVE: t, curveOpts: a }; } -function wi(e) { - const { CURVE: t, curveOpts: n } = bi(e), r = { +function Ci(e) { + const { CURVE: t, curveOpts: n } = wi(e), r = { hmac: e.hmac, randomBytes: e.randomBytes, lowS: e.lowS, @@ -9726,20 +9730,20 @@ function wi(e) { }; return { CURVE: t, curveOpts: n, hash: e.hash, ecdsaOpts: r }; } -function Ci(e, t) { +function ki(e, t) { const n = t.Point; return Object.assign({}, t, { ProjectivePoint: n, - CURVE: Object.assign({}, e, an(n.Fn.ORDER, n.Fn.BITS)) + CURVE: Object.assign({}, e, on(n.Fn.ORDER, n.Fn.BITS)) }); } -function ki(e) { - const { CURVE: t, curveOpts: n, hash: r, ecdsaOpts: i } = wi(e), a = Ii(t, n), o = yi(a, r, i); - return Ci(e, o); +function vi(e) { + const { CURVE: t, curveOpts: n, hash: r, ecdsaOpts: i } = Ci(e), a = mi(t, n), o = bi(a, r, i); + return ki(e, o); } /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -function vi(e, t) { - const n = (r) => ki({ ...e, hash: r }); +function Bi(e, t) { + const n = (r) => vi({ ...e, hash: r }); return { ...n(t), create: n }; } /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ @@ -9751,20 +9755,20 @@ const Fe = { b: BigInt(7), Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"), Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8") -}, Bi = { +}, Qi = { beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"), basises: [ [BigInt("0x3086d221a7d46bcde86c90e49284eb15"), -BigInt("0xe4437ed6010e88286f547fa90abfe4c3")], [BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")] ] -}, Qi = /* @__PURE__ */ BigInt(0), br = /* @__PURE__ */ BigInt(1), Kt = /* @__PURE__ */ BigInt(2); -function Ei(e) { +}, Ei = /* @__PURE__ */ BigInt(0), br = /* @__PURE__ */ BigInt(1), Kt = /* @__PURE__ */ BigInt(2); +function xi(e) { const t = Fe.p, n = BigInt(3), r = BigInt(6), i = BigInt(11), a = BigInt(22), o = BigInt(23), s = BigInt(44), l = BigInt(88), u = e * e * e % t, h = u * u * e % t, g = $(h, n, t) * h % t, c = $(g, n, t) * h % t, d = $(c, Kt, t) * u % t, I = $(d, i, t) * d % t, m = $(I, a, t) * I % t, B = $(m, s, t) * m % t, S = $(B, l, t) * B % t, j = $(S, s, t) * m % t, b = $(j, n, t) * h % t, N = $(b, o, t) * I % t, K = $(N, r, t) * u % t, C = $(K, Kt, t); if (!st.eql(st.sqr(C), e)) throw new Error("Cannot find square root"); return C; } -const st = Re(Fe.p, { sqrt: Ei }), mt = vi({ ...Fe, Fp: st, lowS: !0, endo: Bi }, fe), wr = {}; +const st = Re(Fe.p, { sqrt: xi }), mt = Bi({ ...Fe, Fp: st, lowS: !0, endo: Qi }, fe), wr = {}; function lt(e, ...t) { let n = wr[e]; if (n === void 0) { @@ -9773,12 +9777,12 @@ function lt(e, ...t) { } return fe(ne(n, ...t)); } -const Tt = (e) => e.toBytes(!0).slice(1), He = mt.Point, Xt = (e) => e % Kt === Qi; +const Tt = (e) => e.toBytes(!0).slice(1), He = mt.Point, Xt = (e) => e % Kt === Ei; function Ot(e) { const { Fn: t, BASE: n } = He, r = be(t, e), i = n.multiply(r); return { scalar: Xt(i.y) ? r : t.neg(r), bytes: Tt(i) }; } -function hn(e) { +function fn(e) { const t = st; if (!t.isValidNot0(e)) throw new Error("invalid x: Fail if x ≥ p"); @@ -9789,35 +9793,35 @@ function hn(e) { return a.assertValidity(), a; } const Ye = Ge; -function fn(...e) { +function pn(...e) { return He.Fn.create(Ye(lt("BIP0340/challenge", ...e))); } function Cr(e) { return Ot(e).bytes; } -function xi(e, t, n = ft(32)) { - const { Fn: r } = He, i = q("message", e), { bytes: a, scalar: o } = Ot(t), s = q("auxRand", n, 32), l = r.toBytes(o ^ Ye(lt("BIP0340/aux", s))), u = lt("BIP0340/nonce", l, a, i), { bytes: h, scalar: g } = Ot(u), c = fn(h, a, i), d = new Uint8Array(64); - if (d.set(h, 0), d.set(r.toBytes(r.create(g + c * o)), 32), !pn(d, i, a)) +function Di(e, t, n = ft(32)) { + const { Fn: r } = He, i = q("message", e), { bytes: a, scalar: o } = Ot(t), s = q("auxRand", n, 32), l = r.toBytes(o ^ Ye(lt("BIP0340/aux", s))), u = lt("BIP0340/nonce", l, a, i), { bytes: h, scalar: g } = Ot(u), c = pn(h, a, i), d = new Uint8Array(64); + if (d.set(h, 0), d.set(r.toBytes(r.create(g + c * o)), 32), !In(d, i, a)) throw new Error("sign: Invalid signature produced"); return d; } -function pn(e, t, n) { +function In(e, t, n) { const { Fn: r, BASE: i } = He, a = q("signature", e, 64), o = q("message", t), s = q("publicKey", n, 32); try { - const l = hn(Ye(s)), u = Ye(a.subarray(0, 32)); + const l = fn(Ye(s)), u = Ye(a.subarray(0, 32)); if (!Ht(u, br, Fe.p)) return !1; const h = Ye(a.subarray(32, 64)); if (!Ht(h, br, Fe.n)) return !1; - const g = fn(r.toBytes(u), Tt(l), o), c = i.multiplyUnsafe(h).add(l.multiplyUnsafe(r.neg(g))), { x: d, y: I } = c.toAffine(); + const g = pn(r.toBytes(u), Tt(l), o), c = i.multiplyUnsafe(h).add(l.multiplyUnsafe(r.neg(g))), { x: d, y: I } = c.toAffine(); return !(c.is0() || !Xt(I) || d !== u); } catch { return !1; } } const Zt = /* @__PURE__ */ (() => { - const n = (i = ft(48)) => ln(i, Fe.n); + const n = (i = ft(48)) => cn(i, Fe.n); mt.utils.randomSecretKey; function r(i) { const a = n(i); @@ -9826,15 +9830,15 @@ const Zt = /* @__PURE__ */ (() => { return { keygen: r, getPublicKey: Cr, - sign: xi, - verify: pn, + sign: Di, + verify: In, Point: He, utils: { randomSecretKey: n, randomPrivateKey: n, taggedHash: lt, // TODO: remove - lift_x: hn, + lift_x: fn, pointToBytes: Tt, numberToBytesBE: It, bytesToNumberBE: Ge, @@ -9848,26 +9852,26 @@ const Zt = /* @__PURE__ */ (() => { seed: 48 } }; -})(), Di = mt.CURVE.n; -function Si(e) { +})(), Si = mt.CURVE.n; +function Fi(e) { let t = 0n; for (const n of e) t = t << 8n | BigInt(n); return t; } -function Fi(e) { +function Ui(e) { const t = new Uint8Array(32); let n = e; for (let r = 31; r >= 0; r--) t[r] = Number(n & 0xffn), n >>= 8n; return t; } -function In(e, t) { +function mn(e, t) { const n = De(t); for (let r = 0; r <= 255; r++) { - const i = qr(n, new Uint8Array([0, r])), a = Rt(e, i, 32), o = Si(a); - if (o >= 1n && o < Di) - return { scalar: Fi(o), counter: r }; + const i = qr(n, new Uint8Array([0, r])), a = Rt(e, i, 32), o = Fi(a); + if (o >= 1n && o < Si) + return { scalar: Ui(o), counter: r }; } throw new Error("ScalarExpand: exhausted 256 counters without a valid scalar (should not happen in practice)."); } @@ -9926,26 +9930,26 @@ class V { } } var xt; -function Ui() { +function Gi() { return typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global; } -const Vt = Ui(), Dt = (xt = Vt.Buffer) !== null && xt !== void 0 ? xt : null, Gi = Vt.TextEncoder ? new Vt.TextEncoder() : null; -function mn(e, t) { +const Vt = Gi(), Dt = (xt = Vt.Buffer) !== null && xt !== void 0 ? xt : null, Hi = Vt.TextEncoder ? new Vt.TextEncoder() : null; +function yn(e, t) { return (e & 15) + (e >> 6 | e >> 3 & 8) << 4 | (t & 15) + (t >> 6 | t >> 3 & 8); } -function yn(e, t) { +function bn(e, t) { const n = t.length >> 1; for (let r = 0; r < n; r++) { const i = r << 1; - e[r] = mn(t.charCodeAt(i), t.charCodeAt(i + 1)); + e[r] = yn(t.charCodeAt(i), t.charCodeAt(i + 1)); } } -function Hi(e, t) { +function Ni(e, t) { if (e.length !== t.length * 2) return !1; for (let n = 0; n < t.length; n++) { const r = n << 1; - if (t[n] !== mn(e.charCodeAt(r), e.charCodeAt(r + 1))) + if (t[n] !== yn(e.charCodeAt(r), e.charCodeAt(r + 1))) return !1; } return !0; @@ -9971,7 +9975,7 @@ const ue = Dt !== null ? (e) => { throw new Error("Invalid data type!"); } : (e) => { if (typeof e == "string") - return Gi.encode(e); + return Hi.encode(e); if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength); throw new Error("Invalid data type!"); @@ -9993,13 +9997,13 @@ function Br(e, t = !0) { } return i.join(""); } -function Ni(e) { +function Ki(e) { let t = Math.floor(e.length * 0.75); const n = e.length; return e[n - 1] === "=" && (t -= 1, e[n - 2] === "=" && (t -= 1)), t; } -function Ki(e) { - const t = Ni(e), n = e.length, r = new Uint8Array(t); +function Oi(e) { + const t = Ki(e), n = e.length, r = new Uint8Array(t); let i = 0; for (let a = 0; a < n; a += 4) { const o = ze[e.charCodeAt(a)], s = ze[e.charCodeAt(a + 1)], l = ze[e.charCodeAt(a + 2)], u = ze[e.charCodeAt(a + 3)]; @@ -10007,8 +10011,8 @@ function Ki(e) { } return r; } -const $e = 16 * 1024, Ke = 4, Oi = new V(), St = /* @__PURE__ */ new Map(); -function bn(e, t) { +const $e = 16 * 1024, Ke = 4, Vi = new V(), St = /* @__PURE__ */ new Map(); +function wn(e, t) { return we(this, void 0, void 0, function* () { let n = null, r = null, i = !1; if (typeof WebAssembly > "u") @@ -10019,9 +10023,9 @@ function bn(e, t) { n.exports.Hash_SetMemorySize(C); const D = n.exports.Hash_GetBuffer(), G = n.exports.memory.buffer; r = new Uint8Array(G, D, C); - }, u = () => new DataView(n.exports.memory.buffer).getUint32(n.exports.STATE_SIZE, !0), h = Oi.dispatch(() => we(this, void 0, void 0, function* () { + }, u = () => new DataView(n.exports.memory.buffer).getUint32(n.exports.STATE_SIZE, !0), h = Vi.dispatch(() => we(this, void 0, void 0, function* () { if (!St.has(e.name)) { - const D = Ki(e.data), G = WebAssembly.compile(D); + const D = Oi(e.data), G = WebAssembly.compile(D); St.set(e.name, G); } const C = yield St.get(e.name); @@ -10064,14 +10068,14 @@ function bn(e, t) { if (!i) throw new Error("save() can only be called after init() and before digest()"); const C = n.exports.Hash_GetState(), D = u(), G = n.exports.memory.buffer, v = new Uint8Array(G, C, D), P = new Uint8Array(Ke + D); - return yn(P, e.hash), P.set(v, Ke), P; + return bn(P, e.hash), P.set(v, Ke), P; }, j = (C) => { if (!(C instanceof Uint8Array)) throw new Error("load() expects an Uint8Array generated by save()"); const D = n.exports.Hash_GetState(), G = u(), v = Ke + G, P = n.exports.memory.buffer; if (C.length !== v) throw new Error(`Bad state length (expected ${v} bytes, got ${C.length})`); - if (!Hi(e.hash, C.subarray(0, Ke))) + if (!Ni(e.hash, C.subarray(0, Ke))) throw new Error("This state was written by an incompatible hash implementation"); const Z = C.subarray(Ke); new Uint8Array(P, D, G).set(Z), i = !0; @@ -10119,20 +10123,20 @@ function bn(e, t) { }); } new V(); -var Vi = "argon2", zi = "AGFzbQEAAAABKQVgAX8Bf2AAAX9gEH9/f39/f39/f39/f39/f38AYAR/f39/AGACf38AAwYFAAECAwQFBgEBAoCAAgYIAX8BQZCoBAsHQQQGbWVtb3J5AgASSGFzaF9TZXRNZW1vcnlTaXplAAAOSGFzaF9HZXRCdWZmZXIAAQ5IYXNoX0NhbGN1bGF0ZQAECvEyBVgBAn9BACEBAkAgAEEAKAKICCICRg0AAkAgACACayIAQRB2IABBgIB8cSAASWoiAEAAQX9HDQBB/wHADwtBACEBQQBBACkDiAggAEEQdK18NwOICAsgAcALcAECfwJAQQAoAoAIIgANAEEAPwBBEHQiADYCgAhBACgCiAgiAUGAgCBGDQACQEGAgCAgAWsiAEEQdiAAQYCAfHEgAElqIgBAAEF/Rw0AQQAPC0EAQQApA4gIIABBEHStfDcDiAhBACgCgAghAAsgAAvcDgECfiAAIAQpAwAiECAAKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAMIBAgDCkDAIVCIIkiEDcDACAIIBAgCCkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgBCAQIAQpAwCFQiiJIhA3AwAgACAQIAApAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAwgECAMKQMAhUIwiSIQNwMAIAggECAIKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAEIBAgBCkDAIVCAYk3AwAgASAFKQMAIhAgASkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDSAQIA0pAwCFQiCJIhA3AwAgCSAQIAkpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAUgECAFKQMAhUIoiSIQNwMAIAEgECABKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACANIBAgDSkDAIVCMIkiEDcDACAJIBAgCSkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBSAQIAUpAwCFQgGJNwMAIAIgBikDACIQIAIpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIA4gECAOKQMAhUIgiSIQNwMAIAogECAKKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAGIBAgBikDAIVCKIkiEDcDACACIBAgAikDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgDiAQIA4pAwCFQjCJIhA3AwAgCiAQIAopAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAYgECAGKQMAhUIBiTcDACADIAcpAwAiECADKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAPIBAgDykDAIVCIIkiEDcDACALIBAgCykDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgByAQIAcpAwCFQiiJIhA3AwAgAyAQIAMpAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIA8gECAPKQMAhUIwiSIQNwMAIAsgECALKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAHIBAgBykDAIVCAYk3AwAgACAFKQMAIhAgACkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDyAQIA8pAwCFQiCJIhA3AwAgCiAQIAopAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAUgECAFKQMAhUIoiSIQNwMAIAAgECAAKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAPIBAgDykDAIVCMIkiEDcDACAKIBAgCikDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBSAQIAUpAwCFQgGJNwMAIAEgBikDACIQIAEpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAwgECAMKQMAhUIgiSIQNwMAIAsgECALKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAGIBAgBikDAIVCKIkiEDcDACABIBAgASkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgDCAQIAwpAwCFQjCJIhA3AwAgCyAQIAspAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAYgECAGKQMAhUIBiTcDACACIAcpAwAiECACKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACANIBAgDSkDAIVCIIkiEDcDACAIIBAgCCkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgByAQIAcpAwCFQiiJIhA3AwAgAiAQIAIpAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIA0gECANKQMAhUIwiSIQNwMAIAggECAIKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAHIBAgBykDAIVCAYk3AwAgAyAEKQMAIhAgAykDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDiAQIA4pAwCFQiCJIhA3AwAgCSAQIAkpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAQgECAEKQMAhUIoiSIQNwMAIAMgECADKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAOIBAgDikDAIVCMIkiEDcDACAJIBAgCSkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBCAQIAQpAwCFQgGJNwMAC98aAQN/QQAhBEEAIAIpAwAgASkDAIU3A5AIQQAgAikDCCABKQMIhTcDmAhBACACKQMQIAEpAxCFNwOgCEEAIAIpAxggASkDGIU3A6gIQQAgAikDICABKQMghTcDsAhBACACKQMoIAEpAyiFNwO4CEEAIAIpAzAgASkDMIU3A8AIQQAgAikDOCABKQM4hTcDyAhBACACKQNAIAEpA0CFNwPQCEEAIAIpA0ggASkDSIU3A9gIQQAgAikDUCABKQNQhTcD4AhBACACKQNYIAEpA1iFNwPoCEEAIAIpA2AgASkDYIU3A/AIQQAgAikDaCABKQNohTcD+AhBACACKQNwIAEpA3CFNwOACUEAIAIpA3ggASkDeIU3A4gJQQAgAikDgAEgASkDgAGFNwOQCUEAIAIpA4gBIAEpA4gBhTcDmAlBACACKQOQASABKQOQAYU3A6AJQQAgAikDmAEgASkDmAGFNwOoCUEAIAIpA6ABIAEpA6ABhTcDsAlBACACKQOoASABKQOoAYU3A7gJQQAgAikDsAEgASkDsAGFNwPACUEAIAIpA7gBIAEpA7gBhTcDyAlBACACKQPAASABKQPAAYU3A9AJQQAgAikDyAEgASkDyAGFNwPYCUEAIAIpA9ABIAEpA9ABhTcD4AlBACACKQPYASABKQPYAYU3A+gJQQAgAikD4AEgASkD4AGFNwPwCUEAIAIpA+gBIAEpA+gBhTcD+AlBACACKQPwASABKQPwAYU3A4AKQQAgAikD+AEgASkD+AGFNwOICkEAIAIpA4ACIAEpA4AChTcDkApBACACKQOIAiABKQOIAoU3A5gKQQAgAikDkAIgASkDkAKFNwOgCkEAIAIpA5gCIAEpA5gChTcDqApBACACKQOgAiABKQOgAoU3A7AKQQAgAikDqAIgASkDqAKFNwO4CkEAIAIpA7ACIAEpA7AChTcDwApBACACKQO4AiABKQO4AoU3A8gKQQAgAikDwAIgASkDwAKFNwPQCkEAIAIpA8gCIAEpA8gChTcD2ApBACACKQPQAiABKQPQAoU3A+AKQQAgAikD2AIgASkD2AKFNwPoCkEAIAIpA+ACIAEpA+AChTcD8ApBACACKQPoAiABKQPoAoU3A/gKQQAgAikD8AIgASkD8AKFNwOAC0EAIAIpA/gCIAEpA/gChTcDiAtBACACKQOAAyABKQOAA4U3A5ALQQAgAikDiAMgASkDiAOFNwOYC0EAIAIpA5ADIAEpA5ADhTcDoAtBACACKQOYAyABKQOYA4U3A6gLQQAgAikDoAMgASkDoAOFNwOwC0EAIAIpA6gDIAEpA6gDhTcDuAtBACACKQOwAyABKQOwA4U3A8ALQQAgAikDuAMgASkDuAOFNwPIC0EAIAIpA8ADIAEpA8ADhTcD0AtBACACKQPIAyABKQPIA4U3A9gLQQAgAikD0AMgASkD0AOFNwPgC0EAIAIpA9gDIAEpA9gDhTcD6AtBACACKQPgAyABKQPgA4U3A/ALQQAgAikD6AMgASkD6AOFNwP4C0EAIAIpA/ADIAEpA/ADhTcDgAxBACACKQP4AyABKQP4A4U3A4gMQQAgAikDgAQgASkDgASFNwOQDEEAIAIpA4gEIAEpA4gEhTcDmAxBACACKQOQBCABKQOQBIU3A6AMQQAgAikDmAQgASkDmASFNwOoDEEAIAIpA6AEIAEpA6AEhTcDsAxBACACKQOoBCABKQOoBIU3A7gMQQAgAikDsAQgASkDsASFNwPADEEAIAIpA7gEIAEpA7gEhTcDyAxBACACKQPABCABKQPABIU3A9AMQQAgAikDyAQgASkDyASFNwPYDEEAIAIpA9AEIAEpA9AEhTcD4AxBACACKQPYBCABKQPYBIU3A+gMQQAgAikD4AQgASkD4ASFNwPwDEEAIAIpA+gEIAEpA+gEhTcD+AxBACACKQPwBCABKQPwBIU3A4ANQQAgAikD+AQgASkD+ASFNwOIDUEAIAIpA4AFIAEpA4AFhTcDkA1BACACKQOIBSABKQOIBYU3A5gNQQAgAikDkAUgASkDkAWFNwOgDUEAIAIpA5gFIAEpA5gFhTcDqA1BACACKQOgBSABKQOgBYU3A7ANQQAgAikDqAUgASkDqAWFNwO4DUEAIAIpA7AFIAEpA7AFhTcDwA1BACACKQO4BSABKQO4BYU3A8gNQQAgAikDwAUgASkDwAWFNwPQDUEAIAIpA8gFIAEpA8gFhTcD2A1BACACKQPQBSABKQPQBYU3A+ANQQAgAikD2AUgASkD2AWFNwPoDUEAIAIpA+AFIAEpA+AFhTcD8A1BACACKQPoBSABKQPoBYU3A/gNQQAgAikD8AUgASkD8AWFNwOADkEAIAIpA/gFIAEpA/gFhTcDiA5BACACKQOABiABKQOABoU3A5AOQQAgAikDiAYgASkDiAaFNwOYDkEAIAIpA5AGIAEpA5AGhTcDoA5BACACKQOYBiABKQOYBoU3A6gOQQAgAikDoAYgASkDoAaFNwOwDkEAIAIpA6gGIAEpA6gGhTcDuA5BACACKQOwBiABKQOwBoU3A8AOQQAgAikDuAYgASkDuAaFNwPIDkEAIAIpA8AGIAEpA8AGhTcD0A5BACACKQPIBiABKQPIBoU3A9gOQQAgAikD0AYgASkD0AaFNwPgDkEAIAIpA9gGIAEpA9gGhTcD6A5BACACKQPgBiABKQPgBoU3A/AOQQAgAikD6AYgASkD6AaFNwP4DkEAIAIpA/AGIAEpA/AGhTcDgA9BACACKQP4BiABKQP4BoU3A4gPQQAgAikDgAcgASkDgAeFNwOQD0EAIAIpA4gHIAEpA4gHhTcDmA9BACACKQOQByABKQOQB4U3A6APQQAgAikDmAcgASkDmAeFNwOoD0EAIAIpA6AHIAEpA6AHhTcDsA9BACACKQOoByABKQOoB4U3A7gPQQAgAikDsAcgASkDsAeFNwPAD0EAIAIpA7gHIAEpA7gHhTcDyA9BACACKQPAByABKQPAB4U3A9APQQAgAikDyAcgASkDyAeFNwPYD0EAIAIpA9AHIAEpA9AHhTcD4A9BACACKQPYByABKQPYB4U3A+gPQQAgAikD4AcgASkD4AeFNwPwD0EAIAIpA+gHIAEpA+gHhTcD+A9BACACKQPwByABKQPwB4U3A4AQQQAgAikD+AcgASkD+AeFNwOIEEGQCEGYCEGgCEGoCEGwCEG4CEHACEHICEHQCEHYCEHgCEHoCEHwCEH4CEGACUGICRACQZAJQZgJQaAJQagJQbAJQbgJQcAJQcgJQdAJQdgJQeAJQegJQfAJQfgJQYAKQYgKEAJBkApBmApBoApBqApBsApBuApBwApByApB0ApB2ApB4ApB6ApB8ApB+ApBgAtBiAsQAkGQC0GYC0GgC0GoC0GwC0G4C0HAC0HIC0HQC0HYC0HgC0HoC0HwC0H4C0GADEGIDBACQZAMQZgMQaAMQagMQbAMQbgMQcAMQcgMQdAMQdgMQeAMQegMQfAMQfgMQYANQYgNEAJBkA1BmA1BoA1BqA1BsA1BuA1BwA1ByA1B0A1B2A1B4A1B6A1B8A1B+A1BgA5BiA4QAkGQDkGYDkGgDkGoDkGwDkG4DkHADkHIDkHQDkHYDkHgDkHoDkHwDkH4DkGAD0GIDxACQZAPQZgPQaAPQagPQbAPQbgPQcAPQcgPQdAPQdgPQeAPQegPQfAPQfgPQYAQQYgQEAJBkAhBmAhBkAlBmAlBkApBmApBkAtBmAtBkAxBmAxBkA1BmA1BkA5BmA5BkA9BmA8QAkGgCEGoCEGgCUGoCUGgCkGoCkGgC0GoC0GgDEGoDEGgDUGoDUGgDkGoDkGgD0GoDxACQbAIQbgIQbAJQbgJQbAKQbgKQbALQbgLQbAMQbgMQbANQbgNQbAOQbgOQbAPQbgPEAJBwAhByAhBwAlByAlBwApByApBwAtByAtBwAxByAxBwA1ByA1BwA5ByA5BwA9ByA8QAkHQCEHYCEHQCUHYCUHQCkHYCkHQC0HYC0HQDEHYDEHQDUHYDUHQDkHYDkHQD0HYDxACQeAIQegIQeAJQegJQeAKQegKQeALQegLQeAMQegMQeANQegNQeAOQegOQeAPQegPEAJB8AhB+AhB8AlB+AlB8ApB+ApB8AtB+AtB8AxB+AxB8A1B+A1B8A5B+A5B8A9B+A8QAkGACUGICUGACkGICkGAC0GIC0GADEGIDEGADUGIDUGADkGIDkGAD0GID0GAEEGIEBACAkACQCADRQ0AA0AgACAEaiIDIAIgBGoiBSkDACABIARqIgYpAwCFIARBkAhqKQMAhSADKQMAhTcDACADQQhqIgMgBUEIaikDACAGQQhqKQMAhSAEQZgIaikDAIUgAykDAIU3AwAgBEEQaiIEQYAIRw0ADAILC0EAIQQDQCAAIARqIgMgAiAEaiIFKQMAIAEgBGoiBikDAIUgBEGQCGopAwCFNwMAIANBCGogBUEIaikDACAGQQhqKQMAhSAEQZgIaikDAIU3AwAgBEEQaiIEQYAIRw0ACwsL5QcMBX8BfgR/An4BfwF+AX8Bfgd/AX4DfwF+AkBBACgCgAgiAiABQQp0aiIDKAIIIAFHDQAgAygCDCEEIAMoAgAhBUEAIAMoAhQiBq03A7gQQQAgBK0iBzcDsBBBACAFIAEgBUECdG4iCGwiCUECdK03A6gQAkACQAJAAkAgBEUNAEF/IQogBUUNASAIQQNsIQsgCEECdCIErSEMIAWtIQ0gBkF/akECSSEOQgAhDwNAQQAgDzcDkBAgD6chEEIAIRFBACEBA0BBACARNwOgECAPIBGEUCIDIA5xIRIgBkEBRiAPUCITIAZBAkYgEUICVHFxciEUQX8gAUEBakEDcSAIbEF/aiATGyEVIAEgEHIhFiABIAhsIRcgA0EBdCEYQgAhGQNAQQBCADcDwBBBACAZNwOYECAYIQECQCASRQ0AQQBCATcDwBBBkBhBkBBBkCBBABADQZAYQZAYQZAgQQAQA0ECIQELAkAgASAITw0AIAQgGaciGmwgF2ogAWohAwNAIANBACAEIAEbQQAgEVAiGxtqQX9qIRwCQAJAIBQNAEEAKAKACCICIBxBCnQiHGohCgwBCwJAIAFB/wBxIgINAEEAQQApA8AQQgF8NwPAEEGQGEGQEEGQIEEAEANBkBhBkBhBkCBBABADCyAcQQp0IRwgAkEDdEGQGGohCkEAKAKACCECCyACIANBCnRqIAIgHGogAiAKKQMAIh1CIIinIAVwIBogFhsiHCAEbCABIAFBACAZIBytUSIcGyIKIBsbIBdqIAogC2ogExsgAUUgHHJrIhsgFWqtIB1C/////w+DIh0gHX5CIIggG61+QiCIfSAMgqdqQQp0akEBEAMgA0EBaiEDIAggAUEBaiIBRw0ACwsgGUIBfCIZIA1SDQALIBFCAXwiEachASARQgRSDQALIA9CAXwiDyAHUg0AC0EAKAKACCECCyAJQQx0QYB4aiEXIAVBf2oiCkUNAgwBC0EAQgM3A6AQQQAgBEF/aq03A5AQQYB4IRcLIAIgF2ohGyAIQQx0IQhBACEcA0AgCCAcQQFqIhxsQYB4aiEEQQAhAQNAIBsgAWoiAyADKQMAIAIgBCABamopAwCFNwMAIANBCGoiAyADKQMAIAIgBCABQQhyamopAwCFNwMAIAFBCGohAyABQRBqIQEgA0H4B0kNAAsgHCAKRw0ACwsgAiAXaiEbQXghAQNAIAIgAWoiA0EIaiAbIAFqIgRBCGopAwA3AwAgA0EQaiAEQRBqKQMANwMAIANBGGogBEEYaikDADcDACADQSBqIARBIGopAwA3AwAgAUEgaiIBQfgHSQ0ACwsL", Ji = "e4cdc523", Yi = { - name: Vi, - data: zi, - hash: Ji -}, Mi = "blake2b", qi = "AGFzbQEAAAABEQRgAAF/YAJ/fwBgAX8AYAAAAwoJAAECAwECAgABBQQBAQICBg4CfwFBsIsFC38AQYAICwdwCAZtZW1vcnkCAA5IYXNoX0dldEJ1ZmZlcgAACkhhc2hfRmluYWwAAwlIYXNoX0luaXQABQtIYXNoX1VwZGF0ZQAGDUhhc2hfR2V0U3RhdGUABw5IYXNoX0NhbGN1bGF0ZQAIClNUQVRFX1NJWkUDAQrTOAkFAEGACQvrAgIFfwF+AkAgAUEBSA0AAkACQAJAIAFBgAFBACgC4IoBIgJrIgNKDQAgASEEDAELQQBBADYC4IoBAkAgAkH/AEoNACACQeCJAWohBSAAIQRBACEGA0AgBSAELQAAOgAAIARBAWohBCAFQQFqIQUgAyAGQQFqIgZB/wFxSg0ACwtBAEEAKQPAiQEiB0KAAXw3A8CJAUEAQQApA8iJASAHQv9+Vq18NwPIiQFB4IkBEAIgACADaiEAAkAgASADayIEQYEBSA0AIAIgAWohBQNAQQBBACkDwIkBIgdCgAF8NwPAiQFBAEEAKQPIiQEgB0L/flatfDcDyIkBIAAQAiAAQYABaiEAIAVBgH9qIgVBgAJLDQALIAVBgH9qIQQMAQsgBEEATA0BC0EAIQUDQCAFQQAoAuCKAWpB4IkBaiAAIAVqLQAAOgAAIAQgBUEBaiIFQf8BcUoNAAsLQQBBACgC4IoBIARqNgLgigELC78uASR+QQBBACkD0IkBQQApA7CJASIBQQApA5CJAXwgACkDICICfCIDhULr+obav7X2wR+FQiCJIgRCq/DT9K/uvLc8fCIFIAGFQiiJIgYgA3wgACkDKCIBfCIHIASFQjCJIgggBXwiCSAGhUIBiSIKQQApA8iJAUEAKQOoiQEiBEEAKQOIiQF8IAApAxAiA3wiBYVCn9j52cKR2oKbf4VCIIkiC0K7zqqm2NDrs7t/fCIMIASFQiiJIg0gBXwgACkDGCIEfCIOfCAAKQNQIgV8Ig9BACkDwIkBQQApA6CJASIQQQApA4CJASIRfCAAKQMAIgZ8IhKFQtGFmu/6z5SH0QCFQiCJIhNCiJLznf/M+YTqAHwiFCAQhUIoiSIVIBJ8IAApAwgiEHwiFiAThUIwiSIXhUIgiSIYQQApA9iJAUEAKQO4iQEiE0EAKQOYiQF8IAApAzAiEnwiGYVC+cL4m5Gjs/DbAIVCIIkiGkLx7fT4paf9p6V/fCIbIBOFQiiJIhwgGXwgACkDOCITfCIZIBqFQjCJIhogG3wiG3wiHSAKhUIoiSIeIA98IAApA1giCnwiDyAYhUIwiSIYIB18Ih0gDiALhUIwiSIOIAx8Ih8gDYVCAYkiDCAWfCAAKQNAIgt8Ig0gGoVCIIkiFiAJfCIaIAyFQiiJIiAgDXwgACkDSCIJfCIhIBaFQjCJIhYgGyAchUIBiSIMIAd8IAApA2AiB3wiDSAOhUIgiSIOIBcgFHwiFHwiFyAMhUIoiSIbIA18IAApA2giDHwiHCAOhUIwiSIOIBd8IhcgG4VCAYkiGyAZIBQgFYVCAYkiFHwgACkDcCINfCIVIAiFQiCJIhkgH3wiHyAUhUIoiSIUIBV8IAApA3giCHwiFXwgDHwiIoVCIIkiI3wiJCAbhUIoiSIbICJ8IBJ8IiIgFyAYIBUgGYVCMIkiFSAffCIZIBSFQgGJIhQgIXwgDXwiH4VCIIkiGHwiFyAUhUIoiSIUIB98IAV8Ih8gGIVCMIkiGCAXfCIXIBSFQgGJIhR8IAF8IiEgFiAafCIWIBUgHSAehUIBiSIaIBx8IAl8IhyFQiCJIhV8Ih0gGoVCKIkiGiAcfCAIfCIcIBWFQjCJIhWFQiCJIh4gGSAOIBYgIIVCAYkiFiAPfCACfCIPhUIgiSIOfCIZIBaFQiiJIhYgD3wgC3wiDyAOhUIwiSIOIBl8Ihl8IiAgFIVCKIkiFCAhfCAEfCIhIB6FQjCJIh4gIHwiICAiICOFQjCJIiIgJHwiIyAbhUIBiSIbIBx8IAp8IhwgDoVCIIkiDiAXfCIXIBuFQiiJIhsgHHwgE3wiHCAOhUIwiSIOIBkgFoVCAYkiFiAffCAQfCIZICKFQiCJIh8gFSAdfCIVfCIdIBaFQiiJIhYgGXwgB3wiGSAfhUIwiSIfIB18Ih0gFoVCAYkiFiAVIBqFQgGJIhUgD3wgBnwiDyAYhUIgiSIYICN8IhogFYVCKIkiFSAPfCADfCIPfCAHfCIihUIgiSIjfCIkIBaFQiiJIhYgInwgBnwiIiAjhUIwiSIjICR8IiQgFoVCAYkiFiAOIBd8Ig4gDyAYhUIwiSIPICAgFIVCAYkiFCAZfCAKfCIXhUIgiSIYfCIZIBSFQiiJIhQgF3wgC3wiF3wgBXwiICAPIBp8Ig8gHyAOIBuFQgGJIg4gIXwgCHwiGoVCIIkiG3wiHyAOhUIoiSIOIBp8IAx8IhogG4VCMIkiG4VCIIkiISAdIB4gDyAVhUIBiSIPIBx8IAF8IhWFQiCJIhx8Ih0gD4VCKIkiDyAVfCADfCIVIByFQjCJIhwgHXwiHXwiHiAWhUIoiSIWICB8IA18IiAgIYVCMIkiISAefCIeIBogFyAYhUIwiSIXIBl8IhggFIVCAYkiFHwgCXwiGSAchUIgiSIaICR8IhwgFIVCKIkiFCAZfCACfCIZIBqFQjCJIhogHSAPhUIBiSIPICJ8IAR8Ih0gF4VCIIkiFyAbIB98Iht8Ih8gD4VCKIkiDyAdfCASfCIdIBeFQjCJIhcgH3wiHyAPhUIBiSIPIBsgDoVCAYkiDiAVfCATfCIVICOFQiCJIhsgGHwiGCAOhUIoiSIOIBV8IBB8IhV8IAx8IiKFQiCJIiN8IiQgD4VCKIkiDyAifCAHfCIiICOFQjCJIiMgJHwiJCAPhUIBiSIPIBogHHwiGiAVIBuFQjCJIhUgHiAWhUIBiSIWIB18IAR8IhuFQiCJIhx8Ih0gFoVCKIkiFiAbfCAQfCIbfCABfCIeIBUgGHwiFSAXIBogFIVCAYkiFCAgfCATfCIYhUIgiSIXfCIaIBSFQiiJIhQgGHwgCXwiGCAXhUIwiSIXhUIgiSIgIB8gISAVIA6FQgGJIg4gGXwgCnwiFYVCIIkiGXwiHyAOhUIoiSIOIBV8IA18IhUgGYVCMIkiGSAffCIffCIhIA+FQiiJIg8gHnwgBXwiHiAghUIwiSIgICF8IiEgGyAchUIwiSIbIB18IhwgFoVCAYkiFiAYfCADfCIYIBmFQiCJIhkgJHwiHSAWhUIoiSIWIBh8IBJ8IhggGYVCMIkiGSAfIA6FQgGJIg4gInwgAnwiHyAbhUIgiSIbIBcgGnwiF3wiGiAOhUIoiSIOIB98IAZ8Ih8gG4VCMIkiGyAafCIaIA6FQgGJIg4gFSAXIBSFQgGJIhR8IAh8IhUgI4VCIIkiFyAcfCIcIBSFQiiJIhQgFXwgC3wiFXwgBXwiIoVCIIkiI3wiJCAOhUIoiSIOICJ8IAh8IiIgGiAgIBUgF4VCMIkiFSAcfCIXIBSFQgGJIhQgGHwgCXwiGIVCIIkiHHwiGiAUhUIoiSIUIBh8IAZ8IhggHIVCMIkiHCAafCIaIBSFQgGJIhR8IAR8IiAgGSAdfCIZIBUgISAPhUIBiSIPIB98IAN8Ih2FQiCJIhV8Ih8gD4VCKIkiDyAdfCACfCIdIBWFQjCJIhWFQiCJIiEgFyAbIBkgFoVCAYkiFiAefCABfCIZhUIgiSIbfCIXIBaFQiiJIhYgGXwgE3wiGSAbhUIwiSIbIBd8Ihd8Ih4gFIVCKIkiFCAgfCAMfCIgICGFQjCJIiEgHnwiHiAiICOFQjCJIiIgJHwiIyAOhUIBiSIOIB18IBJ8Ih0gG4VCIIkiGyAafCIaIA6FQiiJIg4gHXwgC3wiHSAbhUIwiSIbIBcgFoVCAYkiFiAYfCANfCIXICKFQiCJIhggFSAffCIVfCIfIBaFQiiJIhYgF3wgEHwiFyAYhUIwiSIYIB98Ih8gFoVCAYkiFiAVIA+FQgGJIg8gGXwgCnwiFSAchUIgiSIZICN8IhwgD4VCKIkiDyAVfCAHfCIVfCASfCIihUIgiSIjfCIkIBaFQiiJIhYgInwgBXwiIiAjhUIwiSIjICR8IiQgFoVCAYkiFiAbIBp8IhogFSAZhUIwiSIVIB4gFIVCAYkiFCAXfCADfCIXhUIgiSIZfCIbIBSFQiiJIhQgF3wgB3wiF3wgAnwiHiAVIBx8IhUgGCAaIA6FQgGJIg4gIHwgC3wiGoVCIIkiGHwiHCAOhUIoiSIOIBp8IAR8IhogGIVCMIkiGIVCIIkiICAfICEgFSAPhUIBiSIPIB18IAZ8IhWFQiCJIh18Ih8gD4VCKIkiDyAVfCAKfCIVIB2FQjCJIh0gH3wiH3wiISAWhUIoiSIWIB58IAx8Ih4gIIVCMIkiICAhfCIhIBogFyAZhUIwiSIXIBt8IhkgFIVCAYkiFHwgEHwiGiAdhUIgiSIbICR8Ih0gFIVCKIkiFCAafCAJfCIaIBuFQjCJIhsgHyAPhUIBiSIPICJ8IBN8Ih8gF4VCIIkiFyAYIBx8Ihh8IhwgD4VCKIkiDyAffCABfCIfIBeFQjCJIhcgHHwiHCAPhUIBiSIPIBggDoVCAYkiDiAVfCAIfCIVICOFQiCJIhggGXwiGSAOhUIoiSIOIBV8IA18IhV8IA18IiKFQiCJIiN8IiQgD4VCKIkiDyAifCAMfCIiICOFQjCJIiMgJHwiJCAPhUIBiSIPIBsgHXwiGyAVIBiFQjCJIhUgISAWhUIBiSIWIB98IBB8IhiFQiCJIh18Ih8gFoVCKIkiFiAYfCAIfCIYfCASfCIhIBUgGXwiFSAXIBsgFIVCAYkiFCAefCAHfCIZhUIgiSIXfCIbIBSFQiiJIhQgGXwgAXwiGSAXhUIwiSIXhUIgiSIeIBwgICAVIA6FQgGJIg4gGnwgAnwiFYVCIIkiGnwiHCAOhUIoiSIOIBV8IAV8IhUgGoVCMIkiGiAcfCIcfCIgIA+FQiiJIg8gIXwgBHwiISAehUIwiSIeICB8IiAgGCAdhUIwiSIYIB98Ih0gFoVCAYkiFiAZfCAGfCIZIBqFQiCJIhogJHwiHyAWhUIoiSIWIBl8IBN8IhkgGoVCMIkiGiAcIA6FQgGJIg4gInwgCXwiHCAYhUIgiSIYIBcgG3wiF3wiGyAOhUIoiSIOIBx8IAN8IhwgGIVCMIkiGCAbfCIbIA6FQgGJIg4gFSAXIBSFQgGJIhR8IAt8IhUgI4VCIIkiFyAdfCIdIBSFQiiJIhQgFXwgCnwiFXwgBHwiIoVCIIkiI3wiJCAOhUIoiSIOICJ8IAl8IiIgGyAeIBUgF4VCMIkiFSAdfCIXIBSFQgGJIhQgGXwgDHwiGYVCIIkiHXwiGyAUhUIoiSIUIBl8IAp8IhkgHYVCMIkiHSAbfCIbIBSFQgGJIhR8IAN8Ih4gGiAffCIaIBUgICAPhUIBiSIPIBx8IAd8IhyFQiCJIhV8Ih8gD4VCKIkiDyAcfCAQfCIcIBWFQjCJIhWFQiCJIiAgFyAYIBogFoVCAYkiFiAhfCATfCIahUIgiSIYfCIXIBaFQiiJIhYgGnwgDXwiGiAYhUIwiSIYIBd8Ihd8IiEgFIVCKIkiFCAefCAFfCIeICCFQjCJIiAgIXwiISAiICOFQjCJIiIgJHwiIyAOhUIBiSIOIBx8IAt8IhwgGIVCIIkiGCAbfCIbIA6FQiiJIg4gHHwgEnwiHCAYhUIwiSIYIBcgFoVCAYkiFiAZfCABfCIXICKFQiCJIhkgFSAffCIVfCIfIBaFQiiJIhYgF3wgBnwiFyAZhUIwiSIZIB98Ih8gFoVCAYkiFiAVIA+FQgGJIg8gGnwgCHwiFSAdhUIgiSIaICN8Ih0gD4VCKIkiDyAVfCACfCIVfCANfCIihUIgiSIjfCIkIBaFQiiJIhYgInwgCXwiIiAjhUIwiSIjICR8IiQgFoVCAYkiFiAYIBt8IhggFSAahUIwiSIVICEgFIVCAYkiFCAXfCASfCIXhUIgiSIafCIbIBSFQiiJIhQgF3wgCHwiF3wgB3wiISAVIB18IhUgGSAYIA6FQgGJIg4gHnwgBnwiGIVCIIkiGXwiHSAOhUIoiSIOIBh8IAt8IhggGYVCMIkiGYVCIIkiHiAfICAgFSAPhUIBiSIPIBx8IAp8IhWFQiCJIhx8Ih8gD4VCKIkiDyAVfCAEfCIVIByFQjCJIhwgH3wiH3wiICAWhUIoiSIWICF8IAN8IiEgHoVCMIkiHiAgfCIgIBggFyAahUIwiSIXIBt8IhogFIVCAYkiFHwgBXwiGCAchUIgiSIbICR8IhwgFIVCKIkiFCAYfCABfCIYIBuFQjCJIhsgHyAPhUIBiSIPICJ8IAx8Ih8gF4VCIIkiFyAZIB18Ihl8Ih0gD4VCKIkiDyAffCATfCIfIBeFQjCJIhcgHXwiHSAPhUIBiSIPIBkgDoVCAYkiDiAVfCAQfCIVICOFQiCJIhkgGnwiGiAOhUIoiSIOIBV8IAJ8IhV8IBN8IiKFQiCJIiN8IiQgD4VCKIkiDyAifCASfCIiICOFQjCJIiMgJHwiJCAPhUIBiSIPIBsgHHwiGyAVIBmFQjCJIhUgICAWhUIBiSIWIB98IAt8IhmFQiCJIhx8Ih8gFoVCKIkiFiAZfCACfCIZfCAJfCIgIBUgGnwiFSAXIBsgFIVCAYkiFCAhfCAFfCIahUIgiSIXfCIbIBSFQiiJIhQgGnwgA3wiGiAXhUIwiSIXhUIgiSIhIB0gHiAVIA6FQgGJIg4gGHwgEHwiFYVCIIkiGHwiHSAOhUIoiSIOIBV8IAF8IhUgGIVCMIkiGCAdfCIdfCIeIA+FQiiJIg8gIHwgDXwiICAhhUIwiSIhIB58Ih4gGSAchUIwiSIZIB98IhwgFoVCAYkiFiAafCAIfCIaIBiFQiCJIhggJHwiHyAWhUIoiSIWIBp8IAp8IhogGIVCMIkiGCAdIA6FQgGJIg4gInwgBHwiHSAZhUIgiSIZIBcgG3wiF3wiGyAOhUIoiSIOIB18IAd8Ih0gGYVCMIkiGSAbfCIbIA6FQgGJIg4gFSAXIBSFQgGJIhR8IAx8IhUgI4VCIIkiFyAcfCIcIBSFQiiJIhQgFXwgBnwiFXwgEnwiIoVCIIkiI3wiJCAOhUIoiSIOICJ8IBN8IiIgGyAhIBUgF4VCMIkiFSAcfCIXIBSFQgGJIhQgGnwgBnwiGoVCIIkiHHwiGyAUhUIoiSIUIBp8IBB8IhogHIVCMIkiHCAbfCIbIBSFQgGJIhR8IA18IiEgGCAffCIYIBUgHiAPhUIBiSIPIB18IAJ8Ih2FQiCJIhV8Ih4gD4VCKIkiDyAdfCABfCIdIBWFQjCJIhWFQiCJIh8gFyAZIBggFoVCAYkiFiAgfCADfCIYhUIgiSIZfCIXIBaFQiiJIhYgGHwgBHwiGCAZhUIwiSIZIBd8Ihd8IiAgFIVCKIkiFCAhfCAIfCIhIB+FQjCJIh8gIHwiICAiICOFQjCJIiIgJHwiIyAOhUIBiSIOIB18IAd8Ih0gGYVCIIkiGSAbfCIbIA6FQiiJIg4gHXwgDHwiHSAZhUIwiSIZIBcgFoVCAYkiFiAafCALfCIXICKFQiCJIhogFSAefCIVfCIeIBaFQiiJIhYgF3wgCXwiFyAahUIwiSIaIB58Ih4gFoVCAYkiFiAVIA+FQgGJIg8gGHwgBXwiFSAchUIgiSIYICN8IhwgD4VCKIkiDyAVfCAKfCIVfCACfCIChUIgiSIifCIjIBaFQiiJIhYgAnwgC3wiAiAihUIwiSILICN8IiIgFoVCAYkiFiAZIBt8IhkgFSAYhUIwiSIVICAgFIVCAYkiFCAXfCANfCINhUIgiSIXfCIYIBSFQiiJIhQgDXwgBXwiBXwgEHwiECAVIBx8Ig0gGiAZIA6FQgGJIg4gIXwgDHwiDIVCIIkiFXwiGSAOhUIoiSIOIAx8IBJ8IhIgFYVCMIkiDIVCIIkiFSAeIB8gDSAPhUIBiSINIB18IAl8IgmFQiCJIg98IhogDYVCKIkiDSAJfCAIfCIJIA+FQjCJIgggGnwiD3wiGiAWhUIoiSIWIBB8IAd8IhAgEYUgDCAZfCIHIA6FQgGJIgwgCXwgCnwiCiALhUIgiSILIAUgF4VCMIkiBSAYfCIJfCIOIAyFQiiJIgwgCnwgE3wiEyALhUIwiSIKIA58IguFNwOAiQFBACADIAYgDyANhUIBiSINIAJ8fCICIAWFQiCJIgUgB3wiBiANhUIoiSIHIAJ8fCICQQApA4iJAYUgBCABIBIgCSAUhUIBiSIDfHwiASAIhUIgiSISICJ8IgkgA4VCKIkiAyABfHwiASAShUIwiSIEIAl8IhKFNwOIiQFBACATQQApA5CJAYUgECAVhUIwiSIQIBp8IhOFNwOQiQFBACABQQApA5iJAYUgAiAFhUIwiSICIAZ8IgGFNwOYiQFBACASIAOFQgGJQQApA6CJAYUgAoU3A6CJAUEAIBMgFoVCAYlBACkDqIkBhSAKhTcDqIkBQQAgASAHhUIBiUEAKQOwiQGFIASFNwOwiQFBACALIAyFQgGJQQApA7iJAYUgEIU3A7iJAQvdAgUBfwF+AX8BfgJ/IwBBwABrIgAkAAJAQQApA9CJAUIAUg0AQQBBACkDwIkBIgFBACgC4IoBIgKsfCIDNwPAiQFBAEEAKQPIiQEgAyABVK18NwPIiQECQEEALQDoigFFDQBBAEJ/NwPYiQELQQBCfzcD0IkBAkAgAkH/AEoNAEEAIQQDQCACIARqQeCJAWpBADoAACAEQQFqIgRBgAFBACgC4IoBIgJrSA0ACwtB4IkBEAIgAEEAKQOAiQE3AwAgAEEAKQOIiQE3AwggAEEAKQOQiQE3AxAgAEEAKQOYiQE3AxggAEEAKQOgiQE3AyAgAEEAKQOoiQE3AyggAEEAKQOwiQE3AzAgAEEAKQO4iQE3AzhBACgC5IoBIgVBAUgNAEEAIQRBACECA0AgBEGACWogACAEai0AADoAACAEQQFqIQQgBSACQQFqIgJB/wFxSg0ACwsgAEHAAGokAAv9AwMBfwF+AX8jAEGAAWsiAiQAQQBBgQI7AfKKAUEAIAE6APGKAUEAIAA6APCKAUGQfiEAA0AgAEGAiwFqQgA3AAAgAEH4igFqQgA3AAAgAEHwigFqQgA3AAAgAEEYaiIADQALQQAhAEEAQQApA/CKASIDQoiS853/zPmE6gCFNwOAiQFBAEEAKQP4igFCu86qptjQ67O7f4U3A4iJAUEAQQApA4CLAUKr8NP0r+68tzyFNwOQiQFBAEEAKQOIiwFC8e30+KWn/aelf4U3A5iJAUEAQQApA5CLAULRhZrv+s+Uh9EAhTcDoIkBQQBBACkDmIsBQp/Y+dnCkdqCm3+FNwOoiQFBAEEAKQOgiwFC6/qG2r+19sEfhTcDsIkBQQBBACkDqIsBQvnC+JuRo7Pw2wCFNwO4iQFBACADp0H/AXE2AuSKAQJAIAFBAUgNACACQgA3A3ggAkIANwNwIAJCADcDaCACQgA3A2AgAkIANwNYIAJCADcDUCACQgA3A0ggAkIANwNAIAJCADcDOCACQgA3AzAgAkIANwMoIAJCADcDICACQgA3AxggAkIANwMQIAJCADcDCCACQgA3AwBBACEEA0AgAiAAaiAAQYAJai0AADoAACAAQQFqIQAgBEEBaiIEQf8BcSABSA0ACyACQYABEAELIAJBgAFqJAALEgAgAEEDdkH/P3EgAEEQdhAECwkAQYAJIAAQAQsGAEGAiQELGwAgAUEDdkH/P3EgAUEQdhAEQYAJIAAQARADCwsLAQBBgAgLBPAAAAA=", ji = "c6f286e6", Ri = { - name: Mi, - data: qi, - hash: ji +var zi = "argon2", Ji = "AGFzbQEAAAABKQVgAX8Bf2AAAX9gEH9/f39/f39/f39/f39/f38AYAR/f39/AGACf38AAwYFAAECAwQFBgEBAoCAAgYIAX8BQZCoBAsHQQQGbWVtb3J5AgASSGFzaF9TZXRNZW1vcnlTaXplAAAOSGFzaF9HZXRCdWZmZXIAAQ5IYXNoX0NhbGN1bGF0ZQAECvEyBVgBAn9BACEBAkAgAEEAKAKICCICRg0AAkAgACACayIAQRB2IABBgIB8cSAASWoiAEAAQX9HDQBB/wHADwtBACEBQQBBACkDiAggAEEQdK18NwOICAsgAcALcAECfwJAQQAoAoAIIgANAEEAPwBBEHQiADYCgAhBACgCiAgiAUGAgCBGDQACQEGAgCAgAWsiAEEQdiAAQYCAfHEgAElqIgBAAEF/Rw0AQQAPC0EAQQApA4gIIABBEHStfDcDiAhBACgCgAghAAsgAAvcDgECfiAAIAQpAwAiECAAKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAMIBAgDCkDAIVCIIkiEDcDACAIIBAgCCkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgBCAQIAQpAwCFQiiJIhA3AwAgACAQIAApAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAwgECAMKQMAhUIwiSIQNwMAIAggECAIKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAEIBAgBCkDAIVCAYk3AwAgASAFKQMAIhAgASkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDSAQIA0pAwCFQiCJIhA3AwAgCSAQIAkpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAUgECAFKQMAhUIoiSIQNwMAIAEgECABKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACANIBAgDSkDAIVCMIkiEDcDACAJIBAgCSkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBSAQIAUpAwCFQgGJNwMAIAIgBikDACIQIAIpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIA4gECAOKQMAhUIgiSIQNwMAIAogECAKKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAGIBAgBikDAIVCKIkiEDcDACACIBAgAikDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgDiAQIA4pAwCFQjCJIhA3AwAgCiAQIAopAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAYgECAGKQMAhUIBiTcDACADIAcpAwAiECADKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAPIBAgDykDAIVCIIkiEDcDACALIBAgCykDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgByAQIAcpAwCFQiiJIhA3AwAgAyAQIAMpAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIA8gECAPKQMAhUIwiSIQNwMAIAsgECALKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAHIBAgBykDAIVCAYk3AwAgACAFKQMAIhAgACkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDyAQIA8pAwCFQiCJIhA3AwAgCiAQIAopAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAUgECAFKQMAhUIoiSIQNwMAIAAgECAAKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAPIBAgDykDAIVCMIkiEDcDACAKIBAgCikDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBSAQIAUpAwCFQgGJNwMAIAEgBikDACIQIAEpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAwgECAMKQMAhUIgiSIQNwMAIAsgECALKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAGIBAgBikDAIVCKIkiEDcDACABIBAgASkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgDCAQIAwpAwCFQjCJIhA3AwAgCyAQIAspAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAYgECAGKQMAhUIBiTcDACACIAcpAwAiECACKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACANIBAgDSkDAIVCIIkiEDcDACAIIBAgCCkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgByAQIAcpAwCFQiiJIhA3AwAgAiAQIAIpAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIA0gECANKQMAhUIwiSIQNwMAIAggECAIKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAHIBAgBykDAIVCAYk3AwAgAyAEKQMAIhAgAykDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDiAQIA4pAwCFQiCJIhA3AwAgCSAQIAkpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAQgECAEKQMAhUIoiSIQNwMAIAMgECADKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAOIBAgDikDAIVCMIkiEDcDACAJIBAgCSkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBCAQIAQpAwCFQgGJNwMAC98aAQN/QQAhBEEAIAIpAwAgASkDAIU3A5AIQQAgAikDCCABKQMIhTcDmAhBACACKQMQIAEpAxCFNwOgCEEAIAIpAxggASkDGIU3A6gIQQAgAikDICABKQMghTcDsAhBACACKQMoIAEpAyiFNwO4CEEAIAIpAzAgASkDMIU3A8AIQQAgAikDOCABKQM4hTcDyAhBACACKQNAIAEpA0CFNwPQCEEAIAIpA0ggASkDSIU3A9gIQQAgAikDUCABKQNQhTcD4AhBACACKQNYIAEpA1iFNwPoCEEAIAIpA2AgASkDYIU3A/AIQQAgAikDaCABKQNohTcD+AhBACACKQNwIAEpA3CFNwOACUEAIAIpA3ggASkDeIU3A4gJQQAgAikDgAEgASkDgAGFNwOQCUEAIAIpA4gBIAEpA4gBhTcDmAlBACACKQOQASABKQOQAYU3A6AJQQAgAikDmAEgASkDmAGFNwOoCUEAIAIpA6ABIAEpA6ABhTcDsAlBACACKQOoASABKQOoAYU3A7gJQQAgAikDsAEgASkDsAGFNwPACUEAIAIpA7gBIAEpA7gBhTcDyAlBACACKQPAASABKQPAAYU3A9AJQQAgAikDyAEgASkDyAGFNwPYCUEAIAIpA9ABIAEpA9ABhTcD4AlBACACKQPYASABKQPYAYU3A+gJQQAgAikD4AEgASkD4AGFNwPwCUEAIAIpA+gBIAEpA+gBhTcD+AlBACACKQPwASABKQPwAYU3A4AKQQAgAikD+AEgASkD+AGFNwOICkEAIAIpA4ACIAEpA4AChTcDkApBACACKQOIAiABKQOIAoU3A5gKQQAgAikDkAIgASkDkAKFNwOgCkEAIAIpA5gCIAEpA5gChTcDqApBACACKQOgAiABKQOgAoU3A7AKQQAgAikDqAIgASkDqAKFNwO4CkEAIAIpA7ACIAEpA7AChTcDwApBACACKQO4AiABKQO4AoU3A8gKQQAgAikDwAIgASkDwAKFNwPQCkEAIAIpA8gCIAEpA8gChTcD2ApBACACKQPQAiABKQPQAoU3A+AKQQAgAikD2AIgASkD2AKFNwPoCkEAIAIpA+ACIAEpA+AChTcD8ApBACACKQPoAiABKQPoAoU3A/gKQQAgAikD8AIgASkD8AKFNwOAC0EAIAIpA/gCIAEpA/gChTcDiAtBACACKQOAAyABKQOAA4U3A5ALQQAgAikDiAMgASkDiAOFNwOYC0EAIAIpA5ADIAEpA5ADhTcDoAtBACACKQOYAyABKQOYA4U3A6gLQQAgAikDoAMgASkDoAOFNwOwC0EAIAIpA6gDIAEpA6gDhTcDuAtBACACKQOwAyABKQOwA4U3A8ALQQAgAikDuAMgASkDuAOFNwPIC0EAIAIpA8ADIAEpA8ADhTcD0AtBACACKQPIAyABKQPIA4U3A9gLQQAgAikD0AMgASkD0AOFNwPgC0EAIAIpA9gDIAEpA9gDhTcD6AtBACACKQPgAyABKQPgA4U3A/ALQQAgAikD6AMgASkD6AOFNwP4C0EAIAIpA/ADIAEpA/ADhTcDgAxBACACKQP4AyABKQP4A4U3A4gMQQAgAikDgAQgASkDgASFNwOQDEEAIAIpA4gEIAEpA4gEhTcDmAxBACACKQOQBCABKQOQBIU3A6AMQQAgAikDmAQgASkDmASFNwOoDEEAIAIpA6AEIAEpA6AEhTcDsAxBACACKQOoBCABKQOoBIU3A7gMQQAgAikDsAQgASkDsASFNwPADEEAIAIpA7gEIAEpA7gEhTcDyAxBACACKQPABCABKQPABIU3A9AMQQAgAikDyAQgASkDyASFNwPYDEEAIAIpA9AEIAEpA9AEhTcD4AxBACACKQPYBCABKQPYBIU3A+gMQQAgAikD4AQgASkD4ASFNwPwDEEAIAIpA+gEIAEpA+gEhTcD+AxBACACKQPwBCABKQPwBIU3A4ANQQAgAikD+AQgASkD+ASFNwOIDUEAIAIpA4AFIAEpA4AFhTcDkA1BACACKQOIBSABKQOIBYU3A5gNQQAgAikDkAUgASkDkAWFNwOgDUEAIAIpA5gFIAEpA5gFhTcDqA1BACACKQOgBSABKQOgBYU3A7ANQQAgAikDqAUgASkDqAWFNwO4DUEAIAIpA7AFIAEpA7AFhTcDwA1BACACKQO4BSABKQO4BYU3A8gNQQAgAikDwAUgASkDwAWFNwPQDUEAIAIpA8gFIAEpA8gFhTcD2A1BACACKQPQBSABKQPQBYU3A+ANQQAgAikD2AUgASkD2AWFNwPoDUEAIAIpA+AFIAEpA+AFhTcD8A1BACACKQPoBSABKQPoBYU3A/gNQQAgAikD8AUgASkD8AWFNwOADkEAIAIpA/gFIAEpA/gFhTcDiA5BACACKQOABiABKQOABoU3A5AOQQAgAikDiAYgASkDiAaFNwOYDkEAIAIpA5AGIAEpA5AGhTcDoA5BACACKQOYBiABKQOYBoU3A6gOQQAgAikDoAYgASkDoAaFNwOwDkEAIAIpA6gGIAEpA6gGhTcDuA5BACACKQOwBiABKQOwBoU3A8AOQQAgAikDuAYgASkDuAaFNwPIDkEAIAIpA8AGIAEpA8AGhTcD0A5BACACKQPIBiABKQPIBoU3A9gOQQAgAikD0AYgASkD0AaFNwPgDkEAIAIpA9gGIAEpA9gGhTcD6A5BACACKQPgBiABKQPgBoU3A/AOQQAgAikD6AYgASkD6AaFNwP4DkEAIAIpA/AGIAEpA/AGhTcDgA9BACACKQP4BiABKQP4BoU3A4gPQQAgAikDgAcgASkDgAeFNwOQD0EAIAIpA4gHIAEpA4gHhTcDmA9BACACKQOQByABKQOQB4U3A6APQQAgAikDmAcgASkDmAeFNwOoD0EAIAIpA6AHIAEpA6AHhTcDsA9BACACKQOoByABKQOoB4U3A7gPQQAgAikDsAcgASkDsAeFNwPAD0EAIAIpA7gHIAEpA7gHhTcDyA9BACACKQPAByABKQPAB4U3A9APQQAgAikDyAcgASkDyAeFNwPYD0EAIAIpA9AHIAEpA9AHhTcD4A9BACACKQPYByABKQPYB4U3A+gPQQAgAikD4AcgASkD4AeFNwPwD0EAIAIpA+gHIAEpA+gHhTcD+A9BACACKQPwByABKQPwB4U3A4AQQQAgAikD+AcgASkD+AeFNwOIEEGQCEGYCEGgCEGoCEGwCEG4CEHACEHICEHQCEHYCEHgCEHoCEHwCEH4CEGACUGICRACQZAJQZgJQaAJQagJQbAJQbgJQcAJQcgJQdAJQdgJQeAJQegJQfAJQfgJQYAKQYgKEAJBkApBmApBoApBqApBsApBuApBwApByApB0ApB2ApB4ApB6ApB8ApB+ApBgAtBiAsQAkGQC0GYC0GgC0GoC0GwC0G4C0HAC0HIC0HQC0HYC0HgC0HoC0HwC0H4C0GADEGIDBACQZAMQZgMQaAMQagMQbAMQbgMQcAMQcgMQdAMQdgMQeAMQegMQfAMQfgMQYANQYgNEAJBkA1BmA1BoA1BqA1BsA1BuA1BwA1ByA1B0A1B2A1B4A1B6A1B8A1B+A1BgA5BiA4QAkGQDkGYDkGgDkGoDkGwDkG4DkHADkHIDkHQDkHYDkHgDkHoDkHwDkH4DkGAD0GIDxACQZAPQZgPQaAPQagPQbAPQbgPQcAPQcgPQdAPQdgPQeAPQegPQfAPQfgPQYAQQYgQEAJBkAhBmAhBkAlBmAlBkApBmApBkAtBmAtBkAxBmAxBkA1BmA1BkA5BmA5BkA9BmA8QAkGgCEGoCEGgCUGoCUGgCkGoCkGgC0GoC0GgDEGoDEGgDUGoDUGgDkGoDkGgD0GoDxACQbAIQbgIQbAJQbgJQbAKQbgKQbALQbgLQbAMQbgMQbANQbgNQbAOQbgOQbAPQbgPEAJBwAhByAhBwAlByAlBwApByApBwAtByAtBwAxByAxBwA1ByA1BwA5ByA5BwA9ByA8QAkHQCEHYCEHQCUHYCUHQCkHYCkHQC0HYC0HQDEHYDEHQDUHYDUHQDkHYDkHQD0HYDxACQeAIQegIQeAJQegJQeAKQegKQeALQegLQeAMQegMQeANQegNQeAOQegOQeAPQegPEAJB8AhB+AhB8AlB+AlB8ApB+ApB8AtB+AtB8AxB+AxB8A1B+A1B8A5B+A5B8A9B+A8QAkGACUGICUGACkGICkGAC0GIC0GADEGIDEGADUGIDUGADkGIDkGAD0GID0GAEEGIEBACAkACQCADRQ0AA0AgACAEaiIDIAIgBGoiBSkDACABIARqIgYpAwCFIARBkAhqKQMAhSADKQMAhTcDACADQQhqIgMgBUEIaikDACAGQQhqKQMAhSAEQZgIaikDAIUgAykDAIU3AwAgBEEQaiIEQYAIRw0ADAILC0EAIQQDQCAAIARqIgMgAiAEaiIFKQMAIAEgBGoiBikDAIUgBEGQCGopAwCFNwMAIANBCGogBUEIaikDACAGQQhqKQMAhSAEQZgIaikDAIU3AwAgBEEQaiIEQYAIRw0ACwsL5QcMBX8BfgR/An4BfwF+AX8Bfgd/AX4DfwF+AkBBACgCgAgiAiABQQp0aiIDKAIIIAFHDQAgAygCDCEEIAMoAgAhBUEAIAMoAhQiBq03A7gQQQAgBK0iBzcDsBBBACAFIAEgBUECdG4iCGwiCUECdK03A6gQAkACQAJAAkAgBEUNAEF/IQogBUUNASAIQQNsIQsgCEECdCIErSEMIAWtIQ0gBkF/akECSSEOQgAhDwNAQQAgDzcDkBAgD6chEEIAIRFBACEBA0BBACARNwOgECAPIBGEUCIDIA5xIRIgBkEBRiAPUCITIAZBAkYgEUICVHFxciEUQX8gAUEBakEDcSAIbEF/aiATGyEVIAEgEHIhFiABIAhsIRcgA0EBdCEYQgAhGQNAQQBCADcDwBBBACAZNwOYECAYIQECQCASRQ0AQQBCATcDwBBBkBhBkBBBkCBBABADQZAYQZAYQZAgQQAQA0ECIQELAkAgASAITw0AIAQgGaciGmwgF2ogAWohAwNAIANBACAEIAEbQQAgEVAiGxtqQX9qIRwCQAJAIBQNAEEAKAKACCICIBxBCnQiHGohCgwBCwJAIAFB/wBxIgINAEEAQQApA8AQQgF8NwPAEEGQGEGQEEGQIEEAEANBkBhBkBhBkCBBABADCyAcQQp0IRwgAkEDdEGQGGohCkEAKAKACCECCyACIANBCnRqIAIgHGogAiAKKQMAIh1CIIinIAVwIBogFhsiHCAEbCABIAFBACAZIBytUSIcGyIKIBsbIBdqIAogC2ogExsgAUUgHHJrIhsgFWqtIB1C/////w+DIh0gHX5CIIggG61+QiCIfSAMgqdqQQp0akEBEAMgA0EBaiEDIAggAUEBaiIBRw0ACwsgGUIBfCIZIA1SDQALIBFCAXwiEachASARQgRSDQALIA9CAXwiDyAHUg0AC0EAKAKACCECCyAJQQx0QYB4aiEXIAVBf2oiCkUNAgwBC0EAQgM3A6AQQQAgBEF/aq03A5AQQYB4IRcLIAIgF2ohGyAIQQx0IQhBACEcA0AgCCAcQQFqIhxsQYB4aiEEQQAhAQNAIBsgAWoiAyADKQMAIAIgBCABamopAwCFNwMAIANBCGoiAyADKQMAIAIgBCABQQhyamopAwCFNwMAIAFBCGohAyABQRBqIQEgA0H4B0kNAAsgHCAKRw0ACwsgAiAXaiEbQXghAQNAIAIgAWoiA0EIaiAbIAFqIgRBCGopAwA3AwAgA0EQaiAEQRBqKQMANwMAIANBGGogBEEYaikDADcDACADQSBqIARBIGopAwA3AwAgAUEgaiIBQfgHSQ0ACwsL", Yi = "e4cdc523", Mi = { + name: zi, + data: Ji, + hash: Yi +}, qi = "blake2b", ji = "AGFzbQEAAAABEQRgAAF/YAJ/fwBgAX8AYAAAAwoJAAECAwECAgABBQQBAQICBg4CfwFBsIsFC38AQYAICwdwCAZtZW1vcnkCAA5IYXNoX0dldEJ1ZmZlcgAACkhhc2hfRmluYWwAAwlIYXNoX0luaXQABQtIYXNoX1VwZGF0ZQAGDUhhc2hfR2V0U3RhdGUABw5IYXNoX0NhbGN1bGF0ZQAIClNUQVRFX1NJWkUDAQrTOAkFAEGACQvrAgIFfwF+AkAgAUEBSA0AAkACQAJAIAFBgAFBACgC4IoBIgJrIgNKDQAgASEEDAELQQBBADYC4IoBAkAgAkH/AEoNACACQeCJAWohBSAAIQRBACEGA0AgBSAELQAAOgAAIARBAWohBCAFQQFqIQUgAyAGQQFqIgZB/wFxSg0ACwtBAEEAKQPAiQEiB0KAAXw3A8CJAUEAQQApA8iJASAHQv9+Vq18NwPIiQFB4IkBEAIgACADaiEAAkAgASADayIEQYEBSA0AIAIgAWohBQNAQQBBACkDwIkBIgdCgAF8NwPAiQFBAEEAKQPIiQEgB0L/flatfDcDyIkBIAAQAiAAQYABaiEAIAVBgH9qIgVBgAJLDQALIAVBgH9qIQQMAQsgBEEATA0BC0EAIQUDQCAFQQAoAuCKAWpB4IkBaiAAIAVqLQAAOgAAIAQgBUEBaiIFQf8BcUoNAAsLQQBBACgC4IoBIARqNgLgigELC78uASR+QQBBACkD0IkBQQApA7CJASIBQQApA5CJAXwgACkDICICfCIDhULr+obav7X2wR+FQiCJIgRCq/DT9K/uvLc8fCIFIAGFQiiJIgYgA3wgACkDKCIBfCIHIASFQjCJIgggBXwiCSAGhUIBiSIKQQApA8iJAUEAKQOoiQEiBEEAKQOIiQF8IAApAxAiA3wiBYVCn9j52cKR2oKbf4VCIIkiC0K7zqqm2NDrs7t/fCIMIASFQiiJIg0gBXwgACkDGCIEfCIOfCAAKQNQIgV8Ig9BACkDwIkBQQApA6CJASIQQQApA4CJASIRfCAAKQMAIgZ8IhKFQtGFmu/6z5SH0QCFQiCJIhNCiJLznf/M+YTqAHwiFCAQhUIoiSIVIBJ8IAApAwgiEHwiFiAThUIwiSIXhUIgiSIYQQApA9iJAUEAKQO4iQEiE0EAKQOYiQF8IAApAzAiEnwiGYVC+cL4m5Gjs/DbAIVCIIkiGkLx7fT4paf9p6V/fCIbIBOFQiiJIhwgGXwgACkDOCITfCIZIBqFQjCJIhogG3wiG3wiHSAKhUIoiSIeIA98IAApA1giCnwiDyAYhUIwiSIYIB18Ih0gDiALhUIwiSIOIAx8Ih8gDYVCAYkiDCAWfCAAKQNAIgt8Ig0gGoVCIIkiFiAJfCIaIAyFQiiJIiAgDXwgACkDSCIJfCIhIBaFQjCJIhYgGyAchUIBiSIMIAd8IAApA2AiB3wiDSAOhUIgiSIOIBcgFHwiFHwiFyAMhUIoiSIbIA18IAApA2giDHwiHCAOhUIwiSIOIBd8IhcgG4VCAYkiGyAZIBQgFYVCAYkiFHwgACkDcCINfCIVIAiFQiCJIhkgH3wiHyAUhUIoiSIUIBV8IAApA3giCHwiFXwgDHwiIoVCIIkiI3wiJCAbhUIoiSIbICJ8IBJ8IiIgFyAYIBUgGYVCMIkiFSAffCIZIBSFQgGJIhQgIXwgDXwiH4VCIIkiGHwiFyAUhUIoiSIUIB98IAV8Ih8gGIVCMIkiGCAXfCIXIBSFQgGJIhR8IAF8IiEgFiAafCIWIBUgHSAehUIBiSIaIBx8IAl8IhyFQiCJIhV8Ih0gGoVCKIkiGiAcfCAIfCIcIBWFQjCJIhWFQiCJIh4gGSAOIBYgIIVCAYkiFiAPfCACfCIPhUIgiSIOfCIZIBaFQiiJIhYgD3wgC3wiDyAOhUIwiSIOIBl8Ihl8IiAgFIVCKIkiFCAhfCAEfCIhIB6FQjCJIh4gIHwiICAiICOFQjCJIiIgJHwiIyAbhUIBiSIbIBx8IAp8IhwgDoVCIIkiDiAXfCIXIBuFQiiJIhsgHHwgE3wiHCAOhUIwiSIOIBkgFoVCAYkiFiAffCAQfCIZICKFQiCJIh8gFSAdfCIVfCIdIBaFQiiJIhYgGXwgB3wiGSAfhUIwiSIfIB18Ih0gFoVCAYkiFiAVIBqFQgGJIhUgD3wgBnwiDyAYhUIgiSIYICN8IhogFYVCKIkiFSAPfCADfCIPfCAHfCIihUIgiSIjfCIkIBaFQiiJIhYgInwgBnwiIiAjhUIwiSIjICR8IiQgFoVCAYkiFiAOIBd8Ig4gDyAYhUIwiSIPICAgFIVCAYkiFCAZfCAKfCIXhUIgiSIYfCIZIBSFQiiJIhQgF3wgC3wiF3wgBXwiICAPIBp8Ig8gHyAOIBuFQgGJIg4gIXwgCHwiGoVCIIkiG3wiHyAOhUIoiSIOIBp8IAx8IhogG4VCMIkiG4VCIIkiISAdIB4gDyAVhUIBiSIPIBx8IAF8IhWFQiCJIhx8Ih0gD4VCKIkiDyAVfCADfCIVIByFQjCJIhwgHXwiHXwiHiAWhUIoiSIWICB8IA18IiAgIYVCMIkiISAefCIeIBogFyAYhUIwiSIXIBl8IhggFIVCAYkiFHwgCXwiGSAchUIgiSIaICR8IhwgFIVCKIkiFCAZfCACfCIZIBqFQjCJIhogHSAPhUIBiSIPICJ8IAR8Ih0gF4VCIIkiFyAbIB98Iht8Ih8gD4VCKIkiDyAdfCASfCIdIBeFQjCJIhcgH3wiHyAPhUIBiSIPIBsgDoVCAYkiDiAVfCATfCIVICOFQiCJIhsgGHwiGCAOhUIoiSIOIBV8IBB8IhV8IAx8IiKFQiCJIiN8IiQgD4VCKIkiDyAifCAHfCIiICOFQjCJIiMgJHwiJCAPhUIBiSIPIBogHHwiGiAVIBuFQjCJIhUgHiAWhUIBiSIWIB18IAR8IhuFQiCJIhx8Ih0gFoVCKIkiFiAbfCAQfCIbfCABfCIeIBUgGHwiFSAXIBogFIVCAYkiFCAgfCATfCIYhUIgiSIXfCIaIBSFQiiJIhQgGHwgCXwiGCAXhUIwiSIXhUIgiSIgIB8gISAVIA6FQgGJIg4gGXwgCnwiFYVCIIkiGXwiHyAOhUIoiSIOIBV8IA18IhUgGYVCMIkiGSAffCIffCIhIA+FQiiJIg8gHnwgBXwiHiAghUIwiSIgICF8IiEgGyAchUIwiSIbIB18IhwgFoVCAYkiFiAYfCADfCIYIBmFQiCJIhkgJHwiHSAWhUIoiSIWIBh8IBJ8IhggGYVCMIkiGSAfIA6FQgGJIg4gInwgAnwiHyAbhUIgiSIbIBcgGnwiF3wiGiAOhUIoiSIOIB98IAZ8Ih8gG4VCMIkiGyAafCIaIA6FQgGJIg4gFSAXIBSFQgGJIhR8IAh8IhUgI4VCIIkiFyAcfCIcIBSFQiiJIhQgFXwgC3wiFXwgBXwiIoVCIIkiI3wiJCAOhUIoiSIOICJ8IAh8IiIgGiAgIBUgF4VCMIkiFSAcfCIXIBSFQgGJIhQgGHwgCXwiGIVCIIkiHHwiGiAUhUIoiSIUIBh8IAZ8IhggHIVCMIkiHCAafCIaIBSFQgGJIhR8IAR8IiAgGSAdfCIZIBUgISAPhUIBiSIPIB98IAN8Ih2FQiCJIhV8Ih8gD4VCKIkiDyAdfCACfCIdIBWFQjCJIhWFQiCJIiEgFyAbIBkgFoVCAYkiFiAefCABfCIZhUIgiSIbfCIXIBaFQiiJIhYgGXwgE3wiGSAbhUIwiSIbIBd8Ihd8Ih4gFIVCKIkiFCAgfCAMfCIgICGFQjCJIiEgHnwiHiAiICOFQjCJIiIgJHwiIyAOhUIBiSIOIB18IBJ8Ih0gG4VCIIkiGyAafCIaIA6FQiiJIg4gHXwgC3wiHSAbhUIwiSIbIBcgFoVCAYkiFiAYfCANfCIXICKFQiCJIhggFSAffCIVfCIfIBaFQiiJIhYgF3wgEHwiFyAYhUIwiSIYIB98Ih8gFoVCAYkiFiAVIA+FQgGJIg8gGXwgCnwiFSAchUIgiSIZICN8IhwgD4VCKIkiDyAVfCAHfCIVfCASfCIihUIgiSIjfCIkIBaFQiiJIhYgInwgBXwiIiAjhUIwiSIjICR8IiQgFoVCAYkiFiAbIBp8IhogFSAZhUIwiSIVIB4gFIVCAYkiFCAXfCADfCIXhUIgiSIZfCIbIBSFQiiJIhQgF3wgB3wiF3wgAnwiHiAVIBx8IhUgGCAaIA6FQgGJIg4gIHwgC3wiGoVCIIkiGHwiHCAOhUIoiSIOIBp8IAR8IhogGIVCMIkiGIVCIIkiICAfICEgFSAPhUIBiSIPIB18IAZ8IhWFQiCJIh18Ih8gD4VCKIkiDyAVfCAKfCIVIB2FQjCJIh0gH3wiH3wiISAWhUIoiSIWIB58IAx8Ih4gIIVCMIkiICAhfCIhIBogFyAZhUIwiSIXIBt8IhkgFIVCAYkiFHwgEHwiGiAdhUIgiSIbICR8Ih0gFIVCKIkiFCAafCAJfCIaIBuFQjCJIhsgHyAPhUIBiSIPICJ8IBN8Ih8gF4VCIIkiFyAYIBx8Ihh8IhwgD4VCKIkiDyAffCABfCIfIBeFQjCJIhcgHHwiHCAPhUIBiSIPIBggDoVCAYkiDiAVfCAIfCIVICOFQiCJIhggGXwiGSAOhUIoiSIOIBV8IA18IhV8IA18IiKFQiCJIiN8IiQgD4VCKIkiDyAifCAMfCIiICOFQjCJIiMgJHwiJCAPhUIBiSIPIBsgHXwiGyAVIBiFQjCJIhUgISAWhUIBiSIWIB98IBB8IhiFQiCJIh18Ih8gFoVCKIkiFiAYfCAIfCIYfCASfCIhIBUgGXwiFSAXIBsgFIVCAYkiFCAefCAHfCIZhUIgiSIXfCIbIBSFQiiJIhQgGXwgAXwiGSAXhUIwiSIXhUIgiSIeIBwgICAVIA6FQgGJIg4gGnwgAnwiFYVCIIkiGnwiHCAOhUIoiSIOIBV8IAV8IhUgGoVCMIkiGiAcfCIcfCIgIA+FQiiJIg8gIXwgBHwiISAehUIwiSIeICB8IiAgGCAdhUIwiSIYIB98Ih0gFoVCAYkiFiAZfCAGfCIZIBqFQiCJIhogJHwiHyAWhUIoiSIWIBl8IBN8IhkgGoVCMIkiGiAcIA6FQgGJIg4gInwgCXwiHCAYhUIgiSIYIBcgG3wiF3wiGyAOhUIoiSIOIBx8IAN8IhwgGIVCMIkiGCAbfCIbIA6FQgGJIg4gFSAXIBSFQgGJIhR8IAt8IhUgI4VCIIkiFyAdfCIdIBSFQiiJIhQgFXwgCnwiFXwgBHwiIoVCIIkiI3wiJCAOhUIoiSIOICJ8IAl8IiIgGyAeIBUgF4VCMIkiFSAdfCIXIBSFQgGJIhQgGXwgDHwiGYVCIIkiHXwiGyAUhUIoiSIUIBl8IAp8IhkgHYVCMIkiHSAbfCIbIBSFQgGJIhR8IAN8Ih4gGiAffCIaIBUgICAPhUIBiSIPIBx8IAd8IhyFQiCJIhV8Ih8gD4VCKIkiDyAcfCAQfCIcIBWFQjCJIhWFQiCJIiAgFyAYIBogFoVCAYkiFiAhfCATfCIahUIgiSIYfCIXIBaFQiiJIhYgGnwgDXwiGiAYhUIwiSIYIBd8Ihd8IiEgFIVCKIkiFCAefCAFfCIeICCFQjCJIiAgIXwiISAiICOFQjCJIiIgJHwiIyAOhUIBiSIOIBx8IAt8IhwgGIVCIIkiGCAbfCIbIA6FQiiJIg4gHHwgEnwiHCAYhUIwiSIYIBcgFoVCAYkiFiAZfCABfCIXICKFQiCJIhkgFSAffCIVfCIfIBaFQiiJIhYgF3wgBnwiFyAZhUIwiSIZIB98Ih8gFoVCAYkiFiAVIA+FQgGJIg8gGnwgCHwiFSAdhUIgiSIaICN8Ih0gD4VCKIkiDyAVfCACfCIVfCANfCIihUIgiSIjfCIkIBaFQiiJIhYgInwgCXwiIiAjhUIwiSIjICR8IiQgFoVCAYkiFiAYIBt8IhggFSAahUIwiSIVICEgFIVCAYkiFCAXfCASfCIXhUIgiSIafCIbIBSFQiiJIhQgF3wgCHwiF3wgB3wiISAVIB18IhUgGSAYIA6FQgGJIg4gHnwgBnwiGIVCIIkiGXwiHSAOhUIoiSIOIBh8IAt8IhggGYVCMIkiGYVCIIkiHiAfICAgFSAPhUIBiSIPIBx8IAp8IhWFQiCJIhx8Ih8gD4VCKIkiDyAVfCAEfCIVIByFQjCJIhwgH3wiH3wiICAWhUIoiSIWICF8IAN8IiEgHoVCMIkiHiAgfCIgIBggFyAahUIwiSIXIBt8IhogFIVCAYkiFHwgBXwiGCAchUIgiSIbICR8IhwgFIVCKIkiFCAYfCABfCIYIBuFQjCJIhsgHyAPhUIBiSIPICJ8IAx8Ih8gF4VCIIkiFyAZIB18Ihl8Ih0gD4VCKIkiDyAffCATfCIfIBeFQjCJIhcgHXwiHSAPhUIBiSIPIBkgDoVCAYkiDiAVfCAQfCIVICOFQiCJIhkgGnwiGiAOhUIoiSIOIBV8IAJ8IhV8IBN8IiKFQiCJIiN8IiQgD4VCKIkiDyAifCASfCIiICOFQjCJIiMgJHwiJCAPhUIBiSIPIBsgHHwiGyAVIBmFQjCJIhUgICAWhUIBiSIWIB98IAt8IhmFQiCJIhx8Ih8gFoVCKIkiFiAZfCACfCIZfCAJfCIgIBUgGnwiFSAXIBsgFIVCAYkiFCAhfCAFfCIahUIgiSIXfCIbIBSFQiiJIhQgGnwgA3wiGiAXhUIwiSIXhUIgiSIhIB0gHiAVIA6FQgGJIg4gGHwgEHwiFYVCIIkiGHwiHSAOhUIoiSIOIBV8IAF8IhUgGIVCMIkiGCAdfCIdfCIeIA+FQiiJIg8gIHwgDXwiICAhhUIwiSIhIB58Ih4gGSAchUIwiSIZIB98IhwgFoVCAYkiFiAafCAIfCIaIBiFQiCJIhggJHwiHyAWhUIoiSIWIBp8IAp8IhogGIVCMIkiGCAdIA6FQgGJIg4gInwgBHwiHSAZhUIgiSIZIBcgG3wiF3wiGyAOhUIoiSIOIB18IAd8Ih0gGYVCMIkiGSAbfCIbIA6FQgGJIg4gFSAXIBSFQgGJIhR8IAx8IhUgI4VCIIkiFyAcfCIcIBSFQiiJIhQgFXwgBnwiFXwgEnwiIoVCIIkiI3wiJCAOhUIoiSIOICJ8IBN8IiIgGyAhIBUgF4VCMIkiFSAcfCIXIBSFQgGJIhQgGnwgBnwiGoVCIIkiHHwiGyAUhUIoiSIUIBp8IBB8IhogHIVCMIkiHCAbfCIbIBSFQgGJIhR8IA18IiEgGCAffCIYIBUgHiAPhUIBiSIPIB18IAJ8Ih2FQiCJIhV8Ih4gD4VCKIkiDyAdfCABfCIdIBWFQjCJIhWFQiCJIh8gFyAZIBggFoVCAYkiFiAgfCADfCIYhUIgiSIZfCIXIBaFQiiJIhYgGHwgBHwiGCAZhUIwiSIZIBd8Ihd8IiAgFIVCKIkiFCAhfCAIfCIhIB+FQjCJIh8gIHwiICAiICOFQjCJIiIgJHwiIyAOhUIBiSIOIB18IAd8Ih0gGYVCIIkiGSAbfCIbIA6FQiiJIg4gHXwgDHwiHSAZhUIwiSIZIBcgFoVCAYkiFiAafCALfCIXICKFQiCJIhogFSAefCIVfCIeIBaFQiiJIhYgF3wgCXwiFyAahUIwiSIaIB58Ih4gFoVCAYkiFiAVIA+FQgGJIg8gGHwgBXwiFSAchUIgiSIYICN8IhwgD4VCKIkiDyAVfCAKfCIVfCACfCIChUIgiSIifCIjIBaFQiiJIhYgAnwgC3wiAiAihUIwiSILICN8IiIgFoVCAYkiFiAZIBt8IhkgFSAYhUIwiSIVICAgFIVCAYkiFCAXfCANfCINhUIgiSIXfCIYIBSFQiiJIhQgDXwgBXwiBXwgEHwiECAVIBx8Ig0gGiAZIA6FQgGJIg4gIXwgDHwiDIVCIIkiFXwiGSAOhUIoiSIOIAx8IBJ8IhIgFYVCMIkiDIVCIIkiFSAeIB8gDSAPhUIBiSINIB18IAl8IgmFQiCJIg98IhogDYVCKIkiDSAJfCAIfCIJIA+FQjCJIgggGnwiD3wiGiAWhUIoiSIWIBB8IAd8IhAgEYUgDCAZfCIHIA6FQgGJIgwgCXwgCnwiCiALhUIgiSILIAUgF4VCMIkiBSAYfCIJfCIOIAyFQiiJIgwgCnwgE3wiEyALhUIwiSIKIA58IguFNwOAiQFBACADIAYgDyANhUIBiSINIAJ8fCICIAWFQiCJIgUgB3wiBiANhUIoiSIHIAJ8fCICQQApA4iJAYUgBCABIBIgCSAUhUIBiSIDfHwiASAIhUIgiSISICJ8IgkgA4VCKIkiAyABfHwiASAShUIwiSIEIAl8IhKFNwOIiQFBACATQQApA5CJAYUgECAVhUIwiSIQIBp8IhOFNwOQiQFBACABQQApA5iJAYUgAiAFhUIwiSICIAZ8IgGFNwOYiQFBACASIAOFQgGJQQApA6CJAYUgAoU3A6CJAUEAIBMgFoVCAYlBACkDqIkBhSAKhTcDqIkBQQAgASAHhUIBiUEAKQOwiQGFIASFNwOwiQFBACALIAyFQgGJQQApA7iJAYUgEIU3A7iJAQvdAgUBfwF+AX8BfgJ/IwBBwABrIgAkAAJAQQApA9CJAUIAUg0AQQBBACkDwIkBIgFBACgC4IoBIgKsfCIDNwPAiQFBAEEAKQPIiQEgAyABVK18NwPIiQECQEEALQDoigFFDQBBAEJ/NwPYiQELQQBCfzcD0IkBAkAgAkH/AEoNAEEAIQQDQCACIARqQeCJAWpBADoAACAEQQFqIgRBgAFBACgC4IoBIgJrSA0ACwtB4IkBEAIgAEEAKQOAiQE3AwAgAEEAKQOIiQE3AwggAEEAKQOQiQE3AxAgAEEAKQOYiQE3AxggAEEAKQOgiQE3AyAgAEEAKQOoiQE3AyggAEEAKQOwiQE3AzAgAEEAKQO4iQE3AzhBACgC5IoBIgVBAUgNAEEAIQRBACECA0AgBEGACWogACAEai0AADoAACAEQQFqIQQgBSACQQFqIgJB/wFxSg0ACwsgAEHAAGokAAv9AwMBfwF+AX8jAEGAAWsiAiQAQQBBgQI7AfKKAUEAIAE6APGKAUEAIAA6APCKAUGQfiEAA0AgAEGAiwFqQgA3AAAgAEH4igFqQgA3AAAgAEHwigFqQgA3AAAgAEEYaiIADQALQQAhAEEAQQApA/CKASIDQoiS853/zPmE6gCFNwOAiQFBAEEAKQP4igFCu86qptjQ67O7f4U3A4iJAUEAQQApA4CLAUKr8NP0r+68tzyFNwOQiQFBAEEAKQOIiwFC8e30+KWn/aelf4U3A5iJAUEAQQApA5CLAULRhZrv+s+Uh9EAhTcDoIkBQQBBACkDmIsBQp/Y+dnCkdqCm3+FNwOoiQFBAEEAKQOgiwFC6/qG2r+19sEfhTcDsIkBQQBBACkDqIsBQvnC+JuRo7Pw2wCFNwO4iQFBACADp0H/AXE2AuSKAQJAIAFBAUgNACACQgA3A3ggAkIANwNwIAJCADcDaCACQgA3A2AgAkIANwNYIAJCADcDUCACQgA3A0ggAkIANwNAIAJCADcDOCACQgA3AzAgAkIANwMoIAJCADcDICACQgA3AxggAkIANwMQIAJCADcDCCACQgA3AwBBACEEA0AgAiAAaiAAQYAJai0AADoAACAAQQFqIQAgBEEBaiIEQf8BcSABSA0ACyACQYABEAELIAJBgAFqJAALEgAgAEEDdkH/P3EgAEEQdhAECwkAQYAJIAAQAQsGAEGAiQELGwAgAUEDdkH/P3EgAUEQdhAEQYAJIAAQARADCwsLAQBBgAgLBPAAAAA=", Ri = "c6f286e6", _i = { + name: qi, + data: ji, + hash: Ri }; new V(); function Qr(e) { return !Number.isInteger(e) || e < 8 || e > 512 || e % 8 !== 0 ? new Error("Invalid variant! Valid values: 8, 16, ..., 512") : null; } -function _i(e, t) { +function Pi(e, t) { return e | t << 16; } function Jt(e = 512, t = null) { @@ -10142,10 +10146,10 @@ function Jt(e = 512, t = null) { if (t !== null) { if (n = ue(t), n.length > 64) return Promise.reject(new Error("Max key length is 64 bytes")); - r = _i(e, n.length); + r = Pi(e, n.length); } const i = e / 8; - return bn(Ri, i).then((a) => { + return wn(_i, i).then((a) => { r > 512 && a.writeMemory(n), a.init(r); const o = { init: r > 512 ? () => (a.writeMemory(n), a.init(r), o) : () => (a.init(r), o), @@ -10160,7 +10164,7 @@ function Jt(e = 512, t = null) { return o; }); } -function Pi(e, t, n) { +function Li(e, t, n) { const r = [ `m=${t.memorySize}`, `t=${t.iterations}`, @@ -10189,7 +10193,7 @@ function Ft(e, t, n) { return o === 64 ? (s = e, s.init()) : s = yield Jt(o * 8), s.update(a), a = s.digest("binary"), i.set(a.subarray(0, o), r * 32), i; }); } -function Li(e) { +function Ti(e) { switch (e) { case "d": return 0; @@ -10199,11 +10203,11 @@ function Li(e) { return 2; } } -function Ti(e) { +function Xi(e) { return we(this, void 0, void 0, function* () { var t; - const { parallelism: n, iterations: r, hashLength: i } = e, a = ue(e.password), o = ue(e.salt), s = 19, l = Li(e.hashType), { memorySize: u } = e, h = ue((t = e.secret) !== null && t !== void 0 ? t : ""), [g, c] = yield Promise.all([ - bn(Yi, 1024), + const { parallelism: n, iterations: r, hashLength: i } = e, a = ue(e.password), o = ue(e.salt), s = 19, l = Ti(e.hashType), { memorySize: u } = e, h = ue((t = e.secret) !== null && t !== void 0 ? t : ""), [g, c] = yield Promise.all([ + wn(Mi, 1024), Jt(512) ]); g.setMemorySize(u * 1024 + 1024); @@ -10217,16 +10221,16 @@ function Ti(e) { g.writeMemory(D, C * 1024), C += 1, S.set(se(1), 64), D = yield Ft(c, S, 1024), g.writeMemory(D, C * 1024); } const b = new Uint8Array(1024); - yn(b, g.calculate(new Uint8Array([]), u)); + bn(b, g.calculate(new Uint8Array([]), u)); const N = yield Ft(c, b, i); if (e.outputType === "hex") { const K = new Uint8Array(i * 2); return zt(K, N, i); } - return e.outputType === "encoded" ? Pi(o, e, N) : N; + return e.outputType === "encoded" ? Li(o, e, N) : N; }); } -const Xi = (e) => { +const Zi = (e) => { var t; if (!e || typeof e != "object") throw new Error("Invalid options parameter. It requires an object."); @@ -10251,9 +10255,9 @@ const Xi = (e) => { if (e.outputType === void 0 && (e.outputType = "hex"), !["hex", "binary", "encoded"].includes(e.outputType)) throw new Error(`Insupported output type ${e.outputType}. Valid values: ['hex', 'binary', 'encoded']`); }; -function Zi(e) { +function $i(e) { return we(this, void 0, void 0, function* () { - return Xi(e), Ti(Object.assign(Object.assign({}, e), { hashType: "id" })); + return Zi(e), Xi(Object.assign(Object.assign({}, e), { hashType: "id" })); }); } new V(); @@ -10283,10 +10287,10 @@ const We = { parallelism: 1, hashLength: 32 }; -async function $i(e, t) { +async function Wi(e, t) { if (t.length < 8) throw new Error("Argon2id salt must be at least 8 bytes."); - const n = await Zi({ + const n = await $i({ password: e, salt: t, parallelism: We.parallelism, @@ -10297,7 +10301,7 @@ async function $i(e, t) { }); return n instanceof Uint8Array ? n : new Uint8Array(n); } -function Wi(e) { +function e1(e) { return new TextEncoder().encode(e.normalize("NFKC")); } class Oe extends Error { @@ -10305,94 +10309,97 @@ class Oe extends Error { super(t), this.name = "LoginNameError"; } } -const xr = 3, Dr = 32, e1 = /^[\x00-\x7F]*$/u, t1 = /^[a-z0-9._-]+$/u, r1 = /[._-]{2,}/u, Sr = /[a-z0-9]/u; -function n1(e) { +const xr = 3, Dr = 32, t1 = /^[\x00-\x7F]*$/u, r1 = /^[a-z0-9._-]+$/u, n1 = /[._-]{2,}/u, Sr = /[a-z0-9]/u; +function i1(e) { const t = e.trim().toLowerCase(); - if (!e1.test(t)) + if (!t1.test(t)) throw new Oe("Login name must contain ASCII characters only."); if (t.length < xr || t.length > Dr) throw new Oe(`Login name must be between ${xr} and ${Dr} characters.`); - if (!t1.test(t)) + if (!r1.test(t)) throw new Oe("Login name may only contain a-z, 0-9, '.', '_', and '-'."); const n = t[0], r = t[t.length - 1]; if (!Sr.test(n) || !Sr.test(r)) throw new Oe("Login name must not begin or end with punctuation."); - if (r1.test(t)) + if (n1.test(t)) throw new Oe("Login name must not contain consecutive punctuation."); return t; } -function G1(e) { +function H1(e) { try { - return n1(e), !0; + return i1(e), !0; } catch { return !1; } } -function i1(e) { +function a1(e) { return fe(qr(De("bitlogin/password-salt/v1"), new Uint8Array([0]), De(e))).slice(0, 16); } -async function H1(e, t) { - const n = i1(t), r = Wi(e), i = await $i(r, n), a = jr(Rr("bitlogin/password-root/v1"), i), o = In(a, "bitlogin/password-locator-signing/v1"), s = Rt(a, "bitlogin/password-capsule-encryption/v1", 32); - return { locatorPrivateKey: o.scalar, capsuleKey: s }; +async function N1(e, t) { + const n = a1(t), r = e1(e), i = await Wi(r, n), a = jr(Rr("bitlogin/password-root/v1"), i), o = mn(a, "bitlogin/password-locator-signing/v1"), s = Rt(a, "bitlogin/password-capsule-encryption/v1", 32); + return _r(r, i, a), { locatorPrivateKey: o.scalar, capsuleKey: s }; } -function N1(e) { - const t = jr(Rr("bitlogin/recovery-root/v1"), e), n = In(t, "bitlogin/recovery-signing/v1"), r = Rt(t, "bitlogin/recovery-capsule-encryption/v1", 32); - return { recoveryPrivateKey: n.scalar, capsuleKey: r }; +function K1(e) { + const t = jr(Rr("bitlogin/recovery-root/v1"), e), n = mn(t, "bitlogin/recovery-signing/v1"), r = Rt(t, "bitlogin/recovery-capsule-encryption/v1", 32); + return _r(t), { recoveryPrivateKey: n.scalar, capsuleKey: r }; } -const a1 = mt.CURVE.n; -function o1(e) { +const o1 = mt.CURVE.n; +function s1(e) { if (e.length !== 32) return !1; let t = 0n; for (const n of e) t = t << 8n | BigInt(n); - return t >= 1n && t < a1; + return t >= 1n && t < o1; } -function K1() { +function O1() { for (; ; ) { const e = qe(32); - if (o1(e)) + if (s1(e)) return e; } } -function s1(e) { +function l1(e) { return Zt.getPublicKey(e); } -function O1(e) { - return jt(s1(e)); +function V1(e) { + return jt(l1(e)); } -function l1(e, t) { +function c1(e, t) { return Zt.sign(e, t); } -function c1(e, t, n) { +function u1(e, t, n) { try { return Zt.verify(e, t, n); } catch { return !1; } } -function u1(e) { +function d1(e) { return JSON.stringify([0, e.pubkey, e.created_at, e.kind, e.tags, e.content]); } -function wn(e) { - return jt(fe(De(u1(e)))); +function Cn(e) { + return jt(fe(De(d1(e)))); } -function V1(e, t) { - const n = wn(e), r = jt(l1(Je(n), t)); +function z1(e, t) { + const n = Cn(e), r = jt(c1(Je(n), t)); return { ...e, id: n, sig: r }; } function Fr(e) { - if (!/^[0-9a-f]{64}$/u.test(e.id) || !/^[0-9a-f]{64}$/u.test(e.pubkey) || !/^[0-9a-f]{128}$/u.test(e.sig) || wn(e) !== e.id) + if (!/^[0-9a-f]{64}$/u.test(e.id) || !/^[0-9a-f]{64}$/u.test(e.pubkey) || !/^[0-9a-f]{128}$/u.test(e.sig) || Cn(e) !== e.id) return !1; try { - return c1(Je(e.sig), Je(e.id), Je(e.pubkey)); + return u1(Je(e.sig), Je(e.id), Je(e.pubkey)); } catch { return !1; } } -const z1 = 0, J1 = 5, Y1 = 10002, M1 = 10050, q1 = 22242, j1 = 30078, R1 = "bitlogin:password:v1", _1 = "bitlogin:recovery:v1", P1 = "bitlogin.credential.v1", L1 = "bitlogin.recovery.v1", Cn = "bitlogin.recovery-export.v3"; +function J1(e, t) { + return e.tags.find((n) => n[0] === t)?.[1]; +} +const Y1 = 0, M1 = 5, q1 = 10002, j1 = 10050, R1 = 22242, _1 = 30078, P1 = "bitlogin:password:v1", L1 = "bitlogin:recovery:v1", T1 = "bitlogin.credential.v1", X1 = "bitlogin.recovery.v1", kn = "bitlogin.recovery-export.v3"; var Ut, Ur; -function d1() { +function g1() { return Ur || (Ur = 1, Ut = function e(t) { if (typeof t == "number" && isNaN(t)) throw new Error("NaN is not allowed"); @@ -10406,22 +10413,22 @@ function d1() { }, "")}}`; }), Ut; } -var g1 = d1(); -const T1 = /* @__PURE__ */ Kr(g1); +var A1 = g1(); +const Z1 = /* @__PURE__ */ Kr(A1); /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */ function Ue(e) { return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array"; } -function A1(e, ...t) { +function h1(e, ...t) { if (!Ue(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 kn(e, t) { +function vn(e, t) { return Array.isArray(t) ? t.length === 0 ? !0 : e ? t.every((n) => typeof n == "string") : t.every((n) => Number.isSafeInteger(n)) : !1; } -function vn(e) { +function Bn(e) { if (typeof e != "function") throw new Error("function expected"); return !0; @@ -10440,11 +10447,11 @@ function ct(e) { throw new Error("array expected"); } function ut(e, t) { - if (!kn(!0, t)) + if (!vn(!0, t)) throw new Error(`${e}: array of strings expected`); } function $t(e, t) { - if (!kn(!1, t)) + if (!vn(!1, t)) throw new Error(`${e}: array of numbers expected`); } // @__NO_SIDE_EFFECTS__ @@ -10480,7 +10487,7 @@ function tr(e = "") { }; } // @__NO_SIDE_EFFECTS__ -function Bn(e, t = "=") { +function Qn(e, t = "=") { return Ne(e), ke("padding", t), { encode(n) { for (ut("padding.encode", n); n.length * e % 8; ) @@ -10534,7 +10541,7 @@ function Yt(e, t, n) { i.push(0); return i.reverse(); } -const Qn = (e, t) => t === 0 ? e : Qn(t, e % t), dt = /* @__NO_SIDE_EFFECTS__ */ (e, t) => e + (t - Qn(e, t)), et = /* @__PURE__ */ (() => { +const En = (e, t) => t === 0 ? e : En(t, e % t), dt = /* @__NO_SIDE_EFFECTS__ */ (e, t) => e + (t - En(e, t)), et = /* @__PURE__ */ (() => { let e = []; for (let t = 0; t < 40; t++) e.push(2 ** t); @@ -10568,7 +10575,7 @@ function gt(e, t, n, r) { return r && a > 0 && l.push(i >>> 0), l; } // @__NO_SIDE_EFFECTS__ -function h1(e) { +function f1(e) { Ne(e); const t = 2 ** 8; return { @@ -10596,15 +10603,15 @@ function rr(e, t = !1) { }; } function Gr(e) { - return vn(e), function(...t) { + return Bn(e), function(...t) { try { return e.apply(null, t); } catch { } }; } -function f1(e, t) { - return Ne(e), vn(t), { +function p1(e, t) { + return Ne(e), Bn(t), { encode(n) { if (!Ue(n)) throw new Error("checksum.encode: input should be Uint8Array"); @@ -10622,30 +10629,30 @@ function f1(e, t) { } }; } -const X1 = { +const $1 = { alphabet: er, chain: Wt, - checksum: f1, + checksum: p1, convertRadix: Yt, convertRadix2: gt, - radix: h1, + radix: f1, radix2: rr, join: tr, - padding: Bn -}, p1 = typeof Uint8Array.from([]).toBase64 == "function" && typeof Uint8Array.fromBase64 == "function", I1 = (e, t) => { + padding: Qn +}, I1 = typeof Uint8Array.from([]).toBase64 == "function" && typeof Uint8Array.fromBase64 == "function", m1 = (e, t) => { ke("base64", e); const n = /^[A-Za-z0-9=+/]+$/, r = "base64"; if (e.length > 0 && !n.test(e)) throw new Error("invalid base64"); return Uint8Array.fromBase64(e, { alphabet: r, lastChunkHandling: "strict" }); -}, Z1 = p1 ? { +}, W1 = I1 ? { encode(e) { - return A1(e), e.toBase64(); + return h1(e), e.toBase64(); }, decode(e) { - return I1(e); + return m1(e); } -} : /* @__PURE__ */ Wt(/* @__PURE__ */ rr(6), /* @__PURE__ */ er("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ Bn(6), /* @__PURE__ */ tr("")), Mt = /* @__PURE__ */ Wt(/* @__PURE__ */ er("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), /* @__PURE__ */ tr("")), Hr = [996825010, 642813549, 513874426, 1027748829, 705979059]; +} : /* @__PURE__ */ Wt(/* @__PURE__ */ rr(6), /* @__PURE__ */ er("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ Qn(6), /* @__PURE__ */ tr("")), Mt = /* @__PURE__ */ Wt(/* @__PURE__ */ er("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), /* @__PURE__ */ tr("")), Hr = [996825010, 642813549, 513874426, 1027748829, 705979059]; function Ve(e) { const t = e >> 25; let n = (e & 33554431) << 5; @@ -10672,7 +10679,7 @@ function Nr(e, t, n = 1) { return i ^= n, Mt.encode(gt([i % et[30]], 30, 5, !1)); } // @__NO_SIDE_EFFECTS__ -function m1(e) { +function y1(e) { const t = e === "bech32" ? 1 : 734539939, n = /* @__PURE__ */ rr(5), r = n.decode, i = n.encode, a = Gr(r); function o(g, c, d = 90) { ke("bech32.encode prefix", g), Ue(c) && (c = Array.from(c)), $t("bech32.encode", c); @@ -10723,22 +10730,22 @@ function m1(e) { toWords: i }; } -const nr = /* @__PURE__ */ m1("bech32"); -function $1(e) { +const nr = /* @__PURE__ */ y1("bech32"); +function e2(e) { return nr.encodeFromBytes("npub", Je(e)); } -function W1(e) { +function t2(e) { return nr.encodeFromBytes("nsec", e); } -function e2(e) { +function r2(e) { const { prefix: t, bytes: n } = nr.decodeToBytes(e); if (t !== "nsec" || n.length !== 32) throw new Error("Not a valid nsec."); return n; } -function t2(e) { +function n2(e) { return { - schema: Cn, + schema: kn, recovery_public_key: e.recoveryPublicKeyHex, vault_relays: e.vaultRelayUrls, recovery_capsule_events: e.recoveryCapsuleEvents, @@ -10751,11 +10758,11 @@ class oe extends Error { super(t), this.name = "RecoveryExportParseError"; } } -function r2(e) { +function i2(e) { if (typeof e != "object" || e === null) throw new oe("Recovery export must be a JSON object."); const t = e; - if (t.schema !== Cn) + if (t.schema !== kn) throw new oe(`Unsupported recovery export schema: ${String(t.schema)}`); if (typeof t.recovery_public_key != "string" || !/^[0-9a-f]{64}$/u.test(t.recovery_public_key)) throw new oe("recovery_public_key must be lowercase 64-char hex."); @@ -10776,62 +10783,67 @@ function r2(e) { return t; } export { - jr as $, - rt as A, - Q1 as B, - pt as C, - R1 as D, - b1 as E, - Ce as F, - x1 as G, - pe as H, - X1 as I, - fe as J, - q1 as K, - We as L, - e2 as M, - Je as N, - n1 as O, - H1 as P, - w1 as Q, + qr as $, + x1 as A, + rt as B, + E1 as C, + P1 as D, + w1 as E, + pt as F, + Ce as G, + D1 as H, + pe as I, + $1 as J, + R1 as K, + fe as L, + We as M, + r2 as N, + Je as O, + i1 as P, + N1 as Q, oe as R, - L1 as S, - N1 as T, + X1 as S, + C1 as T, K1 as U, - k1 as V, - J1 as W, + O1 as V, + v1 as W, qe as X, - Z1 as Y, - qr as Z, - mt as _, - $1 as a, - U1 as a0, - Rt as a1, - t2 as a2, - W1 as a3, - z1 as b, - wn as c, - Y1 as d, - y1 as e, - M1 as f, - O1 as g, - j1 as h, - G1 as i, - T1 as j, - C1 as k, - D1 as l, - S1 as m, - F1 as n, - o1 as o, - r2 as p, - P1 as q, - v1 as r, - V1 as s, - _1 as t, + _r as Y, + M1 as Z, + W1 as _, + e2 as a, + mt as a0, + jr as a1, + G1 as a2, + Rt as a3, + Rr as a4, + mn as a5, + n2 as a6, + t2 as a7, + Kr as a8, + Y1 as b, + Cn as c, + q1 as d, + b1 as e, + j1 as f, + V1 as g, + _1 as h, + H1 as i, + Z1 as j, + k1 as k, + S1 as l, + F1 as m, + U1 as n, + s1 as o, + i2 as p, + T1 as q, + B1 as r, + z1 as s, + L1 as t, De as u, Fr as v, - bt as w, - B1 as x, - ht as y, - E1 as z + J1 as w, + bt as x, + Q1 as y, + ht as z }; diff --git a/vendor/bitlogin/bitlogin-shared-DxcpMAo3.js b/vendor/bitlogin/bitlogin-shared-DxcpMAo3.js new file mode 100644 index 00000000..52a9516e --- /dev/null +++ b/vendor/bitlogin/bitlogin-shared-DxcpMAo3.js @@ -0,0 +1,8269 @@ +import { a8 as Ye } from "./bitlogin-shared-B2Rc9khL.js"; +function We(we, je) { + for (var Ie = 0; Ie < je.length; Ie++) { + const Ae = je[Ie]; + if (typeof Ae != "string" && !Array.isArray(Ae)) { + for (const Ce in Ae) + if (Ce !== "default" && !(Ce in we)) { + const N = Object.getOwnPropertyDescriptor(Ae, Ce); + N && Object.defineProperty(we, Ce, N.get ? N : { + enumerable: !0, + get: () => Ae[Ce] + }); + } + } + } + return Object.freeze(Object.defineProperty(we, Symbol.toStringTag, { value: "Module" })); +} +var Fe = { exports: {} }; +/*! For license information please see index.js.LICENSE.txt */ +var Ze = Fe.exports, He; +function ze() { + return He || (He = 1, (function(we, je) { + (function(Ie, Ae) { + we.exports = Ae(); + })(Ze, () => (() => { + var Ie = { 7289(N, O, E) { + var h = E(6763); + (() => { + const d = () => { + const a = new Error("not implemented"); + return a.code = "ENOSYS", a; + }; + if (!globalThis.fs) { + let a = ""; + globalThis.fs = { constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 }, writeSync(i, n) { + a += f.decode(n); + const r = a.lastIndexOf(` +`); + return r != -1 && (h.log(a.substring(0, r)), a = a.substring(r + 1)), n.length; + }, write(i, n, r, e, t, c) { + r === 0 && e === n.length && t === null ? c(null, this.writeSync(i, n)) : c(d()); + }, chmod(i, n, r) { + r(d()); + }, chown(i, n, r, e) { + e(d()); + }, close(i, n) { + n(d()); + }, fchmod(i, n, r) { + r(d()); + }, fchown(i, n, r, e) { + e(d()); + }, fstat(i, n) { + n(d()); + }, fsync(i, n) { + n(null); + }, ftruncate(i, n, r) { + r(d()); + }, lchown(i, n, r, e) { + e(d()); + }, link(i, n, r) { + r(d()); + }, lstat(i, n) { + n(d()); + }, mkdir(i, n, r) { + r(d()); + }, open(i, n, r, e) { + e(d()); + }, read(i, n, r, e, t, c) { + c(d()); + }, readdir(i, n) { + n(d()); + }, readlink(i, n) { + n(d()); + }, rename(i, n, r) { + r(d()); + }, rmdir(i, n) { + n(d()); + }, stat(i, n) { + n(d()); + }, symlink(i, n, r) { + r(d()); + }, truncate(i, n, r) { + r(d()); + }, unlink(i, n) { + n(d()); + }, utimes(i, n, r, e) { + e(d()); + } }; + } + if (globalThis.process || (globalThis.process = { getuid: () => -1, getgid: () => -1, geteuid: () => -1, getegid: () => -1, getgroups() { + throw d(); + }, pid: -1, ppid: -1, umask() { + throw d(); + }, cwd() { + throw d(); + }, chdir() { + throw d(); + } }), !globalThis.crypto) throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)"); + if (!globalThis.performance) throw new Error("globalThis.performance is not available, polyfill required (performance.now only)"); + if (!globalThis.TextEncoder) throw new Error("globalThis.TextEncoder is not available, polyfill required"); + if (!globalThis.TextDecoder) throw new Error("globalThis.TextDecoder is not available, polyfill required"); + const o = new TextEncoder("utf-8"), f = new TextDecoder("utf-8"); + globalThis.Go = class { + constructor() { + this.argv = ["js"], this.env = {}, this.exit = (u) => { + u !== 0 && h.warn("exit code:", u); + }, this._exitPromise = new Promise((u) => { + this._resolveExitPromise = u; + }), this._pendingEvent = null, this._scheduledTimeouts = /* @__PURE__ */ new Map(), this._nextCallbackTimeoutID = 1; + const a = (u, p) => { + this.mem.setUint32(u + 0, p, !0), this.mem.setUint32(u + 4, Math.floor(p / 4294967296), !0); + }, i = (u) => this.mem.getUint32(u + 0, !0) + 4294967296 * this.mem.getInt32(u + 4, !0), n = (u) => { + const p = this.mem.getFloat64(u, !0); + if (p === 0) return; + if (!isNaN(p)) return p; + const l = this.mem.getUint32(u, !0); + return this._values[l]; + }, r = (u, p) => { + if (typeof p == "number" && p !== 0) return isNaN(p) ? (this.mem.setUint32(u + 4, 2146959360, !0), void this.mem.setUint32(u, 0, !0)) : void this.mem.setFloat64(u, p, !0); + if (p === void 0) return void this.mem.setFloat64(u, 0, !0); + let v = this._ids.get(p); + v === void 0 && (v = this._idPool.pop(), v === void 0 && (v = this._values.length), this._values[v] = p, this._goRefCounts[v] = 0, this._ids.set(p, v)), this._goRefCounts[v]++; + let y = 0; + switch (typeof p) { + case "object": + p !== null && (y = 1); + break; + case "string": + y = 2; + break; + case "symbol": + y = 3; + break; + case "function": + y = 4; + } + this.mem.setUint32(u + 4, 2146959360 | y, !0), this.mem.setUint32(u, v, !0); + }, e = (u) => { + const p = i(u + 0), l = i(u + 8); + return new Uint8Array(this._inst.exports.mem.buffer, p, l); + }, t = (u) => { + const p = i(u + 0), l = i(u + 8), v = new Array(l); + for (let y = 0; y < l; y++) v[y] = n(p + 8 * y); + return v; + }, c = (u) => { + const p = i(u + 0), l = i(u + 8); + return f.decode(new DataView(this._inst.exports.mem.buffer, p, l)); + }, s = Date.now() - performance.now(); + this.importObject = { _gotest: { add: (u, p) => u + p }, gojs: { "runtime.wasmExit": (u) => { + u >>>= 0; + const p = this.mem.getInt32(u + 8, !0); + this.exited = !0, delete this._inst, delete this._values, delete this._goRefCounts, delete this._ids, delete this._idPool, this.exit(p); + }, "runtime.wasmWrite": (u) => { + const p = i((u >>>= 0) + 8), l = i(u + 16), v = this.mem.getInt32(u + 24, !0); + fs.writeSync(p, new Uint8Array(this._inst.exports.mem.buffer, l, v)); + }, "runtime.resetMemoryDataView": (u) => { + this.mem = new DataView(this._inst.exports.mem.buffer); + }, "runtime.nanotime1": (u) => { + a((u >>>= 0) + 8, 1e6 * (s + performance.now())); + }, "runtime.walltime": (u) => { + u >>>= 0; + const p = (/* @__PURE__ */ new Date()).getTime(); + a(u + 8, p / 1e3), this.mem.setInt32(u + 16, p % 1e3 * 1e6, !0); + }, "runtime.scheduleTimeoutEvent": (u) => { + u >>>= 0; + const p = this._nextCallbackTimeoutID; + this._nextCallbackTimeoutID++, this._scheduledTimeouts.set(p, setTimeout(() => { + for (this._resume(); this._scheduledTimeouts.has(p); ) h.warn("scheduleTimeoutEvent: missed timeout event"), this._resume(); + }, i(u + 8))), this.mem.setInt32(u + 16, p, !0); + }, "runtime.clearTimeoutEvent": (u) => { + u >>>= 0; + const p = this.mem.getInt32(u + 8, !0); + clearTimeout(this._scheduledTimeouts.get(p)), this._scheduledTimeouts.delete(p); + }, "runtime.getRandomData": (u) => { + u >>>= 0, crypto.getRandomValues(e(u + 8)); + }, "syscall/js.finalizeRef": (u) => { + u >>>= 0; + const p = this.mem.getUint32(u + 8, !0); + if (this._goRefCounts[p]--, this._goRefCounts[p] === 0) { + const l = this._values[p]; + this._values[p] = null, this._ids.delete(l), this._idPool.push(p); + } + }, "syscall/js.stringVal": (u) => { + r((u >>>= 0) + 24, c(u + 8)); + }, "syscall/js.valueGet": (u) => { + u >>>= 0; + const p = Reflect.get(n(u + 8), c(u + 16)); + u = this._inst.exports.getsp() >>> 0, r(u + 32, p); + }, "syscall/js.valueSet": (u) => { + u >>>= 0, Reflect.set(n(u + 8), c(u + 16), n(u + 32)); + }, "syscall/js.valueDelete": (u) => { + u >>>= 0, Reflect.deleteProperty(n(u + 8), c(u + 16)); + }, "syscall/js.valueIndex": (u) => { + r((u >>>= 0) + 24, Reflect.get(n(u + 8), i(u + 16))); + }, "syscall/js.valueSetIndex": (u) => { + u >>>= 0, Reflect.set(n(u + 8), i(u + 16), n(u + 24)); + }, "syscall/js.valueCall": (u) => { + u >>>= 0; + try { + const p = n(u + 8), l = Reflect.get(p, c(u + 16)), v = t(u + 32), y = Reflect.apply(l, p, v); + u = this._inst.exports.getsp() >>> 0, r(u + 56, y), this.mem.setUint8(u + 64, 1); + } catch (p) { + u = this._inst.exports.getsp() >>> 0, r(u + 56, p), this.mem.setUint8(u + 64, 0); + } + }, "syscall/js.valueInvoke": (u) => { + u >>>= 0; + try { + const p = n(u + 8), l = t(u + 16), v = Reflect.apply(p, void 0, l); + u = this._inst.exports.getsp() >>> 0, r(u + 40, v), this.mem.setUint8(u + 48, 1); + } catch (p) { + u = this._inst.exports.getsp() >>> 0, r(u + 40, p), this.mem.setUint8(u + 48, 0); + } + }, "syscall/js.valueNew": (u) => { + u >>>= 0; + try { + const p = n(u + 8), l = t(u + 16), v = Reflect.construct(p, l); + u = this._inst.exports.getsp() >>> 0, r(u + 40, v), this.mem.setUint8(u + 48, 1); + } catch (p) { + u = this._inst.exports.getsp() >>> 0, r(u + 40, p), this.mem.setUint8(u + 48, 0); + } + }, "syscall/js.valueLength": (u) => { + a((u >>>= 0) + 16, parseInt(n(u + 8).length)); + }, "syscall/js.valuePrepareString": (u) => { + u >>>= 0; + const p = o.encode(String(n(u + 8))); + r(u + 16, p), a(u + 24, p.length); + }, "syscall/js.valueLoadString": (u) => { + const p = n((u >>>= 0) + 8); + e(u + 16).set(p); + }, "syscall/js.valueInstanceOf": (u) => { + u >>>= 0, this.mem.setUint8(u + 24, n(u + 8) instanceof n(u + 16) ? 1 : 0); + }, "syscall/js.copyBytesToGo": (u) => { + const p = e((u >>>= 0) + 8), l = n(u + 32); + if (!(l instanceof Uint8Array || l instanceof Uint8ClampedArray)) return void this.mem.setUint8(u + 48, 0); + const v = l.subarray(0, p.length); + p.set(v), a(u + 40, v.length), this.mem.setUint8(u + 48, 1); + }, "syscall/js.copyBytesToJS": (u) => { + const p = n((u >>>= 0) + 8), l = e(u + 16); + if (!(p instanceof Uint8Array || p instanceof Uint8ClampedArray)) return void this.mem.setUint8(u + 48, 0); + const v = l.subarray(0, p.length); + p.set(v), a(u + 40, v.length), this.mem.setUint8(u + 48, 1); + }, debug: (u) => { + h.log(u); + } } }; + } + async run(a) { + if (!(a instanceof WebAssembly.Instance)) throw new Error("Go.run: WebAssembly.Instance expected"); + this._inst = a, this.mem = new DataView(this._inst.exports.mem.buffer), this._values = [NaN, 0, null, !0, !1, globalThis, this], this._goRefCounts = new Array(this._values.length).fill(1 / 0), this._ids = /* @__PURE__ */ new Map([[0, 1], [null, 2], [!0, 3], [!1, 4], [globalThis, 5], [this, 6]]), this._idPool = [], this.exited = !1; + let i = 4096; + const n = (c) => { + const s = i, u = o.encode(c + "\0"); + return new Uint8Array(this.mem.buffer, i, u.length).set(u), i += u.length, i % 8 != 0 && (i += 8 - i % 8), s; + }, r = this.argv.length, e = []; + this.argv.forEach((c) => { + e.push(n(c)); + }), e.push(0), Object.keys(this.env).sort().forEach((c) => { + e.push(n(`${c}=${this.env[c]}`)); + }), e.push(0); + const t = i; + if (e.forEach((c) => { + this.mem.setUint32(i, c, !0), this.mem.setUint32(i + 4, 0, !0), i += 8; + }), i >= 12288) throw new Error("total length of command line and environment variables exceeds limit"); + this._inst.exports.run(r, t), this.exited && this._resolveExitPromise(), await this._exitPromise; + } + _resume() { + if (this.exited) throw new Error("Go program has already exited"); + this._inst.exports.resume(), this.exited && this._resolveExitPromise(); + } + _makeFuncWrapper(a) { + const i = this; + return function() { + const n = { id: a, this: this, args: arguments }; + return i._pendingEvent = n, i._resume(), n.result; + }; + } + }; + })(); + }, 3318(N) { + var O; + O = () => (() => { + var E = { 5804(d, o, f) { + Object.defineProperty(o, "__esModule", { value: !0 }); + var a = f(2495); + o.default = function(i, n) { + this.faradayServer = i(a.serviceNames.frdrpc.FaradayServer, n); + }; + }, 3586(d, o, f) { + var a = this && this.__importDefault || function(s) { + return s && s.__esModule ? s : { default: s }; + }; + Object.defineProperty(o, "__esModule", { value: !0 }), o.LitApi = o.TaprootAssetsApi = o.FaradayApi = o.PoolApi = o.LoopApi = o.LndApi = void 0; + var i = f(728); + Object.defineProperty(o, "LndApi", { enumerable: !0, get: function() { + return a(i).default; + } }); + var n = f(3762); + Object.defineProperty(o, "LoopApi", { enumerable: !0, get: function() { + return a(n).default; + } }); + var r = f(7082); + Object.defineProperty(o, "PoolApi", { enumerable: !0, get: function() { + return a(r).default; + } }); + var e = f(5804); + Object.defineProperty(o, "FaradayApi", { enumerable: !0, get: function() { + return a(e).default; + } }); + var t = f(9147); + Object.defineProperty(o, "TaprootAssetsApi", { enumerable: !0, get: function() { + return a(t).default; + } }); + var c = f(2191); + Object.defineProperty(o, "LitApi", { enumerable: !0, get: function() { + return a(c).default; + } }); + }, 2191(d, o, f) { + Object.defineProperty(o, "__esModule", { value: !0 }); + var a = f(2495); + o.default = function(i, n) { + this.autopilot = i(a.serviceNames.litrpc.Autopilot, n), this.firewall = i(a.serviceNames.litrpc.Firewall, n), this.sessions = i(a.serviceNames.litrpc.Sessions, n), this.status = i(a.serviceNames.litrpc.Status, n); + }; + }, 728(d, o, f) { + Object.defineProperty(o, "__esModule", { value: !0 }); + var a = f(2495); + o.default = function(i, n) { + this.autopilot = i(a.serviceNames.autopilotrpc.Autopilot, n), this.chainNotifier = i(a.serviceNames.chainrpc.ChainNotifier, n), this.invoices = i(a.serviceNames.invoicesrpc.Invoices, n), this.lightning = i(a.serviceNames.lnrpc.Lightning, n), this.router = i(a.serviceNames.routerrpc.Router, n), this.signer = i(a.serviceNames.signrpc.Signer, n), this.walletKit = i(a.serviceNames.walletrpc.WalletKit, n), this.walletUnlocker = i(a.serviceNames.lnrpc.WalletUnlocker, n), this.watchtower = i(a.serviceNames.watchtowerrpc.Watchtower, n), this.watchtowerClient = i(a.serviceNames.wtclientrpc.WatchtowerClient, n); + }; + }, 3762(d, o, f) { + Object.defineProperty(o, "__esModule", { value: !0 }); + var a = f(2495); + o.default = function(i, n) { + this.swapClient = i(a.serviceNames.looprpc.SwapClient, n), this.debug = i(a.serviceNames.looprpc.Debug, n); + }; + }, 7082(d, o, f) { + Object.defineProperty(o, "__esModule", { value: !0 }); + var a = f(2495); + o.default = function(i, n) { + this.trader = i(a.serviceNames.poolrpc.Trader, n), this.channelAuctioneer = i(a.serviceNames.poolrpc.ChannelAuctioneer, n), this.hashmail = i(a.serviceNames.poolrpc.HashMail, n); + }; + }, 9147(d, o, f) { + Object.defineProperty(o, "__esModule", { value: !0 }); + var a = f(2495); + o.default = function(i, n) { + this.taprootAssets = i(a.serviceNames.taprpc.TaprootAssets, n), this.assetWallet = i(a.serviceNames.assetwalletrpc.AssetWallet, n), this.mint = i(a.serviceNames.mintrpc.Mint, n), this.priceOracle = i(a.serviceNames.priceoraclerpc.PriceOracle, n), this.rfq = i(a.serviceNames.rfqrpc.Rfq, n), this.tapChannels = i(a.serviceNames.tapchannelrpc.TaprootAssetChannels, n), this.tapDev = i(a.serviceNames.tapdevrpc.TapDev, n), this.universe = i(a.serviceNames.universerpc.Universe, n); + }; + }, 4245(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(t, c, s, u) { + u === void 0 && (u = s), Object.defineProperty(t, u, { enumerable: !0, get: function() { + return c[s]; + } }); + } : function(t, c, s, u) { + u === void 0 && (u = s), t[u] = c[s]; + }), i = this && this.__exportStar || function(t, c) { + for (var s in t) s === "default" || Object.prototype.hasOwnProperty.call(c, s) || a(c, t, s); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), o.subscriptionMethods = o.TaprootAssetsApi = o.LitApi = o.FaradayApi = o.PoolApi = o.LoopApi = o.LndApi = o.snakeKeysToCamel = o.isObject = o.camelKeysToSnake = void 0, i(f(4578), o); + var n = f(1022); + Object.defineProperty(o, "camelKeysToSnake", { enumerable: !0, get: function() { + return n.camelKeysToSnake; + } }), Object.defineProperty(o, "isObject", { enumerable: !0, get: function() { + return n.isObject; + } }), Object.defineProperty(o, "snakeKeysToCamel", { enumerable: !0, get: function() { + return n.snakeKeysToCamel; + } }); + var r = f(3586); + Object.defineProperty(o, "LndApi", { enumerable: !0, get: function() { + return r.LndApi; + } }), Object.defineProperty(o, "LoopApi", { enumerable: !0, get: function() { + return r.LoopApi; + } }), Object.defineProperty(o, "PoolApi", { enumerable: !0, get: function() { + return r.PoolApi; + } }), Object.defineProperty(o, "FaradayApi", { enumerable: !0, get: function() { + return r.FaradayApi; + } }), Object.defineProperty(o, "LitApi", { enumerable: !0, get: function() { + return r.LitApi; + } }), Object.defineProperty(o, "TaprootAssetsApi", { enumerable: !0, get: function() { + return r.TaprootAssetsApi; + } }); + var e = f(2495); + Object.defineProperty(o, "subscriptionMethods", { enumerable: !0, get: function() { + return e.subscriptionMethods; + } }); + }, 9444(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(5712), o); + }, 1241(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(4376), o); + }, 9926(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(2277), o); + }, 6636(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(8647), o); + }, 8925(d, o) { + var f, a, i, n; + Object.defineProperty(o, "__esModule", { value: !0 }), o.CloseRecommendationRequest_Metric = o.EntryType = o.FiatBackend = o.Granularity = void 0, (n = o.Granularity || (o.Granularity = {})).UNKNOWN_GRANULARITY = "UNKNOWN_GRANULARITY", n.MINUTE = "MINUTE", n.FIVE_MINUTES = "FIVE_MINUTES", n.FIFTEEN_MINUTES = "FIFTEEN_MINUTES", n.THIRTY_MINUTES = "THIRTY_MINUTES", n.HOUR = "HOUR", n.SIX_HOURS = "SIX_HOURS", n.TWELVE_HOURS = "TWELVE_HOURS", n.DAY = "DAY", n.UNRECOGNIZED = "UNRECOGNIZED", (i = o.FiatBackend || (o.FiatBackend = {})).UNKNOWN_FIATBACKEND = "UNKNOWN_FIATBACKEND", i.COINCAP = "COINCAP", i.COINDESK = "COINDESK", i.CUSTOM = "CUSTOM", i.COINGECKO = "COINGECKO", i.UNRECOGNIZED = "UNRECOGNIZED", (a = o.EntryType || (o.EntryType = {})).UNKNOWN = "UNKNOWN", a.LOCAL_CHANNEL_OPEN = "LOCAL_CHANNEL_OPEN", a.REMOTE_CHANNEL_OPEN = "REMOTE_CHANNEL_OPEN", a.CHANNEL_OPEN_FEE = "CHANNEL_OPEN_FEE", a.CHANNEL_CLOSE = "CHANNEL_CLOSE", a.RECEIPT = "RECEIPT", a.PAYMENT = "PAYMENT", a.FEE = "FEE", a.CIRCULAR_RECEIPT = "CIRCULAR_RECEIPT", a.FORWARD = "FORWARD", a.FORWARD_FEE = "FORWARD_FEE", a.CIRCULAR_PAYMENT = "CIRCULAR_PAYMENT", a.CIRCULAR_FEE = "CIRCULAR_FEE", a.SWEEP = "SWEEP", a.SWEEP_FEE = "SWEEP_FEE", a.CHANNEL_CLOSE_FEE = "CHANNEL_CLOSE_FEE", a.UNRECOGNIZED = "UNRECOGNIZED", (f = o.CloseRecommendationRequest_Metric || (o.CloseRecommendationRequest_Metric = {})).UNKNOWN = "UNKNOWN", f.UPTIME = "UPTIME", f.REVENUE = "REVENUE", f.INCOMING_VOLUME = "INCOMING_VOLUME", f.OUTGOING_VOLUME = "OUTGOING_VOLUME", f.TOTAL_VOLUME = "TOTAL_VOLUME", f.UNRECOGNIZED = "UNRECOGNIZED"; + }, 8507(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(8925), o); + }, 4578(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(S, M, j, H) { + H === void 0 && (H = j), Object.defineProperty(S, H, { enumerable: !0, get: function() { + return M[j]; + } }); + } : function(S, M, j, H) { + H === void 0 && (H = j), S[H] = M[j]; + }), i = this && this.__setModuleDefault || (Object.create ? function(S, M) { + Object.defineProperty(S, "default", { enumerable: !0, value: M }); + } : function(S, M) { + S.default = M; + }), n = this && this.__importStar || function(S) { + if (S && S.__esModule) return S; + var M = {}; + if (S != null) for (var j in S) j !== "default" && Object.prototype.hasOwnProperty.call(S, j) && a(M, S, j); + return i(M, S), M; + }; + Object.defineProperty(o, "__esModule", { value: !0 }), o.universerpc = o.taprpc = o.tapdevrpc = o.tapchannelrpc = o.rfqrpc = o.priceoraclerpc = o.mintrpc = o.authmailboxrpc = o.assetwalletrpc = o.poolrpc = o.looprpc = o.wtclientrpc = o.watchtowerrpc = o.walletrpc = o.signrpc = o.routerrpc = o.peersrpc = o.lnrpc = o.invoicesrpc = o.chainrpc = o.autopilotrpc = o.litrpc = o.frdrpc = void 0; + var r = n(f(8507)); + o.frdrpc = r; + var e = n(f(2844)); + o.litrpc = e; + var t = n(f(9926)); + o.autopilotrpc = t; + var c = n(f(6636)); + o.chainrpc = c; + var s = n(f(8561)); + o.invoicesrpc = s; + var u = n(f(1419)); + o.lnrpc = u; + var p = n(f(1908)); + o.peersrpc = p; + var l = n(f(6534)); + o.routerrpc = l; + var v = n(f(8054)); + o.signrpc = v; + var y = n(f(718)); + o.walletrpc = y; + var g = n(f(5109)); + o.watchtowerrpc = g; + var _ = n(f(7685)); + o.wtclientrpc = _; + var T = n(f(7967)); + o.looprpc = T; + var b = n(f(2471)); + o.poolrpc = b; + var A = n(f(9444)); + o.assetwalletrpc = A; + var m = n(f(1241)); + o.authmailboxrpc = m; + var I = n(f(1393)); + o.mintrpc = I; + var P = n(f(2162)); + o.priceoraclerpc = P; + var x = n(f(4386)); + o.rfqrpc = x; + var F = n(f(8933)); + o.tapchannelrpc = F; + var K = n(f(8753)); + o.tapdevrpc = K; + var Y = n(f(5600)); + o.taprpc = Y; + var Q = n(f(7164)); + o.universerpc = Q; + }, 8561(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(4195), o); + }, 8650(d, o) { + var f; + Object.defineProperty(o, "__esModule", { value: !0 }), o.ActionState = void 0, (f = o.ActionState || (o.ActionState = {})).STATE_UNKNOWN = "STATE_UNKNOWN", f.STATE_PENDING = "STATE_PENDING", f.STATE_DONE = "STATE_DONE", f.STATE_ERROR = "STATE_ERROR", f.UNRECOGNIZED = "UNRECOGNIZED"; + }, 5547(d, o) { + Object.defineProperty(o, "__esModule", { value: !0 }); + }, 1199(d, o) { + var f, a; + Object.defineProperty(o, "__esModule", { value: !0 }), o.SessionState = o.SessionType = void 0, (a = o.SessionType || (o.SessionType = {})).TYPE_MACAROON_READONLY = "TYPE_MACAROON_READONLY", a.TYPE_MACAROON_ADMIN = "TYPE_MACAROON_ADMIN", a.TYPE_MACAROON_CUSTOM = "TYPE_MACAROON_CUSTOM", a.TYPE_UI_PASSWORD = "TYPE_UI_PASSWORD", a.TYPE_AUTOPILOT = "TYPE_AUTOPILOT", a.TYPE_MACAROON_ACCOUNT = "TYPE_MACAROON_ACCOUNT", a.UNRECOGNIZED = "UNRECOGNIZED", (f = o.SessionState || (o.SessionState = {})).STATE_CREATED = "STATE_CREATED", f.STATE_IN_USE = "STATE_IN_USE", f.STATE_REVOKED = "STATE_REVOKED", f.STATE_EXPIRED = "STATE_EXPIRED", f.STATE_RESERVED = "STATE_RESERVED", f.UNRECOGNIZED = "UNRECOGNIZED"; + }, 6440(d, o) { + Object.defineProperty(o, "__esModule", { value: !0 }); + }, 2844(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(8650), o), i(f(5547), o), i(f(1199), o), i(f(6440), o); + }, 2277(d, o) { + Object.defineProperty(o, "__esModule", { value: !0 }); + }, 8647(d, o) { + Object.defineProperty(o, "__esModule", { value: !0 }); + }, 4195(d, o) { + var f; + Object.defineProperty(o, "__esModule", { value: !0 }), o.LookupModifier = void 0, (f = o.LookupModifier || (o.LookupModifier = {})).DEFAULT = "DEFAULT", f.HTLC_SET_ONLY = "HTLC_SET_ONLY", f.HTLC_SET_BLANK = "HTLC_SET_BLANK", f.UNRECOGNIZED = "UNRECOGNIZED"; + }, 4377(d, o) { + var f, a, i, n, r, e, t, c, s, u, p, l, v, y, g, _, T, b, A, m, I; + Object.defineProperty(o, "__esModule", { value: !0 }), o.Failure_FailureCode = o.HTLCAttempt_HTLCStatus = o.Payment_PaymentStatus = o.Invoice_InvoiceState = o.ChannelEventUpdate_UpdateType = o.PendingChannelsResponse_ForceClosedChannel_AnchorState = o.PeerEvent_EventType = o.Peer_SyncType = o.ChannelCloseSummary_ClosureType = o.UpdateFailure = o.FeatureBit = o.PaymentFailureReason = o.InvoiceHTLCState = o.NodeMetricType = o.ResolutionOutcome = o.ResolutionType = o.Initiator = o.CommitmentType = o.AddressType = o.CoinSelectionStrategy = o.OutputScriptType = void 0, (I = o.OutputScriptType || (o.OutputScriptType = {})).SCRIPT_TYPE_PUBKEY_HASH = "SCRIPT_TYPE_PUBKEY_HASH", I.SCRIPT_TYPE_SCRIPT_HASH = "SCRIPT_TYPE_SCRIPT_HASH", I.SCRIPT_TYPE_WITNESS_V0_PUBKEY_HASH = "SCRIPT_TYPE_WITNESS_V0_PUBKEY_HASH", I.SCRIPT_TYPE_WITNESS_V0_SCRIPT_HASH = "SCRIPT_TYPE_WITNESS_V0_SCRIPT_HASH", I.SCRIPT_TYPE_PUBKEY = "SCRIPT_TYPE_PUBKEY", I.SCRIPT_TYPE_MULTISIG = "SCRIPT_TYPE_MULTISIG", I.SCRIPT_TYPE_NULLDATA = "SCRIPT_TYPE_NULLDATA", I.SCRIPT_TYPE_NON_STANDARD = "SCRIPT_TYPE_NON_STANDARD", I.SCRIPT_TYPE_WITNESS_UNKNOWN = "SCRIPT_TYPE_WITNESS_UNKNOWN", I.SCRIPT_TYPE_WITNESS_V1_TAPROOT = "SCRIPT_TYPE_WITNESS_V1_TAPROOT", I.UNRECOGNIZED = "UNRECOGNIZED", (m = o.CoinSelectionStrategy || (o.CoinSelectionStrategy = {})).STRATEGY_USE_GLOBAL_CONFIG = "STRATEGY_USE_GLOBAL_CONFIG", m.STRATEGY_LARGEST = "STRATEGY_LARGEST", m.STRATEGY_RANDOM = "STRATEGY_RANDOM", m.UNRECOGNIZED = "UNRECOGNIZED", (A = o.AddressType || (o.AddressType = {})).WITNESS_PUBKEY_HASH = "WITNESS_PUBKEY_HASH", A.NESTED_PUBKEY_HASH = "NESTED_PUBKEY_HASH", A.UNUSED_WITNESS_PUBKEY_HASH = "UNUSED_WITNESS_PUBKEY_HASH", A.UNUSED_NESTED_PUBKEY_HASH = "UNUSED_NESTED_PUBKEY_HASH", A.TAPROOT_PUBKEY = "TAPROOT_PUBKEY", A.UNUSED_TAPROOT_PUBKEY = "UNUSED_TAPROOT_PUBKEY", A.UNRECOGNIZED = "UNRECOGNIZED", (b = o.CommitmentType || (o.CommitmentType = {})).UNKNOWN_COMMITMENT_TYPE = "UNKNOWN_COMMITMENT_TYPE", b.LEGACY = "LEGACY", b.STATIC_REMOTE_KEY = "STATIC_REMOTE_KEY", b.ANCHORS = "ANCHORS", b.SCRIPT_ENFORCED_LEASE = "SCRIPT_ENFORCED_LEASE", b.SIMPLE_TAPROOT = "SIMPLE_TAPROOT", b.SIMPLE_TAPROOT_OVERLAY = "SIMPLE_TAPROOT_OVERLAY", b.UNRECOGNIZED = "UNRECOGNIZED", (T = o.Initiator || (o.Initiator = {})).INITIATOR_UNKNOWN = "INITIATOR_UNKNOWN", T.INITIATOR_LOCAL = "INITIATOR_LOCAL", T.INITIATOR_REMOTE = "INITIATOR_REMOTE", T.INITIATOR_BOTH = "INITIATOR_BOTH", T.UNRECOGNIZED = "UNRECOGNIZED", (_ = o.ResolutionType || (o.ResolutionType = {})).TYPE_UNKNOWN = "TYPE_UNKNOWN", _.ANCHOR = "ANCHOR", _.INCOMING_HTLC = "INCOMING_HTLC", _.OUTGOING_HTLC = "OUTGOING_HTLC", _.COMMIT = "COMMIT", _.UNRECOGNIZED = "UNRECOGNIZED", (g = o.ResolutionOutcome || (o.ResolutionOutcome = {})).OUTCOME_UNKNOWN = "OUTCOME_UNKNOWN", g.CLAIMED = "CLAIMED", g.UNCLAIMED = "UNCLAIMED", g.ABANDONED = "ABANDONED", g.FIRST_STAGE = "FIRST_STAGE", g.TIMEOUT = "TIMEOUT", g.UNRECOGNIZED = "UNRECOGNIZED", (y = o.NodeMetricType || (o.NodeMetricType = {})).UNKNOWN = "UNKNOWN", y.BETWEENNESS_CENTRALITY = "BETWEENNESS_CENTRALITY", y.UNRECOGNIZED = "UNRECOGNIZED", (v = o.InvoiceHTLCState || (o.InvoiceHTLCState = {})).ACCEPTED = "ACCEPTED", v.SETTLED = "SETTLED", v.CANCELED = "CANCELED", v.UNRECOGNIZED = "UNRECOGNIZED", (l = o.PaymentFailureReason || (o.PaymentFailureReason = {})).FAILURE_REASON_NONE = "FAILURE_REASON_NONE", l.FAILURE_REASON_TIMEOUT = "FAILURE_REASON_TIMEOUT", l.FAILURE_REASON_NO_ROUTE = "FAILURE_REASON_NO_ROUTE", l.FAILURE_REASON_ERROR = "FAILURE_REASON_ERROR", l.FAILURE_REASON_INCORRECT_PAYMENT_DETAILS = "FAILURE_REASON_INCORRECT_PAYMENT_DETAILS", l.FAILURE_REASON_INSUFFICIENT_BALANCE = "FAILURE_REASON_INSUFFICIENT_BALANCE", l.FAILURE_REASON_CANCELED = "FAILURE_REASON_CANCELED", l.UNRECOGNIZED = "UNRECOGNIZED", (p = o.FeatureBit || (o.FeatureBit = {})).DATALOSS_PROTECT_REQ = "DATALOSS_PROTECT_REQ", p.DATALOSS_PROTECT_OPT = "DATALOSS_PROTECT_OPT", p.INITIAL_ROUING_SYNC = "INITIAL_ROUING_SYNC", p.UPFRONT_SHUTDOWN_SCRIPT_REQ = "UPFRONT_SHUTDOWN_SCRIPT_REQ", p.UPFRONT_SHUTDOWN_SCRIPT_OPT = "UPFRONT_SHUTDOWN_SCRIPT_OPT", p.GOSSIP_QUERIES_REQ = "GOSSIP_QUERIES_REQ", p.GOSSIP_QUERIES_OPT = "GOSSIP_QUERIES_OPT", p.TLV_ONION_REQ = "TLV_ONION_REQ", p.TLV_ONION_OPT = "TLV_ONION_OPT", p.EXT_GOSSIP_QUERIES_REQ = "EXT_GOSSIP_QUERIES_REQ", p.EXT_GOSSIP_QUERIES_OPT = "EXT_GOSSIP_QUERIES_OPT", p.STATIC_REMOTE_KEY_REQ = "STATIC_REMOTE_KEY_REQ", p.STATIC_REMOTE_KEY_OPT = "STATIC_REMOTE_KEY_OPT", p.PAYMENT_ADDR_REQ = "PAYMENT_ADDR_REQ", p.PAYMENT_ADDR_OPT = "PAYMENT_ADDR_OPT", p.MPP_REQ = "MPP_REQ", p.MPP_OPT = "MPP_OPT", p.WUMBO_CHANNELS_REQ = "WUMBO_CHANNELS_REQ", p.WUMBO_CHANNELS_OPT = "WUMBO_CHANNELS_OPT", p.ANCHORS_REQ = "ANCHORS_REQ", p.ANCHORS_OPT = "ANCHORS_OPT", p.ANCHORS_ZERO_FEE_HTLC_REQ = "ANCHORS_ZERO_FEE_HTLC_REQ", p.ANCHORS_ZERO_FEE_HTLC_OPT = "ANCHORS_ZERO_FEE_HTLC_OPT", p.ROUTE_BLINDING_REQUIRED = "ROUTE_BLINDING_REQUIRED", p.ROUTE_BLINDING_OPTIONAL = "ROUTE_BLINDING_OPTIONAL", p.AMP_REQ = "AMP_REQ", p.AMP_OPT = "AMP_OPT", p.UNRECOGNIZED = "UNRECOGNIZED", (u = o.UpdateFailure || (o.UpdateFailure = {})).UPDATE_FAILURE_UNKNOWN = "UPDATE_FAILURE_UNKNOWN", u.UPDATE_FAILURE_PENDING = "UPDATE_FAILURE_PENDING", u.UPDATE_FAILURE_NOT_FOUND = "UPDATE_FAILURE_NOT_FOUND", u.UPDATE_FAILURE_INTERNAL_ERR = "UPDATE_FAILURE_INTERNAL_ERR", u.UPDATE_FAILURE_INVALID_PARAMETER = "UPDATE_FAILURE_INVALID_PARAMETER", u.UNRECOGNIZED = "UNRECOGNIZED", (s = o.ChannelCloseSummary_ClosureType || (o.ChannelCloseSummary_ClosureType = {})).COOPERATIVE_CLOSE = "COOPERATIVE_CLOSE", s.LOCAL_FORCE_CLOSE = "LOCAL_FORCE_CLOSE", s.REMOTE_FORCE_CLOSE = "REMOTE_FORCE_CLOSE", s.BREACH_CLOSE = "BREACH_CLOSE", s.FUNDING_CANCELED = "FUNDING_CANCELED", s.ABANDONED = "ABANDONED", s.UNRECOGNIZED = "UNRECOGNIZED", (c = o.Peer_SyncType || (o.Peer_SyncType = {})).UNKNOWN_SYNC = "UNKNOWN_SYNC", c.ACTIVE_SYNC = "ACTIVE_SYNC", c.PASSIVE_SYNC = "PASSIVE_SYNC", c.PINNED_SYNC = "PINNED_SYNC", c.UNRECOGNIZED = "UNRECOGNIZED", (t = o.PeerEvent_EventType || (o.PeerEvent_EventType = {})).PEER_ONLINE = "PEER_ONLINE", t.PEER_OFFLINE = "PEER_OFFLINE", t.UNRECOGNIZED = "UNRECOGNIZED", (e = o.PendingChannelsResponse_ForceClosedChannel_AnchorState || (o.PendingChannelsResponse_ForceClosedChannel_AnchorState = {})).LIMBO = "LIMBO", e.RECOVERED = "RECOVERED", e.LOST = "LOST", e.UNRECOGNIZED = "UNRECOGNIZED", (r = o.ChannelEventUpdate_UpdateType || (o.ChannelEventUpdate_UpdateType = {})).OPEN_CHANNEL = "OPEN_CHANNEL", r.CLOSED_CHANNEL = "CLOSED_CHANNEL", r.ACTIVE_CHANNEL = "ACTIVE_CHANNEL", r.INACTIVE_CHANNEL = "INACTIVE_CHANNEL", r.PENDING_OPEN_CHANNEL = "PENDING_OPEN_CHANNEL", r.FULLY_RESOLVED_CHANNEL = "FULLY_RESOLVED_CHANNEL", r.CHANNEL_FUNDING_TIMEOUT = "CHANNEL_FUNDING_TIMEOUT", r.UNRECOGNIZED = "UNRECOGNIZED", (n = o.Invoice_InvoiceState || (o.Invoice_InvoiceState = {})).OPEN = "OPEN", n.SETTLED = "SETTLED", n.CANCELED = "CANCELED", n.ACCEPTED = "ACCEPTED", n.UNRECOGNIZED = "UNRECOGNIZED", (i = o.Payment_PaymentStatus || (o.Payment_PaymentStatus = {})).UNKNOWN = "UNKNOWN", i.IN_FLIGHT = "IN_FLIGHT", i.SUCCEEDED = "SUCCEEDED", i.FAILED = "FAILED", i.INITIATED = "INITIATED", i.UNRECOGNIZED = "UNRECOGNIZED", (a = o.HTLCAttempt_HTLCStatus || (o.HTLCAttempt_HTLCStatus = {})).IN_FLIGHT = "IN_FLIGHT", a.SUCCEEDED = "SUCCEEDED", a.FAILED = "FAILED", a.UNRECOGNIZED = "UNRECOGNIZED", (f = o.Failure_FailureCode || (o.Failure_FailureCode = {})).RESERVED = "RESERVED", f.INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS = "INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS", f.INCORRECT_PAYMENT_AMOUNT = "INCORRECT_PAYMENT_AMOUNT", f.FINAL_INCORRECT_CLTV_EXPIRY = "FINAL_INCORRECT_CLTV_EXPIRY", f.FINAL_INCORRECT_HTLC_AMOUNT = "FINAL_INCORRECT_HTLC_AMOUNT", f.FINAL_EXPIRY_TOO_SOON = "FINAL_EXPIRY_TOO_SOON", f.INVALID_REALM = "INVALID_REALM", f.EXPIRY_TOO_SOON = "EXPIRY_TOO_SOON", f.INVALID_ONION_VERSION = "INVALID_ONION_VERSION", f.INVALID_ONION_HMAC = "INVALID_ONION_HMAC", f.INVALID_ONION_KEY = "INVALID_ONION_KEY", f.AMOUNT_BELOW_MINIMUM = "AMOUNT_BELOW_MINIMUM", f.FEE_INSUFFICIENT = "FEE_INSUFFICIENT", f.INCORRECT_CLTV_EXPIRY = "INCORRECT_CLTV_EXPIRY", f.CHANNEL_DISABLED = "CHANNEL_DISABLED", f.TEMPORARY_CHANNEL_FAILURE = "TEMPORARY_CHANNEL_FAILURE", f.REQUIRED_NODE_FEATURE_MISSING = "REQUIRED_NODE_FEATURE_MISSING", f.REQUIRED_CHANNEL_FEATURE_MISSING = "REQUIRED_CHANNEL_FEATURE_MISSING", f.UNKNOWN_NEXT_PEER = "UNKNOWN_NEXT_PEER", f.TEMPORARY_NODE_FAILURE = "TEMPORARY_NODE_FAILURE", f.PERMANENT_NODE_FAILURE = "PERMANENT_NODE_FAILURE", f.PERMANENT_CHANNEL_FAILURE = "PERMANENT_CHANNEL_FAILURE", f.EXPIRY_TOO_FAR = "EXPIRY_TOO_FAR", f.MPP_TIMEOUT = "MPP_TIMEOUT", f.INVALID_ONION_PAYLOAD = "INVALID_ONION_PAYLOAD", f.INVALID_ONION_BLINDING = "INVALID_ONION_BLINDING", f.INTERNAL_FAILURE = "INTERNAL_FAILURE", f.UNKNOWN_FAILURE = "UNKNOWN_FAILURE", f.UNREADABLE_FAILURE = "UNREADABLE_FAILURE", f.UNRECOGNIZED = "UNRECOGNIZED"; + }, 9353(d, o) { + var f, a; + Object.defineProperty(o, "__esModule", { value: !0 }), o.FeatureSet = o.UpdateAction = void 0, (a = o.UpdateAction || (o.UpdateAction = {})).ADD = "ADD", a.REMOVE = "REMOVE", a.UNRECOGNIZED = "UNRECOGNIZED", (f = o.FeatureSet || (o.FeatureSet = {})).SET_INIT = "SET_INIT", f.SET_LEGACY_GLOBAL = "SET_LEGACY_GLOBAL", f.SET_NODE_ANN = "SET_NODE_ANN", f.SET_INVOICE = "SET_INVOICE", f.SET_INVOICE_AMP = "SET_INVOICE_AMP", f.UNRECOGNIZED = "UNRECOGNIZED"; + }, 7543(d, o) { + var f, a, i, n, r, e; + Object.defineProperty(o, "__esModule", { value: !0 }), o.HtlcEvent_EventType = o.MissionControlConfig_ProbabilityModel = o.ChanStatusAction = o.ResolveHoldForwardAction = o.PaymentState = o.FailureDetail = void 0, (e = o.FailureDetail || (o.FailureDetail = {})).UNKNOWN = "UNKNOWN", e.NO_DETAIL = "NO_DETAIL", e.ONION_DECODE = "ONION_DECODE", e.LINK_NOT_ELIGIBLE = "LINK_NOT_ELIGIBLE", e.ON_CHAIN_TIMEOUT = "ON_CHAIN_TIMEOUT", e.HTLC_EXCEEDS_MAX = "HTLC_EXCEEDS_MAX", e.INSUFFICIENT_BALANCE = "INSUFFICIENT_BALANCE", e.INCOMPLETE_FORWARD = "INCOMPLETE_FORWARD", e.HTLC_ADD_FAILED = "HTLC_ADD_FAILED", e.FORWARDS_DISABLED = "FORWARDS_DISABLED", e.INVOICE_CANCELED = "INVOICE_CANCELED", e.INVOICE_UNDERPAID = "INVOICE_UNDERPAID", e.INVOICE_EXPIRY_TOO_SOON = "INVOICE_EXPIRY_TOO_SOON", e.INVOICE_NOT_OPEN = "INVOICE_NOT_OPEN", e.MPP_INVOICE_TIMEOUT = "MPP_INVOICE_TIMEOUT", e.ADDRESS_MISMATCH = "ADDRESS_MISMATCH", e.SET_TOTAL_MISMATCH = "SET_TOTAL_MISMATCH", e.SET_TOTAL_TOO_LOW = "SET_TOTAL_TOO_LOW", e.SET_OVERPAID = "SET_OVERPAID", e.UNKNOWN_INVOICE = "UNKNOWN_INVOICE", e.INVALID_KEYSEND = "INVALID_KEYSEND", e.MPP_IN_PROGRESS = "MPP_IN_PROGRESS", e.CIRCULAR_ROUTE = "CIRCULAR_ROUTE", e.UNRECOGNIZED = "UNRECOGNIZED", (r = o.PaymentState || (o.PaymentState = {})).IN_FLIGHT = "IN_FLIGHT", r.SUCCEEDED = "SUCCEEDED", r.FAILED_TIMEOUT = "FAILED_TIMEOUT", r.FAILED_NO_ROUTE = "FAILED_NO_ROUTE", r.FAILED_ERROR = "FAILED_ERROR", r.FAILED_INCORRECT_PAYMENT_DETAILS = "FAILED_INCORRECT_PAYMENT_DETAILS", r.FAILED_INSUFFICIENT_BALANCE = "FAILED_INSUFFICIENT_BALANCE", r.UNRECOGNIZED = "UNRECOGNIZED", (n = o.ResolveHoldForwardAction || (o.ResolveHoldForwardAction = {})).SETTLE = "SETTLE", n.FAIL = "FAIL", n.RESUME = "RESUME", n.RESUME_MODIFIED = "RESUME_MODIFIED", n.UNRECOGNIZED = "UNRECOGNIZED", (i = o.ChanStatusAction || (o.ChanStatusAction = {})).ENABLE = "ENABLE", i.DISABLE = "DISABLE", i.AUTO = "AUTO", i.UNRECOGNIZED = "UNRECOGNIZED", (a = o.MissionControlConfig_ProbabilityModel || (o.MissionControlConfig_ProbabilityModel = {})).APRIORI = "APRIORI", a.BIMODAL = "BIMODAL", a.UNRECOGNIZED = "UNRECOGNIZED", (f = o.HtlcEvent_EventType || (o.HtlcEvent_EventType = {})).UNKNOWN = "UNKNOWN", f.SEND = "SEND", f.RECEIVE = "RECEIVE", f.FORWARD = "FORWARD", f.UNRECOGNIZED = "UNRECOGNIZED"; + }, 5636(d, o) { + var f, a; + Object.defineProperty(o, "__esModule", { value: !0 }), o.MuSig2Version = o.SignMethod = void 0, (a = o.SignMethod || (o.SignMethod = {})).SIGN_METHOD_WITNESS_V0 = "SIGN_METHOD_WITNESS_V0", a.SIGN_METHOD_TAPROOT_KEY_SPEND_BIP0086 = "SIGN_METHOD_TAPROOT_KEY_SPEND_BIP0086", a.SIGN_METHOD_TAPROOT_KEY_SPEND = "SIGN_METHOD_TAPROOT_KEY_SPEND", a.SIGN_METHOD_TAPROOT_SCRIPT_SPEND = "SIGN_METHOD_TAPROOT_SCRIPT_SPEND", a.UNRECOGNIZED = "UNRECOGNIZED", (f = o.MuSig2Version || (o.MuSig2Version = {})).MUSIG2_VERSION_UNDEFINED = "MUSIG2_VERSION_UNDEFINED", f.MUSIG2_VERSION_V040 = "MUSIG2_VERSION_V040", f.MUSIG2_VERSION_V100RC2 = "MUSIG2_VERSION_V100RC2", f.UNRECOGNIZED = "UNRECOGNIZED"; + }, 4219(d, o) { + var f; + Object.defineProperty(o, "__esModule", { value: !0 }), o.WalletState = void 0, (f = o.WalletState || (o.WalletState = {})).NON_EXISTING = "NON_EXISTING", f.LOCKED = "LOCKED", f.UNLOCKED = "UNLOCKED", f.RPC_ACTIVE = "RPC_ACTIVE", f.SERVER_ACTIVE = "SERVER_ACTIVE", f.WAITING_TO_START = "WAITING_TO_START", f.UNRECOGNIZED = "UNRECOGNIZED"; + }, 5779(d, o) { + var f, a, i; + Object.defineProperty(o, "__esModule", { value: !0 }), o.ChangeAddressType = o.WitnessType = o.AddressType = void 0, (i = o.AddressType || (o.AddressType = {})).UNKNOWN = "UNKNOWN", i.WITNESS_PUBKEY_HASH = "WITNESS_PUBKEY_HASH", i.NESTED_WITNESS_PUBKEY_HASH = "NESTED_WITNESS_PUBKEY_HASH", i.HYBRID_NESTED_WITNESS_PUBKEY_HASH = "HYBRID_NESTED_WITNESS_PUBKEY_HASH", i.TAPROOT_PUBKEY = "TAPROOT_PUBKEY", i.UNRECOGNIZED = "UNRECOGNIZED", (a = o.WitnessType || (o.WitnessType = {})).UNKNOWN_WITNESS = "UNKNOWN_WITNESS", a.COMMITMENT_TIME_LOCK = "COMMITMENT_TIME_LOCK", a.COMMITMENT_NO_DELAY = "COMMITMENT_NO_DELAY", a.COMMITMENT_REVOKE = "COMMITMENT_REVOKE", a.HTLC_OFFERED_REVOKE = "HTLC_OFFERED_REVOKE", a.HTLC_ACCEPTED_REVOKE = "HTLC_ACCEPTED_REVOKE", a.HTLC_OFFERED_TIMEOUT_SECOND_LEVEL = "HTLC_OFFERED_TIMEOUT_SECOND_LEVEL", a.HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL = "HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL", a.HTLC_OFFERED_REMOTE_TIMEOUT = "HTLC_OFFERED_REMOTE_TIMEOUT", a.HTLC_ACCEPTED_REMOTE_SUCCESS = "HTLC_ACCEPTED_REMOTE_SUCCESS", a.HTLC_SECOND_LEVEL_REVOKE = "HTLC_SECOND_LEVEL_REVOKE", a.WITNESS_KEY_HASH = "WITNESS_KEY_HASH", a.NESTED_WITNESS_KEY_HASH = "NESTED_WITNESS_KEY_HASH", a.COMMITMENT_ANCHOR = "COMMITMENT_ANCHOR", a.COMMITMENT_NO_DELAY_TWEAKLESS = "COMMITMENT_NO_DELAY_TWEAKLESS", a.COMMITMENT_TO_REMOTE_CONFIRMED = "COMMITMENT_TO_REMOTE_CONFIRMED", a.HTLC_OFFERED_TIMEOUT_SECOND_LEVEL_INPUT_CONFIRMED = "HTLC_OFFERED_TIMEOUT_SECOND_LEVEL_INPUT_CONFIRMED", a.HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL_INPUT_CONFIRMED = "HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL_INPUT_CONFIRMED", a.LEASE_COMMITMENT_TIME_LOCK = "LEASE_COMMITMENT_TIME_LOCK", a.LEASE_COMMITMENT_TO_REMOTE_CONFIRMED = "LEASE_COMMITMENT_TO_REMOTE_CONFIRMED", a.LEASE_HTLC_OFFERED_TIMEOUT_SECOND_LEVEL = "LEASE_HTLC_OFFERED_TIMEOUT_SECOND_LEVEL", a.LEASE_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL = "LEASE_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL", a.TAPROOT_PUB_KEY_SPEND = "TAPROOT_PUB_KEY_SPEND", a.TAPROOT_LOCAL_COMMIT_SPEND = "TAPROOT_LOCAL_COMMIT_SPEND", a.TAPROOT_REMOTE_COMMIT_SPEND = "TAPROOT_REMOTE_COMMIT_SPEND", a.TAPROOT_ANCHOR_SWEEP_SPEND = "TAPROOT_ANCHOR_SWEEP_SPEND", a.TAPROOT_HTLC_OFFERED_TIMEOUT_SECOND_LEVEL = "TAPROOT_HTLC_OFFERED_TIMEOUT_SECOND_LEVEL", a.TAPROOT_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL = "TAPROOT_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL", a.TAPROOT_HTLC_SECOND_LEVEL_REVOKE = "TAPROOT_HTLC_SECOND_LEVEL_REVOKE", a.TAPROOT_HTLC_ACCEPTED_REVOKE = "TAPROOT_HTLC_ACCEPTED_REVOKE", a.TAPROOT_HTLC_OFFERED_REVOKE = "TAPROOT_HTLC_OFFERED_REVOKE", a.TAPROOT_HTLC_OFFERED_REMOTE_TIMEOUT = "TAPROOT_HTLC_OFFERED_REMOTE_TIMEOUT", a.TAPROOT_HTLC_LOCAL_OFFERED_TIMEOUT = "TAPROOT_HTLC_LOCAL_OFFERED_TIMEOUT", a.TAPROOT_HTLC_ACCEPTED_REMOTE_SUCCESS = "TAPROOT_HTLC_ACCEPTED_REMOTE_SUCCESS", a.TAPROOT_HTLC_ACCEPTED_LOCAL_SUCCESS = "TAPROOT_HTLC_ACCEPTED_LOCAL_SUCCESS", a.TAPROOT_COMMITMENT_REVOKE = "TAPROOT_COMMITMENT_REVOKE", a.UNRECOGNIZED = "UNRECOGNIZED", (f = o.ChangeAddressType || (o.ChangeAddressType = {})).CHANGE_ADDRESS_TYPE_UNSPECIFIED = "CHANGE_ADDRESS_TYPE_UNSPECIFIED", f.CHANGE_ADDRESS_TYPE_P2TR = "CHANGE_ADDRESS_TYPE_P2TR", f.UNRECOGNIZED = "UNRECOGNIZED"; + }, 5577(d, o) { + Object.defineProperty(o, "__esModule", { value: !0 }); + }, 4899(d, o) { + Object.defineProperty(o, "__esModule", { value: !0 }); + }, 6035(d, o) { + var f; + Object.defineProperty(o, "__esModule", { value: !0 }), o.PolicyType = void 0, (f = o.PolicyType || (o.PolicyType = {})).LEGACY = "LEGACY", f.ANCHOR = "ANCHOR", f.TAPROOT = "TAPROOT", f.UNRECOGNIZED = "UNRECOGNIZED"; + }, 1419(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(4377), o), i(f(4219), o), i(f(5577), o); + }, 1730(d, o) { + var f, a, i, n, r, e, t, c, s; + Object.defineProperty(o, "__esModule", { value: !0 }), o.ListSwapsFilter_SwapTypeFilter = o.StaticAddressLoopInSwapState = o.DepositState = o.AutoReason = o.LiquidityRuleType = o.FailureReason = o.SwapState = o.SwapType = o.AddressType = void 0, (s = o.AddressType || (o.AddressType = {})).ADDRESS_TYPE_UNKNOWN = "ADDRESS_TYPE_UNKNOWN", s.TAPROOT_PUBKEY = "TAPROOT_PUBKEY", s.UNRECOGNIZED = "UNRECOGNIZED", (c = o.SwapType || (o.SwapType = {})).LOOP_OUT = "LOOP_OUT", c.LOOP_IN = "LOOP_IN", c.UNRECOGNIZED = "UNRECOGNIZED", (t = o.SwapState || (o.SwapState = {})).INITIATED = "INITIATED", t.PREIMAGE_REVEALED = "PREIMAGE_REVEALED", t.HTLC_PUBLISHED = "HTLC_PUBLISHED", t.SUCCESS = "SUCCESS", t.FAILED = "FAILED", t.INVOICE_SETTLED = "INVOICE_SETTLED", t.UNRECOGNIZED = "UNRECOGNIZED", (e = o.FailureReason || (o.FailureReason = {})).FAILURE_REASON_NONE = "FAILURE_REASON_NONE", e.FAILURE_REASON_OFFCHAIN = "FAILURE_REASON_OFFCHAIN", e.FAILURE_REASON_TIMEOUT = "FAILURE_REASON_TIMEOUT", e.FAILURE_REASON_SWEEP_TIMEOUT = "FAILURE_REASON_SWEEP_TIMEOUT", e.FAILURE_REASON_INSUFFICIENT_VALUE = "FAILURE_REASON_INSUFFICIENT_VALUE", e.FAILURE_REASON_TEMPORARY = "FAILURE_REASON_TEMPORARY", e.FAILURE_REASON_INCORRECT_AMOUNT = "FAILURE_REASON_INCORRECT_AMOUNT", e.FAILURE_REASON_ABANDONED = "FAILURE_REASON_ABANDONED", e.FAILURE_REASON_INSUFFICIENT_CONFIRMED_BALANCE = "FAILURE_REASON_INSUFFICIENT_CONFIRMED_BALANCE", e.FAILURE_REASON_INCORRECT_HTLC_AMT_SWEPT = "FAILURE_REASON_INCORRECT_HTLC_AMT_SWEPT", e.UNRECOGNIZED = "UNRECOGNIZED", (r = o.LiquidityRuleType || (o.LiquidityRuleType = {})).UNKNOWN = "UNKNOWN", r.THRESHOLD = "THRESHOLD", r.UNRECOGNIZED = "UNRECOGNIZED", (n = o.AutoReason || (o.AutoReason = {})).AUTO_REASON_UNKNOWN = "AUTO_REASON_UNKNOWN", n.AUTO_REASON_BUDGET_NOT_STARTED = "AUTO_REASON_BUDGET_NOT_STARTED", n.AUTO_REASON_SWEEP_FEES = "AUTO_REASON_SWEEP_FEES", n.AUTO_REASON_BUDGET_ELAPSED = "AUTO_REASON_BUDGET_ELAPSED", n.AUTO_REASON_IN_FLIGHT = "AUTO_REASON_IN_FLIGHT", n.AUTO_REASON_SWAP_FEE = "AUTO_REASON_SWAP_FEE", n.AUTO_REASON_MINER_FEE = "AUTO_REASON_MINER_FEE", n.AUTO_REASON_PREPAY = "AUTO_REASON_PREPAY", n.AUTO_REASON_FAILURE_BACKOFF = "AUTO_REASON_FAILURE_BACKOFF", n.AUTO_REASON_LOOP_OUT = "AUTO_REASON_LOOP_OUT", n.AUTO_REASON_LOOP_IN = "AUTO_REASON_LOOP_IN", n.AUTO_REASON_LIQUIDITY_OK = "AUTO_REASON_LIQUIDITY_OK", n.AUTO_REASON_BUDGET_INSUFFICIENT = "AUTO_REASON_BUDGET_INSUFFICIENT", n.AUTO_REASON_FEE_INSUFFICIENT = "AUTO_REASON_FEE_INSUFFICIENT", n.UNRECOGNIZED = "UNRECOGNIZED", (i = o.DepositState || (o.DepositState = {})).UNKNOWN_STATE = "UNKNOWN_STATE", i.DEPOSITED = "DEPOSITED", i.WITHDRAWING = "WITHDRAWING", i.WITHDRAWN = "WITHDRAWN", i.LOOPING_IN = "LOOPING_IN", i.LOOPED_IN = "LOOPED_IN", i.SWEEP_HTLC_TIMEOUT = "SWEEP_HTLC_TIMEOUT", i.HTLC_TIMEOUT_SWEPT = "HTLC_TIMEOUT_SWEPT", i.PUBLISH_EXPIRED = "PUBLISH_EXPIRED", i.WAIT_FOR_EXPIRY_SWEEP = "WAIT_FOR_EXPIRY_SWEEP", i.EXPIRED = "EXPIRED", i.UNRECOGNIZED = "UNRECOGNIZED", (a = o.StaticAddressLoopInSwapState || (o.StaticAddressLoopInSwapState = {})).UNKNOWN_STATIC_ADDRESS_SWAP_STATE = "UNKNOWN_STATIC_ADDRESS_SWAP_STATE", a.INIT_HTLC = "INIT_HTLC", a.SIGN_HTLC_TX = "SIGN_HTLC_TX", a.MONITOR_INVOICE_HTLC_TX = "MONITOR_INVOICE_HTLC_TX", a.PAYMENT_RECEIVED = "PAYMENT_RECEIVED", a.SWEEP_STATIC_ADDRESS_HTLC_TIMEOUT = "SWEEP_STATIC_ADDRESS_HTLC_TIMEOUT", a.MONITOR_HTLC_TIMEOUT_SWEEP = "MONITOR_HTLC_TIMEOUT_SWEEP", a.HTLC_STATIC_ADDRESS_TIMEOUT_SWEPT = "HTLC_STATIC_ADDRESS_TIMEOUT_SWEPT", a.SUCCEEDED = "SUCCEEDED", a.SUCCEEDED_TRANSITIONING_FAILED = "SUCCEEDED_TRANSITIONING_FAILED", a.UNLOCK_DEPOSITS = "UNLOCK_DEPOSITS", a.FAILED_STATIC_ADDRESS_SWAP = "FAILED_STATIC_ADDRESS_SWAP", a.UNRECOGNIZED = "UNRECOGNIZED", (f = o.ListSwapsFilter_SwapTypeFilter || (o.ListSwapsFilter_SwapTypeFilter = {})).ANY = "ANY", f.LOOP_OUT = "LOOP_OUT", f.LOOP_IN = "LOOP_IN", f.UNRECOGNIZED = "UNRECOGNIZED"; + }, 66(d, o) { + Object.defineProperty(o, "__esModule", { value: !0 }); + }, 7967(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(1730), o), i(f(66), o); + }, 1393(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(5398), o); + }, 1908(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(9353), o); + }, 3029(d, o) { + var f, a, i, n, r, e, t, c, s, u, p, l, v, y; + Object.defineProperty(o, "__esModule", { value: !0 }), o.InvalidOrder_FailReason = o.AccountDiff_AccountState = o.SubscribeError_Error = o.OrderReject_OrderRejectReason = o.OrderMatchReject_RejectReason = o.DurationBucketState = o.OrderState = o.ChannelConfirmationConstraints = o.ChannelAnnouncementConstraints = o.NodeTier = o.AuctionType = o.OrderChannelType = o.AuctionAccountState = o.ChannelType = void 0, (y = o.ChannelType || (o.ChannelType = {})).TWEAKLESS = "TWEAKLESS", y.ANCHORS = "ANCHORS", y.SCRIPT_ENFORCED_LEASE = "SCRIPT_ENFORCED_LEASE", y.UNRECOGNIZED = "UNRECOGNIZED", (v = o.AuctionAccountState || (o.AuctionAccountState = {})).STATE_PENDING_OPEN = "STATE_PENDING_OPEN", v.STATE_OPEN = "STATE_OPEN", v.STATE_EXPIRED = "STATE_EXPIRED", v.STATE_PENDING_UPDATE = "STATE_PENDING_UPDATE", v.STATE_CLOSED = "STATE_CLOSED", v.STATE_PENDING_BATCH = "STATE_PENDING_BATCH", v.STATE_EXPIRED_PENDING_UPDATE = "STATE_EXPIRED_PENDING_UPDATE", v.UNRECOGNIZED = "UNRECOGNIZED", (l = o.OrderChannelType || (o.OrderChannelType = {})).ORDER_CHANNEL_TYPE_UNKNOWN = "ORDER_CHANNEL_TYPE_UNKNOWN", l.ORDER_CHANNEL_TYPE_PEER_DEPENDENT = "ORDER_CHANNEL_TYPE_PEER_DEPENDENT", l.ORDER_CHANNEL_TYPE_SCRIPT_ENFORCED = "ORDER_CHANNEL_TYPE_SCRIPT_ENFORCED", l.UNRECOGNIZED = "UNRECOGNIZED", (p = o.AuctionType || (o.AuctionType = {})).AUCTION_TYPE_BTC_INBOUND_LIQUIDITY = "AUCTION_TYPE_BTC_INBOUND_LIQUIDITY", p.AUCTION_TYPE_BTC_OUTBOUND_LIQUIDITY = "AUCTION_TYPE_BTC_OUTBOUND_LIQUIDITY", p.UNRECOGNIZED = "UNRECOGNIZED", (u = o.NodeTier || (o.NodeTier = {})).TIER_DEFAULT = "TIER_DEFAULT", u.TIER_0 = "TIER_0", u.TIER_1 = "TIER_1", u.UNRECOGNIZED = "UNRECOGNIZED", (s = o.ChannelAnnouncementConstraints || (o.ChannelAnnouncementConstraints = {})).ANNOUNCEMENT_NO_PREFERENCE = "ANNOUNCEMENT_NO_PREFERENCE", s.ONLY_ANNOUNCED = "ONLY_ANNOUNCED", s.ONLY_UNANNOUNCED = "ONLY_UNANNOUNCED", s.UNRECOGNIZED = "UNRECOGNIZED", (c = o.ChannelConfirmationConstraints || (o.ChannelConfirmationConstraints = {})).CONFIRMATION_NO_PREFERENCE = "CONFIRMATION_NO_PREFERENCE", c.ONLY_CONFIRMED = "ONLY_CONFIRMED", c.ONLY_ZEROCONF = "ONLY_ZEROCONF", c.UNRECOGNIZED = "UNRECOGNIZED", (t = o.OrderState || (o.OrderState = {})).ORDER_SUBMITTED = "ORDER_SUBMITTED", t.ORDER_CLEARED = "ORDER_CLEARED", t.ORDER_PARTIALLY_FILLED = "ORDER_PARTIALLY_FILLED", t.ORDER_EXECUTED = "ORDER_EXECUTED", t.ORDER_CANCELED = "ORDER_CANCELED", t.ORDER_EXPIRED = "ORDER_EXPIRED", t.ORDER_FAILED = "ORDER_FAILED", t.UNRECOGNIZED = "UNRECOGNIZED", (e = o.DurationBucketState || (o.DurationBucketState = {})).NO_MARKET = "NO_MARKET", e.MARKET_CLOSED = "MARKET_CLOSED", e.ACCEPTING_ORDERS = "ACCEPTING_ORDERS", e.MARKET_OPEN = "MARKET_OPEN", e.UNRECOGNIZED = "UNRECOGNIZED", (r = o.OrderMatchReject_RejectReason || (o.OrderMatchReject_RejectReason = {})).UNKNOWN = "UNKNOWN", r.SERVER_MISBEHAVIOR = "SERVER_MISBEHAVIOR", r.BATCH_VERSION_MISMATCH = "BATCH_VERSION_MISMATCH", r.PARTIAL_REJECT = "PARTIAL_REJECT", r.UNRECOGNIZED = "UNRECOGNIZED", (n = o.OrderReject_OrderRejectReason || (o.OrderReject_OrderRejectReason = {})).DUPLICATE_PEER = "DUPLICATE_PEER", n.CHANNEL_FUNDING_FAILED = "CHANNEL_FUNDING_FAILED", n.UNRECOGNIZED = "UNRECOGNIZED", (i = o.SubscribeError_Error || (o.SubscribeError_Error = {})).UNKNOWN = "UNKNOWN", i.SERVER_SHUTDOWN = "SERVER_SHUTDOWN", i.ACCOUNT_DOES_NOT_EXIST = "ACCOUNT_DOES_NOT_EXIST", i.INCOMPLETE_ACCOUNT_RESERVATION = "INCOMPLETE_ACCOUNT_RESERVATION", i.UNRECOGNIZED = "UNRECOGNIZED", (a = o.AccountDiff_AccountState || (o.AccountDiff_AccountState = {})).OUTPUT_RECREATED = "OUTPUT_RECREATED", a.OUTPUT_DUST_EXTENDED_OFFCHAIN = "OUTPUT_DUST_EXTENDED_OFFCHAIN", a.OUTPUT_DUST_ADDED_TO_FEES = "OUTPUT_DUST_ADDED_TO_FEES", a.OUTPUT_FULLY_SPENT = "OUTPUT_FULLY_SPENT", a.UNRECOGNIZED = "UNRECOGNIZED", (f = o.InvalidOrder_FailReason || (o.InvalidOrder_FailReason = {})).INVALID_AMT = "INVALID_AMT", f.UNRECOGNIZED = "UNRECOGNIZED"; + }, 4541(d, o) { + Object.defineProperty(o, "__esModule", { value: !0 }); + }, 7521(d, o) { + var f, a, i, n; + Object.defineProperty(o, "__esModule", { value: !0 }), o.MatchRejectReason = o.MatchState = o.AccountState = o.AccountVersion = void 0, (n = o.AccountVersion || (o.AccountVersion = {})).ACCOUNT_VERSION_LND_DEPENDENT = "ACCOUNT_VERSION_LND_DEPENDENT", n.ACCOUNT_VERSION_LEGACY = "ACCOUNT_VERSION_LEGACY", n.ACCOUNT_VERSION_TAPROOT = "ACCOUNT_VERSION_TAPROOT", n.ACCOUNT_VERSION_TAPROOT_V2 = "ACCOUNT_VERSION_TAPROOT_V2", n.UNRECOGNIZED = "UNRECOGNIZED", (i = o.AccountState || (o.AccountState = {})).PENDING_OPEN = "PENDING_OPEN", i.PENDING_UPDATE = "PENDING_UPDATE", i.OPEN = "OPEN", i.EXPIRED = "EXPIRED", i.PENDING_CLOSED = "PENDING_CLOSED", i.CLOSED = "CLOSED", i.RECOVERY_FAILED = "RECOVERY_FAILED", i.PENDING_BATCH = "PENDING_BATCH", i.UNRECOGNIZED = "UNRECOGNIZED", (a = o.MatchState || (o.MatchState = {})).PREPARE = "PREPARE", a.ACCEPTED = "ACCEPTED", a.REJECTED = "REJECTED", a.SIGNED = "SIGNED", a.FINALIZED = "FINALIZED", a.UNRECOGNIZED = "UNRECOGNIZED", (f = o.MatchRejectReason || (o.MatchRejectReason = {})).NONE = "NONE", f.SERVER_MISBEHAVIOR = "SERVER_MISBEHAVIOR", f.BATCH_VERSION_MISMATCH = "BATCH_VERSION_MISMATCH", f.PARTIAL_REJECT_COLLATERAL = "PARTIAL_REJECT_COLLATERAL", f.PARTIAL_REJECT_DUPLICATE_PEER = "PARTIAL_REJECT_DUPLICATE_PEER", f.PARTIAL_REJECT_CHANNEL_FUNDING_FAILED = "PARTIAL_REJECT_CHANNEL_FUNDING_FAILED", f.UNRECOGNIZED = "UNRECOGNIZED"; + }, 2471(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(3029), o), i(f(4541), o), i(f(7521), o); + }, 2162(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(9719), o); + }, 4386(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(1380), o); + }, 6534(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(7543), o); + }, 2495(d, o) { + Object.defineProperty(o, "__esModule", { value: !0 }), o.subscriptionMethods = o.serviceNames = void 0, o.serviceNames = { frdrpc: { FaradayServer: "frdrpc.FaradayServer" }, litrpc: { Firewall: "litrpc.Firewall", Autopilot: "litrpc.Autopilot", Sessions: "litrpc.Sessions", Status: "litrpc.Status" }, autopilotrpc: { Autopilot: "autopilotrpc.Autopilot" }, chainrpc: { ChainNotifier: "chainrpc.ChainNotifier" }, invoicesrpc: { Invoices: "invoicesrpc.Invoices" }, lnrpc: { Lightning: "lnrpc.Lightning", State: "lnrpc.State", WalletUnlocker: "lnrpc.WalletUnlocker" }, peersrpc: { Peers: "peersrpc.Peers" }, routerrpc: { Router: "routerrpc.Router" }, signrpc: { Signer: "signrpc.Signer" }, walletrpc: { WalletKit: "walletrpc.WalletKit" }, watchtowerrpc: { Watchtower: "watchtowerrpc.Watchtower" }, wtclientrpc: { WatchtowerClient: "wtclientrpc.WatchtowerClient" }, looprpc: { SwapClient: "looprpc.SwapClient", Debug: "looprpc.Debug" }, poolrpc: { ChannelAuctioneer: "poolrpc.ChannelAuctioneer", HashMail: "poolrpc.HashMail", Trader: "poolrpc.Trader" }, assetwalletrpc: { AssetWallet: "assetwalletrpc.AssetWallet" }, authmailboxrpc: { Mailbox: "authmailboxrpc.Mailbox" }, mintrpc: { Mint: "mintrpc.Mint" }, priceoraclerpc: { PriceOracle: "priceoraclerpc.PriceOracle" }, rfqrpc: { Rfq: "rfqrpc.Rfq" }, tapchannelrpc: { TaprootAssetChannels: "tapchannelrpc.TaprootAssetChannels" }, tapdevrpc: { TapDev: "tapdevrpc.TapDev" }, taprpc: { TaprootAssets: "taprpc.TaprootAssets" }, universerpc: { Universe: "universerpc.Universe" } }, o.subscriptionMethods = ["chainrpc.ChainNotifier.RegisterConfirmationsNtfn", "chainrpc.ChainNotifier.RegisterSpendNtfn", "chainrpc.ChainNotifier.RegisterBlockEpochNtfn", "invoicesrpc.Invoices.SubscribeSingleInvoice", "invoicesrpc.Invoices.HtlcModifier", "lnrpc.Lightning.SubscribeTransactions", "lnrpc.Lightning.SubscribePeerEvents", "lnrpc.Lightning.SubscribeChannelEvents", "lnrpc.Lightning.OpenChannel", "lnrpc.Lightning.ChannelAcceptor", "lnrpc.Lightning.CloseChannel", "lnrpc.Lightning.SendPayment", "lnrpc.Lightning.SendToRoute", "lnrpc.Lightning.SubscribeInvoices", "lnrpc.Lightning.SubscribeChannelGraph", "lnrpc.Lightning.SubscribeChannelBackups", "lnrpc.Lightning.RegisterRPCMiddleware", "lnrpc.Lightning.SubscribeCustomMessages", "routerrpc.Router.SendPaymentV2", "routerrpc.Router.TrackPaymentV2", "routerrpc.Router.TrackPayments", "routerrpc.Router.SubscribeHtlcEvents", "routerrpc.Router.SendPayment", "routerrpc.Router.TrackPayment", "routerrpc.Router.HtlcInterceptor", "lnrpc.State.SubscribeState", "looprpc.SwapClient.Monitor", "poolrpc.ChannelAuctioneer.SubscribeBatchAuction", "poolrpc.ChannelAuctioneer.SubscribeSidecar", "poolrpc.HashMail.RecvStream", "authmailboxrpc.Mailbox.ReceiveMessages", "lnrpc.Lightning.SubscribeTransactions", "lnrpc.Lightning.SubscribePeerEvents", "lnrpc.Lightning.SubscribeChannelEvents", "lnrpc.Lightning.OpenChannel", "lnrpc.Lightning.ChannelAcceptor", "lnrpc.Lightning.CloseChannel", "lnrpc.Lightning.SendPayment", "lnrpc.Lightning.SendToRoute", "lnrpc.Lightning.SubscribeInvoices", "lnrpc.Lightning.SubscribeChannelGraph", "lnrpc.Lightning.SubscribeChannelBackups", "lnrpc.Lightning.RegisterRPCMiddleware", "lnrpc.Lightning.SubscribeCustomMessages", "mintrpc.Mint.SubscribeMintEvents", "rfqrpc.Rfq.SubscribeRfqEventNtfns", "routerrpc.Router.SendPaymentV2", "routerrpc.Router.TrackPaymentV2", "routerrpc.Router.TrackPayments", "routerrpc.Router.SubscribeHtlcEvents", "routerrpc.Router.SendPayment", "routerrpc.Router.TrackPayment", "routerrpc.Router.HtlcInterceptor", "tapchannelrpc.TaprootAssetChannels.SendPayment", "tapdevrpc.TapDev.SubscribeSendAssetEventNtfns", "tapdevrpc.TapDev.SubscribeReceiveAssetEventNtfns", "taprpc.TaprootAssets.SubscribeReceiveEvents", "taprpc.TaprootAssets.SubscribeSendEvents"]; + }, 8054(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(5636), o); + }, 8933(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(6190), o); + }, 5712(d, o) { + var f; + Object.defineProperty(o, "__esModule", { value: !0 }), o.CoinSelectType = void 0, (f = o.CoinSelectType || (o.CoinSelectType = {})).COIN_SELECT_DEFAULT = "COIN_SELECT_DEFAULT", f.COIN_SELECT_BIP86_ONLY = "COIN_SELECT_BIP86_ONLY", f.COIN_SELECT_SCRIPT_TREES_ALLOWED = "COIN_SELECT_SCRIPT_TREES_ALLOWED", f.UNRECOGNIZED = "UNRECOGNIZED"; + }, 4376(d, o) { + Object.defineProperty(o, "__esModule", { value: !0 }); + }, 5398(d, o) { + var f; + Object.defineProperty(o, "__esModule", { value: !0 }), o.BatchState = void 0, (f = o.BatchState || (o.BatchState = {})).BATCH_STATE_UNKNOWN = "BATCH_STATE_UNKNOWN", f.BATCH_STATE_PENDING = "BATCH_STATE_PENDING", f.BATCH_STATE_FROZEN = "BATCH_STATE_FROZEN", f.BATCH_STATE_COMMITTED = "BATCH_STATE_COMMITTED", f.BATCH_STATE_BROADCAST = "BATCH_STATE_BROADCAST", f.BATCH_STATE_CONFIRMED = "BATCH_STATE_CONFIRMED", f.BATCH_STATE_FINALIZED = "BATCH_STATE_FINALIZED", f.BATCH_STATE_SEEDLING_CANCELLED = "BATCH_STATE_SEEDLING_CANCELLED", f.BATCH_STATE_SPROUT_CANCELLED = "BATCH_STATE_SPROUT_CANCELLED", f.UNRECOGNIZED = "UNRECOGNIZED"; + }, 9719(d, o) { + var f, a; + Object.defineProperty(o, "__esModule", { value: !0 }), o.Intent = o.TransactionType = void 0, (a = o.TransactionType || (o.TransactionType = {})).PURCHASE = "PURCHASE", a.SALE = "SALE", a.UNRECOGNIZED = "UNRECOGNIZED", (f = o.Intent || (o.Intent = {})).INTENT_UNSPECIFIED = "INTENT_UNSPECIFIED", f.INTENT_PAY_INVOICE_HINT = "INTENT_PAY_INVOICE_HINT", f.INTENT_PAY_INVOICE = "INTENT_PAY_INVOICE", f.INTENT_PAY_INVOICE_QUALIFY = "INTENT_PAY_INVOICE_QUALIFY", f.INTENT_RECV_PAYMENT_HINT = "INTENT_RECV_PAYMENT_HINT", f.INTENT_RECV_PAYMENT = "INTENT_RECV_PAYMENT", f.INTENT_RECV_PAYMENT_QUALIFY = "INTENT_RECV_PAYMENT_QUALIFY", f.UNRECOGNIZED = "UNRECOGNIZED"; + }, 1380(d, o) { + var f; + Object.defineProperty(o, "__esModule", { value: !0 }), o.QuoteRespStatus = void 0, (f = o.QuoteRespStatus || (o.QuoteRespStatus = {})).INVALID_ASSET_RATES = "INVALID_ASSET_RATES", f.INVALID_EXPIRY = "INVALID_EXPIRY", f.PRICE_ORACLE_QUERY_ERR = "PRICE_ORACLE_QUERY_ERR", f.UNRECOGNIZED = "UNRECOGNIZED"; + }, 6190(d, o) { + Object.defineProperty(o, "__esModule", { value: !0 }); + }, 3126(d, o) { + var f; + Object.defineProperty(o, "__esModule", { value: !0 }), o.ProofTransferType = void 0, (f = o.ProofTransferType || (o.ProofTransferType = {})).PROOF_TRANSFER_TYPE_SEND = "PROOF_TRANSFER_TYPE_SEND", f.PROOF_TRANSFER_TYPE_RECEIVE = "PROOF_TRANSFER_TYPE_RECEIVE", f.UNRECOGNIZED = "UNRECOGNIZED"; + }, 8960(d, o) { + var f, a, i, n, r, e, t, c, s, u; + Object.defineProperty(o, "__esModule", { value: !0 }), o.ParcelType = o.SendState = o.AddrEventStatus = o.ScriptKeyType = o.AddrVersion = o.ProofDeliveryStatus = o.OutputType = o.AssetVersion = o.AssetMetaType = o.AssetType = void 0, (u = o.AssetType || (o.AssetType = {})).NORMAL = "NORMAL", u.COLLECTIBLE = "COLLECTIBLE", u.UNRECOGNIZED = "UNRECOGNIZED", (s = o.AssetMetaType || (o.AssetMetaType = {})).META_TYPE_OPAQUE = "META_TYPE_OPAQUE", s.META_TYPE_JSON = "META_TYPE_JSON", s.UNRECOGNIZED = "UNRECOGNIZED", (c = o.AssetVersion || (o.AssetVersion = {})).ASSET_VERSION_V0 = "ASSET_VERSION_V0", c.ASSET_VERSION_V1 = "ASSET_VERSION_V1", c.UNRECOGNIZED = "UNRECOGNIZED", (t = o.OutputType || (o.OutputType = {})).OUTPUT_TYPE_SIMPLE = "OUTPUT_TYPE_SIMPLE", t.OUTPUT_TYPE_SPLIT_ROOT = "OUTPUT_TYPE_SPLIT_ROOT", t.UNRECOGNIZED = "UNRECOGNIZED", (e = o.ProofDeliveryStatus || (o.ProofDeliveryStatus = {})).PROOF_DELIVERY_STATUS_NOT_APPLICABLE = "PROOF_DELIVERY_STATUS_NOT_APPLICABLE", e.PROOF_DELIVERY_STATUS_COMPLETE = "PROOF_DELIVERY_STATUS_COMPLETE", e.PROOF_DELIVERY_STATUS_PENDING = "PROOF_DELIVERY_STATUS_PENDING", e.UNRECOGNIZED = "UNRECOGNIZED", (r = o.AddrVersion || (o.AddrVersion = {})).ADDR_VERSION_UNSPECIFIED = "ADDR_VERSION_UNSPECIFIED", r.ADDR_VERSION_V0 = "ADDR_VERSION_V0", r.ADDR_VERSION_V1 = "ADDR_VERSION_V1", r.ADDR_VERSION_V2 = "ADDR_VERSION_V2", r.UNRECOGNIZED = "UNRECOGNIZED", (n = o.ScriptKeyType || (o.ScriptKeyType = {})).SCRIPT_KEY_UNKNOWN = "SCRIPT_KEY_UNKNOWN", n.SCRIPT_KEY_BIP86 = "SCRIPT_KEY_BIP86", n.SCRIPT_KEY_SCRIPT_PATH_EXTERNAL = "SCRIPT_KEY_SCRIPT_PATH_EXTERNAL", n.SCRIPT_KEY_BURN = "SCRIPT_KEY_BURN", n.SCRIPT_KEY_TOMBSTONE = "SCRIPT_KEY_TOMBSTONE", n.SCRIPT_KEY_CHANNEL = "SCRIPT_KEY_CHANNEL", n.SCRIPT_KEY_UNIQUE_PEDERSEN = "SCRIPT_KEY_UNIQUE_PEDERSEN", n.UNRECOGNIZED = "UNRECOGNIZED", (i = o.AddrEventStatus || (o.AddrEventStatus = {})).ADDR_EVENT_STATUS_UNKNOWN = "ADDR_EVENT_STATUS_UNKNOWN", i.ADDR_EVENT_STATUS_TRANSACTION_DETECTED = "ADDR_EVENT_STATUS_TRANSACTION_DETECTED", i.ADDR_EVENT_STATUS_TRANSACTION_CONFIRMED = "ADDR_EVENT_STATUS_TRANSACTION_CONFIRMED", i.ADDR_EVENT_STATUS_PROOF_RECEIVED = "ADDR_EVENT_STATUS_PROOF_RECEIVED", i.ADDR_EVENT_STATUS_COMPLETED = "ADDR_EVENT_STATUS_COMPLETED", i.UNRECOGNIZED = "UNRECOGNIZED", (a = o.SendState || (o.SendState = {})).SEND_STATE_VIRTUAL_INPUT_SELECT = "SEND_STATE_VIRTUAL_INPUT_SELECT", a.SEND_STATE_VIRTUAL_SIGN = "SEND_STATE_VIRTUAL_SIGN", a.SEND_STATE_ANCHOR_SIGN = "SEND_STATE_ANCHOR_SIGN", a.SEND_STATE_LOG_COMMITMENT = "SEND_STATE_LOG_COMMITMENT", a.SEND_STATE_BROADCAST = "SEND_STATE_BROADCAST", a.SEND_STATE_WAIT_CONFIRMATION = "SEND_STATE_WAIT_CONFIRMATION", a.SEND_STATE_STORE_PROOFS = "SEND_STATE_STORE_PROOFS", a.SEND_STATE_TRANSFER_PROOFS = "SEND_STATE_TRANSFER_PROOFS", a.SEND_STATE_COMPLETED = "SEND_STATE_COMPLETED", a.UNRECOGNIZED = "UNRECOGNIZED", (f = o.ParcelType || (o.ParcelType = {})).PARCEL_TYPE_ADDRESS = "PARCEL_TYPE_ADDRESS", f.PARCEL_TYPE_PRE_SIGNED = "PARCEL_TYPE_PRE_SIGNED", f.PARCEL_TYPE_PENDING = "PARCEL_TYPE_PENDING", f.PARCEL_TYPE_PRE_ANCHORED = "PARCEL_TYPE_PRE_ANCHORED", f.UNRECOGNIZED = "UNRECOGNIZED"; + }, 5558(d, o) { + var f, a, i, n, r; + Object.defineProperty(o, "__esModule", { value: !0 }), o.AssetTypeFilter = o.SortDirection = o.AssetQuerySort = o.UniverseSyncMode = o.ProofType = void 0, (r = o.ProofType || (o.ProofType = {})).PROOF_TYPE_UNSPECIFIED = "PROOF_TYPE_UNSPECIFIED", r.PROOF_TYPE_ISSUANCE = "PROOF_TYPE_ISSUANCE", r.PROOF_TYPE_TRANSFER = "PROOF_TYPE_TRANSFER", r.UNRECOGNIZED = "UNRECOGNIZED", (n = o.UniverseSyncMode || (o.UniverseSyncMode = {})).SYNC_ISSUANCE_ONLY = "SYNC_ISSUANCE_ONLY", n.SYNC_FULL = "SYNC_FULL", n.UNRECOGNIZED = "UNRECOGNIZED", (i = o.AssetQuerySort || (o.AssetQuerySort = {})).SORT_BY_NONE = "SORT_BY_NONE", i.SORT_BY_ASSET_NAME = "SORT_BY_ASSET_NAME", i.SORT_BY_ASSET_ID = "SORT_BY_ASSET_ID", i.SORT_BY_ASSET_TYPE = "SORT_BY_ASSET_TYPE", i.SORT_BY_TOTAL_SYNCS = "SORT_BY_TOTAL_SYNCS", i.SORT_BY_TOTAL_PROOFS = "SORT_BY_TOTAL_PROOFS", i.SORT_BY_GENESIS_HEIGHT = "SORT_BY_GENESIS_HEIGHT", i.SORT_BY_TOTAL_SUPPLY = "SORT_BY_TOTAL_SUPPLY", i.UNRECOGNIZED = "UNRECOGNIZED", (a = o.SortDirection || (o.SortDirection = {})).SORT_DIRECTION_ASC = "SORT_DIRECTION_ASC", a.SORT_DIRECTION_DESC = "SORT_DIRECTION_DESC", a.UNRECOGNIZED = "UNRECOGNIZED", (f = o.AssetTypeFilter || (o.AssetTypeFilter = {})).FILTER_ASSET_NONE = "FILTER_ASSET_NONE", f.FILTER_ASSET_NORMAL = "FILTER_ASSET_NORMAL", f.FILTER_ASSET_COLLECTIBLE = "FILTER_ASSET_COLLECTIBLE", f.UNRECOGNIZED = "UNRECOGNIZED"; + }, 8753(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(3126), o); + }, 5600(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(8960), o); + }, 7164(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(5558), o); + }, 718(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(5779), o); + }, 5109(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(4899), o); + }, 7685(d, o, f) { + var a = this && this.__createBinding || (Object.create ? function(n, r, e, t) { + t === void 0 && (t = e), Object.defineProperty(n, t, { enumerable: !0, get: function() { + return r[e]; + } }); + } : function(n, r, e, t) { + t === void 0 && (t = e), n[t] = r[e]; + }), i = this && this.__exportStar || function(n, r) { + for (var e in n) e === "default" || Object.prototype.hasOwnProperty.call(r, e) || a(r, n, e); + }; + Object.defineProperty(o, "__esModule", { value: !0 }), i(f(6035), o); + }, 1022(d, o) { + Object.defineProperty(o, "__esModule", { value: !0 }), o.camelKeysToSnake = o.snakeKeysToCamel = o.isObject = void 0; + var f = function(a) { + return Array.isArray(a); + }; + o.isObject = function(a) { + return a === Object(a) && !f(a) && typeof a != "function"; + }, o.snakeKeysToCamel = function(a) { + if ((0, o.isObject)(a)) { + var i = {}; + return Object.keys(a).forEach(function(n) { + var r; + i[r = n, r.replace(/([-_][a-z])/gi, function(e) { + return e.toUpperCase().replace("-", "").replace("_", ""); + })] = (0, o.snakeKeysToCamel)(a[n]); + }), i; + } + return f(a) ? a.map(function(n) { + return (0, o.snakeKeysToCamel)(n); + }) : a; + }, o.camelKeysToSnake = function(a) { + if ((0, o.isObject)(a)) { + var i = {}; + return Object.keys(a).forEach(function(n) { + var r; + i[r = n, r.replace(/[A-Z]/g, function(e) { + return "_".concat(e.toLowerCase()); + })] = (0, o.camelKeysToSnake)(a[n]); + }), i; + } + return f(a) ? a.map(function(n) { + return (0, o.camelKeysToSnake)(n); + }) : a; + }; + } }, h = {}; + return (function d(o) { + var f = h[o]; + if (f !== void 0) return f.exports; + var a = h[o] = { exports: {} }; + return E[o].call(a.exports, a, a.exports, d), a.exports; + })(4245); + })(), N.exports = O(); + }, 4148(N, O, E) { + var h = E(5606), d = E(6763); + function o(w) { + return o = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(C) { + return typeof C; + } : function(C) { + return C && typeof Symbol == "function" && C.constructor === Symbol && C !== Symbol.prototype ? "symbol" : typeof C; + }, o(w); + } + function f(w, C, R) { + return Object.defineProperty(w, "prototype", { writable: !1 }), w; + } + var a, i, n = E(9597).codes, r = n.ERR_AMBIGUOUS_ARGUMENT, e = n.ERR_INVALID_ARG_TYPE, t = n.ERR_INVALID_ARG_VALUE, c = n.ERR_INVALID_RETURN_VALUE, s = n.ERR_MISSING_ARGS, u = E(3918), p = E(537).inspect, l = E(537).types, v = l.isPromise, y = l.isRegExp, g = E(9133)(), _ = E(9394)(), T = E(8075)("RegExp.prototype.test"); + function b() { + var w = E(2299); + a = w.isDeepEqual, i = w.isDeepStrictEqual; + } + var A = !1, m = N.exports = F, I = {}; + function P(w) { + throw w.message instanceof Error ? w.message : new u(w); + } + function x(w, C, R, B) { + if (!R) { + var D = !1; + if (C === 0) D = !0, B = "No value argument passed to `assert.ok()`"; + else if (B instanceof Error) throw B; + var U = new u({ actual: R, expected: !0, message: B, operator: "==", stackStartFn: w }); + throw U.generatedMessage = D, U; + } + } + function F() { + for (var w = arguments.length, C = new Array(w), R = 0; R < w; R++) C[R] = arguments[R]; + x.apply(void 0, [F, C.length].concat(C)); + } + m.fail = function w(C, R, B, D, U) { + var k, G = arguments.length; + if (G === 0 ? k = "Failed" : G === 1 ? (B = C, C = void 0) : (A === !1 && (A = !0, (h.emitWarning ? h.emitWarning : d.warn.bind(d))("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.", "DeprecationWarning", "DEP0094")), G === 2 && (D = "!=")), B instanceof Error) throw B; + var V = { actual: C, expected: R, operator: D === void 0 ? "fail" : D, stackStartFn: U || w }; + B !== void 0 && (V.message = B); + var W = new u(V); + throw k && (W.message = k, W.generatedMessage = !0), W; + }, m.AssertionError = u, m.ok = F, m.equal = function w(C, R, B) { + if (arguments.length < 2) throw new s("actual", "expected"); + C != R && P({ actual: C, expected: R, message: B, operator: "==", stackStartFn: w }); + }, m.notEqual = function w(C, R, B) { + if (arguments.length < 2) throw new s("actual", "expected"); + C == R && P({ actual: C, expected: R, message: B, operator: "!=", stackStartFn: w }); + }, m.deepEqual = function w(C, R, B) { + if (arguments.length < 2) throw new s("actual", "expected"); + a === void 0 && b(), a(C, R) || P({ actual: C, expected: R, message: B, operator: "deepEqual", stackStartFn: w }); + }, m.notDeepEqual = function w(C, R, B) { + if (arguments.length < 2) throw new s("actual", "expected"); + a === void 0 && b(), a(C, R) && P({ actual: C, expected: R, message: B, operator: "notDeepEqual", stackStartFn: w }); + }, m.deepStrictEqual = function w(C, R, B) { + if (arguments.length < 2) throw new s("actual", "expected"); + a === void 0 && b(), i(C, R) || P({ actual: C, expected: R, message: B, operator: "deepStrictEqual", stackStartFn: w }); + }, m.notDeepStrictEqual = function w(C, R, B) { + if (arguments.length < 2) throw new s("actual", "expected"); + a === void 0 && b(), i(C, R) && P({ actual: C, expected: R, message: B, operator: "notDeepStrictEqual", stackStartFn: w }); + }, m.strictEqual = function w(C, R, B) { + if (arguments.length < 2) throw new s("actual", "expected"); + _(C, R) || P({ actual: C, expected: R, message: B, operator: "strictEqual", stackStartFn: w }); + }, m.notStrictEqual = function w(C, R, B) { + if (arguments.length < 2) throw new s("actual", "expected"); + _(C, R) && P({ actual: C, expected: R, message: B, operator: "notStrictEqual", stackStartFn: w }); + }; + var K = f(function w(C, R, B) { + var D = this; + (function(U, k) { + if (!(U instanceof k)) throw new TypeError("Cannot call a class as a function"); + })(this, w), R.forEach(function(U) { + U in C && (B !== void 0 && typeof B[U] == "string" && y(C[U]) && T(C[U], B[U]) ? D[U] = B[U] : D[U] = C[U]); + }); + }); + function Y(w, C, R, B) { + if (typeof C != "function") { + if (y(C)) return T(C, w); + if (arguments.length === 2) throw new e("expected", ["Function", "RegExp"], C); + if (o(w) !== "object" || w === null) { + var D = new u({ actual: w, expected: C, message: R, operator: "deepStrictEqual", stackStartFn: B }); + throw D.operator = B.name, D; + } + var U = Object.keys(C); + if (C instanceof Error) U.push("name", "message"); + else if (U.length === 0) throw new t("error", C, "may not be an empty object"); + return a === void 0 && b(), U.forEach(function(k) { + typeof w[k] == "string" && y(C[k]) && T(C[k], w[k]) || (function(G, V, W, z, q, $) { + if (!(W in G) || !i(G[W], V[W])) { + if (!z) { + var te = new K(G, q), re = new K(V, q, G), ie = new u({ actual: te, expected: re, operator: "deepStrictEqual", stackStartFn: $ }); + throw ie.actual = G, ie.expected = V, ie.operator = $.name, ie; + } + P({ actual: G, expected: V, message: z, operator: $.name, stackStartFn: $ }); + } + })(w, C, k, R, U, B); + }), !0; + } + return C.prototype !== void 0 && w instanceof C || !Error.isPrototypeOf(C) && C.call({}, w) === !0; + } + function Q(w) { + if (typeof w != "function") throw new e("fn", "Function", w); + try { + w(); + } catch (C) { + return C; + } + return I; + } + function S(w) { + return v(w) || w !== null && o(w) === "object" && typeof w.then == "function" && typeof w.catch == "function"; + } + function M(w) { + return Promise.resolve().then(function() { + var C; + if (typeof w == "function") { + if (!S(C = w())) throw new c("instance of Promise", "promiseFn", C); + } else { + if (!S(w)) throw new e("promiseFn", ["Function", "Promise"], w); + C = w; + } + return Promise.resolve().then(function() { + return C; + }).then(function() { + return I; + }).catch(function(R) { + return R; + }); + }); + } + function j(w, C, R, B) { + if (typeof R == "string") { + if (arguments.length === 4) throw new e("error", ["Object", "Error", "Function", "RegExp"], R); + if (o(C) === "object" && C !== null) { + if (C.message === R) throw new r("error/message", 'The error message "'.concat(C.message, '" is identical to the message.')); + } else if (C === R) throw new r("error/message", 'The error "'.concat(C, '" is identical to the message.')); + B = R, R = void 0; + } else if (R != null && o(R) !== "object" && typeof R != "function") throw new e("error", ["Object", "Error", "Function", "RegExp"], R); + if (C === I) { + var D = ""; + R && R.name && (D += " (".concat(R.name, ")")), D += B ? ": ".concat(B) : "."; + var U = w.name === "rejects" ? "rejection" : "exception"; + P({ actual: void 0, expected: R, operator: w.name, message: "Missing expected ".concat(U).concat(D), stackStartFn: w }); + } + if (R && !Y(C, R, B, w)) throw C; + } + function H(w, C, R, B) { + if (C !== I) { + if (typeof R == "string" && (B = R, R = void 0), !R || Y(C, R)) { + var D = B ? ": ".concat(B) : ".", U = w.name === "doesNotReject" ? "rejection" : "exception"; + P({ actual: C, expected: R, operator: w.name, message: "Got unwanted ".concat(U).concat(D, ` +`) + 'Actual message: "'.concat(C && C.message, '"'), stackStartFn: w }); + } + throw C; + } + } + function Z(w, C, R, B, D) { + if (!y(C)) throw new e("regexp", "RegExp", C); + var U = D === "match"; + if (typeof w != "string" || T(C, w) !== U) { + if (R instanceof Error) throw R; + var k = !R; + R = R || (typeof w != "string" ? 'The "string" argument must be of type string. Received type ' + "".concat(o(w), " (").concat(p(w), ")") : (U ? "The input did not match the regular expression " : "The input was expected to not match the regular expression ") + "".concat(p(C), `. Input: + +`).concat(p(w), ` +`)); + var G = new u({ actual: w, expected: C, message: R, operator: D, stackStartFn: B }); + throw G.generatedMessage = k, G; + } + } + function L() { + for (var w = arguments.length, C = new Array(w), R = 0; R < w; R++) C[R] = arguments[R]; + x.apply(void 0, [L, C.length].concat(C)); + } + m.throws = function w(C) { + for (var R = arguments.length, B = new Array(R > 1 ? R - 1 : 0), D = 1; D < R; D++) B[D - 1] = arguments[D]; + j.apply(void 0, [w, Q(C)].concat(B)); + }, m.rejects = function w(C) { + for (var R = arguments.length, B = new Array(R > 1 ? R - 1 : 0), D = 1; D < R; D++) B[D - 1] = arguments[D]; + return M(C).then(function(U) { + return j.apply(void 0, [w, U].concat(B)); + }); + }, m.doesNotThrow = function w(C) { + for (var R = arguments.length, B = new Array(R > 1 ? R - 1 : 0), D = 1; D < R; D++) B[D - 1] = arguments[D]; + H.apply(void 0, [w, Q(C)].concat(B)); + }, m.doesNotReject = function w(C) { + for (var R = arguments.length, B = new Array(R > 1 ? R - 1 : 0), D = 1; D < R; D++) B[D - 1] = arguments[D]; + return M(C).then(function(U) { + return H.apply(void 0, [w, U].concat(B)); + }); + }, m.ifError = function w(C) { + if (C != null) { + var R = "ifError got unwanted exception: "; + o(C) === "object" && typeof C.message == "string" ? C.message.length === 0 && C.constructor ? R += C.constructor.name : R += C.message : R += p(C); + var B = new u({ actual: C, expected: null, operator: "ifError", message: R, stackStartFn: w }), D = C.stack; + if (typeof D == "string") { + var U = D.split(` +`); + U.shift(); + for (var k = B.stack.split(` +`), G = 0; G < U.length; G++) { + var V = k.indexOf(U[G]); + if (V !== -1) { + k = k.slice(0, V); + break; + } + } + B.stack = "".concat(k.join(` +`), ` +`).concat(U.join(` +`)); + } + throw B; + } + }, m.match = function w(C, R, B) { + Z(C, R, B, w, "match"); + }, m.doesNotMatch = function w(C, R, B) { + Z(C, R, B, w, "doesNotMatch"); + }, m.strict = g(L, m, { equal: m.strictEqual, deepEqual: m.deepStrictEqual, notEqual: m.notStrictEqual, notDeepEqual: m.notDeepStrictEqual }), m.strict.strict = m.strict; + }, 3918(N, O, E) { + var h = E(5606); + function d(P, x) { + var F = Object.keys(P); + if (Object.getOwnPropertySymbols) { + var K = Object.getOwnPropertySymbols(P); + x && (K = K.filter(function(Y) { + return Object.getOwnPropertyDescriptor(P, Y).enumerable; + })), F.push.apply(F, K); + } + return F; + } + function o(P) { + for (var x = 1; x < arguments.length; x++) { + var F = arguments[x] != null ? arguments[x] : {}; + x % 2 ? d(Object(F), !0).forEach(function(K) { + var Y, Q, S; + Y = P, Q = K, S = F[K], (Q = a(Q)) in Y ? Object.defineProperty(Y, Q, { value: S, enumerable: !0, configurable: !0, writable: !0 }) : Y[Q] = S; + }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(P, Object.getOwnPropertyDescriptors(F)) : d(Object(F)).forEach(function(K) { + Object.defineProperty(P, K, Object.getOwnPropertyDescriptor(F, K)); + }); + } + return P; + } + function f(P, x) { + for (var F = 0; F < x.length; F++) { + var K = x[F]; + K.enumerable = K.enumerable || !1, K.configurable = !0, "value" in K && (K.writable = !0), Object.defineProperty(P, a(K.key), K); + } + } + function a(P) { + var x = (function(F) { + if (u(F) !== "object" || F === null) return F; + var K = F[Symbol.toPrimitive]; + if (K !== void 0) { + var Y = K.call(F, "string"); + if (u(Y) !== "object") return Y; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return String(F); + })(P); + return u(x) === "symbol" ? x : String(x); + } + function i(P, x) { + if (x && (u(x) === "object" || typeof x == "function")) return x; + if (x !== void 0) throw new TypeError("Derived constructors may only return object or undefined"); + return n(P); + } + function n(P) { + if (P === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + return P; + } + function r(P) { + var x = typeof Map == "function" ? /* @__PURE__ */ new Map() : void 0; + return r = function(F) { + if (F === null || (K = F, Function.toString.call(K).indexOf("[native code]") === -1)) return F; + var K; + if (typeof F != "function") throw new TypeError("Super expression must either be null or a function"); + if (x !== void 0) { + if (x.has(F)) return x.get(F); + x.set(F, Y); + } + function Y() { + return e(F, arguments, s(this).constructor); + } + return Y.prototype = Object.create(F.prototype, { constructor: { value: Y, enumerable: !1, writable: !0, configurable: !0 } }), c(Y, F); + }, r(P); + } + function e(P, x, F) { + return e = t() ? Reflect.construct.bind() : function(K, Y, Q) { + var S = [null]; + S.push.apply(S, Y); + var M = new (Function.bind.apply(K, S))(); + return Q && c(M, Q.prototype), M; + }, e.apply(null, arguments); + } + function t() { + if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1; + if (typeof Proxy == "function") return !0; + try { + return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() { + })), !0; + } catch { + return !1; + } + } + function c(P, x) { + return c = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(F, K) { + return F.__proto__ = K, F; + }, c(P, x); + } + function s(P) { + return s = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(x) { + return x.__proto__ || Object.getPrototypeOf(x); + }, s(P); + } + function u(P) { + return u = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(x) { + return typeof x; + } : function(x) { + return x && typeof Symbol == "function" && x.constructor === Symbol && x !== Symbol.prototype ? "symbol" : typeof x; + }, u(P); + } + var p = E(537).inspect, l = E(9597).codes.ERR_INVALID_ARG_TYPE; + function v(P, x, F) { + return (F === void 0 || F > P.length) && (F = P.length), P.substring(F - x.length, F) === x; + } + var y = "", g = "", _ = "", T = "", b = { deepStrictEqual: "Expected values to be strictly deep-equal:", strictEqual: "Expected values to be strictly equal:", strictEqualObject: 'Expected "actual" to be reference-equal to "expected":', deepEqual: "Expected values to be loosely deep-equal:", equal: "Expected values to be loosely equal:", notDeepStrictEqual: 'Expected "actual" not to be strictly deep-equal to:', notStrictEqual: 'Expected "actual" to be strictly unequal to:', notStrictEqualObject: 'Expected "actual" not to be reference-equal to "expected":', notDeepEqual: 'Expected "actual" not to be loosely deep-equal to:', notEqual: 'Expected "actual" to be loosely unequal to:', notIdentical: "Values identical but not reference-equal:" }; + function A(P) { + var x = Object.keys(P), F = Object.create(Object.getPrototypeOf(P)); + return x.forEach(function(K) { + F[K] = P[K]; + }), Object.defineProperty(F, "message", { value: P.message }), F; + } + function m(P) { + return p(P, { compact: !1, customInspect: !1, depth: 1e3, maxArrayLength: 1 / 0, showHidden: !1, breakLength: 1 / 0, showProxy: !1, sorted: !0, getters: !0 }); + } + var I = (function(P, x) { + (function(j, H) { + if (typeof H != "function" && H !== null) throw new TypeError("Super expression must either be null or a function"); + j.prototype = Object.create(H && H.prototype, { constructor: { value: j, writable: !0, configurable: !0 } }), Object.defineProperty(j, "prototype", { writable: !1 }), H && c(j, H); + })(M, P); + var F, K, Y, Q, S = (F = M, K = t(), function() { + var j, H = s(F); + if (K) { + var Z = s(this).constructor; + j = Reflect.construct(H, arguments, Z); + } else j = H.apply(this, arguments); + return i(this, j); + }); + function M(j) { + var H; + if ((function(W, z) { + if (!(W instanceof z)) throw new TypeError("Cannot call a class as a function"); + })(this, M), u(j) !== "object" || j === null) throw new l("options", "Object", j); + var Z = j.message, L = j.operator, w = j.stackStartFn, C = j.actual, R = j.expected, B = Error.stackTraceLimit; + if (Error.stackTraceLimit = 0, Z != null) H = S.call(this, String(Z)); + else if (h.stderr && h.stderr.isTTY && (h.stderr && h.stderr.getColorDepth && h.stderr.getColorDepth() !== 1 ? (y = "\x1B[34m", g = "\x1B[32m", T = "\x1B[39m", _ = "\x1B[31m") : (y = "", g = "", T = "", _ = "")), u(C) === "object" && C !== null && u(R) === "object" && R !== null && "stack" in C && C instanceof Error && "stack" in R && R instanceof Error && (C = A(C), R = A(R)), L === "deepStrictEqual" || L === "strictEqual") H = S.call(this, (function(W, z, q) { + var $ = "", te = "", re = 0, ie = "", ue = !1, ne = m(W), X = ne.split(` +`), ee = m(z).split(` +`), J = 0, ce = ""; + if (q === "strictEqual" && u(W) === "object" && u(z) === "object" && W !== null && z !== null && (q = "strictEqualObject"), X.length === 1 && ee.length === 1 && X[0] !== ee[0]) { + var _e = X[0].length + ee[0].length; + if (_e <= 10) { + if (!(u(W) === "object" && W !== null || u(z) === "object" && z !== null || W === 0 && z === 0)) return "".concat(b[q], ` + +`) + "".concat(X[0], " !== ").concat(ee[0], ` +`); + } else if (q !== "strictEqualObject" && _e < (h.stderr && h.stderr.isTTY ? h.stderr.columns : 80)) { + for (; X[0][J] === ee[0][J]; ) J++; + J > 2 && (ce = ` + `.concat((function(oe, Ee) { + if (Ee = Math.floor(Ee), oe.length == 0 || Ee == 0) return ""; + var Se = oe.length * Ee; + for (Ee = Math.floor(Math.log(Ee) / Math.log(2)); Ee; ) oe += oe, Ee--; + return oe + oe.substring(0, Se - oe.length); + })(" ", J), "^"), J = 0); + } + } + for (var pe = X[X.length - 1], ye = ee[ee.length - 1]; pe === ye && (J++ < 2 ? ie = ` + `.concat(pe).concat(ie) : $ = pe, X.pop(), ee.pop(), X.length !== 0 && ee.length !== 0); ) pe = X[X.length - 1], ye = ee[ee.length - 1]; + var Te = Math.max(X.length, ee.length); + if (Te === 0) { + var ae = ne.split(` +`); + if (ae.length > 30) for (ae[26] = "".concat(y, "...").concat(T); ae.length > 27; ) ae.pop(); + return "".concat(b.notIdentical, ` + +`).concat(ae.join(` +`), ` +`); + } + J > 3 && (ie = ` +`.concat(y, "...").concat(T).concat(ie), ue = !0), $ !== "" && (ie = ` + `.concat($).concat(ie), $ = ""); + var le = 0, ve = b[q] + ` +`.concat(g, "+ actual").concat(T, " ").concat(_, "- expected").concat(T), Oe = " ".concat(y, "...").concat(T, " Lines skipped"); + for (J = 0; J < Te; J++) { + var se = J - re; + if (X.length < J + 1) se > 1 && J > 2 && (se > 4 ? (te += ` +`.concat(y, "...").concat(T), ue = !0) : se > 3 && (te += ` + `.concat(ee[J - 2]), le++), te += ` + `.concat(ee[J - 1]), le++), re = J, $ += ` +`.concat(_, "-").concat(T, " ").concat(ee[J]), le++; + else if (ee.length < J + 1) se > 1 && J > 2 && (se > 4 ? (te += ` +`.concat(y, "...").concat(T), ue = !0) : se > 3 && (te += ` + `.concat(X[J - 2]), le++), te += ` + `.concat(X[J - 1]), le++), re = J, te += ` +`.concat(g, "+").concat(T, " ").concat(X[J]), le++; + else { + var de = ee[J], fe = X[J], ge = fe !== de && (!v(fe, ",") || fe.slice(0, -1) !== de); + ge && v(de, ",") && de.slice(0, -1) === fe && (ge = !1, fe += ","), ge ? (se > 1 && J > 2 && (se > 4 ? (te += ` +`.concat(y, "...").concat(T), ue = !0) : se > 3 && (te += ` + `.concat(X[J - 2]), le++), te += ` + `.concat(X[J - 1]), le++), re = J, te += ` +`.concat(g, "+").concat(T, " ").concat(fe), $ += ` +`.concat(_, "-").concat(T, " ").concat(de), le += 2) : (te += $, $ = "", se !== 1 && J !== 0 || (te += ` + `.concat(fe), le++)); + } + if (le > 20 && J < Te - 2) return "".concat(ve).concat(Oe, ` +`).concat(te, ` +`).concat(y, "...").concat(T).concat($, ` +`) + "".concat(y, "...").concat(T); + } + return "".concat(ve).concat(ue ? Oe : "", ` +`).concat(te).concat($).concat(ie).concat(ce); + })(C, R, L)); + else if (L === "notDeepStrictEqual" || L === "notStrictEqual") { + var D = b[L], U = m(C).split(` +`); + if (L === "notStrictEqual" && u(C) === "object" && C !== null && (D = b.notStrictEqualObject), U.length > 30) for (U[26] = "".concat(y, "...").concat(T); U.length > 27; ) U.pop(); + H = U.length === 1 ? S.call(this, "".concat(D, " ").concat(U[0])) : S.call(this, "".concat(D, ` + +`).concat(U.join(` +`), ` +`)); + } else { + var k = m(C), G = "", V = b[L]; + L === "notDeepEqual" || L === "notEqual" ? (k = "".concat(b[L], ` + +`).concat(k)).length > 1024 && (k = "".concat(k.slice(0, 1021), "...")) : (G = "".concat(m(R)), k.length > 512 && (k = "".concat(k.slice(0, 509), "...")), G.length > 512 && (G = "".concat(G.slice(0, 509), "...")), L === "deepEqual" || L === "equal" ? k = "".concat(V, ` + +`).concat(k, ` + +should equal + +`) : G = " ".concat(L, " ").concat(G)), H = S.call(this, "".concat(k).concat(G)); + } + return Error.stackTraceLimit = B, H.generatedMessage = !Z, Object.defineProperty(n(H), "name", { value: "AssertionError [ERR_ASSERTION]", enumerable: !1, writable: !0, configurable: !0 }), H.code = "ERR_ASSERTION", H.actual = C, H.expected = R, H.operator = L, Error.captureStackTrace && Error.captureStackTrace(n(H), w), H.stack, H.name = "AssertionError", i(H); + } + return Y = M, (Q = [{ key: "toString", value: function() { + return "".concat(this.name, " [").concat(this.code, "]: ").concat(this.message); + } }, { key: x, value: function(j, H) { + return p(this, o(o({}, H), {}, { customInspect: !1, depth: 0 })); + } }]) && f(Y.prototype, Q), Object.defineProperty(Y, "prototype", { writable: !1 }), M; + })(r(Error), p.custom); + N.exports = I; + }, 9597(N, O, E) { + function h(e) { + return h = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t) { + return typeof t; + } : function(t) { + return t && typeof Symbol == "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t; + }, h(e); + } + function d(e, t) { + return d = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(c, s) { + return c.__proto__ = s, c; + }, d(e, t); + } + function o(e) { + return o = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t) { + return t.__proto__ || Object.getPrototypeOf(t); + }, o(e); + } + var f, a, i = {}; + function n(e, t, c) { + c || (c = Error); + var s = (function(u) { + (function(_, T) { + if (typeof T != "function" && T !== null) throw new TypeError("Super expression must either be null or a function"); + _.prototype = Object.create(T && T.prototype, { constructor: { value: _, writable: !0, configurable: !0 } }), Object.defineProperty(_, "prototype", { writable: !1 }), T && d(_, T); + })(g, u); + var p, l, v, y = (l = g, v = (function() { + if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1; + if (typeof Proxy == "function") return !0; + try { + return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() { + })), !0; + } catch { + return !1; + } + })(), function() { + var _, T = o(l); + if (v) { + var b = o(this).constructor; + _ = Reflect.construct(T, arguments, b); + } else _ = T.apply(this, arguments); + return (function(A, m) { + if (m && (h(m) === "object" || typeof m == "function")) return m; + if (m !== void 0) throw new TypeError("Derived constructors may only return object or undefined"); + return (function(I) { + if (I === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + return I; + })(A); + })(this, _); + }); + function g(_, T, b) { + var A; + return (function(m, I) { + if (!(m instanceof I)) throw new TypeError("Cannot call a class as a function"); + })(this, g), A = y.call(this, (function(m, I, P) { + return typeof t == "string" ? t : t(m, I, P); + })(_, T, b)), A.code = e, A; + } + return p = g, Object.defineProperty(p, "prototype", { writable: !1 }), p; + })(c); + i[e] = s; + } + function r(e, t) { + if (Array.isArray(e)) { + var c = e.length; + return e = e.map(function(s) { + return String(s); + }), c > 2 ? "one of ".concat(t, " ").concat(e.slice(0, c - 1).join(", "), ", or ") + e[c - 1] : c === 2 ? "one of ".concat(t, " ").concat(e[0], " or ").concat(e[1]) : "of ".concat(t, " ").concat(e[0]); + } + return "of ".concat(t, " ").concat(String(e)); + } + n("ERR_AMBIGUOUS_ARGUMENT", 'The "%s" argument is ambiguous. %s', TypeError), n("ERR_INVALID_ARG_TYPE", function(e, t, c) { + var s, u, p, l, v; + if (f === void 0 && (f = E(4148)), f(typeof e == "string", "'name' must be a string"), typeof t == "string" && (u = "not ", t.substr(0, 4) === u) ? (s = "must not be", t = t.replace(/^not /, "")) : s = "must be", (function(g, _, T) { + return (T === void 0 || T > g.length) && (T = g.length), g.substring(T - 9, T) === _; + })(e, " argument")) p = "The ".concat(e, " ").concat(s, " ").concat(r(t, "type")); + else { + var y = (typeof v != "number" && (v = 0), v + 1 > (l = e).length || l.indexOf(".", v) === -1 ? "argument" : "property"); + p = 'The "'.concat(e, '" ').concat(y, " ").concat(s, " ").concat(r(t, "type")); + } + return p + ". Received type ".concat(h(c)); + }, TypeError), n("ERR_INVALID_ARG_VALUE", function(e, t) { + var c = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "is invalid"; + a === void 0 && (a = E(537)); + var s = a.inspect(t); + return s.length > 128 && (s = "".concat(s.slice(0, 128), "...")), "The argument '".concat(e, "' ").concat(c, ". Received ").concat(s); + }, TypeError), n("ERR_INVALID_RETURN_VALUE", function(e, t, c) { + var s; + return s = c && c.constructor && c.constructor.name ? "instance of ".concat(c.constructor.name) : "type ".concat(h(c)), "Expected ".concat(e, ' to be returned from the "').concat(t, '"') + " function but got ".concat(s, "."); + }, TypeError), n("ERR_MISSING_ARGS", function() { + for (var e = arguments.length, t = new Array(e), c = 0; c < e; c++) t[c] = arguments[c]; + f === void 0 && (f = E(4148)), f(t.length > 0, "At least one arg needs to be specified"); + var s = "The ", u = t.length; + switch (t = t.map(function(p) { + return '"'.concat(p, '"'); + }), u) { + case 1: + s += "".concat(t[0], " argument"); + break; + case 2: + s += "".concat(t[0], " and ").concat(t[1], " arguments"); + break; + default: + s += t.slice(0, u - 1).join(", "), s += ", and ".concat(t[u - 1], " arguments"); + } + return "".concat(s, " must be specified"); + }, TypeError), N.exports.codes = i; + }, 2299(N, O, E) { + function h(D, U) { + return (function(k) { + if (Array.isArray(k)) return k; + })(D) || (function(k, G) { + var V = k == null ? null : typeof Symbol < "u" && k[Symbol.iterator] || k["@@iterator"]; + if (V != null) { + var W, z, q, $, te = [], re = !0, ie = !1; + try { + if (q = (V = V.call(k)).next, G !== 0) for (; !(re = (W = q.call(V)).done) && (te.push(W.value), te.length !== G); re = !0) ; + } catch (ue) { + ie = !0, z = ue; + } finally { + try { + if (!re && V.return != null && ($ = V.return(), Object($) !== $)) return; + } finally { + if (ie) throw z; + } + } + return te; + } + })(D, U) || (function(k, G) { + if (k) { + if (typeof k == "string") return d(k, G); + var V = Object.prototype.toString.call(k).slice(8, -1); + return V === "Object" && k.constructor && (V = k.constructor.name), V === "Map" || V === "Set" ? Array.from(k) : V === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(V) ? d(k, G) : void 0; + } + })(D, U) || (function() { + throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`); + })(); + } + function d(D, U) { + (U == null || U > D.length) && (U = D.length); + for (var k = 0, G = new Array(U); k < U; k++) G[k] = D[k]; + return G; + } + function o(D) { + return o = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(U) { + return typeof U; + } : function(U) { + return U && typeof Symbol == "function" && U.constructor === Symbol && U !== Symbol.prototype ? "symbol" : typeof U; + }, o(D); + } + var f = /a/g.flags !== void 0, a = function(D) { + var U = []; + return D.forEach(function(k) { + return U.push(k); + }), U; + }, i = function(D) { + var U = []; + return D.forEach(function(k, G) { + return U.push([G, k]); + }), U; + }, n = Object.is ? Object.is : E(7653), r = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols : function() { + return []; + }, e = Number.isNaN ? Number.isNaN : E(4133); + function t(D) { + return D.call.bind(D); + } + var c = t(Object.prototype.hasOwnProperty), s = t(Object.prototype.propertyIsEnumerable), u = t(Object.prototype.toString), p = E(537).types, l = p.isAnyArrayBuffer, v = p.isArrayBufferView, y = p.isDate, g = p.isMap, _ = p.isRegExp, T = p.isSet, b = p.isNativeError, A = p.isBoxedPrimitive, m = p.isNumberObject, I = p.isStringObject, P = p.isBooleanObject, x = p.isBigIntObject, F = p.isSymbolObject, K = p.isFloat32Array, Y = p.isFloat64Array; + function Q(D) { + if (D.length === 0 || D.length > 10) return !0; + for (var U = 0; U < D.length; U++) { + var k = D.charCodeAt(U); + if (k < 48 || k > 57) return !0; + } + return D.length === 10 && D >= Math.pow(2, 32); + } + function S(D) { + return Object.keys(D).filter(Q).concat(r(D).filter(Object.prototype.propertyIsEnumerable.bind(D))); + } + function M(D, U) { + if (D === U) return 0; + for (var k = D.length, G = U.length, V = 0, W = Math.min(k, G); V < W; ++V) if (D[V] !== U[V]) { + k = D[V], G = U[V]; + break; + } + return k < G ? -1 : G < k ? 1 : 0; + } + function j(D, U, k, G) { + if (D === U) return D !== 0 || !k || n(D, U); + if (k) { + if (o(D) !== "object") return typeof D == "number" && e(D) && e(U); + if (o(U) !== "object" || D === null || U === null || Object.getPrototypeOf(D) !== Object.getPrototypeOf(U)) return !1; + } else { + if (D === null || o(D) !== "object") return (U === null || o(U) !== "object") && D == U; + if (U === null || o(U) !== "object") return !1; + } + var V, W, z, q, $ = u(D); + if ($ !== u(U)) return !1; + if (Array.isArray(D)) { + if (D.length !== U.length) return !1; + var te = S(D), re = S(U); + return te.length === re.length && Z(D, U, k, G, 1, te); + } + if ($ === "[object Object]" && (!g(D) && g(U) || !T(D) && T(U))) return !1; + if (y(D)) { + if (!y(U) || Date.prototype.getTime.call(D) !== Date.prototype.getTime.call(U)) return !1; + } else if (_(D)) { + if (!_(U) || (z = D, q = U, !(f ? z.source === q.source && z.flags === q.flags : RegExp.prototype.toString.call(z) === RegExp.prototype.toString.call(q)))) return !1; + } else if (b(D) || D instanceof Error) { + if (D.message !== U.message || D.name !== U.name) return !1; + } else { + if (v(D)) { + if (k || !K(D) && !Y(D)) { + if (!(function(ne, X) { + return ne.byteLength === X.byteLength && M(new Uint8Array(ne.buffer, ne.byteOffset, ne.byteLength), new Uint8Array(X.buffer, X.byteOffset, X.byteLength)) === 0; + })(D, U)) return !1; + } else if (!(function(ne, X) { + if (ne.byteLength !== X.byteLength) return !1; + for (var ee = 0; ee < ne.byteLength; ee++) if (ne[ee] !== X[ee]) return !1; + return !0; + })(D, U)) return !1; + var ie = S(D), ue = S(U); + return ie.length === ue.length && Z(D, U, k, G, 0, ie); + } + if (T(D)) return !(!T(U) || D.size !== U.size) && Z(D, U, k, G, 2); + if (g(D)) return !(!g(U) || D.size !== U.size) && Z(D, U, k, G, 3); + if (l(D)) { + if (W = U, (V = D).byteLength !== W.byteLength || M(new Uint8Array(V), new Uint8Array(W)) !== 0) return !1; + } else if (A(D) && !(function(ne, X) { + return m(ne) ? m(X) && n(Number.prototype.valueOf.call(ne), Number.prototype.valueOf.call(X)) : I(ne) ? I(X) && String.prototype.valueOf.call(ne) === String.prototype.valueOf.call(X) : P(ne) ? P(X) && Boolean.prototype.valueOf.call(ne) === Boolean.prototype.valueOf.call(X) : x(ne) ? x(X) && BigInt.prototype.valueOf.call(ne) === BigInt.prototype.valueOf.call(X) : F(X) && Symbol.prototype.valueOf.call(ne) === Symbol.prototype.valueOf.call(X); + })(D, U)) return !1; + } + return Z(D, U, k, G, 0); + } + function H(D, U) { + return U.filter(function(k) { + return s(D, k); + }); + } + function Z(D, U, k, G, V, W) { + if (arguments.length === 5) { + W = Object.keys(D); + var z = Object.keys(U); + if (W.length !== z.length) return !1; + } + for (var q = 0; q < W.length; q++) if (!c(U, W[q])) return !1; + if (k && arguments.length === 5) { + var $ = r(D); + if ($.length !== 0) { + var te = 0; + for (q = 0; q < $.length; q++) { + var re = $[q]; + if (s(D, re)) { + if (!s(U, re)) return !1; + W.push(re), te++; + } else if (s(U, re)) return !1; + } + var ie = r(U); + if ($.length !== ie.length && H(U, ie).length !== te) return !1; + } else { + var ue = r(U); + if (ue.length !== 0 && H(U, ue).length !== 0) return !1; + } + } + if (W.length === 0 && (V === 0 || V === 1 && D.length === 0 || D.size === 0)) return !0; + if (G === void 0) G = { val1: /* @__PURE__ */ new Map(), val2: /* @__PURE__ */ new Map(), position: 0 }; + else { + var ne = G.val1.get(D); + if (ne !== void 0) { + var X = G.val2.get(U); + if (X !== void 0) return ne === X; + } + G.position++; + } + G.val1.set(D, G.position), G.val2.set(U, G.position); + var ee = (function(J, ce, _e, pe, ye, Te) { + var ae = 0; + if (Te === 2) { + if (!(function(se, de, fe, ge) { + for (var oe = null, Ee = a(se), Se = 0; Se < Ee.length; Se++) { + var be = Ee[Se]; + if (o(be) === "object" && be !== null) oe === null && (oe = /* @__PURE__ */ new Set()), oe.add(be); + else if (!de.has(be)) { + if (fe || !C(se, de, be)) return !1; + oe === null && (oe = /* @__PURE__ */ new Set()), oe.add(be); + } + } + if (oe !== null) { + for (var he = a(de), Re = 0; Re < he.length; Re++) { + var Ne = he[Re]; + if (o(Ne) === "object" && Ne !== null) { + if (!L(oe, Ne, fe, ge)) return !1; + } else if (!fe && !se.has(Ne) && !L(oe, Ne, fe, ge)) return !1; + } + return oe.size === 0; + } + return !0; + })(J, ce, _e, ye)) return !1; + } else if (Te === 3) { + if (!(function(se, de, fe, ge) { + for (var oe = null, Ee = i(se), Se = 0; Se < Ee.length; Se++) { + var be = h(Ee[Se], 2), he = be[0], Re = be[1]; + if (o(he) === "object" && he !== null) oe === null && (oe = /* @__PURE__ */ new Set()), oe.add(he); + else { + var Ne = de.get(he); + if (Ne === void 0 && !de.has(he) || !j(Re, Ne, fe, ge)) { + if (fe || !R(se, de, he, Re, ge)) return !1; + oe === null && (oe = /* @__PURE__ */ new Set()), oe.add(he); + } + } + } + if (oe !== null) { + for (var Le = i(de), Pe = 0; Pe < Le.length; Pe++) { + var Me = h(Le[Pe], 2), me = Me[0], De = Me[1]; + if (o(me) === "object" && me !== null) { + if (!B(oe, se, me, De, fe, ge)) return !1; + } else if (!(fe || se.has(me) && j(se.get(me), De, !1, ge) || B(oe, se, me, De, !1, ge))) return !1; + } + return oe.size === 0; + } + return !0; + })(J, ce, _e, ye)) return !1; + } else if (Te === 1) for (; ae < J.length; ae++) { + if (!c(J, ae)) { + if (c(ce, ae)) return !1; + for (var le = Object.keys(J); ae < le.length; ae++) { + var ve = le[ae]; + if (!c(ce, ve) || !j(J[ve], ce[ve], _e, ye)) return !1; + } + return le.length === Object.keys(ce).length; + } + if (!c(ce, ae) || !j(J[ae], ce[ae], _e, ye)) return !1; + } + for (ae = 0; ae < pe.length; ae++) { + var Oe = pe[ae]; + if (!j(J[Oe], ce[Oe], _e, ye)) return !1; + } + return !0; + })(D, U, k, W, G, V); + return G.val1.delete(D), G.val2.delete(U), ee; + } + function L(D, U, k, G) { + for (var V = a(D), W = 0; W < V.length; W++) { + var z = V[W]; + if (j(U, z, k, G)) return D.delete(z), !0; + } + return !1; + } + function w(D) { + switch (o(D)) { + case "undefined": + return null; + case "object": + return; + case "symbol": + return !1; + case "string": + D = +D; + case "number": + if (e(D)) return !1; + } + return !0; + } + function C(D, U, k) { + var G = w(k); + return G ?? (U.has(G) && !D.has(G)); + } + function R(D, U, k, G, V) { + var W = w(k); + if (W != null) return W; + var z = U.get(W); + return !(z === void 0 && !U.has(W) || !j(G, z, !1, V)) && !D.has(W) && j(G, z, !1, V); + } + function B(D, U, k, G, V, W) { + for (var z = a(D), q = 0; q < z.length; q++) { + var $ = z[q]; + if (j(k, $, V, W) && j(G, U.get($), V, W)) return D.delete($), !0; + } + return !1; + } + N.exports = { isDeepEqual: function(D, U) { + return j(D, U, !1); + }, isDeepStrictEqual: function(D, U) { + return j(D, U, !0); + } }; + }, 3144(N, O, E) { + var h = E(6743), d = E(1002), o = E(76), f = E(7119); + N.exports = f || h.call(o, d); + }, 2205(N, O, E) { + var h = E(6743), d = E(1002), o = E(3144); + N.exports = function() { + return o(h, d, arguments); + }; + }, 1002(N) { + N.exports = Function.prototype.apply; + }, 76(N) { + N.exports = Function.prototype.call; + }, 3126(N, O, E) { + var h = E(6743), d = E(9675), o = E(76), f = E(3144); + N.exports = function(a) { + if (a.length < 1 || typeof a[0] != "function") throw new d("a function is required"); + return f(h, o, a); + }; + }, 7119(N) { + N.exports = typeof Reflect < "u" && Reflect && Reflect.apply; + }, 8075(N, O, E) { + var h = E(453), d = E(487), o = d(h("String.prototype.indexOf")); + N.exports = function(f, a) { + var i = h(f, !!a); + return typeof i == "function" && o(f, ".prototype.") > -1 ? d(i) : i; + }; + }, 487(N, O, E) { + var h = E(6897), d = E(655), o = E(3126), f = E(2205); + N.exports = function(a) { + var i = o(arguments), n = a.length - (arguments.length - 1); + return h(i, 1 + (n > 0 ? n : 0), !0); + }, d ? d(N.exports, "apply", { value: f }) : N.exports.apply = f; + }, 6556(N, O, E) { + var h = E(453), d = E(3126), o = d([h("%String.prototype.indexOf%")]); + N.exports = function(f, a) { + var i = h(f, !!a); + return typeof i == "function" && o(f, ".prototype.") > -1 ? d([i]) : i; + }; + }, 6763(N, O, E) { + var h = E(537), d = E(4148); + function o() { + return (/* @__PURE__ */ new Date()).getTime(); + } + var f, a = Array.prototype.slice, i = {}; + f = E.g !== void 0 && E.g.console ? E.g.console : typeof window < "u" && window.console ? window.console : {}; + for (var n = [[function() { + }, "log"], [function() { + f.log.apply(f, arguments); + }, "info"], [function() { + f.log.apply(f, arguments); + }, "warn"], [function() { + f.warn.apply(f, arguments); + }, "error"], [function(s) { + i[s] = o(); + }, "time"], [function(s) { + var u = i[s]; + if (!u) throw new Error("No such label: " + s); + delete i[s]; + var p = o() - u; + f.log(s + ": " + p + "ms"); + }, "timeEnd"], [function() { + var s = new Error(); + s.name = "Trace", s.message = h.format.apply(null, arguments), f.error(s.stack); + }, "trace"], [function(s) { + f.log(h.inspect(s) + ` +`); + }, "dir"], [function(s) { + if (!s) { + var u = a.call(arguments, 1); + d.ok(!1, h.format.apply(null, u)); + } + }, "assert"]], r = 0; r < n.length; r++) { + var e = n[r], t = e[0], c = e[1]; + f[c] || (f[c] = t); + } + N.exports = f; + }, 955(N, O, E) { + var h; + N.exports = (h = E(9021), E(754), E(4636), E(9506), E(7165), (function() { + var d = h, o = d.lib.BlockCipher, f = d.algo, a = [], i = [], n = [], r = [], e = [], t = [], c = [], s = [], u = [], p = []; + (function() { + for (var y = [], g = 0; g < 256; g++) y[g] = g < 128 ? g << 1 : g << 1 ^ 283; + var _ = 0, T = 0; + for (g = 0; g < 256; g++) { + var b = T ^ T << 1 ^ T << 2 ^ T << 3 ^ T << 4; + b = b >>> 8 ^ 255 & b ^ 99, a[_] = b, i[b] = _; + var A = y[_], m = y[A], I = y[m], P = 257 * y[b] ^ 16843008 * b; + n[_] = P << 24 | P >>> 8, r[_] = P << 16 | P >>> 16, e[_] = P << 8 | P >>> 24, t[_] = P, P = 16843009 * I ^ 65537 * m ^ 257 * A ^ 16843008 * _, c[b] = P << 24 | P >>> 8, s[b] = P << 16 | P >>> 16, u[b] = P << 8 | P >>> 24, p[b] = P, _ ? (_ = A ^ y[y[y[I ^ A]]], T ^= y[y[T]]) : _ = T = 1; + } + })(); + var l = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54], v = f.AES = o.extend({ _doReset: function() { + if (!this._nRounds || this._keyPriorReset !== this._key) { + for (var y = this._keyPriorReset = this._key, g = y.words, _ = y.sigBytes / 4, T = 4 * ((this._nRounds = _ + 6) + 1), b = this._keySchedule = [], A = 0; A < T; A++) A < _ ? b[A] = g[A] : (P = b[A - 1], A % _ ? _ > 6 && A % _ == 4 && (P = a[P >>> 24] << 24 | a[P >>> 16 & 255] << 16 | a[P >>> 8 & 255] << 8 | a[255 & P]) : (P = a[(P = P << 8 | P >>> 24) >>> 24] << 24 | a[P >>> 16 & 255] << 16 | a[P >>> 8 & 255] << 8 | a[255 & P], P ^= l[A / _ | 0] << 24), b[A] = b[A - _] ^ P); + for (var m = this._invKeySchedule = [], I = 0; I < T; I++) { + if (A = T - I, I % 4) var P = b[A]; + else P = b[A - 4]; + m[I] = I < 4 || A <= 4 ? P : c[a[P >>> 24]] ^ s[a[P >>> 16 & 255]] ^ u[a[P >>> 8 & 255]] ^ p[a[255 & P]]; + } + } + }, encryptBlock: function(y, g) { + this._doCryptBlock(y, g, this._keySchedule, n, r, e, t, a); + }, decryptBlock: function(y, g) { + var _ = y[g + 1]; + y[g + 1] = y[g + 3], y[g + 3] = _, this._doCryptBlock(y, g, this._invKeySchedule, c, s, u, p, i), _ = y[g + 1], y[g + 1] = y[g + 3], y[g + 3] = _; + }, _doCryptBlock: function(y, g, _, T, b, A, m, I) { + for (var P = this._nRounds, x = y[g] ^ _[0], F = y[g + 1] ^ _[1], K = y[g + 2] ^ _[2], Y = y[g + 3] ^ _[3], Q = 4, S = 1; S < P; S++) { + var M = T[x >>> 24] ^ b[F >>> 16 & 255] ^ A[K >>> 8 & 255] ^ m[255 & Y] ^ _[Q++], j = T[F >>> 24] ^ b[K >>> 16 & 255] ^ A[Y >>> 8 & 255] ^ m[255 & x] ^ _[Q++], H = T[K >>> 24] ^ b[Y >>> 16 & 255] ^ A[x >>> 8 & 255] ^ m[255 & F] ^ _[Q++], Z = T[Y >>> 24] ^ b[x >>> 16 & 255] ^ A[F >>> 8 & 255] ^ m[255 & K] ^ _[Q++]; + x = M, F = j, K = H, Y = Z; + } + M = (I[x >>> 24] << 24 | I[F >>> 16 & 255] << 16 | I[K >>> 8 & 255] << 8 | I[255 & Y]) ^ _[Q++], j = (I[F >>> 24] << 24 | I[K >>> 16 & 255] << 16 | I[Y >>> 8 & 255] << 8 | I[255 & x]) ^ _[Q++], H = (I[K >>> 24] << 24 | I[Y >>> 16 & 255] << 16 | I[x >>> 8 & 255] << 8 | I[255 & F]) ^ _[Q++], Z = (I[Y >>> 24] << 24 | I[x >>> 16 & 255] << 16 | I[F >>> 8 & 255] << 8 | I[255 & K]) ^ _[Q++], y[g] = M, y[g + 1] = j, y[g + 2] = H, y[g + 3] = Z; + }, keySize: 8 }); + d.AES = o._createHelper(v); + })(), h.AES); + }, 3128(N, O, E) { + var h; + N.exports = (h = E(9021), E(754), E(4636), E(9506), E(7165), (function() { + var d = h, o = d.lib.BlockCipher, f = d.algo; + const a = 16, i = [608135816, 2242054355, 320440878, 57701188, 2752067618, 698298832, 137296536, 3964562569, 1160258022, 953160567, 3193202383, 887688300, 3232508343, 3380367581, 1065670069, 3041331479, 2450970073, 2306472731], n = [[3509652390, 2564797868, 805139163, 3491422135, 3101798381, 1780907670, 3128725573, 4046225305, 614570311, 3012652279, 134345442, 2240740374, 1667834072, 1901547113, 2757295779, 4103290238, 227898511, 1921955416, 1904987480, 2182433518, 2069144605, 3260701109, 2620446009, 720527379, 3318853667, 677414384, 3393288472, 3101374703, 2390351024, 1614419982, 1822297739, 2954791486, 3608508353, 3174124327, 2024746970, 1432378464, 3864339955, 2857741204, 1464375394, 1676153920, 1439316330, 715854006, 3033291828, 289532110, 2706671279, 2087905683, 3018724369, 1668267050, 732546397, 1947742710, 3462151702, 2609353502, 2950085171, 1814351708, 2050118529, 680887927, 999245976, 1800124847, 3300911131, 1713906067, 1641548236, 4213287313, 1216130144, 1575780402, 4018429277, 3917837745, 3693486850, 3949271944, 596196993, 3549867205, 258830323, 2213823033, 772490370, 2760122372, 1774776394, 2652871518, 566650946, 4142492826, 1728879713, 2882767088, 1783734482, 3629395816, 2517608232, 2874225571, 1861159788, 326777828, 3124490320, 2130389656, 2716951837, 967770486, 1724537150, 2185432712, 2364442137, 1164943284, 2105845187, 998989502, 3765401048, 2244026483, 1075463327, 1455516326, 1322494562, 910128902, 469688178, 1117454909, 936433444, 3490320968, 3675253459, 1240580251, 122909385, 2157517691, 634681816, 4142456567, 3825094682, 3061402683, 2540495037, 79693498, 3249098678, 1084186820, 1583128258, 426386531, 1761308591, 1047286709, 322548459, 995290223, 1845252383, 2603652396, 3431023940, 2942221577, 3202600964, 3727903485, 1712269319, 422464435, 3234572375, 1170764815, 3523960633, 3117677531, 1434042557, 442511882, 3600875718, 1076654713, 1738483198, 4213154764, 2393238008, 3677496056, 1014306527, 4251020053, 793779912, 2902807211, 842905082, 4246964064, 1395751752, 1040244610, 2656851899, 3396308128, 445077038, 3742853595, 3577915638, 679411651, 2892444358, 2354009459, 1767581616, 3150600392, 3791627101, 3102740896, 284835224, 4246832056, 1258075500, 768725851, 2589189241, 3069724005, 3532540348, 1274779536, 3789419226, 2764799539, 1660621633, 3471099624, 4011903706, 913787905, 3497959166, 737222580, 2514213453, 2928710040, 3937242737, 1804850592, 3499020752, 2949064160, 2386320175, 2390070455, 2415321851, 4061277028, 2290661394, 2416832540, 1336762016, 1754252060, 3520065937, 3014181293, 791618072, 3188594551, 3933548030, 2332172193, 3852520463, 3043980520, 413987798, 3465142937, 3030929376, 4245938359, 2093235073, 3534596313, 375366246, 2157278981, 2479649556, 555357303, 3870105701, 2008414854, 3344188149, 4221384143, 3956125452, 2067696032, 3594591187, 2921233993, 2428461, 544322398, 577241275, 1471733935, 610547355, 4027169054, 1432588573, 1507829418, 2025931657, 3646575487, 545086370, 48609733, 2200306550, 1653985193, 298326376, 1316178497, 3007786442, 2064951626, 458293330, 2589141269, 3591329599, 3164325604, 727753846, 2179363840, 146436021, 1461446943, 4069977195, 705550613, 3059967265, 3887724982, 4281599278, 3313849956, 1404054877, 2845806497, 146425753, 1854211946], [1266315497, 3048417604, 3681880366, 3289982499, 290971e4, 1235738493, 2632868024, 2414719590, 3970600049, 1771706367, 1449415276, 3266420449, 422970021, 1963543593, 2690192192, 3826793022, 1062508698, 1531092325, 1804592342, 2583117782, 2714934279, 4024971509, 1294809318, 4028980673, 1289560198, 2221992742, 1669523910, 35572830, 157838143, 1052438473, 1016535060, 1802137761, 1753167236, 1386275462, 3080475397, 2857371447, 1040679964, 2145300060, 2390574316, 1461121720, 2956646967, 4031777805, 4028374788, 33600511, 2920084762, 1018524850, 629373528, 3691585981, 3515945977, 2091462646, 2486323059, 586499841, 988145025, 935516892, 3367335476, 2599673255, 2839830854, 265290510, 3972581182, 2759138881, 3795373465, 1005194799, 847297441, 406762289, 1314163512, 1332590856, 1866599683, 4127851711, 750260880, 613907577, 1450815602, 3165620655, 3734664991, 3650291728, 3012275730, 3704569646, 1427272223, 778793252, 1343938022, 2676280711, 2052605720, 1946737175, 3164576444, 3914038668, 3967478842, 3682934266, 1661551462, 3294938066, 4011595847, 840292616, 3712170807, 616741398, 312560963, 711312465, 1351876610, 322626781, 1910503582, 271666773, 2175563734, 1594956187, 70604529, 3617834859, 1007753275, 1495573769, 4069517037, 2549218298, 2663038764, 504708206, 2263041392, 3941167025, 2249088522, 1514023603, 1998579484, 1312622330, 694541497, 2582060303, 2151582166, 1382467621, 776784248, 2618340202, 3323268794, 2497899128, 2784771155, 503983604, 4076293799, 907881277, 423175695, 432175456, 1378068232, 4145222326, 3954048622, 3938656102, 3820766613, 2793130115, 2977904593, 26017576, 3274890735, 3194772133, 1700274565, 1756076034, 4006520079, 3677328699, 720338349, 1533947780, 354530856, 688349552, 3973924725, 1637815568, 332179504, 3949051286, 53804574, 2852348879, 3044236432, 1282449977, 3583942155, 3416972820, 4006381244, 1617046695, 2628476075, 3002303598, 1686838959, 431878346, 2686675385, 1700445008, 1080580658, 1009431731, 832498133, 3223435511, 2605976345, 2271191193, 2516031870, 1648197032, 4164389018, 2548247927, 300782431, 375919233, 238389289, 3353747414, 2531188641, 2019080857, 1475708069, 455242339, 2609103871, 448939670, 3451063019, 1395535956, 2413381860, 1841049896, 1491858159, 885456874, 4264095073, 4001119347, 1565136089, 3898914787, 1108368660, 540939232, 1173283510, 2745871338, 3681308437, 4207628240, 3343053890, 4016749493, 1699691293, 1103962373, 3625875870, 2256883143, 3830138730, 1031889488, 3479347698, 1535977030, 4236805024, 3251091107, 2132092099, 1774941330, 1199868427, 1452454533, 157007616, 2904115357, 342012276, 595725824, 1480756522, 206960106, 497939518, 591360097, 863170706, 2375253569, 3596610801, 1814182875, 2094937945, 3421402208, 1082520231, 3463918190, 2785509508, 435703966, 3908032597, 1641649973, 2842273706, 3305899714, 1510255612, 2148256476, 2655287854, 3276092548, 4258621189, 236887753, 3681803219, 274041037, 1734335097, 3815195456, 3317970021, 1899903192, 1026095262, 4050517792, 356393447, 2410691914, 3873677099, 3682840055], [3913112168, 2491498743, 4132185628, 2489919796, 1091903735, 1979897079, 3170134830, 3567386728, 3557303409, 857797738, 1136121015, 1342202287, 507115054, 2535736646, 337727348, 3213592640, 1301675037, 2528481711, 1895095763, 1721773893, 3216771564, 62756741, 2142006736, 835421444, 2531993523, 1442658625, 3659876326, 2882144922, 676362277, 1392781812, 170690266, 3921047035, 1759253602, 3611846912, 1745797284, 664899054, 1329594018, 3901205900, 3045908486, 2062866102, 2865634940, 3543621612, 3464012697, 1080764994, 553557557, 3656615353, 3996768171, 991055499, 499776247, 1265440854, 648242737, 3940784050, 980351604, 3713745714, 1749149687, 3396870395, 4211799374, 3640570775, 1161844396, 3125318951, 1431517754, 545492359, 4268468663, 3499529547, 1437099964, 2702547544, 3433638243, 2581715763, 2787789398, 1060185593, 1593081372, 2418618748, 4260947970, 69676912, 2159744348, 86519011, 2512459080, 3838209314, 1220612927, 3339683548, 133810670, 1090789135, 1078426020, 1569222167, 845107691, 3583754449, 4072456591, 1091646820, 628848692, 1613405280, 3757631651, 526609435, 236106946, 48312990, 2942717905, 3402727701, 1797494240, 859738849, 992217954, 4005476642, 2243076622, 3870952857, 3732016268, 765654824, 3490871365, 2511836413, 1685915746, 3888969200, 1414112111, 2273134842, 3281911079, 4080962846, 172450625, 2569994100, 980381355, 4109958455, 2819808352, 2716589560, 2568741196, 3681446669, 3329971472, 1835478071, 660984891, 3704678404, 4045999559, 3422617507, 3040415634, 1762651403, 1719377915, 3470491036, 2693910283, 3642056355, 3138596744, 1364962596, 2073328063, 1983633131, 926494387, 3423689081, 2150032023, 4096667949, 1749200295, 3328846651, 309677260, 2016342300, 1779581495, 3079819751, 111262694, 1274766160, 443224088, 298511866, 1025883608, 3806446537, 1145181785, 168956806, 3641502830, 3584813610, 1689216846, 3666258015, 3200248200, 1692713982, 2646376535, 4042768518, 1618508792, 1610833997, 3523052358, 4130873264, 2001055236, 3610705100, 2202168115, 4028541809, 2961195399, 1006657119, 2006996926, 3186142756, 1430667929, 3210227297, 1314452623, 4074634658, 4101304120, 2273951170, 1399257539, 3367210612, 3027628629, 1190975929, 2062231137, 2333990788, 2221543033, 2438960610, 1181637006, 548689776, 2362791313, 3372408396, 3104550113, 3145860560, 296247880, 1970579870, 3078560182, 3769228297, 1714227617, 3291629107, 3898220290, 166772364, 1251581989, 493813264, 448347421, 195405023, 2709975567, 677966185, 3703036547, 1463355134, 2715995803, 1338867538, 1343315457, 2802222074, 2684532164, 233230375, 2599980071, 2000651841, 3277868038, 1638401717, 4028070440, 3237316320, 6314154, 819756386, 300326615, 590932579, 1405279636, 3267499572, 3150704214, 2428286686, 3959192993, 3461946742, 1862657033, 1266418056, 963775037, 2089974820, 2263052895, 1917689273, 448879540, 3550394620, 3981727096, 150775221, 3627908307, 1303187396, 508620638, 2975983352, 2726630617, 1817252668, 1876281319, 1457606340, 908771278, 3720792119, 3617206836, 2455994898, 1729034894, 1080033504], [976866871, 3556439503, 2881648439, 1522871579, 1555064734, 1336096578, 3548522304, 2579274686, 3574697629, 3205460757, 3593280638, 3338716283, 3079412587, 564236357, 2993598910, 1781952180, 1464380207, 3163844217, 3332601554, 1699332808, 1393555694, 1183702653, 3581086237, 1288719814, 691649499, 2847557200, 2895455976, 3193889540, 2717570544, 1781354906, 1676643554, 2592534050, 3230253752, 1126444790, 2770207658, 2633158820, 2210423226, 2615765581, 2414155088, 3127139286, 673620729, 2805611233, 1269405062, 4015350505, 3341807571, 4149409754, 1057255273, 2012875353, 2162469141, 2276492801, 2601117357, 993977747, 3918593370, 2654263191, 753973209, 36408145, 2530585658, 25011837, 3520020182, 2088578344, 530523599, 2918365339, 1524020338, 1518925132, 3760827505, 3759777254, 1202760957, 3985898139, 3906192525, 674977740, 4174734889, 2031300136, 2019492241, 3983892565, 4153806404, 3822280332, 352677332, 2297720250, 60907813, 90501309, 3286998549, 1016092578, 2535922412, 2839152426, 457141659, 509813237, 4120667899, 652014361, 1966332200, 2975202805, 55981186, 2327461051, 676427537, 3255491064, 2882294119, 3433927263, 1307055953, 942726286, 933058658, 2468411793, 3933900994, 4215176142, 1361170020, 2001714738, 2830558078, 3274259782, 1222529897, 1679025792, 2729314320, 3714953764, 1770335741, 151462246, 3013232138, 1682292957, 1483529935, 471910574, 1539241949, 458788160, 3436315007, 1807016891, 3718408830, 978976581, 1043663428, 3165965781, 1927990952, 4200891579, 2372276910, 3208408903, 3533431907, 1412390302, 2931980059, 4132332400, 1947078029, 3881505623, 4168226417, 2941484381, 1077988104, 1320477388, 886195818, 18198404, 3786409e3, 2509781533, 112762804, 3463356488, 1866414978, 891333506, 18488651, 661792760, 1628790961, 3885187036, 3141171499, 876946877, 2693282273, 1372485963, 791857591, 2686433993, 3759982718, 3167212022, 3472953795, 2716379847, 445679433, 3561995674, 3504004811, 3574258232, 54117162, 3331405415, 2381918588, 3769707343, 4154350007, 1140177722, 4074052095, 668550556, 3214352940, 367459370, 261225585, 2610173221, 4209349473, 3468074219, 3265815641, 314222801, 3066103646, 3808782860, 282218597, 3406013506, 3773591054, 379116347, 1285071038, 846784868, 2669647154, 3771962079, 3550491691, 2305946142, 453669953, 1268987020, 3317592352, 3279303384, 3744833421, 2610507566, 3859509063, 266596637, 3847019092, 517658769, 3462560207, 3443424879, 370717030, 4247526661, 2224018117, 4143653529, 4112773975, 2788324899, 2477274417, 1456262402, 2901442914, 1517677493, 1846949527, 2295493580, 3734397586, 2176403920, 1280348187, 1908823572, 3871786941, 846861322, 1172426758, 3287448474, 3383383037, 1655181056, 3139813346, 901632758, 1897031941, 2986607138, 3066810236, 3447102507, 1393639104, 373351379, 950779232, 625454576, 3124240540, 4148612726, 2007998917, 544563296, 2244738638, 2330496472, 2058025392, 1291430526, 424198748, 50039436, 29584100, 3605783033, 2429876329, 2791104160, 1057563949, 3255363231, 3075367218, 3463963227, 1469046755, 985887462]]; + var r = { pbox: [], sbox: [] }; + function e(s, u) { + let p = u >> 24 & 255, l = u >> 16 & 255, v = u >> 8 & 255, y = 255 & u, g = s.sbox[0][p] + s.sbox[1][l]; + return g ^= s.sbox[2][v], g += s.sbox[3][y], g; + } + function t(s, u, p) { + let l, v = u, y = p; + for (let g = 0; g < a; ++g) v ^= s.pbox[g], y = e(s, v) ^ y, l = v, v = y, y = l; + return l = v, v = y, y = l, y ^= s.pbox[a], v ^= s.pbox[17], { left: v, right: y }; + } + var c = f.Blowfish = o.extend({ _doReset: function() { + if (this._keyPriorReset !== this._key) { + var s = this._keyPriorReset = this._key, u = s.words, p = s.sigBytes / 4; + (function(l, v, y) { + for (let A = 0; A < 4; A++) { + l.sbox[A] = []; + for (let m = 0; m < 256; m++) l.sbox[A][m] = n[A][m]; + } + let g = 0; + for (let A = 0; A < 18; A++) l.pbox[A] = i[A] ^ v[g], g++, g >= y && (g = 0); + let _ = 0, T = 0, b = 0; + for (let A = 0; A < 18; A += 2) b = t(l, _, T), _ = b.left, T = b.right, l.pbox[A] = _, l.pbox[A + 1] = T; + for (let A = 0; A < 4; A++) for (let m = 0; m < 256; m += 2) b = t(l, _, T), _ = b.left, T = b.right, l.sbox[A][m] = _, l.sbox[A][m + 1] = T; + })(r, u, p); + } + }, encryptBlock: function(s, u) { + var p = t(r, s[u], s[u + 1]); + s[u] = p.left, s[u + 1] = p.right; + }, decryptBlock: function(s, u) { + var p = (function(l, v, y) { + let g, _ = v, T = y; + for (let b = 17; b > 1; --b) _ ^= l.pbox[b], T = e(l, _) ^ T, g = _, _ = T, T = g; + return g = _, _ = T, T = g, T ^= l.pbox[1], _ ^= l.pbox[0], { left: _, right: T }; + })(r, s[u], s[u + 1]); + s[u] = p.left, s[u + 1] = p.right; + }, blockSize: 2, keySize: 4, ivSize: 2 }); + d.Blowfish = o._createHelper(c); + })(), h.Blowfish); + }, 7165(N, O, E) { + var h, d, o, f, a, i, n, r, e, t, c, s, u, p, l, v, y, g, _; + N.exports = (h = E(9021), E(9506), void (h.lib.Cipher || (d = h, o = d.lib, f = o.Base, a = o.WordArray, i = o.BufferedBlockAlgorithm, n = d.enc, n.Utf8, r = n.Base64, e = d.algo.EvpKDF, t = o.Cipher = i.extend({ cfg: f.extend(), createEncryptor: function(T, b) { + return this.create(this._ENC_XFORM_MODE, T, b); + }, createDecryptor: function(T, b) { + return this.create(this._DEC_XFORM_MODE, T, b); + }, init: function(T, b, A) { + this.cfg = this.cfg.extend(A), this._xformMode = T, this._key = b, this.reset(); + }, reset: function() { + i.reset.call(this), this._doReset(); + }, process: function(T) { + return this._append(T), this._process(); + }, finalize: function(T) { + return T && this._append(T), this._doFinalize(); + }, keySize: 4, ivSize: 4, _ENC_XFORM_MODE: 1, _DEC_XFORM_MODE: 2, _createHelper: /* @__PURE__ */ (function() { + function T(b) { + return typeof b == "string" ? _ : y; + } + return function(b) { + return { encrypt: function(A, m, I) { + return T(m).encrypt(b, A, m, I); + }, decrypt: function(A, m, I) { + return T(m).decrypt(b, A, m, I); + } }; + }; + })() }), o.StreamCipher = t.extend({ _doFinalize: function() { + return this._process(!0); + }, blockSize: 1 }), c = d.mode = {}, s = o.BlockCipherMode = f.extend({ createEncryptor: function(T, b) { + return this.Encryptor.create(T, b); + }, createDecryptor: function(T, b) { + return this.Decryptor.create(T, b); + }, init: function(T, b) { + this._cipher = T, this._iv = b; + } }), u = c.CBC = (function() { + var T = s.extend(); + function b(A, m, I) { + var P, x = this._iv; + x ? (P = x, this._iv = void 0) : P = this._prevBlock; + for (var F = 0; F < I; F++) A[m + F] ^= P[F]; + } + return T.Encryptor = T.extend({ processBlock: function(A, m) { + var I = this._cipher, P = I.blockSize; + b.call(this, A, m, P), I.encryptBlock(A, m), this._prevBlock = A.slice(m, m + P); + } }), T.Decryptor = T.extend({ processBlock: function(A, m) { + var I = this._cipher, P = I.blockSize, x = A.slice(m, m + P); + I.decryptBlock(A, m), b.call(this, A, m, P), this._prevBlock = x; + } }), T; + })(), p = (d.pad = {}).Pkcs7 = { pad: function(T, b) { + for (var A = 4 * b, m = A - T.sigBytes % A, I = m << 24 | m << 16 | m << 8 | m, P = [], x = 0; x < m; x += 4) P.push(I); + var F = a.create(P, m); + T.concat(F); + }, unpad: function(T) { + var b = 255 & T.words[T.sigBytes - 1 >>> 2]; + T.sigBytes -= b; + } }, o.BlockCipher = t.extend({ cfg: t.cfg.extend({ mode: u, padding: p }), reset: function() { + var T; + t.reset.call(this); + var b = this.cfg, A = b.iv, m = b.mode; + this._xformMode == this._ENC_XFORM_MODE ? T = m.createEncryptor : (T = m.createDecryptor, this._minBufferSize = 1), this._mode && this._mode.__creator == T ? this._mode.init(this, A && A.words) : (this._mode = T.call(m, this, A && A.words), this._mode.__creator = T); + }, _doProcessBlock: function(T, b) { + this._mode.processBlock(T, b); + }, _doFinalize: function() { + var T, b = this.cfg.padding; + return this._xformMode == this._ENC_XFORM_MODE ? (b.pad(this._data, this.blockSize), T = this._process(!0)) : (T = this._process(!0), b.unpad(T)), T; + }, blockSize: 4 }), l = o.CipherParams = f.extend({ init: function(T) { + this.mixIn(T); + }, toString: function(T) { + return (T || this.formatter).stringify(this); + } }), v = (d.format = {}).OpenSSL = { stringify: function(T) { + var b = T.ciphertext, A = T.salt; + return (A ? a.create([1398893684, 1701076831]).concat(A).concat(b) : b).toString(r); + }, parse: function(T) { + var b, A = r.parse(T), m = A.words; + return m[0] == 1398893684 && m[1] == 1701076831 && (b = a.create(m.slice(2, 4)), m.splice(0, 4), A.sigBytes -= 16), l.create({ ciphertext: A, salt: b }); + } }, y = o.SerializableCipher = f.extend({ cfg: f.extend({ format: v }), encrypt: function(T, b, A, m) { + m = this.cfg.extend(m); + var I = T.createEncryptor(A, m), P = I.finalize(b), x = I.cfg; + return l.create({ ciphertext: P, key: A, iv: x.iv, algorithm: T, mode: x.mode, padding: x.padding, blockSize: T.blockSize, formatter: m.format }); + }, decrypt: function(T, b, A, m) { + return m = this.cfg.extend(m), b = this._parse(b, m.format), T.createDecryptor(A, m).finalize(b.ciphertext); + }, _parse: function(T, b) { + return typeof T == "string" ? b.parse(T, this) : T; + } }), g = (d.kdf = {}).OpenSSL = { execute: function(T, b, A, m, I) { + if (m || (m = a.random(8)), I) P = e.create({ keySize: b + A, hasher: I }).compute(T, m); + else var P = e.create({ keySize: b + A }).compute(T, m); + var x = a.create(P.words.slice(b), 4 * A); + return P.sigBytes = 4 * b, l.create({ key: P, iv: x, salt: m }); + } }, _ = o.PasswordBasedCipher = y.extend({ cfg: y.cfg.extend({ kdf: g }), encrypt: function(T, b, A, m) { + var I = (m = this.cfg.extend(m)).kdf.execute(A, T.keySize, T.ivSize, m.salt, m.hasher); + m.iv = I.iv; + var P = y.encrypt.call(this, T, b, I.key, m); + return P.mixIn(I), P; + }, decrypt: function(T, b, A, m) { + m = this.cfg.extend(m), b = this._parse(b, m.format); + var I = m.kdf.execute(A, T.keySize, T.ivSize, b.salt, m.hasher); + return m.iv = I.iv, y.decrypt.call(this, T, b, I.key, m); + } })))); + }, 9021(N, O, E) { + var h; + N.exports = (h = h || (function(d) { + var o; + if (typeof window < "u" && window.crypto && (o = window.crypto), typeof self < "u" && self.crypto && (o = self.crypto), typeof globalThis < "u" && globalThis.crypto && (o = globalThis.crypto), !o && typeof window < "u" && window.msCrypto && (o = window.msCrypto), !o && E.g !== void 0 && E.g.crypto && (o = E.g.crypto), !o) try { + o = E(477); + } catch { + } + var f = function() { + if (o) { + if (typeof o.getRandomValues == "function") try { + return o.getRandomValues(new Uint32Array(1))[0]; + } catch { + } + if (typeof o.randomBytes == "function") try { + return o.randomBytes(4).readInt32LE(); + } catch { + } + } + throw new Error("Native crypto module could not be used to get secure random number."); + }, a = Object.create || /* @__PURE__ */ (function() { + function v() { + } + return function(y) { + var g; + return v.prototype = y, g = new v(), v.prototype = null, g; + }; + })(), i = {}, n = i.lib = {}, r = n.Base = { extend: function(v) { + var y = a(this); + return v && y.mixIn(v), y.hasOwnProperty("init") && this.init !== y.init || (y.init = function() { + y.$super.init.apply(this, arguments); + }), y.init.prototype = y, y.$super = this, y; + }, create: function() { + var v = this.extend(); + return v.init.apply(v, arguments), v; + }, init: function() { + }, mixIn: function(v) { + for (var y in v) v.hasOwnProperty(y) && (this[y] = v[y]); + v.hasOwnProperty("toString") && (this.toString = v.toString); + }, clone: function() { + return this.init.prototype.extend(this); + } }, e = n.WordArray = r.extend({ init: function(v, y) { + v = this.words = v || [], this.sigBytes = y ?? 4 * v.length; + }, toString: function(v) { + return (v || c).stringify(this); + }, concat: function(v) { + var y = this.words, g = v.words, _ = this.sigBytes, T = v.sigBytes; + if (this.clamp(), _ % 4) for (var b = 0; b < T; b++) { + var A = g[b >>> 2] >>> 24 - b % 4 * 8 & 255; + y[_ + b >>> 2] |= A << 24 - (_ + b) % 4 * 8; + } + else for (var m = 0; m < T; m += 4) y[_ + m >>> 2] = g[m >>> 2]; + return this.sigBytes += T, this; + }, clamp: function() { + var v = this.words, y = this.sigBytes; + v[y >>> 2] &= 4294967295 << 32 - y % 4 * 8, v.length = d.ceil(y / 4); + }, clone: function() { + var v = r.clone.call(this); + return v.words = this.words.slice(0), v; + }, random: function(v) { + for (var y = [], g = 0; g < v; g += 4) y.push(f()); + return new e.init(y, v); + } }), t = i.enc = {}, c = t.Hex = { stringify: function(v) { + for (var y = v.words, g = v.sigBytes, _ = [], T = 0; T < g; T++) { + var b = y[T >>> 2] >>> 24 - T % 4 * 8 & 255; + _.push((b >>> 4).toString(16)), _.push((15 & b).toString(16)); + } + return _.join(""); + }, parse: function(v) { + for (var y = v.length, g = [], _ = 0; _ < y; _ += 2) g[_ >>> 3] |= parseInt(v.substr(_, 2), 16) << 24 - _ % 8 * 4; + return new e.init(g, y / 2); + } }, s = t.Latin1 = { stringify: function(v) { + for (var y = v.words, g = v.sigBytes, _ = [], T = 0; T < g; T++) { + var b = y[T >>> 2] >>> 24 - T % 4 * 8 & 255; + _.push(String.fromCharCode(b)); + } + return _.join(""); + }, parse: function(v) { + for (var y = v.length, g = [], _ = 0; _ < y; _++) g[_ >>> 2] |= (255 & v.charCodeAt(_)) << 24 - _ % 4 * 8; + return new e.init(g, y); + } }, u = t.Utf8 = { stringify: function(v) { + try { + return decodeURIComponent(escape(s.stringify(v))); + } catch { + throw new Error("Malformed UTF-8 data"); + } + }, parse: function(v) { + return s.parse(unescape(encodeURIComponent(v))); + } }, p = n.BufferedBlockAlgorithm = r.extend({ reset: function() { + this._data = new e.init(), this._nDataBytes = 0; + }, _append: function(v) { + typeof v == "string" && (v = u.parse(v)), this._data.concat(v), this._nDataBytes += v.sigBytes; + }, _process: function(v) { + var y, g = this._data, _ = g.words, T = g.sigBytes, b = this.blockSize, A = T / (4 * b), m = (A = v ? d.ceil(A) : d.max((0 | A) - this._minBufferSize, 0)) * b, I = d.min(4 * m, T); + if (m) { + for (var P = 0; P < m; P += b) this._doProcessBlock(_, P); + y = _.splice(0, m), g.sigBytes -= I; + } + return new e.init(y, I); + }, clone: function() { + var v = r.clone.call(this); + return v._data = this._data.clone(), v; + }, _minBufferSize: 0 }), l = (n.Hasher = p.extend({ cfg: r.extend(), init: function(v) { + this.cfg = this.cfg.extend(v), this.reset(); + }, reset: function() { + p.reset.call(this), this._doReset(); + }, update: function(v) { + return this._append(v), this._process(), this; + }, finalize: function(v) { + return v && this._append(v), this._doFinalize(); + }, blockSize: 16, _createHelper: function(v) { + return function(y, g) { + return new v.init(g).finalize(y); + }; + }, _createHmacHelper: function(v) { + return function(y, g) { + return new l.HMAC.init(v, g).finalize(y); + }; + } }), i.algo = {}); + return i; + })(Math), h); + }, 754(N, O, E) { + var h, d, o; + N.exports = (h = E(9021), o = (d = h).lib.WordArray, d.enc.Base64 = { stringify: function(f) { + var a = f.words, i = f.sigBytes, n = this._map; + f.clamp(); + for (var r = [], e = 0; e < i; e += 3) for (var t = (a[e >>> 2] >>> 24 - e % 4 * 8 & 255) << 16 | (a[e + 1 >>> 2] >>> 24 - (e + 1) % 4 * 8 & 255) << 8 | a[e + 2 >>> 2] >>> 24 - (e + 2) % 4 * 8 & 255, c = 0; c < 4 && e + 0.75 * c < i; c++) r.push(n.charAt(t >>> 6 * (3 - c) & 63)); + var s = n.charAt(64); + if (s) for (; r.length % 4; ) r.push(s); + return r.join(""); + }, parse: function(f) { + var a = f.length, i = this._map, n = this._reverseMap; + if (!n) { + n = this._reverseMap = []; + for (var r = 0; r < i.length; r++) n[i.charCodeAt(r)] = r; + } + var e = i.charAt(64); + if (e) { + var t = f.indexOf(e); + t !== -1 && (a = t); + } + return (function(c, s, u) { + for (var p = [], l = 0, v = 0; v < s; v++) if (v % 4) { + var y = u[c.charCodeAt(v - 1)] << v % 4 * 2 | u[c.charCodeAt(v)] >>> 6 - v % 4 * 2; + p[l >>> 2] |= y << 24 - l % 4 * 8, l++; + } + return o.create(p, l); + })(f, a, n); + }, _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" }, h.enc.Base64); + }, 4725(N, O, E) { + var h, d, o; + N.exports = (h = E(9021), o = (d = h).lib.WordArray, d.enc.Base64url = { stringify: function(f, a) { + a === void 0 && (a = !0); + var i = f.words, n = f.sigBytes, r = a ? this._safe_map : this._map; + f.clamp(); + for (var e = [], t = 0; t < n; t += 3) for (var c = (i[t >>> 2] >>> 24 - t % 4 * 8 & 255) << 16 | (i[t + 1 >>> 2] >>> 24 - (t + 1) % 4 * 8 & 255) << 8 | i[t + 2 >>> 2] >>> 24 - (t + 2) % 4 * 8 & 255, s = 0; s < 4 && t + 0.75 * s < n; s++) e.push(r.charAt(c >>> 6 * (3 - s) & 63)); + var u = r.charAt(64); + if (u) for (; e.length % 4; ) e.push(u); + return e.join(""); + }, parse: function(f, a) { + a === void 0 && (a = !0); + var i = f.length, n = a ? this._safe_map : this._map, r = this._reverseMap; + if (!r) { + r = this._reverseMap = []; + for (var e = 0; e < n.length; e++) r[n.charCodeAt(e)] = e; + } + var t = n.charAt(64); + if (t) { + var c = f.indexOf(t); + c !== -1 && (i = c); + } + return (function(s, u, p) { + for (var l = [], v = 0, y = 0; y < u; y++) if (y % 4) { + var g = p[s.charCodeAt(y - 1)] << y % 4 * 2 | p[s.charCodeAt(y)] >>> 6 - y % 4 * 2; + l[v >>> 2] |= g << 24 - v % 4 * 8, v++; + } + return o.create(l, v); + })(f, i, r); + }, _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", _safe_map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" }, h.enc.Base64url); + }, 5503(N, O, E) { + var h; + N.exports = (h = E(9021), (function() { + var d = h, o = d.lib.WordArray, f = d.enc; + function a(i) { + return i << 8 & 4278255360 | i >>> 8 & 16711935; + } + f.Utf16 = f.Utf16BE = { stringify: function(i) { + for (var n = i.words, r = i.sigBytes, e = [], t = 0; t < r; t += 2) { + var c = n[t >>> 2] >>> 16 - t % 4 * 8 & 65535; + e.push(String.fromCharCode(c)); + } + return e.join(""); + }, parse: function(i) { + for (var n = i.length, r = [], e = 0; e < n; e++) r[e >>> 1] |= i.charCodeAt(e) << 16 - e % 2 * 16; + return o.create(r, 2 * n); + } }, f.Utf16LE = { stringify: function(i) { + for (var n = i.words, r = i.sigBytes, e = [], t = 0; t < r; t += 2) { + var c = a(n[t >>> 2] >>> 16 - t % 4 * 8 & 65535); + e.push(String.fromCharCode(c)); + } + return e.join(""); + }, parse: function(i) { + for (var n = i.length, r = [], e = 0; e < n; e++) r[e >>> 1] |= a(i.charCodeAt(e) << 16 - e % 2 * 16); + return o.create(r, 2 * n); + } }; + })(), h.enc.Utf16); + }, 9506(N, O, E) { + var h, d, o, f, a, i, n, r; + N.exports = (r = E(9021), E(5471), E(1025), o = (d = (h = r).lib).Base, f = d.WordArray, i = (a = h.algo).MD5, n = a.EvpKDF = o.extend({ cfg: o.extend({ keySize: 4, hasher: i, iterations: 1 }), init: function(e) { + this.cfg = this.cfg.extend(e); + }, compute: function(e, t) { + for (var c, s = this.cfg, u = s.hasher.create(), p = f.create(), l = p.words, v = s.keySize, y = s.iterations; l.length < v; ) { + c && u.update(c), c = u.update(e).finalize(t), u.reset(); + for (var g = 1; g < y; g++) c = u.finalize(c), u.reset(); + p.concat(c); + } + return p.sigBytes = 4 * v, p; + } }), h.EvpKDF = function(e, t, c) { + return n.create(c).compute(e, t); + }, r.EvpKDF); + }, 25(N, O, E) { + var h, d, o, f; + N.exports = (f = E(9021), E(7165), d = (h = f).lib.CipherParams, o = h.enc.Hex, h.format.Hex = { stringify: function(a) { + return a.ciphertext.toString(o); + }, parse: function(a) { + var i = o.parse(a); + return d.create({ ciphertext: i }); + } }, f.format.Hex); + }, 1025(N, O, E) { + var h, d, o; + N.exports = (d = (h = E(9021)).lib.Base, o = h.enc.Utf8, void (h.algo.HMAC = d.extend({ init: function(f, a) { + f = this._hasher = new f.init(), typeof a == "string" && (a = o.parse(a)); + var i = f.blockSize, n = 4 * i; + a.sigBytes > n && (a = f.finalize(a)), a.clamp(); + for (var r = this._oKey = a.clone(), e = this._iKey = a.clone(), t = r.words, c = e.words, s = 0; s < i; s++) t[s] ^= 1549556828, c[s] ^= 909522486; + r.sigBytes = e.sigBytes = n, this.reset(); + }, reset: function() { + var f = this._hasher; + f.reset(), f.update(this._iKey); + }, update: function(f) { + return this._hasher.update(f), this; + }, finalize: function(f) { + var a = this._hasher, i = a.finalize(f); + return a.reset(), a.finalize(this._oKey.clone().concat(i)); + } }))); + }, 1396(N, O, E) { + var h; + N.exports = (h = E(9021), E(3240), E(6440), E(5503), E(754), E(4725), E(4636), E(5471), E(3009), E(6308), E(1380), E(9557), E(5953), E(8056), E(1025), E(19), E(9506), E(7165), E(2169), E(6939), E(6372), E(3797), E(8454), E(2073), E(4905), E(482), E(2155), E(8124), E(25), E(955), E(7628), E(7193), E(6298), E(2696), E(3128), h); + }, 6440(N, O, E) { + var h; + N.exports = (h = E(9021), (function() { + if (typeof ArrayBuffer == "function") { + var d = h.lib.WordArray, o = d.init, f = d.init = function(a) { + if (a instanceof ArrayBuffer && (a = new Uint8Array(a)), (a instanceof Int8Array || typeof Uint8ClampedArray < "u" && a instanceof Uint8ClampedArray || a instanceof Int16Array || a instanceof Uint16Array || a instanceof Int32Array || a instanceof Uint32Array || a instanceof Float32Array || a instanceof Float64Array) && (a = new Uint8Array(a.buffer, a.byteOffset, a.byteLength)), a instanceof Uint8Array) { + for (var i = a.byteLength, n = [], r = 0; r < i; r++) n[r >>> 2] |= a[r] << 24 - r % 4 * 8; + o.call(this, n, i); + } else o.apply(this, arguments); + }; + f.prototype = d; + } + })(), h.lib.WordArray); + }, 4636(N, O, E) { + var h; + N.exports = (h = E(9021), (function(d) { + var o = h, f = o.lib, a = f.WordArray, i = f.Hasher, n = o.algo, r = []; + (function() { + for (var p = 0; p < 64; p++) r[p] = 4294967296 * d.abs(d.sin(p + 1)) | 0; + })(); + var e = n.MD5 = i.extend({ _doReset: function() { + this._hash = new a.init([1732584193, 4023233417, 2562383102, 271733878]); + }, _doProcessBlock: function(p, l) { + for (var v = 0; v < 16; v++) { + var y = l + v, g = p[y]; + p[y] = 16711935 & (g << 8 | g >>> 24) | 4278255360 & (g << 24 | g >>> 8); + } + var _ = this._hash.words, T = p[l + 0], b = p[l + 1], A = p[l + 2], m = p[l + 3], I = p[l + 4], P = p[l + 5], x = p[l + 6], F = p[l + 7], K = p[l + 8], Y = p[l + 9], Q = p[l + 10], S = p[l + 11], M = p[l + 12], j = p[l + 13], H = p[l + 14], Z = p[l + 15], L = _[0], w = _[1], C = _[2], R = _[3]; + L = t(L, w, C, R, T, 7, r[0]), R = t(R, L, w, C, b, 12, r[1]), C = t(C, R, L, w, A, 17, r[2]), w = t(w, C, R, L, m, 22, r[3]), L = t(L, w, C, R, I, 7, r[4]), R = t(R, L, w, C, P, 12, r[5]), C = t(C, R, L, w, x, 17, r[6]), w = t(w, C, R, L, F, 22, r[7]), L = t(L, w, C, R, K, 7, r[8]), R = t(R, L, w, C, Y, 12, r[9]), C = t(C, R, L, w, Q, 17, r[10]), w = t(w, C, R, L, S, 22, r[11]), L = t(L, w, C, R, M, 7, r[12]), R = t(R, L, w, C, j, 12, r[13]), C = t(C, R, L, w, H, 17, r[14]), L = c(L, w = t(w, C, R, L, Z, 22, r[15]), C, R, b, 5, r[16]), R = c(R, L, w, C, x, 9, r[17]), C = c(C, R, L, w, S, 14, r[18]), w = c(w, C, R, L, T, 20, r[19]), L = c(L, w, C, R, P, 5, r[20]), R = c(R, L, w, C, Q, 9, r[21]), C = c(C, R, L, w, Z, 14, r[22]), w = c(w, C, R, L, I, 20, r[23]), L = c(L, w, C, R, Y, 5, r[24]), R = c(R, L, w, C, H, 9, r[25]), C = c(C, R, L, w, m, 14, r[26]), w = c(w, C, R, L, K, 20, r[27]), L = c(L, w, C, R, j, 5, r[28]), R = c(R, L, w, C, A, 9, r[29]), C = c(C, R, L, w, F, 14, r[30]), L = s(L, w = c(w, C, R, L, M, 20, r[31]), C, R, P, 4, r[32]), R = s(R, L, w, C, K, 11, r[33]), C = s(C, R, L, w, S, 16, r[34]), w = s(w, C, R, L, H, 23, r[35]), L = s(L, w, C, R, b, 4, r[36]), R = s(R, L, w, C, I, 11, r[37]), C = s(C, R, L, w, F, 16, r[38]), w = s(w, C, R, L, Q, 23, r[39]), L = s(L, w, C, R, j, 4, r[40]), R = s(R, L, w, C, T, 11, r[41]), C = s(C, R, L, w, m, 16, r[42]), w = s(w, C, R, L, x, 23, r[43]), L = s(L, w, C, R, Y, 4, r[44]), R = s(R, L, w, C, M, 11, r[45]), C = s(C, R, L, w, Z, 16, r[46]), L = u(L, w = s(w, C, R, L, A, 23, r[47]), C, R, T, 6, r[48]), R = u(R, L, w, C, F, 10, r[49]), C = u(C, R, L, w, H, 15, r[50]), w = u(w, C, R, L, P, 21, r[51]), L = u(L, w, C, R, M, 6, r[52]), R = u(R, L, w, C, m, 10, r[53]), C = u(C, R, L, w, Q, 15, r[54]), w = u(w, C, R, L, b, 21, r[55]), L = u(L, w, C, R, K, 6, r[56]), R = u(R, L, w, C, Z, 10, r[57]), C = u(C, R, L, w, x, 15, r[58]), w = u(w, C, R, L, j, 21, r[59]), L = u(L, w, C, R, I, 6, r[60]), R = u(R, L, w, C, S, 10, r[61]), C = u(C, R, L, w, A, 15, r[62]), w = u(w, C, R, L, Y, 21, r[63]), _[0] = _[0] + L | 0, _[1] = _[1] + w | 0, _[2] = _[2] + C | 0, _[3] = _[3] + R | 0; + }, _doFinalize: function() { + var p = this._data, l = p.words, v = 8 * this._nDataBytes, y = 8 * p.sigBytes; + l[y >>> 5] |= 128 << 24 - y % 32; + var g = d.floor(v / 4294967296), _ = v; + l[15 + (y + 64 >>> 9 << 4)] = 16711935 & (g << 8 | g >>> 24) | 4278255360 & (g << 24 | g >>> 8), l[14 + (y + 64 >>> 9 << 4)] = 16711935 & (_ << 8 | _ >>> 24) | 4278255360 & (_ << 24 | _ >>> 8), p.sigBytes = 4 * (l.length + 1), this._process(); + for (var T = this._hash, b = T.words, A = 0; A < 4; A++) { + var m = b[A]; + b[A] = 16711935 & (m << 8 | m >>> 24) | 4278255360 & (m << 24 | m >>> 8); + } + return T; + }, clone: function() { + var p = i.clone.call(this); + return p._hash = this._hash.clone(), p; + } }); + function t(p, l, v, y, g, _, T) { + var b = p + (l & v | ~l & y) + g + T; + return (b << _ | b >>> 32 - _) + l; + } + function c(p, l, v, y, g, _, T) { + var b = p + (l & y | v & ~y) + g + T; + return (b << _ | b >>> 32 - _) + l; + } + function s(p, l, v, y, g, _, T) { + var b = p + (l ^ v ^ y) + g + T; + return (b << _ | b >>> 32 - _) + l; + } + function u(p, l, v, y, g, _, T) { + var b = p + (v ^ (l | ~y)) + g + T; + return (b << _ | b >>> 32 - _) + l; + } + o.MD5 = i._createHelper(e), o.HmacMD5 = i._createHmacHelper(e); + })(Math), h.MD5); + }, 2169(N, O, E) { + var h; + N.exports = (h = E(9021), E(7165), h.mode.CFB = (function() { + var d = h.lib.BlockCipherMode.extend(); + function o(f, a, i, n) { + var r, e = this._iv; + e ? (r = e.slice(0), this._iv = void 0) : r = this._prevBlock, n.encryptBlock(r, 0); + for (var t = 0; t < i; t++) f[a + t] ^= r[t]; + } + return d.Encryptor = d.extend({ processBlock: function(f, a) { + var i = this._cipher, n = i.blockSize; + o.call(this, f, a, n, i), this._prevBlock = f.slice(a, a + n); + } }), d.Decryptor = d.extend({ processBlock: function(f, a) { + var i = this._cipher, n = i.blockSize, r = f.slice(a, a + n); + o.call(this, f, a, n, i), this._prevBlock = r; + } }), d; + })(), h.mode.CFB); + }, 6372(N, O, E) { + var h; + N.exports = (h = E(9021), E(7165), h.mode.CTRGladman = (function() { + var d = h.lib.BlockCipherMode.extend(); + function o(a) { + if (255 & ~(a >> 24)) a += 16777216; + else { + var i = a >> 16 & 255, n = a >> 8 & 255, r = 255 & a; + i === 255 ? (i = 0, n === 255 ? (n = 0, r === 255 ? r = 0 : ++r) : ++n) : ++i, a = 0, a += i << 16, a += n << 8, a += r; + } + return a; + } + var f = d.Encryptor = d.extend({ processBlock: function(a, i) { + var n = this._cipher, r = n.blockSize, e = this._iv, t = this._counter; + e && (t = this._counter = e.slice(0), this._iv = void 0), (function(u) { + (u[0] = o(u[0])) === 0 && (u[1] = o(u[1])); + })(t); + var c = t.slice(0); + n.encryptBlock(c, 0); + for (var s = 0; s < r; s++) a[i + s] ^= c[s]; + } }); + return d.Decryptor = f, d; + })(), h.mode.CTRGladman); + }, 6939(N, O, E) { + var h, d, o; + N.exports = (o = E(9021), E(7165), o.mode.CTR = (d = (h = o.lib.BlockCipherMode.extend()).Encryptor = h.extend({ processBlock: function(f, a) { + var i = this._cipher, n = i.blockSize, r = this._iv, e = this._counter; + r && (e = this._counter = r.slice(0), this._iv = void 0); + var t = e.slice(0); + i.encryptBlock(t, 0), e[n - 1] = e[n - 1] + 1 | 0; + for (var c = 0; c < n; c++) f[a + c] ^= t[c]; + } }), h.Decryptor = d, h), o.mode.CTR); + }, 8454(N, O, E) { + var h, d; + N.exports = (d = E(9021), E(7165), d.mode.ECB = ((h = d.lib.BlockCipherMode.extend()).Encryptor = h.extend({ processBlock: function(o, f) { + this._cipher.encryptBlock(o, f); + } }), h.Decryptor = h.extend({ processBlock: function(o, f) { + this._cipher.decryptBlock(o, f); + } }), h), d.mode.ECB); + }, 3797(N, O, E) { + var h, d, o; + N.exports = (o = E(9021), E(7165), o.mode.OFB = (d = (h = o.lib.BlockCipherMode.extend()).Encryptor = h.extend({ processBlock: function(f, a) { + var i = this._cipher, n = i.blockSize, r = this._iv, e = this._keystream; + r && (e = this._keystream = r.slice(0), this._iv = void 0), i.encryptBlock(e, 0); + for (var t = 0; t < n; t++) f[a + t] ^= e[t]; + } }), h.Decryptor = d, h), o.mode.OFB); + }, 2073(N, O, E) { + var h; + N.exports = (h = E(9021), E(7165), h.pad.AnsiX923 = { pad: function(d, o) { + var f = d.sigBytes, a = 4 * o, i = a - f % a, n = f + i - 1; + d.clamp(), d.words[n >>> 2] |= i << 24 - n % 4 * 8, d.sigBytes += i; + }, unpad: function(d) { + var o = 255 & d.words[d.sigBytes - 1 >>> 2]; + d.sigBytes -= o; + } }, h.pad.Ansix923); + }, 4905(N, O, E) { + var h; + N.exports = (h = E(9021), E(7165), h.pad.Iso10126 = { pad: function(d, o) { + var f = 4 * o, a = f - d.sigBytes % f; + d.concat(h.lib.WordArray.random(a - 1)).concat(h.lib.WordArray.create([a << 24], 1)); + }, unpad: function(d) { + var o = 255 & d.words[d.sigBytes - 1 >>> 2]; + d.sigBytes -= o; + } }, h.pad.Iso10126); + }, 482(N, O, E) { + var h; + N.exports = (h = E(9021), E(7165), h.pad.Iso97971 = { pad: function(d, o) { + d.concat(h.lib.WordArray.create([2147483648], 1)), h.pad.ZeroPadding.pad(d, o); + }, unpad: function(d) { + h.pad.ZeroPadding.unpad(d), d.sigBytes--; + } }, h.pad.Iso97971); + }, 8124(N, O, E) { + var h; + N.exports = (h = E(9021), E(7165), h.pad.NoPadding = { pad: function() { + }, unpad: function() { + } }, h.pad.NoPadding); + }, 2155(N, O, E) { + var h; + N.exports = (h = E(9021), E(7165), h.pad.ZeroPadding = { pad: function(d, o) { + var f = 4 * o; + d.clamp(), d.sigBytes += f - (d.sigBytes % f || f); + }, unpad: function(d) { + var o = d.words, f = d.sigBytes - 1; + for (f = d.sigBytes - 1; f >= 0; f--) if (o[f >>> 2] >>> 24 - f % 4 * 8 & 255) { + d.sigBytes = f + 1; + break; + } + } }, h.pad.ZeroPadding); + }, 19(N, O, E) { + var h, d, o, f, a, i, n, r, e; + N.exports = (e = E(9021), E(3009), E(1025), o = (d = (h = e).lib).Base, f = d.WordArray, i = (a = h.algo).SHA256, n = a.HMAC, r = a.PBKDF2 = o.extend({ cfg: o.extend({ keySize: 4, hasher: i, iterations: 25e4 }), init: function(t) { + this.cfg = this.cfg.extend(t); + }, compute: function(t, c) { + for (var s = this.cfg, u = n.create(s.hasher, t), p = f.create(), l = f.create([1]), v = p.words, y = l.words, g = s.keySize, _ = s.iterations; v.length < g; ) { + var T = u.update(c).finalize(l); + u.reset(); + for (var b = T.words, A = b.length, m = T, I = 1; I < _; I++) { + m = u.finalize(m), u.reset(); + for (var P = m.words, x = 0; x < A; x++) b[x] ^= P[x]; + } + p.concat(T), y[0]++; + } + return p.sigBytes = 4 * g, p; + } }), h.PBKDF2 = function(t, c, s) { + return r.create(s).compute(t, c); + }, e.PBKDF2); + }, 2696(N, O, E) { + var h; + N.exports = (h = E(9021), E(754), E(4636), E(9506), E(7165), (function() { + var d = h, o = d.lib.StreamCipher, f = d.algo, a = [], i = [], n = [], r = f.RabbitLegacy = o.extend({ _doReset: function() { + var t = this._key.words, c = this.cfg.iv, s = this._X = [t[0], t[3] << 16 | t[2] >>> 16, t[1], t[0] << 16 | t[3] >>> 16, t[2], t[1] << 16 | t[0] >>> 16, t[3], t[2] << 16 | t[1] >>> 16], u = this._C = [t[2] << 16 | t[2] >>> 16, 4294901760 & t[0] | 65535 & t[1], t[3] << 16 | t[3] >>> 16, 4294901760 & t[1] | 65535 & t[2], t[0] << 16 | t[0] >>> 16, 4294901760 & t[2] | 65535 & t[3], t[1] << 16 | t[1] >>> 16, 4294901760 & t[3] | 65535 & t[0]]; + this._b = 0; + for (var p = 0; p < 4; p++) e.call(this); + for (p = 0; p < 8; p++) u[p] ^= s[p + 4 & 7]; + if (c) { + var l = c.words, v = l[0], y = l[1], g = 16711935 & (v << 8 | v >>> 24) | 4278255360 & (v << 24 | v >>> 8), _ = 16711935 & (y << 8 | y >>> 24) | 4278255360 & (y << 24 | y >>> 8), T = g >>> 16 | 4294901760 & _, b = _ << 16 | 65535 & g; + for (u[0] ^= g, u[1] ^= T, u[2] ^= _, u[3] ^= b, u[4] ^= g, u[5] ^= T, u[6] ^= _, u[7] ^= b, p = 0; p < 4; p++) e.call(this); + } + }, _doProcessBlock: function(t, c) { + var s = this._X; + e.call(this), a[0] = s[0] ^ s[5] >>> 16 ^ s[3] << 16, a[1] = s[2] ^ s[7] >>> 16 ^ s[5] << 16, a[2] = s[4] ^ s[1] >>> 16 ^ s[7] << 16, a[3] = s[6] ^ s[3] >>> 16 ^ s[1] << 16; + for (var u = 0; u < 4; u++) a[u] = 16711935 & (a[u] << 8 | a[u] >>> 24) | 4278255360 & (a[u] << 24 | a[u] >>> 8), t[c + u] ^= a[u]; + }, blockSize: 4, ivSize: 2 }); + function e() { + for (var t = this._X, c = this._C, s = 0; s < 8; s++) i[s] = c[s]; + for (c[0] = c[0] + 1295307597 + this._b | 0, c[1] = c[1] + 3545052371 + (c[0] >>> 0 < i[0] >>> 0 ? 1 : 0) | 0, c[2] = c[2] + 886263092 + (c[1] >>> 0 < i[1] >>> 0 ? 1 : 0) | 0, c[3] = c[3] + 1295307597 + (c[2] >>> 0 < i[2] >>> 0 ? 1 : 0) | 0, c[4] = c[4] + 3545052371 + (c[3] >>> 0 < i[3] >>> 0 ? 1 : 0) | 0, c[5] = c[5] + 886263092 + (c[4] >>> 0 < i[4] >>> 0 ? 1 : 0) | 0, c[6] = c[6] + 1295307597 + (c[5] >>> 0 < i[5] >>> 0 ? 1 : 0) | 0, c[7] = c[7] + 3545052371 + (c[6] >>> 0 < i[6] >>> 0 ? 1 : 0) | 0, this._b = c[7] >>> 0 < i[7] >>> 0 ? 1 : 0, s = 0; s < 8; s++) { + var u = t[s] + c[s], p = 65535 & u, l = u >>> 16, v = ((p * p >>> 17) + p * l >>> 15) + l * l, y = ((4294901760 & u) * u | 0) + ((65535 & u) * u | 0); + n[s] = v ^ y; + } + t[0] = n[0] + (n[7] << 16 | n[7] >>> 16) + (n[6] << 16 | n[6] >>> 16) | 0, t[1] = n[1] + (n[0] << 8 | n[0] >>> 24) + n[7] | 0, t[2] = n[2] + (n[1] << 16 | n[1] >>> 16) + (n[0] << 16 | n[0] >>> 16) | 0, t[3] = n[3] + (n[2] << 8 | n[2] >>> 24) + n[1] | 0, t[4] = n[4] + (n[3] << 16 | n[3] >>> 16) + (n[2] << 16 | n[2] >>> 16) | 0, t[5] = n[5] + (n[4] << 8 | n[4] >>> 24) + n[3] | 0, t[6] = n[6] + (n[5] << 16 | n[5] >>> 16) + (n[4] << 16 | n[4] >>> 16) | 0, t[7] = n[7] + (n[6] << 8 | n[6] >>> 24) + n[5] | 0; + } + d.RabbitLegacy = o._createHelper(r); + })(), h.RabbitLegacy); + }, 6298(N, O, E) { + var h; + N.exports = (h = E(9021), E(754), E(4636), E(9506), E(7165), (function() { + var d = h, o = d.lib.StreamCipher, f = d.algo, a = [], i = [], n = [], r = f.Rabbit = o.extend({ _doReset: function() { + for (var t = this._key.words, c = this.cfg.iv, s = 0; s < 4; s++) t[s] = 16711935 & (t[s] << 8 | t[s] >>> 24) | 4278255360 & (t[s] << 24 | t[s] >>> 8); + var u = this._X = [t[0], t[3] << 16 | t[2] >>> 16, t[1], t[0] << 16 | t[3] >>> 16, t[2], t[1] << 16 | t[0] >>> 16, t[3], t[2] << 16 | t[1] >>> 16], p = this._C = [t[2] << 16 | t[2] >>> 16, 4294901760 & t[0] | 65535 & t[1], t[3] << 16 | t[3] >>> 16, 4294901760 & t[1] | 65535 & t[2], t[0] << 16 | t[0] >>> 16, 4294901760 & t[2] | 65535 & t[3], t[1] << 16 | t[1] >>> 16, 4294901760 & t[3] | 65535 & t[0]]; + for (this._b = 0, s = 0; s < 4; s++) e.call(this); + for (s = 0; s < 8; s++) p[s] ^= u[s + 4 & 7]; + if (c) { + var l = c.words, v = l[0], y = l[1], g = 16711935 & (v << 8 | v >>> 24) | 4278255360 & (v << 24 | v >>> 8), _ = 16711935 & (y << 8 | y >>> 24) | 4278255360 & (y << 24 | y >>> 8), T = g >>> 16 | 4294901760 & _, b = _ << 16 | 65535 & g; + for (p[0] ^= g, p[1] ^= T, p[2] ^= _, p[3] ^= b, p[4] ^= g, p[5] ^= T, p[6] ^= _, p[7] ^= b, s = 0; s < 4; s++) e.call(this); + } + }, _doProcessBlock: function(t, c) { + var s = this._X; + e.call(this), a[0] = s[0] ^ s[5] >>> 16 ^ s[3] << 16, a[1] = s[2] ^ s[7] >>> 16 ^ s[5] << 16, a[2] = s[4] ^ s[1] >>> 16 ^ s[7] << 16, a[3] = s[6] ^ s[3] >>> 16 ^ s[1] << 16; + for (var u = 0; u < 4; u++) a[u] = 16711935 & (a[u] << 8 | a[u] >>> 24) | 4278255360 & (a[u] << 24 | a[u] >>> 8), t[c + u] ^= a[u]; + }, blockSize: 4, ivSize: 2 }); + function e() { + for (var t = this._X, c = this._C, s = 0; s < 8; s++) i[s] = c[s]; + for (c[0] = c[0] + 1295307597 + this._b | 0, c[1] = c[1] + 3545052371 + (c[0] >>> 0 < i[0] >>> 0 ? 1 : 0) | 0, c[2] = c[2] + 886263092 + (c[1] >>> 0 < i[1] >>> 0 ? 1 : 0) | 0, c[3] = c[3] + 1295307597 + (c[2] >>> 0 < i[2] >>> 0 ? 1 : 0) | 0, c[4] = c[4] + 3545052371 + (c[3] >>> 0 < i[3] >>> 0 ? 1 : 0) | 0, c[5] = c[5] + 886263092 + (c[4] >>> 0 < i[4] >>> 0 ? 1 : 0) | 0, c[6] = c[6] + 1295307597 + (c[5] >>> 0 < i[5] >>> 0 ? 1 : 0) | 0, c[7] = c[7] + 3545052371 + (c[6] >>> 0 < i[6] >>> 0 ? 1 : 0) | 0, this._b = c[7] >>> 0 < i[7] >>> 0 ? 1 : 0, s = 0; s < 8; s++) { + var u = t[s] + c[s], p = 65535 & u, l = u >>> 16, v = ((p * p >>> 17) + p * l >>> 15) + l * l, y = ((4294901760 & u) * u | 0) + ((65535 & u) * u | 0); + n[s] = v ^ y; + } + t[0] = n[0] + (n[7] << 16 | n[7] >>> 16) + (n[6] << 16 | n[6] >>> 16) | 0, t[1] = n[1] + (n[0] << 8 | n[0] >>> 24) + n[7] | 0, t[2] = n[2] + (n[1] << 16 | n[1] >>> 16) + (n[0] << 16 | n[0] >>> 16) | 0, t[3] = n[3] + (n[2] << 8 | n[2] >>> 24) + n[1] | 0, t[4] = n[4] + (n[3] << 16 | n[3] >>> 16) + (n[2] << 16 | n[2] >>> 16) | 0, t[5] = n[5] + (n[4] << 8 | n[4] >>> 24) + n[3] | 0, t[6] = n[6] + (n[5] << 16 | n[5] >>> 16) + (n[4] << 16 | n[4] >>> 16) | 0, t[7] = n[7] + (n[6] << 8 | n[6] >>> 24) + n[5] | 0; + } + d.Rabbit = o._createHelper(r); + })(), h.Rabbit); + }, 7193(N, O, E) { + var h; + N.exports = (h = E(9021), E(754), E(4636), E(9506), E(7165), (function() { + var d = h, o = d.lib.StreamCipher, f = d.algo, a = f.RC4 = o.extend({ _doReset: function() { + for (var r = this._key, e = r.words, t = r.sigBytes, c = this._S = [], s = 0; s < 256; s++) c[s] = s; + s = 0; + for (var u = 0; s < 256; s++) { + var p = s % t, l = e[p >>> 2] >>> 24 - p % 4 * 8 & 255; + u = (u + c[s] + l) % 256; + var v = c[s]; + c[s] = c[u], c[u] = v; + } + this._i = this._j = 0; + }, _doProcessBlock: function(r, e) { + r[e] ^= i.call(this); + }, keySize: 8, ivSize: 0 }); + function i() { + for (var r = this._S, e = this._i, t = this._j, c = 0, s = 0; s < 4; s++) { + t = (t + r[e = (e + 1) % 256]) % 256; + var u = r[e]; + r[e] = r[t], r[t] = u, c |= r[(r[e] + r[t]) % 256] << 24 - 8 * s; + } + return this._i = e, this._j = t, c; + } + d.RC4 = o._createHelper(a); + var n = f.RC4Drop = a.extend({ cfg: a.cfg.extend({ drop: 192 }), _doReset: function() { + a._doReset.call(this); + for (var r = this.cfg.drop; r > 0; r--) i.call(this); + } }); + d.RC4Drop = o._createHelper(n); + })(), h.RC4); + }, 8056(N, O, E) { + var h; + N.exports = (h = E(9021), (function() { + var d = h, o = d.lib, f = o.WordArray, a = o.Hasher, i = d.algo, n = f.create([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]), r = f.create([5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]), e = f.create([11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6]), t = f.create([8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11]), c = f.create([0, 1518500249, 1859775393, 2400959708, 2840853838]), s = f.create([1352829926, 1548603684, 1836072691, 2053994217, 0]), u = i.RIPEMD160 = a.extend({ _doReset: function() { + this._hash = f.create([1732584193, 4023233417, 2562383102, 271733878, 3285377520]); + }, _doProcessBlock: function(T, b) { + for (var A = 0; A < 16; A++) { + var m = b + A, I = T[m]; + T[m] = 16711935 & (I << 8 | I >>> 24) | 4278255360 & (I << 24 | I >>> 8); + } + var P, x, F, K, Y, Q, S, M, j, H, Z, L = this._hash.words, w = c.words, C = s.words, R = n.words, B = r.words, D = e.words, U = t.words; + for (Q = P = L[0], S = x = L[1], M = F = L[2], j = K = L[3], H = Y = L[4], A = 0; A < 80; A += 1) Z = P + T[b + R[A]] | 0, Z += A < 16 ? p(x, F, K) + w[0] : A < 32 ? l(x, F, K) + w[1] : A < 48 ? v(x, F, K) + w[2] : A < 64 ? y(x, F, K) + w[3] : g(x, F, K) + w[4], Z = (Z = _(Z |= 0, D[A])) + Y | 0, P = Y, Y = K, K = _(F, 10), F = x, x = Z, Z = Q + T[b + B[A]] | 0, Z += A < 16 ? g(S, M, j) + C[0] : A < 32 ? y(S, M, j) + C[1] : A < 48 ? v(S, M, j) + C[2] : A < 64 ? l(S, M, j) + C[3] : p(S, M, j) + C[4], Z = (Z = _(Z |= 0, U[A])) + H | 0, Q = H, H = j, j = _(M, 10), M = S, S = Z; + Z = L[1] + F + j | 0, L[1] = L[2] + K + H | 0, L[2] = L[3] + Y + Q | 0, L[3] = L[4] + P + S | 0, L[4] = L[0] + x + M | 0, L[0] = Z; + }, _doFinalize: function() { + var T = this._data, b = T.words, A = 8 * this._nDataBytes, m = 8 * T.sigBytes; + b[m >>> 5] |= 128 << 24 - m % 32, b[14 + (m + 64 >>> 9 << 4)] = 16711935 & (A << 8 | A >>> 24) | 4278255360 & (A << 24 | A >>> 8), T.sigBytes = 4 * (b.length + 1), this._process(); + for (var I = this._hash, P = I.words, x = 0; x < 5; x++) { + var F = P[x]; + P[x] = 16711935 & (F << 8 | F >>> 24) | 4278255360 & (F << 24 | F >>> 8); + } + return I; + }, clone: function() { + var T = a.clone.call(this); + return T._hash = this._hash.clone(), T; + } }); + function p(T, b, A) { + return T ^ b ^ A; + } + function l(T, b, A) { + return T & b | ~T & A; + } + function v(T, b, A) { + return (T | ~b) ^ A; + } + function y(T, b, A) { + return T & A | b & ~A; + } + function g(T, b, A) { + return T ^ (b | ~A); + } + function _(T, b) { + return T << b | T >>> 32 - b; + } + d.RIPEMD160 = a._createHelper(u), d.HmacRIPEMD160 = a._createHmacHelper(u); + })(), h.RIPEMD160); + }, 5471(N, O, E) { + var h, d, o, f, a, i, n, r; + N.exports = (d = (h = r = E(9021)).lib, o = d.WordArray, f = d.Hasher, a = h.algo, i = [], n = a.SHA1 = f.extend({ _doReset: function() { + this._hash = new o.init([1732584193, 4023233417, 2562383102, 271733878, 3285377520]); + }, _doProcessBlock: function(e, t) { + for (var c = this._hash.words, s = c[0], u = c[1], p = c[2], l = c[3], v = c[4], y = 0; y < 80; y++) { + if (y < 16) i[y] = 0 | e[t + y]; + else { + var g = i[y - 3] ^ i[y - 8] ^ i[y - 14] ^ i[y - 16]; + i[y] = g << 1 | g >>> 31; + } + var _ = (s << 5 | s >>> 27) + v + i[y]; + _ += y < 20 ? 1518500249 + (u & p | ~u & l) : y < 40 ? 1859775393 + (u ^ p ^ l) : y < 60 ? (u & p | u & l | p & l) - 1894007588 : (u ^ p ^ l) - 899497514, v = l, l = p, p = u << 30 | u >>> 2, u = s, s = _; + } + c[0] = c[0] + s | 0, c[1] = c[1] + u | 0, c[2] = c[2] + p | 0, c[3] = c[3] + l | 0, c[4] = c[4] + v | 0; + }, _doFinalize: function() { + var e = this._data, t = e.words, c = 8 * this._nDataBytes, s = 8 * e.sigBytes; + return t[s >>> 5] |= 128 << 24 - s % 32, t[14 + (s + 64 >>> 9 << 4)] = Math.floor(c / 4294967296), t[15 + (s + 64 >>> 9 << 4)] = c, e.sigBytes = 4 * t.length, this._process(), this._hash; + }, clone: function() { + var e = f.clone.call(this); + return e._hash = this._hash.clone(), e; + } }), h.SHA1 = f._createHelper(n), h.HmacSHA1 = f._createHmacHelper(n), r.SHA1); + }, 6308(N, O, E) { + var h, d, o, f, a, i; + N.exports = (i = E(9021), E(3009), d = (h = i).lib.WordArray, o = h.algo, f = o.SHA256, a = o.SHA224 = f.extend({ _doReset: function() { + this._hash = new d.init([3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428]); + }, _doFinalize: function() { + var n = f._doFinalize.call(this); + return n.sigBytes -= 4, n; + } }), h.SHA224 = f._createHelper(a), h.HmacSHA224 = f._createHmacHelper(a), i.SHA224); + }, 3009(N, O, E) { + var h; + N.exports = (h = E(9021), (function(d) { + var o = h, f = o.lib, a = f.WordArray, i = f.Hasher, n = o.algo, r = [], e = []; + (function() { + function s(v) { + for (var y = d.sqrt(v), g = 2; g <= y; g++) if (!(v % g)) return !1; + return !0; + } + function u(v) { + return 4294967296 * (v - (0 | v)) | 0; + } + for (var p = 2, l = 0; l < 64; ) s(p) && (l < 8 && (r[l] = u(d.pow(p, 0.5))), e[l] = u(d.pow(p, 0.3333333333333333)), l++), p++; + })(); + var t = [], c = n.SHA256 = i.extend({ _doReset: function() { + this._hash = new a.init(r.slice(0)); + }, _doProcessBlock: function(s, u) { + for (var p = this._hash.words, l = p[0], v = p[1], y = p[2], g = p[3], _ = p[4], T = p[5], b = p[6], A = p[7], m = 0; m < 64; m++) { + if (m < 16) t[m] = 0 | s[u + m]; + else { + var I = t[m - 15], P = (I << 25 | I >>> 7) ^ (I << 14 | I >>> 18) ^ I >>> 3, x = t[m - 2], F = (x << 15 | x >>> 17) ^ (x << 13 | x >>> 19) ^ x >>> 10; + t[m] = P + t[m - 7] + F + t[m - 16]; + } + var K = l & v ^ l & y ^ v & y, Y = (l << 30 | l >>> 2) ^ (l << 19 | l >>> 13) ^ (l << 10 | l >>> 22), Q = A + ((_ << 26 | _ >>> 6) ^ (_ << 21 | _ >>> 11) ^ (_ << 7 | _ >>> 25)) + (_ & T ^ ~_ & b) + e[m] + t[m]; + A = b, b = T, T = _, _ = g + Q | 0, g = y, y = v, v = l, l = Q + (Y + K) | 0; + } + p[0] = p[0] + l | 0, p[1] = p[1] + v | 0, p[2] = p[2] + y | 0, p[3] = p[3] + g | 0, p[4] = p[4] + _ | 0, p[5] = p[5] + T | 0, p[6] = p[6] + b | 0, p[7] = p[7] + A | 0; + }, _doFinalize: function() { + var s = this._data, u = s.words, p = 8 * this._nDataBytes, l = 8 * s.sigBytes; + return u[l >>> 5] |= 128 << 24 - l % 32, u[14 + (l + 64 >>> 9 << 4)] = d.floor(p / 4294967296), u[15 + (l + 64 >>> 9 << 4)] = p, s.sigBytes = 4 * u.length, this._process(), this._hash; + }, clone: function() { + var s = i.clone.call(this); + return s._hash = this._hash.clone(), s; + } }); + o.SHA256 = i._createHelper(c), o.HmacSHA256 = i._createHmacHelper(c); + })(Math), h.SHA256); + }, 5953(N, O, E) { + var h; + N.exports = (h = E(9021), E(3240), (function(d) { + var o = h, f = o.lib, a = f.WordArray, i = f.Hasher, n = o.x64.Word, r = o.algo, e = [], t = [], c = []; + (function() { + for (var p = 1, l = 0, v = 0; v < 24; v++) { + e[p + 5 * l] = (v + 1) * (v + 2) / 2 % 64; + var y = (2 * p + 3 * l) % 5; + p = l % 5, l = y; + } + for (p = 0; p < 5; p++) for (l = 0; l < 5; l++) t[p + 5 * l] = l + (2 * p + 3 * l) % 5 * 5; + for (var g = 1, _ = 0; _ < 24; _++) { + for (var T = 0, b = 0, A = 0; A < 7; A++) { + if (1 & g) { + var m = (1 << A) - 1; + m < 32 ? b ^= 1 << m : T ^= 1 << m - 32; + } + 128 & g ? g = g << 1 ^ 113 : g <<= 1; + } + c[_] = n.create(T, b); + } + })(); + var s = []; + (function() { + for (var p = 0; p < 25; p++) s[p] = n.create(); + })(); + var u = r.SHA3 = i.extend({ cfg: i.cfg.extend({ outputLength: 512 }), _doReset: function() { + for (var p = this._state = [], l = 0; l < 25; l++) p[l] = new n.init(); + this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32; + }, _doProcessBlock: function(p, l) { + for (var v = this._state, y = this.blockSize / 2, g = 0; g < y; g++) { + var _ = p[l + 2 * g], T = p[l + 2 * g + 1]; + _ = 16711935 & (_ << 8 | _ >>> 24) | 4278255360 & (_ << 24 | _ >>> 8), T = 16711935 & (T << 8 | T >>> 24) | 4278255360 & (T << 24 | T >>> 8), (C = v[g]).high ^= T, C.low ^= _; + } + for (var b = 0; b < 24; b++) { + for (var A = 0; A < 5; A++) { + for (var m = 0, I = 0, P = 0; P < 5; P++) m ^= (C = v[A + 5 * P]).high, I ^= C.low; + var x = s[A]; + x.high = m, x.low = I; + } + for (A = 0; A < 5; A++) { + var F = s[(A + 4) % 5], K = s[(A + 1) % 5], Y = K.high, Q = K.low; + for (m = F.high ^ (Y << 1 | Q >>> 31), I = F.low ^ (Q << 1 | Y >>> 31), P = 0; P < 5; P++) (C = v[A + 5 * P]).high ^= m, C.low ^= I; + } + for (var S = 1; S < 25; S++) { + var M = (C = v[S]).high, j = C.low, H = e[S]; + H < 32 ? (m = M << H | j >>> 32 - H, I = j << H | M >>> 32 - H) : (m = j << H - 32 | M >>> 64 - H, I = M << H - 32 | j >>> 64 - H); + var Z = s[t[S]]; + Z.high = m, Z.low = I; + } + var L = s[0], w = v[0]; + for (L.high = w.high, L.low = w.low, A = 0; A < 5; A++) for (P = 0; P < 5; P++) { + var C = v[S = A + 5 * P], R = s[S], B = s[(A + 1) % 5 + 5 * P], D = s[(A + 2) % 5 + 5 * P]; + C.high = R.high ^ ~B.high & D.high, C.low = R.low ^ ~B.low & D.low; + } + C = v[0]; + var U = c[b]; + C.high ^= U.high, C.low ^= U.low; + } + }, _doFinalize: function() { + var p = this._data, l = p.words, v = (this._nDataBytes, 8 * p.sigBytes), y = 32 * this.blockSize; + l[v >>> 5] |= 1 << 24 - v % 32, l[(d.ceil((v + 1) / y) * y >>> 5) - 1] |= 128, p.sigBytes = 4 * l.length, this._process(); + for (var g = this._state, _ = this.cfg.outputLength / 8, T = _ / 8, b = [], A = 0; A < T; A++) { + var m = g[A], I = m.high, P = m.low; + I = 16711935 & (I << 8 | I >>> 24) | 4278255360 & (I << 24 | I >>> 8), P = 16711935 & (P << 8 | P >>> 24) | 4278255360 & (P << 24 | P >>> 8), b.push(P), b.push(I); + } + return new a.init(b, _); + }, clone: function() { + for (var p = i.clone.call(this), l = p._state = this._state.slice(0), v = 0; v < 25; v++) l[v] = l[v].clone(); + return p; + } }); + o.SHA3 = i._createHelper(u), o.HmacSHA3 = i._createHmacHelper(u); + })(Math), h.SHA3); + }, 9557(N, O, E) { + var h, d, o, f, a, i, n, r; + N.exports = (r = E(9021), E(3240), E(1380), d = (h = r).x64, o = d.Word, f = d.WordArray, a = h.algo, i = a.SHA512, n = a.SHA384 = i.extend({ _doReset: function() { + this._hash = new f.init([new o.init(3418070365, 3238371032), new o.init(1654270250, 914150663), new o.init(2438529370, 812702999), new o.init(355462360, 4144912697), new o.init(1731405415, 4290775857), new o.init(2394180231, 1750603025), new o.init(3675008525, 1694076839), new o.init(1203062813, 3204075428)]); + }, _doFinalize: function() { + var e = i._doFinalize.call(this); + return e.sigBytes -= 16, e; + } }), h.SHA384 = i._createHelper(n), h.HmacSHA384 = i._createHmacHelper(n), r.SHA384); + }, 1380(N, O, E) { + var h; + N.exports = (h = E(9021), E(3240), (function() { + var d = h, o = d.lib.Hasher, f = d.x64, a = f.Word, i = f.WordArray, n = d.algo; + function r() { + return a.create.apply(a, arguments); + } + var e = [r(1116352408, 3609767458), r(1899447441, 602891725), r(3049323471, 3964484399), r(3921009573, 2173295548), r(961987163, 4081628472), r(1508970993, 3053834265), r(2453635748, 2937671579), r(2870763221, 3664609560), r(3624381080, 2734883394), r(310598401, 1164996542), r(607225278, 1323610764), r(1426881987, 3590304994), r(1925078388, 4068182383), r(2162078206, 991336113), r(2614888103, 633803317), r(3248222580, 3479774868), r(3835390401, 2666613458), r(4022224774, 944711139), r(264347078, 2341262773), r(604807628, 2007800933), r(770255983, 1495990901), r(1249150122, 1856431235), r(1555081692, 3175218132), r(1996064986, 2198950837), r(2554220882, 3999719339), r(2821834349, 766784016), r(2952996808, 2566594879), r(3210313671, 3203337956), r(3336571891, 1034457026), r(3584528711, 2466948901), r(113926993, 3758326383), r(338241895, 168717936), r(666307205, 1188179964), r(773529912, 1546045734), r(1294757372, 1522805485), r(1396182291, 2643833823), r(1695183700, 2343527390), r(1986661051, 1014477480), r(2177026350, 1206759142), r(2456956037, 344077627), r(2730485921, 1290863460), r(2820302411, 3158454273), r(3259730800, 3505952657), r(3345764771, 106217008), r(3516065817, 3606008344), r(3600352804, 1432725776), r(4094571909, 1467031594), r(275423344, 851169720), r(430227734, 3100823752), r(506948616, 1363258195), r(659060556, 3750685593), r(883997877, 3785050280), r(958139571, 3318307427), r(1322822218, 3812723403), r(1537002063, 2003034995), r(1747873779, 3602036899), r(1955562222, 1575990012), r(2024104815, 1125592928), r(2227730452, 2716904306), r(2361852424, 442776044), r(2428436474, 593698344), r(2756734187, 3733110249), r(3204031479, 2999351573), r(3329325298, 3815920427), r(3391569614, 3928383900), r(3515267271, 566280711), r(3940187606, 3454069534), r(4118630271, 4000239992), r(116418474, 1914138554), r(174292421, 2731055270), r(289380356, 3203993006), r(460393269, 320620315), r(685471733, 587496836), r(852142971, 1086792851), r(1017036298, 365543100), r(1126000580, 2618297676), r(1288033470, 3409855158), r(1501505948, 4234509866), r(1607167915, 987167468), r(1816402316, 1246189591)], t = []; + (function() { + for (var s = 0; s < 80; s++) t[s] = r(); + })(); + var c = n.SHA512 = o.extend({ _doReset: function() { + this._hash = new i.init([new a.init(1779033703, 4089235720), new a.init(3144134277, 2227873595), new a.init(1013904242, 4271175723), new a.init(2773480762, 1595750129), new a.init(1359893119, 2917565137), new a.init(2600822924, 725511199), new a.init(528734635, 4215389547), new a.init(1541459225, 327033209)]); + }, _doProcessBlock: function(s, u) { + for (var p = this._hash.words, l = p[0], v = p[1], y = p[2], g = p[3], _ = p[4], T = p[5], b = p[6], A = p[7], m = l.high, I = l.low, P = v.high, x = v.low, F = y.high, K = y.low, Y = g.high, Q = g.low, S = _.high, M = _.low, j = T.high, H = T.low, Z = b.high, L = b.low, w = A.high, C = A.low, R = m, B = I, D = P, U = x, k = F, G = K, V = Y, W = Q, z = S, q = M, $ = j, te = H, re = Z, ie = L, ue = w, ne = C, X = 0; X < 80; X++) { + var ee, J, ce = t[X]; + if (X < 16) J = ce.high = 0 | s[u + 2 * X], ee = ce.low = 0 | s[u + 2 * X + 1]; + else { + var _e = t[X - 15], pe = _e.high, ye = _e.low, Te = (pe >>> 1 | ye << 31) ^ (pe >>> 8 | ye << 24) ^ pe >>> 7, ae = (ye >>> 1 | pe << 31) ^ (ye >>> 8 | pe << 24) ^ (ye >>> 7 | pe << 25), le = t[X - 2], ve = le.high, Oe = le.low, se = (ve >>> 19 | Oe << 13) ^ (ve << 3 | Oe >>> 29) ^ ve >>> 6, de = (Oe >>> 19 | ve << 13) ^ (Oe << 3 | ve >>> 29) ^ (Oe >>> 6 | ve << 26), fe = t[X - 7], ge = fe.high, oe = fe.low, Ee = t[X - 16], Se = Ee.high, be = Ee.low; + J = (J = (J = Te + ge + ((ee = ae + oe) >>> 0 < ae >>> 0 ? 1 : 0)) + se + ((ee += de) >>> 0 < de >>> 0 ? 1 : 0)) + Se + ((ee += be) >>> 0 < be >>> 0 ? 1 : 0), ce.high = J, ce.low = ee; + } + var he, Re = z & $ ^ ~z & re, Ne = q & te ^ ~q & ie, Le = R & D ^ R & k ^ D & k, Pe = B & U ^ B & G ^ U & G, Me = (R >>> 28 | B << 4) ^ (R << 30 | B >>> 2) ^ (R << 25 | B >>> 7), me = (B >>> 28 | R << 4) ^ (B << 30 | R >>> 2) ^ (B << 25 | R >>> 7), De = (z >>> 14 | q << 18) ^ (z >>> 18 | q << 14) ^ (z << 23 | q >>> 9), Ke = (q >>> 14 | z << 18) ^ (q >>> 18 | z << 14) ^ (q << 23 | z >>> 9), xe = e[X], Ve = xe.high, ke = xe.low, Ue = ue + De + ((he = ne + Ke) >>> 0 < ne >>> 0 ? 1 : 0), Be = me + Pe; + ue = re, ne = ie, re = $, ie = te, $ = z, te = q, z = V + (Ue = (Ue = (Ue = Ue + Re + ((he += Ne) >>> 0 < Ne >>> 0 ? 1 : 0)) + Ve + ((he += ke) >>> 0 < ke >>> 0 ? 1 : 0)) + J + ((he += ee) >>> 0 < ee >>> 0 ? 1 : 0)) + ((q = W + he | 0) >>> 0 < W >>> 0 ? 1 : 0) | 0, V = k, W = G, k = D, G = U, D = R, U = B, R = Ue + (Me + Le + (Be >>> 0 < me >>> 0 ? 1 : 0)) + ((B = he + Be | 0) >>> 0 < he >>> 0 ? 1 : 0) | 0; + } + I = l.low = I + B, l.high = m + R + (I >>> 0 < B >>> 0 ? 1 : 0), x = v.low = x + U, v.high = P + D + (x >>> 0 < U >>> 0 ? 1 : 0), K = y.low = K + G, y.high = F + k + (K >>> 0 < G >>> 0 ? 1 : 0), Q = g.low = Q + W, g.high = Y + V + (Q >>> 0 < W >>> 0 ? 1 : 0), M = _.low = M + q, _.high = S + z + (M >>> 0 < q >>> 0 ? 1 : 0), H = T.low = H + te, T.high = j + $ + (H >>> 0 < te >>> 0 ? 1 : 0), L = b.low = L + ie, b.high = Z + re + (L >>> 0 < ie >>> 0 ? 1 : 0), C = A.low = C + ne, A.high = w + ue + (C >>> 0 < ne >>> 0 ? 1 : 0); + }, _doFinalize: function() { + var s = this._data, u = s.words, p = 8 * this._nDataBytes, l = 8 * s.sigBytes; + return u[l >>> 5] |= 128 << 24 - l % 32, u[30 + (l + 128 >>> 10 << 5)] = Math.floor(p / 4294967296), u[31 + (l + 128 >>> 10 << 5)] = p, s.sigBytes = 4 * u.length, this._process(), this._hash.toX32(); + }, clone: function() { + var s = o.clone.call(this); + return s._hash = this._hash.clone(), s; + }, blockSize: 32 }); + d.SHA512 = o._createHelper(c), d.HmacSHA512 = o._createHmacHelper(c); + })(), h.SHA512); + }, 7628(N, O, E) { + var h; + N.exports = (h = E(9021), E(754), E(4636), E(9506), E(7165), (function() { + var d = h, o = d.lib, f = o.WordArray, a = o.BlockCipher, i = d.algo, n = [57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4], r = [14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32], e = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28], t = [{ 0: 8421888, 268435456: 32768, 536870912: 8421378, 805306368: 2, 1073741824: 512, 1342177280: 8421890, 1610612736: 8389122, 1879048192: 8388608, 2147483648: 514, 2415919104: 8389120, 2684354560: 33280, 2952790016: 8421376, 3221225472: 32770, 3489660928: 8388610, 3758096384: 0, 4026531840: 33282, 134217728: 0, 402653184: 8421890, 671088640: 33282, 939524096: 32768, 1207959552: 8421888, 1476395008: 512, 1744830464: 8421378, 2013265920: 2, 2281701376: 8389120, 2550136832: 33280, 2818572288: 8421376, 3087007744: 8389122, 3355443200: 8388610, 3623878656: 32770, 3892314112: 514, 4160749568: 8388608, 1: 32768, 268435457: 2, 536870913: 8421888, 805306369: 8388608, 1073741825: 8421378, 1342177281: 33280, 1610612737: 512, 1879048193: 8389122, 2147483649: 8421890, 2415919105: 8421376, 2684354561: 8388610, 2952790017: 33282, 3221225473: 514, 3489660929: 8389120, 3758096385: 32770, 4026531841: 0, 134217729: 8421890, 402653185: 8421376, 671088641: 8388608, 939524097: 512, 1207959553: 32768, 1476395009: 8388610, 1744830465: 2, 2013265921: 33282, 2281701377: 32770, 2550136833: 8389122, 2818572289: 514, 3087007745: 8421888, 3355443201: 8389120, 3623878657: 0, 3892314113: 33280, 4160749569: 8421378 }, { 0: 1074282512, 16777216: 16384, 33554432: 524288, 50331648: 1074266128, 67108864: 1073741840, 83886080: 1074282496, 100663296: 1073758208, 117440512: 16, 134217728: 540672, 150994944: 1073758224, 167772160: 1073741824, 184549376: 540688, 201326592: 524304, 218103808: 0, 234881024: 16400, 251658240: 1074266112, 8388608: 1073758208, 25165824: 540688, 41943040: 16, 58720256: 1073758224, 75497472: 1074282512, 92274688: 1073741824, 109051904: 524288, 125829120: 1074266128, 142606336: 524304, 159383552: 0, 176160768: 16384, 192937984: 1074266112, 209715200: 1073741840, 226492416: 540672, 243269632: 1074282496, 260046848: 16400, 268435456: 0, 285212672: 1074266128, 301989888: 1073758224, 318767104: 1074282496, 335544320: 1074266112, 352321536: 16, 369098752: 540688, 385875968: 16384, 402653184: 16400, 419430400: 524288, 436207616: 524304, 452984832: 1073741840, 469762048: 540672, 486539264: 1073758208, 503316480: 1073741824, 520093696: 1074282512, 276824064: 540688, 293601280: 524288, 310378496: 1074266112, 327155712: 16384, 343932928: 1073758208, 360710144: 1074282512, 377487360: 16, 394264576: 1073741824, 411041792: 1074282496, 427819008: 1073741840, 444596224: 1073758224, 461373440: 524304, 478150656: 0, 494927872: 16400, 511705088: 1074266128, 528482304: 540672 }, { 0: 260, 1048576: 0, 2097152: 67109120, 3145728: 65796, 4194304: 65540, 5242880: 67108868, 6291456: 67174660, 7340032: 67174400, 8388608: 67108864, 9437184: 67174656, 10485760: 65792, 11534336: 67174404, 12582912: 67109124, 13631488: 65536, 14680064: 4, 15728640: 256, 524288: 67174656, 1572864: 67174404, 2621440: 0, 3670016: 67109120, 4718592: 67108868, 5767168: 65536, 6815744: 65540, 7864320: 260, 8912896: 4, 9961472: 256, 11010048: 67174400, 12058624: 65796, 13107200: 65792, 14155776: 67109124, 15204352: 67174660, 16252928: 67108864, 16777216: 67174656, 17825792: 65540, 18874368: 65536, 19922944: 67109120, 20971520: 256, 22020096: 67174660, 23068672: 67108868, 24117248: 0, 25165824: 67109124, 26214400: 67108864, 27262976: 4, 28311552: 65792, 29360128: 67174400, 30408704: 260, 31457280: 65796, 32505856: 67174404, 17301504: 67108864, 18350080: 260, 19398656: 67174656, 20447232: 0, 21495808: 65540, 22544384: 67109120, 23592960: 256, 24641536: 67174404, 25690112: 65536, 26738688: 67174660, 27787264: 65796, 28835840: 67108868, 29884416: 67109124, 30932992: 67174400, 31981568: 4, 33030144: 65792 }, { 0: 2151682048, 65536: 2147487808, 131072: 4198464, 196608: 2151677952, 262144: 0, 327680: 4198400, 393216: 2147483712, 458752: 4194368, 524288: 2147483648, 589824: 4194304, 655360: 64, 720896: 2147487744, 786432: 2151678016, 851968: 4160, 917504: 4096, 983040: 2151682112, 32768: 2147487808, 98304: 64, 163840: 2151678016, 229376: 2147487744, 294912: 4198400, 360448: 2151682112, 425984: 0, 491520: 2151677952, 557056: 4096, 622592: 2151682048, 688128: 4194304, 753664: 4160, 819200: 2147483648, 884736: 4194368, 950272: 4198464, 1015808: 2147483712, 1048576: 4194368, 1114112: 4198400, 1179648: 2147483712, 1245184: 0, 1310720: 4160, 1376256: 2151678016, 1441792: 2151682048, 1507328: 2147487808, 1572864: 2151682112, 1638400: 2147483648, 1703936: 2151677952, 1769472: 4198464, 1835008: 2147487744, 1900544: 4194304, 1966080: 64, 2031616: 4096, 1081344: 2151677952, 1146880: 2151682112, 1212416: 0, 1277952: 4198400, 1343488: 4194368, 1409024: 2147483648, 1474560: 2147487808, 1540096: 64, 1605632: 2147483712, 1671168: 4096, 1736704: 2147487744, 1802240: 2151678016, 1867776: 4160, 1933312: 2151682048, 1998848: 4194304, 2064384: 4198464 }, { 0: 128, 4096: 17039360, 8192: 262144, 12288: 536870912, 16384: 537133184, 20480: 16777344, 24576: 553648256, 28672: 262272, 32768: 16777216, 36864: 537133056, 40960: 536871040, 45056: 553910400, 49152: 553910272, 53248: 0, 57344: 17039488, 61440: 553648128, 2048: 17039488, 6144: 553648256, 10240: 128, 14336: 17039360, 18432: 262144, 22528: 537133184, 26624: 553910272, 30720: 536870912, 34816: 537133056, 38912: 0, 43008: 553910400, 47104: 16777344, 51200: 536871040, 55296: 553648128, 59392: 16777216, 63488: 262272, 65536: 262144, 69632: 128, 73728: 536870912, 77824: 553648256, 81920: 16777344, 86016: 553910272, 90112: 537133184, 94208: 16777216, 98304: 553910400, 102400: 553648128, 106496: 17039360, 110592: 537133056, 114688: 262272, 118784: 536871040, 122880: 0, 126976: 17039488, 67584: 553648256, 71680: 16777216, 75776: 17039360, 79872: 537133184, 83968: 536870912, 88064: 17039488, 92160: 128, 96256: 553910272, 100352: 262272, 104448: 553910400, 108544: 0, 112640: 553648128, 116736: 16777344, 120832: 262144, 124928: 537133056, 129024: 536871040 }, { 0: 268435464, 256: 8192, 512: 270532608, 768: 270540808, 1024: 268443648, 1280: 2097152, 1536: 2097160, 1792: 268435456, 2048: 0, 2304: 268443656, 2560: 2105344, 2816: 8, 3072: 270532616, 3328: 2105352, 3584: 8200, 3840: 270540800, 128: 270532608, 384: 270540808, 640: 8, 896: 2097152, 1152: 2105352, 1408: 268435464, 1664: 268443648, 1920: 8200, 2176: 2097160, 2432: 8192, 2688: 268443656, 2944: 270532616, 3200: 0, 3456: 270540800, 3712: 2105344, 3968: 268435456, 4096: 268443648, 4352: 270532616, 4608: 270540808, 4864: 8200, 5120: 2097152, 5376: 268435456, 5632: 268435464, 5888: 2105344, 6144: 2105352, 6400: 0, 6656: 8, 6912: 270532608, 7168: 8192, 7424: 268443656, 7680: 270540800, 7936: 2097160, 4224: 8, 4480: 2105344, 4736: 2097152, 4992: 268435464, 5248: 268443648, 5504: 8200, 5760: 270540808, 6016: 270532608, 6272: 270540800, 6528: 270532616, 6784: 8192, 7040: 2105352, 7296: 2097160, 7552: 0, 7808: 268435456, 8064: 268443656 }, { 0: 1048576, 16: 33555457, 32: 1024, 48: 1049601, 64: 34604033, 80: 0, 96: 1, 112: 34603009, 128: 33555456, 144: 1048577, 160: 33554433, 176: 34604032, 192: 34603008, 208: 1025, 224: 1049600, 240: 33554432, 8: 34603009, 24: 0, 40: 33555457, 56: 34604032, 72: 1048576, 88: 33554433, 104: 33554432, 120: 1025, 136: 1049601, 152: 33555456, 168: 34603008, 184: 1048577, 200: 1024, 216: 34604033, 232: 1, 248: 1049600, 256: 33554432, 272: 1048576, 288: 33555457, 304: 34603009, 320: 1048577, 336: 33555456, 352: 34604032, 368: 1049601, 384: 1025, 400: 34604033, 416: 1049600, 432: 1, 448: 0, 464: 34603008, 480: 33554433, 496: 1024, 264: 1049600, 280: 33555457, 296: 34603009, 312: 1, 328: 33554432, 344: 1048576, 360: 1025, 376: 34604032, 392: 33554433, 408: 34603008, 424: 0, 440: 34604033, 456: 1049601, 472: 1024, 488: 33555456, 504: 1048577 }, { 0: 134219808, 1: 131072, 2: 134217728, 3: 32, 4: 131104, 5: 134350880, 6: 134350848, 7: 2048, 8: 134348800, 9: 134219776, 10: 133120, 11: 134348832, 12: 2080, 13: 0, 14: 134217760, 15: 133152, 2147483648: 2048, 2147483649: 134350880, 2147483650: 134219808, 2147483651: 134217728, 2147483652: 134348800, 2147483653: 133120, 2147483654: 133152, 2147483655: 32, 2147483656: 134217760, 2147483657: 2080, 2147483658: 131104, 2147483659: 134350848, 2147483660: 0, 2147483661: 134348832, 2147483662: 134219776, 2147483663: 131072, 16: 133152, 17: 134350848, 18: 32, 19: 2048, 20: 134219776, 21: 134217760, 22: 134348832, 23: 131072, 24: 0, 25: 131104, 26: 134348800, 27: 134219808, 28: 134350880, 29: 133120, 30: 2080, 31: 134217728, 2147483664: 131072, 2147483665: 2048, 2147483666: 134348832, 2147483667: 133152, 2147483668: 32, 2147483669: 134348800, 2147483670: 134217728, 2147483671: 134219808, 2147483672: 134350880, 2147483673: 134217760, 2147483674: 134219776, 2147483675: 0, 2147483676: 133120, 2147483677: 2080, 2147483678: 131104, 2147483679: 134350848 }], c = [4160749569, 528482304, 33030144, 2064384, 129024, 8064, 504, 2147483679], s = i.DES = a.extend({ _doReset: function() { + for (var v = this._key.words, y = [], g = 0; g < 56; g++) { + var _ = n[g] - 1; + y[g] = v[_ >>> 5] >>> 31 - _ % 32 & 1; + } + for (var T = this._subKeys = [], b = 0; b < 16; b++) { + var A = T[b] = [], m = e[b]; + for (g = 0; g < 24; g++) A[g / 6 | 0] |= y[(r[g] - 1 + m) % 28] << 31 - g % 6, A[4 + (g / 6 | 0)] |= y[28 + (r[g + 24] - 1 + m) % 28] << 31 - g % 6; + for (A[0] = A[0] << 1 | A[0] >>> 31, g = 1; g < 7; g++) A[g] = A[g] >>> 4 * (g - 1) + 3; + A[7] = A[7] << 5 | A[7] >>> 27; + } + var I = this._invSubKeys = []; + for (g = 0; g < 16; g++) I[g] = T[15 - g]; + }, encryptBlock: function(v, y) { + this._doCryptBlock(v, y, this._subKeys); + }, decryptBlock: function(v, y) { + this._doCryptBlock(v, y, this._invSubKeys); + }, _doCryptBlock: function(v, y, g) { + this._lBlock = v[y], this._rBlock = v[y + 1], u.call(this, 4, 252645135), u.call(this, 16, 65535), p.call(this, 2, 858993459), p.call(this, 8, 16711935), u.call(this, 1, 1431655765); + for (var _ = 0; _ < 16; _++) { + for (var T = g[_], b = this._lBlock, A = this._rBlock, m = 0, I = 0; I < 8; I++) m |= t[I][((A ^ T[I]) & c[I]) >>> 0]; + this._lBlock = A, this._rBlock = b ^ m; + } + var P = this._lBlock; + this._lBlock = this._rBlock, this._rBlock = P, u.call(this, 1, 1431655765), p.call(this, 8, 16711935), p.call(this, 2, 858993459), u.call(this, 16, 65535), u.call(this, 4, 252645135), v[y] = this._lBlock, v[y + 1] = this._rBlock; + }, keySize: 2, ivSize: 2, blockSize: 2 }); + function u(v, y) { + var g = (this._lBlock >>> v ^ this._rBlock) & y; + this._rBlock ^= g, this._lBlock ^= g << v; + } + function p(v, y) { + var g = (this._rBlock >>> v ^ this._lBlock) & y; + this._lBlock ^= g, this._rBlock ^= g << v; + } + d.DES = a._createHelper(s); + var l = i.TripleDES = a.extend({ _doReset: function() { + var v = this._key.words; + if (v.length !== 2 && v.length !== 4 && v.length < 6) throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192."); + var y = v.slice(0, 2), g = v.length < 4 ? v.slice(0, 2) : v.slice(2, 4), _ = v.length < 6 ? v.slice(0, 2) : v.slice(4, 6); + this._des1 = s.createEncryptor(f.create(y)), this._des2 = s.createEncryptor(f.create(g)), this._des3 = s.createEncryptor(f.create(_)); + }, encryptBlock: function(v, y) { + this._des1.encryptBlock(v, y), this._des2.decryptBlock(v, y), this._des3.encryptBlock(v, y); + }, decryptBlock: function(v, y) { + this._des3.decryptBlock(v, y), this._des2.encryptBlock(v, y), this._des1.decryptBlock(v, y); + }, keySize: 6, ivSize: 2, blockSize: 2 }); + d.TripleDES = a._createHelper(l); + })(), h.TripleDES); + }, 3240(N, O, E) { + var h, d, o, f, a, i; + N.exports = (h = E(9021), o = (d = h).lib, f = o.Base, a = o.WordArray, (i = d.x64 = {}).Word = f.extend({ init: function(n, r) { + this.high = n, this.low = r; + } }), i.WordArray = f.extend({ init: function(n, r) { + n = this.words = n || [], this.sigBytes = r ?? 8 * n.length; + }, toX32: function() { + for (var n = this.words, r = n.length, e = [], t = 0; t < r; t++) { + var c = n[t]; + e.push(c.high), e.push(c.low); + } + return a.create(e, this.sigBytes); + }, clone: function() { + for (var n = f.clone.call(this), r = n.words = this.words.slice(0), e = r.length, t = 0; t < e; t++) r[t] = r[t].clone(); + return n; + } }), h); + }, 7833(N, O, E) { + var h = E(6763), d = E(5606); + O.formatArgs = function(f) { + if (f[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + f[0] + (this.useColors ? "%c " : " ") + "+" + N.exports.humanize(this.diff), !this.useColors) return; + const a = "color: " + this.color; + f.splice(1, 0, a, "color: inherit"); + let i = 0, n = 0; + f[0].replace(/%[a-zA-Z%]/g, (r) => { + r !== "%%" && (i++, r === "%c" && (n = i)); + }), f.splice(n, 0, a); + }, O.save = function(f) { + try { + f ? O.storage.setItem("debug", f) : O.storage.removeItem("debug"); + } catch { + } + }, O.load = function() { + let f; + try { + f = O.storage.getItem("debug") || O.storage.getItem("DEBUG"); + } catch { + } + return !f && d !== void 0 && "env" in d && (f = d.env.DEBUG), f; + }, O.useColors = function() { + if (typeof window < "u" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) return !0; + if (typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) return !1; + let f; + return typeof document < "u" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window < "u" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator < "u" && navigator.userAgent && (f = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(f[1], 10) >= 31 || typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/); + }, O.storage = (function() { + try { + return localStorage; + } catch { + } + })(), O.destroy = /* @__PURE__ */ (() => { + let f = !1; + return () => { + f || (f = !0, h.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")); + }; + })(), O.colors = ["#0000CC", "#0000FF", "#0033CC", "#0033FF", "#0066CC", "#0066FF", "#0099CC", "#0099FF", "#00CC00", "#00CC33", "#00CC66", "#00CC99", "#00CCCC", "#00CCFF", "#3300CC", "#3300FF", "#3333CC", "#3333FF", "#3366CC", "#3366FF", "#3399CC", "#3399FF", "#33CC00", "#33CC33", "#33CC66", "#33CC99", "#33CCCC", "#33CCFF", "#6600CC", "#6600FF", "#6633CC", "#6633FF", "#66CC00", "#66CC33", "#9900CC", "#9900FF", "#9933CC", "#9933FF", "#99CC00", "#99CC33", "#CC0000", "#CC0033", "#CC0066", "#CC0099", "#CC00CC", "#CC00FF", "#CC3300", "#CC3333", "#CC3366", "#CC3399", "#CC33CC", "#CC33FF", "#CC6600", "#CC6633", "#CC9900", "#CC9933", "#CCCC00", "#CCCC33", "#FF0000", "#FF0033", "#FF0066", "#FF0099", "#FF00CC", "#FF00FF", "#FF3300", "#FF3333", "#FF3366", "#FF3399", "#FF33CC", "#FF33FF", "#FF6600", "#FF6633", "#FF9900", "#FF9933", "#FFCC00", "#FFCC33"], O.log = h.debug || h.log || (() => { + }), N.exports = E(736)(O); + const { formatters: o } = N.exports; + o.j = function(f) { + try { + return JSON.stringify(f); + } catch (a) { + return "[UnexpectedJSONParseError]: " + a.message; + } + }; + }, 736(N, O, E) { + var h = E(6763); + N.exports = function(d) { + function o(i) { + let n, r, e, t = null; + function c(...s) { + if (!c.enabled) return; + const u = c, p = Number(/* @__PURE__ */ new Date()), l = p - (n || p); + u.diff = l, u.prev = n, u.curr = p, n = p, s[0] = o.coerce(s[0]), typeof s[0] != "string" && s.unshift("%O"); + let v = 0; + s[0] = s[0].replace(/%([a-zA-Z%])/g, (y, g) => { + if (y === "%%") return "%"; + v++; + const _ = o.formatters[g]; + if (typeof _ == "function") { + const T = s[v]; + y = _.call(u, T), s.splice(v, 1), v--; + } + return y; + }), o.formatArgs.call(u, s), (u.log || o.log).apply(u, s); + } + return c.namespace = i, c.useColors = o.useColors(), c.color = o.selectColor(i), c.extend = f, c.destroy = o.destroy, Object.defineProperty(c, "enabled", { enumerable: !0, configurable: !1, get: () => t !== null ? t : (r !== o.namespaces && (r = o.namespaces, e = o.enabled(i)), e), set: (s) => { + t = s; + } }), typeof o.init == "function" && o.init(c), c; + } + function f(i, n) { + const r = o(this.namespace + (n === void 0 ? ":" : n) + i); + return r.log = this.log, r; + } + function a(i, n) { + let r = 0, e = 0, t = -1, c = 0; + for (; r < i.length; ) if (e < n.length && (n[e] === i[r] || n[e] === "*")) n[e] === "*" ? (t = e, c = r, e++) : (r++, e++); + else { + if (t === -1) return !1; + e = t + 1, c++, r = c; + } + for (; e < n.length && n[e] === "*"; ) e++; + return e === n.length; + } + return o.debug = o, o.default = o, o.coerce = function(i) { + return i instanceof Error ? i.stack || i.message : i; + }, o.disable = function() { + const i = [...o.names, ...o.skips.map((n) => "-" + n)].join(","); + return o.enable(""), i; + }, o.enable = function(i) { + o.save(i), o.namespaces = i, o.names = [], o.skips = []; + const n = (typeof i == "string" ? i : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean); + for (const r of n) r[0] === "-" ? o.skips.push(r.slice(1)) : o.names.push(r); + }, o.enabled = function(i) { + for (const n of o.skips) if (a(i, n)) return !1; + for (const n of o.names) if (a(i, n)) return !0; + return !1; + }, o.humanize = E(6585), o.destroy = function() { + h.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); + }, Object.keys(d).forEach((i) => { + o[i] = d[i]; + }), o.names = [], o.skips = [], o.formatters = {}, o.selectColor = function(i) { + let n = 0; + for (let r = 0; r < i.length; r++) n = (n << 5) - n + i.charCodeAt(r), n |= 0; + return o.colors[Math.abs(n) % o.colors.length]; + }, o.enable(o.load()), o; + }; + }, 41(N, O, E) { + var h = E(655), d = E(8068), o = E(9675), f = E(5795); + N.exports = function(a, i, n) { + if (!a || typeof a != "object" && typeof a != "function") throw new o("`obj` must be an object or a function`"); + if (typeof i != "string" && typeof i != "symbol") throw new o("`property` must be a string or a symbol`"); + if (arguments.length > 3 && typeof arguments[3] != "boolean" && arguments[3] !== null) throw new o("`nonEnumerable`, if provided, must be a boolean or null"); + if (arguments.length > 4 && typeof arguments[4] != "boolean" && arguments[4] !== null) throw new o("`nonWritable`, if provided, must be a boolean or null"); + if (arguments.length > 5 && typeof arguments[5] != "boolean" && arguments[5] !== null) throw new o("`nonConfigurable`, if provided, must be a boolean or null"); + if (arguments.length > 6 && typeof arguments[6] != "boolean") throw new o("`loose`, if provided, must be a boolean"); + var r = arguments.length > 3 ? arguments[3] : null, e = arguments.length > 4 ? arguments[4] : null, t = arguments.length > 5 ? arguments[5] : null, c = arguments.length > 6 && arguments[6], s = !!f && f(a, i); + if (h) h(a, i, { configurable: t === null && s ? s.configurable : !t, enumerable: r === null && s ? s.enumerable : !r, value: n, writable: e === null && s ? s.writable : !e }); + else { + if (!c && (r || e || t)) throw new d("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable."); + a[i] = n; + } + }; + }, 8452(N, O, E) { + var h = E(1189), d = typeof Symbol == "function" && typeof Symbol("foo") == "symbol", o = Object.prototype.toString, f = Array.prototype.concat, a = E(41), i = E(592)(), n = function(e, t, c, s) { + if (t in e) { + if (s === !0) { + if (e[t] === c) return; + } else if (typeof (u = s) != "function" || o.call(u) !== "[object Function]" || !s()) return; + } + var u; + i ? a(e, t, c, !0) : a(e, t, c); + }, r = function(e, t) { + var c = arguments.length > 2 ? arguments[2] : {}, s = h(t); + d && (s = f.call(s, Object.getOwnPropertySymbols(t))); + for (var u = 0; u < s.length; u += 1) n(e, s[u], t[s[u]], c[s[u]]); + }; + r.supportsDescriptors = !!i, N.exports = r; + }, 7176(N, O, E) { + var h, d = E(3126), o = E(5795); + try { + h = [].__proto__ === Array.prototype; + } catch (n) { + if (!n || typeof n != "object" || !("code" in n) || n.code !== "ERR_PROTO_ACCESS") throw n; + } + var f = !!h && o && o(Object.prototype, "__proto__"), a = Object, i = a.getPrototypeOf; + N.exports = f && typeof f.get == "function" ? d([f.get]) : typeof i == "function" && function(n) { + return i(n == null ? n : a(n)); + }; + }, 655(N) { + var O = Object.defineProperty || !1; + if (O) try { + O({}, "a", { value: 1 }); + } catch { + O = !1; + } + N.exports = O; + }, 1237(N) { + N.exports = EvalError; + }, 9383(N) { + N.exports = Error; + }, 9290(N) { + N.exports = RangeError; + }, 9538(N) { + N.exports = ReferenceError; + }, 8068(N) { + N.exports = SyntaxError; + }, 9675(N) { + N.exports = TypeError; + }, 5345(N) { + N.exports = URIError; + }, 9612(N) { + N.exports = Object; + }, 2682(N, O, E) { + var h = E(9600), d = Object.prototype.toString, o = Object.prototype.hasOwnProperty; + N.exports = function(f, a, i) { + if (!h(a)) throw new TypeError("iterator must be a function"); + var n, r; + arguments.length >= 3 && (n = i), r = f, d.call(r) === "[object Array]" ? (function(e, t, c) { + for (var s = 0, u = e.length; s < u; s++) o.call(e, s) && (c == null ? t(e[s], s, e) : t.call(c, e[s], s, e)); + })(f, a, n) : typeof f == "string" ? (function(e, t, c) { + for (var s = 0, u = e.length; s < u; s++) c == null ? t(e.charAt(s), s, e) : t.call(c, e.charAt(s), s, e); + })(f, a, n) : (function(e, t, c) { + for (var s in e) o.call(e, s) && (c == null ? t(e[s], s, e) : t.call(c, e[s], s, e)); + })(f, a, n); + }; + }, 9353(N) { + var O = Object.prototype.toString, E = Math.max, h = function(d, o) { + for (var f = [], a = 0; a < d.length; a += 1) f[a] = d[a]; + for (var i = 0; i < o.length; i += 1) f[i + d.length] = o[i]; + return f; + }; + N.exports = function(d) { + var o = this; + if (typeof o != "function" || O.apply(o) !== "[object Function]") throw new TypeError("Function.prototype.bind called on incompatible " + o); + for (var f, a = (function(t) { + for (var c = [], s = 1, u = 0; s < t.length; s += 1, u += 1) c[u] = t[s]; + return c; + })(arguments), i = E(0, o.length - a.length), n = [], r = 0; r < i; r++) n[r] = "$" + r; + if (f = Function("binder", "return function (" + (function(t) { + for (var c = "", s = 0; s < t.length; s += 1) c += t[s], s + 1 < t.length && (c += ","); + return c; + })(n) + "){ return binder.apply(this,arguments); }")(function() { + if (this instanceof f) { + var t = o.apply(this, h(a, arguments)); + return Object(t) === t ? t : this; + } + return o.apply(d, h(a, arguments)); + }), o.prototype) { + var e = function() { + }; + e.prototype = o.prototype, f.prototype = new e(), e.prototype = null; + } + return f; + }; + }, 6743(N, O, E) { + var h = E(9353); + N.exports = Function.prototype.bind || h; + }, 453(N, O, E) { + var h, d = E(9612), o = E(9383), f = E(1237), a = E(9290), i = E(9538), n = E(8068), r = E(9675), e = E(5345), t = E(1514), c = E(8968), s = E(6188), u = E(8002), p = E(5880), l = E(414), v = E(3093), y = Function, g = function(V) { + try { + return y('"use strict"; return (' + V + ").constructor;")(); + } catch { + } + }, _ = E(5795), T = E(655), b = function() { + throw new r(); + }, A = _ ? (function() { + try { + return b; + } catch { + try { + return _(arguments, "callee").get; + } catch { + return b; + } + } + })() : b, m = E(4039)(), I = E(3628), P = E(1064), x = E(8648), F = E(1002), K = E(76), Y = {}, Q = typeof Uint8Array < "u" && I ? I(Uint8Array) : h, S = { __proto__: null, "%AggregateError%": typeof AggregateError > "u" ? h : AggregateError, "%Array%": Array, "%ArrayBuffer%": typeof ArrayBuffer > "u" ? h : ArrayBuffer, "%ArrayIteratorPrototype%": m && I ? I([][Symbol.iterator]()) : h, "%AsyncFromSyncIteratorPrototype%": h, "%AsyncFunction%": Y, "%AsyncGenerator%": Y, "%AsyncGeneratorFunction%": Y, "%AsyncIteratorPrototype%": Y, "%Atomics%": typeof Atomics > "u" ? h : Atomics, "%BigInt%": typeof BigInt > "u" ? h : BigInt, "%BigInt64Array%": typeof BigInt64Array > "u" ? h : BigInt64Array, "%BigUint64Array%": typeof BigUint64Array > "u" ? h : BigUint64Array, "%Boolean%": Boolean, "%DataView%": typeof DataView > "u" ? h : DataView, "%Date%": Date, "%decodeURI%": decodeURI, "%decodeURIComponent%": decodeURIComponent, "%encodeURI%": encodeURI, "%encodeURIComponent%": encodeURIComponent, "%Error%": o, "%eval%": eval, "%EvalError%": f, "%Float16Array%": typeof Float16Array > "u" ? h : Float16Array, "%Float32Array%": typeof Float32Array > "u" ? h : Float32Array, "%Float64Array%": typeof Float64Array > "u" ? h : Float64Array, "%FinalizationRegistry%": typeof FinalizationRegistry > "u" ? h : FinalizationRegistry, "%Function%": y, "%GeneratorFunction%": Y, "%Int8Array%": typeof Int8Array > "u" ? h : Int8Array, "%Int16Array%": typeof Int16Array > "u" ? h : Int16Array, "%Int32Array%": typeof Int32Array > "u" ? h : Int32Array, "%isFinite%": isFinite, "%isNaN%": isNaN, "%IteratorPrototype%": m && I ? I(I([][Symbol.iterator]())) : h, "%JSON%": typeof JSON == "object" ? JSON : h, "%Map%": typeof Map > "u" ? h : Map, "%MapIteratorPrototype%": typeof Map < "u" && m && I ? I((/* @__PURE__ */ new Map())[Symbol.iterator]()) : h, "%Math%": Math, "%Number%": Number, "%Object%": d, "%Object.getOwnPropertyDescriptor%": _, "%parseFloat%": parseFloat, "%parseInt%": parseInt, "%Promise%": typeof Promise > "u" ? h : Promise, "%Proxy%": typeof Proxy > "u" ? h : Proxy, "%RangeError%": a, "%ReferenceError%": i, "%Reflect%": typeof Reflect > "u" ? h : Reflect, "%RegExp%": RegExp, "%Set%": typeof Set > "u" ? h : Set, "%SetIteratorPrototype%": typeof Set < "u" && m && I ? I((/* @__PURE__ */ new Set())[Symbol.iterator]()) : h, "%SharedArrayBuffer%": typeof SharedArrayBuffer > "u" ? h : SharedArrayBuffer, "%String%": String, "%StringIteratorPrototype%": m && I ? I(""[Symbol.iterator]()) : h, "%Symbol%": m ? Symbol : h, "%SyntaxError%": n, "%ThrowTypeError%": A, "%TypedArray%": Q, "%TypeError%": r, "%Uint8Array%": typeof Uint8Array > "u" ? h : Uint8Array, "%Uint8ClampedArray%": typeof Uint8ClampedArray > "u" ? h : Uint8ClampedArray, "%Uint16Array%": typeof Uint16Array > "u" ? h : Uint16Array, "%Uint32Array%": typeof Uint32Array > "u" ? h : Uint32Array, "%URIError%": e, "%WeakMap%": typeof WeakMap > "u" ? h : WeakMap, "%WeakRef%": typeof WeakRef > "u" ? h : WeakRef, "%WeakSet%": typeof WeakSet > "u" ? h : WeakSet, "%Function.prototype.call%": K, "%Function.prototype.apply%": F, "%Object.defineProperty%": T, "%Object.getPrototypeOf%": P, "%Math.abs%": t, "%Math.floor%": c, "%Math.max%": s, "%Math.min%": u, "%Math.pow%": p, "%Math.round%": l, "%Math.sign%": v, "%Reflect.getPrototypeOf%": x }; + if (I) try { + null.error; + } catch (V) { + var M = I(I(V)); + S["%Error.prototype%"] = M; + } + var j = function V(W) { + var z; + if (W === "%AsyncFunction%") z = g("async function () {}"); + else if (W === "%GeneratorFunction%") z = g("function* () {}"); + else if (W === "%AsyncGeneratorFunction%") z = g("async function* () {}"); + else if (W === "%AsyncGenerator%") { + var q = V("%AsyncGeneratorFunction%"); + q && (z = q.prototype); + } else if (W === "%AsyncIteratorPrototype%") { + var $ = V("%AsyncGenerator%"); + $ && I && (z = I($.prototype)); + } + return S[W] = z, z; + }, H = { __proto__: null, "%ArrayBufferPrototype%": ["ArrayBuffer", "prototype"], "%ArrayPrototype%": ["Array", "prototype"], "%ArrayProto_entries%": ["Array", "prototype", "entries"], "%ArrayProto_forEach%": ["Array", "prototype", "forEach"], "%ArrayProto_keys%": ["Array", "prototype", "keys"], "%ArrayProto_values%": ["Array", "prototype", "values"], "%AsyncFunctionPrototype%": ["AsyncFunction", "prototype"], "%AsyncGenerator%": ["AsyncGeneratorFunction", "prototype"], "%AsyncGeneratorPrototype%": ["AsyncGeneratorFunction", "prototype", "prototype"], "%BooleanPrototype%": ["Boolean", "prototype"], "%DataViewPrototype%": ["DataView", "prototype"], "%DatePrototype%": ["Date", "prototype"], "%ErrorPrototype%": ["Error", "prototype"], "%EvalErrorPrototype%": ["EvalError", "prototype"], "%Float32ArrayPrototype%": ["Float32Array", "prototype"], "%Float64ArrayPrototype%": ["Float64Array", "prototype"], "%FunctionPrototype%": ["Function", "prototype"], "%Generator%": ["GeneratorFunction", "prototype"], "%GeneratorPrototype%": ["GeneratorFunction", "prototype", "prototype"], "%Int8ArrayPrototype%": ["Int8Array", "prototype"], "%Int16ArrayPrototype%": ["Int16Array", "prototype"], "%Int32ArrayPrototype%": ["Int32Array", "prototype"], "%JSONParse%": ["JSON", "parse"], "%JSONStringify%": ["JSON", "stringify"], "%MapPrototype%": ["Map", "prototype"], "%NumberPrototype%": ["Number", "prototype"], "%ObjectPrototype%": ["Object", "prototype"], "%ObjProto_toString%": ["Object", "prototype", "toString"], "%ObjProto_valueOf%": ["Object", "prototype", "valueOf"], "%PromisePrototype%": ["Promise", "prototype"], "%PromiseProto_then%": ["Promise", "prototype", "then"], "%Promise_all%": ["Promise", "all"], "%Promise_reject%": ["Promise", "reject"], "%Promise_resolve%": ["Promise", "resolve"], "%RangeErrorPrototype%": ["RangeError", "prototype"], "%ReferenceErrorPrototype%": ["ReferenceError", "prototype"], "%RegExpPrototype%": ["RegExp", "prototype"], "%SetPrototype%": ["Set", "prototype"], "%SharedArrayBufferPrototype%": ["SharedArrayBuffer", "prototype"], "%StringPrototype%": ["String", "prototype"], "%SymbolPrototype%": ["Symbol", "prototype"], "%SyntaxErrorPrototype%": ["SyntaxError", "prototype"], "%TypedArrayPrototype%": ["TypedArray", "prototype"], "%TypeErrorPrototype%": ["TypeError", "prototype"], "%Uint8ArrayPrototype%": ["Uint8Array", "prototype"], "%Uint8ClampedArrayPrototype%": ["Uint8ClampedArray", "prototype"], "%Uint16ArrayPrototype%": ["Uint16Array", "prototype"], "%Uint32ArrayPrototype%": ["Uint32Array", "prototype"], "%URIErrorPrototype%": ["URIError", "prototype"], "%WeakMapPrototype%": ["WeakMap", "prototype"], "%WeakSetPrototype%": ["WeakSet", "prototype"] }, Z = E(6743), L = E(9957), w = Z.call(K, Array.prototype.concat), C = Z.call(F, Array.prototype.splice), R = Z.call(K, String.prototype.replace), B = Z.call(K, String.prototype.slice), D = Z.call(K, RegExp.prototype.exec), U = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g, k = /\\(\\)?/g, G = function(V, W) { + var z, q = V; + if (L(H, q) && (q = "%" + (z = H[q])[0] + "%"), L(S, q)) { + var $ = S[q]; + if ($ === Y && ($ = j(q)), $ === void 0 && !W) throw new r("intrinsic " + V + " exists, but is not available. Please file an issue!"); + return { alias: z, name: q, value: $ }; + } + throw new n("intrinsic " + V + " does not exist!"); + }; + N.exports = function(V, W) { + if (typeof V != "string" || V.length === 0) throw new r("intrinsic name must be a non-empty string"); + if (arguments.length > 1 && typeof W != "boolean") throw new r('"allowMissing" argument must be a boolean'); + if (D(/^%?[^%]*%?$/, V) === null) throw new n("`%` may not be present anywhere but at the beginning and end of the intrinsic name"); + var z = (function(pe) { + var ye = B(pe, 0, 1), Te = B(pe, -1); + if (ye === "%" && Te !== "%") throw new n("invalid intrinsic syntax, expected closing `%`"); + if (Te === "%" && ye !== "%") throw new n("invalid intrinsic syntax, expected opening `%`"); + var ae = []; + return R(pe, U, function(le, ve, Oe, se) { + ae[ae.length] = Oe ? R(se, k, "$1") : ve || le; + }), ae; + })(V), q = z.length > 0 ? z[0] : "", $ = G("%" + q + "%", W), te = $.name, re = $.value, ie = !1, ue = $.alias; + ue && (q = ue[0], C(z, w([0, 1], ue))); + for (var ne = 1, X = !0; ne < z.length; ne += 1) { + var ee = z[ne], J = B(ee, 0, 1), ce = B(ee, -1); + if ((J === '"' || J === "'" || J === "`" || ce === '"' || ce === "'" || ce === "`") && J !== ce) throw new n("property names with quotes must have matching quotes"); + if (ee !== "constructor" && X || (ie = !0), L(S, te = "%" + (q += "." + ee) + "%")) re = S[te]; + else if (re != null) { + if (!(ee in re)) { + if (!W) throw new r("base intrinsic for " + V + " exists, but the property is not available."); + return; + } + if (_ && ne + 1 >= z.length) { + var _e = _(re, ee); + re = (X = !!_e) && "get" in _e && !("originalValue" in _e.get) ? _e.get : re[ee]; + } else X = L(re, ee), re = re[ee]; + X && !ie && (S[te] = re); + } + } + return re; + }; + }, 1064(N, O, E) { + var h = E(9612); + N.exports = h.getPrototypeOf || null; + }, 8648(N) { + N.exports = typeof Reflect < "u" && Reflect.getPrototypeOf || null; + }, 3628(N, O, E) { + var h = E(8648), d = E(1064), o = E(7176); + N.exports = h ? function(f) { + return h(f); + } : d ? function(f) { + if (!f || typeof f != "object" && typeof f != "function") throw new TypeError("getProto: not an object"); + return d(f); + } : o ? function(f) { + return o(f); + } : null; + }, 6549(N) { + N.exports = Object.getOwnPropertyDescriptor; + }, 5795(N, O, E) { + var h = E(6549); + if (h) try { + h([], "length"); + } catch { + h = null; + } + N.exports = h; + }, 592(N, O, E) { + var h = E(655), d = function() { + return !!h; + }; + d.hasArrayLengthDefineBug = function() { + if (!h) return null; + try { + return h([], "length", { value: 1 }).length !== 1; + } catch { + return !0; + } + }, N.exports = d; + }, 4039(N, O, E) { + var h = typeof Symbol < "u" && Symbol, d = E(1333); + N.exports = function() { + return typeof h == "function" && typeof Symbol == "function" && typeof h("foo") == "symbol" && typeof Symbol("bar") == "symbol" && d(); + }; + }, 1333(N) { + N.exports = function() { + if (typeof Symbol != "function" || typeof Object.getOwnPropertySymbols != "function") return !1; + if (typeof Symbol.iterator == "symbol") return !0; + var O = {}, E = Symbol("test"), h = Object(E); + if (typeof E == "string" || Object.prototype.toString.call(E) !== "[object Symbol]" || Object.prototype.toString.call(h) !== "[object Symbol]") return !1; + for (var d in O[E] = 42, O) return !1; + if (typeof Object.keys == "function" && Object.keys(O).length !== 0 || typeof Object.getOwnPropertyNames == "function" && Object.getOwnPropertyNames(O).length !== 0) return !1; + var o = Object.getOwnPropertySymbols(O); + if (o.length !== 1 || o[0] !== E || !Object.prototype.propertyIsEnumerable.call(O, E)) return !1; + if (typeof Object.getOwnPropertyDescriptor == "function") { + var f = Object.getOwnPropertyDescriptor(O, E); + if (f.value !== 42 || f.enumerable !== !0) return !1; + } + return !0; + }; + }, 9092(N, O, E) { + var h = E(1333); + N.exports = function() { + return h() && !!Symbol.toStringTag; + }; + }, 9957(N, O, E) { + var h = Function.prototype.call, d = Object.prototype.hasOwnProperty, o = E(6743); + N.exports = o.call(h, d); + }, 6698(N) { + typeof Object.create == "function" ? N.exports = function(O, E) { + E && (O.super_ = E, O.prototype = Object.create(E.prototype, { constructor: { value: O, enumerable: !1, writable: !0, configurable: !0 } })); + } : N.exports = function(O, E) { + if (E) { + O.super_ = E; + var h = function() { + }; + h.prototype = E.prototype, O.prototype = new h(), O.prototype.constructor = O; + } + }; + }, 7244(N, O, E) { + var h = E(9092)(), d = E(6556)("Object.prototype.toString"), o = function(i) { + return !(h && i && typeof i == "object" && Symbol.toStringTag in i) && d(i) === "[object Arguments]"; + }, f = function(i) { + return !!o(i) || i !== null && typeof i == "object" && "length" in i && typeof i.length == "number" && i.length >= 0 && d(i) !== "[object Array]" && "callee" in i && d(i.callee) === "[object Function]"; + }, a = (function() { + return o(arguments); + })(); + o.isLegacyArguments = f, N.exports = a ? o : f; + }, 9600(N) { + var O, E, h = Function.prototype.toString, d = typeof Reflect == "object" && Reflect !== null && Reflect.apply; + if (typeof d == "function" && typeof Object.defineProperty == "function") try { + O = Object.defineProperty({}, "length", { get: function() { + throw E; + } }), E = {}, d(function() { + throw 42; + }, null, O); + } catch (c) { + c !== E && (d = null); + } + else d = null; + var o = /^\s*class\b/, f = function(c) { + try { + var s = h.call(c); + return o.test(s); + } catch { + return !1; + } + }, a = function(c) { + try { + return !f(c) && (h.call(c), !0); + } catch { + return !1; + } + }, i = Object.prototype.toString, n = typeof Symbol == "function" && !!Symbol.toStringTag, r = !(0 in [,]), e = function() { + return !1; + }; + if (typeof document == "object") { + var t = document.all; + i.call(t) === i.call(document.all) && (e = function(c) { + if ((r || !c) && (c === void 0 || typeof c == "object")) try { + var s = i.call(c); + return (s === "[object HTMLAllCollection]" || s === "[object HTML document.all class]" || s === "[object HTMLCollection]" || s === "[object Object]") && c("") == null; + } catch { + } + return !1; + }); + } + N.exports = d ? function(c) { + if (e(c)) return !0; + if (!c || typeof c != "function" && typeof c != "object") return !1; + try { + d(c, null, O); + } catch (s) { + if (s !== E) return !1; + } + return !f(c) && a(c); + } : function(c) { + if (e(c)) return !0; + if (!c || typeof c != "function" && typeof c != "object") return !1; + if (n) return a(c); + if (f(c)) return !1; + var s = i.call(c); + return !(s !== "[object Function]" && s !== "[object GeneratorFunction]" && !/^\[object HTML/.test(s)) && a(c); + }; + }, 8184(N, O, E) { + var h, d = E(6556), o = E(9721)(/^\s*(?:function)?\*/), f = E(9092)(), a = E(3628), i = d("Object.prototype.toString"), n = d("Function.prototype.toString"); + N.exports = function(r) { + if (typeof r != "function") return !1; + if (o(n(r))) return !0; + if (!f) return i(r) === "[object GeneratorFunction]"; + if (!a) return !1; + if (h === void 0) { + var e = (function() { + if (!f) return !1; + try { + return Function("return function*() {}")(); + } catch { + } + })(); + h = !!e && a(e); + } + return a(r) === h; + }; + }, 3003(N) { + N.exports = function(O) { + return O != O; + }; + }, 4133(N, O, E) { + var h = E(487), d = E(8452), o = E(3003), f = E(6642), a = E(2464), i = h(f(), Number); + d(i, { getPolyfill: f, implementation: o, shim: a }), N.exports = i; + }, 6642(N, O, E) { + var h = E(3003); + N.exports = function() { + return Number.isNaN && Number.isNaN(NaN) && !Number.isNaN("a") ? Number.isNaN : h; + }; + }, 2464(N, O, E) { + var h = E(8452), d = E(6642); + N.exports = function() { + var o = d(); + return h(Number, { isNaN: o }, { isNaN: function() { + return Number.isNaN !== o; + } }), o; + }; + }, 4035(N, O, E) { + var h, d = E(6556), o = E(9092)(), f = E(9957), a = E(5795); + if (o) { + var i = d("RegExp.prototype.exec"), n = {}, r = function() { + throw n; + }, e = { toString: r, valueOf: r }; + typeof Symbol.toPrimitive == "symbol" && (e[Symbol.toPrimitive] = r), h = function(c) { + if (!c || typeof c != "object") return !1; + var s = a(c, "lastIndex"); + if (!s || !f(s, "value")) return !1; + try { + i(c, e); + } catch (u) { + return u === n; + } + }; + } else { + var t = d("Object.prototype.toString"); + h = function(c) { + return !(!c || typeof c != "object" && typeof c != "function") && t(c) === "[object RegExp]"; + }; + } + N.exports = h; + }, 5680(N, O, E) { + var h = E(5767); + N.exports = function(d) { + return !!h(d); + }; + }, 1514(N) { + N.exports = Math.abs; + }, 8968(N) { + N.exports = Math.floor; + }, 4459(N) { + N.exports = Number.isNaN || function(O) { + return O != O; + }; + }, 6188(N) { + N.exports = Math.max; + }, 8002(N) { + N.exports = Math.min; + }, 5880(N) { + N.exports = Math.pow; + }, 414(N) { + N.exports = Math.round; + }, 3093(N, O, E) { + var h = E(4459); + N.exports = function(d) { + return h(d) || d === 0 ? d : d < 0 ? -1 : 1; + }; + }, 6585(N) { + var O = 1e3, E = 60 * O, h = 60 * E, d = 24 * h, o = 7 * d; + function f(a, i, n, r) { + var e = i >= 1.5 * n; + return Math.round(a / n) + " " + r + (e ? "s" : ""); + } + N.exports = function(a, i) { + i = i || {}; + var n, r, e = typeof a; + if (e === "string" && a.length > 0) return (function(t) { + if (!((t = String(t)).length > 100)) { + var c = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t); + if (c) { + var s = parseFloat(c[1]); + switch ((c[2] || "ms").toLowerCase()) { + case "years": + case "year": + case "yrs": + case "yr": + case "y": + return 315576e5 * s; + case "weeks": + case "week": + case "w": + return s * o; + case "days": + case "day": + case "d": + return s * d; + case "hours": + case "hour": + case "hrs": + case "hr": + case "h": + return s * h; + case "minutes": + case "minute": + case "mins": + case "min": + case "m": + return s * E; + case "seconds": + case "second": + case "secs": + case "sec": + case "s": + return s * O; + case "milliseconds": + case "millisecond": + case "msecs": + case "msec": + case "ms": + return s; + default: + return; + } + } + } + })(a); + if (e === "number" && isFinite(a)) return i.long ? (n = a, (r = Math.abs(n)) >= d ? f(n, r, d, "day") : r >= h ? f(n, r, h, "hour") : r >= E ? f(n, r, E, "minute") : r >= O ? f(n, r, O, "second") : n + " ms") : (function(t) { + var c = Math.abs(t); + return c >= d ? Math.round(t / d) + "d" : c >= h ? Math.round(t / h) + "h" : c >= E ? Math.round(t / E) + "m" : c >= O ? Math.round(t / O) + "s" : t + "ms"; + })(a); + throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(a)); + }; + }, 9211(N) { + var O = function(E) { + return E != E; + }; + N.exports = function(E, h) { + return E === 0 && h === 0 ? 1 / E == 1 / h : E === h || !(!O(E) || !O(h)); + }; + }, 7653(N, O, E) { + var h = E(8452), d = E(487), o = E(9211), f = E(9394), a = E(6576), i = d(f(), Object); + h(i, { getPolyfill: f, implementation: o, shim: a }), N.exports = i; + }, 9394(N, O, E) { + var h = E(9211); + N.exports = function() { + return typeof Object.is == "function" ? Object.is : h; + }; + }, 6576(N, O, E) { + var h = E(9394), d = E(8452); + N.exports = function() { + var o = h(); + return d(Object, { is: o }, { is: function() { + return Object.is !== o; + } }), o; + }; + }, 8875(N, O, E) { + var h; + if (!Object.keys) { + var d = Object.prototype.hasOwnProperty, o = Object.prototype.toString, f = E(1093), a = Object.prototype.propertyIsEnumerable, i = !a.call({ toString: null }, "toString"), n = a.call(function() { + }, "prototype"), r = ["toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "constructor"], e = function(s) { + var u = s.constructor; + return u && u.prototype === s; + }, t = { $applicationCache: !0, $console: !0, $external: !0, $frame: !0, $frameElement: !0, $frames: !0, $innerHeight: !0, $innerWidth: !0, $onmozfullscreenchange: !0, $onmozfullscreenerror: !0, $outerHeight: !0, $outerWidth: !0, $pageXOffset: !0, $pageYOffset: !0, $parent: !0, $scrollLeft: !0, $scrollTop: !0, $scrollX: !0, $scrollY: !0, $self: !0, $webkitIndexedDB: !0, $webkitStorageInfo: !0, $window: !0 }, c = (function() { + if (typeof window > "u") return !1; + for (var s in window) try { + if (!t["$" + s] && d.call(window, s) && window[s] !== null && typeof window[s] == "object") try { + e(window[s]); + } catch { + return !0; + } + } catch { + return !0; + } + return !1; + })(); + h = function(s) { + var u = s !== null && typeof s == "object", p = o.call(s) === "[object Function]", l = f(s), v = u && o.call(s) === "[object String]", y = []; + if (!u && !p && !l) throw new TypeError("Object.keys called on a non-object"); + var g = n && p; + if (v && s.length > 0 && !d.call(s, 0)) for (var _ = 0; _ < s.length; ++_) y.push(String(_)); + if (l && s.length > 0) for (var T = 0; T < s.length; ++T) y.push(String(T)); + else for (var b in s) g && b === "prototype" || !d.call(s, b) || y.push(String(b)); + if (i) for (var A = (function(I) { + if (typeof window > "u" || !c) return e(I); + try { + return e(I); + } catch { + return !1; + } + })(s), m = 0; m < r.length; ++m) A && r[m] === "constructor" || !d.call(s, r[m]) || y.push(r[m]); + return y; + }; + } + N.exports = h; + }, 1189(N, O, E) { + var h = Array.prototype.slice, d = E(1093), o = Object.keys, f = o ? function(i) { + return o(i); + } : E(8875), a = Object.keys; + f.shim = function() { + if (Object.keys) { + var i = (function() { + var n = Object.keys(arguments); + return n && n.length === arguments.length; + })(1, 2); + i || (Object.keys = function(n) { + return d(n) ? a(h.call(n)) : a(n); + }); + } else Object.keys = f; + return Object.keys || f; + }, N.exports = f; + }, 1093(N) { + var O = Object.prototype.toString; + N.exports = function(E) { + var h = O.call(E), d = h === "[object Arguments]"; + return d || (d = h !== "[object Array]" && E !== null && typeof E == "object" && typeof E.length == "number" && E.length >= 0 && O.call(E.callee) === "[object Function]"), d; + }; + }, 8403(N, O, E) { + var h = E(1189), d = E(1333)(), o = E(6556), f = E(9612), a = o("Array.prototype.push"), i = o("Object.prototype.propertyIsEnumerable"), n = d ? f.getOwnPropertySymbols : null; + N.exports = function(r, e) { + if (r == null) throw new TypeError("target must be an object"); + var t = f(r); + if (arguments.length === 1) return t; + for (var c = 1; c < arguments.length; ++c) { + var s = f(arguments[c]), u = h(s), p = d && (f.getOwnPropertySymbols || n); + if (p) for (var l = p(s), v = 0; v < l.length; ++v) { + var y = l[v]; + i(s, y) && a(u, y); + } + for (var g = 0; g < u.length; ++g) { + var _ = u[g]; + if (i(s, _)) { + var T = s[_]; + t[_] = T; + } + } + } + return t; + }; + }, 9133(N, O, E) { + var h = E(8403); + N.exports = function() { + return Object.assign ? (function() { + if (!Object.assign) return !1; + for (var d = "abcdefghijklmnopqrst", o = d.split(""), f = {}, a = 0; a < o.length; ++a) f[o[a]] = o[a]; + var i = Object.assign({}, f), n = ""; + for (var r in i) n += r; + return d !== n; + })() || (function() { + if (!Object.assign || !Object.preventExtensions) return !1; + var d = Object.preventExtensions({ 1: 2 }); + try { + Object.assign(d, "xy"); + } catch { + return d[1] === "y"; + } + return !1; + })() ? h : Object.assign : h; + }; + }, 6578(N) { + N.exports = ["Float16Array", "Float32Array", "Float64Array", "Int8Array", "Int16Array", "Int32Array", "Uint8Array", "Uint8ClampedArray", "Uint16Array", "Uint32Array", "BigInt64Array", "BigUint64Array"]; + }, 5606(N) { + var O, E, h = N.exports = {}; + function d() { + throw new Error("setTimeout has not been defined"); + } + function o() { + throw new Error("clearTimeout has not been defined"); + } + function f(u) { + if (O === setTimeout) return setTimeout(u, 0); + if ((O === d || !O) && setTimeout) return O = setTimeout, setTimeout(u, 0); + try { + return O(u, 0); + } catch { + try { + return O.call(null, u, 0); + } catch { + return O.call(this, u, 0); + } + } + } + (function() { + try { + O = typeof setTimeout == "function" ? setTimeout : d; + } catch { + O = d; + } + try { + E = typeof clearTimeout == "function" ? clearTimeout : o; + } catch { + E = o; + } + })(); + var a, i = [], n = !1, r = -1; + function e() { + n && a && (n = !1, a.length ? i = a.concat(i) : r = -1, i.length && t()); + } + function t() { + if (!n) { + var u = f(e); + n = !0; + for (var p = i.length; p; ) { + for (a = i, i = []; ++r < p; ) a && a[r].run(); + r = -1, p = i.length; + } + a = null, n = !1, (function(l) { + if (E === clearTimeout) return clearTimeout(l); + if ((E === o || !E) && clearTimeout) return E = clearTimeout, clearTimeout(l); + try { + return E(l); + } catch { + try { + return E.call(null, l); + } catch { + return E.call(this, l); + } + } + })(u); + } + } + function c(u, p) { + this.fun = u, this.array = p; + } + function s() { + } + h.nextTick = function(u) { + var p = new Array(arguments.length - 1); + if (arguments.length > 1) for (var l = 1; l < arguments.length; l++) p[l - 1] = arguments[l]; + i.push(new c(u, p)), i.length !== 1 || n || f(t); + }, c.prototype.run = function() { + this.fun.apply(null, this.array); + }, h.title = "browser", h.browser = !0, h.env = {}, h.argv = [], h.version = "", h.versions = {}, h.on = s, h.addListener = s, h.once = s, h.off = s, h.removeListener = s, h.removeAllListeners = s, h.emit = s, h.prependListener = s, h.prependOnceListener = s, h.listeners = function(u) { + return []; + }, h.binding = function(u) { + throw new Error("process.binding is not supported"); + }, h.cwd = function() { + return "/"; + }, h.chdir = function(u) { + throw new Error("process.chdir is not supported"); + }, h.umask = function() { + return 0; + }; + }, 9721(N, O, E) { + var h = E(6556), d = E(4035), o = h("RegExp.prototype.exec"), f = E(9675); + N.exports = function(a) { + if (!d(a)) throw new f("`regex` must be a RegExp"); + return function(i) { + return o(a, i) !== null; + }; + }; + }, 6897(N, O, E) { + var h = E(453), d = E(41), o = E(592)(), f = E(5795), a = E(9675), i = h("%Math.floor%"); + N.exports = function(n, r) { + if (typeof n != "function") throw new a("`fn` is not a function"); + if (typeof r != "number" || r < 0 || r > 4294967295 || i(r) !== r) throw new a("`length` must be a positive 32-bit integer"); + var e = arguments.length > 2 && !!arguments[2], t = !0, c = !0; + if ("length" in n && f) { + var s = f(n, "length"); + s && !s.configurable && (t = !1), s && !s.writable && (c = !1); + } + return (t || c || !e) && (o ? d(n, "length", r, !0, !0) : d(n, "length", r)), n; + }; + }, 4717(N, O, E) { + var h = this && this.__awaiter || function(a, i, n, r) { + return new (n || (n = Promise))(function(e, t) { + function c(p) { + try { + u(r.next(p)); + } catch (l) { + t(l); + } + } + function s(p) { + try { + u(r.throw(p)); + } catch (l) { + t(l); + } + } + function u(p) { + var l; + p.done ? e(p.value) : (l = p.value, l instanceof n ? l : new n(function(v) { + v(l); + })).then(c, s); + } + u((r = r.apply(a, i || [])).next()); + }); + }, d = this && this.__generator || function(a, i) { + var n, r, e, t = { label: 0, sent: function() { + if (1 & e[0]) throw e[1]; + return e[1]; + }, trys: [], ops: [] }, c = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return c.next = s(0), c.throw = s(1), c.return = s(2), typeof Symbol == "function" && (c[Symbol.iterator] = function() { + return this; + }), c; + function s(u) { + return function(p) { + return (function(l) { + if (n) throw new TypeError("Generator is already executing."); + for (; c && (c = 0, l[0] && (t = 0)), t; ) try { + if (n = 1, r && (e = 2 & l[0] ? r.return : l[0] ? r.throw || ((e = r.return) && e.call(r), 0) : r.next) && !(e = e.call(r, l[1])).done) return e; + switch (r = 0, e && (l = [2 & l[0], e.value]), l[0]) { + case 0: + case 1: + e = l; + break; + case 4: + return t.label++, { value: l[1], done: !1 }; + case 5: + t.label++, r = l[1], l = [0]; + continue; + case 7: + l = t.ops.pop(), t.trys.pop(); + continue; + default: + if (!((e = (e = t.trys).length > 0 && e[e.length - 1]) || l[0] !== 6 && l[0] !== 2)) { + t = 0; + continue; + } + if (l[0] === 3 && (!e || l[1] > e[0] && l[1] < e[3])) { + t.label = l[1]; + break; + } + if (l[0] === 6 && t.label < e[1]) { + t.label = e[1], e = l; + break; + } + if (e && t.label < e[2]) { + t.label = e[2], t.ops.push(l); + break; + } + e[2] && t.ops.pop(), t.trys.pop(); + continue; + } + l = i.call(a, t); + } catch (v) { + l = [6, v], r = 0; + } finally { + n = e = 0; + } + if (5 & l[0]) throw l[1]; + return { value: l[0] ? l[1] : void 0, done: !0 }; + })([u, p]); + }; + } + }; + Object.defineProperty(O, "__esModule", { value: !0 }), O.createRpc = f; + var o = E(3318); + function f(a, i) { + return new Proxy({}, { get: function(n, r) { + var e, t = this, c = (e = r.toString()) && e[0].toUpperCase() + e.slice(1), s = "".concat(a, ".").concat(c); + return o.subscriptionMethods.includes(s) ? function(u, p, l) { + i.subscribe(s, u, p, l); + } : function(u) { + return h(t, void 0, void 0, function() { + return d(this, function(p) { + switch (p.label) { + case 0: + return [4, i.request(s, u)]; + case 1: + return [2, p.sent()]; + } + }); + }); + }; + } }); + } + O.default = f; + }, 6315(N, O, E) { + var h = this && this.__awaiter || function(a, i, n, r) { + return new (n || (n = Promise))(function(e, t) { + function c(p) { + try { + u(r.next(p)); + } catch (l) { + t(l); + } + } + function s(p) { + try { + u(r.throw(p)); + } catch (l) { + t(l); + } + } + function u(p) { + var l; + p.done ? e(p.value) : (l = p.value, l instanceof n ? l : new n(function(v) { + v(l); + })).then(c, s); + } + u((r = r.apply(a, i || [])).next()); + }); + }, d = this && this.__generator || function(a, i) { + var n, r, e, t = { label: 0, sent: function() { + if (1 & e[0]) throw e[1]; + return e[1]; + }, trys: [], ops: [] }, c = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return c.next = s(0), c.throw = s(1), c.return = s(2), typeof Symbol == "function" && (c[Symbol.iterator] = function() { + return this; + }), c; + function s(u) { + return function(p) { + return (function(l) { + if (n) throw new TypeError("Generator is already executing."); + for (; c && (c = 0, l[0] && (t = 0)), t; ) try { + if (n = 1, r && (e = 2 & l[0] ? r.return : l[0] ? r.throw || ((e = r.return) && e.call(r), 0) : r.next) && !(e = e.call(r, l[1])).done) return e; + switch (r = 0, e && (l = [2 & l[0], e.value]), l[0]) { + case 0: + case 1: + e = l; + break; + case 4: + return t.label++, { value: l[1], done: !1 }; + case 5: + t.label++, r = l[1], l = [0]; + continue; + case 7: + l = t.ops.pop(), t.trys.pop(); + continue; + default: + if (!((e = (e = t.trys).length > 0 && e[e.length - 1]) || l[0] !== 6 && l[0] !== 2)) { + t = 0; + continue; + } + if (l[0] === 3 && (!e || l[1] > e[0] && l[1] < e[3])) { + t.label = l[1]; + break; + } + if (l[0] === 6 && t.label < e[1]) { + t.label = e[1], e = l; + break; + } + if (e && t.label < e[2]) { + t.label = e[2], t.ops.push(l); + break; + } + e[2] && t.ops.pop(), t.trys.pop(); + continue; + } + l = i.call(a, t); + } catch (v) { + l = [6, v], r = 0; + } finally { + n = e = 0; + } + if (5 & l[0]) throw l[1]; + return { value: l[0] ? l[1] : void 0, done: !0 }; + })([u, p]); + }; + } + }; + Object.defineProperty(O, "__esModule", { value: !0 }), O.PasskeyEncryptionService = void 0; + var o = E(1389), f = (function() { + function a(i, n) { + this.isUnlockedState = !1, this.namespace = i, this.displayName = n || "LNC User (".concat(i, ")"); + } + return Object.defineProperty(a.prototype, "method", { get: function() { + return "passkey"; + }, enumerable: !1, configurable: !0 }), Object.defineProperty(a.prototype, "isUnlocked", { get: function() { + return this.isUnlockedState && !!this.encryptionKey; + }, enumerable: !1, configurable: !0 }), a.prototype.encrypt = function(i) { + return h(this, void 0, void 0, function() { + var n, r, e, t, c, s; + return d(this, function(u) { + switch (u.label) { + case 0: + if (!this.isUnlocked || !this.encryptionKey) throw new Error("Passkey encryption service is locked. Call unlock() first."); + u.label = 1; + case 1: + return u.trys.push([1, 3, , 4]), n = crypto.getRandomValues(new Uint8Array(12)), r = new TextEncoder(), e = r.encode(i), [4, crypto.subtle.encrypt({ name: "AES-GCM", iv: n }, this.encryptionKey, e)]; + case 2: + return t = u.sent(), (c = new Uint8Array(n.length + t.byteLength)).set(n), c.set(new Uint8Array(t), n.length), [2, (0, o.arrayBufferToBase64)(c.buffer)]; + case 3: + throw s = u.sent(), new Error("Passkey encryption failed: ".concat(s.message)); + case 4: + return [2]; + } + }); + }); + }, a.prototype.decrypt = function(i) { + return h(this, void 0, void 0, function() { + var n, r, e, t, c; + return d(this, function(s) { + switch (s.label) { + case 0: + if (!this.isUnlocked || !this.encryptionKey) throw new Error("Passkey encryption service is locked. Call unlock() first."); + s.label = 1; + case 1: + return s.trys.push([1, 3, , 4]), n = (0, o.base64ToArrayBuffer)(i), r = n.slice(0, 12), e = n.slice(12), [4, crypto.subtle.decrypt({ name: "AES-GCM", iv: r }, this.encryptionKey, e)]; + case 2: + return t = s.sent(), [2, new TextDecoder().decode(t)]; + case 3: + throw c = s.sent(), new Error("Passkey decryption failed: ".concat(c.message)); + case 4: + return [2]; + } + }); + }); + }, a.prototype.unlock = function(i) { + return h(this, void 0, void 0, function() { + var n; + return d(this, function(r) { + switch (r.label) { + case 0: + if (i.method !== "passkey") throw new Error("Passkey encryption service requires passkey unlock method"); + r.label = 1; + case 1: + return r.trys.push([1, 14, , 15]), !i.credentialId || i.createIfMissing ? [3, 3] : [4, this.authenticateWithExistingPasskey(i.credentialId)]; + case 2: + return r.sent(), [3, 13]; + case 3: + if (!i.createIfMissing) return [3, 12]; + if (!i.credentialId) return [3, 9]; + r.label = 4; + case 4: + return r.trys.push([4, 6, , 8]), [4, this.authenticateWithExistingPasskey(i.credentialId)]; + case 5: + return r.sent(), [3, 8]; + case 6: + return r.sent(), [4, this.createNewPasskey()]; + case 7: + return r.sent(), [3, 8]; + case 8: + return [3, 11]; + case 9: + return [4, this.createNewPasskey()]; + case 10: + r.sent(), r.label = 11; + case 11: + return [3, 13]; + case 12: + throw new Error("No passkey credential available and createIfMissing is false"); + case 13: + return this.isUnlockedState = !0, [3, 15]; + case 14: + throw n = r.sent(), new Error("Passkey unlock failed: ".concat(n.message)); + case 15: + return [2]; + } + }); + }); + }, a.prototype.lock = function() { + this.encryptionKey = void 0, this.credentialId = void 0, this.isUnlockedState = !1; + }, a.prototype.canHandle = function(i) { + return i === "passkey"; + }, a.prototype.getCredentialId = function() { + if (!this.credentialId) throw new Error("No credential ID available - unlock first"); + return this.credentialId; + }, a.isSupported = function() { + return h(this, void 0, void 0, function() { + var i, n; + return d(this, function(r) { + switch (r.label) { + case 0: + return r.trys.push([0, 2, , 3]), window.PublicKeyCredential ? [4, PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()] : [2, !1]; + case 1: + return r.sent() ? (i = PublicKeyCredential, (n = i.getClientExtensionResults) === null || n === void 0 || n.call(i), [2, !0]) : [2, !1]; + case 2: + return r.sent(), [2, !1]; + case 3: + return [2]; + } + }); + }); + }, a.prototype.createNewPasskey = function() { + return h(this, void 0, void 0, function() { + var i, n, r; + return d(this, function(e) { + switch (e.label) { + case 0: + return [4, this.generateDeterministicChallenge()]; + case 1: + return i = e.sent(), n = crypto.getRandomValues(new Uint8Array(16)), [4, navigator.credentials.create({ publicKey: { challenge: i.buffer, rp: { name: this.namespace, id: window.location.hostname }, user: { id: n, name: this.displayName, displayName: this.displayName }, pubKeyCredParams: [{ alg: -7, type: "public-key" }, { alg: -257, type: "public-key" }], authenticatorSelection: { authenticatorAttachment: "platform", userVerification: "required", residentKey: "required" }, extensions: { prf: { eval: { first: i.buffer } } } } })]; + case 2: + if (!(r = e.sent())) throw new Error("Failed to create passkey credential"); + return this.credentialId = r.id, [4, this.deriveEncryptionKey(r, i)]; + case 3: + return e.sent(), [2]; + } + }); + }); + }, a.prototype.authenticateWithExistingPasskey = function(i) { + return h(this, void 0, void 0, function() { + var n, r; + return d(this, function(e) { + switch (e.label) { + case 0: + return [4, this.generateDeterministicChallenge()]; + case 1: + return n = e.sent(), [4, navigator.credentials.get({ publicKey: { challenge: n.buffer, allowCredentials: [{ type: "public-key", id: (0, o.base64ToArrayBuffer)(i) }], userVerification: "required", extensions: { prf: { eval: { first: n.buffer } } } } })]; + case 2: + if (!(r = e.sent())) throw new Error("Failed to authenticate with passkey"); + return this.credentialId = i, [4, this.deriveEncryptionKey(r, n)]; + case 3: + return e.sent(), [2]; + } + }); + }); + }, a.prototype.deriveEncryptionKey = function(i, n) { + return h(this, void 0, void 0, function() { + var r, e, t, c, s, u, p; + return d(this, function(l) { + switch (l.label) { + case 0: + if (r = ((s = i.getClientExtensionResults) === null || s === void 0 ? void 0 : s.call(i)) || {}, !(!((p = (u = r.prf) === null || u === void 0 ? void 0 : u.results) === null || p === void 0) && p.first)) throw new Error("PRF extension not supported or failed"); + return e = new Uint8Array(r.prf.results.first), [4, crypto.subtle.importKey("raw", e, "HKDF", !1, ["deriveKey"])]; + case 1: + return t = l.sent(), c = this, [4, crypto.subtle.deriveKey({ name: "HKDF", hash: "SHA-256", salt: new Uint8Array(n), info: new TextEncoder().encode(this.namespace) }, t, { name: "AES-GCM", length: 256 }, !1, ["encrypt", "decrypt"])]; + case 2: + return c.encryptionKey = l.sent(), [2]; + } + }); + }); + }, a.prototype.generateDeterministicChallenge = function() { + return h(this, void 0, void 0, function() { + var i, n, r; + return d(this, function(e) { + switch (e.label) { + case 0: + return i = new TextEncoder(), n = i.encode(this.namespace), [4, crypto.subtle.digest("SHA-256", n)]; + case 1: + return r = e.sent(), [2, new Uint8Array(r)]; + } + }); + }); + }, a; + })(); + O.PasskeyEncryptionService = f; + }, 6200(N, O, E) { + var h = this && this.__awaiter || function(a, i, n, r) { + return new (n || (n = Promise))(function(e, t) { + function c(p) { + try { + u(r.next(p)); + } catch (l) { + t(l); + } + } + function s(p) { + try { + u(r.throw(p)); + } catch (l) { + t(l); + } + } + function u(p) { + var l; + p.done ? e(p.value) : (l = p.value, l instanceof n ? l : new n(function(v) { + v(l); + })).then(c, s); + } + u((r = r.apply(a, i || [])).next()); + }); + }, d = this && this.__generator || function(a, i) { + var n, r, e, t = { label: 0, sent: function() { + if (1 & e[0]) throw e[1]; + return e[1]; + }, trys: [], ops: [] }, c = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return c.next = s(0), c.throw = s(1), c.return = s(2), typeof Symbol == "function" && (c[Symbol.iterator] = function() { + return this; + }), c; + function s(u) { + return function(p) { + return (function(l) { + if (n) throw new TypeError("Generator is already executing."); + for (; c && (c = 0, l[0] && (t = 0)), t; ) try { + if (n = 1, r && (e = 2 & l[0] ? r.return : l[0] ? r.throw || ((e = r.return) && e.call(r), 0) : r.next) && !(e = e.call(r, l[1])).done) return e; + switch (r = 0, e && (l = [2 & l[0], e.value]), l[0]) { + case 0: + case 1: + e = l; + break; + case 4: + return t.label++, { value: l[1], done: !1 }; + case 5: + t.label++, r = l[1], l = [0]; + continue; + case 7: + l = t.ops.pop(), t.trys.pop(); + continue; + default: + if (!((e = (e = t.trys).length > 0 && e[e.length - 1]) || l[0] !== 6 && l[0] !== 2)) { + t = 0; + continue; + } + if (l[0] === 3 && (!e || l[1] > e[0] && l[1] < e[3])) { + t.label = l[1]; + break; + } + if (l[0] === 6 && t.label < e[1]) { + t.label = e[1], e = l; + break; + } + if (e && t.label < e[2]) { + t.label = e[2], t.ops.push(l); + break; + } + e[2] && t.ops.pop(), t.trys.pop(); + continue; + } + l = i.call(a, t); + } catch (v) { + l = [6, v], r = 0; + } finally { + n = e = 0; + } + if (5 & l[0]) throw l[1]; + return { value: l[0] ? l[1] : void 0, done: !0 }; + })([u, p]); + }; + } + }; + Object.defineProperty(O, "__esModule", { value: !0 }), O.PasswordEncryptionService = void 0; + var o = E(5105), f = (function() { + function a() { + this.isUnlockedState = !1; + } + return Object.defineProperty(a.prototype, "method", { get: function() { + return "password"; + }, enumerable: !1, configurable: !0 }), Object.defineProperty(a.prototype, "isUnlocked", { get: function() { + return this.isUnlockedState && !!this.password && !!this.salt; + }, enumerable: !1, configurable: !0 }), a.prototype.encrypt = function(i) { + return h(this, void 0, void 0, function() { + return d(this, function(n) { + if (!this.isUnlocked || !this.password || !this.salt) throw new Error("Encryption service is locked. Call unlock() first."); + return [2, (0, o.encrypt)(i, this.password, this.salt)]; + }); + }); + }, a.prototype.decrypt = function(i) { + return h(this, void 0, void 0, function() { + return d(this, function(n) { + if (!this.isUnlocked || !this.password || !this.salt) throw new Error("Encryption service is locked. Call unlock() first."); + return [2, (0, o.decrypt)(i, this.password, this.salt)]; + }); + }); + }, a.prototype.unlock = function(i) { + return h(this, void 0, void 0, function() { + return d(this, function(n) { + if (i.method !== "password") throw new Error("Password encryption service requires password unlock method"); + if (!i.password) throw new Error("Password is required for password unlock"); + if (this.password = i.password, i.salt) { + if (this.salt = i.salt, i.cipher) try { + if (!(0, o.verifyTestCipher)(i.cipher, this.password, this.salt)) throw new Error("Invalid password"); + } catch { + throw new Error("Invalid password"); + } + } else this.salt = (0, o.generateSalt)(); + return this.isUnlockedState = !0, [2]; + }); + }); + }, a.prototype.lock = function() { + this.password = void 0, this.salt = void 0, this.isUnlockedState = !1; + }, a.prototype.canHandle = function(i) { + return i === "password"; + }, a.prototype.getSalt = function() { + if (!this.salt) throw new Error("No salt available - unlock first"); + return this.salt; + }, a.prototype.createTestCipher = function() { + if (!this.password || !this.salt) throw new Error("No password/salt available - unlock first"); + return (0, o.createTestCipher)(this.password, this.salt); + }, a; + })(); + O.PasswordEncryptionService = f; + }, 4245(N, O, E) { + var h = this && this.__createBinding || (Object.create ? function(e, t, c, s) { + s === void 0 && (s = c); + var u = Object.getOwnPropertyDescriptor(t, c); + u && !("get" in u ? !t.__esModule : u.writable || u.configurable) || (u = { enumerable: !0, get: function() { + return t[c]; + } }), Object.defineProperty(e, s, u); + } : function(e, t, c, s) { + s === void 0 && (s = c), e[s] = t[c]; + }), d = this && this.__exportStar || function(e, t) { + for (var c in e) c === "default" || Object.prototype.hasOwnProperty.call(t, c) || h(t, e, c); + }, o = this && this.__awaiter || function(e, t, c, s) { + return new (c || (c = Promise))(function(u, p) { + function l(g) { + try { + y(s.next(g)); + } catch (_) { + p(_); + } + } + function v(g) { + try { + y(s.throw(g)); + } catch (_) { + p(_); + } + } + function y(g) { + var _; + g.done ? u(g.value) : (_ = g.value, _ instanceof c ? _ : new c(function(T) { + T(_); + })).then(l, v); + } + y((s = s.apply(e, t || [])).next()); + }); + }, f = this && this.__generator || function(e, t) { + var c, s, u, p = { label: 0, sent: function() { + if (1 & u[0]) throw u[1]; + return u[1]; + }, trys: [], ops: [] }, l = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return l.next = v(0), l.throw = v(1), l.return = v(2), typeof Symbol == "function" && (l[Symbol.iterator] = function() { + return this; + }), l; + function v(y) { + return function(g) { + return (function(_) { + if (c) throw new TypeError("Generator is already executing."); + for (; l && (l = 0, _[0] && (p = 0)), p; ) try { + if (c = 1, s && (u = 2 & _[0] ? s.return : _[0] ? s.throw || ((u = s.return) && u.call(s), 0) : s.next) && !(u = u.call(s, _[1])).done) return u; + switch (s = 0, u && (_ = [2 & _[0], u.value]), _[0]) { + case 0: + case 1: + u = _; + break; + case 4: + return p.label++, { value: _[1], done: !1 }; + case 5: + p.label++, s = _[1], _ = [0]; + continue; + case 7: + _ = p.ops.pop(), p.trys.pop(); + continue; + default: + if (!((u = (u = p.trys).length > 0 && u[u.length - 1]) || _[0] !== 6 && _[0] !== 2)) { + p = 0; + continue; + } + if (_[0] === 3 && (!u || _[1] > u[0] && _[1] < u[3])) { + p.label = _[1]; + break; + } + if (_[0] === 6 && p.label < u[1]) { + p.label = u[1], u = _; + break; + } + if (u && p.label < u[2]) { + p.label = u[2], p.ops.push(_); + break; + } + u[2] && p.ops.pop(), p.trys.pop(); + continue; + } + _ = t.call(e, p); + } catch (T) { + _ = [6, T], s = 0; + } finally { + c = u = 0; + } + if (5 & _[0]) throw _[1]; + return { value: _[0] ? _[1] : void 0, done: !0 }; + })([y, g]); + }; + } + }, a = this && this.__importDefault || function(e) { + return e && e.__esModule ? e : { default: e }; + }; + Object.defineProperty(O, "__esModule", { value: !0 }), O.WasmManager = O.LightningNodeConnect = void 0, E(7289); + var i = a(E(2293)); + O.LightningNodeConnect = i.default; + var n = a(E(4038)), r = E(254); + Object.defineProperty(O, "WasmManager", { enumerable: !0, get: function() { + return r.WasmManager; + } }), WebAssembly.instantiateStreaming || (WebAssembly.instantiateStreaming = function(e, t) { + return o(void 0, void 0, void 0, function() { + var c; + return f(this, function(s) { + switch (s.label) { + case 0: + return [4, e]; + case 1: + return [4, s.sent().arrayBuffer()]; + case 2: + return c = s.sent(), [4, WebAssembly.instantiate(c, t)]; + case 3: + return [2, s.sent()]; + } + }); + }); + }), d(E(3318), O), O.default = n.default; + }, 2293(N, O, E) { + var h = this && this.__assign || function() { + return h = Object.assign || function(y) { + for (var g, _ = 1, T = arguments.length; _ < T; _++) for (var b in g = arguments[_]) Object.prototype.hasOwnProperty.call(g, b) && (y[b] = g[b]); + return y; + }, h.apply(this, arguments); + }, d = this && this.__awaiter || function(y, g, _, T) { + return new (_ || (_ = Promise))(function(b, A) { + function m(x) { + try { + P(T.next(x)); + } catch (F) { + A(F); + } + } + function I(x) { + try { + P(T.throw(x)); + } catch (F) { + A(F); + } + } + function P(x) { + var F; + x.done ? b(x.value) : (F = x.value, F instanceof _ ? F : new _(function(K) { + K(F); + })).then(m, I); + } + P((T = T.apply(y, g || [])).next()); + }); + }, o = this && this.__generator || function(y, g) { + var _, T, b, A = { label: 0, sent: function() { + if (1 & b[0]) throw b[1]; + return b[1]; + }, trys: [], ops: [] }, m = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return m.next = I(0), m.throw = I(1), m.return = I(2), typeof Symbol == "function" && (m[Symbol.iterator] = function() { + return this; + }), m; + function I(P) { + return function(x) { + return (function(F) { + if (_) throw new TypeError("Generator is already executing."); + for (; m && (m = 0, F[0] && (A = 0)), A; ) try { + if (_ = 1, T && (b = 2 & F[0] ? T.return : F[0] ? T.throw || ((b = T.return) && b.call(T), 0) : T.next) && !(b = b.call(T, F[1])).done) return b; + switch (T = 0, b && (F = [2 & F[0], b.value]), F[0]) { + case 0: + case 1: + b = F; + break; + case 4: + return A.label++, { value: F[1], done: !1 }; + case 5: + A.label++, T = F[1], F = [0]; + continue; + case 7: + F = A.ops.pop(), A.trys.pop(); + continue; + default: + if (!((b = (b = A.trys).length > 0 && b[b.length - 1]) || F[0] !== 6 && F[0] !== 2)) { + A = 0; + continue; + } + if (F[0] === 3 && (!b || F[1] > b[0] && F[1] < b[3])) { + A.label = F[1]; + break; + } + if (F[0] === 6 && A.label < b[1]) { + A.label = b[1], b = F; + break; + } + if (b && A.label < b[2]) { + A.label = b[2], A.ops.push(F); + break; + } + b[2] && A.ops.pop(), A.trys.pop(); + continue; + } + F = g.call(y, A); + } catch (K) { + F = [6, K], T = 0; + } finally { + _ = b = 0; + } + if (5 & F[0]) throw F[1]; + return { value: F[0] ? F[1] : void 0, done: !0 }; + })([P, x]); + }; + } + }, f = this && this.__importDefault || function(y) { + return y && y.__esModule ? y : { default: y }; + }; + Object.defineProperty(O, "__esModule", { value: !0 }), O.DEFAULT_CONFIG = void 0; + var a = E(3318), i = E(4717), n = E(6315), r = f(E(9440)), e = E(3666), t = E(6041), c = E(9792), s = E(8348), u = E(9764), p = E(254), l = (0, u.createLogger)("LightningNodeConnect"); + O.DEFAULT_CONFIG = { wasmClientCode: "https://lightning.engineering/lnc-v0.3.6-alpha.wasm", namespace: "default", serverHost: "mailbox.terminal.lightning.today:443", allowPasskeys: !0, enableSessions: !0 }; + var v = (function() { + function y(g) { + var _, T = this, b = Object.assign({}, O.DEFAULT_CONFIG, { passkeyDisplayName: "LNC User (".concat(g?.namespace || "default", ")") }, g); + this._config = b, this._credentialCache = new t.CredentialCache(), b.enableSessions !== !1 && (_ = new r.default(b.namespace, b.session)), this._strategyManager = new s.StrategyManager({ namespace: b.namespace, allowPasskeys: b.allowPasskeys, passkeyDisplayName: b.passkeyDisplayName }, _), this._sessionCoordinator = new c.SessionCoordinator(_), this._authCoordinator = new e.AuthenticationCoordinator(this._strategyManager, this._credentialCache, this._sessionCoordinator), this._wasmManager = new p.WasmManager(b.namespace, b.wasmClientCode, { onLocalKeyCreated: function(A) { + T._credentialCache.set("localKey", A); + }, onRemoteKeyReceived: function(A) { + T._credentialCache.set("remoteKey", A); + } }), this.lnd = new a.LndApi(i.createRpc, this), this.loop = new a.LoopApi(i.createRpc, this), this.pool = new a.PoolApi(i.createRpc, this), this.faraday = new a.FaradayApi(i.createRpc, this), this.tapd = new a.TaprootAssetsApi(i.createRpc, this), this.lit = new a.LitApi(i.createRpc, this); + } + return Object.defineProperty(y.prototype, "isReady", { get: function() { + return this._wasmManager.isReady; + }, enumerable: !1, configurable: !0 }), Object.defineProperty(y.prototype, "isConnected", { get: function() { + return this._wasmManager.isConnected; + }, enumerable: !1, configurable: !0 }), Object.defineProperty(y.prototype, "status", { get: function() { + return this._wasmManager.status; + }, enumerable: !1, configurable: !0 }), Object.defineProperty(y.prototype, "expiry", { get: function() { + return this._wasmManager.expiry; + }, enumerable: !1, configurable: !0 }), Object.defineProperty(y.prototype, "isReadOnly", { get: function() { + return this._wasmManager.isReadOnly; + }, enumerable: !1, configurable: !0 }), Object.defineProperty(y.prototype, "serverHost", { get: function() { + return this._credentialCache.get("serverHost") || this._config.serverHost; + }, set: function(g) { + this._credentialCache.set("serverHost", g); + }, enumerable: !1, configurable: !0 }), y.prototype.hasPerms = function(g) { + return this._wasmManager.hasPerms(g); + }, y.prototype.preload = function() { + return d(this, void 0, void 0, function() { + return o(this, function(g) { + switch (g.label) { + case 0: + return [4, this._wasmManager.preload()]; + case 1: + return g.sent(), [2]; + } + }); + }); + }, y.prototype.connect = function() { + return d(this, void 0, void 0, function() { + var g, _, T, b; + return o(this, function(A) { + switch (A.label) { + case 0: + if (g = this._credentialCache.get("pairingPhrase") || "", _ = this._credentialCache.get("localKey") || "", !g && !_) throw new Error("No pairing phrase or local key available. Call pair() or unlock() first."); + return T = { pairingPhrase: g, serverHost: this._credentialCache.get("serverHost") || this._config.serverHost, localKey: _, remoteKey: this._credentialCache.get("remoteKey") || "" }, [4, this._wasmManager.connect(T)]; + case 1: + if (A.sent(), this._config.enableSessions === !1) return [3, 5]; + A.label = 2; + case 2: + return A.trys.push([2, 4, , 5]), [4, this._authCoordinator.createSessionAfterConnection()]; + case 3: + return A.sent(), [3, 5]; + case 4: + return b = A.sent(), l.error("Session creation failed after successful connection; session-based refresh will be unavailable:", b), [3, 5]; + case 5: + return [2]; + } + }); + }); + }, y.prototype.disconnect = function() { + this._wasmManager.disconnect(); + }, y.prototype.request = function(g, _) { + return this._wasmManager.request(g, _); + }, y.prototype.subscribe = function(g, _, T, b) { + this._wasmManager.subscribe(g, _, T, b); + }, y.prototype.pair = function(g, _) { + return d(this, void 0, void 0, function() { + return o(this, function(T) { + switch (T.label) { + case 0: + return [4, this._authCoordinator.waitForSessionRestoration()]; + case 1: + return T.sent(), this._credentialCache.set("pairingPhrase", g), this._credentialCache.get("serverHost") || this._credentialCache.set("serverHost", this._config.serverHost), [4, this.run()]; + case 2: + return T.sent(), [4, this.connect()]; + case 3: + return T.sent(), _ ? _.method !== "password" ? [3, 5] : [4, this.persistWithPassword(_.password)] : [3, 7]; + case 4: + return T.sent(), [3, 7]; + case 5: + return [4, this.persistWithPasskey(_)]; + case 6: + T.sent(), T.label = 7; + case 7: + return [2]; + } + }); + }); + }, y.prototype.login = function(g) { + return d(this, void 0, void 0, function() { + return o(this, function(_) { + switch (_.label) { + case 0: + return [4, this.unlock(g)]; + case 1: + if (!_.sent()) throw new Error("Failed to unlock with method '".concat(g.method, "'")); + return [4, this.connect()]; + case 2: + return _.sent(), [2]; + } + }); + }); + }, y.prototype.unlock = function(g) { + return d(this, void 0, void 0, function() { + return o(this, function(_) { + return [2, this._authCoordinator.unlock(g)]; + }); + }); + }, y.prototype.persistWithPassword = function(g) { + return d(this, void 0, void 0, function() { + var _; + return o(this, function(T) { + switch (T.label) { + case 0: + if (!this.isConnected) throw new Error("Must be connected before persisting credentials"); + if (!(_ = this._strategyManager.getStrategy("password"))) throw new Error("Password strategy not available"); + return [4, _.unlock({ method: "password", password: g })]; + case 1: + if (!T.sent()) throw new Error("Failed to unlock password strategy"); + return [4, this._authCoordinator.persistCachedCredentials(_)]; + case 2: + return T.sent(), [2]; + } + }); + }); + }, y.prototype.persistWithPasskey = function(g) { + return d(this, void 0, void 0, function() { + var _; + return o(this, function(T) { + switch (T.label) { + case 0: + if (!this.isConnected) throw new Error("Must be connected before persisting credentials"); + if (!(_ = this._strategyManager.getStrategy("passkey"))) throw new Error("Passkey strategy not available"); + return [4, _.unlock(h({ method: "passkey", createIfMissing: !0 }, g))]; + case 1: + if (!T.sent()) throw new Error("Failed to unlock passkey strategy"); + return [4, this._authCoordinator.persistCachedCredentials(_)]; + case 2: + return T.sent(), [2]; + } + }); + }); + }, y.prototype.tryAutoRestore = function() { + return d(this, void 0, void 0, function() { + return o(this, function(g) { + return [2, this._authCoordinator.tryAutoRestore()]; + }); + }); + }, y.prototype.getAuthenticationInfo = function() { + return d(this, void 0, void 0, function() { + return o(this, function(g) { + return [2, this._authCoordinator.getAuthenticationInfo()]; + }); + }); + }, y.prototype.supportsPasskeys = function() { + if (this._config.allowPasskeys === !1) return !1; + var g = this._strategyManager.getStrategy("passkey"); + return !!g && g.isSupported; + }, y.isPasskeySupported = function() { + return d(this, void 0, void 0, function() { + return o(this, function(g) { + return [2, n.PasskeyEncryptionService.isSupported()]; + }); + }); + }, y.prototype.clear = function(g) { + var _ = g?.session !== !1, T = g?.persisted === !0; + _ && this._authCoordinator.clearSession(), T && this._strategyManager.clearAll(); + }, y.prototype.run = function() { + return d(this, void 0, void 0, function() { + return o(this, function(g) { + switch (g.label) { + case 0: + return [4, this._wasmManager.run()]; + case 1: + return g.sent(), [4, this._wasmManager.waitTilReady()]; + case 2: + return g.sent(), [2]; + } + }); + }); + }, y; + })(); + O.default = v; + }, 4038(N, O, E) { + var h = this && this.__awaiter || function(e, t, c, s) { + return new (c || (c = Promise))(function(u, p) { + function l(g) { + try { + y(s.next(g)); + } catch (_) { + p(_); + } + } + function v(g) { + try { + y(s.throw(g)); + } catch (_) { + p(_); + } + } + function y(g) { + var _; + g.done ? u(g.value) : (_ = g.value, _ instanceof c ? _ : new c(function(T) { + T(_); + })).then(l, v); + } + y((s = s.apply(e, t || [])).next()); + }); + }, d = this && this.__generator || function(e, t) { + var c, s, u, p = { label: 0, sent: function() { + if (1 & u[0]) throw u[1]; + return u[1]; + }, trys: [], ops: [] }, l = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return l.next = v(0), l.throw = v(1), l.return = v(2), typeof Symbol == "function" && (l[Symbol.iterator] = function() { + return this; + }), l; + function v(y) { + return function(g) { + return (function(_) { + if (c) throw new TypeError("Generator is already executing."); + for (; l && (l = 0, _[0] && (p = 0)), p; ) try { + if (c = 1, s && (u = 2 & _[0] ? s.return : _[0] ? s.throw || ((u = s.return) && u.call(s), 0) : s.next) && !(u = u.call(s, _[1])).done) return u; + switch (s = 0, u && (_ = [2 & _[0], u.value]), _[0]) { + case 0: + case 1: + u = _; + break; + case 4: + return p.label++, { value: _[1], done: !1 }; + case 5: + p.label++, s = _[1], _ = [0]; + continue; + case 7: + _ = p.ops.pop(), p.trys.pop(); + continue; + default: + if (!((u = (u = p.trys).length > 0 && u[u.length - 1]) || _[0] !== 6 && _[0] !== 2)) { + p = 0; + continue; + } + if (_[0] === 3 && (!u || _[1] > u[0] && _[1] < u[3])) { + p.label = _[1]; + break; + } + if (_[0] === 6 && p.label < u[1]) { + p.label = u[1], u = _; + break; + } + if (u && p.label < u[2]) { + p.label = u[2], p.ops.push(_); + break; + } + u[2] && p.ops.pop(), p.trys.pop(); + continue; + } + _ = t.call(e, p); + } catch (T) { + _ = [6, T], s = 0; + } finally { + c = u = 0; + } + if (5 & _[0]) throw _[1]; + return { value: _[0] ? _[1] : void 0, done: !0 }; + })([y, g]); + }; + } + }, o = this && this.__importDefault || function(e) { + return e && e.__esModule ? e : { default: e }; + }; + Object.defineProperty(O, "__esModule", { value: !0 }), O.DEFAULT_CONFIG = void 0; + var f = E(3318), a = E(4717), i = o(E(5820)), n = E(254); + O.DEFAULT_CONFIG = { wasmClientCode: "https://lightning.engineering/lnc-v0.3.6-alpha.wasm", namespace: "default", serverHost: "mailbox.terminal.lightning.today:443" }; + var r = (function() { + function e(t) { + var c = this, s = Object.assign({}, O.DEFAULT_CONFIG, t); + s.credentialStore ? this.credentials = s.credentialStore : this.credentials = new i.default(s.namespace, s.password), !this.credentials.isPaired && s.serverHost && (this.credentials.serverHost = s.serverHost), s.pairingPhrase && (this.credentials.pairingPhrase = s.pairingPhrase), this.wasmManager = new n.WasmManager(s.namespace, s.wasmClientCode, { onLocalKeyCreated: function(u) { + c.credentials.localKey = u; + }, onRemoteKeyReceived: function(u) { + c.credentials.remoteKey = u; + } }), this.lnd = new f.LndApi(a.createRpc, this), this.loop = new f.LoopApi(a.createRpc, this), this.pool = new f.PoolApi(a.createRpc, this), this.faraday = new f.FaradayApi(a.createRpc, this), this.tapd = new f.TaprootAssetsApi(a.createRpc, this), this.lit = new f.LitApi(a.createRpc, this); + } + return Object.defineProperty(e.prototype, "isReady", { get: function() { + return this.wasmManager.isReady; + }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isConnected", { get: function() { + return this.wasmManager.isConnected; + }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "status", { get: function() { + return this.wasmManager.status; + }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "expiry", { get: function() { + return this.wasmManager.expiry; + }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isReadOnly", { get: function() { + return this.wasmManager.isReadOnly; + }, enumerable: !1, configurable: !0 }), e.prototype.hasPerms = function(t) { + return this.wasmManager.hasPerms(t); + }, e.prototype.preload = function() { + return h(this, void 0, void 0, function() { + return d(this, function(t) { + switch (t.label) { + case 0: + return [4, this.wasmManager.preload()]; + case 1: + return t.sent(), [2]; + } + }); + }); + }, e.prototype.run = function() { + return h(this, void 0, void 0, function() { + return d(this, function(t) { + switch (t.label) { + case 0: + return [4, this.wasmManager.run()]; + case 1: + return t.sent(), [2]; + } + }); + }); + }, e.prototype.connect = function() { + return h(this, void 0, void 0, function() { + var t; + return d(this, function(c) { + switch (c.label) { + case 0: + return t = { pairingPhrase: this.credentials.pairingPhrase, serverHost: this.credentials.serverHost, localKey: this.credentials.localKey || "", remoteKey: this.credentials.remoteKey || "" }, [4, this.wasmManager.connect(t)]; + case 1: + return c.sent(), this.credentials.password && this.credentials.clear(!0), [2]; + } + }); + }); + }, e.prototype.disconnect = function() { + this.wasmManager.disconnect(); + }, e.prototype.waitTilReady = function() { + return h(this, void 0, void 0, function() { + return d(this, function(t) { + switch (t.label) { + case 0: + return [4, this.wasmManager.waitTilReady()]; + case 1: + return t.sent(), [2]; + } + }); + }); + }, e.prototype.request = function(t, c) { + return this.wasmManager.request(t, c); + }, e.prototype.subscribe = function(t, c, s, u) { + this.wasmManager.subscribe(t, c, s, u); + }, e; + })(); + O.default = r; + }, 2637(N, O, E) { + var h = this && this.__awaiter || function(a, i, n, r) { + return new (n || (n = Promise))(function(e, t) { + function c(p) { + try { + u(r.next(p)); + } catch (l) { + t(l); + } + } + function s(p) { + try { + u(r.throw(p)); + } catch (l) { + t(l); + } + } + function u(p) { + var l; + p.done ? e(p.value) : (l = p.value, l instanceof n ? l : new n(function(v) { + v(l); + })).then(c, s); + } + u((r = r.apply(a, i || [])).next()); + }); + }, d = this && this.__generator || function(a, i) { + var n, r, e, t = { label: 0, sent: function() { + if (1 & e[0]) throw e[1]; + return e[1]; + }, trys: [], ops: [] }, c = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return c.next = s(0), c.throw = s(1), c.return = s(2), typeof Symbol == "function" && (c[Symbol.iterator] = function() { + return this; + }), c; + function s(u) { + return function(p) { + return (function(l) { + if (n) throw new TypeError("Generator is already executing."); + for (; c && (c = 0, l[0] && (t = 0)), t; ) try { + if (n = 1, r && (e = 2 & l[0] ? r.return : l[0] ? r.throw || ((e = r.return) && e.call(r), 0) : r.next) && !(e = e.call(r, l[1])).done) return e; + switch (r = 0, e && (l = [2 & l[0], e.value]), l[0]) { + case 0: + case 1: + e = l; + break; + case 4: + return t.label++, { value: l[1], done: !1 }; + case 5: + t.label++, r = l[1], l = [0]; + continue; + case 7: + l = t.ops.pop(), t.trys.pop(); + continue; + default: + if (!((e = (e = t.trys).length > 0 && e[e.length - 1]) || l[0] !== 6 && l[0] !== 2)) { + t = 0; + continue; + } + if (l[0] === 3 && (!e || l[1] > e[0] && l[1] < e[3])) { + t.label = l[1]; + break; + } + if (l[0] === 6 && t.label < e[1]) { + t.label = e[1], e = l; + break; + } + if (e && t.label < e[2]) { + t.label = e[2], t.ops.push(l); + break; + } + e[2] && t.ops.pop(), t.trys.pop(); + continue; + } + l = i.call(a, t); + } catch (v) { + l = [6, v], r = 0; + } finally { + n = e = 0; + } + if (5 & l[0]) throw l[1]; + return { value: l[0] ? l[1] : void 0, done: !0 }; + })([u, p]); + }; + } + }; + Object.defineProperty(O, "__esModule", { value: !0 }), O.BaseCredentialRepository = void 0; + var o = (0, E(9764).createLogger)("CredentialRepository"), f = (function() { + function a(i) { + this.namespace = i, this.credentials = /* @__PURE__ */ new Map(); + } + return Object.defineProperty(a.prototype, "hasAnyCredentials", { get: function() { + return this.loadedCredentials.size > 0; + }, enumerable: !1, configurable: !0 }), a.prototype.removeCredential = function(i) { + return h(this, void 0, void 0, function() { + return d(this, function(n) { + return this.remove(i), [2]; + }); + }); + }, a.prototype.hasCredential = function(i) { + return this.loadedCredentials.has(i); + }, a.prototype.clear = function() { + this.credentials.clear(), this.save(); + }, Object.defineProperty(a.prototype, "storageKey", { get: function() { + return "".concat("lnc-web:").concat(this.namespace); + }, enumerable: !1, configurable: !0 }), Object.defineProperty(a.prototype, "loadedCredentials", { get: function() { + return this.credentials.size === 0 && this.load(), this.credentials; + }, enumerable: !1, configurable: !0 }), a.prototype.get = function(i) { + var n; + return (n = this.loadedCredentials.get(i)) !== null && n !== void 0 ? n : void 0; + }, a.prototype.set = function(i, n) { + this.credentials.set(i, n), this.save(i); + }, a.prototype.remove = function(i) { + this.credentials.delete(i), this.save(); + }, a.prototype.save = function(i) { + if (globalThis.localStorage !== void 0) if (this.credentials.size !== 0) { + var n = Object.fromEntries(this.credentials.entries()), r = i ? " (".concat(i, " updated)") : ""; + o.info("Saving credentials to localStorage".concat(r)), globalThis.localStorage.setItem(this.storageKey, JSON.stringify(n)); + } else globalThis.localStorage.removeItem(this.storageKey); + }, a.prototype.load = function() { + if (globalThis.localStorage !== void 0) { + var i = globalThis.localStorage.getItem(this.storageKey); + if (i) try { + var n = JSON.parse(i); + this.credentials = new Map(Object.entries(n)), o.info("loaded credentials from localStorage"); + } catch (r) { + o.error("Failed to parse cached credentials for ".concat(this.namespace, ":"), r); + } + } + }, a; + })(); + O.BaseCredentialRepository = f; + }, 4279(N, O, E) { + var h, d = this && this.__extends || (h = function(e, t) { + return h = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(c, s) { + c.__proto__ = s; + } || function(c, s) { + for (var u in s) Object.prototype.hasOwnProperty.call(s, u) && (c[u] = s[u]); + }, h(e, t); + }, function(e, t) { + if (typeof t != "function" && t !== null) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null"); + function c() { + this.constructor = e; + } + h(e, t), e.prototype = t === null ? Object.create(t) : (c.prototype = t.prototype, new c()); + }), o = this && this.__awaiter || function(e, t, c, s) { + return new (c || (c = Promise))(function(u, p) { + function l(g) { + try { + y(s.next(g)); + } catch (_) { + p(_); + } + } + function v(g) { + try { + y(s.throw(g)); + } catch (_) { + p(_); + } + } + function y(g) { + var _; + g.done ? u(g.value) : (_ = g.value, _ instanceof c ? _ : new c(function(T) { + T(_); + })).then(l, v); + } + y((s = s.apply(e, t || [])).next()); + }); + }, f = this && this.__generator || function(e, t) { + var c, s, u, p = { label: 0, sent: function() { + if (1 & u[0]) throw u[1]; + return u[1]; + }, trys: [], ops: [] }, l = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return l.next = v(0), l.throw = v(1), l.return = v(2), typeof Symbol == "function" && (l[Symbol.iterator] = function() { + return this; + }), l; + function v(y) { + return function(g) { + return (function(_) { + if (c) throw new TypeError("Generator is already executing."); + for (; l && (l = 0, _[0] && (p = 0)), p; ) try { + if (c = 1, s && (u = 2 & _[0] ? s.return : _[0] ? s.throw || ((u = s.return) && u.call(s), 0) : s.next) && !(u = u.call(s, _[1])).done) return u; + switch (s = 0, u && (_ = [2 & _[0], u.value]), _[0]) { + case 0: + case 1: + u = _; + break; + case 4: + return p.label++, { value: _[1], done: !1 }; + case 5: + p.label++, s = _[1], _ = [0]; + continue; + case 7: + _ = p.ops.pop(), p.trys.pop(); + continue; + default: + if (!((u = (u = p.trys).length > 0 && u[u.length - 1]) || _[0] !== 6 && _[0] !== 2)) { + p = 0; + continue; + } + if (_[0] === 3 && (!u || _[1] > u[0] && _[1] < u[3])) { + p.label = _[1]; + break; + } + if (_[0] === 6 && p.label < u[1]) { + p.label = u[1], u = _; + break; + } + if (u && p.label < u[2]) { + p.label = u[2], p.ops.push(_); + break; + } + u[2] && p.ops.pop(), p.trys.pop(); + continue; + } + _ = t.call(e, p); + } catch (T) { + _ = [6, T], s = 0; + } finally { + c = u = 0; + } + if (5 & _[0]) throw _[1]; + return { value: _[0] ? _[1] : void 0, done: !0 }; + })([y, g]); + }; + } + }; + Object.defineProperty(O, "__esModule", { value: !0 }), O.PasskeyCredentialRepository = void 0; + var a = E(9764), i = E(2637), n = (0, a.createLogger)("PasskeyCredentialRepository"), r = (function(e) { + function t(c, s) { + var u = e.call(this, c) || this; + return u.encryption = s, u; + } + return d(t, e), t.prototype.unlock = function(c) { + return o(this, void 0, void 0, function() { + var s, u, p, l; + return f(this, function(v) { + switch (v.label) { + case 0: + if (c.method !== "passkey") throw new Error("Passkey repository requires passkey unlock method"); + return s = (p = this.get("passkeyCredentialId")) !== null && p !== void 0 ? p : c.credentialId, [4, this.encryption.unlock({ method: "passkey", credentialId: s, createIfMissing: (l = c.createIfMissing) !== null && l !== void 0 && l })]; + case 1: + return v.sent(), this.encryption.isUnlocked && (u = this.encryption.getCredentialId(), this.set("passkeyCredentialId", u)), [2]; + } + }); + }); + }, t.prototype.getCredential = function(c) { + return o(this, void 0, void 0, function() { + var s, u; + return f(this, function(p) { + switch (p.label) { + case 0: + if (!(s = this.get(c))) return [2, void 0]; + p.label = 1; + case 1: + return p.trys.push([1, 3, , 4]), [4, this.encryption.decrypt(s)]; + case 2: + return [2, p.sent()]; + case 3: + return u = p.sent(), n.error("Failed to decrypt credential ".concat(c, ":"), u), [2, void 0]; + case 4: + return [2]; + } + }); + }); + }, t.prototype.setCredential = function(c, s) { + return o(this, void 0, void 0, function() { + var u; + return f(this, function(p) { + switch (p.label) { + case 0: + if (!this.encryption.isUnlocked) throw new Error("Repository is locked. Call unlock() first."); + return [4, this.encryption.encrypt(s)]; + case 1: + return u = p.sent(), this.set(c, u), [2]; + } + }); + }); + }, Object.defineProperty(t.prototype, "isUnlocked", { get: function() { + return this.encryption.isUnlocked; + }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasStoredAuthData", { get: function() { + return this.hasCredential("passkeyCredentialId"); + }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "storedCredentialId", { get: function() { + return this.get("passkeyCredentialId"); + }, enumerable: !1, configurable: !0 }), t.prototype.lock = function() { + this.encryption.lock(); + }, t; + })(i.BaseCredentialRepository); + O.PasskeyCredentialRepository = r; + }, 2672(N, O, E) { + var h, d = this && this.__extends || (h = function(e, t) { + return h = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(c, s) { + c.__proto__ = s; + } || function(c, s) { + for (var u in s) Object.prototype.hasOwnProperty.call(s, u) && (c[u] = s[u]); + }, h(e, t); + }, function(e, t) { + if (typeof t != "function" && t !== null) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null"); + function c() { + this.constructor = e; + } + h(e, t), e.prototype = t === null ? Object.create(t) : (c.prototype = t.prototype, new c()); + }), o = this && this.__awaiter || function(e, t, c, s) { + return new (c || (c = Promise))(function(u, p) { + function l(g) { + try { + y(s.next(g)); + } catch (_) { + p(_); + } + } + function v(g) { + try { + y(s.throw(g)); + } catch (_) { + p(_); + } + } + function y(g) { + var _; + g.done ? u(g.value) : (_ = g.value, _ instanceof c ? _ : new c(function(T) { + T(_); + })).then(l, v); + } + y((s = s.apply(e, t || [])).next()); + }); + }, f = this && this.__generator || function(e, t) { + var c, s, u, p = { label: 0, sent: function() { + if (1 & u[0]) throw u[1]; + return u[1]; + }, trys: [], ops: [] }, l = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return l.next = v(0), l.throw = v(1), l.return = v(2), typeof Symbol == "function" && (l[Symbol.iterator] = function() { + return this; + }), l; + function v(y) { + return function(g) { + return (function(_) { + if (c) throw new TypeError("Generator is already executing."); + for (; l && (l = 0, _[0] && (p = 0)), p; ) try { + if (c = 1, s && (u = 2 & _[0] ? s.return : _[0] ? s.throw || ((u = s.return) && u.call(s), 0) : s.next) && !(u = u.call(s, _[1])).done) return u; + switch (s = 0, u && (_ = [2 & _[0], u.value]), _[0]) { + case 0: + case 1: + u = _; + break; + case 4: + return p.label++, { value: _[1], done: !1 }; + case 5: + p.label++, s = _[1], _ = [0]; + continue; + case 7: + _ = p.ops.pop(), p.trys.pop(); + continue; + default: + if (!((u = (u = p.trys).length > 0 && u[u.length - 1]) || _[0] !== 6 && _[0] !== 2)) { + p = 0; + continue; + } + if (_[0] === 3 && (!u || _[1] > u[0] && _[1] < u[3])) { + p.label = _[1]; + break; + } + if (_[0] === 6 && p.label < u[1]) { + p.label = u[1], u = _; + break; + } + if (u && p.label < u[2]) { + p.label = u[2], p.ops.push(_); + break; + } + u[2] && p.ops.pop(), p.trys.pop(); + continue; + } + _ = t.call(e, p); + } catch (T) { + _ = [6, T], s = 0; + } finally { + c = u = 0; + } + if (5 & _[0]) throw _[1]; + return { value: _[0] ? _[1] : void 0, done: !0 }; + })([y, g]); + }; + } + }; + Object.defineProperty(O, "__esModule", { value: !0 }), O.PasswordCredentialRepository = void 0; + var a = E(9764), i = E(2637), n = (0, a.createLogger)("PasswordCredentialRepository"), r = (function(e) { + function t(c, s) { + var u = e.call(this, c) || this; + return u.encryption = s, u; + } + return d(t, e), Object.defineProperty(t.prototype, "isUnlocked", { get: function() { + return this.encryption.isUnlocked; + }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasStoredAuthData", { get: function() { + return this.hasCredential("salt") && this.hasCredential("cipher"); + }, enumerable: !1, configurable: !0 }), t.prototype.unlock = function(c) { + return o(this, void 0, void 0, function() { + var s, u; + return f(this, function(p) { + switch (p.label) { + case 0: + if (c.method !== "password") throw new Error("Password repository requires password unlock method"); + return s = this.get("salt"), u = this.get("cipher"), [4, this.encryption.unlock({ method: "password", password: c.password, salt: s, cipher: u })]; + case 1: + return p.sent(), s || (this.set("salt", this.encryption.getSalt()), this.set("cipher", this.encryption.createTestCipher())), [2]; + } + }); + }); + }, t.prototype.getCredential = function(c) { + return o(this, void 0, void 0, function() { + var s, u; + return f(this, function(p) { + switch (p.label) { + case 0: + if (!(s = this.get(c))) return n.debug("No encrypted credential found for ".concat(c, " in ").concat(this.namespace)), [2, void 0]; + p.label = 1; + case 1: + return p.trys.push([1, 3, , 4]), [4, this.encryption.decrypt(s)]; + case 2: + return [2, p.sent()]; + case 3: + return u = p.sent(), n.error("Failed to decrypt credential ".concat(c, ":"), u), [2, void 0]; + case 4: + return [2]; + } + }); + }); + }, t.prototype.setCredential = function(c, s) { + return o(this, void 0, void 0, function() { + var u; + return f(this, function(p) { + switch (p.label) { + case 0: + if (!this.encryption.isUnlocked) throw new Error("Repository is locked. Call unlock() first."); + return [4, this.encryption.encrypt(s)]; + case 1: + return u = p.sent(), this.set(c, u), [2]; + } + }); + }); + }, t.prototype.lock = function() { + this.encryption.lock(); + }, t; + })(i.BaseCredentialRepository); + O.PasswordCredentialRepository = r; + }, 1313(N, O) { + var E = this && this.__awaiter || function(o, f, a, i) { + return new (a || (a = Promise))(function(n, r) { + function e(s) { + try { + c(i.next(s)); + } catch (u) { + r(u); + } + } + function t(s) { + try { + c(i.throw(s)); + } catch (u) { + r(u); + } + } + function c(s) { + var u; + s.done ? n(s.value) : (u = s.value, u instanceof a ? u : new a(function(p) { + p(u); + })).then(e, t); + } + c((i = i.apply(o, f || [])).next()); + }); + }, h = this && this.__generator || function(o, f) { + var a, i, n, r = { label: 0, sent: function() { + if (1 & n[0]) throw n[1]; + return n[1]; + }, trys: [], ops: [] }, e = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return e.next = t(0), e.throw = t(1), e.return = t(2), typeof Symbol == "function" && (e[Symbol.iterator] = function() { + return this; + }), e; + function t(c) { + return function(s) { + return (function(u) { + if (a) throw new TypeError("Generator is already executing."); + for (; e && (e = 0, u[0] && (r = 0)), r; ) try { + if (a = 1, i && (n = 2 & u[0] ? i.return : u[0] ? i.throw || ((n = i.return) && n.call(i), 0) : i.next) && !(n = n.call(i, u[1])).done) return n; + switch (i = 0, n && (u = [2 & u[0], n.value]), u[0]) { + case 0: + case 1: + n = u; + break; + case 4: + return r.label++, { value: u[1], done: !1 }; + case 5: + r.label++, i = u[1], u = [0]; + continue; + case 7: + u = r.ops.pop(), r.trys.pop(); + continue; + default: + if (!((n = (n = r.trys).length > 0 && n[n.length - 1]) || u[0] !== 6 && u[0] !== 2)) { + r = 0; + continue; + } + if (u[0] === 3 && (!n || u[1] > n[0] && u[1] < n[3])) { + r.label = u[1]; + break; + } + if (u[0] === 6 && r.label < n[1]) { + r.label = n[1], n = u; + break; + } + if (n && r.label < n[2]) { + r.label = n[2], r.ops.push(u); + break; + } + n[2] && r.ops.pop(), r.trys.pop(); + continue; + } + u = f.call(o, r); + } catch (p) { + u = [6, p], i = 0; + } finally { + a = n = 0; + } + if (5 & u[0]) throw u[1]; + return { value: u[0] ? u[1] : void 0, done: !0 }; + })([c, s]); + }; + } + }; + Object.defineProperty(O, "__esModule", { value: !0 }), O.CredentialsEncrypter = void 0; + var d = (function() { + function o(f) { + this.cryptoService = f; + } + return o.prototype.encrypt = function(f) { + return E(this, void 0, void 0, function() { + var a, i, n, r; + return h(this, function(e) { + switch (e.label) { + case 0: + return [4, this.cryptoService.generateRandomCredentialsKey()]; + case 1: + return a = e.sent(), [4, this.cryptoService.encryptCredentials(a, JSON.stringify(f))]; + case 2: + return i = e.sent(), n = i.ciphertextB64, r = i.ivB64, [2, { credentialsKey: a, ciphertextB64: n, ivB64: r }]; + } + }); + }); + }, o.prototype.decrypt = function(f) { + return E(this, void 0, void 0, function() { + var a, i, n, r, e; + return h(this, function(t) { + switch (t.label) { + case 0: + return a = f.credentialsKey, i = f.ciphertextB64, n = f.ivB64, [4, this.cryptoService.decryptCredentials(a, i, n)]; + case 1: + if (r = t.sent(), !((c = e = JSON.parse(r)) && typeof c == "object" && "localKey" in c && typeof c.localKey == "string" && "remoteKey" in c && typeof c.remoteKey == "string" && "pairingPhrase" in c && typeof c.pairingPhrase == "string" && "serverHost" in c && typeof c.serverHost == "string")) throw new Error("Decrypted credentials have an invalid shape"); + return [2, e]; + } + var c; + }); + }); + }, o; + })(); + O.CredentialsEncrypter = d; + }, 7027(N, O) { + var E = this && this.__awaiter || function(o, f, a, i) { + return new (a || (a = Promise))(function(n, r) { + function e(s) { + try { + c(i.next(s)); + } catch (u) { + r(u); + } + } + function t(s) { + try { + c(i.throw(s)); + } catch (u) { + r(u); + } + } + function c(s) { + var u; + s.done ? n(s.value) : (u = s.value, u instanceof a ? u : new a(function(p) { + p(u); + })).then(e, t); + } + c((i = i.apply(o, f || [])).next()); + }); + }, h = this && this.__generator || function(o, f) { + var a, i, n, r = { label: 0, sent: function() { + if (1 & n[0]) throw n[1]; + return n[1]; + }, trys: [], ops: [] }, e = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return e.next = t(0), e.throw = t(1), e.return = t(2), typeof Symbol == "function" && (e[Symbol.iterator] = function() { + return this; + }), e; + function t(c) { + return function(s) { + return (function(u) { + if (a) throw new TypeError("Generator is already executing."); + for (; e && (e = 0, u[0] && (r = 0)), r; ) try { + if (a = 1, i && (n = 2 & u[0] ? i.return : u[0] ? i.throw || ((n = i.return) && n.call(i), 0) : i.next) && !(n = n.call(i, u[1])).done) return n; + switch (i = 0, n && (u = [2 & u[0], n.value]), u[0]) { + case 0: + case 1: + n = u; + break; + case 4: + return r.label++, { value: u[1], done: !1 }; + case 5: + r.label++, i = u[1], u = [0]; + continue; + case 7: + u = r.ops.pop(), r.trys.pop(); + continue; + default: + if (!((n = (n = r.trys).length > 0 && n[n.length - 1]) || u[0] !== 6 && u[0] !== 2)) { + r = 0; + continue; + } + if (u[0] === 3 && (!n || u[1] > n[0] && u[1] < n[3])) { + r.label = u[1]; + break; + } + if (u[0] === 6 && r.label < n[1]) { + r.label = n[1], n = u; + break; + } + if (n && r.label < n[2]) { + r.label = n[2], r.ops.push(u); + break; + } + n[2] && r.ops.pop(), r.trys.pop(); + continue; + } + u = f.call(o, r); + } catch (p) { + u = [6, p], i = 0; + } finally { + a = n = 0; + } + if (5 & u[0]) throw u[1]; + return { value: u[0] ? u[1] : void 0, done: !0 }; + })([c, s]); + }; + } + }; + Object.defineProperty(O, "__esModule", { value: !0 }), O.KeyWrapper = void 0; + var d = (function() { + function o(f) { + this.cryptoService = f; + } + return o.prototype.wrapCredentialsKey = function(f, a, i) { + return E(this, void 0, void 0, function() { + var n, r; + return h(this, function(e) { + switch (e.label) { + case 0: + return [4, this.cryptoService.wrapWithDeviceKey(f, a)]; + case 1: + return n = e.sent(), [4, this.cryptoService.wrapWithOriginKey(f, i)]; + case 2: + return r = e.sent(), [2, { deviceWrap: n, originWrap: r }]; + } + }); + }); + }, o.prototype.unwrapCredentialsKey = function(f, a, i) { + return E(this, void 0, void 0, function() { + var n, r; + return h(this, function(e) { + switch (e.label) { + case 0: + return [4, this.cryptoService.unwrapWithDeviceKey(a, f.deviceWrap.keyB64, f.deviceWrap.ivB64)]; + case 1: + return n = e.sent(), [4, this.cryptoService.unwrapWithOriginKey(i, f.originWrap.keyB64, f.originWrap.ivB64)]; + case 2: + return r = e.sent(), [4, this.keysMatch(n, r)]; + case 3: + if (!e.sent()) throw new Error("Key unwrapping mismatch"); + return [2, n]; + } + }); + }); + }, o.prototype.keysMatch = function(f, a) { + return E(this, void 0, void 0, function() { + var i, n, r, e; + return h(this, function(t) { + switch (t.label) { + case 0: + return t.trys.push([0, 3, , 4]), i = new TextEncoder().encode("verification"), n = new Uint8Array(12), [4, crypto.subtle.encrypt({ name: "AES-GCM", iv: n }, f, i)]; + case 1: + return r = t.sent(), [4, crypto.subtle.encrypt({ name: "AES-GCM", iv: n }, a, i)]; + case 2: + return e = t.sent(), [2, this.arraysEqual(new Uint8Array(r), new Uint8Array(e))]; + case 3: + return t.sent(), [2, !1]; + case 4: + return [2]; + } + }); + }); + }, o.prototype.arraysEqual = function(f, a) { + if (f.length !== a.length) return !1; + for (var i = !0, n = 0; n < f.length; n++) f[n] !== a[n] && (i = !1); + return i; + }, o; + })(); + O.KeyWrapper = d; + }, 9124(N, O, E) { + var h = this && this.__awaiter || function(a, i, n, r) { + return new (n || (n = Promise))(function(e, t) { + function c(p) { + try { + u(r.next(p)); + } catch (l) { + t(l); + } + } + function s(p) { + try { + u(r.throw(p)); + } catch (l) { + t(l); + } + } + function u(p) { + var l; + p.done ? e(p.value) : (l = p.value, l instanceof n ? l : new n(function(v) { + v(l); + })).then(c, s); + } + u((r = r.apply(a, i || [])).next()); + }); + }, d = this && this.__generator || function(a, i) { + var n, r, e, t = { label: 0, sent: function() { + if (1 & e[0]) throw e[1]; + return e[1]; + }, trys: [], ops: [] }, c = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return c.next = s(0), c.throw = s(1), c.return = s(2), typeof Symbol == "function" && (c[Symbol.iterator] = function() { + return this; + }), c; + function s(u) { + return function(p) { + return (function(l) { + if (n) throw new TypeError("Generator is already executing."); + for (; c && (c = 0, l[0] && (t = 0)), t; ) try { + if (n = 1, r && (e = 2 & l[0] ? r.return : l[0] ? r.throw || ((e = r.return) && e.call(r), 0) : r.next) && !(e = e.call(r, l[1])).done) return e; + switch (r = 0, e && (l = [2 & l[0], e.value]), l[0]) { + case 0: + case 1: + e = l; + break; + case 4: + return t.label++, { value: l[1], done: !1 }; + case 5: + t.label++, r = l[1], l = [0]; + continue; + case 7: + l = t.ops.pop(), t.trys.pop(); + continue; + default: + if (!((e = (e = t.trys).length > 0 && e[e.length - 1]) || l[0] !== 6 && l[0] !== 2)) { + t = 0; + continue; + } + if (l[0] === 3 && (!e || l[1] > e[0] && l[1] < e[3])) { + t.label = l[1]; + break; + } + if (l[0] === 6 && t.label < e[1]) { + t.label = e[1], e = l; + break; + } + if (e && t.label < e[2]) { + t.label = e[2], t.ops.push(l); + break; + } + e[2] && t.ops.pop(), t.trys.pop(); + continue; + } + l = i.call(a, t); + } catch (v) { + l = [6, v], r = 0; + } finally { + n = e = 0; + } + if (5 & l[0]) throw l[1]; + return { value: l[0] ? l[1] : void 0, done: !0 }; + })([u, p]); + }; + } + }; + Object.defineProperty(O, "__esModule", { value: !0 }); + var o = E(1389), f = (function() { + function a() { + } + return a.prototype.generateRandomCredentialsKey = function() { + return h(this, void 0, void 0, function() { + var i; + return d(this, function(n) { + switch (n.label) { + case 0: + return n.trys.push([0, 2, , 3]), [4, crypto.subtle.generateKey({ name: "AES-GCM", length: 256 }, !0, ["encrypt", "decrypt"])]; + case 1: + return [2, n.sent()]; + case 2: + throw i = n.sent(), new Error("[CryptoService] Credentials key generation failed: ".concat(i.message)); + case 3: + return [2]; + } + }); + }); + }, a.prototype.encryptCredentials = function(i, n) { + return h(this, void 0, void 0, function() { + var r, e, t, c, s; + return d(this, function(u) { + switch (u.label) { + case 0: + return u.trys.push([0, 2, , 3]), r = crypto.getRandomValues(new Uint8Array(12)), e = new TextEncoder(), t = e.encode(n), [4, crypto.subtle.encrypt({ name: "AES-GCM", iv: r }, i, t)]; + case 1: + return c = u.sent(), [2, { ciphertextB64: (0, o.arrayBufferToBase64)(c), ivB64: (0, o.arrayBufferToBase64)(r.buffer) }]; + case 2: + throw s = u.sent(), new Error("[CryptoService] Credential encryption failed: ".concat(s.message)); + case 3: + return [2]; + } + }); + }); + }, a.prototype.decryptCredentials = function(i, n, r) { + return h(this, void 0, void 0, function() { + var e, t, c, s; + return d(this, function(u) { + switch (u.label) { + case 0: + return u.trys.push([0, 2, , 3]), e = (0, o.base64ToArrayBuffer)(n), t = (0, o.base64ToArrayBuffer)(r), [4, crypto.subtle.decrypt({ name: "AES-GCM", iv: t }, i, e)]; + case 1: + return c = u.sent(), [2, new TextDecoder().decode(c)]; + case 2: + throw s = u.sent(), new Error("[CryptoService] Credential decryption failed: ".concat(s.message)); + case 3: + return [2]; + } + }); + }); + }, a.prototype.wrapWithDeviceKey = function(i, n) { + return h(this, void 0, void 0, function() { + var r, e, t; + return d(this, function(c) { + switch (c.label) { + case 0: + return c.trys.push([0, 2, , 3]), r = crypto.getRandomValues(new Uint8Array(12)), [4, crypto.subtle.wrapKey("raw", i, n, { name: "AES-GCM", iv: r })]; + case 1: + return e = c.sent(), [2, { keyB64: (0, o.arrayBufferToBase64)(e), ivB64: (0, o.arrayBufferToBase64)(r.buffer) }]; + case 2: + throw t = c.sent(), new Error("[CryptoService] Device key wrapping failed: ".concat(t.message)); + case 3: + return [2]; + } + }); + }); + }, a.prototype.unwrapWithDeviceKey = function(i, n, r) { + return h(this, void 0, void 0, function() { + var e, t, c; + return d(this, function(s) { + switch (s.label) { + case 0: + return s.trys.push([0, 2, , 3]), e = (0, o.base64ToArrayBuffer)(n), t = (0, o.base64ToArrayBuffer)(r), [4, crypto.subtle.unwrapKey("raw", e, i, { name: "AES-GCM", iv: t }, { name: "AES-GCM", length: 256 }, !1, ["encrypt", "decrypt"])]; + case 1: + return [2, s.sent()]; + case 2: + throw c = s.sent(), new Error("[CryptoService] Device key unwrapping failed: ".concat(c.message)); + case 3: + return [2]; + } + }); + }); + }, a.prototype.wrapWithOriginKey = function(i, n) { + return h(this, void 0, void 0, function() { + var r, e, t; + return d(this, function(c) { + switch (c.label) { + case 0: + return c.trys.push([0, 2, , 3]), r = crypto.getRandomValues(new Uint8Array(12)), [4, crypto.subtle.wrapKey("raw", i, n, { name: "AES-GCM", iv: r })]; + case 1: + return e = c.sent(), [2, { keyB64: (0, o.arrayBufferToBase64)(e), ivB64: (0, o.arrayBufferToBase64)(r.buffer) }]; + case 2: + throw t = c.sent(), new Error("[CryptoService] Origin key wrapping failed: ".concat(t.message)); + case 3: + return [2]; + } + }); + }); + }, a.prototype.unwrapWithOriginKey = function(i, n, r) { + return h(this, void 0, void 0, function() { + var e, t, c; + return d(this, function(s) { + switch (s.label) { + case 0: + return s.trys.push([0, 2, , 3]), e = (0, o.base64ToArrayBuffer)(n), t = (0, o.base64ToArrayBuffer)(r), [4, crypto.subtle.unwrapKey("raw", e, i, { name: "AES-GCM", iv: t }, { name: "AES-GCM", length: 256 }, !1, ["encrypt", "decrypt"])]; + case 1: + return [2, s.sent()]; + case 2: + throw c = s.sent(), new Error("[CryptoService] Origin key unwrapping failed: ".concat(c.message)); + case 3: + return [2]; + } + }); + }); + }, a; + })(); + O.default = f; + }, 9242(N, O, E) { + var h = this && this.__awaiter || function(a, i, n, r) { + return new (n || (n = Promise))(function(e, t) { + function c(p) { + try { + u(r.next(p)); + } catch (l) { + t(l); + } + } + function s(p) { + try { + u(r.throw(p)); + } catch (l) { + t(l); + } + } + function u(p) { + var l; + p.done ? e(p.value) : (l = p.value, l instanceof n ? l : new n(function(v) { + v(l); + })).then(c, s); + } + u((r = r.apply(a, i || [])).next()); + }); + }, d = this && this.__generator || function(a, i) { + var n, r, e, t = { label: 0, sent: function() { + if (1 & e[0]) throw e[1]; + return e[1]; + }, trys: [], ops: [] }, c = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return c.next = s(0), c.throw = s(1), c.return = s(2), typeof Symbol == "function" && (c[Symbol.iterator] = function() { + return this; + }), c; + function s(u) { + return function(p) { + return (function(l) { + if (n) throw new TypeError("Generator is already executing."); + for (; c && (c = 0, l[0] && (t = 0)), t; ) try { + if (n = 1, r && (e = 2 & l[0] ? r.return : l[0] ? r.throw || ((e = r.return) && e.call(r), 0) : r.next) && !(e = e.call(r, l[1])).done) return e; + switch (r = 0, e && (l = [2 & l[0], e.value]), l[0]) { + case 0: + case 1: + e = l; + break; + case 4: + return t.label++, { value: l[1], done: !1 }; + case 5: + t.label++, r = l[1], l = [0]; + continue; + case 7: + l = t.ops.pop(), t.trys.pop(); + continue; + default: + if (!((e = (e = t.trys).length > 0 && e[e.length - 1]) || l[0] !== 6 && l[0] !== 2)) { + t = 0; + continue; + } + if (l[0] === 3 && (!e || l[1] > e[0] && l[1] < e[3])) { + t.label = l[1]; + break; + } + if (l[0] === 6 && t.label < e[1]) { + t.label = e[1], e = l; + break; + } + if (e && t.label < e[2]) { + t.label = e[2], t.ops.push(l); + break; + } + e[2] && t.ops.pop(), t.trys.pop(); + continue; + } + l = i.call(a, t); + } catch (v) { + l = [6, v], r = 0; + } finally { + n = e = 0; + } + if (5 & l[0]) throw l[1]; + return { value: l[0] ? l[1] : void 0, done: !0 }; + })([u, p]); + }; + } + }; + Object.defineProperty(O, "__esModule", { value: !0 }), O.DeviceBinder = void 0; + var o = E(1389), f = (function() { + function a() { + } + return a.prototype.generateFingerprint = function() { + return h(this, void 0, void 0, function() { + var i, n, r, e, t; + return d(this, function(c) { + switch (c.label) { + case 0: + if (!(!((e = globalThis.screen) === null || e === void 0) && e.width) || !(!((t = globalThis.screen) === null || t === void 0) && t.height)) throw new Error("Device fingerprinting requires a browser environment with screen access"); + return i = "".concat(globalThis.screen.width, "x").concat(globalThis.screen.height, "x").concat(globalThis.screen.colorDepth), n = Intl.DateTimeFormat().resolvedOptions().timeZone, [4, this.generateCanvasFingerprint()]; + case 1: + return r = c.sent(), [2, this.hashFingerprint("".concat(i, "|").concat(n, "|").concat(r))]; + } + }); + }); + }, a.prototype.deriveSessionKey = function(i, n) { + return h(this, void 0, void 0, function() { + var r, e; + return d(this, function(t) { + switch (t.label) { + case 0: + return r = new TextEncoder().encode(i), [4, crypto.subtle.importKey("raw", r, "HKDF", !1, ["deriveKey"])]; + case 1: + return e = t.sent(), [2, crypto.subtle.deriveKey({ name: "HKDF", hash: "SHA-256", salt: new TextEncoder().encode(n), info: new TextEncoder().encode("lnc-session-device-key") }, e, { name: "AES-GCM", length: 256 }, !1, ["wrapKey", "unwrapKey"])]; + } + }); + }); + }, a.prototype.generateCanvasFingerprint = function() { + return h(this, void 0, void 0, function() { + var i, n, r, e; + return d(this, function(t) { + switch (t.label) { + case 0: + if (t.trys.push([0, 2, , 3]), i = document.createElement("canvas"), !(n = i.getContext("2d"))) throw new Error("Canvas 2D context unavailable"); + return n.textBaseline = "top", n.font = "14px Arial", n.fillText("Device fingerprint test", 2, 2), r = i.toDataURL(), [4, crypto.subtle.digest("SHA-256", new TextEncoder().encode(r))]; + case 1: + return e = t.sent(), [2, (0, o.arrayBufferToHex)(e)]; + case 2: + throw t.sent(), new Error("Canvas fingerprinting required for session security"); + case 3: + return [2]; + } + }); + }); + }, a.prototype.hashFingerprint = function(i) { + return h(this, void 0, void 0, function() { + var n; + return d(this, function(r) { + switch (r.label) { + case 0: + return [4, crypto.subtle.digest("SHA-256", new TextEncoder().encode(i))]; + case 1: + return n = r.sent(), [2, (0, o.arrayBufferToHex)(n)]; + } + }); + }); + }, a; + })(); + O.DeviceBinder = f; + }, 1228(N, O, E) { + var h = this && this.__awaiter || function(a, i, n, r) { + return new (n || (n = Promise))(function(e, t) { + function c(p) { + try { + u(r.next(p)); + } catch (l) { + t(l); + } + } + function s(p) { + try { + u(r.throw(p)); + } catch (l) { + t(l); + } + } + function u(p) { + var l; + p.done ? e(p.value) : (l = p.value, l instanceof n ? l : new n(function(v) { + v(l); + })).then(c, s); + } + u((r = r.apply(a, i || [])).next()); + }); + }, d = this && this.__generator || function(a, i) { + var n, r, e, t = { label: 0, sent: function() { + if (1 & e[0]) throw e[1]; + return e[1]; + }, trys: [], ops: [] }, c = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return c.next = s(0), c.throw = s(1), c.return = s(2), typeof Symbol == "function" && (c[Symbol.iterator] = function() { + return this; + }), c; + function s(u) { + return function(p) { + return (function(l) { + if (n) throw new TypeError("Generator is already executing."); + for (; c && (c = 0, l[0] && (t = 0)), t; ) try { + if (n = 1, r && (e = 2 & l[0] ? r.return : l[0] ? r.throw || ((e = r.return) && e.call(r), 0) : r.next) && !(e = e.call(r, l[1])).done) return e; + switch (r = 0, e && (l = [2 & l[0], e.value]), l[0]) { + case 0: + case 1: + e = l; + break; + case 4: + return t.label++, { value: l[1], done: !1 }; + case 5: + t.label++, r = l[1], l = [0]; + continue; + case 7: + l = t.ops.pop(), t.trys.pop(); + continue; + default: + if (!((e = (e = t.trys).length > 0 && e[e.length - 1]) || l[0] !== 6 && l[0] !== 2)) { + t = 0; + continue; + } + if (l[0] === 3 && (!e || l[1] > e[0] && l[1] < e[3])) { + t.label = l[1]; + break; + } + if (l[0] === 6 && t.label < e[1]) { + t.label = e[1], e = l; + break; + } + if (e && t.label < e[2]) { + t.label = e[2], t.ops.push(l); + break; + } + e[2] && t.ops.pop(), t.trys.pop(); + continue; + } + l = i.call(a, t); + } catch (v) { + l = [6, v], r = 0; + } finally { + n = e = 0; + } + if (5 & l[0]) throw l[1]; + return { value: l[0] ? l[1] : void 0, done: !0 }; + })([u, p]); + }; + } + }; + Object.defineProperty(O, "__esModule", { value: !0 }), O.OriginKeyManager = void 0; + var o = (0, E(9764).createLogger)("OriginKeyManager"), f = (function() { + function a(i) { + this.dbName = "lnc-origin-keys", this.dbVersion = 1, this.storeName = "keys", this.namespace = i; + } + return a.prototype.isExpired = function(i) { + return Date.now() > i; + }, a.prototype.getOrCreateOriginKey = function() { + return h(this, void 0, void 0, function() { + var i, n, r, e; + return d(this, function(t) { + switch (t.label) { + case 0: + return t.trys.push([0, 4, , 5]), [4, this.loadOriginKey()]; + case 1: + return (i = t.sent()) && !this.isExpired(i.expiresAt) ? [2, i] : [4, crypto.subtle.generateKey({ name: "AES-GCM", length: 256 }, !1, ["wrapKey", "unwrapKey"])]; + case 2: + return n = t.sent(), r = Date.now() + 864e5, [4, this.saveOriginKey(n, r)]; + case 3: + return t.sent(), [2, { originKey: n, expiresAt: r }]; + case 4: + throw e = t.sent(), new Error("Failed to get or create origin key: ".concat(e.message)); + case 5: + return [2]; + } + }); + }); + }, a.prototype.loadOriginKey = function() { + return h(this, void 0, void 0, function() { + var i, n = this; + return d(this, function(r) { + switch (r.label) { + case 0: + return r.trys.push([0, 2, , 3]), [4, this.withDB(function(e) { + return new Promise(function(t) { + var c = e.transaction([n.storeName], "readonly").objectStore(n.storeName).get(n.namespace); + c.onsuccess = function() { + var s = c.result; + s && s.originKey && typeof s.originKey == "object" && !Array.isArray(s.originKey) && typeof s.expiresAt == "number" && Number.isFinite(s.expiresAt) ? t({ originKey: s.originKey, expiresAt: s.expiresAt }) : t(void 0); + }, c.onerror = function() { + return t(void 0); + }; + }); + })]; + case 1: + return [2, r.sent()]; + case 2: + return i = r.sent(), o.error("Failed to load origin key: ".concat(i.message)), [2, void 0]; + case 3: + return [2]; + } + }); + }); + }, a.prototype.saveOriginKey = function(i, n) { + return h(this, void 0, void 0, function() { + var r, e = this; + return d(this, function(t) { + switch (t.label) { + case 0: + return t.trys.push([0, 2, , 3]), [4, this.withDB(function(c) { + var s = { namespace: e.namespace, originKey: i, expiresAt: n, createdAt: Date.now() }; + return new Promise(function(u, p) { + var l = c.transaction([e.storeName], "readwrite").objectStore(e.storeName).put(s); + l.onsuccess = function() { + return u(); + }, l.onerror = function() { + var v; + p(new Error("Failed to save origin key: ".concat((v = l.error) === null || v === void 0 ? void 0 : v.message))); + }; + }); + })]; + case 1: + return t.sent(), [3, 3]; + case 2: + throw r = t.sent(), o.error("Failed to save origin key: ".concat(r.message), r), new Error("Failed to save origin key: ".concat(r.message)); + case 3: + return [2]; + } + }); + }); + }, a.prototype.clearOriginKey = function() { + return h(this, void 0, void 0, function() { + var i, n = this; + return d(this, function(r) { + switch (r.label) { + case 0: + return r.trys.push([0, 2, , 3]), [4, this.withDB(function(e) { + return new Promise(function(t, c) { + var s = e.transaction([n.storeName], "readwrite").objectStore(n.storeName).delete(n.namespace); + s.onsuccess = function() { + o.info("Origin key cleared", { namespace: n.namespace }), t(); + }, s.onerror = function() { + var u; + return c(new Error("Failed to clear origin key: ".concat((u = s.error) === null || u === void 0 ? void 0 : u.message))); + }; + }); + })]; + case 1: + return r.sent(), [3, 3]; + case 2: + return i = r.sent(), o.warn("Failed to clear origin key:", i), [3, 3]; + case 3: + return [2]; + } + }); + }); + }, a.prototype.withDB = function(i) { + return h(this, void 0, void 0, function() { + var n; + return d(this, function(r) { + switch (r.label) { + case 0: + return [4, this.openDB()]; + case 1: + n = r.sent(), r.label = 2; + case 2: + return r.trys.push([2, , 4, 5]), [4, i(n)]; + case 3: + return [2, r.sent()]; + case 4: + return n.close(), [7]; + case 5: + return [2]; + } + }); + }); + }, a.prototype.openDB = function() { + return h(this, void 0, void 0, function() { + var i = this; + return d(this, function(n) { + return [2, new Promise(function(r, e) { + var t = indexedDB.open(i.dbName, i.dbVersion); + t.onupgradeneeded = function(c) { + var s = c.target.result; + s.objectStoreNames.contains(i.storeName) || s.createObjectStore(i.storeName, { keyPath: "namespace" }).createIndex("expiresAt", "expiresAt", { unique: !1 }); + }, t.onsuccess = function() { + return r(t.result); + }, t.onerror = function() { + return e(new Error("Failed to open IndexedDB")); + }; + })]; + }); + }); + }, a; + })(); + O.OriginKeyManager = f; + }, 9440(N, O, E) { + var h = this && this.__awaiter || function(p, l, v, y) { + return new (v || (v = Promise))(function(g, _) { + function T(m) { + try { + A(y.next(m)); + } catch (I) { + _(I); + } + } + function b(m) { + try { + A(y.throw(m)); + } catch (I) { + _(I); + } + } + function A(m) { + var I; + m.done ? g(m.value) : (I = m.value, I instanceof v ? I : new v(function(P) { + P(I); + })).then(T, b); + } + A((y = y.apply(p, l || [])).next()); + }); + }, d = this && this.__generator || function(p, l) { + var v, y, g, _ = { label: 0, sent: function() { + if (1 & g[0]) throw g[1]; + return g[1]; + }, trys: [], ops: [] }, T = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return T.next = b(0), T.throw = b(1), T.return = b(2), typeof Symbol == "function" && (T[Symbol.iterator] = function() { + return this; + }), T; + function b(A) { + return function(m) { + return (function(I) { + if (v) throw new TypeError("Generator is already executing."); + for (; T && (T = 0, I[0] && (_ = 0)), _; ) try { + if (v = 1, y && (g = 2 & I[0] ? y.return : I[0] ? y.throw || ((g = y.return) && g.call(y), 0) : y.next) && !(g = g.call(y, I[1])).done) return g; + switch (y = 0, g && (I = [2 & I[0], g.value]), I[0]) { + case 0: + case 1: + g = I; + break; + case 4: + return _.label++, { value: I[1], done: !1 }; + case 5: + _.label++, y = I[1], I = [0]; + continue; + case 7: + I = _.ops.pop(), _.trys.pop(); + continue; + default: + if (!((g = (g = _.trys).length > 0 && g[g.length - 1]) || I[0] !== 6 && I[0] !== 2)) { + _ = 0; + continue; + } + if (I[0] === 3 && (!g || I[1] > g[0] && I[1] < g[3])) { + _.label = I[1]; + break; + } + if (I[0] === 6 && _.label < g[1]) { + _.label = g[1], g = I; + break; + } + if (g && _.label < g[2]) { + _.label = g[2], _.ops.push(I); + break; + } + g[2] && _.ops.pop(), _.trys.pop(); + continue; + } + I = l.call(p, _); + } catch (P) { + I = [6, P], y = 0; + } finally { + v = g = 0; + } + if (5 & I[0]) throw I[1]; + return { value: I[0] ? I[1] : void 0, done: !0 }; + })([A, m]); + }; + } + }, o = this && this.__importDefault || function(p) { + return p && p.__esModule ? p : { default: p }; + }; + Object.defineProperty(O, "__esModule", { value: !0 }); + var f = E(9764), a = E(1313), i = E(7027), n = o(E(9124)), r = E(9242), e = E(1228), t = E(7424), c = (0, f.createLogger)("SessionManager"), s = Object.freeze({ sessionDurationMs: 864e5, enableActivityRefresh: !0, maxRefreshes: 10, maxSessionAgeMs: 6048e5 }), u = (function() { + function p(l, v) { + this.isRefreshing = !1, this.namespace = l; + var y = new n.default(); + this.encrypter = new a.CredentialsEncrypter(y), this.keyWrapper = new i.KeyWrapper(y), this.deviceBinder = new r.DeviceBinder(), this.originKeyManager = new e.OriginKeyManager(l), this.storage = new t.SessionStorage(l), this.config = this.validateConfig(v); + } + return Object.defineProperty(p.prototype, "canAutoRestore", { get: function() { + return this.storage.hasData(); + }, enumerable: !1, configurable: !0 }), Object.defineProperty(p.prototype, "sessionTimeRemaining", { get: function() { + var l = this.storage.load(); + return l ? Math.max(0, l.expiresAt - Date.now()) : 0; + }, enumerable: !1, configurable: !0 }), Object.defineProperty(p.prototype, "hasActiveSession", { get: function() { + var l = this.storage.load(); + return l != null && Date.now() < l.expiresAt; + }, enumerable: !1, configurable: !0 }), p.prototype.getNamespace = function() { + return this.namespace; + }, p.prototype.clearSession = function() { + this.storage.clear(); + }, p.prototype.hasValidSession = function() { + return h(this, void 0, void 0, function() { + return d(this, function(l) { + switch (l.label) { + case 0: + return this.hasActiveSession ? [4, this.restoreSession()] : [2, !1]; + case 1: + return [2, !!l.sent()]; + } + }); + }); + }, p.prototype.createSession = function(l) { + return h(this, void 0, void 0, function() { + var v, y, g, _, T, b, A, m, I; + return d(this, function(P) { + switch (P.label) { + case 0: + return v = this.generateSecureSessionId(), y = Date.now(), g = y + this.config.sessionDurationMs, [4, this.deviceBinder.generateFingerprint()]; + case 1: + return _ = P.sent(), [4, this.encrypter.encrypt(l)]; + case 2: + return T = P.sent(), [4, this.deviceBinder.deriveSessionKey(_, v)]; + case 3: + return b = P.sent(), [4, this.originKeyManager.getOrCreateOriginKey()]; + case 4: + return A = P.sent(), [4, this.keyWrapper.wrapCredentialsKey(T.credentialsKey, b, A.originKey)]; + case 5: + return m = P.sent(), I = { sessionId: v, createdAt: y, expiresAt: g, refreshCount: 0, encryptedCredentials: T.ciphertextB64, credentialsIV: T.ivB64, device: m.deviceWrap, origin: m.originWrap }, this.storage.save(I), c.info("Session created successfully"), [2]; + } + }); + }); + }, p.prototype.restoreSession = function() { + return h(this, void 0, void 0, function() { + var l, v; + return d(this, function(y) { + switch (y.label) { + case 0: + return y.trys.push([0, 2, , 3]), [4, this.restoreSessionOrThrow()]; + case 1: + return (l = y.sent()) || this.storage.clear(), [2, l]; + case 2: + return v = y.sent(), c.error("Session restoration failed:", v), this.storage.clear(), [2, void 0]; + case 3: + return [2]; + } + }); + }); + }, p.prototype.refreshSession = function() { + return h(this, void 0, void 0, function() { + return d(this, function(l) { + switch (l.label) { + case 0: + if (this.isRefreshing && this.refreshPromise) return c.warn("Refresh already in progress; waiting for result"), [2, this.refreshPromise]; + this.isRefreshing = !0, this.refreshPromise = this.refreshSessionInternal(), l.label = 1; + case 1: + return l.trys.push([1, , 3, 4]), [4, this.refreshPromise]; + case 2: + return [2, l.sent()]; + case 3: + return this.isRefreshing = !1, this.refreshPromise = void 0, [7]; + case 4: + return [2]; + } + }); + }); + }, p.prototype.refreshSessionInternal = function() { + return h(this, void 0, void 0, function() { + var l, v, y, g, _, T, b, A, m; + return d(this, function(I) { + switch (I.label) { + case 0: + return (l = this.storage.load()) ? l.refreshCount >= this.config.maxRefreshes ? (c.warn("Maximum refresh count reached"), [2, !1]) : Date.now() - l.createdAt >= this.config.maxSessionAgeMs ? (c.warn("Maximum session age exceeded"), [2, !1]) : [4, this.restoreSessionOrThrow()] : (c.warn("No session data available for refresh"), [2, !1]); + case 1: + return (v = I.sent()) ? [4, this.encrypter.encrypt(v)] : (c.warn("Refresh aborted: session could not be restored"), [2, !1]); + case 2: + return y = I.sent(), T = (_ = this.deviceBinder).deriveSessionKey, [4, this.deviceBinder.generateFingerprint()]; + case 3: + return [4, T.apply(_, [I.sent(), l.sessionId])]; + case 4: + return g = I.sent(), [4, this.originKeyManager.getOrCreateOriginKey()]; + case 5: + return b = I.sent(), [4, this.keyWrapper.wrapCredentialsKey(y.credentialsKey, g, b.originKey)]; + case 6: + return A = I.sent(), m = { sessionId: l.sessionId, createdAt: l.createdAt, expiresAt: Date.now() + this.config.sessionDurationMs, refreshCount: l.refreshCount + 1, encryptedCredentials: y.ciphertextB64, credentialsIV: y.ivB64, device: A.deviceWrap, origin: A.originWrap }, this.storage.save(m), [2, !0]; + } + }); + }); + }, p.prototype.restoreSessionOrThrow = function() { + return h(this, void 0, void 0, function() { + var l, v, y, g, _, T; + return d(this, function(b) { + switch (b.label) { + case 0: + return c.info("Starting session restoration..."), (l = this.storage.load()) ? Date.now() > l.expiresAt ? (c.info("Session expired"), [2, void 0]) : [4, this.deviceBinder.generateFingerprint()] : (c.info("No session data found"), [2, void 0]); + case 1: + return v = b.sent(), [4, this.deviceBinder.deriveSessionKey(v, l.sessionId)]; + case 2: + return y = b.sent(), [4, this.originKeyManager.loadOriginKey()]; + case 3: + if (!(g = b.sent())) throw new Error("Origin key missing"); + if (this.originKeyManager.isExpired(g.expiresAt)) throw new Error("Origin key expired"); + return [4, this.keyWrapper.unwrapCredentialsKey({ deviceWrap: l.device, originWrap: l.origin }, y, g.originKey)]; + case 4: + return _ = b.sent(), [4, this.encrypter.decrypt({ credentialsKey: _, ciphertextB64: l.encryptedCredentials, ivB64: l.credentialsIV })]; + case 5: + return T = b.sent(), c.info("Session restoration successful!"), [2, T]; + } + }); + }); + }, p.prototype.generateSecureSessionId = function() { + if (crypto.randomUUID) return crypto.randomUUID(); + var l = new Uint8Array(16); + return crypto.getRandomValues(l), Array.from(l, function(v) { + return v.toString(16).padStart(2, "0"); + }).join(""); + }, p.prototype.validateConfig = function(l) { + var v = l ? Object.fromEntries(Object.entries(l).filter(function(g) { + return g[1] !== void 0; + })) : {}, y = Object.assign({}, s, v); + if (!Number.isFinite(y.sessionDurationMs) || y.sessionDurationMs <= 0) throw new Error("sessionDurationMs must be a finite positive number"); + if (!Number.isInteger(y.maxRefreshes) || y.maxRefreshes < 0) throw new Error("maxRefreshes must be a non-negative integer"); + if (typeof y.enableActivityRefresh != "boolean") throw new Error("enableActivityRefresh must be a boolean"); + if (!Number.isFinite(y.maxSessionAgeMs) || y.maxSessionAgeMs <= 0) throw new Error("maxSessionAgeMs must be a finite positive number"); + if (y.maxSessionAgeMs < y.sessionDurationMs) throw new Error("maxSessionAgeMs must be >= sessionDurationMs"); + return Object.freeze(y); + }, p; + })(); + O.default = u; + }, 5673(N, O, E) { + var h = this && this.__awaiter || function(a, i, n, r) { + return new (n || (n = Promise))(function(e, t) { + function c(p) { + try { + u(r.next(p)); + } catch (l) { + t(l); + } + } + function s(p) { + try { + u(r.throw(p)); + } catch (l) { + t(l); + } + } + function u(p) { + var l; + p.done ? e(p.value) : (l = p.value, l instanceof n ? l : new n(function(v) { + v(l); + })).then(c, s); + } + u((r = r.apply(a, i || [])).next()); + }); + }, d = this && this.__generator || function(a, i) { + var n, r, e, t = { label: 0, sent: function() { + if (1 & e[0]) throw e[1]; + return e[1]; + }, trys: [], ops: [] }, c = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return c.next = s(0), c.throw = s(1), c.return = s(2), typeof Symbol == "function" && (c[Symbol.iterator] = function() { + return this; + }), c; + function s(u) { + return function(p) { + return (function(l) { + if (n) throw new TypeError("Generator is already executing."); + for (; c && (c = 0, l[0] && (t = 0)), t; ) try { + if (n = 1, r && (e = 2 & l[0] ? r.return : l[0] ? r.throw || ((e = r.return) && e.call(r), 0) : r.next) && !(e = e.call(r, l[1])).done) return e; + switch (r = 0, e && (l = [2 & l[0], e.value]), l[0]) { + case 0: + case 1: + e = l; + break; + case 4: + return t.label++, { value: l[1], done: !1 }; + case 5: + t.label++, r = l[1], l = [0]; + continue; + case 7: + l = t.ops.pop(), t.trys.pop(); + continue; + default: + if (!((e = (e = t.trys).length > 0 && e[e.length - 1]) || l[0] !== 6 && l[0] !== 2)) { + t = 0; + continue; + } + if (l[0] === 3 && (!e || l[1] > e[0] && l[1] < e[3])) { + t.label = l[1]; + break; + } + if (l[0] === 6 && t.label < e[1]) { + t.label = e[1], e = l; + break; + } + if (e && t.label < e[2]) { + t.label = e[2], t.ops.push(l); + break; + } + e[2] && t.ops.pop(), t.trys.pop(); + continue; + } + l = i.call(a, t); + } catch (v) { + l = [6, v], r = 0; + } finally { + n = e = 0; + } + if (5 & l[0]) throw l[1]; + return { value: l[0] ? l[1] : void 0, done: !0 }; + })([u, p]); + }; + } + }; + Object.defineProperty(O, "__esModule", { value: !0 }); + var o = (0, E(9764).createLogger)("SessionRefreshManager"), f = (function() { + function a(i) { + this.sessionManager = i, this.lastActivity = Date.now(), this.activityListeners = [], this.isRunning = !1, this.hasVisibilityListener = !1, this.consecutiveErrors = 0, this.isRefreshing = !1, this.config = i.config, this.visibilityHandler = this.handleVisibilityChange.bind(this), this.refreshTriggerMs = Math.min(144e5, 0.25 * this.config.sessionDurationMs); + } + return a.prototype.start = function() { + if (!this.isRunning && this.config.enableActivityRefresh) if (typeof document < "u") { + if (this.config.sessionDurationMs < 12e5) { + var i = this.config.sessionDurationMs / 6e4; + o.warn("Session duration (".concat(i, "m) is less ") + "than the minimum recommended for auto-refresh (".concat(20, "m). ") + "The periodic check may not observe the session inside the refresh window before it expires."); + } + this.isRunning = !0, this.lastActivity = Date.now(), this.consecutiveErrors = 0, this.setupActivityMonitoring(), this.resumeRefreshTimer(), this.visibilityHandler && (document.addEventListener("visibilitychange", this.visibilityHandler), this.hasVisibilityListener = !0); + } else o.warn("No document available; activity monitoring disabled"); + }, a.prototype.stop = function() { + this.isRunning && (this.isRunning = !1, this.cleanupTimersAndListeners(), this.hasVisibilityListener && this.visibilityHandler && (document.removeEventListener("visibilitychange", this.visibilityHandler), this.hasVisibilityListener = !1)); + }, a.prototype.setupActivityMonitoring = function() { + var i = this, n = this.createThrottledActivityUpdater(); + ["click", "keydown", "mousemove", "scroll", "touchstart"].forEach(function(r) { + var e = function() { + return n(); + }; + document.addEventListener(r, e, { passive: !0 }), i.activityListeners.push({ event: r, handler: e }); + }); + }, a.prototype.createThrottledActivityUpdater = function() { + var i = this, n = !1; + return function() { + n || (n = !0, i.lastActivity = Date.now(), i.activityThrottleTimer = setTimeout(function() { + n = !1; + }, 3e4)); + }; + }, a.prototype.resumeRefreshTimer = function() { + var i = this; + this.refreshTimer && clearTimeout(this.refreshTimer), this.refreshTimer = setTimeout(function() { + return h(i, void 0, void 0, function() { + return d(this, function(n) { + switch (n.label) { + case 0: + return [4, this.checkAndRefreshSession()]; + case 1: + return n.sent(), this.isRunning && this.resumeRefreshTimer(), [2]; + } + }); + }); + }, 3e5); + }, a.prototype.pauseRefreshTimer = function() { + this.refreshTimer && (clearTimeout(this.refreshTimer), this.refreshTimer = void 0); + }, a.prototype.checkAndRefreshSession = function() { + return h(this, void 0, void 0, function() { + var i, n, r; + return d(this, function(e) { + switch (e.label) { + case 0: + if (this.isRefreshing) return [2]; + this.isRefreshing = !0, e.label = 1; + case 1: + return e.trys.push([1, 4, 5, 6]), (i = Date.now() - this.lastActivity) >= 18e5 ? (o.debug("Refresh suppressed: user inactive " + "for ".concat(Math.round(i / 1e3), "s")), [2]) : (n = this.sessionManager.sessionTimeRemaining) > 0 && n < this.refreshTriggerMs ? [4, this.sessionManager.refreshSession()] : [3, 3]; + case 2: + e.sent() ? (this.consecutiveErrors = 0, o.info("Session automatically refreshed")) : (o.warn("Session refresh declined (max refreshes or max age reached). Stopping."), this.stop()), e.label = 3; + case 3: + return [3, 6]; + case 4: + return r = e.sent(), this.consecutiveErrors++, o.error("Refresh check failed " + "(attempt ".concat(this.consecutiveErrors, "/").concat(3, "):"), r), this.consecutiveErrors >= 3 && (o.error("Stopping after repeated failures"), this.stop()), [3, 6]; + case 5: + return this.isRefreshing = !1, [7]; + case 6: + return [2]; + } + }); + }); + }, a.prototype.handleVisibilityChange = function() { + this.isRunning && (document.hidden ? this.pauseRefreshTimer() : (this.lastActivity = Date.now(), this.resumeRefreshTimer())); + }, a.prototype.cleanupTimersAndListeners = function() { + this.refreshTimer && (clearTimeout(this.refreshTimer), this.refreshTimer = void 0), this.activityThrottleTimer && (clearTimeout(this.activityThrottleTimer), this.activityThrottleTimer = void 0), this.activityListeners.forEach(function(i) { + var n = i.event, r = i.handler; + document.removeEventListener(n, r); + }), this.activityListeners = []; + }, a.prototype.getLastActivity = function() { + return this.lastActivity; + }, a.prototype.isActive = function() { + return this.isRunning; + }, a.prototype.forceRefreshCheck = function() { + return h(this, void 0, void 0, function() { + return d(this, function(i) { + switch (i.label) { + case 0: + return this.isRunning ? [4, this.checkAndRefreshSession()] : (o.warn("forceRefreshCheck called while not running"), [2, !1]); + case 1: + return i.sent(), [2, this.isRunning]; + } + }); + }); + }, a; + })(); + O.default = f; + }, 7424(N, O, E) { + Object.defineProperty(O, "__esModule", { value: !0 }), O.SessionStorage = void 0; + var h = (0, E(9764).createLogger)("SessionStorage"), d = "lnc-session:", o = function(a) { + if (!a || typeof a != "object") return !1; + var i = a; + return typeof i.keyB64 == "string" && typeof i.ivB64 == "string"; + }, f = (function() { + function a(i) { + this._cache = void 0, this._namespace = i; + } + return a.prototype.save = function(i) { + if (typeof sessionStorage < "u") try { + var n = "".concat(d).concat(this._namespace); + sessionStorage.setItem(n, JSON.stringify(i)), this._cache = i, h.info("Session saved to sessionStorage", { namespace: this._namespace, sessionId: i.sessionId, createdAt: i.createdAt, expiresAt: i.expiresAt, refreshCount: i.refreshCount }); + } catch (r) { + throw h.error("Failed to save session data", { namespace: this._namespace, error: r }), r; + } + }, a.prototype.load = function() { + var i; + if (typeof sessionStorage < "u") { + if (this._cache !== void 0) return (i = this._cache) !== null && i !== void 0 ? i : void 0; + try { + var n = "".concat(d).concat(this._namespace), r = sessionStorage.getItem(n); + if (!r) return void (this._cache = null); + var e = JSON.parse(r); + if (!e || typeof e != "object" || !(c = e) || typeof c.sessionId != "string" || typeof c.createdAt != "number" || typeof c.expiresAt != "number" || typeof c.refreshCount != "number" || typeof c.encryptedCredentials != "string" || typeof c.credentialsIV != "string" || !Number.isFinite(c.createdAt) || !Number.isFinite(c.expiresAt) || c.createdAt <= 0 || c.expiresAt <= 0 || c.createdAt > c.expiresAt || !Number.isInteger(c.refreshCount) || c.refreshCount < 0 || c.sessionId.length === 0 || !o(c.device) || !o(c.origin)) return h.error("Invalid session data", { namespace: this._namespace }), sessionStorage.removeItem(n), void (this._cache = null); + var t = e; + return this._cache = t, h.info("Session loaded from sessionStorage", { namespace: this._namespace, sessionId: t.sessionId, createdAt: t.createdAt, expiresAt: t.expiresAt, refreshCount: t.refreshCount }), t; + } catch (s) { + h.error("Failed to load session data", { namespace: this._namespace, error: s }); + try { + n = "".concat(d).concat(this._namespace), sessionStorage.removeItem(n); + } catch (u) { + h.warn("Cleanup failed during error recovery", { namespace: this._namespace, cleanupError: u }); + } + return void (this._cache = null); + } + var c; + } + }, a.prototype.clear = function() { + if (typeof sessionStorage < "u") try { + var i = "".concat(d).concat(this._namespace); + sessionStorage.removeItem(i), this._cache = null; + } catch (n) { + h.error("Failed to clear session data", { namespace: this._namespace, error: n }); + } + }, a.prototype.hasData = function() { + return typeof sessionStorage < "u" && (this._cache === void 0 && this.load(), this._cache != null); + }, a; + })(); + O.SessionStorage = f; + }, 3666(N, O, E) { + var h = this && this.__awaiter || function(i, n, r, e) { + return new (r || (r = Promise))(function(t, c) { + function s(l) { + try { + p(e.next(l)); + } catch (v) { + c(v); + } + } + function u(l) { + try { + p(e.throw(l)); + } catch (v) { + c(v); + } + } + function p(l) { + var v; + l.done ? t(l.value) : (v = l.value, v instanceof r ? v : new r(function(y) { + y(v); + })).then(s, u); + } + p((e = e.apply(i, n || [])).next()); + }); + }, d = this && this.__generator || function(i, n) { + var r, e, t, c = { label: 0, sent: function() { + if (1 & t[0]) throw t[1]; + return t[1]; + }, trys: [], ops: [] }, s = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return s.next = u(0), s.throw = u(1), s.return = u(2), typeof Symbol == "function" && (s[Symbol.iterator] = function() { + return this; + }), s; + function u(p) { + return function(l) { + return (function(v) { + if (r) throw new TypeError("Generator is already executing."); + for (; s && (s = 0, v[0] && (c = 0)), c; ) try { + if (r = 1, e && (t = 2 & v[0] ? e.return : v[0] ? e.throw || ((t = e.return) && t.call(e), 0) : e.next) && !(t = t.call(e, v[1])).done) return t; + switch (e = 0, t && (v = [2 & v[0], t.value]), v[0]) { + case 0: + case 1: + t = v; + break; + case 4: + return c.label++, { value: v[1], done: !1 }; + case 5: + c.label++, e = v[1], v = [0]; + continue; + case 7: + v = c.ops.pop(), c.trys.pop(); + continue; + default: + if (!((t = (t = c.trys).length > 0 && t[t.length - 1]) || v[0] !== 6 && v[0] !== 2)) { + c = 0; + continue; + } + if (v[0] === 3 && (!t || v[1] > t[0] && v[1] < t[3])) { + c.label = v[1]; + break; + } + if (v[0] === 6 && c.label < t[1]) { + c.label = t[1], t = v; + break; + } + if (t && c.label < t[2]) { + c.label = t[2], c.ops.push(v); + break; + } + t[2] && c.ops.pop(), c.trys.pop(); + continue; + } + v = n.call(i, c); + } catch (y) { + v = [6, y], e = 0; + } finally { + r = t = 0; + } + if (5 & v[0]) throw v[1]; + return { value: v[0] ? v[1] : void 0, done: !0 }; + })([p, l]); + }; + } + }; + Object.defineProperty(O, "__esModule", { value: !0 }), O.AuthenticationCoordinator = void 0; + var o = (0, E(9764).createLogger)("AuthenticationCoordinator"), f = ["localKey", "remoteKey", "pairingPhrase", "serverHost"], a = (function() { + function i(n, r, e) { + this.strategyManager = n, this.credentialCache = r, this.sessionCoordinator = e, this.sessionRestored = !1, this.initializeCachePromise = this.initializeCache(); + } + return Object.defineProperty(i.prototype, "isUnlocked", { get: function() { + return !!this.activeStrategy && this.activeStrategy.isUnlocked; + }, enumerable: !1, configurable: !0 }), i.prototype.getActiveStrategy = function() { + return this.activeStrategy; + }, i.prototype.clearSession = function() { + this.credentialCache.clear(), this.sessionCoordinator.clearSession(), this.sessionRestored = !1, this.activeStrategy = void 0, o.info("Cleared session state"); + }, i.prototype.unlock = function(n) { + return h(this, void 0, void 0, function() { + var r, e; + return d(this, function(t) { + switch (t.label) { + case 0: + return t.trys.push([0, 4, , 5]), [4, this.waitForSessionRestoration()]; + case 1: + return t.sent(), n.method === "session" && this.sessionRestored ? [2, !0] : (r = this.strategyManager.getStrategy(n.method)) ? [4, r.unlock(n)] : (o.error("Authentication method '".concat(n.method, "' not supported")), [2, !1]); + case 2: + return t.sent() ? (this.activeStrategy = r, [4, this.loadCredentialsFromStrategy(r)]) : (o.error("Failed to unlock with ".concat(n.method)), [2, !1]); + case 3: + return t.sent(), [2, !0]; + case 4: + return e = t.sent(), o.error("Unlock failed:", e), this.credentialCache.clear(), this.activeStrategy = void 0, [2, !1]; + case 5: + return [2]; + } + }); + }); + }, i.prototype.getAuthenticationInfo = function() { + return h(this, void 0, void 0, function() { + var n, r, e, t, c, s, u, p; + return d(this, function(l) { + switch (l.label) { + case 0: + return [4, this.waitForSessionRestoration()]; + case 1: + return l.sent(), n = this.strategyManager.hasAnyCredentials, r = this.sessionCoordinator.hasActiveSession, [4, this.sessionCoordinator.getTimeRemaining()]; + case 2: + return e = l.sent(), t = this.strategyManager.getStrategy("passkey"), c = !!t && t.isSupported, s = c && ((u = t?.hasStoredAuthData) === null || u === void 0 ? void 0 : u.call(t)) === !0, [2, { isUnlocked: this.isUnlocked, hasStoredCredentials: n, hasActiveSession: r, sessionTimeRemaining: e, supportsPasskeys: c, hasPasskey: s, preferredUnlockMethod: this.strategyManager.preferredMethod, passkeyCredentialId: s ? (p = t?.getCredentialId) === null || p === void 0 ? void 0 : p.call(t) : void 0 }]; + } + }); + }); + }, i.prototype.tryAutoRestore = function() { + return h(this, void 0, void 0, function() { + var n, r, e; + return d(this, function(t) { + switch (t.label) { + case 0: + if (!this.sessionCoordinator.isSessionAvailable || this.sessionRestored) return [2, !1]; + if (!(n = this.strategyManager.getStrategy("session"))) return [2, !1]; + t.label = 1; + case 1: + return t.trys.push([1, 3, , 4]), [4, this.sessionCoordinator.tryAutoRestore()]; + case 2: + return (r = t.sent()) ? (this.credentialCache.hydrateFromSession(r), this.sessionRestored = !0, this.activeStrategy = n, [2, !0]) : [2, !1]; + case 3: + return e = t.sent(), o.error("Auto-restore failed:", e), [3, 4]; + case 4: + return [2, !1]; + } + }); + }); + }, i.prototype.createSessionAfterConnection = function() { + return h(this, void 0, void 0, function() { + return d(this, function(n) { + switch (n.label) { + case 0: + return this.sessionCoordinator.isSessionAvailable ? [4, this.sessionCoordinator.createSession({ localKey: this.getCachedCredential("localKey"), remoteKey: this.getCachedCredential("remoteKey"), pairingPhrase: this.getCachedCredential("pairingPhrase"), serverHost: this.getCachedCredential("serverHost") })] : [3, 2]; + case 1: + n.sent(), n.label = 2; + case 2: + return [2]; + } + }); + }); + }, i.prototype.getCachedCredential = function(n) { + return this.credentialCache.get(n) || ""; + }, i.prototype.initializeCache = function() { + return h(this, void 0, void 0, function() { + return d(this, function(n) { + switch (n.label) { + case 0: + return [4, this.tryAutoRestore()]; + case 1: + return n.sent(), this.sessionRestored || !this.activeStrategy ? [3, 3] : [4, this.loadCredentialsFromStrategy(this.activeStrategy)]; + case 2: + n.sent(), n.label = 3; + case 3: + return [2]; + } + }); + }); + }, i.prototype.waitForSessionRestoration = function() { + return h(this, void 0, void 0, function() { + return d(this, function(n) { + switch (n.label) { + case 0: + return !this.sessionCoordinator.isSessionAvailable || this.sessionRestored ? [2] : this.initializeCachePromise ? [4, this.initializeCachePromise] : [3, 2]; + case 1: + return n.sent(), [3, 4]; + case 2: + return [4, this.tryAutoRestore()]; + case 3: + n.sent(), n.label = 4; + case 4: + return [2]; + } + }); + }); + }, i.prototype.persistCachedCredentials = function(n) { + return h(this, void 0, void 0, function() { + var r, e, t, c, s, u; + return d(this, function(p) { + switch (p.label) { + case 0: + if (this.activeStrategy = n, n.method === "session") return [2]; + r = [], e = 0, t = f, p.label = 1; + case 1: + if (!(e < t.length)) return [3, 6]; + if (c = t[e], !(s = this.credentialCache.get(c))) return [3, 5]; + p.label = 2; + case 2: + return p.trys.push([2, 4, , 5]), [4, n.setCredential(c, s)]; + case 3: + return p.sent(), [3, 5]; + case 4: + return u = p.sent(), o.error("Failed to persist ".concat(c, ":"), u), r.push(c), [3, 5]; + case 5: + return e++, [3, 1]; + case 6: + if (r.length > 0) throw new Error("Failed to persist credentials: ".concat(r.join(", "))); + return [2]; + } + }); + }); + }, i.prototype.loadCredentialsFromStrategy = function(n) { + return h(this, void 0, void 0, function() { + var r, e, t, c, s, u; + return d(this, function(p) { + switch (p.label) { + case 0: + r = [], e = 0, t = f, p.label = 1; + case 1: + if (!(e < t.length)) return [3, 6]; + c = t[e], p.label = 2; + case 2: + return p.trys.push([2, 4, , 5]), [4, n.getCredential(c)]; + case 3: + return (s = p.sent()) && this.credentialCache.set(c, s), [3, 5]; + case 4: + return u = p.sent(), o.error("Failed to load credential ".concat(c, ":"), u), r.push(c), [3, 5]; + case 5: + return e++, [3, 1]; + case 6: + if (r.length > 0) throw new Error("Failed to load credentials: ".concat(r.join(", "))); + return [2]; + } + }); + }); + }, i; + })(); + O.AuthenticationCoordinator = a; + }, 6041(N, O, E) { + Object.defineProperty(O, "__esModule", { value: !0 }), O.CredentialCache = void 0; + var h = (0, E(9764).createLogger)("CredentialCache"), d = (function() { + function o() { + this.cache = /* @__PURE__ */ new Map(); + } + return Object.defineProperty(o.prototype, "size", { get: function() { + return this.cache.size; + }, enumerable: !1, configurable: !0 }), o.prototype.get = function(f) { + return this.cache.get(f); + }, o.prototype.set = function(f, a) { + this.cache.set(f, a); + }, o.prototype.has = function(f) { + return this.cache.has(f); + }, o.prototype.hasAny = function() { + return this.cache.size > 0; + }, o.prototype.clear = function() { + this.cache.clear(), h.info("Cache cleared"); + }, o.prototype.getAll = function() { + return new Map(this.cache); + }, o.prototype.hydrate = function(f) { + for (var a = 0, i = Object.entries(f); a < i.length; a++) { + var n = i[a], r = n[0], e = n[1]; + this.cache.set(r, e); + } + h.info("Hydrated with credentials:", { keys: Object.keys(f) }); + }, o.prototype.hydrateFromSession = function(f) { + this.cache.set("localKey", f.localKey), this.cache.set("remoteKey", f.remoteKey), this.cache.set("pairingPhrase", f.pairingPhrase), this.cache.set("serverHost", f.serverHost), h.info("Hydrated from session:", { hasLocalKey: !!f.localKey, hasRemoteKey: !!f.remoteKey, hasPairingPhrase: !!f.pairingPhrase, serverHost: f.serverHost }); + }, o.prototype.keys = function() { + return Array.from(this.cache.keys()); + }, o.prototype.values = function() { + return Array.from(this.cache.values()); + }, o.prototype.entries = function() { + return Array.from(this.cache.entries()); + }, o.prototype.snapshot = function() { + return Object.fromEntries(this.cache.entries()); + }, o; + })(); + O.CredentialCache = d; + }, 9389(N, O, E) { + var h = this && this.__awaiter || function(n, r, e, t) { + return new (e || (e = Promise))(function(c, s) { + function u(v) { + try { + l(t.next(v)); + } catch (y) { + s(y); + } + } + function p(v) { + try { + l(t.throw(v)); + } catch (y) { + s(y); + } + } + function l(v) { + var y; + v.done ? c(v.value) : (y = v.value, y instanceof e ? y : new e(function(g) { + g(y); + })).then(u, p); + } + l((t = t.apply(n, r || [])).next()); + }); + }, d = this && this.__generator || function(n, r) { + var e, t, c, s = { label: 0, sent: function() { + if (1 & c[0]) throw c[1]; + return c[1]; + }, trys: [], ops: [] }, u = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return u.next = p(0), u.throw = p(1), u.return = p(2), typeof Symbol == "function" && (u[Symbol.iterator] = function() { + return this; + }), u; + function p(l) { + return function(v) { + return (function(y) { + if (e) throw new TypeError("Generator is already executing."); + for (; u && (u = 0, y[0] && (s = 0)), s; ) try { + if (e = 1, t && (c = 2 & y[0] ? t.return : y[0] ? t.throw || ((c = t.return) && c.call(t), 0) : t.next) && !(c = c.call(t, y[1])).done) return c; + switch (t = 0, c && (y = [2 & y[0], c.value]), y[0]) { + case 0: + case 1: + c = y; + break; + case 4: + return s.label++, { value: y[1], done: !1 }; + case 5: + s.label++, t = y[1], y = [0]; + continue; + case 7: + y = s.ops.pop(), s.trys.pop(); + continue; + default: + if (!((c = (c = s.trys).length > 0 && c[c.length - 1]) || y[0] !== 6 && y[0] !== 2)) { + s = 0; + continue; + } + if (y[0] === 3 && (!c || y[1] > c[0] && y[1] < c[3])) { + s.label = y[1]; + break; + } + if (y[0] === 6 && s.label < c[1]) { + s.label = c[1], c = y; + break; + } + if (c && s.label < c[2]) { + s.label = c[2], s.ops.push(y); + break; + } + c[2] && s.ops.pop(), s.trys.pop(); + continue; + } + y = r.call(n, s); + } catch (g) { + y = [6, g], t = 0; + } finally { + e = c = 0; + } + if (5 & y[0]) throw y[1]; + return { value: y[0] ? y[1] : void 0, done: !0 }; + })([l, v]); + }; + } + }; + Object.defineProperty(O, "__esModule", { value: !0 }), O.PasskeyStrategy = void 0; + var o = E(6315), f = E(4279), a = (0, E(9764).createLogger)("PasskeyStrategy"), i = (function() { + function n(r, e) { + this.method = "passkey"; + var t = new o.PasskeyEncryptionService(r, e); + this.repository = new f.PasskeyCredentialRepository(r, t); + } + return Object.defineProperty(n.prototype, "isSupported", { get: function() { + return typeof window < "u" && !(!window.PublicKeyCredential || !window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable); + }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isUnlocked", { get: function() { + return this.repository.isUnlocked; + }, enumerable: !1, configurable: !0 }), n.prototype.unlock = function(r) { + return h(this, void 0, void 0, function() { + var e; + return d(this, function(t) { + switch (t.label) { + case 0: + if (r.method !== "passkey") return [2, !1]; + t.label = 1; + case 1: + return t.trys.push([1, 3, , 4]), [4, this.repository.unlock(r)]; + case 2: + return t.sent(), [2, !0]; + case 3: + return e = t.sent(), a.error("Unlock failed:", e), [2, !1]; + case 4: + return [2]; + } + }); + }); + }, Object.defineProperty(n.prototype, "hasAnyCredentials", { get: function() { + return this.repository.hasAnyCredentials; + }, enumerable: !1, configurable: !0 }), n.prototype.hasStoredAuthData = function() { + return this.repository.hasStoredAuthData; + }, n.prototype.getCredentialId = function() { + return this.repository.storedCredentialId; + }, n.prototype.getCredential = function(r) { + return h(this, void 0, void 0, function() { + var e; + return d(this, function(t) { + switch (t.label) { + case 0: + if (!this.isUnlocked) return a.warn("Cannot get credential - not unlocked"), [2, void 0]; + t.label = 1; + case 1: + return t.trys.push([1, 3, , 4]), [4, this.repository.getCredential(r)]; + case 2: + return [2, t.sent()]; + case 3: + return e = t.sent(), a.error("Failed to get credential ".concat(r, ":"), e), [2, void 0]; + case 4: + return [2]; + } + }); + }); + }, n.prototype.setCredential = function(r, e) { + return h(this, void 0, void 0, function() { + var t; + return d(this, function(c) { + switch (c.label) { + case 0: + if (!this.isUnlocked) return a.warn("Cannot set credential - not unlocked"), [2]; + c.label = 1; + case 1: + return c.trys.push([1, 3, , 4]), [4, this.repository.setCredential(r, e)]; + case 2: + return c.sent(), [3, 4]; + case 3: + throw t = c.sent(), a.error("Failed to set credential ".concat(r, ":"), t), t; + case 4: + return [2]; + } + }); + }); + }, n.prototype.clear = function() { + this.repository.clear(); + }, n; + })(); + O.PasskeyStrategy = i; + }, 8562(N, O, E) { + var h = this && this.__awaiter || function(n, r, e, t) { + return new (e || (e = Promise))(function(c, s) { + function u(v) { + try { + l(t.next(v)); + } catch (y) { + s(y); + } + } + function p(v) { + try { + l(t.throw(v)); + } catch (y) { + s(y); + } + } + function l(v) { + var y; + v.done ? c(v.value) : (y = v.value, y instanceof e ? y : new e(function(g) { + g(y); + })).then(u, p); + } + l((t = t.apply(n, r || [])).next()); + }); + }, d = this && this.__generator || function(n, r) { + var e, t, c, s = { label: 0, sent: function() { + if (1 & c[0]) throw c[1]; + return c[1]; + }, trys: [], ops: [] }, u = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return u.next = p(0), u.throw = p(1), u.return = p(2), typeof Symbol == "function" && (u[Symbol.iterator] = function() { + return this; + }), u; + function p(l) { + return function(v) { + return (function(y) { + if (e) throw new TypeError("Generator is already executing."); + for (; u && (u = 0, y[0] && (s = 0)), s; ) try { + if (e = 1, t && (c = 2 & y[0] ? t.return : y[0] ? t.throw || ((c = t.return) && c.call(t), 0) : t.next) && !(c = c.call(t, y[1])).done) return c; + switch (t = 0, c && (y = [2 & y[0], c.value]), y[0]) { + case 0: + case 1: + c = y; + break; + case 4: + return s.label++, { value: y[1], done: !1 }; + case 5: + s.label++, t = y[1], y = [0]; + continue; + case 7: + y = s.ops.pop(), s.trys.pop(); + continue; + default: + if (!((c = (c = s.trys).length > 0 && c[c.length - 1]) || y[0] !== 6 && y[0] !== 2)) { + s = 0; + continue; + } + if (y[0] === 3 && (!c || y[1] > c[0] && y[1] < c[3])) { + s.label = y[1]; + break; + } + if (y[0] === 6 && s.label < c[1]) { + s.label = c[1], c = y; + break; + } + if (c && s.label < c[2]) { + s.label = c[2], s.ops.push(y); + break; + } + c[2] && s.ops.pop(), s.trys.pop(); + continue; + } + y = r.call(n, s); + } catch (g) { + y = [6, g], t = 0; + } finally { + e = c = 0; + } + if (5 & y[0]) throw y[1]; + return { value: y[0] ? y[1] : void 0, done: !0 }; + })([l, v]); + }; + } + }; + Object.defineProperty(O, "__esModule", { value: !0 }), O.PasswordStrategy = void 0; + var o = E(6200), f = E(2672), a = (0, E(9764).createLogger)("PasswordStrategy"), i = (function() { + function n(r) { + this.method = "password"; + var e = new o.PasswordEncryptionService(); + this.repository = new f.PasswordCredentialRepository(r, e); + } + return Object.defineProperty(n.prototype, "isSupported", { get: function() { + return !0; + }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isUnlocked", { get: function() { + return this.repository.isUnlocked; + }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "hasAnyCredentials", { get: function() { + return this.repository.hasAnyCredentials; + }, enumerable: !1, configurable: !0 }), n.prototype.unlock = function(r) { + return h(this, void 0, void 0, function() { + var e; + return d(this, function(t) { + switch (t.label) { + case 0: + if (r.method !== "password") return [2, !1]; + if (!r.password) return a.error("Password required for unlock"), [2, !1]; + t.label = 1; + case 1: + return t.trys.push([1, 3, , 4]), [4, this.repository.unlock(r)]; + case 2: + return t.sent(), [2, !0]; + case 3: + return e = t.sent(), a.error("Unlock failed:", e), [2, !1]; + case 4: + return [2]; + } + }); + }); + }, n.prototype.getCredential = function(r) { + return h(this, void 0, void 0, function() { + var e; + return d(this, function(t) { + switch (t.label) { + case 0: + if (!this.isUnlocked) return a.warn("Cannot get credential - not unlocked"), [2, void 0]; + t.label = 1; + case 1: + return t.trys.push([1, 3, , 4]), [4, this.repository.getCredential(r)]; + case 2: + return [2, t.sent()]; + case 3: + return e = t.sent(), a.error("Failed to get credential ".concat(r, ":"), e), [2, void 0]; + case 4: + return [2]; + } + }); + }); + }, n.prototype.setCredential = function(r, e) { + return h(this, void 0, void 0, function() { + var t; + return d(this, function(c) { + switch (c.label) { + case 0: + if (!this.isUnlocked) return a.warn("Cannot set credential - not unlocked"), [2]; + c.label = 1; + case 1: + return c.trys.push([1, 3, , 4]), [4, this.repository.setCredential(r, e)]; + case 2: + return c.sent(), [3, 4]; + case 3: + throw t = c.sent(), a.error("Failed to set credential ".concat(r, ":"), t), t; + case 4: + return [2]; + } + }); + }); + }, n.prototype.clear = function() { + this.repository.clear(); + }, n; + })(); + O.PasswordStrategy = i; + }, 9792(N, O, E) { + var h = this && this.__awaiter || function(n, r, e, t) { + return new (e || (e = Promise))(function(c, s) { + function u(v) { + try { + l(t.next(v)); + } catch (y) { + s(y); + } + } + function p(v) { + try { + l(t.throw(v)); + } catch (y) { + s(y); + } + } + function l(v) { + var y; + v.done ? c(v.value) : (y = v.value, y instanceof e ? y : new e(function(g) { + g(y); + })).then(u, p); + } + l((t = t.apply(n, r || [])).next()); + }); + }, d = this && this.__generator || function(n, r) { + var e, t, c, s = { label: 0, sent: function() { + if (1 & c[0]) throw c[1]; + return c[1]; + }, trys: [], ops: [] }, u = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return u.next = p(0), u.throw = p(1), u.return = p(2), typeof Symbol == "function" && (u[Symbol.iterator] = function() { + return this; + }), u; + function p(l) { + return function(v) { + return (function(y) { + if (e) throw new TypeError("Generator is already executing."); + for (; u && (u = 0, y[0] && (s = 0)), s; ) try { + if (e = 1, t && (c = 2 & y[0] ? t.return : y[0] ? t.throw || ((c = t.return) && c.call(t), 0) : t.next) && !(c = c.call(t, y[1])).done) return c; + switch (t = 0, c && (y = [2 & y[0], c.value]), y[0]) { + case 0: + case 1: + c = y; + break; + case 4: + return s.label++, { value: y[1], done: !1 }; + case 5: + s.label++, t = y[1], y = [0]; + continue; + case 7: + y = s.ops.pop(), s.trys.pop(); + continue; + default: + if (!((c = (c = s.trys).length > 0 && c[c.length - 1]) || y[0] !== 6 && y[0] !== 2)) { + s = 0; + continue; + } + if (y[0] === 3 && (!c || y[1] > c[0] && y[1] < c[3])) { + s.label = y[1]; + break; + } + if (y[0] === 6 && s.label < c[1]) { + s.label = c[1], c = y; + break; + } + if (c && s.label < c[2]) { + s.label = c[2], s.ops.push(y); + break; + } + c[2] && s.ops.pop(), s.trys.pop(); + continue; + } + y = r.call(n, s); + } catch (g) { + y = [6, g], t = 0; + } finally { + e = c = 0; + } + if (5 & y[0]) throw y[1]; + return { value: y[0] ? y[1] : void 0, done: !0 }; + })([l, v]); + }; + } + }, o = this && this.__importDefault || function(n) { + return n && n.__esModule ? n : { default: n }; + }; + Object.defineProperty(O, "__esModule", { value: !0 }), O.SessionCoordinator = void 0; + var f = o(E(5673)), a = (0, E(9764).createLogger)("SessionCoordinator"), i = (function() { + function n(r) { + r && (this.sessionManager = r, this.refreshManager = new f.default(r)); + } + return Object.defineProperty(n.prototype, "hasActiveSession", { get: function() { + return !!this.sessionManager && this.sessionManager.hasActiveSession; + }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isSessionAvailable", { get: function() { + return !!this.sessionManager; + }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "sessionExpiry", { get: function() { + if (this.sessionManager) { + var r = this.sessionManager.sessionTimeRemaining; + return r > 0 ? new Date(Date.now() + r) : void 0; + } + }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isAutoRefreshActive", { get: function() { + var r, e; + return (e = (r = this.refreshManager) === null || r === void 0 ? void 0 : r.isActive()) !== null && e !== void 0 && e; + }, enumerable: !1, configurable: !0 }), n.prototype.getSessionManager = function() { + return this.sessionManager; + }, n.prototype.clearSession = function() { + this.sessionManager && (this.stopRefreshManager(), this.sessionManager.clearSession(), a.info("Session cleared")); + }, n.prototype.canAutoRestore = function() { + return h(this, void 0, void 0, function() { + return d(this, function(r) { + return this.sessionManager && this.sessionManager.canAutoRestore ? [2, this.sessionManager.hasValidSession()] : [2, !1]; + }); + }); + }, n.prototype.tryAutoRestore = function() { + return h(this, void 0, void 0, function() { + var r, e; + return d(this, function(t) { + switch (t.label) { + case 0: + if (!this.sessionManager) return [2, void 0]; + t.label = 1; + case 1: + return t.trys.push([1, 3, , 4]), [4, this.sessionManager.restoreSession()]; + case 2: + return (r = t.sent()) && this.startRefreshManager(), [2, r]; + case 3: + return e = t.sent(), a.error("Session auto-restoration error:", e), [2, void 0]; + case 4: + return [2]; + } + }); + }); + }, n.prototype.createSession = function(r) { + return h(this, void 0, void 0, function() { + var e; + return d(this, function(t) { + switch (t.label) { + case 0: + if (!this.sessionManager) return a.warn("No session manager available - skipping session creation"), [2]; + t.label = 1; + case 1: + return t.trys.push([1, 3, , 4]), [4, this.sessionManager.createSession(r)]; + case 2: + return t.sent(), this.startRefreshManager(), [3, 4]; + case 3: + throw e = t.sent(), a.error("Failed to create session:", e), e; + case 4: + return [2]; + } + }); + }); + }, n.prototype.refreshSession = function() { + return h(this, void 0, void 0, function() { + return d(this, function(r) { + return this.sessionManager ? [2, this.sessionManager.refreshSession()] : [2, !1]; + }); + }); + }, n.prototype.getTimeRemaining = function() { + return h(this, void 0, void 0, function() { + return d(this, function(r) { + return this.sessionManager ? [2, this.sessionManager.sessionTimeRemaining] : [2, 0]; + }); + }); + }, n.prototype.startRefreshManager = function() { + var r; + !((r = this.sessionManager) === null || r === void 0) && r.config.enableActivityRefresh && this.refreshManager && !this.refreshManager.isActive() && (this.refreshManager.start(), a.info("Automatic session refresh started")); + }, n.prototype.stopRefreshManager = function() { + this.refreshManager && this.refreshManager.isActive() && (this.refreshManager.stop(), a.info("Automatic session refresh stopped")); + }, n; + })(); + O.SessionCoordinator = i; + }, 3581(N, O, E) { + var h = this && this.__awaiter || function(a, i, n, r) { + return new (n || (n = Promise))(function(e, t) { + function c(p) { + try { + u(r.next(p)); + } catch (l) { + t(l); + } + } + function s(p) { + try { + u(r.throw(p)); + } catch (l) { + t(l); + } + } + function u(p) { + var l; + p.done ? e(p.value) : (l = p.value, l instanceof n ? l : new n(function(v) { + v(l); + })).then(c, s); + } + u((r = r.apply(a, i || [])).next()); + }); + }, d = this && this.__generator || function(a, i) { + var n, r, e, t = { label: 0, sent: function() { + if (1 & e[0]) throw e[1]; + return e[1]; + }, trys: [], ops: [] }, c = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return c.next = s(0), c.throw = s(1), c.return = s(2), typeof Symbol == "function" && (c[Symbol.iterator] = function() { + return this; + }), c; + function s(u) { + return function(p) { + return (function(l) { + if (n) throw new TypeError("Generator is already executing."); + for (; c && (c = 0, l[0] && (t = 0)), t; ) try { + if (n = 1, r && (e = 2 & l[0] ? r.return : l[0] ? r.throw || ((e = r.return) && e.call(r), 0) : r.next) && !(e = e.call(r, l[1])).done) return e; + switch (r = 0, e && (l = [2 & l[0], e.value]), l[0]) { + case 0: + case 1: + e = l; + break; + case 4: + return t.label++, { value: l[1], done: !1 }; + case 5: + t.label++, r = l[1], l = [0]; + continue; + case 7: + l = t.ops.pop(), t.trys.pop(); + continue; + default: + if (!((e = (e = t.trys).length > 0 && e[e.length - 1]) || l[0] !== 6 && l[0] !== 2)) { + t = 0; + continue; + } + if (l[0] === 3 && (!e || l[1] > e[0] && l[1] < e[3])) { + t.label = l[1]; + break; + } + if (l[0] === 6 && t.label < e[1]) { + t.label = e[1], e = l; + break; + } + if (e && t.label < e[2]) { + t.label = e[2], t.ops.push(l); + break; + } + e[2] && t.ops.pop(), t.trys.pop(); + continue; + } + l = i.call(a, t); + } catch (v) { + l = [6, v], r = 0; + } finally { + n = e = 0; + } + if (5 & l[0]) throw l[1]; + return { value: l[0] ? l[1] : void 0, done: !0 }; + })([u, p]); + }; + } + }; + Object.defineProperty(O, "__esModule", { value: !0 }), O.SessionStrategy = void 0; + var o = (0, E(9764).createLogger)("SessionStrategy"), f = (function() { + function a(i) { + this.sessionManager = i, this.method = "session"; + } + return Object.defineProperty(a.prototype, "isSupported", { get: function() { + return !0; + }, enumerable: !1, configurable: !0 }), Object.defineProperty(a.prototype, "isUnlocked", { get: function() { + return this.sessionManager.hasActiveSession; + }, enumerable: !1, configurable: !0 }), Object.defineProperty(a.prototype, "hasAnyCredentials", { get: function() { + return this.sessionManager.hasActiveSession; + }, enumerable: !1, configurable: !0 }), a.prototype.clear = function() { + this.sessionManager.clearSession(); + }, a.prototype.unlock = function(i) { + return h(this, void 0, void 0, function() { + var n; + return d(this, function(r) { + switch (r.label) { + case 0: + if (i.method !== "session") return [2, !1]; + r.label = 1; + case 1: + return r.trys.push([1, 3, , 4]), [4, this.sessionManager.restoreSession()]; + case 2: + return [2, !!r.sent()]; + case 3: + return n = r.sent(), o.error("Session restore failed:", n), [2, !1]; + case 4: + return [2]; + } + }); + }); + }, a.prototype.canAutoRestore = function() { + return h(this, void 0, void 0, function() { + return d(this, function(i) { + switch (i.label) { + case 0: + return this.sessionManager.canAutoRestore ? [4, this.sessionManager.hasValidSession()] : [2, !1]; + case 1: + return [2, i.sent()]; + } + }); + }); + }, a.prototype.getCredential = function(i) { + return h(this, void 0, void 0, function() { + var n, r; + return d(this, function(e) { + switch (e.label) { + case 0: + if (!this.isUnlocked) return o.warn("Cannot get credential - no active session"), [2, void 0]; + e.label = 1; + case 1: + return e.trys.push([1, 3, , 4]), [4, this.sessionManager.restoreSession()]; + case 2: + return (n = e.sent()) && i in n ? [2, n[i].toString()] : [2, void 0]; + case 3: + return r = e.sent(), o.error("Failed to get credential ".concat(i, ":"), r), [2, void 0]; + case 4: + return [2]; + } + }); + }); + }, a.prototype.setCredential = function(i, n) { + return h(this, void 0, void 0, function() { + return d(this, function(r) { + throw o.warn("setCredential(".concat(i, ") not supported - use createSession() instead")), new Error("SessionStrategy does not support direct credential storage"); + }); + }); + }, a; + })(); + O.SessionStrategy = f; + }, 8348(N, O, E) { + Object.defineProperty(O, "__esModule", { value: !0 }), O.StrategyManager = void 0; + var h = E(9764), d = E(9389), o = E(8562), f = E(3581), a = (0, h.createLogger)("StrategyManager"), i = (function() { + function n(r, e) { + this.strategies = /* @__PURE__ */ new Map(), this.registerStrategies(r, e); + } + return Object.defineProperty(n.prototype, "hasAnyCredentials", { get: function() { + return Array.from(this.strategies.entries()).some(function(r) { + var e = r[0], t = r[1]; + return e !== "session" && t.hasAnyCredentials; + }); + }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "preferredMethod", { get: function() { + var r, e = this.strategies.get("session"); + if (e?.hasAnyCredentials || e?.isUnlocked) return "session"; + var t = this.strategies.get("passkey"); + if (t?.isSupported && (!((r = t.hasStoredAuthData) === null || r === void 0) && r.call(t))) return "passkey"; + var c = this.strategies.get("password"); + return c?.hasAnyCredentials, "password"; + }, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "supportedMethods", { get: function() { + var r = []; + return Array.from(this.strategies.entries()).forEach(function(e) { + var t = e[0]; + e[1].isSupported && r.push(t); + }), r; + }, enumerable: !1, configurable: !0 }), n.prototype.getStrategy = function(r) { + return this.strategies.get(r); + }, n.prototype.clearAll = function() { + this.strategies.forEach(function(r) { + return r.clear(); + }), a.info("Cleared all strategies"); + }, n.prototype.registerStrategies = function(r, e) { + var t = r.namespace || "default"; + if (this.strategies.set("password", new o.PasswordStrategy(t)), r.allowPasskeys) { + var c = r.passkeyDisplayName || "LNC User (".concat(t, ")"); + this.strategies.set("passkey", new d.PasskeyStrategy(t, c)); + } + e && this.strategies.set("session", new f.SessionStrategy(e)), a.info("Registered strategies: ".concat(Array.from(this.strategies.keys()).join(", "))); + }, n; + })(); + O.StrategyManager = i; + }, 6482(N, O) { + var E = this && this.__awaiter || function(d, o, f, a) { + return new (f || (f = Promise))(function(i, n) { + function r(c) { + try { + t(a.next(c)); + } catch (s) { + n(s); + } + } + function e(c) { + try { + t(a.throw(c)); + } catch (s) { + n(s); + } + } + function t(c) { + var s; + c.done ? i(c.value) : (s = c.value, s instanceof f ? s : new f(function(u) { + u(s); + })).then(r, e); + } + t((a = a.apply(d, o || [])).next()); + }); + }, h = this && this.__generator || function(d, o) { + var f, a, i, n = { label: 0, sent: function() { + if (1 & i[0]) throw i[1]; + return i[1]; + }, trys: [], ops: [] }, r = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return r.next = e(0), r.throw = e(1), r.return = e(2), typeof Symbol == "function" && (r[Symbol.iterator] = function() { + return this; + }), r; + function e(t) { + return function(c) { + return (function(s) { + if (f) throw new TypeError("Generator is already executing."); + for (; r && (r = 0, s[0] && (n = 0)), n; ) try { + if (f = 1, a && (i = 2 & s[0] ? a.return : s[0] ? a.throw || ((i = a.return) && i.call(a), 0) : a.next) && !(i = i.call(a, s[1])).done) return i; + switch (a = 0, i && (s = [2 & s[0], i.value]), s[0]) { + case 0: + case 1: + i = s; + break; + case 4: + return n.label++, { value: s[1], done: !1 }; + case 5: + n.label++, a = s[1], s = [0]; + continue; + case 7: + s = n.ops.pop(), n.trys.pop(); + continue; + default: + if (!((i = (i = n.trys).length > 0 && i[i.length - 1]) || s[0] !== 6 && s[0] !== 2)) { + n = 0; + continue; + } + if (s[0] === 3 && (!i || s[1] > i[0] && s[1] < i[3])) { + n.label = s[1]; + break; + } + if (s[0] === 6 && n.label < i[1]) { + n.label = i[1], i = s; + break; + } + if (i && n.label < i[2]) { + n.label = i[2], n.ops.push(s); + break; + } + i[2] && n.ops.pop(), n.trys.pop(); + continue; + } + s = o.call(d, n); + } catch (u) { + s = [6, u], a = 0; + } finally { + f = i = 0; + } + if (5 & s[0]) throw s[1]; + return { value: s[0] ? s[1] : void 0, done: !0 }; + })([t, c]); + }; + } + }; + Object.defineProperty(O, "__esModule", { value: !0 }), O.waitFor = function(d, o) { + return E(this, void 0, void 0, function() { + return h(this, function(f) { + return [2, new Promise(function(a, i) { + var n = 0, r = setInterval(function() { + n++, d() ? (clearInterval(r), a()) : n > 20 && (clearInterval(r), i(new Error(o))); + }, 500); + })]; + }); + }); + }; + }, 5820(N, O, E) { + Object.defineProperty(O, "__esModule", { value: !0 }); + var h = E(5105), d = "lnc-web", o = (function() { + function f(a, i) { + this.persisted = { salt: "", cipher: "", serverHost: "", localKey: "", remoteKey: "", pairingPhrase: "" }, this._localKey = "", this._remoteKey = "", this._pairingPhrase = "", this.namespace = "default", a && (this.namespace = a), this._load(), i && (this.password = i); + } + return Object.defineProperty(f.prototype, "password", { get: function() { + return this._password || ""; + }, set: function(a) { + if (this.persisted.cipher) { + var i = this.persisted, n = i.cipher, r = i.salt; + if (!(0, h.verifyTestCipher)(n, a, r)) throw new Error("The password provided is not valid"); + this._password = a, this._pairingPhrase = this._decrypt(this.persisted.pairingPhrase), this._localKey = this._decrypt(this.persisted.localKey), this._remoteKey = this._decrypt(this.persisted.remoteKey); + } else this._password = a, this.persisted.salt = (0, h.generateSalt)(), this.persisted.cipher = (0, h.createTestCipher)(a, this.persisted.salt), this.pairingPhrase && (this.persisted.pairingPhrase = this._encrypt(this.pairingPhrase)), this.localKey && (this.persisted.localKey = this._encrypt(this.localKey)), this.remoteKey && (this.persisted.remoteKey = this._encrypt(this.remoteKey)), this._save(), this.clear(!0); + }, enumerable: !1, configurable: !0 }), Object.defineProperty(f.prototype, "serverHost", { get: function() { + return this.persisted.serverHost; + }, set: function(a) { + this.persisted.serverHost = a, this._save(); + }, enumerable: !1, configurable: !0 }), Object.defineProperty(f.prototype, "pairingPhrase", { get: function() { + return this._pairingPhrase; + }, set: function(a) { + this._pairingPhrase = a, this._password && (this.persisted.pairingPhrase = this._encrypt(a), this._save()); + }, enumerable: !1, configurable: !0 }), Object.defineProperty(f.prototype, "localKey", { get: function() { + return this._localKey; + }, set: function(a) { + this._localKey = a, this._password && (this.persisted.localKey = this._encrypt(a), this._save()); + }, enumerable: !1, configurable: !0 }), Object.defineProperty(f.prototype, "remoteKey", { get: function() { + return this._remoteKey; + }, set: function(a) { + this._remoteKey = a, this._password && (this.persisted.remoteKey = this._encrypt(a), this._save()); + }, enumerable: !1, configurable: !0 }), Object.defineProperty(f.prototype, "isPaired", { get: function() { + return !!this.persisted.remoteKey || !!this.persisted.pairingPhrase; + }, enumerable: !1, configurable: !0 }), f.prototype.clear = function(a) { + if (!a) { + var i = "".concat(d, ":").concat(this.namespace); + localStorage.removeItem(i), this.persisted = { salt: "", cipher: "", serverHost: this.persisted.serverHost, localKey: "", remoteKey: "", pairingPhrase: "" }; + } + this._localKey = "", this._remoteKey = "", this._pairingPhrase = "", this._password = void 0; + }, f.prototype._load = function() { + if (typeof localStorage < "u") try { + var a = "".concat(d, ":").concat(this.namespace), i = localStorage.getItem(a); + if (!i) return; + this.persisted = JSON.parse(i); + } catch (r) { + var n = r.message; + throw new Error("Failed to load secure data: ".concat(n)); + } + }, f.prototype._save = function() { + if (typeof localStorage < "u") { + var a = "".concat(d, ":").concat(this.namespace); + localStorage.setItem(a, JSON.stringify(this.persisted)); + } + }, f.prototype._encrypt = function(a) { + return a && this._password ? (0, h.encrypt)(a, this._password, this.persisted.salt) : ""; + }, f.prototype._decrypt = function(a) { + return a && this._password ? (0, h.decrypt)(a, this._password, this.persisted.salt) : ""; + }, f; + })(); + O.default = o; + }, 1389(N, O) { + Object.defineProperty(O, "__esModule", { value: !0 }), O.arrayBufferToBase64 = function(E) { + for (var h = new Uint8Array(E), d = "", o = 0; o < h.byteLength; o++) d += String.fromCharCode(h[o]); + return btoa(d); + }, O.base64ToArrayBuffer = function(E) { + for (var h = E.replace(/-/g, "+").replace(/_/g, "/"), d = h.padEnd(h.length + (4 - h.length % 4) % 4, "="), o = atob(d), f = new Uint8Array(o.length), a = 0; a < o.length; a++) f[a] = o.charCodeAt(a); + return f.buffer; + }, O.arrayBufferToHex = function(E) { + return Array.from(new Uint8Array(E)).map(function(h) { + return h.toString(16).padStart(2, "0"); + }).join(""); + }; + }, 5105(N, O, E) { + Object.defineProperty(O, "__esModule", { value: !0 }), O.verifyTestCipher = O.createTestCipher = O.decrypt = O.encrypt = O.generateSalt = void 0; + var h = E(1396), d = "Irrelevant data for password verification"; + O.generateSalt = function() { + var o = new Uint8Array(32); + globalThis.crypto.getRandomValues(o); + var f = Array.from(o, function(a) { + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charCodeAt(a % 62); + }); + return String.fromCharCode.apply(String, f); + }, O.encrypt = function(o, f, a) { + return h.AES.encrypt(JSON.stringify(o), f + a).toString(); + }, O.decrypt = function(o, f, a) { + var i = h.AES.decrypt(o, f + a); + return JSON.parse(i.toString(h.enc.Utf8)); + }, O.createTestCipher = function(o, f) { + return (0, O.encrypt)(d, o, f); + }, O.verifyTestCipher = function(o, f, a) { + try { + return (0, O.decrypt)(o, f, a) === d; + } catch { + return !1; + } + }; + }, 9764(N, O, E) { + var h = this && this.__spreadArray || function(i, n, r) { + if (r || arguments.length === 2) for (var e, t = 0, c = n.length; t < c; t++) !e && t in n || (e || (e = Array.prototype.slice.call(n, 0, t)), e[t] = n[t]); + return i.concat(e || Array.prototype.slice.call(n)); + }, d = this && this.__importDefault || function(i) { + return i && i.__esModule ? i : { default: i }; + }; + Object.defineProperty(O, "__esModule", { value: !0 }), O.wasmLog = O.log = O.Logger = O.LogLevel = void 0, O.createLogger = function(i) { + return a.fromEnv(i); + }; + var o, f = d(E(7833)); + (function(i) { + i[i.debug = 1] = "debug", i[i.info = 2] = "info", i[i.warn = 3] = "warn", i[i.error = 4] = "error", i[i.none = 5] = "none"; + })(o || (O.LogLevel = o = {})); + var a = (function() { + function i(n, r) { + var e = this; + this.debug = function(t) { + for (var c = [], s = 1; s < arguments.length; s++) c[s - 1] = arguments[s]; + return e._log(o.debug, t, c); + }, this.info = function(t) { + for (var c = [], s = 1; s < arguments.length; s++) c[s - 1] = arguments[s]; + return e._log(o.info, t, c); + }, this.warn = function(t) { + for (var c = [], s = 1; s < arguments.length; s++) c[s - 1] = arguments[s]; + return e._log(o.warn, t, c); + }, this.error = function(t) { + for (var c = [], s = 1; s < arguments.length; s++) c[s - 1] = arguments[s]; + return e._log(o.error, t, c); + }, this._levelToOutput = n, this._logger = (0, f.default)(r); + } + return Object.defineProperty(i.prototype, "level", { get: function() { + return this._levelToOutput; + }, enumerable: !1, configurable: !0 }), i.fromEnv = function(n) { + var r = o.none; + if (globalThis.localStorage && globalThis.localStorage.getItem("debug")) { + var e = globalThis.localStorage.getItem("debug-level") || "debug"; + r = o[e]; + } + return new i(r, n); + }, i.prototype._log = function(n, r, e) { + if (!(this._levelToOutput > n)) { + var t = Object.keys(o).reduce(function(c, s) { + return n === o[s] ? s : c; + }, "??"); + this._logger.apply(this, h(["[".concat(t, "] ").concat(r)], e, !1)); + } + }, i; + })(); + O.Logger = a, O.log = a.fromEnv("main"), O.wasmLog = a.fromEnv("wasm"); + }, 254(N, O, E) { + var h = this && this.__assign || function() { + return h = Object.assign || function(e) { + for (var t, c = 1, s = arguments.length; c < s; c++) for (var u in t = arguments[c]) Object.prototype.hasOwnProperty.call(t, u) && (e[u] = t[u]); + return e; + }, h.apply(this, arguments); + }, d = this && this.__awaiter || function(e, t, c, s) { + return new (c || (c = Promise))(function(u, p) { + function l(g) { + try { + y(s.next(g)); + } catch (_) { + p(_); + } + } + function v(g) { + try { + y(s.throw(g)); + } catch (_) { + p(_); + } + } + function y(g) { + var _; + g.done ? u(g.value) : (_ = g.value, _ instanceof c ? _ : new c(function(T) { + T(_); + })).then(l, v); + } + y((s = s.apply(e, t || [])).next()); + }); + }, o = this && this.__generator || function(e, t) { + var c, s, u, p = { label: 0, sent: function() { + if (1 & u[0]) throw u[1]; + return u[1]; + }, trys: [], ops: [] }, l = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype); + return l.next = v(0), l.throw = v(1), l.return = v(2), typeof Symbol == "function" && (l[Symbol.iterator] = function() { + return this; + }), l; + function v(y) { + return function(g) { + return (function(_) { + if (c) throw new TypeError("Generator is already executing."); + for (; l && (l = 0, _[0] && (p = 0)), p; ) try { + if (c = 1, s && (u = 2 & _[0] ? s.return : _[0] ? s.throw || ((u = s.return) && u.call(s), 0) : s.next) && !(u = u.call(s, _[1])).done) return u; + switch (s = 0, u && (_ = [2 & _[0], u.value]), _[0]) { + case 0: + case 1: + u = _; + break; + case 4: + return p.label++, { value: _[1], done: !1 }; + case 5: + p.label++, s = _[1], _ = [0]; + continue; + case 7: + _ = p.ops.pop(), p.trys.pop(); + continue; + default: + if (!((u = (u = p.trys).length > 0 && u[u.length - 1]) || _[0] !== 6 && _[0] !== 2)) { + p = 0; + continue; + } + if (_[0] === 3 && (!u || _[1] > u[0] && _[1] < u[3])) { + p.label = _[1]; + break; + } + if (_[0] === 6 && p.label < u[1]) { + p.label = u[1], u = _; + break; + } + if (u && p.label < u[2]) { + p.label = u[2], p.ops.push(_); + break; + } + u[2] && p.ops.pop(), p.trys.pop(); + continue; + } + _ = t.call(e, p); + } catch (T) { + _ = [6, T], s = 0; + } finally { + c = u = 0; + } + if (5 & _[0]) throw _[1]; + return { value: _[0] ? _[1] : void 0, done: !0 }; + })([y, g]); + }; + } + }; + Object.defineProperty(O, "__esModule", { value: !0 }), O.WasmManager = O.lncGlobal = void 0; + var f = E(3318), a = E(6482), i = E(9764); + O.lncGlobal = globalThis; + var n = { wasmClientIsReady: function() { + return !1; + }, wasmClientIsConnected: function() { + return !1; + }, wasmClientConnectServer: function() { + throw new Error("WASM client not initialized"); + }, wasmClientDisconnect: function() { + throw new Error("WASM client not initialized"); + }, wasmClientInvokeRPC: function() { + throw new Error("WASM client not initialized"); + }, wasmClientHasPerms: function() { + return !1; + }, wasmClientIsReadOnly: function() { + return !1; + }, wasmClientStatus: function() { + return "uninitialized"; + }, wasmClientGetExpiry: function() { + return 0; + } }, r = (function() { + function e(t, c, s) { + this._namespace = t, this._wasmClientCode = c, this._callbacks = s, this.go = new O.lncGlobal.Go(); + } + return Object.defineProperty(e.prototype, "wasm", { get: function() { + return O.lncGlobal[this._namespace]; + }, set: function(t) { + O.lncGlobal[this._namespace] = t; + }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isReady", { get: function() { + return this.wasm && this.wasm.wasmClientIsReady && this.wasm.wasmClientIsReady(); + }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isConnected", { get: function() { + return this.wasm && this.wasm.wasmClientIsConnected && this.wasm.wasmClientIsConnected(); + }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "status", { get: function() { + return this.wasm && this.wasm.wasmClientStatus && this.wasm.wasmClientStatus(); + }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "expiry", { get: function() { + return this.wasm && this.wasm.wasmClientGetExpiry && new Date(1e3 * this.wasm.wasmClientGetExpiry()); + }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isReadOnly", { get: function() { + return this.wasm && this.wasm.wasmClientIsReadOnly && this.wasm.wasmClientIsReadOnly(); + }, enumerable: !1, configurable: !0 }), e.prototype.hasPerms = function(t) { + return this.wasm && this.wasm.wasmClientHasPerms && this.wasm.wasmClientHasPerms(t); + }, e.prototype.preload = function() { + return d(this, void 0, void 0, function() { + var t; + return o(this, function(c) { + switch (c.label) { + case 0: + return this._preloadPromise ? [4, this._preloadPromise] : [3, 2]; + case 1: + return c.sent(), [2]; + case 2: + return this._preloadPromise = WebAssembly.instantiateStreaming(fetch(this._wasmClientCode), this.go.importObject), t = this, [4, this._preloadPromise]; + case 3: + return t.result = c.sent(), i.wasmLog.info("downloaded WASM file"), [2]; + } + }); + }); + }, e.prototype.run = function() { + return d(this, void 0, void 0, function() { + return o(this, function(t) { + switch (t.label) { + case 0: + return this.isReady ? [3, 2] : [4, this.preload()]; + case 1: + t.sent(), t.label = 2; + case 2: + return typeof this.wasm != "object" && (this.wasm = h({}, n)), this.setupWasmCallbacks(), this.go.argv = ["wasm-client", "--debuglevel=debug,GOBN=info,GRPC=info", "--namespace=" + this._namespace, "--onlocalprivcreate=".concat(this._namespace, ".onLocalPrivCreate"), "--onremotekeyreceive=".concat(this._namespace, ".onRemoteKeyReceive"), "--onauthdata=".concat(this._namespace, ".onAuthData")], this.result ? (this.go.run(this.result.instance), [4, WebAssembly.instantiate(this.result.module, this.go.importObject)]) : [3, 4]; + case 3: + return t.sent(), [3, 5]; + case 4: + throw new Error("Can't find WASM instance."); + case 5: + return [2]; + } + }); + }); + }, e.prototype.waitTilReady = function() { + return d(this, void 0, void 0, function() { + var t = this; + return o(this, function(c) { + switch (c.label) { + case 0: + return [4, (0, a.waitFor)(function() { + return t.isReady; + }, "Failed to load the WASM client")]; + case 1: + return c.sent(), i.wasmLog.info("The WASM client is ready"), [2]; + } + }); + }); + }, e.prototype.connect = function(t) { + return d(this, void 0, void 0, function() { + var c, s, u, p; + return o(this, function(l) { + switch (l.label) { + case 0: + return this.isConnected ? [2] : this.isReady ? [3, 3] : [4, this.run()]; + case 1: + return l.sent(), [4, this.waitTilReady()]; + case 2: + l.sent(), l.label = 3; + case 3: + return c = t.pairingPhrase, s = t.localKey, u = t.remoteKey, p = t.serverHost, this.wasm.wasmClientConnectServer(p, !1, c, s ?? "", u ?? ""), typeof window < "u" ? window.addEventListener("unload", this.wasm.wasmClientDisconnect) : i.wasmLog.info("No unload event listener added. window is not available"), [4, this.waitForConnection()]; + case 4: + return l.sent(), [2]; + } + }); + }); + }, e.prototype.disconnect = function() { + typeof window < "u" && window.removeEventListener("unload", this.wasm.wasmClientDisconnect), this.wasm.wasmClientDisconnect(); + }, e.prototype.request = function(t, c) { + var s = this; + return new Promise(function(u, p) { + i.wasmLog.debug("".concat(t, " request"), c); + var l = JSON.stringify(c || {}); + s.wasm.wasmClientInvokeRPC(t, l, function(v) { + try { + var y = JSON.parse(v), g = (0, f.snakeKeysToCamel)(y); + i.wasmLog.debug("".concat(t, " response"), g), u(g); + } catch (_) { + i.wasmLog.debug("".concat(t, " parser error"), { response: v, error: _ }), p(new Error(v)); + } + }); + }); + }, e.prototype.subscribe = function(t, c, s, u) { + i.wasmLog.debug("".concat(t, " request"), c); + var p = JSON.stringify(c || {}); + this.wasm.wasmClientInvokeRPC(t, p, function(l) { + try { + var v = JSON.parse(l), y = (0, f.snakeKeysToCamel)(v); + i.wasmLog.debug("".concat(t, " response"), y), s && s(y); + } catch (_) { + i.wasmLog.debug("".concat(t, " error"), _); + var g = new Error(l); + u && u(g); + } + }); + }, e.prototype.setupWasmCallbacks = function() { + var t = this; + this.wasm.onLocalPrivCreate || (this.wasm.onLocalPrivCreate = function(c) { + t._callbacks.onLocalKeyCreated(c); + }), this.wasm.onRemoteKeyReceive || (this.wasm.onRemoteKeyReceive = function(c) { + t._callbacks.onRemoteKeyReceived(c); + }), this.wasm.onAuthData || (this.wasm.onAuthData = function(c) { + i.wasmLog.debug("auth data received: " + c); + }); + }, e.prototype.waitForConnection = function() { + return d(this, void 0, void 0, function() { + var t = this; + return o(this, function(c) { + switch (c.label) { + case 0: + return [4, (0, a.waitFor)(function() { + return t.isConnected; + }, "Failed to connect the WASM client to the proxy server")]; + case 1: + return c.sent(), i.wasmLog.info("The WASM client is connected to the server"), [2]; + } + }); + }); + }, e; + })(); + O.WasmManager = r; + }, 1135(N) { + N.exports = function(O) { + return O && typeof O == "object" && typeof O.copy == "function" && typeof O.fill == "function" && typeof O.readUInt8 == "function"; + }; + }, 9032(N, O, E) { + var h = E(7244), d = E(8184), o = E(5767), f = E(5680); + function a(S) { + return S.call.bind(S); + } + var i = typeof BigInt < "u", n = typeof Symbol < "u", r = a(Object.prototype.toString), e = a(Number.prototype.valueOf), t = a(String.prototype.valueOf), c = a(Boolean.prototype.valueOf); + if (i) var s = a(BigInt.prototype.valueOf); + if (n) var u = a(Symbol.prototype.valueOf); + function p(S, M) { + if (typeof S != "object") return !1; + try { + return M(S), !0; + } catch { + return !1; + } + } + function l(S) { + return r(S) === "[object Map]"; + } + function v(S) { + return r(S) === "[object Set]"; + } + function y(S) { + return r(S) === "[object WeakMap]"; + } + function g(S) { + return r(S) === "[object WeakSet]"; + } + function _(S) { + return r(S) === "[object ArrayBuffer]"; + } + function T(S) { + return typeof ArrayBuffer < "u" && (_.working ? _(S) : S instanceof ArrayBuffer); + } + function b(S) { + return r(S) === "[object DataView]"; + } + function A(S) { + return typeof DataView < "u" && (b.working ? b(S) : S instanceof DataView); + } + O.isArgumentsObject = h, O.isGeneratorFunction = d, O.isTypedArray = f, O.isPromise = function(S) { + return typeof Promise < "u" && S instanceof Promise || S !== null && typeof S == "object" && typeof S.then == "function" && typeof S.catch == "function"; + }, O.isArrayBufferView = function(S) { + return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? ArrayBuffer.isView(S) : f(S) || A(S); + }, O.isUint8Array = function(S) { + return o(S) === "Uint8Array"; + }, O.isUint8ClampedArray = function(S) { + return o(S) === "Uint8ClampedArray"; + }, O.isUint16Array = function(S) { + return o(S) === "Uint16Array"; + }, O.isUint32Array = function(S) { + return o(S) === "Uint32Array"; + }, O.isInt8Array = function(S) { + return o(S) === "Int8Array"; + }, O.isInt16Array = function(S) { + return o(S) === "Int16Array"; + }, O.isInt32Array = function(S) { + return o(S) === "Int32Array"; + }, O.isFloat32Array = function(S) { + return o(S) === "Float32Array"; + }, O.isFloat64Array = function(S) { + return o(S) === "Float64Array"; + }, O.isBigInt64Array = function(S) { + return o(S) === "BigInt64Array"; + }, O.isBigUint64Array = function(S) { + return o(S) === "BigUint64Array"; + }, l.working = typeof Map < "u" && l(/* @__PURE__ */ new Map()), O.isMap = function(S) { + return typeof Map < "u" && (l.working ? l(S) : S instanceof Map); + }, v.working = typeof Set < "u" && v(/* @__PURE__ */ new Set()), O.isSet = function(S) { + return typeof Set < "u" && (v.working ? v(S) : S instanceof Set); + }, y.working = typeof WeakMap < "u" && y(/* @__PURE__ */ new WeakMap()), O.isWeakMap = function(S) { + return typeof WeakMap < "u" && (y.working ? y(S) : S instanceof WeakMap); + }, g.working = typeof WeakSet < "u" && g(/* @__PURE__ */ new WeakSet()), O.isWeakSet = function(S) { + return g(S); + }, _.working = typeof ArrayBuffer < "u" && _(new ArrayBuffer()), O.isArrayBuffer = T, b.working = typeof ArrayBuffer < "u" && typeof DataView < "u" && b(new DataView(new ArrayBuffer(1), 0, 1)), O.isDataView = A; + var m = typeof SharedArrayBuffer < "u" ? SharedArrayBuffer : void 0; + function I(S) { + return r(S) === "[object SharedArrayBuffer]"; + } + function P(S) { + return m !== void 0 && (I.working === void 0 && (I.working = I(new m())), I.working ? I(S) : S instanceof m); + } + function x(S) { + return p(S, e); + } + function F(S) { + return p(S, t); + } + function K(S) { + return p(S, c); + } + function Y(S) { + return i && p(S, s); + } + function Q(S) { + return n && p(S, u); + } + O.isSharedArrayBuffer = P, O.isAsyncFunction = function(S) { + return r(S) === "[object AsyncFunction]"; + }, O.isMapIterator = function(S) { + return r(S) === "[object Map Iterator]"; + }, O.isSetIterator = function(S) { + return r(S) === "[object Set Iterator]"; + }, O.isGeneratorObject = function(S) { + return r(S) === "[object Generator]"; + }, O.isWebAssemblyCompiledModule = function(S) { + return r(S) === "[object WebAssembly.Module]"; + }, O.isNumberObject = x, O.isStringObject = F, O.isBooleanObject = K, O.isBigIntObject = Y, O.isSymbolObject = Q, O.isBoxedPrimitive = function(S) { + return x(S) || F(S) || K(S) || Y(S) || Q(S); + }, O.isAnyArrayBuffer = function(S) { + return typeof Uint8Array < "u" && (T(S) || P(S)); + }, ["isProxy", "isExternal", "isModuleNamespaceObject"].forEach(function(S) { + Object.defineProperty(O, S, { enumerable: !1, value: function() { + throw new Error(S + " is not supported in userland"); + } }); + }); + }, 537(N, O, E) { + var h = E(5606), d = E(6763), o = Object.getOwnPropertyDescriptors || function(S) { + for (var M = Object.keys(S), j = {}, H = 0; H < M.length; H++) j[M[H]] = Object.getOwnPropertyDescriptor(S, M[H]); + return j; + }, f = /%[sdj%]/g; + O.format = function(S) { + if (!g(S)) { + for (var M = [], j = 0; j < arguments.length; j++) M.push(r(arguments[j])); + return M.join(" "); + } + j = 1; + for (var H = arguments, Z = H.length, L = String(S).replace(f, function(C) { + if (C === "%%") return "%"; + if (j >= Z) return C; + switch (C) { + case "%s": + return String(H[j++]); + case "%d": + return Number(H[j++]); + case "%j": + try { + return JSON.stringify(H[j++]); + } catch { + return "[Circular]"; + } + default: + return C; + } + }), w = H[j]; j < Z; w = H[++j]) v(w) || !b(w) ? L += " " + w : L += " " + r(w); + return L; + }, O.deprecate = function(S, M) { + if (h !== void 0 && h.noDeprecation === !0) return S; + if (h === void 0) return function() { + return O.deprecate(S, M).apply(this, arguments); + }; + var j = !1; + return function() { + if (!j) { + if (h.throwDeprecation) throw new Error(M); + h.traceDeprecation ? d.trace(M) : d.error(M), j = !0; + } + return S.apply(this, arguments); + }; + }; + var a = {}, i = /^$/; + if (h.env.NODE_DEBUG) { + var n = h.env.NODE_DEBUG; + n = n.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".*").replace(/,/g, "$|^").toUpperCase(), i = new RegExp("^" + n + "$", "i"); + } + function r(S, M) { + var j = { seen: [], stylize: t }; + return arguments.length >= 3 && (j.depth = arguments[2]), arguments.length >= 4 && (j.colors = arguments[3]), l(M) ? j.showHidden = M : M && O._extend(j, M), _(j.showHidden) && (j.showHidden = !1), _(j.depth) && (j.depth = 2), _(j.colors) && (j.colors = !1), _(j.customInspect) && (j.customInspect = !0), j.colors && (j.stylize = e), c(j, S, j.depth); + } + function e(S, M) { + var j = r.styles[M]; + return j ? "\x1B[" + r.colors[j][0] + "m" + S + "\x1B[" + r.colors[j][1] + "m" : S; + } + function t(S, M) { + return S; + } + function c(S, M, j) { + if (S.customInspect && M && I(M.inspect) && M.inspect !== O.inspect && (!M.constructor || M.constructor.prototype !== M)) { + var H = M.inspect(j, S); + return g(H) || (H = c(S, H, j)), H; + } + var Z = (function(k, G) { + if (_(G)) return k.stylize("undefined", "undefined"); + if (g(G)) { + var V = "'" + JSON.stringify(G).replace(/^"|"$/g, "").replace(/'/g, "\\'").replace(/\\"/g, '"') + "'"; + return k.stylize(V, "string"); + } + return y(G) ? k.stylize("" + G, "number") : l(G) ? k.stylize("" + G, "boolean") : v(G) ? k.stylize("null", "null") : void 0; + })(S, M); + if (Z) return Z; + var L = Object.keys(M), w = (function(k) { + var G = {}; + return k.forEach(function(V, W) { + G[V] = !0; + }), G; + })(L); + if (S.showHidden && (L = Object.getOwnPropertyNames(M)), m(M) && (L.indexOf("message") >= 0 || L.indexOf("description") >= 0)) return s(M); + if (L.length === 0) { + if (I(M)) { + var C = M.name ? ": " + M.name : ""; + return S.stylize("[Function" + C + "]", "special"); + } + if (T(M)) return S.stylize(RegExp.prototype.toString.call(M), "regexp"); + if (A(M)) return S.stylize(Date.prototype.toString.call(M), "date"); + if (m(M)) return s(M); + } + var R, B = "", D = !1, U = ["{", "}"]; + return p(M) && (D = !0, U = ["[", "]"]), I(M) && (B = " [Function" + (M.name ? ": " + M.name : "") + "]"), T(M) && (B = " " + RegExp.prototype.toString.call(M)), A(M) && (B = " " + Date.prototype.toUTCString.call(M)), m(M) && (B = " " + s(M)), L.length !== 0 || D && M.length != 0 ? j < 0 ? T(M) ? S.stylize(RegExp.prototype.toString.call(M), "regexp") : S.stylize("[Object]", "special") : (S.seen.push(M), R = D ? (function(k, G, V, W, z) { + for (var q = [], $ = 0, te = G.length; $ < te; ++$) K(G, String($)) ? q.push(u(k, G, V, W, String($), !0)) : q.push(""); + return z.forEach(function(re) { + re.match(/^\d+$/) || q.push(u(k, G, V, W, re, !0)); + }), q; + })(S, M, j, w, L) : L.map(function(k) { + return u(S, M, j, w, k, D); + }), S.seen.pop(), (function(k, G, V) { + return k.reduce(function(W, z) { + return z.indexOf(` +`), W + z.replace(/\u001b\[\d\d?m/g, "").length + 1; + }, 0) > 60 ? V[0] + (G === "" ? "" : G + ` + `) + " " + k.join(`, + `) + " " + V[1] : V[0] + G + " " + k.join(", ") + " " + V[1]; + })(R, B, U)) : U[0] + B + U[1]; + } + function s(S) { + return "[" + Error.prototype.toString.call(S) + "]"; + } + function u(S, M, j, H, Z, L) { + var w, C, R; + if ((R = Object.getOwnPropertyDescriptor(M, Z) || { value: M[Z] }).get ? C = R.set ? S.stylize("[Getter/Setter]", "special") : S.stylize("[Getter]", "special") : R.set && (C = S.stylize("[Setter]", "special")), K(H, Z) || (w = "[" + Z + "]"), C || (S.seen.indexOf(R.value) < 0 ? (C = v(j) ? c(S, R.value, null) : c(S, R.value, j - 1)).indexOf(` +`) > -1 && (C = L ? C.split(` +`).map(function(B) { + return " " + B; + }).join(` +`).slice(2) : ` +` + C.split(` +`).map(function(B) { + return " " + B; + }).join(` +`)) : C = S.stylize("[Circular]", "special")), _(w)) { + if (L && Z.match(/^\d+$/)) return C; + (w = JSON.stringify("" + Z)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/) ? (w = w.slice(1, -1), w = S.stylize(w, "name")) : (w = w.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'"), w = S.stylize(w, "string")); + } + return w + ": " + C; + } + function p(S) { + return Array.isArray(S); + } + function l(S) { + return typeof S == "boolean"; + } + function v(S) { + return S === null; + } + function y(S) { + return typeof S == "number"; + } + function g(S) { + return typeof S == "string"; + } + function _(S) { + return S === void 0; + } + function T(S) { + return b(S) && P(S) === "[object RegExp]"; + } + function b(S) { + return typeof S == "object" && S !== null; + } + function A(S) { + return b(S) && P(S) === "[object Date]"; + } + function m(S) { + return b(S) && (P(S) === "[object Error]" || S instanceof Error); + } + function I(S) { + return typeof S == "function"; + } + function P(S) { + return Object.prototype.toString.call(S); + } + function x(S) { + return S < 10 ? "0" + S.toString(10) : S.toString(10); + } + O.debuglog = function(S) { + if (S = S.toUpperCase(), !a[S]) if (i.test(S)) { + var M = h.pid; + a[S] = function() { + var j = O.format.apply(O, arguments); + d.error("%s %d: %s", S, M, j); + }; + } else a[S] = function() { + }; + return a[S]; + }, O.inspect = r, r.colors = { bold: [1, 22], italic: [3, 23], underline: [4, 24], inverse: [7, 27], white: [37, 39], grey: [90, 39], black: [30, 39], blue: [34, 39], cyan: [36, 39], green: [32, 39], magenta: [35, 39], red: [31, 39], yellow: [33, 39] }, r.styles = { special: "cyan", number: "yellow", boolean: "yellow", undefined: "grey", null: "bold", string: "green", date: "magenta", regexp: "red" }, O.types = E(9032), O.isArray = p, O.isBoolean = l, O.isNull = v, O.isNullOrUndefined = function(S) { + return S == null; + }, O.isNumber = y, O.isString = g, O.isSymbol = function(S) { + return typeof S == "symbol"; + }, O.isUndefined = _, O.isRegExp = T, O.types.isRegExp = T, O.isObject = b, O.isDate = A, O.types.isDate = A, O.isError = m, O.types.isNativeError = m, O.isFunction = I, O.isPrimitive = function(S) { + return S === null || typeof S == "boolean" || typeof S == "number" || typeof S == "string" || typeof S == "symbol" || S === void 0; + }, O.isBuffer = E(1135); + var F = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + function K(S, M) { + return Object.prototype.hasOwnProperty.call(S, M); + } + O.log = function() { + var S, M; + d.log("%s - %s", (M = [x((S = /* @__PURE__ */ new Date()).getHours()), x(S.getMinutes()), x(S.getSeconds())].join(":"), [S.getDate(), F[S.getMonth()], M].join(" ")), O.format.apply(O, arguments)); + }, O.inherits = E(6698), O._extend = function(S, M) { + if (!M || !b(M)) return S; + for (var j = Object.keys(M), H = j.length; H--; ) S[j[H]] = M[j[H]]; + return S; + }; + var Y = typeof Symbol < "u" ? Symbol("util.promisify.custom") : void 0; + function Q(S, M) { + if (!S) { + var j = new Error("Promise was rejected with a falsy value"); + j.reason = S, S = j; + } + return M(S); + } + O.promisify = function(S) { + if (typeof S != "function") throw new TypeError('The "original" argument must be of type Function'); + if (Y && S[Y]) { + var M; + if (typeof (M = S[Y]) != "function") throw new TypeError('The "util.promisify.custom" argument must be of type Function'); + return Object.defineProperty(M, Y, { value: M, enumerable: !1, writable: !1, configurable: !0 }), M; + } + function M() { + for (var j, H, Z = new Promise(function(C, R) { + j = C, H = R; + }), L = [], w = 0; w < arguments.length; w++) L.push(arguments[w]); + L.push(function(C, R) { + C ? H(C) : j(R); + }); + try { + S.apply(this, L); + } catch (C) { + H(C); + } + return Z; + } + return Object.setPrototypeOf(M, Object.getPrototypeOf(S)), Y && Object.defineProperty(M, Y, { value: M, enumerable: !1, writable: !1, configurable: !0 }), Object.defineProperties(M, o(S)); + }, O.promisify.custom = Y, O.callbackify = function(S) { + if (typeof S != "function") throw new TypeError('The "original" argument must be of type Function'); + function M() { + for (var j = [], H = 0; H < arguments.length; H++) j.push(arguments[H]); + var Z = j.pop(); + if (typeof Z != "function") throw new TypeError("The last argument must be of type Function"); + var L = this, w = function() { + return Z.apply(L, arguments); + }; + S.apply(this, j).then(function(C) { + h.nextTick(w.bind(null, null, C)); + }, function(C) { + h.nextTick(Q.bind(null, C, w)); + }); + } + return Object.setPrototypeOf(M, Object.getPrototypeOf(S)), Object.defineProperties(M, o(S)), M; + }; + }, 5767(N, O, E) { + var h = E(2682), d = E(9209), o = E(487), f = E(6556), a = E(5795), i = E(3628), n = f("Object.prototype.toString"), r = E(9092)(), e = typeof globalThis > "u" ? E.g : globalThis, t = d(), c = f("String.prototype.slice"), s = f("Array.prototype.indexOf", !0) || function(p, l) { + for (var v = 0; v < p.length; v += 1) if (p[v] === l) return v; + return -1; + }, u = { __proto__: null }; + h(t, r && a && i ? function(p) { + var l = new e[p](); + if (Symbol.toStringTag in l && i) { + var v = i(l), y = a(v, Symbol.toStringTag); + if (!y && v) { + var g = i(v); + y = a(g, Symbol.toStringTag); + } + u["$" + p] = o(y.get); + } + } : function(p) { + var l = new e[p](), v = l.slice || l.set; + v && (u["$" + p] = o(v)); + }), N.exports = function(p) { + if (!p || typeof p != "object") return !1; + if (!r) { + var l = c(n(p), 8, -1); + return s(t, l) > -1 ? l : l === "Object" && (function(v) { + var y = !1; + return h(u, function(g, _) { + if (!y) try { + g(v), y = c(_, 1); + } catch { + } + }), y; + })(p); + } + return a ? (function(v) { + var y = !1; + return h(u, function(g, _) { + if (!y) try { + "$" + g(v) === _ && (y = c(_, 1)); + } catch { + } + }), y; + })(p) : null; + }; + }, 477() { + }, 9209(N, O, E) { + var h = E(6578), d = typeof globalThis > "u" ? E.g : globalThis; + N.exports = function() { + for (var o = [], f = 0; f < h.length; f++) typeof d[h[f]] == "function" && (o[o.length] = h[f]); + return o; + }; + } }, Ae = {}; + function Ce(N) { + var O = Ae[N]; + if (O !== void 0) return O.exports; + var E = Ae[N] = { exports: {} }; + return Ie[N].call(E.exports, E, E.exports, Ce), E.exports; + } + return Ce.g = (function() { + if (typeof globalThis == "object") return globalThis; + try { + return this || new Function("return this")(); + } catch { + if (typeof window == "object") return window; + } + })(), Ce(4245); + })()); + })(Fe)), Fe.exports; +} +var Ge = ze(); +const qe = /* @__PURE__ */ Ye(Ge), Qe = /* @__PURE__ */ We({ + __proto__: null, + default: qe +}, [Ge]); +export { + Qe as i +}; diff --git a/vendor/bitlogin/bitlogin-shared-IsyHQNSG.js b/vendor/bitlogin/bitlogin-shared-IsyHQNSG.js new file mode 100644 index 00000000..6b496ec3 --- /dev/null +++ b/vendor/bitlogin/bitlogin-shared-IsyHQNSG.js @@ -0,0 +1,11772 @@ +import { a8 as D2 } from "./bitlogin-shared-B2Rc9khL.js"; +const wl = { + debug() { + } +}, Z2 = (e) => e.reduce((t, n) => t + n.toString(16).padStart(2, "0"), ""); +/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +function Qo(e) { + return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array"; +} +function bt(e, t = "") { + if (!Number.isSafeInteger(e) || e < 0) { + const n = t && `"${t}" `; + throw new Error(`${n}expected integer >= 0, got ${e}`); + } +} +function fe(e, t, n = "") { + const r = Qo(e), o = e?.length, i = t !== void 0; + if (!r || i && o !== t) { + const s = n && `"${n}" `, c = i ? ` of length ${t}` : "", a = r ? `length=${o}` : `type=${typeof e}`; + throw new Error(s + "expected Uint8Array" + c + ", got " + a); + } + return e; +} +function pr(e) { + if (typeof e != "function" || typeof e.create != "function") + throw new Error("Hash must wrapped by utils.createHasher"); + bt(e.outputLen), bt(e.blockLen); +} +function Xn(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 W2(e, t) { + fe(e, void 0, "digestInto() output"); + const n = t.outputLen; + if (e.length < n) + throw new Error('"digestInto() output" expected to be of length >=' + n); +} +function mn(...e) { + for (let t = 0; t < e.length; t++) + e[t].fill(0); +} +function Rr(e) { + return new DataView(e.buffer, e.byteOffset, e.byteLength); +} +function Ge(e, t) { + return e << 32 - t | e >>> t; +} +const yl = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", F2 = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")); +function pe(e) { + if (fe(e), yl) + return e.toHex(); + let t = ""; + for (let n = 0; n < e.length; n++) + t += F2[e[n]]; + return t; +} +const Je = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 }; +function es(e) { + if (e >= Je._0 && e <= Je._9) + return e - Je._0; + if (e >= Je.A && e <= Je.F) + return e - (Je.A - 10); + if (e >= Je.a && e <= Je.f) + return e - (Je.a - 10); +} +function ue(e) { + if (typeof e != "string") + throw new Error("hex string expected, got " + typeof e); + if (yl) + return Uint8Array.fromHex(e); + const t = e.length, n = t / 2; + if (t % 2) + throw new Error("hex string expected, got unpadded hex of length " + t); + const r = new Uint8Array(n); + for (let o = 0, i = 0; o < n; o++, i += 2) { + const s = es(e.charCodeAt(i)), c = es(e.charCodeAt(i + 1)); + if (s === void 0 || c === void 0) { + const a = e[i] + e[i + 1]; + throw new Error('hex string expected, got non-hex character "' + a + '" at index ' + i); + } + r[o] = s * 16 + c; + } + return r; +} +function Be(...e) { + let t = 0; + for (let r = 0; r < e.length; r++) { + const o = e[r]; + fe(o), t += o.length; + } + const n = new Uint8Array(t); + for (let r = 0, o = 0; r < e.length; r++) { + const i = e[r]; + n.set(i, o), o += i.length; + } + return n; +} +function V2(e, t = {}) { + const n = (o, i) => e(i).update(o).digest(), r = e(void 0); + return n.outputLen = r.outputLen, n.blockLen = r.blockLen, n.create = (o) => e(o), Object.assign(n, t), Object.freeze(n); +} +function nn(e = 32) { + const t = typeof globalThis == "object" ? globalThis.crypto : null; + if (typeof t?.getRandomValues != "function") + throw new Error("crypto.getRandomValues must be defined"); + return t.getRandomValues(new Uint8Array(e)); +} +const G2 = (e) => ({ + oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, e]) +}); +function j2(e, t, n) { + return e & t ^ ~e & n; +} +function z2(e, t, n) { + return e & t ^ e & n ^ t & n; +} +class q2 { + blockLen; + outputLen; + padOffset; + isLE; + // For partial updates less than block size + buffer; + view; + finished = !1; + length = 0; + pos = 0; + destroyed = !1; + constructor(t, n, r, o) { + this.blockLen = t, this.outputLen = n, this.padOffset = r, this.isLE = o, this.buffer = new Uint8Array(t), this.view = Rr(this.buffer); + } + update(t) { + Xn(this), fe(t); + const { view: n, buffer: r, blockLen: o } = this, i = t.length; + for (let s = 0; s < i; ) { + const c = Math.min(o - this.pos, i - s); + if (c === o) { + const a = Rr(t); + for (; o <= i - s; s += o) + this.process(a, s); + continue; + } + r.set(t.subarray(s, s + c), this.pos), this.pos += c, s += c, this.pos === o && (this.process(n, 0), this.pos = 0); + } + return this.length += t.length, this.roundClean(), this; + } + digestInto(t) { + Xn(this), W2(t, this), this.finished = !0; + const { buffer: n, view: r, blockLen: o, isLE: i } = this; + let { pos: s } = this; + n[s++] = 128, mn(this.buffer.subarray(s)), this.padOffset > o - s && (this.process(r, 0), s = 0); + for (let g = s; g < o; g++) + n[g] = 0; + r.setBigUint64(o - 8, BigInt(this.length * 8), i), this.process(r, 0); + const c = Rr(t), a = this.outputLen; + if (a % 4) + throw new Error("_sha2: outputLen must be aligned to 32bit"); + const h = a / 4, w = this.get(); + if (h > w.length) + throw new Error("_sha2: outputLen bigger than state"); + for (let g = 0; g < h; g++) + c.setUint32(4 * g, w[g], i); + } + digest() { + const { buffer: t, outputLen: n } = this; + this.digestInto(t); + const r = t.slice(0, n); + return this.destroy(), r; + } + _cloneInto(t) { + t ||= new this.constructor(), t.set(...this.get()); + const { blockLen: n, buffer: r, length: o, finished: i, destroyed: s, pos: c } = this; + return t.destroyed = s, t.finished = i, t.length = o, t.pos = c, o % n && t.buffer.set(r), t; + } + clone() { + return this._cloneInto(); + } +} +const ot = /* @__PURE__ */ Uint32Array.from([ + 1779033703, + 3144134277, + 1013904242, + 2773480762, + 1359893119, + 2600822924, + 528734635, + 1541459225 +]), K2 = /* @__PURE__ */ 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 +]), it = /* @__PURE__ */ new Uint32Array(64); +class Q2 extends q2 { + constructor(t) { + super(64, t, 8, !1); + } + get() { + const { A: t, B: n, C: r, D: o, E: i, F: s, G: c, H: a } = this; + return [t, n, r, o, i, s, c, a]; + } + // prettier-ignore + set(t, n, r, o, i, s, c, a) { + this.A = t | 0, this.B = n | 0, this.C = r | 0, this.D = o | 0, this.E = i | 0, this.F = s | 0, this.G = c | 0, this.H = a | 0; + } + process(t, n) { + for (let g = 0; g < 16; g++, n += 4) + it[g] = t.getUint32(n, !1); + for (let g = 16; g < 64; g++) { + const v = it[g - 15], b = it[g - 2], C = Ge(v, 7) ^ Ge(v, 18) ^ v >>> 3, L = Ge(b, 17) ^ Ge(b, 19) ^ b >>> 10; + it[g] = L + it[g - 7] + C + it[g - 16] | 0; + } + let { A: r, B: o, C: i, D: s, E: c, F: a, G: h, H: w } = this; + for (let g = 0; g < 64; g++) { + const v = Ge(c, 6) ^ Ge(c, 11) ^ Ge(c, 25), b = w + v + j2(c, a, h) + K2[g] + it[g] | 0, L = (Ge(r, 2) ^ Ge(r, 13) ^ Ge(r, 22)) + z2(r, o, i) | 0; + w = h, h = a, a = c, c = s + b | 0, s = i, i = o, o = r, r = b + L | 0; + } + r = r + this.A | 0, o = o + this.B | 0, i = i + this.C | 0, s = s + this.D | 0, c = c + this.E | 0, a = a + this.F | 0, h = h + this.G | 0, w = w + this.H | 0, this.set(r, o, i, s, c, a, h, w); + } + roundClean() { + mn(it); + } + destroy() { + this.set(0, 0, 0, 0, 0, 0, 0, 0), mn(this.buffer); + } +} +class J2 extends Q2 { + // We cannot use array here since array allows indexing by variable + // which means optimizer/compiler cannot use registers. + A = ot[0] | 0; + B = ot[1] | 0; + C = ot[2] | 0; + D = ot[3] | 0; + E = ot[4] | 0; + F = ot[5] | 0; + G = ot[6] | 0; + H = ot[7] | 0; + constructor() { + super(32); + } +} +const Ke = /* @__PURE__ */ V2( + () => new J2(), + /* @__PURE__ */ G2(1) +); +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +const Jo = /* @__PURE__ */ BigInt(0), Co = /* @__PURE__ */ BigInt(1); +function er(e, t = "") { + if (typeof e != "boolean") { + const n = t && `"${t}" `; + throw new Error(n + "expected boolean, got type=" + typeof e); + } + return e; +} +function bl(e) { + if (typeof e == "bigint") { + if (!jn(e)) + throw new Error("positive bigint expected, got " + e); + } else + bt(e); + return e; +} +function Rn(e) { + const t = bl(e).toString(16); + return t.length & 1 ? "0" + t : t; +} +function ml(e) { + if (typeof e != "string") + throw new Error("hex string expected, got " + typeof e); + return e === "" ? Jo : BigInt("0x" + e); +} +function Ln(e) { + return ml(pe(e)); +} +function vl(e) { + return ml(pe(Y2(fe(e)).reverse())); +} +function Yo(e, t) { + bt(t), e = bl(e); + const n = ue(e.toString(16).padStart(t * 2, "0")); + if (n.length !== t) + throw new Error("number too large"); + return n; +} +function Cl(e, t) { + return Yo(e, t).reverse(); +} +function Y2(e) { + return Uint8Array.from(e); +} +function X2(e) { + return Uint8Array.from(e, (t, n) => { + const r = t.charCodeAt(0); + if (t.length !== 1 || r > 127) + throw new Error(`string contains non-ASCII character "${e[n]}" with code ${r} at position ${n}`); + return r; + }); +} +const jn = (e) => typeof e == "bigint" && Jo <= e; +function ed(e, t, n) { + return jn(e) && jn(t) && jn(n) && t <= e && e < n; +} +function td(e, t, n, r) { + if (!ed(t, n, r)) + throw new Error("expected valid " + e + ": " + n + " <= n < " + r + ", got " + t); +} +function nd(e) { + let t; + for (t = 0; e > Jo; e >>= Co, t += 1) + ; + return t; +} +const Xo = (e) => (Co << BigInt(e)) - Co; +function rd(e, t, n) { + if (bt(e, "hashLen"), bt(t, "qByteLen"), typeof n != "function") + throw new Error("hmacFn must be a function"); + const r = (M) => new Uint8Array(M), o = Uint8Array.of(), i = Uint8Array.of(0), s = Uint8Array.of(1), c = 1e3; + let a = r(e), h = r(e), w = 0; + const g = () => { + a.fill(1), h.fill(0), w = 0; + }, v = (...M) => n(h, Be(a, ...M)), b = (M = o) => { + h = v(i, M), a = v(), M.length !== 0 && (h = v(s, M), a = v()); + }, C = () => { + if (w++ >= c) + throw new Error("drbg: tried max amount of iterations"); + let M = 0; + const I = []; + for (; M < t; ) { + a = v(); + const U = a.slice(); + I.push(U), M += a.length; + } + return Be(...I); + }; + return (M, I) => { + g(), b(M); + let U; + for (; !(U = I(C())); ) + b(); + return g(), U; + }; +} +function ei(e, t = {}, n = {}) { + if (!e || typeof e != "object") + throw new Error("expected valid options object"); + function r(i, s, c) { + const a = e[i]; + if (c && a === void 0) + return; + const h = typeof a; + if (h !== s || a === null) + throw new Error(`param "${i}" is invalid: expected ${s}, got ${h}`); + } + const o = (i, s) => Object.entries(i).forEach(([c, a]) => r(c, a, s)); + o(t, !1), o(n, !0); +} +function ts(e) { + const t = /* @__PURE__ */ new WeakMap(); + return (n, ...r) => { + const o = t.get(n); + if (o !== void 0) + return o; + const i = e(n, ...r); + return t.set(n, i), i; + }; +} +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +const Re = /* @__PURE__ */ BigInt(0), Te = /* @__PURE__ */ BigInt(1), Lt = /* @__PURE__ */ BigInt(2), xl = /* @__PURE__ */ BigInt(3), El = /* @__PURE__ */ BigInt(4), Al = /* @__PURE__ */ BigInt(5), od = /* @__PURE__ */ BigInt(7), kl = /* @__PURE__ */ BigInt(8), id = /* @__PURE__ */ BigInt(9), _l = /* @__PURE__ */ BigInt(16); +function We(e, t) { + const n = e % t; + return n >= Re ? n : t + n; +} +function Pe(e, t, n) { + let r = e; + for (; t-- > Re; ) + r *= r, r %= n; + return r; +} +function ns(e, t) { + if (e === Re) + throw new Error("invert: expected non-zero number"); + if (t <= Re) + throw new Error("invert: expected positive modulus, got " + t); + let n = We(e, t), r = t, o = Re, i = Te; + for (; n !== Re; ) { + const c = r / n, a = r % n, h = o - i * c; + r = n, n = a, o = i, i = h; + } + if (r !== Te) + throw new Error("invert: does not exist"); + return We(o, t); +} +function ti(e, t, n) { + if (!e.eql(e.sqr(t), n)) + throw new Error("Cannot find square root"); +} +function Sl(e, t) { + const n = (e.ORDER + Te) / El, r = e.pow(t, n); + return ti(e, r, t), r; +} +function sd(e, t) { + const n = (e.ORDER - Al) / kl, r = e.mul(t, Lt), o = e.pow(r, n), i = e.mul(t, o), s = e.mul(e.mul(i, Lt), o), c = e.mul(i, e.sub(s, e.ONE)); + return ti(e, c, t), c; +} +function ad(e) { + const t = gr(e), n = Ll(e), r = n(t, t.neg(t.ONE)), o = n(t, r), i = n(t, t.neg(r)), s = (e + od) / _l; + return (c, a) => { + let h = c.pow(a, s), w = c.mul(h, r); + const g = c.mul(h, o), v = c.mul(h, i), b = c.eql(c.sqr(w), a), C = c.eql(c.sqr(g), a); + h = c.cmov(h, w, b), w = c.cmov(v, g, C); + const L = c.eql(c.sqr(w), a), M = c.cmov(h, w, L); + return ti(c, M, a), M; + }; +} +function Ll(e) { + if (e < xl) + throw new Error("sqrt is not defined for small field"); + let t = e - Te, n = 0; + for (; t % Lt === Re; ) + t /= Lt, n++; + let r = Lt; + const o = gr(e); + for (; rs(o, r) === 1; ) + if (r++ > 1e3) + throw new Error("Cannot find square root: probably non-prime P"); + if (n === 1) + return Sl; + let i = o.pow(r, t); + const s = (t + Te) / Lt; + return function(a, h) { + if (a.is0(h)) + return h; + if (rs(a, h) !== 1) + throw new Error("Cannot find square root"); + let w = n, g = a.mul(a.ONE, i), v = a.pow(h, t), b = a.pow(h, s); + for (; !a.eql(v, a.ONE); ) { + if (a.is0(v)) + return a.ZERO; + let C = 1, L = a.sqr(v); + for (; !a.eql(L, a.ONE); ) + if (C++, L = a.sqr(L), C === w) + throw new Error("Cannot find square root"); + const M = Te << BigInt(w - C - 1), I = a.pow(g, M); + w = C, g = a.sqr(I), v = a.mul(v, g), b = a.mul(b, I); + } + return b; + }; +} +function cd(e) { + return e % El === xl ? Sl : e % kl === Al ? sd : e % _l === id ? ad(e) : Ll(e); +} +const ld = [ + "create", + "isValid", + "is0", + "neg", + "inv", + "sqrt", + "sqr", + "eql", + "add", + "sub", + "mul", + "pow", + "div", + "addN", + "subN", + "mulN", + "sqrN" +]; +function dd(e) { + const t = { + ORDER: "bigint", + BYTES: "number", + BITS: "number" + }, n = ld.reduce((r, o) => (r[o] = "function", r), t); + return ei(e, n), e; +} +function ud(e, t, n) { + if (n < Re) + throw new Error("invalid exponent, negatives unsupported"); + if (n === Re) + return e.ONE; + if (n === Te) + return t; + let r = e.ONE, o = t; + for (; n > Re; ) + n & Te && (r = e.mul(r, o)), o = e.sqr(o), n >>= Te; + return r; +} +function Tl(e, t, n = !1) { + const r = new Array(t.length).fill(n ? e.ZERO : void 0), o = t.reduce((s, c, a) => e.is0(c) ? s : (r[a] = s, e.mul(s, c)), e.ONE), i = e.inv(o); + return t.reduceRight((s, c, a) => e.is0(c) ? s : (r[a] = e.mul(s, r[a]), e.mul(s, c)), i), r; +} +function rs(e, t) { + const n = (e.ORDER - Te) / Lt, r = e.pow(t, n), o = e.eql(r, e.ONE), i = e.eql(r, e.ZERO), s = e.eql(r, e.neg(e.ONE)); + if (!o && !i && !s) + throw new Error("invalid Legendre symbol result"); + return o ? 1 : i ? 0 : -1; +} +function hd(e, t) { + t !== void 0 && bt(t); + const n = t !== void 0 ? t : e.toString(2).length, r = Math.ceil(n / 8); + return { nBitLength: n, nByteLength: r }; +} +class fd { + ORDER; + BITS; + BYTES; + isLE; + ZERO = Re; + ONE = Te; + _lengths; + _sqrt; + // cached sqrt + _mod; + constructor(t, n = {}) { + if (t <= Re) + throw new Error("invalid field: expected ORDER > 0, got " + t); + let r; + this.isLE = !1, n != null && typeof n == "object" && (typeof n.BITS == "number" && (r = n.BITS), typeof n.sqrt == "function" && (this.sqrt = n.sqrt), typeof n.isLE == "boolean" && (this.isLE = n.isLE), n.allowedLengths && (this._lengths = n.allowedLengths?.slice()), typeof n.modFromBytes == "boolean" && (this._mod = n.modFromBytes)); + const { nBitLength: o, nByteLength: i } = hd(t, r); + if (i > 2048) + throw new Error("invalid field: expected ORDER of <= 2048 bytes"); + this.ORDER = t, this.BITS = o, this.BYTES = i, this._sqrt = void 0, Object.preventExtensions(this); + } + create(t) { + return We(t, this.ORDER); + } + isValid(t) { + if (typeof t != "bigint") + throw new Error("invalid field element: expected bigint, got " + typeof t); + return Re <= t && t < this.ORDER; + } + is0(t) { + return t === Re; + } + // is valid and invertible + isValidNot0(t) { + return !this.is0(t) && this.isValid(t); + } + isOdd(t) { + return (t & Te) === Te; + } + neg(t) { + return We(-t, this.ORDER); + } + eql(t, n) { + return t === n; + } + sqr(t) { + return We(t * t, this.ORDER); + } + add(t, n) { + return We(t + n, this.ORDER); + } + sub(t, n) { + return We(t - n, this.ORDER); + } + mul(t, n) { + return We(t * n, this.ORDER); + } + pow(t, n) { + return ud(this, t, n); + } + div(t, n) { + return We(t * ns(n, this.ORDER), this.ORDER); + } + // Same as above, but doesn't normalize + sqrN(t) { + return t * t; + } + addN(t, n) { + return t + n; + } + subN(t, n) { + return t - n; + } + mulN(t, n) { + return t * n; + } + inv(t) { + return ns(t, this.ORDER); + } + sqrt(t) { + return this._sqrt || (this._sqrt = cd(this.ORDER)), this._sqrt(this, t); + } + toBytes(t) { + return this.isLE ? Cl(t, this.BYTES) : Yo(t, this.BYTES); + } + fromBytes(t, n = !1) { + fe(t); + const { _lengths: r, BYTES: o, isLE: i, ORDER: s, _mod: c } = this; + if (r) { + if (!r.includes(t.length) || t.length > o) + throw new Error("Field.fromBytes: expected " + r + " bytes, got " + t.length); + const h = new Uint8Array(o); + h.set(t, i ? 0 : h.length - t.length), t = h; + } + if (t.length !== o) + throw new Error("Field.fromBytes: expected " + o + " bytes, got " + t.length); + let a = i ? vl(t) : Ln(t); + if (c && (a = We(a, s)), !n && !this.isValid(a)) + throw new Error("invalid field element: outside of range 0..ORDER"); + return a; + } + // TODO: we don't need it here, move out to separate fn + invertBatch(t) { + return Tl(this, t); + } + // We can't move this out because Fp6, Fp12 implement it + // and it's unclear what to return in there. + cmov(t, n, r) { + return r ? n : t; + } +} +function gr(e, t = {}) { + return new fd(e, t); +} +function Ml(e) { + if (typeof e != "bigint") + throw new Error("field order must be bigint"); + const t = e.toString(2).length; + return Math.ceil(t / 8); +} +function Bl(e) { + const t = Ml(e); + return t + Math.ceil(t / 2); +} +function Rl(e, t, n = !1) { + fe(e); + const r = e.length, o = Ml(t), i = Bl(t); + if (r < 16 || r < i || r > 1024) + throw new Error("expected " + i + "-1024 bytes of input, got " + r); + const s = n ? vl(e) : Ln(e), c = We(s, t - Te) + Te; + return n ? Cl(c, o) : Yo(c, o); +} +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +const Kt = /* @__PURE__ */ BigInt(0), Tt = /* @__PURE__ */ BigInt(1); +function tr(e, t) { + const n = t.negate(); + return e ? n : t; +} +function os(e, t) { + const n = Tl(e.Fp, t.map((r) => r.Z)); + return t.map((r, o) => e.fromAffine(r.toAffine(n[o]))); +} +function Nl(e, t) { + if (!Number.isSafeInteger(e) || e <= 0 || e > t) + throw new Error("invalid window size, expected [1.." + t + "], got W=" + e); +} +function Nr(e, t) { + Nl(e, t); + const n = Math.ceil(t / e) + 1, r = 2 ** (e - 1), o = 2 ** e, i = Xo(e), s = BigInt(e); + return { windows: n, windowSize: r, mask: i, maxNumber: o, shiftBy: s }; +} +function is(e, t, n) { + const { windowSize: r, mask: o, maxNumber: i, shiftBy: s } = n; + let c = Number(e & o), a = e >> s; + c > r && (c -= i, a += Tt); + const h = t * r, w = h + Math.abs(c) - 1, g = c === 0, v = c < 0, b = t % 2 !== 0; + return { nextN: a, offset: w, isZero: g, isNeg: v, isNegF: b, offsetF: h }; +} +const $r = /* @__PURE__ */ new WeakMap(), $l = /* @__PURE__ */ new WeakMap(); +function Ir(e) { + return $l.get(e) || 1; +} +function ss(e) { + if (e !== Kt) + throw new Error("invalid wNAF"); +} +class pd { + BASE; + ZERO; + Fn; + bits; + // Parametrized with a given Point class (not individual point) + constructor(t, n) { + this.BASE = t.BASE, this.ZERO = t.ZERO, this.Fn = t.Fn, this.bits = n; + } + // non-const time multiplication ladder + _unsafeLadder(t, n, r = this.ZERO) { + let o = t; + for (; n > Kt; ) + n & Tt && (r = r.add(o)), o = o.double(), n >>= Tt; + return r; + } + /** + * Creates a wNAF precomputation window. Used for caching. + * Default window size is set by `utils.precompute()` and is equal to 8. + * Number of precomputed points depends on the curve size: + * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where: + * - 𝑊 is the window size + * - 𝑛 is the bitlength of the curve order. + * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224. + * @param point Point instance + * @param W window size + * @returns precomputed point tables flattened to a single array + */ + precomputeWindow(t, n) { + const { windows: r, windowSize: o } = Nr(n, this.bits), i = []; + let s = t, c = s; + for (let a = 0; a < r; a++) { + c = s, i.push(c); + for (let h = 1; h < o; h++) + c = c.add(s), i.push(c); + s = c.double(); + } + return i; + } + /** + * Implements ec multiplication using precomputed tables and w-ary non-adjacent form. + * More compact implementation: + * https://github.com/paulmillr/noble-secp256k1/blob/47cb1669b6e506ad66b35fe7d76132ae97465da2/index.ts#L502-L541 + * @returns real and fake (for const-time) points + */ + wNAF(t, n, r) { + if (!this.Fn.isValid(r)) + throw new Error("invalid scalar"); + let o = this.ZERO, i = this.BASE; + const s = Nr(t, this.bits); + for (let c = 0; c < s.windows; c++) { + const { nextN: a, offset: h, isZero: w, isNeg: g, isNegF: v, offsetF: b } = is(r, c, s); + r = a, w ? i = i.add(tr(v, n[b])) : o = o.add(tr(g, n[h])); + } + return ss(r), { p: o, f: i }; + } + /** + * Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form. + * @param acc accumulator point to add result of multiplication + * @returns point + */ + wNAFUnsafe(t, n, r, o = this.ZERO) { + const i = Nr(t, this.bits); + for (let s = 0; s < i.windows && r !== Kt; s++) { + const { nextN: c, offset: a, isZero: h, isNeg: w } = is(r, s, i); + if (r = c, !h) { + const g = n[a]; + o = o.add(w ? g.negate() : g); + } + } + return ss(r), o; + } + getPrecomputes(t, n, r) { + let o = $r.get(n); + return o || (o = this.precomputeWindow(n, t), t !== 1 && (typeof r == "function" && (o = r(o)), $r.set(n, o))), o; + } + cached(t, n, r) { + const o = Ir(t); + return this.wNAF(o, this.getPrecomputes(o, t, r), n); + } + unsafe(t, n, r, o) { + const i = Ir(t); + return i === 1 ? this._unsafeLadder(t, n, o) : this.wNAFUnsafe(i, this.getPrecomputes(i, t, r), n, o); + } + // We calculate precomputes for elliptic curve point multiplication + // using windowed method. This specifies window size and + // stores precomputed values. Usually only base point would be precomputed. + createCache(t, n) { + Nl(n, this.bits), $l.set(t, n), $r.delete(t); + } + hasCache(t) { + return Ir(t) !== 1; + } +} +function gd(e, t, n, r) { + let o = t, i = e.ZERO, s = e.ZERO; + for (; n > Kt || r > Kt; ) + n & Tt && (i = i.add(o)), r & Tt && (s = s.add(o)), o = o.double(), n >>= Tt, r >>= Tt; + return { p1: i, p2: s }; +} +function as(e, t, n) { + if (t) { + if (t.ORDER !== e) + throw new Error("Field.ORDER must match order: Fp == p, Fn == n"); + return dd(t), t; + } else + return gr(e, { isLE: n }); +} +function wd(e, t, n = {}, r) { + if (r === void 0 && (r = e === "edwards"), !t || typeof t != "object") + throw new Error(`expected valid ${e} CURVE object`); + for (const a of ["p", "n", "h"]) { + const h = t[a]; + if (!(typeof h == "bigint" && h > Kt)) + throw new Error(`CURVE.${a} must be positive bigint`); + } + const o = as(t.p, n.Fp, r), i = as(t.n, n.Fn, r), c = ["Gx", "Gy", "a", "b"]; + for (const a of c) + if (!o.isValid(t[a])) + throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`); + return t = Object.freeze(Object.assign({}, t)), { CURVE: t, Fp: o, Fn: i }; +} +function Il(e, t) { + return function(r) { + const o = e(r); + return { secretKey: o, publicKey: t(o) }; + }; +} +class Ul { + oHash; + iHash; + blockLen; + outputLen; + finished = !1; + destroyed = !1; + constructor(t, n) { + if (pr(t), fe(n, void 0, "key"), this.iHash = t.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 r = this.blockLen, o = new Uint8Array(r); + o.set(n.length > r ? t.create().update(n).digest() : n); + for (let i = 0; i < o.length; i++) + o[i] ^= 54; + this.iHash.update(o), this.oHash = t.create(); + for (let i = 0; i < o.length; i++) + o[i] ^= 106; + this.oHash.update(o), mn(o); + } + update(t) { + return Xn(this), this.iHash.update(t), this; + } + digestInto(t) { + Xn(this), fe(t, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy(); + } + digest() { + const t = new Uint8Array(this.oHash.outputLen); + return this.digestInto(t), t; + } + _cloneInto(t) { + t ||= Object.create(Object.getPrototypeOf(this), {}); + const { oHash: n, iHash: r, finished: o, destroyed: i, blockLen: s, outputLen: c } = this; + return t = t, t.finished = o, t.destroyed = i, t.blockLen = s, t.outputLen = c, t.oHash = n._cloneInto(t.oHash), t.iHash = r._cloneInto(t.iHash), t; + } + clone() { + return this._cloneInto(); + } + destroy() { + this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy(); + } +} +const Tn = (e, t, n) => new Ul(e, t).update(n).digest(); +Tn.create = (e, t) => new Ul(e, t); +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +const cs = (e, t) => (e + (e >= 0 ? t : -t) / Ol) / t; +function yd(e, t, n) { + const [[r, o], [i, s]] = t, c = cs(s * e, n), a = cs(-o * e, n); + let h = e - c * r - a * i, w = -c * o - a * s; + const g = h < tt, v = w < tt; + g && (h = -h), v && (w = -w); + const b = Xo(Math.ceil(nd(n) / 2)) + Gt; + if (h < tt || h >= b || w < tt || w >= b) + throw new Error("splitScalar (endomorphism): failed, k=" + e); + return { k1neg: g, k1: h, k2neg: v, k2: w }; +} +function xo(e) { + if (!["compact", "recovered", "der"].includes(e)) + throw new Error('Signature format must be "compact", "recovered", or "der"'); + return e; +} +function Ur(e, t) { + const n = {}; + for (let r of Object.keys(t)) + n[r] = e[r] === void 0 ? t[r] : e[r]; + return er(n.lowS, "lowS"), er(n.prehash, "prehash"), n.format !== void 0 && xo(n.format), n; +} +class bd extends Error { + constructor(t = "") { + super(t); + } +} +const ut = { + // asn.1 DER encoding utils + Err: bd, + // Basic building block is TLV (Tag-Length-Value) + _tlv: { + encode: (e, t) => { + const { Err: n } = ut; + if (e < 0 || e > 256) + throw new n("tlv.encode: wrong tag"); + if (t.length & 1) + throw new n("tlv.encode: unpadded data"); + const r = t.length / 2, o = Rn(r); + if (o.length / 2 & 128) + throw new n("tlv.encode: long form length too big"); + const i = r > 127 ? Rn(o.length / 2 | 128) : ""; + return Rn(e) + i + o + t; + }, + // v - value, l - left bytes (unparsed) + decode(e, t) { + const { Err: n } = ut; + let r = 0; + if (e < 0 || e > 256) + throw new n("tlv.encode: wrong tag"); + if (t.length < 2 || t[r++] !== e) + throw new n("tlv.decode: wrong tlv"); + const o = t[r++], i = !!(o & 128); + let s = 0; + if (!i) + s = o; + else { + const a = o & 127; + if (!a) + throw new n("tlv.decode(long): indefinite length not supported"); + if (a > 4) + throw new n("tlv.decode(long): byte length is too big"); + const h = t.subarray(r, r + a); + if (h.length !== a) + throw new n("tlv.decode: length bytes not complete"); + if (h[0] === 0) + throw new n("tlv.decode(long): zero leftmost byte"); + for (const w of h) + s = s << 8 | w; + if (r += a, s < 128) + throw new n("tlv.decode(long): not minimal encoding"); + } + const c = t.subarray(r, r + s); + if (c.length !== s) + throw new n("tlv.decode: wrong value length"); + return { v: c, l: t.subarray(r + s) }; + } + }, + // https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag, + // since we always use positive integers here. It must always be empty: + // - add zero byte if exists + // - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding) + _int: { + encode(e) { + const { Err: t } = ut; + if (e < tt) + throw new t("integer: negative integers are not allowed"); + let n = Rn(e); + if (Number.parseInt(n[0], 16) & 8 && (n = "00" + n), n.length & 1) + throw new t("unexpected DER parsing assertion: unpadded hex"); + return n; + }, + decode(e) { + const { Err: t } = ut; + if (e[0] & 128) + throw new t("invalid signature integer: negative"); + if (e[0] === 0 && !(e[1] & 128)) + throw new t("invalid signature integer: unnecessary leading zero"); + return Ln(e); + } + }, + toSig(e) { + const { Err: t, _int: n, _tlv: r } = ut, o = fe(e, void 0, "signature"), { v: i, l: s } = r.decode(48, o); + if (s.length) + throw new t("invalid signature: left bytes after parsing"); + const { v: c, l: a } = r.decode(2, i), { v: h, l: w } = r.decode(2, a); + if (w.length) + throw new t("invalid signature: left bytes after parsing"); + return { r: n.decode(c), s: n.decode(h) }; + }, + hexFromSig(e) { + const { _tlv: t, _int: n } = ut, r = t.encode(2, n.encode(e.r)), o = t.encode(2, n.encode(e.s)), i = r + o; + return t.encode(48, i); + } +}, tt = BigInt(0), Gt = BigInt(1), Ol = BigInt(2), Nn = BigInt(3), md = BigInt(4); +function vd(e, t = {}) { + const n = wd("weierstrass", e, t), { Fp: r, Fn: o } = n; + let i = n.CURVE; + const { h: s, n: c } = i; + ei(t, {}, { + allowInfinityPoint: "boolean", + clearCofactor: "function", + isTorsionFree: "function", + fromBytes: "function", + toBytes: "function", + endo: "object" + }); + const { endo: a } = t; + if (a && (!r.is0(i.a) || typeof a.beta != "bigint" || !Array.isArray(a.basises))) + throw new Error('invalid endo: expected "beta": bigint and "basises": array'); + const h = Hl(r, o); + function w() { + if (!r.isOdd) + throw new Error("compression is not supported: Field does not have .isOdd()"); + } + function g(l, u, p) { + const { x: f, y } = u.toAffine(), x = r.toBytes(f); + if (er(p, "isCompressed"), p) { + w(); + const O = !r.isOdd(y); + return Be(Pl(O), x); + } else + return Be(Uint8Array.of(4), x, r.toBytes(y)); + } + function v(l) { + fe(l, void 0, "Point"); + const { publicKey: u, publicKeyUncompressed: p } = h, f = l.length, y = l[0], x = l.subarray(1); + if (f === u && (y === 2 || y === 3)) { + const O = r.fromBytes(x); + if (!r.isValid(O)) + throw new Error("bad point: is not on curve, wrong x"); + const R = L(O); + let P; + try { + P = r.sqrt(R); + } catch (J) { + const Y = J instanceof Error ? ": " + J.message : ""; + throw new Error("bad point: is not on curve, sqrt error" + Y); + } + w(); + const S = r.isOdd(P); + return (y & 1) === 1 !== S && (P = r.neg(P)), { x: O, y: P }; + } else if (f === p && y === 4) { + const O = r.BYTES, R = r.fromBytes(x.subarray(0, O)), P = r.fromBytes(x.subarray(O, O * 2)); + if (!M(R, P)) + throw new Error("bad point: is not on curve"); + return { x: R, y: P }; + } else + throw new Error(`bad point: got length ${f}, expected compressed=${u} or uncompressed=${p}`); + } + const b = t.toBytes || g, C = t.fromBytes || v; + function L(l) { + const u = r.sqr(l), p = r.mul(u, l); + return r.add(r.add(p, r.mul(l, i.a)), i.b); + } + function M(l, u) { + const p = r.sqr(u), f = L(l); + return r.eql(p, f); + } + if (!M(i.Gx, i.Gy)) + throw new Error("bad curve params: generator point"); + const I = r.mul(r.pow(i.a, Nn), md), U = r.mul(r.sqr(i.b), BigInt(27)); + if (r.is0(r.add(I, U))) + throw new Error("bad curve params: a or b"); + function q(l, u, p = !1) { + if (!r.isValid(u) || p && r.is0(u)) + throw new Error(`bad point coordinate ${l}`); + return u; + } + function Q(l) { + if (!(l instanceof m)) + throw new Error("Weierstrass Point expected"); + } + function A(l) { + if (!a || !a.basises) + throw new Error("no endo"); + return yd(l, a.basises, o.ORDER); + } + const _ = ts((l, u) => { + const { X: p, Y: f, Z: y } = l; + if (r.eql(y, r.ONE)) + return { x: p, y: f }; + const x = l.is0(); + u == null && (u = x ? r.ONE : r.inv(y)); + const O = r.mul(p, u), R = r.mul(f, u), P = r.mul(y, u); + if (x) + return { x: r.ZERO, y: r.ZERO }; + if (!r.eql(P, r.ONE)) + throw new Error("invZ was invalid"); + return { x: O, y: R }; + }), E = ts((l) => { + if (l.is0()) { + if (t.allowInfinityPoint && !r.is0(l.Y)) + return; + throw new Error("bad point: ZERO"); + } + const { x: u, y: p } = l.toAffine(); + if (!r.isValid(u) || !r.isValid(p)) + throw new Error("bad point: x or y not field elements"); + if (!M(u, p)) + throw new Error("bad point: equation left != right"); + if (!l.isTorsionFree()) + throw new Error("bad point: not in prime-order subgroup"); + return !0; + }); + function T(l, u, p, f, y) { + return p = new m(r.mul(p.X, l), p.Y, p.Z), u = tr(f, u), p = tr(y, p), u.add(p); + } + class m { + // base / generator point + static BASE = new m(i.Gx, i.Gy, r.ONE); + // zero / infinity / identity point + static ZERO = new m(r.ZERO, r.ONE, r.ZERO); + // 0, 1, 0 + // math field + static Fp = r; + // scalar field + static Fn = o; + X; + Y; + Z; + /** Does NOT validate if the point is valid. Use `.assertValidity()`. */ + constructor(u, p, f) { + this.X = q("x", u), this.Y = q("y", p, !0), this.Z = q("z", f), Object.freeze(this); + } + static CURVE() { + return i; + } + /** Does NOT validate if the point is valid. Use `.assertValidity()`. */ + static fromAffine(u) { + const { x: p, y: f } = u || {}; + if (!u || !r.isValid(p) || !r.isValid(f)) + throw new Error("invalid affine point"); + if (u instanceof m) + throw new Error("projective point not allowed"); + return r.is0(p) && r.is0(f) ? m.ZERO : new m(p, f, r.ONE); + } + static fromBytes(u) { + const p = m.fromAffine(C(fe(u, void 0, "point"))); + return p.assertValidity(), p; + } + static fromHex(u) { + return m.fromBytes(ue(u)); + } + get x() { + return this.toAffine().x; + } + get y() { + return this.toAffine().y; + } + /** + * + * @param windowSize + * @param isLazy true will defer table computation until the first multiplication + * @returns + */ + precompute(u = 8, p = !0) { + return d.createCache(this, u), p || this.multiply(Nn), this; + } + // TODO: return `this` + /** A point on curve is valid if it conforms to equation. */ + assertValidity() { + E(this); + } + hasEvenY() { + const { y: u } = this.toAffine(); + if (!r.isOdd) + throw new Error("Field doesn't support isOdd"); + return !r.isOdd(u); + } + /** Compare one point to another. */ + equals(u) { + Q(u); + const { X: p, Y: f, Z: y } = this, { X: x, Y: O, Z: R } = u, P = r.eql(r.mul(p, R), r.mul(x, y)), S = r.eql(r.mul(f, R), r.mul(O, y)); + return P && S; + } + /** Flips point to one corresponding to (x, -y) in Affine coordinates. */ + negate() { + return new m(this.X, r.neg(this.Y), this.Z); + } + // Renes-Costello-Batina exception-free doubling formula. + // There is 30% faster Jacobian formula, but it is not complete. + // https://eprint.iacr.org/2015/1060, algorithm 3 + // Cost: 8M + 3S + 3*a + 2*b3 + 15add. + double() { + const { a: u, b: p } = i, f = r.mul(p, Nn), { X: y, Y: x, Z: O } = this; + let R = r.ZERO, P = r.ZERO, S = r.ZERO, D = r.mul(y, y), J = r.mul(x, x), Y = r.mul(O, O), G = r.mul(y, x); + return G = r.add(G, G), S = r.mul(y, O), S = r.add(S, S), R = r.mul(u, S), P = r.mul(f, Y), P = r.add(R, P), R = r.sub(J, P), P = r.add(J, P), P = r.mul(R, P), R = r.mul(G, R), S = r.mul(f, S), Y = r.mul(u, Y), G = r.sub(D, Y), G = r.mul(u, G), G = r.add(G, S), S = r.add(D, D), D = r.add(S, D), D = r.add(D, Y), D = r.mul(D, G), P = r.add(P, D), Y = r.mul(x, O), Y = r.add(Y, Y), D = r.mul(Y, G), R = r.sub(R, D), S = r.mul(Y, J), S = r.add(S, S), S = r.add(S, S), new m(R, P, S); + } + // Renes-Costello-Batina exception-free addition formula. + // There is 30% faster Jacobian formula, but it is not complete. + // https://eprint.iacr.org/2015/1060, algorithm 1 + // Cost: 12M + 0S + 3*a + 3*b3 + 23add. + add(u) { + Q(u); + const { X: p, Y: f, Z: y } = this, { X: x, Y: O, Z: R } = u; + let P = r.ZERO, S = r.ZERO, D = r.ZERO; + const J = i.a, Y = r.mul(i.b, Nn); + let G = r.mul(p, x), X = r.mul(f, O), ie = r.mul(y, R), N = r.add(p, f), $ = r.add(x, O); + N = r.mul(N, $), $ = r.add(G, X), N = r.sub(N, $), $ = r.add(p, y); + let B = r.add(x, R); + return $ = r.mul($, B), B = r.add(G, ie), $ = r.sub($, B), B = r.add(f, y), P = r.add(O, R), B = r.mul(B, P), P = r.add(X, ie), B = r.sub(B, P), D = r.mul(J, $), P = r.mul(Y, ie), D = r.add(P, D), P = r.sub(X, D), D = r.add(X, D), S = r.mul(P, D), X = r.add(G, G), X = r.add(X, G), ie = r.mul(J, ie), $ = r.mul(Y, $), X = r.add(X, ie), ie = r.sub(G, ie), ie = r.mul(J, ie), $ = r.add($, ie), G = r.mul(X, $), S = r.add(S, G), G = r.mul(B, $), P = r.mul(N, P), P = r.sub(P, G), G = r.mul(N, X), D = r.mul(B, D), D = r.add(D, G), new m(P, S, D); + } + subtract(u) { + return this.add(u.negate()); + } + is0() { + return this.equals(m.ZERO); + } + /** + * Constant time multiplication. + * Uses wNAF method. Windowed method may be 10% faster, + * but takes 2x longer to generate and consumes 2x memory. + * Uses precomputes when available. + * Uses endomorphism for Koblitz curves. + * @param scalar by which the point would be multiplied + * @returns New point + */ + multiply(u) { + const { endo: p } = t; + if (!o.isValidNot0(u)) + throw new Error("invalid scalar: out of range"); + let f, y; + const x = (O) => d.cached(this, O, (R) => os(m, R)); + if (p) { + const { k1neg: O, k1: R, k2neg: P, k2: S } = A(u), { p: D, f: J } = x(R), { p: Y, f: G } = x(S); + y = J.add(G), f = T(p.beta, D, Y, O, P); + } else { + const { p: O, f: R } = x(u); + f = O, y = R; + } + return os(m, [f, y])[0]; + } + /** + * Non-constant-time multiplication. Uses double-and-add algorithm. + * It's faster, but should only be used when you don't care about + * an exposed secret key e.g. sig verification, which works over *public* keys. + */ + multiplyUnsafe(u) { + const { endo: p } = t, f = this; + if (!o.isValid(u)) + throw new Error("invalid scalar: out of range"); + if (u === tt || f.is0()) + return m.ZERO; + if (u === Gt) + return f; + if (d.hasCache(this)) + return this.multiply(u); + if (p) { + const { k1neg: y, k1: x, k2neg: O, k2: R } = A(u), { p1: P, p2: S } = gd(m, f, x, R); + return T(p.beta, P, S, y, O); + } else + return d.unsafe(f, u); + } + /** + * Converts Projective point to affine (x, y) coordinates. + * @param invertedZ Z^-1 (inverted zero) - optional, precomputation is useful for invertBatch + */ + toAffine(u) { + return _(this, u); + } + /** + * Checks whether Point is free of torsion elements (is in prime subgroup). + * Always torsion-free for cofactor=1 curves. + */ + isTorsionFree() { + const { isTorsionFree: u } = t; + return s === Gt ? !0 : u ? u(m, this) : d.unsafe(this, c).is0(); + } + clearCofactor() { + const { clearCofactor: u } = t; + return s === Gt ? this : u ? u(m, this) : this.multiplyUnsafe(s); + } + isSmallOrder() { + return this.multiplyUnsafe(s).is0(); + } + toBytes(u = !0) { + return er(u, "isCompressed"), this.assertValidity(), b(m, this, u); + } + toHex(u = !0) { + return pe(this.toBytes(u)); + } + toString() { + return ``; + } + } + const k = o.BITS, d = new pd(m, t.endo ? Math.ceil(k / 2) : k); + return m.BASE.precompute(8), m; +} +function Pl(e) { + return Uint8Array.of(e ? 2 : 3); +} +function Hl(e, t) { + return { + secretKey: t.BYTES, + publicKey: 1 + e.BYTES, + publicKeyUncompressed: 1 + 2 * e.BYTES, + publicKeyHasPrefix: !0, + signature: 2 * t.BYTES + }; +} +function Cd(e, t = {}) { + const { Fn: n } = e, r = t.randomBytes || nn, o = Object.assign(Hl(e.Fp, n), { seed: Bl(n.ORDER) }); + function i(b) { + try { + const C = n.fromBytes(b); + return n.isValidNot0(C); + } catch { + return !1; + } + } + function s(b, C) { + const { publicKey: L, publicKeyUncompressed: M } = o; + try { + const I = b.length; + return C === !0 && I !== L || C === !1 && I !== M ? !1 : !!e.fromBytes(b); + } catch { + return !1; + } + } + function c(b = r(o.seed)) { + return Rl(fe(b, o.seed, "seed"), n.ORDER); + } + function a(b, C = !0) { + return e.BASE.multiply(n.fromBytes(b)).toBytes(C); + } + function h(b) { + const { secretKey: C, publicKey: L, publicKeyUncompressed: M } = o; + if (!Qo(b) || "_lengths" in n && n._lengths || C === L) + return; + const I = fe(b, void 0, "key").length; + return I === L || I === M; + } + function w(b, C, L = !0) { + if (h(b) === !0) + throw new Error("first arg must be private key"); + if (h(C) === !1) + throw new Error("second arg must be public key"); + const M = n.fromBytes(b); + return e.fromBytes(C).multiply(M).toBytes(L); + } + const g = { + isValidSecretKey: i, + isValidPublicKey: s, + randomSecretKey: c + }, v = Il(c, a); + return Object.freeze({ getPublicKey: a, getSharedSecret: w, keygen: v, Point: e, utils: g, lengths: o }); +} +function xd(e, t, n = {}) { + pr(t), ei(n, {}, { + hmac: "function", + lowS: "boolean", + randomBytes: "function", + bits2int: "function", + bits2int_modN: "function" + }), n = Object.assign({}, n); + const r = n.randomBytes || nn, o = n.hmac || ((p, f) => Tn(t, p, f)), { Fp: i, Fn: s } = e, { ORDER: c, BITS: a } = s, { keygen: h, getPublicKey: w, getSharedSecret: g, utils: v, lengths: b } = Cd(e, n), C = { + prehash: !0, + lowS: typeof n.lowS == "boolean" ? n.lowS : !0, + format: "compact", + extraEntropy: !1 + }, L = c * Ol < i.ORDER; + function M(p) { + const f = c >> Gt; + return p > f; + } + function I(p, f) { + if (!s.isValidNot0(f)) + throw new Error(`invalid signature ${p}: out of range 1..Point.Fn.ORDER`); + return f; + } + function U() { + if (L) + throw new Error('"recovered" sig type is not supported for cofactor >2 curves'); + } + function q(p, f) { + xo(f); + const y = b.signature, x = f === "compact" ? y : f === "recovered" ? y + 1 : void 0; + return fe(p, x); + } + class Q { + r; + s; + recovery; + constructor(f, y, x) { + if (this.r = I("r", f), this.s = I("s", y), x != null) { + if (U(), ![0, 1, 2, 3].includes(x)) + throw new Error("invalid recovery id"); + this.recovery = x; + } + Object.freeze(this); + } + static fromBytes(f, y = C.format) { + q(f, y); + let x; + if (y === "der") { + const { r: S, s: D } = ut.toSig(fe(f)); + return new Q(S, D); + } + y === "recovered" && (x = f[0], y = "compact", f = f.subarray(1)); + const O = b.signature / 2, R = f.subarray(0, O), P = f.subarray(O, O * 2); + return new Q(s.fromBytes(R), s.fromBytes(P), x); + } + static fromHex(f, y) { + return this.fromBytes(ue(f), y); + } + assertRecovery() { + const { recovery: f } = this; + if (f == null) + throw new Error("invalid recovery id: must be present"); + return f; + } + addRecoveryBit(f) { + return new Q(this.r, this.s, f); + } + recoverPublicKey(f) { + const { r: y, s: x } = this, O = this.assertRecovery(), R = O === 2 || O === 3 ? y + c : y; + if (!i.isValid(R)) + throw new Error("invalid recovery id: sig.r+curve.n != R.x"); + const P = i.toBytes(R), S = e.fromBytes(Be(Pl((O & 1) === 0), P)), D = s.inv(R), J = _(fe(f, void 0, "msgHash")), Y = s.create(-J * D), G = s.create(x * D), X = e.BASE.multiplyUnsafe(Y).add(S.multiplyUnsafe(G)); + if (X.is0()) + throw new Error("invalid recovery: point at infinify"); + return X.assertValidity(), X; + } + // Signatures should be low-s, to prevent malleability. + hasHighS() { + return M(this.s); + } + toBytes(f = C.format) { + if (xo(f), f === "der") + return ue(ut.hexFromSig(this)); + const { r: y, s: x } = this, O = s.toBytes(y), R = s.toBytes(x); + return f === "recovered" ? (U(), Be(Uint8Array.of(this.assertRecovery()), O, R)) : Be(O, R); + } + toHex(f) { + return pe(this.toBytes(f)); + } + } + const A = n.bits2int || function(f) { + if (f.length > 8192) + throw new Error("input is too large"); + const y = Ln(f), x = f.length * 8 - a; + return x > 0 ? y >> BigInt(x) : y; + }, _ = n.bits2int_modN || function(f) { + return s.create(A(f)); + }, E = Xo(a); + function T(p) { + return td("num < 2^" + a, p, tt, E), s.toBytes(p); + } + function m(p, f) { + return fe(p, void 0, "message"), f ? fe(t(p), void 0, "prehashed message") : p; + } + function k(p, f, y) { + const { lowS: x, prehash: O, extraEntropy: R } = Ur(y, C); + p = m(p, O); + const P = _(p), S = s.fromBytes(f); + if (!s.isValidNot0(S)) + throw new Error("invalid private key"); + const D = [T(S), T(P)]; + if (R != null && R !== !1) { + const X = R === !0 ? r(b.secretKey) : R; + D.push(fe(X, void 0, "extraEntropy")); + } + const J = Be(...D), Y = P; + function G(X) { + const ie = A(X); + if (!s.isValidNot0(ie)) + return; + const N = s.inv(ie), $ = e.BASE.multiply(ie).toAffine(), B = s.create($.x); + if (B === tt) + return; + const H = s.create(N * s.create(Y + B * S)); + if (H === tt) + return; + let Z = ($.x === B ? 0 : 2) | Number($.y & Gt), K = H; + return x && M(H) && (K = s.neg(H), Z ^= 1), new Q(B, K, L ? void 0 : Z); + } + return { seed: J, k2sig: G }; + } + function d(p, f, y = {}) { + const { seed: x, k2sig: O } = k(p, f, y); + return rd(t.outputLen, s.BYTES, o)(x, O).toBytes(y.format); + } + function l(p, f, y, x = {}) { + const { lowS: O, prehash: R, format: P } = Ur(x, C); + if (y = fe(y, void 0, "publicKey"), f = m(f, R), !Qo(p)) { + const S = p instanceof Q ? ", use sig.toBytes()" : ""; + throw new Error("verify expects Uint8Array signature" + S); + } + q(p, P); + try { + const S = Q.fromBytes(p, P), D = e.fromBytes(y); + if (O && S.hasHighS()) + return !1; + const { r: J, s: Y } = S, G = _(f), X = s.inv(Y), ie = s.create(G * X), N = s.create(J * X), $ = e.BASE.multiplyUnsafe(ie).add(D.multiplyUnsafe(N)); + return $.is0() ? !1 : s.create($.x) === J; + } catch { + return !1; + } + } + function u(p, f, y = {}) { + const { prehash: x } = Ur(y, C); + return f = m(f, x), Q.fromBytes(p, "recovered").recoverPublicKey(f).toBytes(); + } + return Object.freeze({ + keygen: h, + getPublicKey: w, + getSharedSecret: g, + utils: v, + lengths: b, + Point: e, + sign: d, + verify: l, + recoverPublicKey: u, + Signature: Q, + hash: t + }); +} +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +const wr = { + p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"), + n: BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"), + h: BigInt(1), + a: BigInt(0), + b: BigInt(7), + Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"), + Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8") +}, Ed = { + beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"), + basises: [ + [BigInt("0x3086d221a7d46bcde86c90e49284eb15"), -BigInt("0xe4437ed6010e88286f547fa90abfe4c3")], + [BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")] + ] +}, Ad = /* @__PURE__ */ BigInt(0), Eo = /* @__PURE__ */ BigInt(2); +function kd(e) { + const t = wr.p, n = BigInt(3), r = BigInt(6), o = BigInt(11), i = BigInt(22), s = BigInt(23), c = BigInt(44), a = BigInt(88), h = e * e * e % t, w = h * h * e % t, g = Pe(w, n, t) * w % t, v = Pe(g, n, t) * w % t, b = Pe(v, Eo, t) * h % t, C = Pe(b, o, t) * b % t, L = Pe(C, i, t) * C % t, M = Pe(L, c, t) * L % t, I = Pe(M, a, t) * M % t, U = Pe(I, c, t) * L % t, q = Pe(U, n, t) * w % t, Q = Pe(q, s, t) * C % t, A = Pe(Q, r, t) * h % t, _ = Pe(A, Eo, t); + if (!nr.eql(nr.sqr(_), e)) + throw new Error("Cannot find square root"); + return _; +} +const nr = gr(wr.p, { sqrt: kd }), Pt = /* @__PURE__ */ vd(wr, { + Fp: nr, + endo: Ed +}), ni = /* @__PURE__ */ xd(Pt, Ke), ls = {}; +function rr(e, ...t) { + let n = ls[e]; + if (n === void 0) { + const r = Ke(X2(e)); + n = Be(r, r), ls[e] = n; + } + return Ke(Be(n, ...t)); +} +const ri = (e) => e.toBytes(!0).slice(1), oi = (e) => e % Eo === Ad; +function Ao(e) { + const { Fn: t, BASE: n } = Pt, r = t.fromBytes(e), o = n.multiply(r); + return { scalar: oi(o.y) ? r : t.neg(r), bytes: ri(o) }; +} +function Dl(e) { + const t = nr; + if (!t.isValidNot0(e)) + throw new Error("invalid x: Fail if x ≥ p"); + const n = t.create(e * e), r = t.create(n * e + BigInt(7)); + let o = t.sqrt(r); + oi(o) || (o = t.neg(o)); + const i = Pt.fromAffine({ x: e, y: o }); + return i.assertValidity(), i; +} +const pn = Ln; +function Zl(...e) { + return Pt.Fn.create(pn(rr("BIP0340/challenge", ...e))); +} +function ds(e) { + return Ao(e).bytes; +} +function _d(e, t, n = nn(32)) { + const { Fn: r } = Pt, o = fe(e, void 0, "message"), { bytes: i, scalar: s } = Ao(t), c = fe(n, 32, "auxRand"), a = r.toBytes(s ^ pn(rr("BIP0340/aux", c))), h = rr("BIP0340/nonce", a, i, o), { bytes: w, scalar: g } = Ao(h), v = Zl(w, i, o), b = new Uint8Array(64); + if (b.set(w, 0), b.set(r.toBytes(r.create(g + v * s)), 32), !Wl(b, o, i)) + throw new Error("sign: Invalid signature produced"); + return b; +} +function Wl(e, t, n) { + const { Fp: r, Fn: o, BASE: i } = Pt, s = fe(e, 64, "signature"), c = fe(t, void 0, "message"), a = fe(n, 32, "publicKey"); + try { + const h = Dl(pn(a)), w = pn(s.subarray(0, 32)); + if (!r.isValidNot0(w)) + return !1; + const g = pn(s.subarray(32, 64)); + if (!o.isValidNot0(g)) + return !1; + const v = Zl(o.toBytes(w), ri(h), c), b = i.multiplyUnsafe(g).add(h.multiplyUnsafe(o.neg(v))), { x: C, y: L } = b.toAffine(); + return !(b.is0() || !oi(L) || C !== w); + } catch { + return !1; + } +} +const rn = /* @__PURE__ */ (() => { + const n = (r = nn(48)) => Rl(r, wr.n); + return { + keygen: Il(n, ds), + getPublicKey: ds, + sign: _d, + verify: Wl, + Point: Pt, + utils: { + randomSecretKey: n, + taggedHash: rr, + lift_x: Dl, + pointToBytes: ri + }, + lengths: { + secretKey: 32, + publicKey: 32, + publicKeyHasPrefix: !1, + signature: 64, + seed: 48 + } + }; +})(); +/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +function ii(e) { + return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array"; +} +function Sd(e) { + if (!ii(e)) + throw new Error("Uint8Array expected"); +} +function Fl(e, t) { + return Array.isArray(t) ? t.length === 0 ? !0 : e ? t.every((n) => typeof n == "string") : t.every((n) => Number.isSafeInteger(n)) : !1; +} +function Ld(e) { + if (typeof e != "function") + throw new Error("function expected"); + return !0; +} +function Nt(e, t) { + if (typeof t != "string") + throw new Error(`${e}: string expected`); + return !0; +} +function si(e) { + if (!Number.isSafeInteger(e)) + throw new Error(`invalid integer: ${e}`); +} +function ko(e) { + if (!Array.isArray(e)) + throw new Error("array expected"); +} +function or(e, t) { + if (!Fl(!0, t)) + throw new Error(`${e}: array of strings expected`); +} +function Vl(e, t) { + if (!Fl(!1, t)) + throw new Error(`${e}: array of numbers expected`); +} +// @__NO_SIDE_EFFECTS__ +function Gl(...e) { + const t = (i) => i, n = (i, s) => (c) => i(s(c)), r = e.map((i) => i.encode).reduceRight(n, t), o = e.map((i) => i.decode).reduce(n, t); + return { encode: r, decode: o }; +} +// @__NO_SIDE_EFFECTS__ +function jl(e) { + const t = typeof e == "string" ? e.split("") : e, n = t.length; + or("alphabet", t); + const r = new Map(t.map((o, i) => [o, i])); + return { + encode: (o) => (ko(o), o.map((i) => { + if (!Number.isSafeInteger(i) || i < 0 || i >= n) + throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${e}`); + return t[i]; + })), + decode: (o) => (ko(o), o.map((i) => { + Nt("alphabet.decode", i); + const s = r.get(i); + if (s === void 0) + throw new Error(`Unknown letter: "${i}". Allowed: ${e}`); + return s; + })) + }; +} +// @__NO_SIDE_EFFECTS__ +function zl(e = "") { + return Nt("join", e), { + encode: (t) => (or("join.decode", t), t.join(e)), + decode: (t) => (Nt("join.decode", t), t.split(e)) + }; +} +// @__NO_SIDE_EFFECTS__ +function Td(e, t = "=") { + return si(e), Nt("padding", t), { + encode(n) { + for (or("padding.encode", n); n.length * e % 8; ) + n.push(t); + return n; + }, + decode(n) { + or("padding.decode", n); + let r = n.length; + if (r * e % 8) + throw new Error("padding: invalid, string should have whole number of bytes"); + for (; r > 0 && n[r - 1] === t; r--) + if ((r - 1) * e % 8 === 0) + throw new Error("padding: invalid, string has too much padding"); + return n.slice(0, r); + } + }; +} +const ql = (e, t) => t === 0 ? e : ql(t, e % t), ir = /* @__NO_SIDE_EFFECTS__ */ (e, t) => e + (t - ql(e, t)), zn = /* @__PURE__ */ (() => { + let e = []; + for (let t = 0; t < 40; t++) + e.push(2 ** t); + return e; +})(); +function _o(e, t, n, r) { + if (ko(e), t <= 0 || t > 32) + throw new Error(`convertRadix2: wrong from=${t}`); + if (n <= 0 || n > 32) + throw new Error(`convertRadix2: wrong to=${n}`); + if (/* @__PURE__ */ ir(t, n) > 32) + throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${/* @__PURE__ */ ir(t, n)}`); + let o = 0, i = 0; + const s = zn[t], c = zn[n] - 1, a = []; + for (const h of e) { + if (si(h), h >= s) + throw new Error(`convertRadix2: invalid data word=${h} from=${t}`); + if (o = o << t | h, i + t > 32) + throw new Error(`convertRadix2: carry overflow pos=${i} from=${t}`); + for (i += t; i >= n; i -= n) + a.push((o >> i - n & c) >>> 0); + const w = zn[i]; + if (w === void 0) + throw new Error("invalid carry"); + o &= w - 1; + } + if (o = o << n - i & c, !r && i >= t) + throw new Error("Excess padding"); + if (!r && o > 0) + throw new Error(`Non-zero padding: ${o}`); + return r && i > 0 && a.push(o >>> 0), a; +} +// @__NO_SIDE_EFFECTS__ +function Kl(e, t = !1) { + if (si(e), e <= 0 || e > 32) + throw new Error("radix2: bits should be in (0..32]"); + if (/* @__PURE__ */ ir(8, e) > 32 || /* @__PURE__ */ ir(e, 8) > 32) + throw new Error("radix2: carry overflow"); + return { + encode: (n) => { + if (!ii(n)) + throw new Error("radix2.encode input should be Uint8Array"); + return _o(Array.from(n), 8, e, !t); + }, + decode: (n) => (Vl("radix2.decode", n), Uint8Array.from(_o(n, e, 8, t))) + }; +} +function us(e) { + return Ld(e), function(...t) { + try { + return e.apply(null, t); + } catch { + } + }; +} +const Md = typeof Uint8Array.from([]).toBase64 == "function" && typeof Uint8Array.fromBase64 == "function", Bd = (e, t) => { + Nt("base64", e); + const n = /^[A-Za-z0-9=+/]+$/, r = "base64"; + if (e.length > 0 && !n.test(e)) + throw new Error("invalid base64"); + return Uint8Array.fromBase64(e, { alphabet: r, lastChunkHandling: "strict" }); +}, mt = Md ? { + encode(e) { + return Sd(e), e.toBase64(); + }, + decode(e) { + return Bd(e); + } +} : /* @__PURE__ */ Gl(/* @__PURE__ */ Kl(6), /* @__PURE__ */ jl("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ Td(6), /* @__PURE__ */ zl("")), So = /* @__PURE__ */ Gl(/* @__PURE__ */ jl("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), /* @__PURE__ */ zl("")), hs = [996825010, 642813549, 513874426, 1027748829, 705979059]; +function on(e) { + const t = e >> 25; + let n = (e & 33554431) << 5; + for (let r = 0; r < hs.length; r++) + (t >> r & 1) === 1 && (n ^= hs[r]); + return n; +} +function fs(e, t, n = 1) { + const r = e.length; + let o = 1; + for (let i = 0; i < r; i++) { + const s = e.charCodeAt(i); + if (s < 33 || s > 126) + throw new Error(`Invalid prefix (${e})`); + o = on(o) ^ s >> 5; + } + o = on(o); + for (let i = 0; i < r; i++) + o = on(o) ^ e.charCodeAt(i) & 31; + for (let i of t) + o = on(o) ^ i; + for (let i = 0; i < 6; i++) + o = on(o); + return o ^= n, So.encode(_o([o % zn[30]], 30, 5, !1)); +} +// @__NO_SIDE_EFFECTS__ +function Rd(e) { + const n = /* @__PURE__ */ Kl(5), r = n.decode, o = n.encode, i = us(r); + function s(g, v, b = 90) { + Nt("bech32.encode prefix", g), ii(v) && (v = Array.from(v)), Vl("bech32.encode", v); + const C = g.length; + if (C === 0) + throw new TypeError(`Invalid prefix length ${C}`); + const L = C + 7 + v.length; + if (b !== !1 && L > b) + throw new TypeError(`Length ${L} exceeds limit ${b}`); + const M = g.toLowerCase(), I = fs(M, v, 1); + return `${M}1${So.encode(v)}${I}`; + } + function c(g, v = 90) { + Nt("bech32.decode input", g); + const b = g.length; + if (b < 8 || v !== !1 && b > v) + throw new TypeError(`invalid string length: ${b} (${g}). Expected (8..${v})`); + const C = g.toLowerCase(); + if (g !== C && g !== g.toUpperCase()) + throw new Error("String must be lowercase or uppercase"); + const L = C.lastIndexOf("1"); + if (L === 0 || L === -1) + throw new Error('Letter "1" must be present between prefix and data only'); + const M = C.slice(0, L), I = C.slice(L + 1); + if (I.length < 6) + throw new Error("Data must be at least 6 characters long"); + const U = So.decode(I).slice(0, -6), q = fs(M, U, 1); + if (!I.endsWith(q)) + throw new Error(`Invalid checksum in ${g}: expected "${q}"`); + return { prefix: M, words: U }; + } + const a = us(c); + function h(g) { + const { prefix: v, words: b } = c(g, !1); + return { prefix: v, words: b, bytes: r(b) }; + } + function w(g, v) { + return s(g, o(v)); + } + return { + encode: s, + decode: c, + encodeFromBytes: w, + decodeToBytes: h, + decodeUnsafe: a, + fromWords: r, + fromWordsUnsafe: i, + toWords: o + }; +} +const Qt = /* @__PURE__ */ Rd(); +/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */ +function Nd(e) { + return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array"; +} +function ps(e) { + if (typeof e != "boolean") + throw new Error(`boolean expected, not ${e}`); +} +function Or(e) { + if (!Number.isSafeInteger(e) || e < 0) + throw new Error("positive integer expected, got " + e); +} +function Me(e, t, n = "") { + const r = Nd(e), o = e?.length, i = t !== void 0; + if (!r || i && o !== t) { + const s = n && `"${n}" `, c = i ? ` of length ${t}` : "", a = r ? `length=${o}` : `type=${typeof e}`; + throw new Error(s + "expected Uint8Array" + c + ", got " + a); + } + return e; +} +function Se(e) { + return new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4)); +} +function Jt(...e) { + for (let t = 0; t < e.length; t++) + e[t].fill(0); +} +const $d = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68; +function Id(e, t) { + return e.buffer === t.buffer && // best we can do, may fail with an obscure Proxy + e.byteOffset < t.byteOffset + t.byteLength && // a starts before b end + t.byteOffset < e.byteOffset + e.byteLength; +} +function Ql(e, t) { + if (Id(e, t) && e.byteOffset < t.byteOffset) + throw new Error("complex overlap of input and output is not supported"); +} +function Ud(e, t) { + if (t == null || typeof t != "object") + throw new Error("options must be defined"); + return Object.assign(e, t); +} +function Od(e, t) { + if (e.length !== t.length) + return !1; + let n = 0; + for (let r = 0; r < e.length; r++) + n |= e[r] ^ t[r]; + return n === 0; +} +const Pd = /* @__NO_SIDE_EFFECTS__ */ (e, t) => { + function n(r, ...o) { + if (Me(r, void 0, "key"), !$d) + throw new Error("Non little-endian hardware is not yet supported"); + if (e.nonceLength !== void 0) { + const w = o[0]; + Me(w, e.varSizeNonce ? void 0 : e.nonceLength, "nonce"); + } + const i = e.tagLength; + i && o[1] !== void 0 && Me(o[1], void 0, "AAD"); + const s = t(r, ...o), c = (w, g) => { + if (g !== void 0) { + if (w !== 2) + throw new Error("cipher output not supported"); + Me(g, void 0, "output"); + } + }; + let a = !1; + return { + encrypt(w, g) { + if (a) + throw new Error("cannot encrypt() twice with same key + nonce"); + return a = !0, Me(w), c(s.encrypt.length, g), s.encrypt(w, g); + }, + decrypt(w, g) { + if (Me(w), i && w.length < i) + throw new Error('"ciphertext" expected length bigger than tagLength=' + i); + return c(s.decrypt.length, g), s.decrypt(w, g); + } + }; + } + return Object.assign(n, e), n; +}; +function Jl(e, t, n = !0) { + if (t === void 0) + return new Uint8Array(e); + if (t.length !== e) + throw new Error('"output" expected Uint8Array of length ' + e + ", got: " + t.length); + if (n && !jt(t)) + throw new Error("invalid output, must be aligned"); + return t; +} +function jt(e) { + return e.byteOffset % 4 === 0; +} +function Rt(e) { + return Uint8Array.from(e); +} +const yt = 16, Hd = 283; +function Dd(e) { + if (![16, 24, 32].includes(e.length)) + throw new Error('"aes key" expected Uint8Array of length 16/24/32, got length=' + e.length); +} +function ai(e) { + return e << 1 ^ Hd & -(e >> 7); +} +function Vt(e, t) { + let n = 0; + for (; t > 0; t >>= 1) + n ^= e & -(t & 1), e = ai(e); + return n; +} +const Lo = /* @__PURE__ */ (() => { + const e = new Uint8Array(256); + for (let n = 0, r = 1; n < 256; n++, r ^= ai(r)) + e[n] = r; + const t = new Uint8Array(256); + t[0] = 99; + for (let n = 0; n < 255; n++) { + let r = e[255 - n]; + r |= r << 8, t[e[n]] = (r ^ r >> 4 ^ r >> 5 ^ r >> 6 ^ r >> 7 ^ 99) & 255; + } + return Jt(e), t; +})(), Zd = /* @__PURE__ */ Lo.map((e, t) => Lo.indexOf(t)), Wd = (e) => e << 24 | e >>> 8, Pr = (e) => e << 8 | e >>> 24; +function Yl(e, t) { + if (e.length !== 256) + throw new Error("Wrong sbox length"); + const n = new Uint32Array(256).map((h, w) => t(e[w])), r = n.map(Pr), o = r.map(Pr), i = o.map(Pr), s = new Uint32Array(256 * 256), c = new Uint32Array(256 * 256), a = new Uint16Array(256 * 256); + for (let h = 0; h < 256; h++) + for (let w = 0; w < 256; w++) { + const g = h * 256 + w; + s[g] = n[h] ^ r[w], c[g] = o[h] ^ i[w], a[g] = e[h] << 8 | e[w]; + } + return { sbox: e, sbox2: a, T0: n, T1: r, T2: o, T3: i, T01: s, T23: c }; +} +const ci = /* @__PURE__ */ Yl(Lo, (e) => Vt(e, 3) << 24 | e << 16 | e << 8 | Vt(e, 2)), Xl = /* @__PURE__ */ Yl(Zd, (e) => Vt(e, 11) << 24 | Vt(e, 13) << 16 | Vt(e, 9) << 8 | Vt(e, 14)), Fd = /* @__PURE__ */ (() => { + const e = new Uint8Array(16); + for (let t = 0, n = 1; t < 16; t++, n = ai(n)) + e[t] = n; + return e; +})(); +function e0(e) { + Me(e); + const t = e.length; + Dd(e); + const { sbox2: n } = ci, r = []; + jt(e) || r.push(e = Rt(e)); + const o = Se(e), i = o.length, s = (a) => ze(n, a, a, a, a), c = new Uint32Array(t + 28); + c.set(o); + for (let a = i; a < c.length; a++) { + let h = c[a - 1]; + a % i === 0 ? h = s(Wd(h)) ^ Fd[a / i - 1] : i > 6 && a % i === 4 && (h = s(h)), c[a] = c[a - i] ^ h; + } + return Jt(...r), c; +} +function Vd(e) { + const t = e0(e), n = t.slice(), r = t.length, { sbox2: o } = ci, { T0: i, T1: s, T2: c, T3: a } = Xl; + for (let h = 0; h < r; h += 4) + for (let w = 0; w < 4; w++) + n[h + w] = t[r - h - 4 + w]; + Jt(t); + for (let h = 4; h < r - 4; h++) { + const w = n[h], g = ze(o, w, w, w, w); + n[h] = i[g & 255] ^ s[g >>> 8 & 255] ^ c[g >>> 16 & 255] ^ a[g >>> 24]; + } + return n; +} +function pt(e, t, n, r, o, i) { + return e[n << 8 & 65280 | r >>> 8 & 255] ^ t[o >>> 8 & 65280 | i >>> 24 & 255]; +} +function ze(e, t, n, r, o) { + return e[t & 255 | n & 65280] | e[r >>> 16 & 255 | o >>> 16 & 65280] << 16; +} +function gs(e, t, n, r, o) { + const { sbox2: i, T01: s, T23: c } = ci; + let a = 0; + t ^= e[a++], n ^= e[a++], r ^= e[a++], o ^= e[a++]; + const h = e.length / 4 - 2; + for (let C = 0; C < h; C++) { + const L = e[a++] ^ pt(s, c, t, n, r, o), M = e[a++] ^ pt(s, c, n, r, o, t), I = e[a++] ^ pt(s, c, r, o, t, n), U = e[a++] ^ pt(s, c, o, t, n, r); + t = L, n = M, r = I, o = U; + } + const w = e[a++] ^ ze(i, t, n, r, o), g = e[a++] ^ ze(i, n, r, o, t), v = e[a++] ^ ze(i, r, o, t, n), b = e[a++] ^ ze(i, o, t, n, r); + return { s0: w, s1: g, s2: v, s3: b }; +} +function Gd(e, t, n, r, o) { + const { sbox2: i, T01: s, T23: c } = Xl; + let a = 0; + t ^= e[a++], n ^= e[a++], r ^= e[a++], o ^= e[a++]; + const h = e.length / 4 - 2; + for (let C = 0; C < h; C++) { + const L = e[a++] ^ pt(s, c, t, o, r, n), M = e[a++] ^ pt(s, c, n, t, o, r), I = e[a++] ^ pt(s, c, r, n, t, o), U = e[a++] ^ pt(s, c, o, r, n, t); + t = L, n = M, r = I, o = U; + } + const w = e[a++] ^ ze(i, t, o, r, n), g = e[a++] ^ ze(i, n, t, o, r), v = e[a++] ^ ze(i, r, n, t, o), b = e[a++] ^ ze(i, o, r, n, t); + return { s0: w, s1: g, s2: v, s3: b }; +} +function jd(e) { + if (Me(e), e.length % yt !== 0) + throw new Error("aes-(cbc/ecb).decrypt ciphertext should consist of blocks with size " + yt); +} +function zd(e, t, n) { + Me(e); + let r = e.length; + const o = r % yt; + if (!t && o !== 0) + throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding"); + jt(e) || (e = Rt(e)); + const i = Se(e); + if (t) { + let c = yt - o; + c || (c = yt), r = r + c; + } + n = Jl(r, n), Ql(e, n); + const s = Se(n); + return { b: i, o: s, out: n }; +} +function qd(e, t) { + if (!t) + return e; + const n = e.length; + if (!n) + throw new Error("aes/pcks5: empty ciphertext not allowed"); + const r = e[n - 1]; + if (r <= 0 || r > 16) + throw new Error("aes/pcks5: wrong padding"); + const o = e.subarray(0, -r); + for (let i = 0; i < r; i++) + if (e[n - i - 1] !== r) + throw new Error("aes/pcks5: wrong padding"); + return o; +} +function Kd(e) { + const t = new Uint8Array(16), n = Se(t); + t.set(e); + const r = yt - e.length; + for (let o = yt - r; o < yt; o++) + t[o] = r; + return n; +} +const t0 = /* @__PURE__ */ Pd({ blockSize: 16, nonceLength: 16 }, function(t, n, r = {}) { + const o = !r.disablePadding; + return { + encrypt(i, s) { + const c = e0(t), { b: a, o: h, out: w } = zd(i, o, s); + let g = n; + const v = [c]; + jt(g) || v.push(g = Rt(g)); + const b = Se(g); + let C = b[0], L = b[1], M = b[2], I = b[3], U = 0; + for (; U + 4 <= a.length; ) + C ^= a[U + 0], L ^= a[U + 1], M ^= a[U + 2], I ^= a[U + 3], { s0: C, s1: L, s2: M, s3: I } = gs(c, C, L, M, I), h[U++] = C, h[U++] = L, h[U++] = M, h[U++] = I; + if (o) { + const q = Kd(i.subarray(U * 4)); + C ^= q[0], L ^= q[1], M ^= q[2], I ^= q[3], { s0: C, s1: L, s2: M, s3: I } = gs(c, C, L, M, I), h[U++] = C, h[U++] = L, h[U++] = M, h[U++] = I; + } + return Jt(...v), w; + }, + decrypt(i, s) { + jd(i); + const c = Vd(t); + let a = n; + const h = [c]; + jt(a) || h.push(a = Rt(a)); + const w = Se(a); + s = Jl(i.length, s), jt(i) || h.push(i = Rt(i)), Ql(i, s); + const g = Se(i), v = Se(s); + let b = w[0], C = w[1], L = w[2], M = w[3]; + for (let I = 0; I + 4 <= g.length; ) { + const U = b, q = C, Q = L, A = M; + b = g[I + 0], C = g[I + 1], L = g[I + 2], M = g[I + 3]; + const { s0: _, s1: E, s2: T, s3: m } = Gd(c, b, C, L, M); + v[I++] = _ ^ U, v[I++] = E ^ q, v[I++] = T ^ Q, v[I++] = m ^ A; + } + return Jt(...h), qd(s, o); + } + }; +}), n0 = (e) => Uint8Array.from(e.split(""), (t) => t.charCodeAt(0)), Qd = n0("expand 16-byte k"), Jd = n0("expand 32-byte k"), Yd = Se(Qd), Xd = Se(Jd); +function le(e, t) { + return e << t | e >>> 32 - t; +} +function To(e) { + return e.byteOffset % 4 === 0; +} +const $n = 64, eu = 16, r0 = 2 ** 32 - 1, ws = Uint32Array.of(); +function tu(e, t, n, r, o, i, s, c) { + const a = o.length, h = new Uint8Array($n), w = Se(h), g = To(o) && To(i), v = g ? Se(o) : ws, b = g ? Se(i) : ws; + for (let C = 0; C < a; s++) { + if (e(t, n, r, w, s, c), s >= r0) + throw new Error("arx: counter overflow"); + const L = Math.min($n, a - C); + if (g && L === $n) { + const M = C / 4; + if (C % 4 !== 0) + throw new Error("arx: invalid block position"); + for (let I = 0, U; I < eu; I++) + U = M + I, b[U] = v[U] ^ w[I]; + C += $n; + continue; + } + for (let M = 0, I; M < L; M++) + I = C + M, i[I] = o[I] ^ h[M]; + C += L; + } +} +function nu(e, t) { + const { allowShortKeys: n, extendNonceFn: r, counterLength: o, counterRight: i, rounds: s } = Ud({ allowShortKeys: !1, counterLength: 8, counterRight: !1, rounds: 20 }, t); + if (typeof e != "function") + throw new Error("core must be a function"); + return Or(o), Or(s), ps(i), ps(n), (c, a, h, w, g = 0) => { + Me(c, void 0, "key"), Me(a, void 0, "nonce"), Me(h, void 0, "data"); + const v = h.length; + if (w === void 0 && (w = new Uint8Array(v)), Me(w, void 0, "output"), Or(g), g < 0 || g >= r0) + throw new Error("arx: counter overflow"); + if (w.length < v) + throw new Error(`arx: output (${w.length}) is shorter than data (${v})`); + const b = []; + let C = c.length, L, M; + if (C === 32) + b.push(L = Rt(c)), M = Xd; + else if (C === 16 && n) + L = new Uint8Array(32), L.set(c), L.set(c, 16), M = Yd, b.push(L); + else + throw Me(c, 32, "arx key"), new Error("invalid key size"); + To(a) || b.push(a = Rt(a)); + const I = Se(L); + if (r) { + if (a.length !== 24) + throw new Error("arx: extended nonce must be 24 bytes"); + r(M, I, Se(a.subarray(0, 16)), I), a = a.subarray(16); + } + const U = 16 - o; + if (U !== a.length) + throw new Error(`arx: nonce must be ${U} or 16 bytes`); + if (U !== 12) { + const Q = new Uint8Array(12); + Q.set(a, i ? 0 : 12 - a.length), a = Q, b.push(a); + } + const q = Se(a); + return tu(e, M, I, q, h, w, g, s), Jt(...b), w; + }; +} +function ru(e, t, n, r, o, i = 20) { + let s = e[0], c = e[1], a = e[2], h = e[3], w = t[0], g = t[1], v = t[2], b = t[3], C = t[4], L = t[5], M = t[6], I = t[7], U = o, q = n[0], Q = n[1], A = n[2], _ = s, E = c, T = a, m = h, k = w, d = g, l = v, u = b, p = C, f = L, y = M, x = I, O = U, R = q, P = Q, S = A; + for (let J = 0; J < i; J += 2) + _ = _ + k | 0, O = le(O ^ _, 16), p = p + O | 0, k = le(k ^ p, 12), _ = _ + k | 0, O = le(O ^ _, 8), p = p + O | 0, k = le(k ^ p, 7), E = E + d | 0, R = le(R ^ E, 16), f = f + R | 0, d = le(d ^ f, 12), E = E + d | 0, R = le(R ^ E, 8), f = f + R | 0, d = le(d ^ f, 7), T = T + l | 0, P = le(P ^ T, 16), y = y + P | 0, l = le(l ^ y, 12), T = T + l | 0, P = le(P ^ T, 8), y = y + P | 0, l = le(l ^ y, 7), m = m + u | 0, S = le(S ^ m, 16), x = x + S | 0, u = le(u ^ x, 12), m = m + u | 0, S = le(S ^ m, 8), x = x + S | 0, u = le(u ^ x, 7), _ = _ + d | 0, S = le(S ^ _, 16), y = y + S | 0, d = le(d ^ y, 12), _ = _ + d | 0, S = le(S ^ _, 8), y = y + S | 0, d = le(d ^ y, 7), E = E + l | 0, O = le(O ^ E, 16), x = x + O | 0, l = le(l ^ x, 12), E = E + l | 0, O = le(O ^ E, 8), x = x + O | 0, l = le(l ^ x, 7), T = T + u | 0, R = le(R ^ T, 16), p = p + R | 0, u = le(u ^ p, 12), T = T + u | 0, R = le(R ^ T, 8), p = p + R | 0, u = le(u ^ p, 7), m = m + k | 0, P = le(P ^ m, 16), f = f + P | 0, k = le(k ^ f, 12), m = m + k | 0, P = le(P ^ m, 8), f = f + P | 0, k = le(k ^ f, 7); + let D = 0; + r[D++] = s + _ | 0, r[D++] = c + E | 0, r[D++] = a + T | 0, r[D++] = h + m | 0, r[D++] = w + k | 0, r[D++] = g + d | 0, r[D++] = v + l | 0, r[D++] = b + u | 0, r[D++] = C + p | 0, r[D++] = L + f | 0, r[D++] = M + y | 0, r[D++] = I + x | 0, r[D++] = U + O | 0, r[D++] = q + R | 0, r[D++] = Q + P | 0, r[D++] = A + S | 0; +} +const o0 = /* @__PURE__ */ nu(ru, { + counterRight: !1, + counterLength: 4, + allowShortKeys: !1 +}); +function ou(e, t, n) { + return pr(e), n === void 0 && (n = new Uint8Array(e.outputLen)), Tn(e, n, t); +} +const Hr = /* @__PURE__ */ Uint8Array.of(0), ys = /* @__PURE__ */ Uint8Array.of(); +function iu(e, t, n, r = 32) { + pr(e), bt(r, "length"); + const o = e.outputLen; + if (r > 255 * o) + throw new Error("Length must be <= 255*HashLen"); + const i = Math.ceil(r / o); + n === void 0 ? n = ys : fe(n, void 0, "info"); + const s = new Uint8Array(i * o), c = Tn.create(e, t), a = c._cloneInto(), h = new Uint8Array(c.outputLen); + for (let w = 0; w < i; w++) + Hr[0] = w + 1, a.update(w === 0 ? ys : h).update(n).update(Hr).digestInto(h), s.set(h, o * w), c._cloneInto(a); + return c.destroy(), a.destroy(), mn(h, Hr), s.slice(0, r); +} +var su = Object.defineProperty, ye = (e, t) => { + for (var n in t) + su(e, n, { get: t[n], enumerable: !0 }); +}, Ht = Symbol("verified"), au = (e) => e instanceof Object; +function li(e) { + if (!au(e) || typeof e.kind != "number" || typeof e.content != "string" || typeof e.created_at != "number" || typeof e.pubkey != "string" || !e.pubkey.match(/^[a-f0-9]{64}$/) || !Array.isArray(e.tags)) + return !1; + for (let t = 0; t < e.tags.length; t++) { + let n = e.tags[t]; + if (!Array.isArray(n)) + return !1; + for (let r = 0; r < n.length; r++) + if (typeof n[r] != "string") + return !1; + } + return !0; +} +var cu = {}; +ye(cu, { + binarySearch: () => di, + bytesToHex: () => pe, + hexToBytes: () => ue, + insertEventIntoAscendingList: () => du, + insertEventIntoDescendingList: () => lu, + mergeReverseSortedLists: () => uu, + normalizeURL: () => i0, + utf8Decoder: () => nt, + utf8Encoder: () => De +}); +var nt = new TextDecoder("utf-8"), De = new TextEncoder(); +function i0(e) { + try { + e.indexOf("://") === -1 && (e = "wss://" + e); + let t = new URL(e); + return t.protocol === "http:" ? t.protocol = "ws:" : t.protocol === "https:" && (t.protocol = "wss:"), t.pathname = t.pathname.replace(/\/+/g, "/"), t.pathname.endsWith("/") && (t.pathname = t.pathname.slice(0, -1)), (t.port === "80" && t.protocol === "ws:" || t.port === "443" && t.protocol === "wss:") && (t.port = ""), t.searchParams.sort(), t.hash = "", t.toString(); + } catch { + throw new Error(`Invalid URL: ${e}`); + } +} +function lu(e, t) { + const [n, r] = di(e, (o) => t.id === o.id ? 0 : t.created_at === o.created_at ? -1 : o.created_at - t.created_at); + return r || e.splice(n, 0, t), e; +} +function du(e, t) { + const [n, r] = di(e, (o) => t.id === o.id ? 0 : t.created_at === o.created_at ? -1 : t.created_at - o.created_at); + return r || e.splice(n, 0, t), e; +} +function di(e, t) { + let n = 0, r = e.length - 1; + for (; n <= r; ) { + const o = Math.floor((n + r) / 2), i = t(e[o]); + if (i === 0) + return [o, !0]; + i < 0 ? r = o - 1 : n = o + 1; + } + return [n, !1]; +} +function uu(e, t) { + const n = new Array(e.length + t.length); + n.length = 0; + let r = 0, o = 0, i = []; + for (; r < e.length && o < t.length; ) { + let s; + if (e[r]?.created_at > t[o]?.created_at ? (s = e[r], r++) : (s = t[o], o++), n.length > 0 && n[n.length - 1].created_at === s.created_at) { + if (i.includes(s.id)) + continue; + } else + i.length = 0; + n.push(s), i.push(s.id); + } + for (; r < e.length; ) { + const s = e[r]; + if (r++, n.length > 0 && n[n.length - 1].created_at === s.created_at) { + if (i.includes(s.id)) + continue; + } else + i.length = 0; + n.push(s), i.push(s.id); + } + for (; o < t.length; ) { + const s = t[o]; + if (o++, n.length > 0 && n[n.length - 1].created_at === s.created_at) { + if (i.includes(s.id)) + continue; + } else + i.length = 0; + n.push(s), i.push(s.id); + } + return n; +} +var hu = class { + generateSecretKey() { + return rn.utils.randomSecretKey(); + } + getPublicKey(e) { + return pe(rn.getPublicKey(e)); + } + finalizeEvent(e, t) { + const n = e; + return n.pubkey = pe(rn.getPublicKey(t)), n.id = gn(n), n.sig = pe(rn.sign(ue(gn(n)), t)), n[Ht] = !0, n; + } + verifyEvent(e) { + if (typeof e[Ht] == "boolean") + return e[Ht]; + try { + const t = gn(e); + if (t !== e.id) + return e[Ht] = !1, !1; + const n = rn.verify(ue(e.sig), ue(t), ue(e.pubkey)); + return e[Ht] = n, n; + } catch { + return e[Ht] = !1, !1; + } + } +}; +function fu(e) { + if (!li(e)) + throw new Error("can't serialize event with wrong or missing properties"); + return JSON.stringify([0, e.pubkey, e.created_at, e.kind, e.tags, e.content]); +} +function gn(e) { + let t = Ke(De.encode(fu(e))); + return pe(t); +} +var yr = new hu(), ui = yr.generateSecretKey, Yt = yr.getPublicKey, Fe = yr.finalizeEvent, br = yr.verifyEvent, pu = {}; +ye(pu, { + Application: () => _h, + BadgeAward: () => xu, + BadgeDefinition: () => mh, + BlockedRelaysList: () => th, + BlossomServerList: () => ch, + BookmarkList: () => Yu, + Bookmarksets: () => wh, + Calendar: () => Nh, + CalendarEventRSVP: () => $h, + ChannelCreation: () => u0, + ChannelHideMessage: () => p0, + ChannelMessage: () => f0, + ChannelMetadata: () => h0, + ChannelMuteUser: () => g0, + ChatMessage: () => Eu, + ClassifiedListing: () => Th, + ClientAuth: () => y0, + Comment: () => Ru, + CommunitiesList: () => Xu, + CommunityDefinition: () => Ph, + CommunityPostApproval: () => Du, + Contacts: () => mu, + CreateOrUpdateProduct: () => xh, + CreateOrUpdateStall: () => Ch, + Curationsets: () => yh, + Date: () => Bh, + DirectMessageRelaysList: () => sh, + DraftClassifiedListing: () => Mh, + DraftLong: () => Ah, + Emojisets: () => kh, + EncryptedDirectMessage: () => vu, + EventDeletion: () => Cu, + FavoriteRelays: () => rh, + FileMessage: () => ku, + FileMetadata: () => Bu, + FileServerPreference: () => ah, + Followsets: () => fh, + ForumThread: () => Au, + GenericRepost: () => wi, + Genericlists: () => ph, + GiftWrap: () => w0, + GroupMetadata: () => Hh, + HTTPAuth: () => yi, + Handlerinformation: () => Oh, + Handlerrecommendation: () => Uh, + Highlights: () => zu, + InterestsList: () => oh, + Interestsets: () => vh, + JobFeedback: () => Fu, + JobRequest: () => Zu, + JobResult: () => Wu, + Label: () => Hu, + LightningPubRPC: () => dh, + LiveChatMessage: () => Nu, + LiveEvent: () => Sh, + LongFormArticle: () => Eh, + Metadata: () => yu, + Mutelist: () => Ku, + NWCWalletInfo: () => lh, + NWCWalletRequest: () => b0, + NWCWalletResponse: () => uh, + NormalVideo: () => Su, + NostrConnect: () => hh, + OpenTimestamps: () => Tu, + Photo: () => _u, + Pinlist: () => Qu, + Poll: () => Mu, + PollResponse: () => qu, + PrivateDirectMessage: () => d0, + ProblemTracker: () => Uu, + ProfileBadges: () => bh, + PublicChatsList: () => eh, + Reaction: () => gi, + RecommendRelay: () => bu, + RelayList: () => Ju, + RelayReview: () => Ih, + Relaysets: () => gh, + Report: () => Ou, + Reporting: () => Pu, + Repost: () => pi, + Seal: () => l0, + SearchRelaysList: () => nh, + ShortTextNote: () => c0, + ShortVideo: () => Lu, + Time: () => Rh, + UserEmojiList: () => ih, + UserStatuses: () => Lh, + Voice: () => $u, + VoiceComment: () => Iu, + Zap: () => ju, + ZapGoal: () => Vu, + ZapRequest: () => Gu, + classifyKind: () => gu, + isAddressableKind: () => fi, + isEphemeralKind: () => a0, + isKind: () => wu, + isRegularKind: () => s0, + isReplaceableKind: () => hi +}); +function s0(e) { + return e < 1e4 && e !== 0 && e !== 3; +} +function hi(e) { + return e === 0 || e === 3 || 1e4 <= e && e < 2e4; +} +function a0(e) { + return 2e4 <= e && e < 3e4; +} +function fi(e) { + return 3e4 <= e && e < 4e4; +} +function gu(e) { + return s0(e) ? "regular" : hi(e) ? "replaceable" : a0(e) ? "ephemeral" : fi(e) ? "parameterized" : "unknown"; +} +function wu(e, t) { + const n = t instanceof Array ? t : [t]; + return li(e) && n.includes(e.kind) || !1; +} +var yu = 0, c0 = 1, bu = 2, mu = 3, vu = 4, Cu = 5, pi = 6, gi = 7, xu = 8, Eu = 9, Au = 11, l0 = 13, d0 = 14, ku = 15, wi = 16, _u = 20, Su = 21, Lu = 22, u0 = 40, h0 = 41, f0 = 42, p0 = 43, g0 = 44, Tu = 1040, w0 = 1059, Mu = 1068, Bu = 1063, Ru = 1111, Nu = 1311, $u = 1222, Iu = 1244, Uu = 1971, Ou = 1984, Pu = 1984, Hu = 1985, Du = 4550, Zu = 5999, Wu = 6999, Fu = 7e3, Vu = 9041, Gu = 9734, ju = 9735, zu = 9802, qu = 1018, Ku = 1e4, Qu = 10001, Ju = 10002, Yu = 10003, Xu = 10004, eh = 10005, th = 10006, nh = 10007, rh = 10012, oh = 10015, ih = 10030, sh = 10050, ah = 10096, ch = 10063, lh = 13194, dh = 21e3, y0 = 22242, b0 = 23194, uh = 23195, hh = 24133, yi = 27235, fh = 3e4, ph = 30001, gh = 30002, wh = 30003, yh = 30004, bh = 30008, mh = 30009, vh = 30015, Ch = 30017, xh = 30018, Eh = 30023, Ah = 30024, kh = 30030, _h = 30078, Sh = 30311, Lh = 30315, Th = 30402, Mh = 30403, Bh = 31922, Rh = 31923, Nh = 31924, $h = 31925, Ih = 31987, Uh = 31989, Oh = 31990, Ph = 34550, Hh = 39e3; +function Dh(e, t) { + if (e.ids && e.ids.indexOf(t.id) === -1 || e.kinds && e.kinds.indexOf(t.kind) === -1 || e.authors && e.authors.indexOf(t.pubkey) === -1) + return !1; + for (let n in e) + if (n[0] === "#") { + let r = n.slice(1), o = e[`#${r}`]; + if (o && !t.tags.find(([i, s]) => i === n.slice(1) && o.indexOf(s) !== -1)) + return !1; + } + return !(e.since && t.created_at < e.since || e.until && t.created_at > e.until); +} +function Zh(e, t) { + for (let n = 0; n < e.length; n++) + if (Dh(e[n], t)) + return !0; + return !1; +} +var Wh = {}; +ye(Wh, { + getHex64: () => mr, + getInt: () => m0, + getSubscriptionId: () => v0, + matchEventId: () => Fh, + matchEventKind: () => Gh, + matchEventPubkey: () => Vh +}); +function mr(e, t) { + let n = t.length + 3, r = e.indexOf(`"${t}":`) + n, o = e.slice(r).indexOf('"') + r + 1; + return e.slice(o, o + 64); +} +function m0(e, t) { + let n = t.length, r = e.indexOf(`"${t}":`) + n + 3, o = e.slice(r), i = Math.min(o.indexOf(","), o.indexOf("}")); + return parseInt(o.slice(0, i), 10); +} +function v0(e) { + let t = e.slice(0, 22).indexOf('"EVENT"'); + if (t === -1) + return null; + let n = e.slice(t + 7 + 1).indexOf('"'); + if (n === -1) + return null; + let r = t + 7 + 1 + n, o = e.slice(r + 1, 80).indexOf('"'); + if (o === -1) + return null; + let i = r + 1 + o; + return e.slice(r + 1, i); +} +function Fh(e, t) { + return t === mr(e, "id"); +} +function Vh(e, t) { + return t === mr(e, "pubkey"); +} +function Gh(e, t) { + return t === m0(e, "kind"); +} +var jh = {}; +ye(jh, { + makeAuthEvent: () => C0 +}); +function C0(e, t) { + return { + kind: y0, + created_at: Math.floor(Date.now() / 1e3), + tags: [ + ["relay", e], + ["challenge", t] + ], + content: "" + }; +} +var x0 = class extends Error { + constructor(e, t) { + super(`Tried to send message '${e} on a closed connection to ${t}.`), this.name = "SendingOnClosedConnection"; + } +}, E0 = class { + url; + _connected = !1; + onclose = null; + onnotice = (e) => console.debug(`NOTICE from ${this.url}: ${e}`); + onauth; + baseEoseTimeout = 4400; + publishTimeout = 4400; + pingFrequency = 29e3; + pingTimeout = 2e4; + resubscribeBackoff = [1e4, 1e4, 1e4, 2e4, 2e4, 3e4, 6e4]; + openSubs = /* @__PURE__ */ new Map(); + enablePing; + enableReconnect; + idleSince = Date.now(); + ongoingOperations = 0; + reconnectTimeoutHandle; + pingIntervalHandle; + reconnectAttempts = 0; + skipReconnection = !1; + connectionPromise; + openCountRequests = /* @__PURE__ */ new Map(); + openEventPublishes = /* @__PURE__ */ new Map(); + ws; + challenge; + authPromise; + serial = 0; + verifyEvent; + _WebSocket; + constructor(e, t) { + this.url = i0(e), this.verifyEvent = t.verifyEvent, this._WebSocket = t.websocketImplementation || WebSocket, this.enablePing = t.enablePing, this.enableReconnect = t.enableReconnect || !1; + } + static async connect(e, t) { + const n = new E0(e, t); + return await n.connect(t), n; + } + closeAllSubscriptions(e) { + for (let [t, n] of this.openSubs) + n.close(e); + this.openSubs.clear(); + for (let [t, n] of this.openEventPublishes) + n.reject(new Error(e)); + this.openEventPublishes.clear(); + for (let [t, n] of this.openCountRequests) + n.reject(new Error(e)); + this.openCountRequests.clear(); + } + get connected() { + return this._connected; + } + async reconnect() { + const e = this.resubscribeBackoff[Math.min(this.reconnectAttempts, this.resubscribeBackoff.length - 1)]; + this.reconnectAttempts++, this.reconnectTimeoutHandle = setTimeout(async () => { + try { + await this.connect(); + } catch { + } + }, e); + } + handleHardClose(e) { + this.pingIntervalHandle && (clearInterval(this.pingIntervalHandle), this.pingIntervalHandle = void 0), this._connected = !1, this.connectionPromise = void 0, this.idleSince = void 0, this.enableReconnect && !this.skipReconnection ? this.reconnect() : (this.onclose?.(), this.closeAllSubscriptions(e)); + } + async connect(e) { + let t; + return this.connectionPromise ? this.connectionPromise : (this.challenge = void 0, this.authPromise = void 0, this.skipReconnection = !1, this.connectionPromise = new Promise((n, r) => { + e?.timeout && (t = setTimeout(() => { + r("connection timed out"), this.connectionPromise = void 0, this.skipReconnection = !0, this.onclose?.(), this.handleHardClose("relay connection timed out"); + }, e.timeout)), e?.abort && (e.abort.onabort = r); + try { + this.ws = new this._WebSocket(this.url); + } catch (o) { + clearTimeout(t), r(o); + return; + } + this.ws.onopen = () => { + this.reconnectTimeoutHandle && (clearTimeout(this.reconnectTimeoutHandle), this.reconnectTimeoutHandle = void 0), clearTimeout(t), this._connected = !0; + const o = this.reconnectAttempts > 0; + this.reconnectAttempts = 0; + for (const i of this.openSubs.values()) { + if (i.eosed = !1, o) + for (let s = 0; s < i.filters.length; s++) + i.lastEmitted && (i.filters[s].since = i.lastEmitted + 1); + i.fire(); + } + this.enablePing && (this.pingIntervalHandle = setInterval(() => this.pingpong(), this.pingFrequency)), n(); + }, this.ws.onerror = () => { + clearTimeout(t), r("connection failed"), this.connectionPromise = void 0, this.skipReconnection = !0, this.onclose?.(), this.handleHardClose("relay connection failed"); + }, this.ws.onclose = (o) => { + clearTimeout(t), r(o.message || "websocket closed"), this.handleHardClose("relay connection closed"); + }, this.ws.onmessage = this._onmessage.bind(this); + }), this.connectionPromise); + } + waitForPingPong() { + return new Promise((e) => { + this.ws.once("pong", () => e(!0)), this.ws.ping(); + }); + } + waitForDummyReq() { + return new Promise((e, t) => { + if (!this.connectionPromise) + return t(new Error(`no connection to ${this.url}, can't ping`)); + try { + const n = this.subscribe( + [{ ids: ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"], limit: 0 }], + { + label: "", + oneose: () => { + e(!0), n.close(); + }, + onclose() { + e(!0); + }, + eoseTimeout: this.pingTimeout + 1e3 + } + ); + } catch (n) { + t(n); + } + }); + } + async pingpong() { + this.ws?.readyState === 1 && (await Promise.any([ + this.ws && this.ws.ping && this.ws.once ? this.waitForPingPong() : this.waitForDummyReq(), + new Promise((t) => setTimeout(() => t(!1), this.pingTimeout)) + ]) || this.ws?.readyState === this._WebSocket.OPEN && this.ws?.close()); + } + async send(e) { + if (!this.connectionPromise) + throw new x0(e, this.url); + this.connectionPromise.then(() => { + this.ws?.send(e); + }); + } + async auth(e) { + const t = this.challenge; + if (!t) + throw new Error("can't perform auth, no challenge was received"); + return this.authPromise ? this.authPromise : (this.authPromise = new Promise(async (n, r) => { + try { + let o = await e(C0(this.url, t)), i = setTimeout(() => { + let s = this.openEventPublishes.get(o.id); + s && (s.reject(new Error("auth timed out")), this.openEventPublishes.delete(o.id)); + }, this.publishTimeout); + this.openEventPublishes.set(o.id, { resolve: n, reject: r, timeout: i }), this.send('["AUTH",' + JSON.stringify(o) + "]"); + } catch (o) { + console.warn("subscribe auth function failed:", o); + } + }), this.authPromise); + } + async publish(e) { + this.idleSince = void 0, this.ongoingOperations++; + const t = new Promise((n, r) => { + const o = setTimeout(() => { + const i = this.openEventPublishes.get(e.id); + i && (i.reject(new Error("publish timed out")), this.openEventPublishes.delete(e.id)); + }, this.publishTimeout); + this.openEventPublishes.set(e.id, { resolve: n, reject: r, timeout: o }); + }); + return this.send('["EVENT",' + JSON.stringify(e) + "]"), this.ongoingOperations--, this.ongoingOperations === 0 && (this.idleSince = Date.now()), t; + } + async count(e, t) { + this.serial++; + const n = t?.id || "count:" + this.serial, r = new Promise((o, i) => { + this.openCountRequests.set(n, { resolve: o, reject: i }); + }); + return this.send('["COUNT","' + n + '",' + JSON.stringify(e).substring(1)), r; + } + subscribe(e, t) { + t.label !== "" && (this.idleSince = void 0, this.ongoingOperations++); + const n = this.prepareSubscription(e, t); + return n.fire(), t.abort && (t.abort.onabort = () => n.close(String(t.abort.reason || ""))), n; + } + prepareSubscription(e, t) { + this.serial++; + const n = t.id || (t.label ? t.label + ":" : "sub:") + this.serial, r = new zh(this, n, e, t); + return this.openSubs.set(n, r), r; + } + close() { + this.skipReconnection = !0, this.reconnectTimeoutHandle && (clearTimeout(this.reconnectTimeoutHandle), this.reconnectTimeoutHandle = void 0), this.pingIntervalHandle && (clearInterval(this.pingIntervalHandle), this.pingIntervalHandle = void 0), this.closeAllSubscriptions("relay connection closed by us"), this._connected = !1, this.idleSince = void 0, this.onclose?.(), this.ws?.readyState === this._WebSocket.OPEN && this.ws?.close(); + } + _onmessage(e) { + const t = e.data; + if (!t) + return; + const n = v0(t); + if (n) { + const r = this.openSubs.get(n); + if (!r) + return; + const o = mr(t, "id"), i = r.alreadyHaveEvent?.(o); + if (r.receivedEvent?.(this, o), i) + return; + } + try { + let r = JSON.parse(t); + switch (r[0]) { + case "EVENT": { + const o = this.openSubs.get(r[1]), i = r[2]; + this.verifyEvent(i) && Zh(o.filters, i) ? o.onevent(i) : o.oninvalidevent?.(i), (!o.lastEmitted || o.lastEmitted < i.created_at) && (o.lastEmitted = i.created_at); + return; + } + case "COUNT": { + const o = r[1], i = r[2], s = this.openCountRequests.get(o); + s && (s.resolve(i.count), this.openCountRequests.delete(o)); + return; + } + case "EOSE": { + const o = this.openSubs.get(r[1]); + if (!o) + return; + o.receivedEose(); + return; + } + case "OK": { + const o = r[1], i = r[2], s = r[3], c = this.openEventPublishes.get(o); + c && (clearTimeout(c.timeout), i ? c.resolve(s) : c.reject(new Error(s)), this.openEventPublishes.delete(o)); + return; + } + case "CLOSED": { + const o = r[1], i = this.openSubs.get(o); + if (!i) + return; + i.closed = !0, i.close(r[2]); + return; + } + case "NOTICE": { + this.onnotice(r[1]); + return; + } + case "AUTH": { + this.challenge = r[1], this.onauth && this.auth(this.onauth); + return; + } + default: { + this.openSubs.get(r[1])?.oncustom?.(r); + return; + } + } + } catch (r) { + try { + const [o, i, s] = JSON.parse(t); + console.warn(`[nostr] relay ${this.url} error processing message:`, r, s); + } catch { + console.warn(`[nostr] relay ${this.url} error processing message:`, r); + } + return; + } + } +}, zh = class { + relay; + id; + lastEmitted; + closed = !1; + eosed = !1; + filters; + alreadyHaveEvent; + receivedEvent; + onevent; + oninvalidevent; + oneose; + onclose; + oncustom; + eoseTimeout; + eoseTimeoutHandle; + constructor(e, t, n, r) { + if (n.length === 0) + throw new Error("subscription can't be created with zero filters"); + this.relay = e, this.filters = n, this.id = t, this.alreadyHaveEvent = r.alreadyHaveEvent, this.receivedEvent = r.receivedEvent, this.eoseTimeout = r.eoseTimeout || e.baseEoseTimeout, this.oneose = r.oneose, this.onclose = r.onclose, this.oninvalidevent = r.oninvalidevent, this.onevent = r.onevent || ((o) => { + console.warn( + `onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`, + o + ); + }); + } + fire() { + this.relay.send('["REQ","' + this.id + '",' + JSON.stringify(this.filters).substring(1)), this.eoseTimeoutHandle = setTimeout(this.receivedEose.bind(this), this.eoseTimeout); + } + receivedEose() { + this.eosed || (clearTimeout(this.eoseTimeoutHandle), this.eosed = !0, this.oneose?.()); + } + close(e = "closed by caller") { + if (!this.closed && this.relay.connected) { + try { + this.relay.send('["CLOSE",' + JSON.stringify(this.id) + "]"); + } catch (t) { + if (!(t instanceof x0)) throw t; + } + this.closed = !0; + } + this.relay.openSubs.delete(this.id), this.relay.ongoingOperations--, this.relay.ongoingOperations === 0 && (this.relay.idleSince = Date.now()), this.onclose?.(e); + } +}, A0; +try { + A0 = WebSocket; +} catch { +} +var k0 = class extends E0 { + constructor(e, t) { + super(e, { verifyEvent: br, websocketImplementation: A0, ...t }); + } + static async connect(e, t) { + const n = new k0(e, t); + return await n.connect(), n; + } +}, qh; +try { + qh = WebSocket; +} catch { +} +var Mo = {}; +ye(Mo, { + BECH32_REGEX: () => _0, + Bech32MaxSize: () => bi, + NostrTypeGuard: () => Kh, + decode: () => vr, + decodeNostrURI: () => Jh, + encodeBytes: () => xr, + naddrEncode: () => rf, + neventEncode: () => nf, + noteEncode: () => ef, + nprofileEncode: () => tf, + npubEncode: () => Xh, + nsecEncode: () => Yh +}); +var Kh = { + isNProfile: (e) => /^nprofile1[a-z\d]+$/.test(e || ""), + isNEvent: (e) => /^nevent1[a-z\d]+$/.test(e || ""), + isNAddr: (e) => /^naddr1[a-z\d]+$/.test(e || ""), + isNSec: (e) => /^nsec1[a-z\d]{58}$/.test(e || ""), + isNPub: (e) => /^npub1[a-z\d]{58}$/.test(e || ""), + isNote: (e) => /^note1[a-z\d]+$/.test(e || ""), + isNcryptsec: (e) => /^ncryptsec1[a-z\d]+$/.test(e || "") +}, bi = 5e3, _0 = /[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/; +function Qh(e) { + const t = new Uint8Array(4); + return t[0] = e >> 24 & 255, t[1] = e >> 16 & 255, t[2] = e >> 8 & 255, t[3] = e & 255, t; +} +function Jh(e) { + try { + return e.startsWith("nostr:") && (e = e.substring(6)), vr(e); + } catch { + return { type: "invalid", data: null }; + } +} +function vr(e) { + let { prefix: t, words: n } = Qt.decode(e, bi), r = new Uint8Array(Qt.fromWords(n)); + switch (t) { + case "nprofile": { + let o = Dr(r); + if (!o[0]?.[0]) + throw new Error("missing TLV 0 for nprofile"); + if (o[0][0].length !== 32) + throw new Error("TLV 0 should be 32 bytes"); + return { + type: "nprofile", + data: { + pubkey: pe(o[0][0]), + relays: o[1] ? o[1].map((i) => nt.decode(i)) : [] + } + }; + } + case "nevent": { + let o = Dr(r); + if (!o[0]?.[0]) + throw new Error("missing TLV 0 for nevent"); + if (o[0][0].length !== 32) + throw new Error("TLV 0 should be 32 bytes"); + if (o[2] && o[2][0].length !== 32) + throw new Error("TLV 2 should be 32 bytes"); + if (o[3] && o[3][0].length !== 4) + throw new Error("TLV 3 should be 4 bytes"); + return { + type: "nevent", + data: { + id: pe(o[0][0]), + relays: o[1] ? o[1].map((i) => nt.decode(i)) : [], + author: o[2]?.[0] ? pe(o[2][0]) : void 0, + kind: o[3]?.[0] ? parseInt(pe(o[3][0]), 16) : void 0 + } + }; + } + case "naddr": { + let o = Dr(r); + if (!o[0]?.[0]) + throw new Error("missing TLV 0 for naddr"); + if (!o[2]?.[0]) + throw new Error("missing TLV 2 for naddr"); + if (o[2][0].length !== 32) + throw new Error("TLV 2 should be 32 bytes"); + if (!o[3]?.[0]) + throw new Error("missing TLV 3 for naddr"); + if (o[3][0].length !== 4) + throw new Error("TLV 3 should be 4 bytes"); + return { + type: "naddr", + data: { + identifier: nt.decode(o[0][0]), + pubkey: pe(o[2][0]), + kind: parseInt(pe(o[3][0]), 16), + relays: o[1] ? o[1].map((i) => nt.decode(i)) : [] + } + }; + } + case "nsec": + return { type: t, data: r }; + case "npub": + case "note": + return { type: t, data: pe(r) }; + default: + throw new Error(`unknown prefix ${t}`); + } +} +function Dr(e) { + let t = {}, n = e; + for (; n.length > 0; ) { + let r = n[0], o = n[1], i = n.slice(2, 2 + o); + if (n = n.slice(2 + o), i.length < o) + throw new Error(`not enough data to read on TLV ${r}`); + t[r] = t[r] || [], t[r].push(i); + } + return t; +} +function Yh(e) { + return xr("nsec", e); +} +function Xh(e) { + return xr("npub", ue(e)); +} +function ef(e) { + return xr("note", ue(e)); +} +function Cr(e, t) { + let n = Qt.toWords(t); + return Qt.encode(e, n, bi); +} +function xr(e, t) { + return Cr(e, t); +} +function tf(e) { + let t = mi({ + 0: [ue(e.pubkey)], + 1: (e.relays || []).map((n) => De.encode(n)) + }); + return Cr("nprofile", t); +} +function nf(e) { + let t; + e.kind !== void 0 && (t = Qh(e.kind)); + let n = mi({ + 0: [ue(e.id)], + 1: (e.relays || []).map((r) => De.encode(r)), + 2: e.author ? [ue(e.author)] : [], + 3: t ? [new Uint8Array(t)] : [] + }); + return Cr("nevent", n); +} +function rf(e) { + let t = new ArrayBuffer(4); + new DataView(t).setUint32(0, e.kind, !1); + let n = mi({ + 0: [De.encode(e.identifier)], + 1: (e.relays || []).map((r) => De.encode(r)), + 2: [ue(e.pubkey)], + 3: [new Uint8Array(t)] + }); + return Cr("naddr", n); +} +function mi(e) { + let t = []; + return Object.entries(e).reverse().forEach(([n, r]) => { + r.forEach((o) => { + let i = new Uint8Array(o.length + 2); + i.set([parseInt(n)], 0), i.set([o.length], 1), i.set(o, 2), t.push(i); + }); + }), Be(...t); +} +var Bo = {}; +ye(Bo, { + decrypt: () => of, + encrypt: () => S0 +}); +function S0(e, t, n) { + const r = e instanceof Uint8Array ? e : ue(e), o = ni.getSharedSecret(r, ue("02" + t)), i = L0(o); + let s = Uint8Array.from(nn(16)), c = De.encode(n), a = t0(i, s).encrypt(c), h = mt.encode(new Uint8Array(a)), w = mt.encode(new Uint8Array(s.buffer)); + return `${h}?iv=${w}`; +} +function of(e, t, n) { + const r = e instanceof Uint8Array ? e : ue(e); + let [o, i] = n.split("?iv="), s = ni.getSharedSecret(r, ue("02" + t)), c = L0(s), a = mt.decode(i), h = mt.decode(o), w = t0(c, a).decrypt(h); + return nt.decode(w); +} +function L0(e) { + return e.slice(1, 33); +} +var sf = {}; +ye(sf, { + NIP05_REGEX: () => vi, + isNip05: () => af, + isValid: () => df, + queryProfile: () => T0, + searchDomain: () => lf, + useFetchImplementation: () => cf +}); +var vi = /^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/, af = (e) => vi.test(e || ""), Er; +try { + Er = fetch; +} catch { +} +function cf(e) { + Er = e; +} +async function lf(e, t = "") { + try { + const n = `https://${e}/.well-known/nostr.json?name=${t}`, r = await Er(n, { redirect: "manual" }); + if (r.status !== 200) + throw Error("Wrong response code"); + return (await r.json()).names; + } catch { + return {}; + } +} +async function T0(e) { + const t = e.match(vi); + if (!t) + return null; + const [, n = "_", r] = t; + try { + const o = `https://${r}/.well-known/nostr.json?name=${n}`, i = await Er(o, { redirect: "manual" }); + if (i.status !== 200) + throw Error("Wrong response code"); + const s = await i.json(), c = s.names[n]; + return c ? { pubkey: c, relays: s.relays?.[c] } : null; + } catch { + return null; + } +} +async function df(e, t) { + const n = await T0(t); + return n ? n.pubkey === e : !1; +} +var uf = {}; +ye(uf, { + parse: () => hf +}); +function hf(e) { + const t = { + reply: void 0, + root: void 0, + mentions: [], + profiles: [], + quotes: [] + }; + let n, r; + for (let o = e.tags.length - 1; o >= 0; o--) { + const i = e.tags[o]; + if (i[0] === "e" && i[1]) { + const [s, c, a, h, w] = i, g = { + id: c, + relays: a ? [a] : [], + author: w + }; + if (h === "root") { + t.root = g; + continue; + } + if (h === "reply") { + t.reply = g; + continue; + } + if (h === "mention") { + t.mentions.push(g); + continue; + } + n ? r = g : n = g, t.mentions.push(g); + continue; + } + if (i[0] === "q" && i[1]) { + const [s, c, a] = i; + t.quotes.push({ + id: c, + relays: a ? [a] : [] + }); + } + if (i[0] === "p" && i[1]) { + t.profiles.push({ + pubkey: i[1], + relays: i[2] ? [i[2]] : [] + }); + continue; + } + } + return t.root || (t.root = r || n || t.reply), t.reply || (t.reply = n || t.root), [t.reply, t.root].forEach((o) => { + if (!o) + return; + let i = t.mentions.indexOf(o); + if (i !== -1 && t.mentions.splice(i, 1), o.author) { + let s = t.profiles.find((c) => c.pubkey === o.author); + s && s.relays && (o.relays || (o.relays = []), s.relays.forEach((c) => { + o.relays?.indexOf(c) === -1 && o.relays.push(c); + }), s.relays = o.relays); + } + }), t.mentions.forEach((o) => { + if (o.author) { + let i = t.profiles.find((s) => s.pubkey === o.author); + i && i.relays && (o.relays || (o.relays = []), i.relays.forEach((s) => { + o.relays.indexOf(s) === -1 && o.relays.push(s); + }), i.relays = o.relays); + } + }), t; +} +var ff = {}; +ye(ff, { + fetchRelayInformation: () => gf, + useFetchImplementation: () => pf +}); +var M0; +try { + M0 = fetch; +} catch { +} +function pf(e) { + M0 = e; +} +async function gf(e) { + return await (await fetch(e.replace("ws://", "http://").replace("wss://", "https://"), { + headers: { Accept: "application/nostr+json" } + })).json(); +} +var wf = {}; +ye(wf, { + getPow: () => yf, + minePow: () => mf +}); +function yf(e) { + let t = 0; + for (let n = 0; n < 64; n += 8) { + const r = parseInt(e.substring(n, n + 8), 16); + if (r === 0) + t += 32; + else { + t += Math.clz32(r); + break; + } + } + return t; +} +function bf(e) { + let t = 0; + for (let n = 0; n < e.length; n++) { + const r = e[n]; + if (r === 0) + t += 8; + else { + t += Math.clz32(r) - 24; + break; + } + } + return t; +} +function mf(e, t) { + let n = 0; + const r = e, o = ["nonce", n.toString(), t.toString()]; + for (r.tags.push(o); ; ) { + const i = Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3); + i !== r.created_at && (n = 0, r.created_at = i), o[1] = (++n).toString(); + const s = Ke( + De.encode(JSON.stringify([0, r.pubkey, r.created_at, r.kind, r.tags, r.content])) + ); + if (bf(s) >= t) { + r.id = pe(s); + break; + } + } + return r; +} +var vf = {}; +ye(vf, { + unwrapEvent: () => Bf, + unwrapManyEvents: () => Rf, + wrapEvent: () => F0, + wrapManyEvents: () => Mf +}); +var Cf = {}; +ye(Cf, { + createRumor: () => H0, + createSeal: () => D0, + createWrap: () => Z0, + unwrapEvent: () => ki, + unwrapManyEvents: () => W0, + wrapEvent: () => sr, + wrapManyEvents: () => Lf +}); +var fn = {}; +ye(fn, { + decrypt: () => Ai, + encrypt: () => Ei, + getConversationKey: () => Ci, + v2: () => _f +}); +var B0 = 1, R0 = 65535; +function Ci(e, t) { + const n = ni.getSharedSecret(e, ue("02" + t)).subarray(1, 33); + return ou(Ke, n, De.encode("nip44-v2")); +} +function N0(e, t) { + const n = iu(Ke, e, t, 76); + return { + chacha_key: n.subarray(0, 32), + chacha_nonce: n.subarray(32, 44), + hmac_key: n.subarray(44, 76) + }; +} +function xi(e) { + if (!Number.isSafeInteger(e) || e < 1) + throw new Error("expected positive integer"); + if (e <= 32) + return 32; + const t = 1 << Math.floor(Math.log2(e - 1)) + 1, n = t <= 256 ? 32 : t / 8; + return n * (Math.floor((e - 1) / n) + 1); +} +function xf(e) { + if (!Number.isSafeInteger(e) || e < B0 || e > R0) + throw new Error("invalid plaintext size: must be between 1 and 65535 bytes"); + const t = new Uint8Array(2); + return new DataView(t.buffer).setUint16(0, e, !1), t; +} +function Ef(e) { + const t = De.encode(e), n = t.length, r = xf(n), o = new Uint8Array(xi(n) - n); + return Be(r, t, o); +} +function Af(e) { + const t = new DataView(e.buffer).getUint16(0), n = e.subarray(2, 2 + t); + if (t < B0 || t > R0 || n.length !== t || e.length !== 2 + xi(t)) + throw new Error("invalid padding"); + return nt.decode(n); +} +function $0(e, t, n) { + if (n.length !== 32) + throw new Error("AAD associated data must be 32 bytes"); + const r = Be(n, t); + return Tn(Ke, e, r); +} +function kf(e) { + if (typeof e != "string") + throw new Error("payload must be a valid string"); + const t = e.length; + if (t < 132 || t > 87472) + throw new Error("invalid payload length: " + t); + if (e[0] === "#") + throw new Error("unknown encryption version"); + let n; + try { + n = mt.decode(e); + } catch (i) { + throw new Error("invalid base64: " + i.message); + } + const r = n.length; + if (r < 99 || r > 65603) + throw new Error("invalid data length: " + r); + const o = n[0]; + if (o !== 2) + throw new Error("unknown encryption version " + o); + return { + nonce: n.subarray(1, 33), + ciphertext: n.subarray(33, -32), + mac: n.subarray(-32) + }; +} +function Ei(e, t, n = nn(32)) { + const { chacha_key: r, chacha_nonce: o, hmac_key: i } = N0(t, n), s = Ef(e), c = o0(r, o, s), a = $0(i, c, n); + return mt.encode(Be(new Uint8Array([2]), n, c, a)); +} +function Ai(e, t) { + const { nonce: n, ciphertext: r, mac: o } = kf(e), { chacha_key: i, chacha_nonce: s, hmac_key: c } = N0(t, n), a = $0(c, r, n); + if (!Od(a, o)) + throw new Error("invalid MAC"); + const h = o0(i, s, r); + return Af(h); +} +var _f = { + utils: { + getConversationKey: Ci, + calcPaddedLen: xi + }, + encrypt: Ei, + decrypt: Ai +}, Sf = 2880 * 60, I0 = () => Math.round(Date.now() / 1e3), U0 = () => Math.round(I0() - Math.random() * Sf), O0 = (e, t) => Ci(e, t), P0 = (e, t, n) => Ei(JSON.stringify(e), O0(t, n)), bs = (e, t) => JSON.parse(Ai(e.content, O0(t, e.pubkey))); +function H0(e, t) { + const n = { + created_at: I0(), + content: "", + tags: [], + ...e, + pubkey: Yt(t) + }; + return n.id = gn(n), n; +} +function D0(e, t, n) { + return Fe( + { + kind: l0, + content: P0(e, t, n), + created_at: U0(), + tags: [] + }, + t + ); +} +function Z0(e, t) { + const n = ui(); + return Fe( + { + kind: w0, + content: P0(e, n, t), + created_at: U0(), + tags: [["p", t]] + }, + n + ); +} +function sr(e, t, n) { + const r = H0(e, t), o = D0(r, t, n); + return Z0(o, n); +} +function Lf(e, t, n) { + if (!n || n.length === 0) + throw new Error("At least one recipient is required."); + const r = Yt(t), o = [sr(e, t, r)]; + return n.forEach((i) => { + o.push(sr(e, t, i)); + }), o; +} +function ki(e, t) { + const n = bs(e, t); + return bs(n, t); +} +function W0(e, t) { + let n = []; + return e.forEach((r) => { + n.push(ki(r, t)); + }), n.sort((r, o) => r.created_at - o.created_at), n; +} +function Tf(e, t, n, r) { + const o = { + created_at: Math.ceil(Date.now() / 1e3), + kind: d0, + tags: [], + content: t + }; + return (Array.isArray(e) ? e : [e]).forEach(({ publicKey: s, relayUrl: c }) => { + o.tags.push(c ? ["p", s, c] : ["p", s]); + }), r && o.tags.push(["e", r.eventId, r.relayUrl || "", "reply"]), n && o.tags.push(["subject", n]), o; +} +function F0(e, t, n, r, o) { + const i = Tf(t, n, r, o); + return sr(i, e, t.publicKey); +} +function Mf(e, t, n, r, o) { + if (!t || t.length === 0) + throw new Error("At least one recipient is required."); + return [{ publicKey: Yt(e) }, ...t].map( + (s) => F0(e, s, n, r, o) + ); +} +var Bf = ki, Rf = W0, Nf = {}; +ye(Nf, { + finishRepostEvent: () => $f, + getRepostedEvent: () => If, + getRepostedEventPointer: () => V0 +}); +function $f(e, t, n, r) { + let o; + const i = [...e.tags ?? [], ["e", t.id, n], ["p", t.pubkey]]; + return t.kind === c0 ? o = pi : (o = wi, i.push(["k", String(t.kind)])), Fe( + { + kind: o, + tags: i, + content: e.content === "" || t.tags?.find((s) => s[0] === "-") ? "" : JSON.stringify(t), + created_at: e.created_at + }, + r + ); +} +function V0(e) { + if (![pi, wi].includes(e.kind)) + return; + let t, n; + for (let r = e.tags.length - 1; r >= 0 && (t === void 0 || n === void 0); r--) { + const o = e.tags[r]; + o.length >= 2 && (o[0] === "e" && t === void 0 ? t = o : o[0] === "p" && n === void 0 && (n = o)); + } + if (t !== void 0) + return { + id: t[1], + relays: [t[2], n?.[2]].filter((r) => typeof r == "string"), + author: n?.[1] + }; +} +function If(e, { skipVerification: t } = {}) { + const n = V0(e); + if (n === void 0 || e.content === "") + return; + let r; + try { + r = JSON.parse(e.content); + } catch { + return; + } + if (r.id === n.id && !(!t && !br(r))) + return r; +} +var Uf = {}; +ye(Uf, { + NOSTR_URI_REGEX: () => _i, + parse: () => Pf, + test: () => Of +}); +var _i = new RegExp(`nostr:(${_0.source})`); +function Of(e) { + return typeof e == "string" && new RegExp(`^${_i.source}$`).test(e); +} +function Pf(e) { + const t = e.match(new RegExp(`^${_i.source}$`)); + if (!t) + throw new Error(`Invalid Nostr URI: ${e}`); + return { + uri: t[0], + value: t[1], + decoded: vr(t[1]) + }; +} +var Hf = {}; +ye(Hf, { + finishReactionEvent: () => Df, + getReactedEventPointer: () => Zf +}); +function Df(e, t, n) { + const r = t.tags.filter((o) => o.length >= 2 && (o[0] === "e" || o[0] === "p")); + return Fe( + { + ...e, + kind: gi, + tags: [...e.tags ?? [], ...r, ["e", t.id], ["p", t.pubkey]], + content: e.content ?? "+" + }, + n + ); +} +function Zf(e) { + if (e.kind !== gi) + return; + let t, n; + for (let r = e.tags.length - 1; r >= 0 && (t === void 0 || n === void 0); r--) { + const o = e.tags[r]; + o.length >= 2 && (o[0] === "e" && t === void 0 ? t = o : o[0] === "p" && n === void 0 && (n = o)); + } + if (!(t === void 0 || n === void 0)) + return { + id: t[1], + relays: [t[2], n[2]].filter((r) => r !== void 0), + author: n[1] + }; +} +var Wf = {}; +ye(Wf, { + parse: () => Vf +}); +var Zr = /\W/m, ms = /[^\w\/] |[^\w\/]$|$|,| /m, Ff = 42; +function* Vf(e) { + let t = []; + if (typeof e != "string") { + for (let i = 0; i < e.tags.length; i++) { + const s = e.tags[i]; + s[0] === "emoji" && s.length >= 3 && t.push({ type: "emoji", shortcode: s[1], url: s[2] }); + } + e = e.content; + } + const n = e.length; + let r = 0, o = 0; + e: + for (; o < n; ) { + const i = e.indexOf(":", o), s = e.indexOf("#", o); + if (i === -1 && s === -1) + break e; + if (i === -1 || s >= 0 && s < i) { + if (s === 0 || e[s - 1].match(Zr)) { + const c = e.slice(s + 1, s + Ff).match(Zr), a = c ? s + 1 + c.index : n; + yield { type: "text", text: e.slice(r, s) }, yield { type: "hashtag", value: e.slice(s + 1, a) }, o = a, r = o; + continue e; + } + o = s + 1; + continue e; + } + if (e.slice(i - 5, i) === "nostr") { + const c = e.slice(i + 60).match(Zr), a = c ? i + 60 + c.index : n; + try { + let h, { data: w, type: g } = vr(e.slice(i + 1, a)); + switch (g) { + case "npub": + h = { pubkey: w }; + break; + case "note": + h = { id: w }; + break; + case "nsec": + o = a + 1; + continue; + default: + h = w; + } + r !== i - 5 && (yield { type: "text", text: e.slice(r, i - 5) }), yield { type: "reference", pointer: h }, o = a, r = o; + continue e; + } catch { + o = i + 1; + continue e; + } + } else if (e.slice(i - 5, i) === "https" || e.slice(i - 4, i) === "http") { + const c = e.slice(i + 4).match(ms), a = c ? i + 4 + c.index : n, h = e[i - 1] === "s" ? 5 : 4; + try { + let w = new URL(e.slice(i - h, a)); + if (w.hostname.indexOf(".") === -1) + throw new Error("invalid url"); + if (r !== i - h && (yield { type: "text", text: e.slice(r, i - h) }), /\.(png|jpe?g|gif|webp|heic|svg)$/i.test(w.pathname)) { + yield { type: "image", url: w.toString() }, o = a, r = o; + continue e; + } + if (/\.(mp4|avi|webm|mkv|mov)$/i.test(w.pathname)) { + yield { type: "video", url: w.toString() }, o = a, r = o; + continue e; + } + if (/\.(mp3|aac|ogg|opus|wav|flac)$/i.test(w.pathname)) { + yield { type: "audio", url: w.toString() }, o = a, r = o; + continue e; + } + yield { type: "url", url: w.toString() }, o = a, r = o; + continue e; + } catch { + o = a + 1; + continue e; + } + } else if (e.slice(i - 3, i) === "wss" || e.slice(i - 2, i) === "ws") { + const c = e.slice(i + 4).match(ms), a = c ? i + 4 + c.index : n, h = e[i - 1] === "s" ? 3 : 2; + try { + let w = new URL(e.slice(i - h, a)); + if (w.hostname.indexOf(".") === -1) + throw new Error("invalid ws url"); + r !== i - h && (yield { type: "text", text: e.slice(r, i - h) }), yield { type: "relay", url: w.toString() }, o = a, r = o; + continue e; + } catch { + o = a + 1; + continue e; + } + } else { + for (let c = 0; c < t.length; c++) { + const a = t[c]; + if (e[i + a.shortcode.length + 1] === ":" && e.slice(i + 1, i + a.shortcode.length + 1) === a.shortcode) { + r !== i && (yield { type: "text", text: e.slice(r, i) }), yield a, o = i + a.shortcode.length + 2, r = o; + continue e; + } + } + o = i + 1; + continue e; + } + } + r !== n && (yield { type: "text", text: e.slice(r) }); +} +var Gf = {}; +ye(Gf, { + channelCreateEvent: () => jf, + channelHideMessageEvent: () => Kf, + channelMessageEvent: () => qf, + channelMetadataEvent: () => zf, + channelMuteUserEvent: () => Qf +}); +var jf = (e, t) => { + let n; + if (typeof e.content == "object") + n = JSON.stringify(e.content); + else if (typeof e.content == "string") + n = e.content; + else + return; + return Fe( + { + kind: u0, + tags: [...e.tags ?? []], + content: n, + created_at: e.created_at + }, + t + ); +}, zf = (e, t) => { + let n; + if (typeof e.content == "object") + n = JSON.stringify(e.content); + else if (typeof e.content == "string") + n = e.content; + else + return; + return Fe( + { + kind: h0, + tags: [["e", e.channel_create_event_id], ...e.tags ?? []], + content: n, + created_at: e.created_at + }, + t + ); +}, qf = (e, t) => { + const n = [["e", e.channel_create_event_id, e.relay_url, "root"]]; + return e.reply_to_channel_message_event_id && n.push(["e", e.reply_to_channel_message_event_id, e.relay_url, "reply"]), Fe( + { + kind: f0, + tags: [...n, ...e.tags ?? []], + content: e.content, + created_at: e.created_at + }, + t + ); +}, Kf = (e, t) => { + let n; + if (typeof e.content == "object") + n = JSON.stringify(e.content); + else if (typeof e.content == "string") + n = e.content; + else + return; + return Fe( + { + kind: p0, + tags: [["e", e.channel_message_event_id], ...e.tags ?? []], + content: n, + created_at: e.created_at + }, + t + ); +}, Qf = (e, t) => { + let n; + if (typeof e.content == "object") + n = JSON.stringify(e.content); + else if (typeof e.content == "string") + n = e.content; + else + return; + return Fe( + { + kind: g0, + tags: [["p", e.pubkey_to_mute], ...e.tags ?? []], + content: n, + created_at: e.created_at + }, + t + ); +}, Jf = {}; +ye(Jf, { + EMOJI_SHORTCODE_REGEX: () => G0, + matchAll: () => Yf, + regex: () => Si, + replaceAll: () => Xf +}); +var G0 = /:(\w+):/, Si = () => new RegExp(`\\B${G0.source}\\B`, "g"); +function* Yf(e) { + const t = e.matchAll(Si()); + for (const n of t) + try { + const [r, o] = n; + yield { + shortcode: r, + name: o, + start: n.index, + end: n.index + r.length + }; + } catch { + } +} +function Xf(e, t) { + return e.replaceAll(Si(), (n, r) => t({ + shortcode: n, + name: r + })); +} +var e4 = {}; +ye(e4, { + useFetchImplementation: () => t4, + validateGithub: () => n4 +}); +var Li; +try { + Li = fetch; +} catch { +} +function t4(e) { + Li = e; +} +async function n4(e, t, n) { + try { + return await (await Li(`https://gist.github.com/${t}/${n}/raw`)).text() === `Verifying that I control the following Nostr public key: ${e}`; + } catch { + return !1; + } +} +var r4 = {}; +ye(r4, { + makeNwcRequestEvent: () => i4, + parseConnectionString: () => o4 +}); +function o4(e) { + const { host: t, pathname: n, searchParams: r } = new URL(e), o = n || t, i = r.get("relay"), s = r.get("secret"); + if (!o || !i || !s) + throw new Error("invalid connection string"); + return { pubkey: o, relay: i, secret: s }; +} +async function i4(e, t, n) { + const o = S0(t, e, JSON.stringify({ + method: "pay_invoice", + params: { + invoice: n + } + })), i = { + kind: b0, + created_at: Math.round(Date.now() / 1e3), + content: o, + tags: [["p", e]] + }; + return Fe(i, t); +} +var s4 = {}; +ye(s4, { + normalizeIdentifier: () => a4 +}); +function a4(e) { + return e = e.trim().toLowerCase(), e = e.normalize("NFKC"), Array.from(e).map((t) => /\p{Letter}/u.test(t) || /\p{Number}/u.test(t) ? t : "-").join(""); +} +var c4 = {}; +ye(c4, { + getSatoshisAmountFromBolt11: () => p4, + getZapEndpoint: () => d4, + makeZapReceipt: () => f4, + makeZapRequest: () => u4, + useFetchImplementation: () => l4, + validateZapRequest: () => h4 +}); +var Ti; +try { + Ti = fetch; +} catch { +} +function l4(e) { + Ti = e; +} +async function d4(e) { + try { + let t = "", { lud06: n, lud16: r } = JSON.parse(e.content); + if (r) { + let [s, c] = r.split("@"); + t = new URL(`/.well-known/lnurlp/${s}`, `https://${c}`).toString(); + } else if (n) { + let { words: s } = Qt.decode(n, 1e3), c = Qt.fromWords(s); + t = nt.decode(c); + } else + return null; + let i = await (await Ti(t)).json(); + if (i.allowsNostr && i.nostrPubkey) + return i.callback; + } catch { + } + return null; +} +function u4(e) { + let t = { + kind: 9734, + created_at: Math.round(Date.now() / 1e3), + content: e.comment || "", + tags: [ + ["p", "pubkey" in e ? e.pubkey : e.event.pubkey], + ["amount", e.amount.toString()], + ["relays", ...e.relays] + ] + }; + if ("event" in e) { + if (t.tags.push(["e", e.event.id]), hi(e.event.kind)) { + const n = ["a", `${e.event.kind}:${e.event.pubkey}:`]; + t.tags.push(n); + } else if (fi(e.event.kind)) { + let n = e.event.tags.find(([o, i]) => o === "d" && i); + if (!n) + throw new Error("d tag not found or is empty"); + const r = ["a", `${e.event.kind}:${e.event.pubkey}:${n[1]}`]; + t.tags.push(r); + } + t.tags.push(["k", e.event.kind.toString()]); + } + return t; +} +function h4(e) { + let t; + try { + t = JSON.parse(e); + } catch { + return "Invalid zap request JSON."; + } + if (!li(t)) + return "Zap request is not a valid Nostr event."; + if (!br(t)) + return "Invalid signature on zap request."; + let n = t.tags.find(([i, s]) => i === "p" && s); + if (!n) + return "Zap request doesn't have a 'p' tag."; + if (!n[1].match(/^[a-f0-9]{64}$/)) + return "Zap request 'p' tag is not valid hex."; + let r = t.tags.find(([i, s]) => i === "e" && s); + return r && !r[1].match(/^[a-f0-9]{64}$/) ? "Zap request 'e' tag is not valid hex." : t.tags.find(([i, s]) => i === "relays" && s) ? null : "Zap request doesn't have a 'relays' tag."; +} +function f4({ + zapRequest: e, + preimage: t, + bolt11: n, + paidAt: r +}) { + let o = JSON.parse(e), i = o.tags.filter(([c]) => c === "e" || c === "p" || c === "a"), s = { + kind: 9735, + created_at: Math.round(r.getTime() / 1e3), + content: "", + tags: [...i, ["P", o.pubkey], ["bolt11", n], ["description", e]] + }; + return t && s.tags.push(["preimage", t]), s; +} +function p4(e) { + if (e.length < 50) + return 0; + e = e.substring(0, 50); + const t = e.lastIndexOf("1"); + if (t === -1) + return 0; + const n = e.substring(0, t); + if (!n.startsWith("lnbc")) + return 0; + const r = n.substring(4); + if (r.length < 1) + return 0; + const o = r[r.length - 1], i = o.charCodeAt(0) - 48, s = i >= 0 && i <= 9; + let c = r.length - 1; + if (s && c++, c < 1) + return 0; + const a = parseInt(r.substring(0, c)); + switch (o) { + case "m": + return a * 1e5; + case "u": + return a * 100; + case "n": + return a / 10; + case "p": + return a / 1e4; + default: + return a * 1e8; + } +} +var g4 = {}; +ye(g4, { + Negentropy: () => z0, + NegentropyStorageVector: () => b4, + NegentropySync: () => m4 +}); +var Wr = 97, zt = 32, j0 = 16, xt = { + Skip: 0, + Fingerprint: 1, + IdList: 2 +}, et = class { + _raw; + length; + constructor(e) { + typeof e == "number" ? (this._raw = new Uint8Array(e), this.length = 0) : e instanceof Uint8Array ? (this._raw = new Uint8Array(e), this.length = e.length) : (this._raw = new Uint8Array(512), this.length = 0); + } + unwrap() { + return this._raw.subarray(0, this.length); + } + get capacity() { + return this._raw.byteLength; + } + extend(e) { + if (e instanceof et && (e = e.unwrap()), typeof e.length != "number") + throw Error("bad length"); + const t = e.length + this.length; + if (this.capacity < t) { + const n = this._raw, r = Math.max(this.capacity * 2, t); + this._raw = new Uint8Array(r), this._raw.set(n); + } + this._raw.set(e, this.length), this.length += e.length; + } + shift() { + const e = this._raw[0]; + return this._raw = this._raw.subarray(1), this.length--, e; + } + shiftN(e = 1) { + const t = this._raw.subarray(0, e); + return this._raw = this._raw.subarray(e), this.length -= e, t; + } +}; +function In(e) { + let t = 0; + for (; ; ) { + if (e.length === 0) + throw Error("parse ends prematurely"); + let n = e.shift(); + if (t = t << 7 | n & 127, (n & 128) === 0) + break; + } + return t; +} +function Xe(e) { + if (e === 0) + return new et(new Uint8Array([0])); + let t = []; + for (; e !== 0; ) + t.push(e & 127), e >>>= 7; + t.reverse(); + for (let n = 0; n < t.length - 1; n++) + t[n] |= 128; + return new et(new Uint8Array(t)); +} +function w4(e) { + return qn(e, 1)[0]; +} +function qn(e, t) { + if (e.length < t) + throw Error("parse ends prematurely"); + return e.shiftN(t); +} +var y4 = class { + buf; + constructor() { + this.setToZero(); + } + setToZero() { + this.buf = new Uint8Array(zt); + } + add(e) { + let t = 0, n = 0, r = new DataView(this.buf.buffer), o = new DataView(e.buffer); + for (let i = 0; i < 8; i++) { + let s = i * 4, c = r.getUint32(s, !0), a = o.getUint32(s, !0), h = c; + h += t, h += a, h > 4294967295 && (n = 1), r.setUint32(s, h & 4294967295, !0), t = n, n = 0; + } + } + negate() { + let e = new DataView(this.buf.buffer); + for (let n = 0; n < 8; n++) { + let r = n * 4; + e.setUint32(r, ~e.getUint32(r, !0)); + } + let t = new Uint8Array(zt); + t[0] = 1, this.add(t); + } + getFingerprint(e) { + let t = new et(); + return t.extend(this.buf), t.extend(Xe(e)), Ke(t.unwrap()).subarray(0, j0); + } +}, b4 = class { + items; + sealed; + constructor() { + this.items = [], this.sealed = !1; + } + insert(e, t) { + if (this.sealed) + throw Error("already sealed"); + const n = ue(t); + if (n.byteLength !== zt) + throw Error("bad id size for added item"); + this.items.push({ timestamp: e, id: n }); + } + seal() { + if (this.sealed) + throw Error("already sealed"); + this.sealed = !0, this.items.sort(Fr); + for (let e = 1; e < this.items.length; e++) + if (Fr(this.items[e - 1], this.items[e]) === 0) + throw Error("duplicate item inserted"); + } + unseal() { + this.sealed = !1; + } + size() { + return this._checkSealed(), this.items.length; + } + getItem(e) { + if (this._checkSealed(), e >= this.items.length) + throw Error("out of range"); + return this.items[e]; + } + iterate(e, t, n) { + this._checkSealed(), this._checkBounds(e, t); + for (let r = e; r < t && n(this.items[r], r); ++r) + ; + } + findLowerBound(e, t, n) { + return this._checkSealed(), this._checkBounds(e, t), this._binarySearch(this.items, e, t, (r) => Fr(r, n) < 0); + } + fingerprint(e, t) { + let n = new y4(); + return n.setToZero(), this.iterate(e, t, (r) => (n.add(r.id), !0)), n.getFingerprint(t - e); + } + _checkSealed() { + if (!this.sealed) + throw Error("not sealed"); + } + _checkBounds(e, t) { + if (e > t || t > this.items.length) + throw Error("bad range"); + } + _binarySearch(e, t, n, r) { + let o = n - t; + for (; o > 0; ) { + let i = t, s = Math.floor(o / 2); + i += s, r(e[i]) ? (t = ++i, o -= s + 1) : o = s; + } + return t; + } +}, z0 = class { + storage; + frameSizeLimit; + lastTimestampIn; + lastTimestampOut; + constructor(e, t = 6e4) { + if (t < 4096) + throw Error("frameSizeLimit too small"); + this.storage = e, this.frameSizeLimit = t, this.lastTimestampIn = 0, this.lastTimestampOut = 0; + } + _bound(e, t) { + return { timestamp: e, id: t || new Uint8Array(0) }; + } + initiate() { + let e = new et(); + return e.extend(new Uint8Array([Wr])), this.splitRange(0, this.storage.size(), this._bound(Number.MAX_VALUE), e), pe(e.unwrap()); + } + reconcile(e, t, n) { + const r = new et(ue(e)); + this.lastTimestampIn = this.lastTimestampOut = 0; + let o = new et(); + o.extend(new Uint8Array([Wr])); + let i = w4(r); + if (i < 96 || i > 111) + throw Error("invalid negentropy protocol version byte"); + if (i !== Wr) + throw Error("unsupported negentropy protocol version requested: " + (i - 96)); + let s = this.storage.size(), c = this._bound(0), a = 0, h = !1; + for (; r.length !== 0; ) { + let w = new et(), g = () => { + h && (h = !1, w.extend(this.encodeBound(c)), w.extend(Xe(xt.Skip))); + }, v = this.decodeBound(r), b = In(r), C = a, L = this.storage.findLowerBound(a, s, v); + if (b === xt.Skip) + h = !0; + else if (b === xt.Fingerprint) { + let M = qn(r, j0), I = this.storage.fingerprint(C, L); + q0(M, I) !== 0 ? (g(), this.splitRange(C, L, v, w)) : h = !0; + } else if (b === xt.IdList) { + let M = In(r), I = {}; + for (let U = 0; U < M; U++) { + let q = qn(r, zt); + I[pe(q)] = q; + } + if (h = !0, this.storage.iterate(C, L, (U) => { + let q = U.id; + const Q = pe(q); + return I[Q] ? delete I[pe(q)] : t?.(Q), !0; + }), n) + for (let U of Object.values(I)) + n(pe(U)); + } else + throw Error("unexpected mode"); + if (this.exceededFrameSizeLimit(o.length + w.length)) { + let M = this.storage.fingerprint(L, s); + o.extend(this.encodeBound(this._bound(Number.MAX_VALUE))), o.extend(Xe(xt.Fingerprint)), o.extend(M); + break; + } else + o.extend(w); + a = L, c = v; + } + return o.length === 1 ? null : pe(o.unwrap()); + } + splitRange(e, t, n, r) { + let o = t - e, i = 16; + if (o < i * 2) + r.extend(this.encodeBound(n)), r.extend(Xe(xt.IdList)), r.extend(Xe(o)), this.storage.iterate(e, t, (s) => (r.extend(s.id), !0)); + else { + let s = Math.floor(o / i), c = o % i, a = e; + for (let h = 0; h < i; h++) { + let w = s + (h < c ? 1 : 0), g = this.storage.fingerprint(a, a + w); + a += w; + let v; + if (a === t) + v = n; + else { + let b, C; + this.storage.iterate(a - 1, a + 1, (L, M) => (M === a - 1 ? b = L : C = L, !0)), v = this.getMinimalBound(b, C); + } + r.extend(this.encodeBound(v)), r.extend(Xe(xt.Fingerprint)), r.extend(g); + } + } + } + exceededFrameSizeLimit(e) { + return e > this.frameSizeLimit - 200; + } + decodeTimestampIn(e) { + let t = In(e); + return t = t === 0 ? Number.MAX_VALUE : t - 1, this.lastTimestampIn === Number.MAX_VALUE || t === Number.MAX_VALUE ? (this.lastTimestampIn = Number.MAX_VALUE, Number.MAX_VALUE) : (t += this.lastTimestampIn, this.lastTimestampIn = t, t); + } + decodeBound(e) { + let t = this.decodeTimestampIn(e), n = In(e); + if (n > zt) + throw Error("bound key too long"); + let r = qn(e, n); + return { timestamp: t, id: r }; + } + encodeTimestampOut(e) { + if (e === Number.MAX_VALUE) + return this.lastTimestampOut = Number.MAX_VALUE, Xe(0); + let t = e; + return e -= this.lastTimestampOut, this.lastTimestampOut = t, Xe(e + 1); + } + encodeBound(e) { + let t = new et(); + return t.extend(this.encodeTimestampOut(e.timestamp)), t.extend(Xe(e.id.length)), t.extend(e.id), t; + } + getMinimalBound(e, t) { + if (t.timestamp !== e.timestamp) + return this._bound(t.timestamp); + { + let n = 0, r = t.id, o = e.id; + for (let i = 0; i < zt && r[i] === o[i]; i++) + n++; + return this._bound(t.timestamp, t.id.subarray(0, n + 1)); + } + } +}; +function q0(e, t) { + for (let n = 0; n < e.byteLength; n++) { + if (e[n] < t[n]) + return -1; + if (e[n] > t[n]) + return 1; + } + return e.byteLength > t.byteLength ? 1 : e.byteLength < t.byteLength ? -1 : 0; +} +function Fr(e, t) { + return e.timestamp === t.timestamp ? q0(e.id, t.id) : e.timestamp - t.timestamp; +} +var m4 = class { + relay; + storage; + neg; + filter; + subscription; + onhave; + onneed; + constructor(e, t, n, r = {}) { + this.relay = e, this.storage = t, this.neg = new z0(t), this.onhave = r.onhave, this.onneed = r.onneed, this.filter = n, this.subscription = this.relay.prepareSubscription([{}], { label: r.label || "negentropy" }), this.subscription.oncustom = (o) => { + switch (o[0]) { + case "NEG-MSG": { + o.length < 3 && console.warn(`got invalid NEG-MSG from ${this.relay.url}: ${o}`); + try { + const i = this.neg.reconcile(o[2], this.onhave, this.onneed); + i ? this.relay.send(`["NEG-MSG", "${this.subscription.id}", "${i}"]`) : (this.close(), r.onclose?.()); + } catch (i) { + console.error("negentropy reconcile error:", i), r?.onclose?.(`reconcile error: ${i}`); + } + break; + } + case "NEG-CLOSE": { + const i = o[2]; + console.warn("negentropy error:", i), r.onclose?.(i); + break; + } + case "NEG-ERR": + r.onclose?.(); + } + }; + } + async start() { + const e = this.neg.initiate(); + this.relay.send(`["NEG-OPEN","${this.subscription.id}",${JSON.stringify(this.filter)},"${e}"]`); + } + close() { + this.relay.send(`["NEG-CLOSE","${this.subscription.id}"]`), this.subscription.close(); + } +}, v4 = {}; +ye(v4, { + getToken: () => C4, + hashPayload: () => Mi, + unpackEventFromToken: () => Q0, + validateEvent: () => n2, + validateEventKind: () => Y0, + validateEventMethodTag: () => e2, + validateEventPayloadTag: () => t2, + validateEventTimestamp: () => J0, + validateEventUrlTag: () => X0, + validateToken: () => x4 +}); +var K0 = "Nostr "; +async function C4(e, t, n, r = !1, o) { + const i = { + kind: yi, + tags: [ + ["u", e], + ["method", t] + ], + created_at: Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3), + content: "" + }; + o && i.tags.push(["payload", Mi(o)]); + const s = await n(i); + return (r ? K0 : "") + mt.encode(De.encode(JSON.stringify(s))); +} +async function x4(e, t, n) { + const r = await Q0(e).catch((i) => { + throw i; + }); + return await n2(r, t, n).catch((i) => { + throw i; + }); +} +async function Q0(e) { + if (!e) + throw new Error("Missing token"); + e = e.replace(K0, ""); + const t = nt.decode(mt.decode(e)); + if (!t || t.length === 0 || !t.startsWith("{")) + throw new Error("Invalid token"); + return JSON.parse(t); +} +function J0(e) { + return e.created_at ? Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3) - e.created_at < 60 : !1; +} +function Y0(e) { + return e.kind === yi; +} +function X0(e, t) { + const n = e.tags.find((r) => r[0] === "u"); + return n ? n.length > 0 && n[1] === t : !1; +} +function e2(e, t) { + const n = e.tags.find((r) => r[0] === "method"); + return n ? n.length > 0 && n[1].toLowerCase() === t.toLowerCase() : !1; +} +function Mi(e) { + const t = Ke(De.encode(JSON.stringify(e))); + return pe(t); +} +function t2(e, t) { + const n = e.tags.find((o) => o[0] === "payload"); + if (!n) + return !1; + const r = Mi(t); + return n.length > 0 && n[1] === r; +} +async function n2(e, t, n, r) { + if (!br(e)) + throw new Error("Invalid nostr event, signature invalid"); + if (!Y0(e)) + throw new Error("Invalid nostr event, kind invalid"); + if (!J0(e)) + throw new Error("Invalid nostr event, created_at timestamp invalid"); + if (!X0(e, t)) + throw new Error("Invalid nostr event, url tag invalid"); + if (!e2(e, n)) + throw new Error("Invalid nostr event, method tag invalid"); + if (r && typeof r == "object" && Object.keys(r).length > 0 && !t2(e, r)) + throw new Error("Invalid nostr event, payload tag does not match request body hash"); + return !0; +} +class Ct extends Error { + constructor(t, n) { + super(t), this.code = n; + } +} +class r2 extends Ct { +} +class E4 extends Ct { +} +class o2 extends Ct { +} +class vs extends o2 { +} +class Cs extends o2 { +} +class xs extends Ct { +} +class Es extends Ct { +} +class Vr extends Ct { +} +class A4 extends Ct { +} +class k4 extends Ct { +} +function Un(e) { + try { + e.indexOf("://") === -1 && (e = "wss://" + e); + const t = new URL(e); + return t.protocol === "http:" ? t.protocol = "ws:" : t.protocol === "https:" && (t.protocol = "wss:"), t.pathname = t.pathname.replace(/\/+/g, "/"), t.pathname.endsWith("/") && (t.pathname = t.pathname.slice(0, -1)), (t.port === "80" && t.protocol === "ws:" || t.port === "443" && t.protocol === "wss:") && (t.port = ""), t.searchParams.sort(), t.hash = "", t.toString(); + } catch { + throw new Error(`Invalid URL: ${e}`); + } +} +const _4 = 1e3, S4 = 300 * 1e3, L4 = 1e3; +class i2 { + constructor() { + this.relays = /* @__PURE__ */ new Map(), this.enablePing = !1, this.maxWaitForConnection = 3e3; + } + async ensureRelay(t, n) { + t = Un(t); + let r = this.relays.get(t); + r || (r = new k0(t, { + enablePing: this.enablePing, + enableReconnect: !1 + }), r.onclose = () => { + this.relays.delete(t); + }, this.relays.set(t, r)); + try { + await r.connect({ + timeout: n?.connectionTimeout, + abort: n?.abort + }); + } catch (o) { + throw this.relays.delete(t), o; + } + return r; + } + close(t) { + t.map(Un).forEach((n) => { + this.relays.get(n)?.close(), this.relays.delete(n); + }); + } + subscribe(t, n, r) { + const o = [], i = /* @__PURE__ */ new Set(); + for (const b of t) { + const C = Un(b); + i.has(C) || (i.add(C), o.push(C)); + } + let s = !1; + const c = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set(), w = (b) => { + if (h.has(b)) + return !0; + if (h.add(b), h.size > L4) { + const C = h.values().next().value; + C !== void 0 && h.delete(C); + } + return !1; + }, g = (b) => { + if (s) + return Promise.resolve(); + const C = Math.min(_4 * 2 ** b, S4); + return new Promise((L) => { + const M = setTimeout(() => { + a.delete(I), L(); + }, C), I = () => { + clearTimeout(M), a.delete(I), L(); + }; + a.add(I); + }); + }, v = async (b) => { + let C = 0; + for (; !s; ) { + let L; + try { + L = await this.ensureRelay(b, { + connectionTimeout: this.maxWaitForConnection, + abort: r.abort + }); + } catch (I) { + if (s) + return; + const U = I?.message || String(I); + r.ondisconnect?.(b, U), await g(C++); + continue; + } + if (s) + return; + r.onconnect?.(b), C = 0; + const M = await new Promise((I) => { + const U = L.subscribe([n], { + eoseTimeout: 1, + // 1ms (if 0 is provided, uses default of 4400ms) + onevent: r.onevent, + onclose: I, + abort: r.abort, + alreadyHaveEvent: w + }); + c.set(b, U); + }); + if (c.delete(b), s) + return; + r.ondisconnect?.(b, M), await g(C++); + } + }; + return o.forEach((b) => { + v(b); + }), { + close(b) { + s || (s = !0, a.forEach((C) => C()), a.clear(), c.forEach((C) => C.close(b)), c.clear()); + } + }; + } + publish(t, n, r) { + return t.map(Un).map(async (o, i, s) => { + if (s.indexOf(o) !== i) + return Promise.reject("duplicate url"); + let c; + try { + c = await this.ensureRelay(o, { + connectionTimeout: this.maxWaitForConnection, + abort: r?.abort + }); + } catch (a) { + return "connection failure: " + String(a); + } + return c.publish(n); + }); + } + listConnectionStatus() { + const t = /* @__PURE__ */ new Map(); + return this.relays.forEach((n, r) => t.set(r, n.connected)), t; + } + destroy() { + this.relays.forEach((t) => t.close()), this.relays = /* @__PURE__ */ new Map(); + } +} +const As = /^[0-9a-f]{64}$/; +class vt { + static parseWalletConnectUrl(t, n = !1) { + t = t.replace("nostrwalletconnect://", "http://").replace("nostr+walletconnect://", "http://").replace("nostrwalletconnect:", "http://").replace("nostr+walletconnect:", "http://"); + const r = new URL(t), o = r.searchParams.getAll("relay"), i = { + walletPubkey: r.host, + relayUrls: o + }, s = r.searchParams.get("secret"); + s && (i.secret = s); + const c = r.searchParams.get("lud16"); + if (c && (i.lud16 = c), !i.walletPubkey) + throw new Error("Invalid NWC URL: missing wallet pubkey"); + if (!As.test(i.walletPubkey)) + throw new Error("Invalid NWC URL: invalid wallet pubkey"); + if (!i.relayUrls?.length) + throw new Error("Invalid NWC URL: no relay URLs provided"); + for (const a of i.relayUrls) + try { + new URL(a); + } catch { + throw new Error(`Invalid relay URL: ${a}`); + } + if (n && !i.secret) + throw new Error("Invalid NWC URL: missing secret parameter"); + if (i.secret && !As.test(i.secret)) + throw new Error("Invalid NWC URL: invalid secret"); + return i; + } + constructor(t) { + t && t.nostrWalletConnectUrl && (t = { + ...vt.parseWalletConnectUrl(t.nostrWalletConnectUrl, t.requireSecret), + ...t + }), this.options = { + ...t || {} + }, this.relayUrls = this.options.relayUrls, this.logger = t?.logger || wl, this.pool = new i2(), this.options.secret && (this.secret = this.options.secret.toLowerCase().startsWith("nsec") ? Mo.decode(this.options.secret).data : this.options.secret), this.lud16 = this.options.lud16, this.walletPubkey = this.options.walletPubkey.toLowerCase().startsWith("npub") ? Mo.decode(this.options.walletPubkey).data : this.options.walletPubkey; + } + get nostrWalletConnectUrl() { + return this.getNostrWalletConnectUrl(); + } + getNostrWalletConnectUrl(t = !0) { + let n = `nostr+walletconnect://${this.walletPubkey}?relay=${this.relayUrls.join("&relay=")}&pubkey=${this.publicKey}`; + return t && (n = `${n}&secret=${this.secret}`), this.lud16 && (n = `${n}&lud16=${this.lud16}`), n; + } + get connected() { + const t = Array.from(this.pool.listConnectionStatus().values()); + return !!t.length && t.includes(!0); + } + get publicKey() { + if (!this.secret) + throw new Error("Missing secret key"); + return Yt(ue(this.secret)); + } + get encryptionType() { + if (!this._encryptionType) + throw new Error("Missing encryption or version"); + return this._encryptionType; + } + getPublicKey() { + return Promise.resolve(this.publicKey); + } + signEvent(t) { + if (!this.secret) + throw new Error("Missing secret key"); + return Promise.resolve(Fe(t, ue(this.secret))); + } + getEventHash(t) { + return gn(t); + } + close() { + return this.pool.close(this.relayUrls); + } + async encrypt(t, n) { + if (!this.secret) + throw new Error("Missing secret"); + let r; + if (this.encryptionType === "nip04") + r = await Bo.encrypt(this.secret, t, n); + else { + const o = fn.getConversationKey(ue(this.secret), t); + r = fn.encrypt(n, o); + } + return r; + } + async decrypt(t, n) { + if (!this.secret) + throw new Error("Missing secret"); + let r; + if (this.encryptionType === "nip04") + r = await Bo.decrypt(this.secret, t, n); + else { + const o = fn.getConversationKey(ue(this.secret), t); + r = fn.decrypt(n, o); + } + return r; + } + static getAuthorizationUrl(t, n = {}, r) { + if (t.indexOf("/#/") > -1) + throw new Error("hash router paths not supported"); + const o = new URL(t); + return n.name && o.searchParams.set("name", n.name), o.searchParams.set("pubkey", r), n.returnTo && o.searchParams.set("return_to", n.returnTo), n.budgetRenewal && o.searchParams.set("budget_renewal", n.budgetRenewal), n.expiresAt && o.searchParams.set("expires_at", Math.floor(n.expiresAt.getTime() / 1e3).toString()), n.maxAmount && o.searchParams.set("max_amount", n.maxAmount.toString()), n.requestMethods && o.searchParams.set("request_methods", n.requestMethods.join(" ")), n.notificationTypes && o.searchParams.set("notification_types", n.notificationTypes.join(" ")), n.isolated && o.searchParams.set("isolated", "true"), n.metadata && o.searchParams.set("metadata", JSON.stringify(n.metadata)), o; + } + /** + * create a new client-initiated NWC connection via HTTP deeplink + * + * @param authorizationBasePath the deeplink path e.g. https://my.albyhub.com/apps/new + * @param options configure the created app (e.g. the name, budget, expiration) + * @param secret optionally pass a secret, otherwise one will be generated. + */ + static fromAuthorizationUrl(t, n = {}, r) { + r = r || pe(ui()), n.name || (n.name = document.location.host); + const o = this.getAuthorizationUrl(t, n, Yt(ue(r))), i = 600, s = 400, c = window.outerHeight / 2 + window.screenY - i / 2, a = window.outerWidth / 2 + window.screenX - s / 2; + return new Promise((h, w) => { + const g = window.open(o.toString(), `${document.title} - Wallet Connect`, `height=${i},width=${s},top=${c},left=${a}`); + if (!g) { + w(new Error("failed to execute window.open")); + return; + } + const v = () => { + g && g.closed && (clearInterval(C), window.removeEventListener("message", b), w(new Error("Popup closed"))); + }, b = (L) => { + const M = L.data; + if (M && M.type === "nwc:success" && L.origin === `${o.protocol}//${o.host}`) { + if (!M.relayUrls && M.relayUrl && (M.relayUrls = [M.relayUrl]), !M.relayUrls) { + w(new Error("no relayUrls or relayUrl in response")); + return; + } + if (!M.walletPubkey) { + w(new Error("no walletPubkey in response")); + return; + } + h(new vt({ + relayUrls: M.relayUrls, + walletPubkey: M.walletPubkey, + secret: r, + lud16: M.lud16 + })), clearInterval(C), window.removeEventListener("message", b), g && g.close(); + } + }, C = setInterval(v, 500); + window.addEventListener("message", b); + }); + } + async getWalletServiceInfo() { + await this._checkConnected(); + const t = await new Promise((c, a) => { + let h = !1; + const w = setTimeout(() => { + h || (h = !0, g.close(), a(new Error("no info event (kind 13194) returned from relay"))); + }, 1e4), g = this.pool.subscribe(this.relayUrls, { + kinds: [13194], + limit: 1, + authors: [this.walletPubkey] + }, { + onevent: (v) => { + h || (h = !0, clearTimeout(w), g.close(), c(v)); + } + }); + }), n = t.content, r = t.tags.find((c) => c[0] === "notifications"), o = t.tags.find((c) => c[0] === "v"), i = t.tags.find((c) => c[0] === "encryption"); + let s = ["nip04"]; + return o && o[1].includes("1.0") && s.push("nip44_v2"), i && (s = i[1].split(" ")), { + encryptions: s, + // delimiter is " " per spec, but Alby NWC originally returned "," + capabilities: n.split(/[ |,]/g), + notifications: r?.[1]?.split(" ") || [] + }; + } + async getInfo() { + try { + return await this.executeNip47Request("get_info", {}, (n) => !!n.methods, { replyTimeout: 1e4 }); + } catch (t) { + throw console.error("Failed to request get_info", t), t; + } + } + async getBudget() { + try { + return await this.executeNip47Request("get_budget", {}, (n) => n !== void 0, { replyTimeout: 1e4 }); + } catch (t) { + throw console.error("Failed to request get_budget", t), t; + } + } + async getBalance() { + try { + return await this.executeNip47Request("get_balance", {}, (n) => n.balance !== void 0, { replyTimeout: 1e4 }); + } catch (t) { + throw console.error("Failed to request get_balance", t), t; + } + } + async payInvoice(t) { + try { + return await this.executeNip47Request("pay_invoice", t, (r) => !!r); + } catch (n) { + throw console.error("Failed to request pay_invoice", n), n; + } + } + async payKeysend(t) { + try { + return await this.executeNip47Request("pay_keysend", t, (r) => !!r.preimage); + } catch (n) { + throw console.error("Failed to request pay_keysend", n), n; + } + } + async signMessage(t) { + try { + return await this.executeNip47Request("sign_message", t, (r) => r.message === t.message && !!r.signature); + } catch (n) { + throw console.error("Failed to request sign_message", n), n; + } + } + async createConnection(t) { + try { + return await this.executeNip47Request("create_connection", t, (r) => !!r.wallet_pubkey); + } catch (n) { + throw console.error("Failed to request create_connection", n), n; + } + } + async multiPayInvoice(t) { + try { + return { + invoices: await this.executeMultiNip47Request("multi_pay_invoice", t, t.invoices.length, (r) => !!r.preimage), + // TODO: error handling + errors: [] + }; + } catch (n) { + throw console.error("Failed to request multi_pay_invoice", n), n; + } + } + async multiPayKeysend(t) { + try { + return { + keysends: await this.executeMultiNip47Request("multi_pay_keysend", t, t.keysends.length, (r) => !!r.preimage), + // TODO: error handling + errors: [] + }; + } catch (n) { + throw console.error("Failed to request multi_pay_keysend", n), n; + } + } + async makeInvoice(t) { + try { + if (!t.amount) + throw new Error("No amount specified"); + return await this.executeNip47Request("make_invoice", t, (r) => !!r.invoice); + } catch (n) { + throw console.error("Failed to request make_invoice", n), n; + } + } + async makeHoldInvoice(t) { + try { + if (!t.amount) + throw new Error("No amount specified"); + if (!t.payment_hash) + throw new Error("No payment hash specified"); + return await this.executeNip47Request("make_hold_invoice", t, (r) => !!r.invoice); + } catch (n) { + throw console.error("Failed to request make_hold_invoice", n), n; + } + } + async settleHoldInvoice(t) { + try { + return await this.executeNip47Request("settle_hold_invoice", t, (r) => !!r); + } catch (n) { + throw console.error("Failed to request settle_hold_invoice", n), n; + } + } + async cancelHoldInvoice(t) { + try { + return await this.executeNip47Request("cancel_hold_invoice", t, (r) => !!r); + } catch (n) { + throw console.error("Failed to request cancel_hold_invoice", n), n; + } + } + async lookupInvoice(t) { + try { + return await this.executeNip47Request("lookup_invoice", t, (r) => !!r.invoice); + } catch (n) { + throw console.error("Failed to request lookup_invoice", n), n; + } + } + async listTransactions(t) { + try { + return await this.executeNip47Request("list_transactions", t, (r) => !!r.transactions, { replyTimeout: 1e4 }); + } catch (n) { + throw console.error("Failed to request list_transactions", n), n; + } + } + async subscribeNotifications(t, n) { + this.logger.debug("checking connection to relays"), await this._checkConnected(), await this._selectEncryptionType(), this.logger.debug("subscribing to relays"); + const r = this.pool.subscribe(this.relayUrls, { + kinds: [...this.encryptionType === "nip04" ? [23196] : [23197]], + authors: [this.walletPubkey], + "#p": [this.publicKey] + }, { + onevent: async (o) => { + let i; + try { + i = await this.decrypt(this.walletPubkey, o.content); + } catch (c) { + console.error("failed to decrypt request event content", c); + return; + } + let s; + try { + s = JSON.parse(i); + } catch (c) { + console.error("Failed to parse decrypted event content", c); + return; + } + s.notification ? (!n || n.indexOf(s.notification_type) > -1) && t(s) : console.error("No notification in response", s); + }, + onconnect: (o) => { + this.logger.debug("relay connected", o); + }, + ondisconnect: (o, i) => { + this.logger.debug("relay disconnected", o, i); + } + }); + return this.logger.debug("subscribed to relays"), () => { + r?.close(); + }; + } + async executeNip47Request(t, n, r, o) { + return await this._checkConnected(), await this._selectEncryptionType(), new Promise((i, s) => { + (async () => { + const c = { + method: t, + params: n + }, a = await this.encrypt(this.walletPubkey, JSON.stringify(c)), h = { + kind: 23194, + created_at: Math.floor(Date.now() / 1e3), + tags: [ + ["p", this.walletPubkey], + // TODO: Remove version tag after 01-06-2025 + ["v", this.encryptionType === "nip44_v2" ? "1.0" : "0.0"], + ["encryption", this.encryptionType] + ], + content: a + }, w = await this.signEvent(h), g = this.pool.subscribe(this.relayUrls, { + kinds: [23195], + authors: [this.walletPubkey], + "#e": [w.id] + }, { + onevent: async (M) => { + clearTimeout(b), g.close(); + const I = await this.decrypt(this.walletPubkey, M.content); + let U; + try { + U = JSON.parse(I); + } catch { + clearTimeout(b), g.close(), s(new Es("failed to deserialize response", "INTERNAL")); + return; + } + U.result ? r(U.result) ? i(U.result) : (clearTimeout(b), g.close(), s(new Vr("response from NWC failed validation: " + JSON.stringify(U.result), "INTERNAL"))) : (clearTimeout(b), g.close(), s(new E4(U.error?.message || "unknown Error", U.error?.code || "INTERNAL"))); + } + }); + function v() { + g.close(), s(new Cs(`reply timeout: event ${w.id}`, "INTERNAL")); + } + const b = setTimeout(v, o?.replyTimeout || 6e4); + function C() { + g.close(), s(new vs(`publish timeout: ${w.id}`, "INTERNAL")); + } + const L = setTimeout(C, o?.publishTimeout || 5e3); + try { + await Promise.any(this.pool.publish(this.relayUrls, w)), clearTimeout(L); + } catch (M) { + clearTimeout(L), s(new xs(`failed to publish: ${M}`, "INTERNAL")); + } + })(); + }); + } + /** + * @deprecated + * multi- methods were removed from NIP-47. + */ + async executeMultiNip47Request(t, n, r, o, i) { + await this._checkConnected(), await this._selectEncryptionType(); + const s = []; + return new Promise((c, a) => { + (async () => { + const h = { + method: t, + params: n + }, w = await this.encrypt(this.walletPubkey, JSON.stringify(h)), g = { + kind: 23194, + created_at: Math.floor(Date.now() / 1e3), + tags: [ + ["p", this.walletPubkey], + // TODO: Remove version tag after 01-06-2025 + ["v", this.encryptionType === "nip44_v2" ? "1.0" : "0.0"], + ["encryption", this.encryptionType] + ], + content: w + }, v = await this.signEvent(g), b = this.pool.subscribe(this.relayUrls, { + kinds: [23195], + authors: [this.walletPubkey], + "#e": [v.id] + }, { + onevent: async (U) => { + const q = await this.decrypt(this.walletPubkey, U.content); + let Q; + try { + Q = JSON.parse(q); + } catch { + clearTimeout(L), b.close(), a(new Es("failed to deserialize response", "INTERNAL")); + } + if (Q.result) { + if (!o(Q.result)) { + clearTimeout(L), b.close(), a(new Vr("Response from NWC failed validation: " + JSON.stringify(Q.result), "INTERNAL")); + return; + } + const A = U.tags.find((_) => _[0] === "d")?.[1]; + if (A === void 0) { + clearTimeout(L), b.close(), a(new Vr("No d tag found in response event", "INTERNAL")); + return; + } + s.push({ + ...Q.result, + dTag: A + }), s.length === r && (clearTimeout(L), b.close(), c(s)); + } else + clearTimeout(L), b.close(), a(new A4(Q.error?.message, Q.error?.code)); + } + }); + function C() { + b.close(), a(new Cs(`reply timeout: event ${v.id}`, "INTERNAL")); + } + const L = setTimeout(C, i?.replyTimeout || 6e4); + function M() { + b.close(), a(new vs(`Publish timeout: ${v.id}`, "INTERNAL")); + } + const I = setTimeout(M, i?.publishTimeout || 5e3); + try { + await Promise.any(this.pool.publish(this.relayUrls, v)), clearTimeout(I); + } catch (U) { + clearTimeout(I), a(new xs(`Failed to publish: ${U}`, "INTERNAL")); + } + })(); + }); + } + async _checkConnected() { + if (!this.secret) + throw new Error("Missing secret key"); + if (!this.relayUrls) + throw new Error("Missing relay url"); + try { + await Promise.any(this.relayUrls.map((t) => this.pool.ensureRelay(t))); + } catch (t) { + throw console.error("failed to connect to any relay", t), new r2("Failed to connect to " + this.relayUrls.join(","), "OTHER"); + } + } + async _selectEncryptionType() { + if (!this._encryptionType) { + const t = await this.getWalletServiceInfo(), n = this._findPreferredEncryptionType(t.encryptions); + if (!n) + throw new k4("no compatible encryption or version found between wallet and client", "UNSUPPORTED_ENCRYPTION"); + n === "nip04" && console.warn("NIP-04 encryption is about to be deprecated. Please upgrade your wallet service to use NIP-44 instead."), this._encryptionType = n; + } + } + _findPreferredEncryptionType(t) { + return t.includes("nip44_v2") ? "nip44_v2" : t.includes("nip04") ? "nip04" : null; + } +} +const T4 = { + get_info: "getInfo", + get_balance: "getBalance", + make_invoice: "makeInvoice", + pay_invoice: "sendPayment", + pay_keysend: "payKeysend", + lookup_invoice: "lookupInvoice", + list_transactions: "listTransactions", + multi_pay_invoice: "sendMultiPayment", + multi_pay_keysend: "multiKeysend", + sign_message: "signMessage" +}; +class Ar { + get options() { + return this.client.options; + } + static async fromAuthorizationUrl(t, n = {}, r) { + const o = await vt.fromAuthorizationUrl(t, n, r); + return new Ar({ + client: o + }); + } + constructor(t) { + this._enabled = !1, this.client = t?.client || new vt(t), this.subscribers = {}; + } + on(t, n) { + this.subscribers[t] = n; + } + notify(t, n) { + const r = this.subscribers[t]; + r && r(n); + } + getPublicKey() { + return this.client.getPublicKey(); + } + signEvent(t) { + return this.client.signEvent(t); + } + async enable() { + this._enabled = !0; + } + close() { + return this.client.close(); + } + async getInfo() { + await this.checkEnabled(); + const t = ["lightning", "nostr"], n = "Alby JS SDK"; + try { + const r = await this.client.getInfo(), o = { + methods: r.methods.map((i) => T4[i]), + node: { + alias: r.alias, + pubkey: r.pubkey, + color: r.color + }, + supports: t, + version: n + }; + return this.notify("getInfo", o), o; + } catch (r) { + return console.error("Using minimal getInfo", r), { + methods: ["sendPayment"], + node: {}, + supports: t, + version: n + }; + } + } + async getBalance() { + await this.checkEnabled(); + const t = await this.client.getBalance(), n = { + // NWC uses msats - convert to sats for webln + balance: Math.floor(t.balance / 1e3), + currency: "sats" + }; + return this.notify("getBalance", n), n; + } + async sendPayment(t) { + await this.checkEnabled(); + const r = { preimage: (await this.client.payInvoice({ invoice: t })).preimage }; + return this.notify("sendPayment", r), r; + } + async sendPaymentAsync(t) { + return await this.checkEnabled(), this.client.payInvoice({ invoice: t }), this.notify("sendPaymentAsync", {}), {}; + } + async keysend(t) { + await this.checkEnabled(); + const r = { preimage: (await this.client.payKeysend(ks(t))).preimage }; + return this.notify("keysend", r), r; + } + async signMessage(t) { + await this.checkEnabled(); + const n = await this.client.signMessage({ + message: t + }), r = { + message: n.message, + signature: n.signature + }; + return this.notify("keysend", r), r; + } + async makeInvoice(t) { + await this.checkEnabled(); + const n = typeof t == "object" ? t : void 0, r = +(n?.amount ?? t); + if (!r) + throw new Error("No amount specified"); + const i = { paymentRequest: (await this.client.makeInvoice({ + amount: r * 1e3, + // NIP-47 uses msat + description: n?.defaultMemo + // TODO: support additional fields below + //expiry: 86500, + //description_hash: "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9" + })).invoice }; + return this.notify("makeInvoice", i), i; + } + async lookupInvoice(t) { + await this.checkEnabled(); + const n = await this.client.lookupInvoice({ + invoice: t.paymentRequest, + payment_hash: t.paymentHash + }), r = { + preimage: n.preimage, + paymentRequest: n.invoice, + paid: !!n.settled_at + }; + return this.notify("lookupInvoice", r), r; + } + async listTransactions(t) { + await this.checkEnabled(); + const r = { + transactions: (await this.client.listTransactions(t)).transactions.map(M4) + }; + return this.notify("listTransactions", r), r; + } + // NOTE: this method may change - it has not been proposed to be added to the WebLN spec yet. + async sendMultiPayment(t) { + await this.checkEnabled(); + const r = { + payments: (await this.client.multiPayInvoice({ + invoices: t.map((o, i) => ({ + invoice: o, + id: i.toString() + })) + })).invoices.map((o) => { + const i = t[parseInt(o.dTag)]; + if (!i) + throw new Error("Could not find paymentRequest matching response d tag"); + return { + paymentRequest: i, + preimage: o.preimage + }; + }), + // TODO: error handling + errors: [] + }; + return this.notify("sendMultiPayment", r), r; + } + // NOTE: this method may change - it has not been proposed to be added to the WebLN spec yet. + async multiKeysend(t) { + await this.checkEnabled(); + const r = { + keysends: (await this.client.multiPayKeysend({ + keysends: t.map((o, i) => ({ + ...ks(o), + id: i.toString() + })) + })).keysends.map((o) => { + const i = t[parseInt(o.dTag)]; + if (!i) + throw new Error("Could not find keysend matching response d tag"); + return { + keysend: i, + preimage: o.preimage + }; + }), + // TODO: error handling + errors: [] + }; + return this.notify("multiKeysend", r), r; + } + // not-yet implemented WebLN interface methods + lnurl(t) { + throw new Error("Method not implemented."); + } + request(t, n) { + throw new Error("Method not implemented."); + } + verifyMessage(t, n) { + throw new Error("Method not implemented."); + } + async checkEnabled() { + if (!this._enabled) + throw new Error("please call enable() and await the promise before calling this function"); + } +} +function M4(e) { + return { + ...e, + // NWC uses msats - convert to sats for webln + amount: Math.floor(e.amount / 1e3), + fees_paid: e.fees_paid ? Math.floor(e.fees_paid / 1e3) : 0 + }; +} +function ks(e) { + return { + amount: +e.amount * 1e3, + // NIP-47 uses msat + pubkey: e.destination, + tlv_records: e.customRecords ? Object.entries(e.customRecords).map((t) => ({ + type: parseInt(t[0]), + value: Z2(new TextEncoder().encode(t[1])) + })) : [] + // TODO: support optional preimage + // preimage?: "123", + }; +} +class s2 { + constructor(t) { + if (this.appSecretKey = t.appSecretKey || pe(ui()), this.options = { + ...t, + appPubkey: Yt(ue(this.appSecretKey)) + }, !this.options.relayUrls) + throw new Error("Missing relay urls"); + if (!this.options.requestMethods) + throw new Error("Missing request methods"); + this.pool = new i2(), this.logger = t.logger || wl; + } + /** + * returns the NWA connection URI which should be given to the wallet + */ + get connectionUri() { + return this.getConnectionUri(); + } + /** + * returns the NWA connection URI which should be given to the wallet + * @param nwaSchemeSuffix open a specific wallet. e.g. "alby" will set the scheme to + * nostr+walletauth+alby to ensure the link will be opened in an Alby wallet + */ + getConnectionUri(t = "") { + const n = new URLSearchParams({ + request_methods: this.options.requestMethods.join(" "), + ...this.options.name ? { name: this.options.name } : {}, + ...this.options.icon ? { icon: this.options.icon } : {}, + ...this.options.returnTo ? { return_to: this.options.returnTo } : {}, + ...this.options.notificationTypes ? { + notification_types: this.options.notificationTypes.join(" ") + } : {}, + ...this.options.maxAmount ? { max_amount: this.options.maxAmount.toString() } : {}, + ...this.options.budgetRenewal ? { budget_renewal: this.options.budgetRenewal } : {}, + ...this.options.expiresAt ? { expires_at: this.options.expiresAt.toString() } : {}, + ...this.options.isolated ? { isolated: this.options.isolated.toString() } : {}, + ...this.options.metadata ? { metadata: JSON.stringify(this.options.metadata) } : {} + }); + for (const r of this.options.relayUrls) + n.append("relay", r); + return `nostr+walletauth${t ? `+${t}` : ""}://${this.options.appPubkey}?${n.toString().replace(/\+/g, "%20")}`; + } + static parseWalletAuthUrl(t) { + if (!t.startsWith("nostr+walletauth")) + throw new Error("Unexpected scheme. Should be nostr+walletauth:// or nostr+walletauth+specificapp://"); + const n = t.indexOf(":"); + t = t.substring(n + 1), t.startsWith("//") && (t = t.substring(2)), t = "http://" + t; + const r = new URL(t), o = r.host; + if (o?.length !== 64) + throw new Error("Incorrect app pubkey found in auth string"); + const i = r.searchParams.getAll("relay"); + if (!i) + throw new Error("No relay URL found in auth string"); + const s = r.searchParams.get("request_methods")?.split(" "); + if (!s?.length) + throw new Error("No request methods found in auth string"); + const c = r.searchParams.get("notification_types")?.split(" "), a = r.searchParams.get("max_amount"), h = r.searchParams.get("expires_at"), w = r.searchParams.get("metadata"); + return { + name: r.searchParams.get("name") || void 0, + icon: r.searchParams.get("icon") || void 0, + returnTo: r.searchParams.get("return_to") || void 0, + relayUrls: i, + appPubkey: o, + requestMethods: s, + notificationTypes: c, + budgetRenewal: r.searchParams.get("budget_renewal"), + expiresAt: h ? parseInt(h) : void 0, + maxAmount: a ? parseInt(a) : void 0, + isolated: r.searchParams.get("isolated") === "true", + metadata: w ? JSON.parse(w) : void 0 + }; + } + /** + * Waits for a new app connection to be created via NWA (https://github.com/nostr-protocol/nips/pull/851) + * + * @returns a new NWCClient + */ + async subscribe(t) { + this.logger.debug("checking connection to relays"), await this._checkConnected(), this.logger.debug("subscribing to info event"); + const n = this.pool.subscribe(this.options.relayUrls, { + kinds: [13194], + // NIP-47 info event + "#p": [this.options.appPubkey] + }, { + onevent: async (r) => { + const o = new vt({ + relayUrls: this.options.relayUrls, + secret: this.appSecretKey, + walletPubkey: r.pubkey + }); + try { + const i = await o.getInfo(); + o.options.lud16 = i.lud16, o.lud16 = i.lud16; + } catch (i) { + console.error("failed to fetch get_info", i); + } + t.onSuccess(o), n?.close(); + }, + onconnect: (r) => { + this.logger.debug("relay connected", r); + }, + ondisconnect: (r, o) => { + this.logger.debug("relay disconnected", r, o); + } + }); + return { + unsub: () => { + n?.close(); + } + }; + } + close() { + return this.pool.close(this.options.relayUrls); + } + async _checkConnected() { + if (!this.appSecretKey) + throw new Error("Missing secret key"); + if (!this.options.relayUrls) + throw new Error("Missing relay urls"); + try { + await Promise.any(this.options.relayUrls.map((t) => this.pool.ensureRelay(t))); + } catch (t) { + throw console.error("failed to connect to any relay", t), new r2("Failed to connect to " + this.options.relayUrls.join(","), "OTHER"); + } + } +} +const B4 = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68; +if (!B4) + throw new Error("Non little-endian hardware is not supported"); +var Gr = {}, _s; +function R4() { + return _s || (_s = 1, (function(e) { + /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */ + Object.defineProperty(e, "__esModule", { value: !0 }), e.bytes = e.stringToBytes = e.str = e.bytesToString = e.hex = e.utf8 = e.bech32m = e.bech32 = e.base58check = e.base58xmr = e.base58xrp = e.base58flickr = e.base58 = e.base64url = e.base64 = e.base32crockford = e.base32hex = e.base32 = e.base16 = e.utils = e.assertNumber = void 0; + function t(d) { + if (!Number.isSafeInteger(d)) + throw new Error(`Wrong integer: ${d}`); + } + e.assertNumber = t; + function n(...d) { + const l = (f, y) => (x) => f(y(x)), u = Array.from(d).reverse().reduce((f, y) => f ? l(f, y.encode) : y.encode, void 0), p = d.reduce((f, y) => f ? l(f, y.decode) : y.decode, void 0); + return { encode: u, decode: p }; + } + function r(d) { + return { + encode: (l) => { + if (!Array.isArray(l) || l.length && typeof l[0] != "number") + throw new Error("alphabet.encode input should be an array of numbers"); + return l.map((u) => { + if (t(u), u < 0 || u >= d.length) + throw new Error(`Digit index outside alphabet: ${u} (alphabet: ${d.length})`); + return d[u]; + }); + }, + decode: (l) => { + if (!Array.isArray(l) || l.length && typeof l[0] != "string") + throw new Error("alphabet.decode input should be array of strings"); + return l.map((u) => { + if (typeof u != "string") + throw new Error(`alphabet.decode: not string element=${u}`); + const p = d.indexOf(u); + if (p === -1) + throw new Error(`Unknown letter: "${u}". Allowed: ${d}`); + return p; + }); + } + }; + } + function o(d = "") { + if (typeof d != "string") + throw new Error("join separator should be string"); + return { + encode: (l) => { + if (!Array.isArray(l) || l.length && typeof l[0] != "string") + throw new Error("join.encode input should be array of strings"); + for (let u of l) + if (typeof u != "string") + throw new Error(`join.encode: non-string input=${u}`); + return l.join(d); + }, + decode: (l) => { + if (typeof l != "string") + throw new Error("join.decode input should be string"); + return l.split(d); + } + }; + } + function i(d, l = "=") { + if (t(d), typeof l != "string") + throw new Error("padding chr should be string"); + return { + encode(u) { + if (!Array.isArray(u) || u.length && typeof u[0] != "string") + throw new Error("padding.encode input should be array of strings"); + for (let p of u) + if (typeof p != "string") + throw new Error(`padding.encode: non-string input=${p}`); + for (; u.length * d % 8; ) + u.push(l); + return u; + }, + decode(u) { + if (!Array.isArray(u) || u.length && typeof u[0] != "string") + throw new Error("padding.encode input should be array of strings"); + for (let f of u) + if (typeof f != "string") + throw new Error(`padding.decode: non-string input=${f}`); + let p = u.length; + if (p * d % 8) + throw new Error("Invalid padding: string should have whole number of bytes"); + for (; p > 0 && u[p - 1] === l; p--) + if (!((p - 1) * d % 8)) + throw new Error("Invalid padding: string has too much padding"); + return u.slice(0, p); + } + }; + } + function s(d) { + if (typeof d != "function") + throw new Error("normalize fn should be function"); + return { encode: (l) => l, decode: (l) => d(l) }; + } + function c(d, l, u) { + if (l < 2) + throw new Error(`convertRadix: wrong from=${l}, base cannot be less than 2`); + if (u < 2) + throw new Error(`convertRadix: wrong to=${u}, base cannot be less than 2`); + if (!Array.isArray(d)) + throw new Error("convertRadix: data should be array"); + if (!d.length) + return []; + let p = 0; + const f = [], y = Array.from(d); + for (y.forEach((x) => { + if (t(x), x < 0 || x >= l) + throw new Error(`Wrong integer: ${x}`); + }); ; ) { + let x = 0, O = !0; + for (let R = p; R < y.length; R++) { + const P = y[R], S = l * x + P; + if (!Number.isSafeInteger(S) || l * x / l !== x || S - P !== l * x) + throw new Error("convertRadix: carry overflow"); + if (x = S % u, y[R] = Math.floor(S / u), !Number.isSafeInteger(y[R]) || y[R] * u + x !== S) + throw new Error("convertRadix: carry overflow"); + if (O) + y[R] ? O = !1 : p = R; + else continue; + } + if (f.push(x), O) + break; + } + for (let x = 0; x < d.length - 1 && d[x] === 0; x++) + f.push(0); + return f.reverse(); + } + const a = (d, l) => l ? a(l, d % l) : d, h = (d, l) => d + (l - a(d, l)); + function w(d, l, u, p) { + if (!Array.isArray(d)) + throw new Error("convertRadix2: data should be array"); + if (l <= 0 || l > 32) + throw new Error(`convertRadix2: wrong from=${l}`); + if (u <= 0 || u > 32) + throw new Error(`convertRadix2: wrong to=${u}`); + if (h(l, u) > 32) + throw new Error(`convertRadix2: carry overflow from=${l} to=${u} carryBits=${h(l, u)}`); + let f = 0, y = 0; + const x = 2 ** u - 1, O = []; + for (const R of d) { + if (t(R), R >= 2 ** l) + throw new Error(`convertRadix2: invalid data word=${R} from=${l}`); + if (f = f << l | R, y + l > 32) + throw new Error(`convertRadix2: carry overflow pos=${y} from=${l}`); + for (y += l; y >= u; y -= u) + O.push((f >> y - u & x) >>> 0); + f &= 2 ** y - 1; + } + if (f = f << u - y & x, !p && y >= l) + throw new Error("Excess padding"); + if (!p && f) + throw new Error(`Non-zero padding: ${f}`); + return p && y > 0 && O.push(f >>> 0), O; + } + function g(d) { + return t(d), { + encode: (l) => { + if (!(l instanceof Uint8Array)) + throw new Error("radix.encode input should be Uint8Array"); + return c(Array.from(l), 2 ** 8, d); + }, + decode: (l) => { + if (!Array.isArray(l) || l.length && typeof l[0] != "number") + throw new Error("radix.decode input should be array of strings"); + return Uint8Array.from(c(l, d, 2 ** 8)); + } + }; + } + function v(d, l = !1) { + if (t(d), d <= 0 || d > 32) + throw new Error("radix2: bits should be in (0..32]"); + if (h(8, d) > 32 || h(d, 8) > 32) + throw new Error("radix2: carry overflow"); + return { + encode: (u) => { + if (!(u instanceof Uint8Array)) + throw new Error("radix2.encode input should be Uint8Array"); + return w(Array.from(u), 8, d, !l); + }, + decode: (u) => { + if (!Array.isArray(u) || u.length && typeof u[0] != "number") + throw new Error("radix2.decode input should be array of strings"); + return Uint8Array.from(w(u, d, 8, l)); + } + }; + } + function b(d) { + if (typeof d != "function") + throw new Error("unsafeWrapper fn should be function"); + return function(...l) { + try { + return d.apply(null, l); + } catch { + } + }; + } + function C(d, l) { + if (t(d), typeof l != "function") + throw new Error("checksum fn should be function"); + return { + encode(u) { + if (!(u instanceof Uint8Array)) + throw new Error("checksum.encode: input should be Uint8Array"); + const p = l(u).slice(0, d), f = new Uint8Array(u.length + d); + return f.set(u), f.set(p, u.length), f; + }, + decode(u) { + if (!(u instanceof Uint8Array)) + throw new Error("checksum.decode: input should be Uint8Array"); + const p = u.slice(0, -d), f = l(p).slice(0, d), y = u.slice(-d); + for (let x = 0; x < d; x++) + if (f[x] !== y[x]) + throw new Error("Invalid checksum"); + return p; + } + }; + } + e.utils = { alphabet: r, chain: n, checksum: C, radix: g, radix2: v, join: o, padding: i }, e.base16 = n(v(4), r("0123456789ABCDEF"), o("")), e.base32 = n(v(5), r("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), i(5), o("")), e.base32hex = n(v(5), r("0123456789ABCDEFGHIJKLMNOPQRSTUV"), i(5), o("")), e.base32crockford = n(v(5), r("0123456789ABCDEFGHJKMNPQRSTVWXYZ"), o(""), s((d) => d.toUpperCase().replace(/O/g, "0").replace(/[IL]/g, "1"))), e.base64 = n(v(6), r("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), i(6), o("")), e.base64url = n(v(6), r("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), i(6), o("")); + const L = (d) => n(g(58), r(d), o("")); + e.base58 = L("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"), e.base58flickr = L("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"), e.base58xrp = L("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"); + const M = [0, 2, 3, 5, 6, 7, 9, 10, 11]; + e.base58xmr = { + encode(d) { + let l = ""; + for (let u = 0; u < d.length; u += 8) { + const p = d.subarray(u, u + 8); + l += e.base58.encode(p).padStart(M[p.length], "1"); + } + return l; + }, + decode(d) { + let l = []; + for (let u = 0; u < d.length; u += 11) { + const p = d.slice(u, u + 11), f = M.indexOf(p.length), y = e.base58.decode(p); + for (let x = 0; x < y.length - f; x++) + if (y[x] !== 0) + throw new Error("base58xmr: wrong padding"); + l = l.concat(Array.from(y.slice(y.length - f))); + } + return Uint8Array.from(l); + } + }; + const I = (d) => n(C(4, (l) => d(d(l))), e.base58); + e.base58check = I; + const U = n(r("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), o("")), q = [996825010, 642813549, 513874426, 1027748829, 705979059]; + function Q(d) { + const l = d >> 25; + let u = (d & 33554431) << 5; + for (let p = 0; p < q.length; p++) + (l >> p & 1) === 1 && (u ^= q[p]); + return u; + } + function A(d, l, u = 1) { + const p = d.length; + let f = 1; + for (let y = 0; y < p; y++) { + const x = d.charCodeAt(y); + if (x < 33 || x > 126) + throw new Error(`Invalid prefix (${d})`); + f = Q(f) ^ x >> 5; + } + f = Q(f); + for (let y = 0; y < p; y++) + f = Q(f) ^ d.charCodeAt(y) & 31; + for (let y of l) + f = Q(f) ^ y; + for (let y = 0; y < 6; y++) + f = Q(f); + return f ^= u, U.encode(w([f % 2 ** 30], 30, 5, !1)); + } + function _(d) { + const l = d === "bech32" ? 1 : 734539939, u = v(5), p = u.decode, f = u.encode, y = b(p); + function x(S, D, J = 90) { + if (typeof S != "string") + throw new Error(`bech32.encode prefix should be string, not ${typeof S}`); + if (!Array.isArray(D) || D.length && typeof D[0] != "number") + throw new Error(`bech32.encode words should be array of numbers, not ${typeof D}`); + const Y = S.length + 7 + D.length; + if (J !== !1 && Y > J) + throw new TypeError(`Length ${Y} exceeds limit ${J}`); + return S = S.toLowerCase(), `${S}1${U.encode(D)}${A(S, D, l)}`; + } + function O(S, D = 90) { + if (typeof S != "string") + throw new Error(`bech32.decode input should be string, not ${typeof S}`); + if (S.length < 8 || D !== !1 && S.length > D) + throw new TypeError(`Wrong string length: ${S.length} (${S}). Expected (8..${D})`); + const J = S.toLowerCase(); + if (S !== J && S !== S.toUpperCase()) + throw new Error("String must be lowercase or uppercase"); + S = J; + const Y = S.lastIndexOf("1"); + if (Y === 0 || Y === -1) + throw new Error('Letter "1" must be present between prefix and data only'); + const G = S.slice(0, Y), X = S.slice(Y + 1); + if (X.length < 6) + throw new Error("Data must be at least 6 characters long"); + const ie = U.decode(X).slice(0, -6), N = A(G, ie, l); + if (!X.endsWith(N)) + throw new Error(`Invalid checksum in ${S}: expected "${N}"`); + return { prefix: G, words: ie }; + } + const R = b(O); + function P(S) { + const { prefix: D, words: J } = O(S, !1); + return { prefix: D, words: J, bytes: p(J) }; + } + return { encode: x, decode: O, decodeToBytes: P, decodeUnsafe: R, fromWords: p, fromWordsUnsafe: y, toWords: f }; + } + e.bech32 = _("bech32"), e.bech32m = _("bech32m"), e.utf8 = { + encode: (d) => new TextDecoder().decode(d), + decode: (d) => new TextEncoder().encode(d) + }, e.hex = n(v(4), r("0123456789abcdef"), o(""), s((d) => { + if (typeof d != "string" || d.length % 2) + throw new TypeError(`hex.decode: expected string, got ${typeof d} with length ${d.length}`); + return d.toLowerCase(); + })); + const E = { + utf8: e.utf8, + hex: e.hex, + base16: e.base16, + base32: e.base32, + base64: e.base64, + base64url: e.base64url, + base58: e.base58, + base58xmr: e.base58xmr + }, T = `Invalid encoding type. Available types: ${Object.keys(E).join(", ")}`, m = (d, l) => { + if (typeof d != "string" || !E.hasOwnProperty(d)) + throw new TypeError(T); + if (!(l instanceof Uint8Array)) + throw new TypeError("bytesToString() expects Uint8Array"); + return E[d].encode(l); + }; + e.bytesToString = m, e.str = e.bytesToString; + const k = (d, l) => { + if (!E.hasOwnProperty(d)) + throw new TypeError(T); + if (typeof l != "string") + throw new TypeError("stringToBytes() expects string"); + return E[d].decode(l); + }; + e.stringToBytes = k, e.bytes = e.stringToBytes; + })(Gr)), Gr; +} +var jr, Ss; +function N4() { + if (Ss) return jr; + Ss = 1; + const { bech32: e, hex: t, utf8: n } = R4(), r = { + // default network is bitcoin + bech32: "bc", + pubKeyHash: 0, + scriptHash: 5, + validWitnessVersions: [0] + }, o = { + bech32: "tb", + pubKeyHash: 111, + scriptHash: 196, + validWitnessVersions: [0] + }, i = { + bech32: "tbs", + pubKeyHash: 111, + scriptHash: 196, + validWitnessVersions: [0] + }, s = { + bech32: "bcrt", + pubKeyHash: 111, + scriptHash: 196, + validWitnessVersions: [0] + }, c = { + bech32: "sb", + pubKeyHash: 63, + scriptHash: 123, + validWitnessVersions: [0] + }, a = [ + "option_data_loss_protect", + "initial_routing_sync", + "option_upfront_shutdown_script", + "gossip_queries", + "var_onion_optin", + "gossip_queries_ex", + "option_static_remotekey", + "payment_secret", + "basic_mpp", + "option_support_large_channel" + ], h = { + m: BigInt(1e3), + u: BigInt(1e6), + n: BigInt(1e9), + p: BigInt(1e12) + }, w = BigInt("2100000000000000000"), g = BigInt(1e11), v = { + payment_hash: 1, + payment_secret: 16, + description: 13, + payee: 19, + description_hash: 23, + // commit to longer descriptions (used by lnurl-pay) + expiry: 6, + // default: 3600 (1 hour) + min_final_cltv_expiry: 24, + // default: 9 + fallback_address: 9, + route_hint: 3, + // for extra routing info (private etc.) + feature_bits: 5, + metadata: 27 + }, b = {}; + for (let A = 0, _ = Object.keys(v); A < _.length; A++) { + const E = _[A], T = v[_[A]].toString(); + b[T] = E; + } + const C = { + 1: (A) => t.encode(e.fromWordsUnsafe(A)), + // 256 bits + 16: (A) => t.encode(e.fromWordsUnsafe(A)), + // 256 bits + 13: (A) => n.encode(e.fromWordsUnsafe(A)), + // string variable length + 19: (A) => t.encode(e.fromWordsUnsafe(A)), + // 264 bits + 23: (A) => t.encode(e.fromWordsUnsafe(A)), + // 256 bits + 27: (A) => t.encode(e.fromWordsUnsafe(A)), + // variable + 6: M, + // default: 3600 (1 hour) + 24: M, + // default: 9 + 3: I, + // for extra routing info (private etc.) + 5: U + // keep feature bits as array of 5 bit words + }; + function L(A) { + return (_) => ({ + tagCode: parseInt(A), + words: e.encode("unknown", _, Number.MAX_SAFE_INTEGER) + }); + } + function M(A) { + return A.reverse().reduce((_, E, T) => _ + E * Math.pow(32, T), 0); + } + function I(A) { + const _ = []; + let E, T, m, k, d, l = e.fromWordsUnsafe(A); + for (; l.length > 0; ) + E = t.encode(l.slice(0, 33)), T = t.encode(l.slice(33, 41)), m = parseInt(t.encode(l.slice(41, 45)), 16), k = parseInt( + t.encode(l.slice(45, 49)), + 16 + ), d = parseInt(t.encode(l.slice(49, 51)), 16), l = l.slice(51), _.push({ + pubkey: E, + short_channel_id: T, + fee_base_msat: m, + fee_proportional_millionths: k, + cltv_expiry_delta: d + }); + return _; + } + function U(A) { + const _ = A.slice().reverse().map((m) => [ + !!(m & 1), + !!(m & 2), + !!(m & 4), + !!(m & 8), + !!(m & 16) + ]).reduce((m, k) => m.concat(k), []); + for (; _.length < a.length * 2; ) + _.push(!1); + const E = {}; + a.forEach((m, k) => { + let d; + _[k * 2] ? d = "required" : _[k * 2 + 1] ? d = "supported" : d = "unsupported", E[m] = d; + }); + const T = _.slice(a.length * 2); + return E.extra_bits = { + start_bit: a.length * 2, + bits: T, + has_required: T.reduce( + (m, k, d) => d % 2 !== 0 ? m || !1 : m || k, + !1 + ) + }, E; + } + function q(A, _) { + let E, T; + if (A.slice(-1).match(/^[munp]$/)) + E = A.slice(-1), T = A.slice(0, -1); + else { + if (A.slice(-1).match(/^[^munp0-9]$/)) + throw new Error("Not a valid multiplier for the amount"); + T = A; + } + if (!T.match(/^\d+$/)) + throw new Error("Not a valid human readable amount"); + const m = BigInt(T), k = E ? m * g / h[E] : m * g; + if (E === "p" && m % BigInt(10) !== BigInt(0) || k > w) + throw new Error("Amount is outside of valid range"); + return _ ? k.toString() : k; + } + function Q(A, _) { + if (typeof A != "string") + throw new Error("Lightning Payment Request must be string"); + if (A.slice(0, 2).toLowerCase() !== "ln") + throw new Error("Not a proper lightning payment request"); + const E = [], T = e.decode(A, Number.MAX_SAFE_INTEGER); + A = A.toLowerCase(); + const m = T.prefix; + let k = T.words, d = A.slice(m.length + 1), l = k.slice(-104); + k = k.slice(0, -104); + let u = m.match(/^ln(\S+?)(\d*)([a-zA-Z]?)$/); + if (u && !u[2] && (u = m.match(/^ln(\S+)$/)), !u) + throw new Error("Not a proper lightning payment request"); + E.push({ + name: "lightning_network", + letters: "ln" + }); + const p = u[1]; + let f; + if (_) { + if (_.bech32 === void 0 || _.pubKeyHash === void 0 || _.scriptHash === void 0 || !Array.isArray(_.validWitnessVersions)) + throw new Error("Invalid network"); + f = _; + } else + switch (p) { + case r.bech32: + f = r; + break; + case o.bech32: + f = o; + break; + case i.bech32: + f = i; + break; + case s.bech32: + f = s; + break; + case c.bech32: + f = c; + break; + } + if (!f || f.bech32 !== p) + throw new Error("Unknown coin bech32 prefix"); + E.push({ + name: "coin_network", + letters: p, + value: f + }); + const y = u[2]; + let x; + if (y) { + const G = u[3]; + x = q(y + G, !0), E.push({ + name: "amount", + letters: u[2] + u[3], + value: x + }); + } else + x = null; + E.push({ + name: "separator", + letters: "1" + }); + const O = M(k.slice(0, 7)); + k = k.slice(7), E.push({ + name: "timestamp", + letters: d.slice(0, 7), + value: O + }), d = d.slice(7); + let R, P, S, D; + for (; k.length > 0; ) { + const G = k[0].toString(); + R = b[G] || "unknown_tag", P = C[G] || L(G), k = k.slice(1), S = M(k.slice(0, 2)), k = k.slice(2), D = k.slice(0, S), k = k.slice(S), E.push({ + name: R, + tag: d[0], + letters: d.slice(0, 3 + S), + value: P(D) + // see: parsers for more comments + }), d = d.slice(3 + S); + } + E.push({ + name: "signature", + letters: d.slice(0, 104), + value: t.encode(e.fromWordsUnsafe(l)) + }), d = d.slice(104), E.push({ + name: "checksum", + letters: d + }); + let J = { + paymentRequest: A, + sections: E, + get expiry() { + let G = E.find((X) => X.name === "expiry"); + if (G) return Y("timestamp") + G.value; + }, + get route_hints() { + return E.filter((G) => G.name === "route_hint").map((G) => G.value); + } + }; + for (let G in v) + G !== "route_hint" && Object.defineProperty(J, G, { + get() { + return Y(G); + } + }); + return J; + function Y(G) { + let X = E.find((ie) => ie.name === G); + return X ? X.value : void 0; + } + } + return jr = { + decode: Q, + hrpToMillisat: q + }, jr; +} +N4(); +const Ls = (e) => { + let t; + const n = /* @__PURE__ */ new Set(), r = (h, w) => { + const g = typeof h == "function" ? h(t) : h; + if (!Object.is(g, t)) { + const v = t; + t = w ?? (typeof g != "object" || g === null) ? g : Object.assign({}, t, g), n.forEach((b) => b(t, v)); + } + }, o = () => t, c = { setState: r, getState: o, getInitialState: () => a, subscribe: (h) => (n.add(h), () => n.delete(h)) }, a = t = e(r, o, c); + return c; +}, $4 = ((e) => e ? Ls(e) : Ls); +function I4(e, ...t) { + if (!(e instanceof Uint8Array)) + throw new Error("Expected Uint8Array"); + if (t.length > 0 && !t.includes(e.length)) + throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`); +} +function Ts(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 U4(e, t) { + I4(e); + const n = t.outputLen; + if (e.length < n) + throw new Error(`digestInto() expects output buffer of length at least ${n}`); +} +/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +const a2 = (e) => e instanceof Uint8Array, zr = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), je = (e, t) => e << 32 - t | e >>> t, O4 = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68; +if (!O4) + throw new Error("Non little-endian hardware is not supported"); +const P4 = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")); +function H4(e) { + if (!a2(e)) + throw new Error("Uint8Array expected"); + let t = ""; + for (let n = 0; n < e.length; n++) + t += P4[e[n]]; + return t; +} +function D4(e) { + if (typeof e != "string") + throw new Error(`utf8ToBytes expected string, got ${typeof e}`); + return new Uint8Array(new TextEncoder().encode(e)); +} +function c2(e) { + if (typeof e == "string" && (e = D4(e)), !a2(e)) + throw new Error(`expected Uint8Array, got ${typeof e}`); + return e; +} +class Z4 { + // Safe version that clones internal state + clone() { + return this._cloneInto(); + } +} +function W4(e) { + const t = (r) => e().update(c2(r)).digest(), n = e(); + return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t; +} +function F4(e, t, n, r) { + if (typeof e.setBigUint64 == "function") + return e.setBigUint64(t, n, r); + const o = BigInt(32), i = BigInt(4294967295), s = Number(n >> o & i), c = Number(n & i), a = r ? 4 : 0, h = r ? 0 : 4; + e.setUint32(t + a, s, r), e.setUint32(t + h, c, r); +} +class V4 extends Z4 { + constructor(t, n, r, o) { + super(), this.blockLen = t, this.outputLen = n, this.padOffset = r, this.isLE = o, this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.buffer = new Uint8Array(t), this.view = zr(this.buffer); + } + update(t) { + Ts(this); + const { view: n, buffer: r, blockLen: o } = this; + t = c2(t); + const i = t.length; + for (let s = 0; s < i; ) { + const c = Math.min(o - this.pos, i - s); + if (c === o) { + const a = zr(t); + for (; o <= i - s; s += o) + this.process(a, s); + continue; + } + r.set(t.subarray(s, s + c), this.pos), this.pos += c, s += c, this.pos === o && (this.process(n, 0), this.pos = 0); + } + return this.length += t.length, this.roundClean(), this; + } + digestInto(t) { + Ts(this), U4(t, this), this.finished = !0; + const { buffer: n, view: r, blockLen: o, isLE: i } = this; + let { pos: s } = this; + n[s++] = 128, this.buffer.subarray(s).fill(0), this.padOffset > o - s && (this.process(r, 0), s = 0); + for (let g = s; g < o; g++) + n[g] = 0; + F4(r, o - 8, BigInt(this.length * 8), i), this.process(r, 0); + const c = zr(t), a = this.outputLen; + if (a % 4) + throw new Error("_sha2: outputLen should be aligned to 32bit"); + const h = a / 4, w = this.get(); + if (h > w.length) + throw new Error("_sha2: outputLen bigger than state"); + for (let g = 0; g < h; g++) + c.setUint32(4 * g, w[g], i); + } + digest() { + const { buffer: t, outputLen: n } = this; + this.digestInto(t); + const r = t.slice(0, n); + return this.destroy(), r; + } + _cloneInto(t) { + t || (t = new this.constructor()), t.set(...this.get()); + const { blockLen: n, buffer: r, length: o, finished: i, destroyed: s, pos: c } = this; + return t.length = o, t.pos = c, t.finished = i, t.destroyed = s, o % n && t.buffer.set(r), t; + } +} +const G4 = (e, t, n) => e & t ^ ~e & n, j4 = (e, t, n) => e & t ^ e & n ^ t & n, z4 = /* @__PURE__ */ 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 +]), st = /* @__PURE__ */ new Uint32Array([ + 1779033703, + 3144134277, + 1013904242, + 2773480762, + 1359893119, + 2600822924, + 528734635, + 1541459225 +]), at = /* @__PURE__ */ new Uint32Array(64); +class q4 extends V4 { + constructor() { + super(64, 32, 8, !1), this.A = st[0] | 0, this.B = st[1] | 0, this.C = st[2] | 0, this.D = st[3] | 0, this.E = st[4] | 0, this.F = st[5] | 0, this.G = st[6] | 0, this.H = st[7] | 0; + } + get() { + const { A: t, B: n, C: r, D: o, E: i, F: s, G: c, H: a } = this; + return [t, n, r, o, i, s, c, a]; + } + // prettier-ignore + set(t, n, r, o, i, s, c, a) { + this.A = t | 0, this.B = n | 0, this.C = r | 0, this.D = o | 0, this.E = i | 0, this.F = s | 0, this.G = c | 0, this.H = a | 0; + } + process(t, n) { + for (let g = 0; g < 16; g++, n += 4) + at[g] = t.getUint32(n, !1); + for (let g = 16; g < 64; g++) { + const v = at[g - 15], b = at[g - 2], C = je(v, 7) ^ je(v, 18) ^ v >>> 3, L = je(b, 17) ^ je(b, 19) ^ b >>> 10; + at[g] = L + at[g - 7] + C + at[g - 16] | 0; + } + let { A: r, B: o, C: i, D: s, E: c, F: a, G: h, H: w } = this; + for (let g = 0; g < 64; g++) { + const v = je(c, 6) ^ je(c, 11) ^ je(c, 25), b = w + v + G4(c, a, h) + z4[g] + at[g] | 0, L = (je(r, 2) ^ je(r, 13) ^ je(r, 22)) + j4(r, o, i) | 0; + w = h, h = a, a = c, c = s + b | 0, s = i, i = o, o = r, r = b + L | 0; + } + r = r + this.A | 0, o = o + this.B | 0, i = i + this.C | 0, s = s + this.D | 0, c = c + this.E | 0, a = a + this.F | 0, h = h + this.G | 0, w = w + this.H | 0, this.set(r, o, i, s, c, a, h, w); + } + roundClean() { + at.fill(0); + } + destroy() { + this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0); + } +} +const K4 = /* @__PURE__ */ W4(() => new q4()); +var qr = {}, Ms; +function Q4() { + return Ms || (Ms = 1, (function(e) { + /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */ + Object.defineProperty(e, "__esModule", { value: !0 }), e.bytes = e.stringToBytes = e.str = e.bytesToString = e.hex = e.utf8 = e.bech32m = e.bech32 = e.base58check = e.base58xmr = e.base58xrp = e.base58flickr = e.base58 = e.base64url = e.base64 = e.base32crockford = e.base32hex = e.base32 = e.base16 = e.utils = e.assertNumber = void 0; + function t(d) { + if (!Number.isSafeInteger(d)) + throw new Error(`Wrong integer: ${d}`); + } + e.assertNumber = t; + function n(...d) { + const l = (f, y) => (x) => f(y(x)), u = Array.from(d).reverse().reduce((f, y) => f ? l(f, y.encode) : y.encode, void 0), p = d.reduce((f, y) => f ? l(f, y.decode) : y.decode, void 0); + return { encode: u, decode: p }; + } + function r(d) { + return { + encode: (l) => { + if (!Array.isArray(l) || l.length && typeof l[0] != "number") + throw new Error("alphabet.encode input should be an array of numbers"); + return l.map((u) => { + if (t(u), u < 0 || u >= d.length) + throw new Error(`Digit index outside alphabet: ${u} (alphabet: ${d.length})`); + return d[u]; + }); + }, + decode: (l) => { + if (!Array.isArray(l) || l.length && typeof l[0] != "string") + throw new Error("alphabet.decode input should be array of strings"); + return l.map((u) => { + if (typeof u != "string") + throw new Error(`alphabet.decode: not string element=${u}`); + const p = d.indexOf(u); + if (p === -1) + throw new Error(`Unknown letter: "${u}". Allowed: ${d}`); + return p; + }); + } + }; + } + function o(d = "") { + if (typeof d != "string") + throw new Error("join separator should be string"); + return { + encode: (l) => { + if (!Array.isArray(l) || l.length && typeof l[0] != "string") + throw new Error("join.encode input should be array of strings"); + for (let u of l) + if (typeof u != "string") + throw new Error(`join.encode: non-string input=${u}`); + return l.join(d); + }, + decode: (l) => { + if (typeof l != "string") + throw new Error("join.decode input should be string"); + return l.split(d); + } + }; + } + function i(d, l = "=") { + if (t(d), typeof l != "string") + throw new Error("padding chr should be string"); + return { + encode(u) { + if (!Array.isArray(u) || u.length && typeof u[0] != "string") + throw new Error("padding.encode input should be array of strings"); + for (let p of u) + if (typeof p != "string") + throw new Error(`padding.encode: non-string input=${p}`); + for (; u.length * d % 8; ) + u.push(l); + return u; + }, + decode(u) { + if (!Array.isArray(u) || u.length && typeof u[0] != "string") + throw new Error("padding.encode input should be array of strings"); + for (let f of u) + if (typeof f != "string") + throw new Error(`padding.decode: non-string input=${f}`); + let p = u.length; + if (p * d % 8) + throw new Error("Invalid padding: string should have whole number of bytes"); + for (; p > 0 && u[p - 1] === l; p--) + if (!((p - 1) * d % 8)) + throw new Error("Invalid padding: string has too much padding"); + return u.slice(0, p); + } + }; + } + function s(d) { + if (typeof d != "function") + throw new Error("normalize fn should be function"); + return { encode: (l) => l, decode: (l) => d(l) }; + } + function c(d, l, u) { + if (l < 2) + throw new Error(`convertRadix: wrong from=${l}, base cannot be less than 2`); + if (u < 2) + throw new Error(`convertRadix: wrong to=${u}, base cannot be less than 2`); + if (!Array.isArray(d)) + throw new Error("convertRadix: data should be array"); + if (!d.length) + return []; + let p = 0; + const f = [], y = Array.from(d); + for (y.forEach((x) => { + if (t(x), x < 0 || x >= l) + throw new Error(`Wrong integer: ${x}`); + }); ; ) { + let x = 0, O = !0; + for (let R = p; R < y.length; R++) { + const P = y[R], S = l * x + P; + if (!Number.isSafeInteger(S) || l * x / l !== x || S - P !== l * x) + throw new Error("convertRadix: carry overflow"); + if (x = S % u, y[R] = Math.floor(S / u), !Number.isSafeInteger(y[R]) || y[R] * u + x !== S) + throw new Error("convertRadix: carry overflow"); + if (O) + y[R] ? O = !1 : p = R; + else continue; + } + if (f.push(x), O) + break; + } + for (let x = 0; x < d.length - 1 && d[x] === 0; x++) + f.push(0); + return f.reverse(); + } + const a = (d, l) => l ? a(l, d % l) : d, h = (d, l) => d + (l - a(d, l)); + function w(d, l, u, p) { + if (!Array.isArray(d)) + throw new Error("convertRadix2: data should be array"); + if (l <= 0 || l > 32) + throw new Error(`convertRadix2: wrong from=${l}`); + if (u <= 0 || u > 32) + throw new Error(`convertRadix2: wrong to=${u}`); + if (h(l, u) > 32) + throw new Error(`convertRadix2: carry overflow from=${l} to=${u} carryBits=${h(l, u)}`); + let f = 0, y = 0; + const x = 2 ** u - 1, O = []; + for (const R of d) { + if (t(R), R >= 2 ** l) + throw new Error(`convertRadix2: invalid data word=${R} from=${l}`); + if (f = f << l | R, y + l > 32) + throw new Error(`convertRadix2: carry overflow pos=${y} from=${l}`); + for (y += l; y >= u; y -= u) + O.push((f >> y - u & x) >>> 0); + f &= 2 ** y - 1; + } + if (f = f << u - y & x, !p && y >= l) + throw new Error("Excess padding"); + if (!p && f) + throw new Error(`Non-zero padding: ${f}`); + return p && y > 0 && O.push(f >>> 0), O; + } + function g(d) { + return t(d), { + encode: (l) => { + if (!(l instanceof Uint8Array)) + throw new Error("radix.encode input should be Uint8Array"); + return c(Array.from(l), 2 ** 8, d); + }, + decode: (l) => { + if (!Array.isArray(l) || l.length && typeof l[0] != "number") + throw new Error("radix.decode input should be array of strings"); + return Uint8Array.from(c(l, d, 2 ** 8)); + } + }; + } + function v(d, l = !1) { + if (t(d), d <= 0 || d > 32) + throw new Error("radix2: bits should be in (0..32]"); + if (h(8, d) > 32 || h(d, 8) > 32) + throw new Error("radix2: carry overflow"); + return { + encode: (u) => { + if (!(u instanceof Uint8Array)) + throw new Error("radix2.encode input should be Uint8Array"); + return w(Array.from(u), 8, d, !l); + }, + decode: (u) => { + if (!Array.isArray(u) || u.length && typeof u[0] != "number") + throw new Error("radix2.decode input should be array of strings"); + return Uint8Array.from(w(u, d, 8, l)); + } + }; + } + function b(d) { + if (typeof d != "function") + throw new Error("unsafeWrapper fn should be function"); + return function(...l) { + try { + return d.apply(null, l); + } catch { + } + }; + } + function C(d, l) { + if (t(d), typeof l != "function") + throw new Error("checksum fn should be function"); + return { + encode(u) { + if (!(u instanceof Uint8Array)) + throw new Error("checksum.encode: input should be Uint8Array"); + const p = l(u).slice(0, d), f = new Uint8Array(u.length + d); + return f.set(u), f.set(p, u.length), f; + }, + decode(u) { + if (!(u instanceof Uint8Array)) + throw new Error("checksum.decode: input should be Uint8Array"); + const p = u.slice(0, -d), f = l(p).slice(0, d), y = u.slice(-d); + for (let x = 0; x < d; x++) + if (f[x] !== y[x]) + throw new Error("Invalid checksum"); + return p; + } + }; + } + e.utils = { alphabet: r, chain: n, checksum: C, radix: g, radix2: v, join: o, padding: i }, e.base16 = n(v(4), r("0123456789ABCDEF"), o("")), e.base32 = n(v(5), r("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), i(5), o("")), e.base32hex = n(v(5), r("0123456789ABCDEFGHIJKLMNOPQRSTUV"), i(5), o("")), e.base32crockford = n(v(5), r("0123456789ABCDEFGHJKMNPQRSTVWXYZ"), o(""), s((d) => d.toUpperCase().replace(/O/g, "0").replace(/[IL]/g, "1"))), e.base64 = n(v(6), r("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), i(6), o("")), e.base64url = n(v(6), r("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), i(6), o("")); + const L = (d) => n(g(58), r(d), o("")); + e.base58 = L("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"), e.base58flickr = L("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"), e.base58xrp = L("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"); + const M = [0, 2, 3, 5, 6, 7, 9, 10, 11]; + e.base58xmr = { + encode(d) { + let l = ""; + for (let u = 0; u < d.length; u += 8) { + const p = d.subarray(u, u + 8); + l += e.base58.encode(p).padStart(M[p.length], "1"); + } + return l; + }, + decode(d) { + let l = []; + for (let u = 0; u < d.length; u += 11) { + const p = d.slice(u, u + 11), f = M.indexOf(p.length), y = e.base58.decode(p); + for (let x = 0; x < y.length - f; x++) + if (y[x] !== 0) + throw new Error("base58xmr: wrong padding"); + l = l.concat(Array.from(y.slice(y.length - f))); + } + return Uint8Array.from(l); + } + }; + const I = (d) => n(C(4, (l) => d(d(l))), e.base58); + e.base58check = I; + const U = n(r("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), o("")), q = [996825010, 642813549, 513874426, 1027748829, 705979059]; + function Q(d) { + const l = d >> 25; + let u = (d & 33554431) << 5; + for (let p = 0; p < q.length; p++) + (l >> p & 1) === 1 && (u ^= q[p]); + return u; + } + function A(d, l, u = 1) { + const p = d.length; + let f = 1; + for (let y = 0; y < p; y++) { + const x = d.charCodeAt(y); + if (x < 33 || x > 126) + throw new Error(`Invalid prefix (${d})`); + f = Q(f) ^ x >> 5; + } + f = Q(f); + for (let y = 0; y < p; y++) + f = Q(f) ^ d.charCodeAt(y) & 31; + for (let y of l) + f = Q(f) ^ y; + for (let y = 0; y < 6; y++) + f = Q(f); + return f ^= u, U.encode(w([f % 2 ** 30], 30, 5, !1)); + } + function _(d) { + const l = d === "bech32" ? 1 : 734539939, u = v(5), p = u.decode, f = u.encode, y = b(p); + function x(S, D, J = 90) { + if (typeof S != "string") + throw new Error(`bech32.encode prefix should be string, not ${typeof S}`); + if (!Array.isArray(D) || D.length && typeof D[0] != "number") + throw new Error(`bech32.encode words should be array of numbers, not ${typeof D}`); + const Y = S.length + 7 + D.length; + if (J !== !1 && Y > J) + throw new TypeError(`Length ${Y} exceeds limit ${J}`); + return S = S.toLowerCase(), `${S}1${U.encode(D)}${A(S, D, l)}`; + } + function O(S, D = 90) { + if (typeof S != "string") + throw new Error(`bech32.decode input should be string, not ${typeof S}`); + if (S.length < 8 || D !== !1 && S.length > D) + throw new TypeError(`Wrong string length: ${S.length} (${S}). Expected (8..${D})`); + const J = S.toLowerCase(); + if (S !== J && S !== S.toUpperCase()) + throw new Error("String must be lowercase or uppercase"); + S = J; + const Y = S.lastIndexOf("1"); + if (Y === 0 || Y === -1) + throw new Error('Letter "1" must be present between prefix and data only'); + const G = S.slice(0, Y), X = S.slice(Y + 1); + if (X.length < 6) + throw new Error("Data must be at least 6 characters long"); + const ie = U.decode(X).slice(0, -6), N = A(G, ie, l); + if (!X.endsWith(N)) + throw new Error(`Invalid checksum in ${S}: expected "${N}"`); + return { prefix: G, words: ie }; + } + const R = b(O); + function P(S) { + const { prefix: D, words: J } = O(S, !1); + return { prefix: D, words: J, bytes: p(J) }; + } + return { encode: x, decode: O, decodeToBytes: P, decodeUnsafe: R, fromWords: p, fromWordsUnsafe: y, toWords: f }; + } + e.bech32 = _("bech32"), e.bech32m = _("bech32m"), e.utf8 = { + encode: (d) => new TextDecoder().decode(d), + decode: (d) => new TextEncoder().encode(d) + }, e.hex = n(v(4), r("0123456789abcdef"), o(""), s((d) => { + if (typeof d != "string" || d.length % 2) + throw new TypeError(`hex.decode: expected string, got ${typeof d} with length ${d.length}`); + return d.toLowerCase(); + })); + const E = { + utf8: e.utf8, + hex: e.hex, + base16: e.base16, + base32: e.base32, + base64: e.base64, + base64url: e.base64url, + base58: e.base58, + base58xmr: e.base58xmr + }, T = `Invalid encoding type. Available types: ${Object.keys(E).join(", ")}`, m = (d, l) => { + if (typeof d != "string" || !E.hasOwnProperty(d)) + throw new TypeError(T); + if (!(l instanceof Uint8Array)) + throw new TypeError("bytesToString() expects Uint8Array"); + return E[d].encode(l); + }; + e.bytesToString = m, e.str = e.bytesToString; + const k = (d, l) => { + if (!E.hasOwnProperty(d)) + throw new TypeError(T); + if (typeof l != "string") + throw new TypeError("stringToBytes() expects string"); + return E[d].decode(l); + }; + e.stringToBytes = k, e.bytes = e.stringToBytes; + })(qr)), qr; +} +var Kr, Bs; +function J4() { + if (Bs) return Kr; + Bs = 1; + const { bech32: e, hex: t, utf8: n } = Q4(), r = { + // default network is bitcoin + bech32: "bc", + pubKeyHash: 0, + scriptHash: 5, + validWitnessVersions: [0] + }, o = { + bech32: "tb", + pubKeyHash: 111, + scriptHash: 196, + validWitnessVersions: [0] + }, i = { + bech32: "tbs", + pubKeyHash: 111, + scriptHash: 196, + validWitnessVersions: [0] + }, s = { + bech32: "bcrt", + pubKeyHash: 111, + scriptHash: 196, + validWitnessVersions: [0] + }, c = { + bech32: "sb", + pubKeyHash: 63, + scriptHash: 123, + validWitnessVersions: [0] + }, a = [ + "option_data_loss_protect", + "initial_routing_sync", + "option_upfront_shutdown_script", + "gossip_queries", + "var_onion_optin", + "gossip_queries_ex", + "option_static_remotekey", + "payment_secret", + "basic_mpp", + "option_support_large_channel" + ], h = { + m: BigInt(1e3), + u: BigInt(1e6), + n: BigInt(1e9), + p: BigInt(1e12) + }, w = BigInt("2100000000000000000"), g = BigInt(1e11), v = { + payment_hash: 1, + payment_secret: 16, + description: 13, + payee: 19, + description_hash: 23, + // commit to longer descriptions (used by lnurl-pay) + expiry: 6, + // default: 3600 (1 hour) + min_final_cltv_expiry: 24, + // default: 9 + fallback_address: 9, + route_hint: 3, + // for extra routing info (private etc.) + feature_bits: 5, + metadata: 27 + }, b = {}; + for (let A = 0, _ = Object.keys(v); A < _.length; A++) { + const E = _[A], T = v[_[A]].toString(); + b[T] = E; + } + const C = { + 1: (A) => t.encode(e.fromWordsUnsafe(A)), + // 256 bits + 16: (A) => t.encode(e.fromWordsUnsafe(A)), + // 256 bits + 13: (A) => n.encode(e.fromWordsUnsafe(A)), + // string variable length + 19: (A) => t.encode(e.fromWordsUnsafe(A)), + // 264 bits + 23: (A) => t.encode(e.fromWordsUnsafe(A)), + // 256 bits + 27: (A) => t.encode(e.fromWordsUnsafe(A)), + // variable + 6: M, + // default: 3600 (1 hour) + 24: M, + // default: 9 + 3: I, + // for extra routing info (private etc.) + 5: U + // keep feature bits as array of 5 bit words + }; + function L(A) { + return (_) => ({ + tagCode: parseInt(A), + words: e.encode("unknown", _, Number.MAX_SAFE_INTEGER) + }); + } + function M(A) { + return A.reverse().reduce((_, E, T) => _ + E * Math.pow(32, T), 0); + } + function I(A) { + const _ = []; + let E, T, m, k, d, l = e.fromWordsUnsafe(A); + for (; l.length > 0; ) + E = t.encode(l.slice(0, 33)), T = t.encode(l.slice(33, 41)), m = parseInt(t.encode(l.slice(41, 45)), 16), k = parseInt( + t.encode(l.slice(45, 49)), + 16 + ), d = parseInt(t.encode(l.slice(49, 51)), 16), l = l.slice(51), _.push({ + pubkey: E, + short_channel_id: T, + fee_base_msat: m, + fee_proportional_millionths: k, + cltv_expiry_delta: d + }); + return _; + } + function U(A) { + const _ = A.slice().reverse().map((m) => [ + !!(m & 1), + !!(m & 2), + !!(m & 4), + !!(m & 8), + !!(m & 16) + ]).reduce((m, k) => m.concat(k), []); + for (; _.length < a.length * 2; ) + _.push(!1); + const E = {}; + a.forEach((m, k) => { + let d; + _[k * 2] ? d = "required" : _[k * 2 + 1] ? d = "supported" : d = "unsupported", E[m] = d; + }); + const T = _.slice(a.length * 2); + return E.extra_bits = { + start_bit: a.length * 2, + bits: T, + has_required: T.reduce( + (m, k, d) => d % 2 !== 0 ? m || !1 : m || k, + !1 + ) + }, E; + } + function q(A, _) { + let E, T; + if (A.slice(-1).match(/^[munp]$/)) + E = A.slice(-1), T = A.slice(0, -1); + else { + if (A.slice(-1).match(/^[^munp0-9]$/)) + throw new Error("Not a valid multiplier for the amount"); + T = A; + } + if (!T.match(/^\d+$/)) + throw new Error("Not a valid human readable amount"); + const m = BigInt(T), k = E ? m * g / h[E] : m * g; + if (E === "p" && m % BigInt(10) !== BigInt(0) || k > w) + throw new Error("Amount is outside of valid range"); + return _ ? k.toString() : k; + } + function Q(A, _) { + if (typeof A != "string") + throw new Error("Lightning Payment Request must be string"); + if (A.slice(0, 2).toLowerCase() !== "ln") + throw new Error("Not a proper lightning payment request"); + const E = [], T = e.decode(A, Number.MAX_SAFE_INTEGER); + A = A.toLowerCase(); + const m = T.prefix; + let k = T.words, d = A.slice(m.length + 1), l = k.slice(-104); + k = k.slice(0, -104); + let u = m.match(/^ln(\S+?)(\d*)([a-zA-Z]?)$/); + if (u && !u[2] && (u = m.match(/^ln(\S+)$/)), !u) + throw new Error("Not a proper lightning payment request"); + E.push({ + name: "lightning_network", + letters: "ln" + }); + const p = u[1]; + let f; + if (_) { + if (_.bech32 === void 0 || _.pubKeyHash === void 0 || _.scriptHash === void 0 || !Array.isArray(_.validWitnessVersions)) + throw new Error("Invalid network"); + f = _; + } else + switch (p) { + case r.bech32: + f = r; + break; + case o.bech32: + f = o; + break; + case i.bech32: + f = i; + break; + case s.bech32: + f = s; + break; + case c.bech32: + f = c; + break; + } + if (!f || f.bech32 !== p) + throw new Error("Unknown coin bech32 prefix"); + E.push({ + name: "coin_network", + letters: p, + value: f + }); + const y = u[2]; + let x; + if (y) { + const G = u[3]; + x = q(y + G, !0), E.push({ + name: "amount", + letters: u[2] + u[3], + value: x + }); + } else + x = null; + E.push({ + name: "separator", + letters: "1" + }); + const O = M(k.slice(0, 7)); + k = k.slice(7), E.push({ + name: "timestamp", + letters: d.slice(0, 7), + value: O + }), d = d.slice(7); + let R, P, S, D; + for (; k.length > 0; ) { + const G = k[0].toString(); + R = b[G] || "unknown_tag", P = C[G] || L(G), k = k.slice(1), S = M(k.slice(0, 2)), k = k.slice(2), D = k.slice(0, S), k = k.slice(S), E.push({ + name: R, + tag: d[0], + letters: d.slice(0, 3 + S), + value: P(D) + // see: parsers for more comments + }), d = d.slice(3 + S); + } + E.push({ + name: "signature", + letters: d.slice(0, 104), + value: t.encode(e.fromWordsUnsafe(l)) + }), d = d.slice(104), E.push({ + name: "checksum", + letters: d + }); + let J = { + paymentRequest: A, + sections: E, + get expiry() { + let G = E.find((X) => X.name === "expiry"); + if (G) return Y("timestamp") + G.value; + }, + get route_hints() { + return E.filter((G) => G.name === "route_hint").map((G) => G.value); + } + }; + for (let G in v) + G !== "route_hint" && Object.defineProperty(J, G, { + get() { + return Y(G); + } + }); + return J; + function Y(G) { + let X = E.find((ie) => ie.name === G); + return X ? X.value : void 0; + } + } + return Kr = { + decode: Q, + hrpToMillisat: q + }, Kr; +} +var Y4 = J4(); +const X4 = (e) => Uint8Array.from(e.match(/.{1,2}/g).map((t) => parseInt(t, 16))), e3 = (e) => { + if (!e) + return null; + try { + const t = Y4.decode(e); + if (!t || !t.sections) + return null; + const n = t.sections.find((C) => C.name === "payment_hash"); + if (n?.name !== "payment_hash" || !n.value) + return null; + const r = n.value; + let o = 0, i = 0, s = "0"; + const c = t.sections.find((C) => C.name === "amount"); + c?.name === "amount" && c.value && (s = c.value, i = parseInt(c.value), o = parseInt(c.value) / 1e3); + const a = t.sections.find((C) => C.name === "timestamp"); + if (a?.name !== "timestamp" || !a.value) + return null; + const h = a.value; + let w; + const g = t.sections.find((C) => C.name === "expiry"); + g?.name === "expiry" && (w = g.value); + const v = t.sections.find((C) => C.name === "description"), b = v?.name === "description" ? v?.value : void 0; + return { + paymentHash: r, + satoshi: o, + millisatoshi: i, + amountRaw: s, + timestamp: h, + expiry: w, + description: b + }; + } catch { + return null; + } +}; +function t3(e, t) { + try { + if (!/^[0-9a-fA-F]{64}$/.test(e) || !/^[0-9a-fA-F]{64}$/.test(t)) + return !1; + const n = H4(K4(X4(e))); + return t === n; + } catch { + return !1; + } +} +class n3 { + constructor(t) { + if (this.paymentRequest = t.pr, !this.paymentRequest) + throw new Error("Invalid payment request"); + const n = e3(this.paymentRequest); + if (!n) + throw new Error("Failed to decode payment request"); + this.paymentHash = n.paymentHash, this.satoshi = n.satoshi, this.millisatoshi = n.millisatoshi, this.amountRaw = n.amountRaw, this.timestamp = n.timestamp, this.expiry = n.expiry, this.createdDate = new Date(this.timestamp * 1e3), this.expiryDate = this.expiry ? new Date((this.timestamp + this.expiry) * 1e3) : void 0, this.description = n.description ?? null, this.verify = t.verify ?? null, this.preimage = t.preimage ?? null, this.successAction = t.successAction ?? null; + } + async isPaid() { + if (this.preimage) + return this.validatePreimage(this.preimage); + if (this.verify) + return await this.verifyPayment(); + throw new Error("Could not verify payment"); + } + validatePreimage(t) { + return !t || !this.paymentHash ? !1 : t3(t, this.paymentHash); + } + async verifyPayment() { + try { + if (!this.verify) + throw new Error("LNURL verify not available"); + const t = await fetch(this.verify); + if (!t.ok) + throw new Error(`Verification request failed: ${t.status} ${t.statusText}`); + const n = await t.json(); + return n.preimage && (this.preimage = n.preimage), n.settled; + } catch (t) { + return console.error("Failed to check LNURL-verify", t), !1; + } + } + hasExpired() { + const { expiryDate: t } = this; + return t ? t.getTime() < Date.now() : !1; + } +} +const r3 = 1e8, o3 = async (e) => { + const t = "https://getalby.com/api/rates/" + e.toLowerCase() + ".json", n = await fetch(t); + if (!n.ok) + throw new Error(`Failed to fetch rate: ${n.status} ${n.statusText}`); + return (await n.json()).rate_float / r3; +}, i3 = async ({ satoshi: e, currency: t }) => { + const n = await o3(t); + return Number(e) * n; +}; +var Qr = { exports: {} }, Rs; +function s3() { + return Rs || (Rs = 1, (function(e, t) { + var n = (function() { + var r = function(A, _) { + var E = 236, T = 17, m = A, k = i[_], d = null, l = 0, u = null, p = [], f = {}, y = function(N, $) { + l = m * 4 + 17, d = (function(B) { + for (var H = new Array(B), Z = 0; Z < B; Z += 1) { + H[Z] = new Array(B); + for (var K = 0; K < B; K += 1) + H[Z][K] = null; + } + return H; + })(l), x(0, 0), x(l - 7, 0), x(0, l - 7), P(), R(), D(N, $), m >= 7 && S(N), u == null && (u = G(m, k, p)), J(u, $); + }, x = function(N, $) { + for (var B = -1; B <= 7; B += 1) + if (!(N + B <= -1 || l <= N + B)) + for (var H = -1; H <= 7; H += 1) + $ + H <= -1 || l <= $ + H || (0 <= B && B <= 6 && (H == 0 || H == 6) || 0 <= H && H <= 6 && (B == 0 || B == 6) || 2 <= B && B <= 4 && 2 <= H && H <= 4 ? d[N + B][$ + H] = !0 : d[N + B][$ + H] = !1); + }, O = function() { + for (var N = 0, $ = 0, B = 0; B < 8; B += 1) { + y(!0, B); + var H = c.getLostPoint(f); + (B == 0 || N > H) && (N = H, $ = B); + } + return $; + }, R = function() { + for (var N = 8; N < l - 8; N += 1) + d[N][6] == null && (d[N][6] = N % 2 == 0); + for (var $ = 8; $ < l - 8; $ += 1) + d[6][$] == null && (d[6][$] = $ % 2 == 0); + }, P = function() { + for (var N = c.getPatternPosition(m), $ = 0; $ < N.length; $ += 1) + for (var B = 0; B < N.length; B += 1) { + var H = N[$], Z = N[B]; + if (d[H][Z] == null) + for (var K = -2; K <= 2; K += 1) + for (var te = -2; te <= 2; te += 1) + K == -2 || K == 2 || te == -2 || te == 2 || K == 0 && te == 0 ? d[H + K][Z + te] = !0 : d[H + K][Z + te] = !1; + } + }, S = function(N) { + for (var $ = c.getBCHTypeNumber(m), B = 0; B < 18; B += 1) { + var H = !N && ($ >> B & 1) == 1; + d[Math.floor(B / 3)][B % 3 + l - 8 - 3] = H; + } + for (var B = 0; B < 18; B += 1) { + var H = !N && ($ >> B & 1) == 1; + d[B % 3 + l - 8 - 3][Math.floor(B / 3)] = H; + } + }, D = function(N, $) { + for (var B = k << 3 | $, H = c.getBCHTypeInfo(B), Z = 0; Z < 15; Z += 1) { + var K = !N && (H >> Z & 1) == 1; + Z < 6 ? d[Z][8] = K : Z < 8 ? d[Z + 1][8] = K : d[l - 15 + Z][8] = K; + } + for (var Z = 0; Z < 15; Z += 1) { + var K = !N && (H >> Z & 1) == 1; + Z < 8 ? d[8][l - Z - 1] = K : Z < 9 ? d[8][15 - Z - 1 + 1] = K : d[8][15 - Z - 1] = K; + } + d[l - 8][8] = !N; + }, J = function(N, $) { + for (var B = -1, H = l - 1, Z = 7, K = 0, te = c.getMaskFunction($), ee = l - 1; ee > 0; ee -= 2) + for (ee == 6 && (ee -= 1); ; ) { + for (var ge = 0; ge < 2; ge += 1) + if (d[H][ee - ge] == null) { + var ve = !1; + K < N.length && (ve = (N[K] >>> Z & 1) == 1); + var ne = te(H, ee - ge); + ne && (ve = !ve), d[H][ee - ge] = ve, Z -= 1, Z == -1 && (K += 1, Z = 7); + } + if (H += B, H < 0 || l <= H) { + H -= B, B = -B; + break; + } + } + }, Y = function(N, $) { + for (var B = 0, H = 0, Z = 0, K = new Array($.length), te = new Array($.length), ee = 0; ee < $.length; ee += 1) { + var ge = $[ee].dataCount, ve = $[ee].totalCount - ge; + H = Math.max(H, ge), Z = Math.max(Z, ve), K[ee] = new Array(ge); + for (var ne = 0; ne < K[ee].length; ne += 1) + K[ee][ne] = 255 & N.getBuffer()[ne + B]; + B += ge; + var Ue = c.getErrorCorrectPolynomial(ve), Oe = h(K[ee], Ue.getLength() - 1), Ji = Oe.mod(Ue); + te[ee] = new Array(Ue.getLength() - 1); + for (var ne = 0; ne < te[ee].length; ne += 1) { + var Yi = ne + Ji.getLength() - te[ee].length; + te[ee][ne] = Yi >= 0 ? Ji.getAt(Yi) : 0; + } + } + for (var Xi = 0, ne = 0; ne < $.length; ne += 1) + Xi += $[ne].totalCount; + for (var Br = new Array(Xi), Bn = 0, ne = 0; ne < H; ne += 1) + for (var ee = 0; ee < $.length; ee += 1) + ne < K[ee].length && (Br[Bn] = K[ee][ne], Bn += 1); + for (var ne = 0; ne < Z; ne += 1) + for (var ee = 0; ee < $.length; ee += 1) + ne < te[ee].length && (Br[Bn] = te[ee][ne], Bn += 1); + return Br; + }, G = function(N, $, B) { + for (var H = w.getRSBlocks(N, $), Z = g(), K = 0; K < B.length; K += 1) { + var te = B[K]; + Z.put(te.getMode(), 4), Z.put(te.getLength(), c.getLengthInBits(te.getMode(), N)), te.write(Z); + } + for (var ee = 0, K = 0; K < H.length; K += 1) + ee += H[K].dataCount; + if (Z.getLengthInBits() > ee * 8) + throw "code length overflow. (" + Z.getLengthInBits() + ">" + ee * 8 + ")"; + for (Z.getLengthInBits() + 4 <= ee * 8 && Z.put(0, 4); Z.getLengthInBits() % 8 != 0; ) + Z.putBit(!1); + for (; !(Z.getLengthInBits() >= ee * 8 || (Z.put(E, 8), Z.getLengthInBits() >= ee * 8)); ) + Z.put(T, 8); + return Y(Z, H); + }; + f.addData = function(N, $) { + $ = $ || "Byte"; + var B = null; + switch ($) { + case "Numeric": + B = v(N); + break; + case "Alphanumeric": + B = b(N); + break; + case "Byte": + B = C(N); + break; + case "Kanji": + B = L(N); + break; + default: + throw "mode:" + $; + } + p.push(B), u = null; + }, f.isDark = function(N, $) { + if (N < 0 || l <= N || $ < 0 || l <= $) + throw N + "," + $; + return d[N][$]; + }, f.getModuleCount = function() { + return l; + }, f.make = function() { + if (m < 1) { + for (var N = 1; N < 40; N++) { + for (var $ = w.getRSBlocks(N, k), B = g(), H = 0; H < p.length; H++) { + var Z = p[H]; + B.put(Z.getMode(), 4), B.put(Z.getLength(), c.getLengthInBits(Z.getMode(), N)), Z.write(B); + } + for (var K = 0, H = 0; H < $.length; H++) + K += $[H].dataCount; + if (B.getLengthInBits() <= K * 8) + break; + } + m = N; + } + y(!1, O()); + }, f.createTableTag = function(N, $) { + N = N || 2, $ = typeof $ > "u" ? N * 4 : $; + var B = ""; + B += ' "u" ? N * 4 : $, B = typeof B == "string" ? { text: B } : B || {}, B.text = B.text || null, B.id = B.text ? B.id || "qrcode-description" : null, H = typeof H == "string" ? { text: H } : H || {}, H.text = H.text || null, H.id = H.text ? H.id || "qrcode-title" : null; + var K = f.getModuleCount() * N + $ * 2, te, ee, ge, ve, ne = "", Ue; + for (Ue = "l" + N + ",0 0," + N + " -" + N + ",0 0,-" + N + "z ", ne += '' + X(H.text) + "" : "", ne += B.text ? '' + X(B.text) + "" : "", ne += '', ne += ' "u" ? N * 4 : $; + var B = f.getModuleCount() * N + $ * 2, H = $, Z = B - $; + return Q(B, B, function(K, te) { + if (H <= K && K < Z && H <= te && te < Z) { + var ee = Math.floor((K - H) / N), ge = Math.floor((te - H) / N); + return f.isDark(ge, ee) ? 0 : 1; + } else + return 1; + }); + }, f.createImgTag = function(N, $, B) { + N = N || 2, $ = typeof $ > "u" ? N * 4 : $; + var H = f.getModuleCount() * N + $ * 2, Z = ""; + return Z += "": + $ += ">"; + break; + case "&": + $ += "&"; + break; + case '"': + $ += """; + break; + default: + $ += H; + break; + } + } + return $; + }, ie = function(N) { + var $ = 1; + N = typeof N > "u" ? $ * 2 : N; + var B = f.getModuleCount() * $ + N * 2, H = N, Z = B - N, K, te, ee, ge, ve, ne = { + "██": "█", + "█ ": "▀", + " █": "▄", + " ": " " + }, Ue = { + "██": "▀", + "█ ": "▀", + " █": " ", + " ": " " + }, Oe = ""; + for (K = 0; K < B; K += 2) { + for (ee = Math.floor((K - H) / $), ge = Math.floor((K + 1 - H) / $), te = 0; te < B; te += 1) + ve = "█", H <= te && te < Z && H <= K && K < Z && f.isDark(ee, Math.floor((te - H) / $)) && (ve = " "), H <= te && te < Z && H <= K + 1 && K + 1 < Z && f.isDark(ge, Math.floor((te - H) / $)) ? ve += " " : ve += "█", Oe += N < 1 && K + 1 >= Z ? Ue[ve] : ne[ve]; + Oe += ` +`; + } + return B % 2 && N > 0 ? Oe.substring(0, Oe.length - B - 1) + Array(B + 1).join("▀") : Oe.substring(0, Oe.length - 1); + }; + return f.createASCII = function(N, $) { + if (N = N || 1, N < 2) + return ie($); + N -= 1, $ = typeof $ > "u" ? N * 2 : $; + var B = f.getModuleCount() * N + $ * 2, H = $, Z = B - $, K, te, ee, ge, ve = Array(N + 1).join("██"), ne = Array(N + 1).join(" "), Ue = "", Oe = ""; + for (K = 0; K < B; K += 1) { + for (ee = Math.floor((K - H) / N), Oe = "", te = 0; te < B; te += 1) + ge = 1, H <= te && te < Z && H <= K && K < Z && f.isDark(ee, Math.floor((te - H) / N)) && (ge = 0), Oe += ge ? ve : ne; + for (ee = 0; ee < N; ee += 1) + Ue += Oe + ` +`; + } + return Ue.substring(0, Ue.length - 1); + }, f.renderTo2dContext = function(N, $) { + $ = $ || 2; + for (var B = f.getModuleCount(), H = 0; H < B; H++) + for (var Z = 0; Z < B; Z++) + N.fillStyle = f.isDark(H, Z) ? "black" : "white", N.fillRect(H * $, Z * $, $, $); + }, f; + }; + r.stringToBytesFuncs = { + default: function(A) { + for (var _ = [], E = 0; E < A.length; E += 1) { + var T = A.charCodeAt(E); + _.push(T & 255); + } + return _; + } + }, r.stringToBytes = r.stringToBytesFuncs.default, r.createStringToBytes = function(A, _) { + var E = (function() { + for (var m = U(A), k = function() { + var R = m.read(); + if (R == -1) throw "eof"; + return R; + }, d = 0, l = {}; ; ) { + var u = m.read(); + if (u == -1) break; + var p = k(), f = k(), y = k(), x = String.fromCharCode(u << 8 | p), O = f << 8 | y; + l[x] = O, d += 1; + } + if (d != _) + throw d + " != " + _; + return l; + })(), T = 63; + return function(m) { + for (var k = [], d = 0; d < m.length; d += 1) { + var l = m.charCodeAt(d); + if (l < 128) + k.push(l); + else { + var u = E[m.charAt(d)]; + typeof u == "number" ? (u & 255) == u ? k.push(u) : (k.push(u >>> 8), k.push(u & 255)) : k.push(T); + } + } + return k; + }; + }; + var o = { + MODE_NUMBER: 1, + MODE_ALPHA_NUM: 2, + MODE_8BIT_BYTE: 4, + MODE_KANJI: 8 + }, i = { + L: 1, + M: 0, + Q: 3, + H: 2 + }, s = { + PATTERN000: 0, + PATTERN001: 1, + PATTERN010: 2, + PATTERN011: 3, + PATTERN100: 4, + PATTERN101: 5, + PATTERN110: 6, + PATTERN111: 7 + }, c = (function() { + var A = [ + [], + [6, 18], + [6, 22], + [6, 26], + [6, 30], + [6, 34], + [6, 22, 38], + [6, 24, 42], + [6, 26, 46], + [6, 28, 50], + [6, 30, 54], + [6, 32, 58], + [6, 34, 62], + [6, 26, 46, 66], + [6, 26, 48, 70], + [6, 26, 50, 74], + [6, 30, 54, 78], + [6, 30, 56, 82], + [6, 30, 58, 86], + [6, 34, 62, 90], + [6, 28, 50, 72, 94], + [6, 26, 50, 74, 98], + [6, 30, 54, 78, 102], + [6, 28, 54, 80, 106], + [6, 32, 58, 84, 110], + [6, 30, 58, 86, 114], + [6, 34, 62, 90, 118], + [6, 26, 50, 74, 98, 122], + [6, 30, 54, 78, 102, 126], + [6, 26, 52, 78, 104, 130], + [6, 30, 56, 82, 108, 134], + [6, 34, 60, 86, 112, 138], + [6, 30, 58, 86, 114, 142], + [6, 34, 62, 90, 118, 146], + [6, 30, 54, 78, 102, 126, 150], + [6, 24, 50, 76, 102, 128, 154], + [6, 28, 54, 80, 106, 132, 158], + [6, 32, 58, 84, 110, 136, 162], + [6, 26, 54, 82, 110, 138, 166], + [6, 30, 58, 86, 114, 142, 170] + ], _ = 1335, E = 7973, T = 21522, m = {}, k = function(d) { + for (var l = 0; d != 0; ) + l += 1, d >>>= 1; + return l; + }; + return m.getBCHTypeInfo = function(d) { + for (var l = d << 10; k(l) - k(_) >= 0; ) + l ^= _ << k(l) - k(_); + return (d << 10 | l) ^ T; + }, m.getBCHTypeNumber = function(d) { + for (var l = d << 12; k(l) - k(E) >= 0; ) + l ^= E << k(l) - k(E); + return d << 12 | l; + }, m.getPatternPosition = function(d) { + return A[d - 1]; + }, m.getMaskFunction = function(d) { + switch (d) { + case s.PATTERN000: + return function(l, u) { + return (l + u) % 2 == 0; + }; + case s.PATTERN001: + return function(l, u) { + return l % 2 == 0; + }; + case s.PATTERN010: + return function(l, u) { + return u % 3 == 0; + }; + case s.PATTERN011: + return function(l, u) { + return (l + u) % 3 == 0; + }; + case s.PATTERN100: + return function(l, u) { + return (Math.floor(l / 2) + Math.floor(u / 3)) % 2 == 0; + }; + case s.PATTERN101: + return function(l, u) { + return l * u % 2 + l * u % 3 == 0; + }; + case s.PATTERN110: + return function(l, u) { + return (l * u % 2 + l * u % 3) % 2 == 0; + }; + case s.PATTERN111: + return function(l, u) { + return (l * u % 3 + (l + u) % 2) % 2 == 0; + }; + default: + throw "bad maskPattern:" + d; + } + }, m.getErrorCorrectPolynomial = function(d) { + for (var l = h([1], 0), u = 0; u < d; u += 1) + l = l.multiply(h([1, a.gexp(u)], 0)); + return l; + }, m.getLengthInBits = function(d, l) { + if (1 <= l && l < 10) + switch (d) { + case o.MODE_NUMBER: + return 10; + case o.MODE_ALPHA_NUM: + return 9; + case o.MODE_8BIT_BYTE: + return 8; + case o.MODE_KANJI: + return 8; + default: + throw "mode:" + d; + } + else if (l < 27) + switch (d) { + case o.MODE_NUMBER: + return 12; + case o.MODE_ALPHA_NUM: + return 11; + case o.MODE_8BIT_BYTE: + return 16; + case o.MODE_KANJI: + return 10; + default: + throw "mode:" + d; + } + else if (l < 41) + switch (d) { + case o.MODE_NUMBER: + return 14; + case o.MODE_ALPHA_NUM: + return 13; + case o.MODE_8BIT_BYTE: + return 16; + case o.MODE_KANJI: + return 12; + default: + throw "mode:" + d; + } + else + throw "type:" + l; + }, m.getLostPoint = function(d) { + for (var l = d.getModuleCount(), u = 0, p = 0; p < l; p += 1) + for (var f = 0; f < l; f += 1) { + for (var y = 0, x = d.isDark(p, f), O = -1; O <= 1; O += 1) + if (!(p + O < 0 || l <= p + O)) + for (var R = -1; R <= 1; R += 1) + f + R < 0 || l <= f + R || O == 0 && R == 0 || x == d.isDark(p + O, f + R) && (y += 1); + y > 5 && (u += 3 + y - 5); + } + for (var p = 0; p < l - 1; p += 1) + for (var f = 0; f < l - 1; f += 1) { + var P = 0; + d.isDark(p, f) && (P += 1), d.isDark(p + 1, f) && (P += 1), d.isDark(p, f + 1) && (P += 1), d.isDark(p + 1, f + 1) && (P += 1), (P == 0 || P == 4) && (u += 3); + } + for (var p = 0; p < l; p += 1) + for (var f = 0; f < l - 6; f += 1) + d.isDark(p, f) && !d.isDark(p, f + 1) && d.isDark(p, f + 2) && d.isDark(p, f + 3) && d.isDark(p, f + 4) && !d.isDark(p, f + 5) && d.isDark(p, f + 6) && (u += 40); + for (var f = 0; f < l; f += 1) + for (var p = 0; p < l - 6; p += 1) + d.isDark(p, f) && !d.isDark(p + 1, f) && d.isDark(p + 2, f) && d.isDark(p + 3, f) && d.isDark(p + 4, f) && !d.isDark(p + 5, f) && d.isDark(p + 6, f) && (u += 40); + for (var S = 0, f = 0; f < l; f += 1) + for (var p = 0; p < l; p += 1) + d.isDark(p, f) && (S += 1); + var D = Math.abs(100 * S / l / l - 50) / 5; + return u += D * 10, u; + }, m; + })(), a = (function() { + for (var A = new Array(256), _ = new Array(256), E = 0; E < 8; E += 1) + A[E] = 1 << E; + for (var E = 8; E < 256; E += 1) + A[E] = A[E - 4] ^ A[E - 5] ^ A[E - 6] ^ A[E - 8]; + for (var E = 0; E < 255; E += 1) + _[A[E]] = E; + var T = {}; + return T.glog = function(m) { + if (m < 1) + throw "glog(" + m + ")"; + return _[m]; + }, T.gexp = function(m) { + for (; m < 0; ) + m += 255; + for (; m >= 256; ) + m -= 255; + return A[m]; + }, T; + })(); + function h(A, _) { + if (typeof A.length > "u") + throw A.length + "/" + _; + var E = (function() { + for (var m = 0; m < A.length && A[m] == 0; ) + m += 1; + for (var k = new Array(A.length - m + _), d = 0; d < A.length - m; d += 1) + k[d] = A[d + m]; + return k; + })(), T = {}; + return T.getAt = function(m) { + return E[m]; + }, T.getLength = function() { + return E.length; + }, T.multiply = function(m) { + for (var k = new Array(T.getLength() + m.getLength() - 1), d = 0; d < T.getLength(); d += 1) + for (var l = 0; l < m.getLength(); l += 1) + k[d + l] ^= a.gexp(a.glog(T.getAt(d)) + a.glog(m.getAt(l))); + return h(k, 0); + }, T.mod = function(m) { + if (T.getLength() - m.getLength() < 0) + return T; + for (var k = a.glog(T.getAt(0)) - a.glog(m.getAt(0)), d = new Array(T.getLength()), l = 0; l < T.getLength(); l += 1) + d[l] = T.getAt(l); + for (var l = 0; l < m.getLength(); l += 1) + d[l] ^= a.gexp(a.glog(m.getAt(l)) + k); + return h(d, 0).mod(m); + }, T; + } + var w = (function() { + var A = [ + // L + // M + // Q + // H + // 1 + [1, 26, 19], + [1, 26, 16], + [1, 26, 13], + [1, 26, 9], + // 2 + [1, 44, 34], + [1, 44, 28], + [1, 44, 22], + [1, 44, 16], + // 3 + [1, 70, 55], + [1, 70, 44], + [2, 35, 17], + [2, 35, 13], + // 4 + [1, 100, 80], + [2, 50, 32], + [2, 50, 24], + [4, 25, 9], + // 5 + [1, 134, 108], + [2, 67, 43], + [2, 33, 15, 2, 34, 16], + [2, 33, 11, 2, 34, 12], + // 6 + [2, 86, 68], + [4, 43, 27], + [4, 43, 19], + [4, 43, 15], + // 7 + [2, 98, 78], + [4, 49, 31], + [2, 32, 14, 4, 33, 15], + [4, 39, 13, 1, 40, 14], + // 8 + [2, 121, 97], + [2, 60, 38, 2, 61, 39], + [4, 40, 18, 2, 41, 19], + [4, 40, 14, 2, 41, 15], + // 9 + [2, 146, 116], + [3, 58, 36, 2, 59, 37], + [4, 36, 16, 4, 37, 17], + [4, 36, 12, 4, 37, 13], + // 10 + [2, 86, 68, 2, 87, 69], + [4, 69, 43, 1, 70, 44], + [6, 43, 19, 2, 44, 20], + [6, 43, 15, 2, 44, 16], + // 11 + [4, 101, 81], + [1, 80, 50, 4, 81, 51], + [4, 50, 22, 4, 51, 23], + [3, 36, 12, 8, 37, 13], + // 12 + [2, 116, 92, 2, 117, 93], + [6, 58, 36, 2, 59, 37], + [4, 46, 20, 6, 47, 21], + [7, 42, 14, 4, 43, 15], + // 13 + [4, 133, 107], + [8, 59, 37, 1, 60, 38], + [8, 44, 20, 4, 45, 21], + [12, 33, 11, 4, 34, 12], + // 14 + [3, 145, 115, 1, 146, 116], + [4, 64, 40, 5, 65, 41], + [11, 36, 16, 5, 37, 17], + [11, 36, 12, 5, 37, 13], + // 15 + [5, 109, 87, 1, 110, 88], + [5, 65, 41, 5, 66, 42], + [5, 54, 24, 7, 55, 25], + [11, 36, 12, 7, 37, 13], + // 16 + [5, 122, 98, 1, 123, 99], + [7, 73, 45, 3, 74, 46], + [15, 43, 19, 2, 44, 20], + [3, 45, 15, 13, 46, 16], + // 17 + [1, 135, 107, 5, 136, 108], + [10, 74, 46, 1, 75, 47], + [1, 50, 22, 15, 51, 23], + [2, 42, 14, 17, 43, 15], + // 18 + [5, 150, 120, 1, 151, 121], + [9, 69, 43, 4, 70, 44], + [17, 50, 22, 1, 51, 23], + [2, 42, 14, 19, 43, 15], + // 19 + [3, 141, 113, 4, 142, 114], + [3, 70, 44, 11, 71, 45], + [17, 47, 21, 4, 48, 22], + [9, 39, 13, 16, 40, 14], + // 20 + [3, 135, 107, 5, 136, 108], + [3, 67, 41, 13, 68, 42], + [15, 54, 24, 5, 55, 25], + [15, 43, 15, 10, 44, 16], + // 21 + [4, 144, 116, 4, 145, 117], + [17, 68, 42], + [17, 50, 22, 6, 51, 23], + [19, 46, 16, 6, 47, 17], + // 22 + [2, 139, 111, 7, 140, 112], + [17, 74, 46], + [7, 54, 24, 16, 55, 25], + [34, 37, 13], + // 23 + [4, 151, 121, 5, 152, 122], + [4, 75, 47, 14, 76, 48], + [11, 54, 24, 14, 55, 25], + [16, 45, 15, 14, 46, 16], + // 24 + [6, 147, 117, 4, 148, 118], + [6, 73, 45, 14, 74, 46], + [11, 54, 24, 16, 55, 25], + [30, 46, 16, 2, 47, 17], + // 25 + [8, 132, 106, 4, 133, 107], + [8, 75, 47, 13, 76, 48], + [7, 54, 24, 22, 55, 25], + [22, 45, 15, 13, 46, 16], + // 26 + [10, 142, 114, 2, 143, 115], + [19, 74, 46, 4, 75, 47], + [28, 50, 22, 6, 51, 23], + [33, 46, 16, 4, 47, 17], + // 27 + [8, 152, 122, 4, 153, 123], + [22, 73, 45, 3, 74, 46], + [8, 53, 23, 26, 54, 24], + [12, 45, 15, 28, 46, 16], + // 28 + [3, 147, 117, 10, 148, 118], + [3, 73, 45, 23, 74, 46], + [4, 54, 24, 31, 55, 25], + [11, 45, 15, 31, 46, 16], + // 29 + [7, 146, 116, 7, 147, 117], + [21, 73, 45, 7, 74, 46], + [1, 53, 23, 37, 54, 24], + [19, 45, 15, 26, 46, 16], + // 30 + [5, 145, 115, 10, 146, 116], + [19, 75, 47, 10, 76, 48], + [15, 54, 24, 25, 55, 25], + [23, 45, 15, 25, 46, 16], + // 31 + [13, 145, 115, 3, 146, 116], + [2, 74, 46, 29, 75, 47], + [42, 54, 24, 1, 55, 25], + [23, 45, 15, 28, 46, 16], + // 32 + [17, 145, 115], + [10, 74, 46, 23, 75, 47], + [10, 54, 24, 35, 55, 25], + [19, 45, 15, 35, 46, 16], + // 33 + [17, 145, 115, 1, 146, 116], + [14, 74, 46, 21, 75, 47], + [29, 54, 24, 19, 55, 25], + [11, 45, 15, 46, 46, 16], + // 34 + [13, 145, 115, 6, 146, 116], + [14, 74, 46, 23, 75, 47], + [44, 54, 24, 7, 55, 25], + [59, 46, 16, 1, 47, 17], + // 35 + [12, 151, 121, 7, 152, 122], + [12, 75, 47, 26, 76, 48], + [39, 54, 24, 14, 55, 25], + [22, 45, 15, 41, 46, 16], + // 36 + [6, 151, 121, 14, 152, 122], + [6, 75, 47, 34, 76, 48], + [46, 54, 24, 10, 55, 25], + [2, 45, 15, 64, 46, 16], + // 37 + [17, 152, 122, 4, 153, 123], + [29, 74, 46, 14, 75, 47], + [49, 54, 24, 10, 55, 25], + [24, 45, 15, 46, 46, 16], + // 38 + [4, 152, 122, 18, 153, 123], + [13, 74, 46, 32, 75, 47], + [48, 54, 24, 14, 55, 25], + [42, 45, 15, 32, 46, 16], + // 39 + [20, 147, 117, 4, 148, 118], + [40, 75, 47, 7, 76, 48], + [43, 54, 24, 22, 55, 25], + [10, 45, 15, 67, 46, 16], + // 40 + [19, 148, 118, 6, 149, 119], + [18, 75, 47, 31, 76, 48], + [34, 54, 24, 34, 55, 25], + [20, 45, 15, 61, 46, 16] + ], _ = function(m, k) { + var d = {}; + return d.totalCount = m, d.dataCount = k, d; + }, E = {}, T = function(m, k) { + switch (k) { + case i.L: + return A[(m - 1) * 4 + 0]; + case i.M: + return A[(m - 1) * 4 + 1]; + case i.Q: + return A[(m - 1) * 4 + 2]; + case i.H: + return A[(m - 1) * 4 + 3]; + default: + return; + } + }; + return E.getRSBlocks = function(m, k) { + var d = T(m, k); + if (typeof d > "u") + throw "bad rs block @ typeNumber:" + m + "/errorCorrectionLevel:" + k; + for (var l = d.length / 3, u = [], p = 0; p < l; p += 1) + for (var f = d[p * 3 + 0], y = d[p * 3 + 1], x = d[p * 3 + 2], O = 0; O < f; O += 1) + u.push(_(y, x)); + return u; + }, E; + })(), g = function() { + var A = [], _ = 0, E = {}; + return E.getBuffer = function() { + return A; + }, E.getAt = function(T) { + var m = Math.floor(T / 8); + return (A[m] >>> 7 - T % 8 & 1) == 1; + }, E.put = function(T, m) { + for (var k = 0; k < m; k += 1) + E.putBit((T >>> m - k - 1 & 1) == 1); + }, E.getLengthInBits = function() { + return _; + }, E.putBit = function(T) { + var m = Math.floor(_ / 8); + A.length <= m && A.push(0), T && (A[m] |= 128 >>> _ % 8), _ += 1; + }, E; + }, v = function(A) { + var _ = o.MODE_NUMBER, E = A, T = {}; + T.getMode = function() { + return _; + }, T.getLength = function(d) { + return E.length; + }, T.write = function(d) { + for (var l = E, u = 0; u + 2 < l.length; ) + d.put(m(l.substring(u, u + 3)), 10), u += 3; + u < l.length && (l.length - u == 1 ? d.put(m(l.substring(u, u + 1)), 4) : l.length - u == 2 && d.put(m(l.substring(u, u + 2)), 7)); + }; + var m = function(d) { + for (var l = 0, u = 0; u < d.length; u += 1) + l = l * 10 + k(d.charAt(u)); + return l; + }, k = function(d) { + if ("0" <= d && d <= "9") + return d.charCodeAt(0) - 48; + throw "illegal char :" + d; + }; + return T; + }, b = function(A) { + var _ = o.MODE_ALPHA_NUM, E = A, T = {}; + T.getMode = function() { + return _; + }, T.getLength = function(k) { + return E.length; + }, T.write = function(k) { + for (var d = E, l = 0; l + 1 < d.length; ) + k.put( + m(d.charAt(l)) * 45 + m(d.charAt(l + 1)), + 11 + ), l += 2; + l < d.length && k.put(m(d.charAt(l)), 6); + }; + var m = function(k) { + if ("0" <= k && k <= "9") + return k.charCodeAt(0) - 48; + if ("A" <= k && k <= "Z") + return k.charCodeAt(0) - 65 + 10; + switch (k) { + case " ": + return 36; + case "$": + return 37; + case "%": + return 38; + case "*": + return 39; + case "+": + return 40; + case "-": + return 41; + case ".": + return 42; + case "/": + return 43; + case ":": + return 44; + default: + throw "illegal char :" + k; + } + }; + return T; + }, C = function(A) { + var _ = o.MODE_8BIT_BYTE, E = r.stringToBytes(A), T = {}; + return T.getMode = function() { + return _; + }, T.getLength = function(m) { + return E.length; + }, T.write = function(m) { + for (var k = 0; k < E.length; k += 1) + m.put(E[k], 8); + }, T; + }, L = function(A) { + var _ = o.MODE_KANJI, E = r.stringToBytesFuncs.SJIS; + if (!E) + throw "sjis not supported."; + (function(k, d) { + var l = E(k); + if (l.length != 2 || (l[0] << 8 | l[1]) != d) + throw "sjis not supported."; + })("友", 38726); + var T = E(A), m = {}; + return m.getMode = function() { + return _; + }, m.getLength = function(k) { + return ~~(T.length / 2); + }, m.write = function(k) { + for (var d = T, l = 0; l + 1 < d.length; ) { + var u = (255 & d[l]) << 8 | 255 & d[l + 1]; + if (33088 <= u && u <= 40956) + u -= 33088; + else if (57408 <= u && u <= 60351) + u -= 49472; + else + throw "illegal char at " + (l + 1) + "/" + u; + u = (u >>> 8 & 255) * 192 + (u & 255), k.put(u, 13), l += 2; + } + if (l < d.length) + throw "illegal char at " + (l + 1); + }, m; + }, M = function() { + var A = [], _ = {}; + return _.writeByte = function(E) { + A.push(E & 255); + }, _.writeShort = function(E) { + _.writeByte(E), _.writeByte(E >>> 8); + }, _.writeBytes = function(E, T, m) { + T = T || 0, m = m || E.length; + for (var k = 0; k < m; k += 1) + _.writeByte(E[k + T]); + }, _.writeString = function(E) { + for (var T = 0; T < E.length; T += 1) + _.writeByte(E.charCodeAt(T)); + }, _.toByteArray = function() { + return A; + }, _.toString = function() { + var E = ""; + E += "["; + for (var T = 0; T < A.length; T += 1) + T > 0 && (E += ","), E += A[T]; + return E += "]", E; + }, _; + }, I = function() { + var A = 0, _ = 0, E = 0, T = "", m = {}, k = function(l) { + T += String.fromCharCode(d(l & 63)); + }, d = function(l) { + if (!(l < 0)) { + if (l < 26) + return 65 + l; + if (l < 52) + return 97 + (l - 26); + if (l < 62) + return 48 + (l - 52); + if (l == 62) + return 43; + if (l == 63) + return 47; + } + throw "n:" + l; + }; + return m.writeByte = function(l) { + for (A = A << 8 | l & 255, _ += 8, E += 1; _ >= 6; ) + k(A >>> _ - 6), _ -= 6; + }, m.flush = function() { + if (_ > 0 && (k(A << 6 - _), A = 0, _ = 0), E % 3 != 0) + for (var l = 3 - E % 3, u = 0; u < l; u += 1) + T += "="; + }, m.toString = function() { + return T; + }, m; + }, U = function(A) { + var _ = A, E = 0, T = 0, m = 0, k = {}; + k.read = function() { + for (; m < 8; ) { + if (E >= _.length) { + if (m == 0) + return -1; + throw "unexpected end of file./" + m; + } + var l = _.charAt(E); + if (E += 1, l == "=") + return m = 0, -1; + if (l.match(/^\s$/)) + continue; + T = T << 6 | d(l.charCodeAt(0)), m += 6; + } + var u = T >>> m - 8 & 255; + return m -= 8, u; + }; + var d = function(l) { + if (65 <= l && l <= 90) + return l - 65; + if (97 <= l && l <= 122) + return l - 97 + 26; + if (48 <= l && l <= 57) + return l - 48 + 52; + if (l == 43) + return 62; + if (l == 47) + return 63; + throw "c:" + l; + }; + return k; + }, q = function(A, _) { + var E = A, T = _, m = new Array(A * _), k = {}; + k.setPixel = function(p, f, y) { + m[f * E + p] = y; + }, k.write = function(p) { + p.writeString("GIF87a"), p.writeShort(E), p.writeShort(T), p.writeByte(128), p.writeByte(0), p.writeByte(0), p.writeByte(0), p.writeByte(0), p.writeByte(0), p.writeByte(255), p.writeByte(255), p.writeByte(255), p.writeString(","), p.writeShort(0), p.writeShort(0), p.writeShort(E), p.writeShort(T), p.writeByte(0); + var f = 2, y = l(f); + p.writeByte(f); + for (var x = 0; y.length - x > 255; ) + p.writeByte(255), p.writeBytes(y, x, 255), x += 255; + p.writeByte(y.length - x), p.writeBytes(y, x, y.length - x), p.writeByte(0), p.writeString(";"); + }; + var d = function(p) { + var f = p, y = 0, x = 0, O = {}; + return O.write = function(R, P) { + if (R >>> P) + throw "length over"; + for (; y + P >= 8; ) + f.writeByte(255 & (R << y | x)), P -= 8 - y, R >>>= 8 - y, x = 0, y = 0; + x = R << y | x, y = y + P; + }, O.flush = function() { + y > 0 && f.writeByte(x); + }, O; + }, l = function(p) { + for (var f = 1 << p, y = (1 << p) + 1, x = p + 1, O = u(), R = 0; R < f; R += 1) + O.add(String.fromCharCode(R)); + O.add(String.fromCharCode(f)), O.add(String.fromCharCode(y)); + var P = M(), S = d(P); + S.write(f, x); + var D = 0, J = String.fromCharCode(m[D]); + for (D += 1; D < m.length; ) { + var Y = String.fromCharCode(m[D]); + D += 1, O.contains(J + Y) ? J = J + Y : (S.write(O.indexOf(J), x), O.size() < 4095 && (O.size() == 1 << x && (x += 1), O.add(J + Y)), J = Y); + } + return S.write(O.indexOf(J), x), S.write(y, x), S.flush(), P.toByteArray(); + }, u = function() { + var p = {}, f = 0, y = {}; + return y.add = function(x) { + if (y.contains(x)) + throw "dup key:" + x; + p[x] = f, f += 1; + }, y.size = function() { + return f; + }, y.indexOf = function(x) { + return p[x]; + }, y.contains = function(x) { + return typeof p[x] < "u"; + }, y; + }; + return k; + }, Q = function(A, _, E) { + for (var T = q(A, _), m = 0; m < _; m += 1) + for (var k = 0; k < A; k += 1) + T.setPixel(k, m, E(k, m)); + var d = M(); + T.write(d); + for (var l = I(), u = d.toByteArray(), p = 0; p < u.length; p += 1) + l.writeByte(u[p]); + return l.flush(), "data:image/gif;base64," + l; + }; + return r; + })(); + (function() { + n.stringToBytesFuncs["UTF-8"] = function(r) { + function o(i) { + for (var s = [], c = 0; c < i.length; c++) { + var a = i.charCodeAt(c); + a < 128 ? s.push(a) : a < 2048 ? s.push( + 192 | a >> 6, + 128 | a & 63 + ) : a < 55296 || a >= 57344 ? s.push( + 224 | a >> 12, + 128 | a >> 6 & 63, + 128 | a & 63 + ) : (c++, a = 65536 + ((a & 1023) << 10 | i.charCodeAt(c) & 1023), s.push( + 240 | a >> 18, + 128 | a >> 12 & 63, + 128 | a >> 6 & 63, + 128 | a & 63 + )); + } + return s; + } + return o(r); + }; + })(), (function(r) { + e.exports = r(); + })(function() { + return n; + }); + })(Qr)), Qr.exports; +} +var a3 = s3(); +const Bi = /* @__PURE__ */ D2(a3); +class Kn { + constructor(t) { + this._config = t; + } + async unload() { + } +} +const c3 = (e) => { + const t = []; + for (let n = 0, r = atob(e.replace(/[ \r\n]+$/, "")); n < r.length; ++n) { + let o = r.charCodeAt(n).toString(16); + o.length === 1 && (o = "0" + o), t[t.length] = o; + } + return t.join(""); +}; +let ke; +async function l2() { + try { + if (ke) return ke; + const e = (await import("./bitlogin-shared-DxcpMAo3.js").then((t) => t.i)).default; + return ke = new e(), ke; + } catch (e) { + throw console.error(e), new Error("LNC is not available"); + } +} +const Ns = "ONLY CONNECT TO TRUSTED WEBSITES"; +class d2 { + constructor(t) { + this.lnc = t; + } + enable() { + return Promise.resolve(); + } + async getInfo() { + const t = await ke.lnd.lightning.getInfo(); + return { methods: ["enable", "getBalance", "getInfo", "sendPayment"], version: "1.0", node: { alias: t.alias, pubkey: t.identityPubkey, color: t.color }, supports: ["lightning"] }; + } + makeInvoice(t) { + throw new Error("Method not implemented."); + } + async sendPayment(t) { + const n = await ke.lnd.lightning.sendPaymentSync({ paymentRequest: t }); + if (n.paymentError) throw new Error(n.paymentError); + if (!n.paymentPreimage) throw new Error("No preimage in response"); + if (typeof n.paymentPreimage != "string") throw new Error("expected preimage as string"); + return { preimage: c3(n.paymentPreimage) }; + } + async getBalance() { + var t; + const n = await ke.lnd.lightning.channelBalance(); + return { balance: parseInt(((t = n.localBalance) == null ? void 0 : t.sat) || "0") }; + } + keysend(t) { + throw new Error("Method not implemented."); + } + lnurl(t) { + throw new Error("Method not implemented."); + } + lookupInvoice(t) { + throw new Error("Method not implemented."); + } + signMessage(t) { + throw new Error("Method not implemented."); + } + verifyMessage(t, n) { + throw new Error("Method not implemented."); + } +} +class u2 { + constructor(t, n) { + this._instanceUrl = t, this._adminKey = n; + } + enable() { + return Promise.resolve(); + } + async getInfo() { + return { node: { alias: (await this.requestLnbits("GET", "/api/v1/wallet")).name, pubkey: "" }, methods: ["getInfo", "getBalance", "sendPayment"], version: "1.0", supports: ["lightning"] }; + } + async makeInvoice(t) { + return { paymentRequest: (await this.requestLnbits("POST", "/api/v1/payments", { amount: t.amount || t.defaultAmount || +t, memo: t.defaultMemo, out: !1 })).payment_request }; + } + async sendPayment(t) { + const n = await this.requestLnbits("POST", "/api/v1/payments", { bolt11: t, out: !0 }), r = await this.requestLnbits("GET", `/api/v1/payments/${n.payment_hash}`); + if (!r.preimage) throw new Error("No preimage"); + return { preimage: r.preimage }; + } + async getBalance() { + const t = await this.requestLnbits("GET", "/api/v1/wallet"); + return { balance: Math.floor(t.balance / 1e3) }; + } + keysend(t) { + throw new Error("Method not implemented."); + } + lnurl(t) { + throw new Error("Method not implemented."); + } + lookupInvoice(t) { + throw new Error("Method not implemented."); + } + signMessage(t) { + throw new Error("Method not implemented."); + } + verifyMessage(t, n) { + throw new Error("Method not implemented."); + } + async requestLnbits(t, n, r) { + let o = null; + const i = new Headers(); + if (i.append("Accept", "application/json"), i.append("Content-Type", "application/json"), i.append("X-Api-Key", this._adminKey), t === "POST") o = JSON.stringify(r); + else if (r !== void 0) throw new Error("TODO: support args in GET"); + const s = await fetch(this._instanceUrl + n + "", { method: t, headers: i, body: o }); + if (!s.ok) { + const c = await s.json(); + throw console.error("errBody", c), new Error(c.detail); + } + return await s.json(); + } +} +function qe() { + return qe = Object.assign ? Object.assign.bind() : function(e) { + for (var t = 1; t < arguments.length; t++) { + var n = arguments[t]; + for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]); + } + return e; + }, qe.apply(this, arguments); +} +class Ye extends Kn { + constructor(t) { + super(t); + } + async init() { + if (!this._config.nwcUrl) throw new Error("no nwc URL provided"); + return new Ar({ nostrWalletConnectUrl: this._config.nwcUrl }); + } +} +const l3 = { "extension.generic": class extends Kn { + constructor(e) { + super(e); + } + init() { + if (!window.webln) throw new Error("No WebLN provider available"); + return Promise.resolve(window.webln); + } +}, "nwc.alby": Ye, "nwc.albyhub": Ye, "nwc.generic": Ye, "nwc.lnfi": Ye, "nwc.coinos": Ye, "nwc.flash": Ye, "nwc.cashume": Ye, "nwc.lnbits": Ye, "nwc.rizful": Ye, lnbits: class extends Kn { + constructor(e) { + super(e); + } + async init() { + if (!this._config.lnbitsInstanceUrl) throw new Error("no lnbits URL provided"); + if (!this._config.lnbitsAdminKey) throw new Error("no lnbits admin key provided"); + return new u2(this._config.lnbitsInstanceUrl, this._config.lnbitsAdminKey); + } +}, lnc: class extends Kn { + constructor(e) { + super(e); + } + async init() { + await l2(); + const e = new d2(ke); + try { + const t = !ke.credentials.pairingPhrase; + for (t ? (console.log("Pairing phrase does not exist"), ke.credentials.password = Ns) : console.log("Pairing phrase set"), await ke.connect(), t || (ke.credentials.password = Ns); !ke.isConnected; ) console.log("Waiting to connect..."), await new Promise((n) => { + setTimeout(n, 100); + }); + } catch (t) { + throw console.error(t), ke.disconnect(), ke.credentials.clear(), t; + } + return e; + } + async unload() { + ke.disconnect(), ke.credentials.clear(), await super.unload(); + } +} }, Ro = { showBalance: !0, appName: "Bitcoin Connect", persistConnection: !0 }, V = $4((e, t) => ({ route: "/start", routeHistory: [], modalOpen: !1, currency: void 0, connected: !1, connecting: !1, error: void 0, alias: void 0, balance: void 0, connectorName: void 0, invoice: void 0, provider: void 0, connector: void 0, connectorConfig: void 0, bitcoinConnectConfig: Ro, info: void 0, connectNWC: (n) => t().connect({ connectorName: "NWC", connectorType: "nwc.generic", nwcUrl: n }), connect: async (n, r = { redirectTo: "/connected" }) => { + e({ connecting: !0, error: void 0 }); + try { + const o = new l3[n.connectorType](n), i = await o.init(); + let s; + await i.enable(); + try { + s = await i.getInfo(); + } catch { + console.error("Failed to request wallet info"); + } + if (!t().connecting) return; + e({ connectorConfig: n, connector: o, connected: !0, connecting: !1, info: s, provider: i, connectorName: n.connectorName, route: r.redirectTo }); + const { bitcoinConnectConfig: c } = t(); + c.persistConnection !== !1 && window.localStorage.setItem("bc:config", JSON.stringify(n)); + } catch (o) { + console.error(o), e({ error: o.toString(), connecting: !1 }), t().disconnect(); + } +}, disconnect: () => { + var n; + (n = t().connector) == null || n.unload(), e({ connectorConfig: void 0, connector: void 0, connected: !1, connecting: !1, connectorName: void 0, provider: void 0, modalOpen: !1 }), window.localStorage.removeItem("bc:config"); +}, pushRoute: (n) => { + t().route !== n && e({ route: n, routeHistory: [...t().routeHistory, t().route] }); +}, popRoute() { + const n = t().routeHistory, r = n.pop() || "/start"; + e({ route: r, routeHistory: n }); +}, clearRouteHistory() { + e({ route: "/start", routeHistory: [] }); +}, setModalOpen: (n) => { + e({ modalOpen: n }); +}, setBitcoinConnectConfig: (n) => { + e({ bitcoinConnectConfig: qe({}, Ro, n) }); + const r = t(); + r.bitcoinConnectConfig.autoConnect === !1 || r.connected || r.connecting || (function() { + try { + const { hash: o } = window.location; + if (o) { + const i = o.indexOf("?"), s = o.slice(i > 0 ? i : 1), c = new URLSearchParams(s), a = c.get("nwc"); + if (a && a.startsWith("nostr+walletconnect://")) { + const { searchParams: h } = new URL(a); + h.get("relay") && h.get("secret") && (c.delete("nwc"), window.location.hash = o.slice(0, i > 0 ? i + 1 : 1) + c.toString(), V.getState().connectNWC(a)); + } + } + } catch (o) { + console.error(o); + } + })(); +}, setError: (n) => { + e({ error: n }); +}, setCurrency: (n) => { + n ? window.localStorage.setItem("bc:currency", n) : window.localStorage.removeItem("bc:currency"), e({ currency: n }); +}, supports: (n) => { + const { info: r, provider: o } = t(); + return !(r == null || !r.methods) && r.methods.indexOf(n) > -1 && !(o == null || !o.getBalance); +} })); +function F(e, t, n, r) { + var o, i = arguments.length, s = i < 3 ? t : r; + if (typeof Reflect == "object" && typeof Reflect.decorate == "function") s = Reflect.decorate(e, t, n, r); + else for (var c = e.length - 1; c >= 0; c--) (o = e[c]) && (s = (i < 3 ? o(s) : i > 3 ? o(t, n, s) : o(t, n)) || s); + return i > 3 && s && Object.defineProperty(t, n, s), s; +} +globalThis.window && ((function() { + const e = window.localStorage.getItem("bc:config"); + if (e) { + const n = JSON.parse(e); + V.getState().connect(n, { redirectTo: "/start" }); + } + const t = window.localStorage.getItem("bc:currency"); + t && V.getState().setCurrency(t); +})(), window.addEventListener("webln:enabled", () => { + V.getState().connecting || V.getState().connect({ connectorName: "Extension", connectorType: "extension.generic" }, { redirectTo: "/start" }); +})), typeof SuppressedError == "function" && SuppressedError; +const Qn = globalThis, Ri = Qn.ShadowRoot && (Qn.ShadyCSS === void 0 || Qn.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, h2 = Symbol(), $s = /* @__PURE__ */ new WeakMap(); +class d3 { + constructor(t, n, r) { + if (this._$cssResult$ = !0, r !== h2) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); + this.cssText = t, this.t = n; + } + get styleSheet() { + let t = this.o; + const n = this.t; + if (Ri && t === void 0) { + const r = n !== void 0 && n.length === 1; + r && (t = $s.get(n)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), r && $s.set(n, t)); + } + return t; + } + toString() { + return this.cssText; + } +} +const Is = Ri ? (e) => e : (e) => e instanceof CSSStyleSheet ? ((t) => { + let n = ""; + for (const r of t.cssRules) n += r.cssText; + return ((r) => new d3(typeof r == "string" ? r : r + "", void 0, h2))(n); +})(e) : e, { is: u3, defineProperty: h3, getOwnPropertyDescriptor: f3, getOwnPropertyNames: p3, getOwnPropertySymbols: g3, getPrototypeOf: w3 } = Object, kr = globalThis, Us = kr.trustedTypes, y3 = Us ? Us.emptyScript : "", b3 = kr.reactiveElementPolyfillSupport, wn = (e, t) => e, ar = { toAttribute(e, t) { + switch (t) { + case Boolean: + e = e ? y3 : null; + break; + case Object: + case Array: + e = e == null ? e : JSON.stringify(e); + } + return e; +}, fromAttribute(e, t) { + let n = e; + switch (t) { + case Boolean: + n = e !== null; + break; + case Number: + n = e === null ? null : Number(e); + break; + case Object: + case Array: + try { + n = JSON.parse(e); + } catch { + n = null; + } + } + return n; +} }, Ni = (e, t) => !u3(e, t), Os = { attribute: !0, type: String, converter: ar, reflect: !1, useDefault: !1, hasChanged: Ni }; +Symbol.metadata ??= Symbol("metadata"), kr.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap(); +class sn extends HTMLElement { + static addInitializer(t) { + this._$Ei(), (this.l ??= []).push(t); + } + static get observedAttributes() { + return this.finalize(), this._$Eh && [...this._$Eh.keys()]; + } + static createProperty(t, n = Os) { + if (n.state && (n.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(t) && ((n = Object.create(n)).wrapped = !0), this.elementProperties.set(t, n), !n.noAccessor) { + const r = Symbol(), o = this.getPropertyDescriptor(t, r, n); + o !== void 0 && h3(this.prototype, t, o); + } + } + static getPropertyDescriptor(t, n, r) { + const { get: o, set: i } = f3(this.prototype, t) ?? { get() { + return this[n]; + }, set(s) { + this[n] = s; + } }; + return { get: o, set(s) { + const c = o?.call(this); + i?.call(this, s), this.requestUpdate(t, c, r); + }, configurable: !0, enumerable: !0 }; + } + static getPropertyOptions(t) { + return this.elementProperties.get(t) ?? Os; + } + static _$Ei() { + if (this.hasOwnProperty(wn("elementProperties"))) return; + const t = w3(this); + t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties); + } + static finalize() { + if (this.hasOwnProperty(wn("finalized"))) return; + if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(wn("properties"))) { + const n = this.properties, r = [...p3(n), ...g3(n)]; + for (const o of r) this.createProperty(o, n[o]); + } + const t = this[Symbol.metadata]; + if (t !== null) { + const n = litPropertyMetadata.get(t); + if (n !== void 0) for (const [r, o] of n) this.elementProperties.set(r, o); + } + this._$Eh = /* @__PURE__ */ new Map(); + for (const [n, r] of this.elementProperties) { + const o = this._$Eu(n, r); + o !== void 0 && this._$Eh.set(o, n); + } + this.elementStyles = this.finalizeStyles(this.styles); + } + static finalizeStyles(t) { + const n = []; + if (Array.isArray(t)) { + const r = new Set(t.flat(1 / 0).reverse()); + for (const o of r) n.unshift(Is(o)); + } else t !== void 0 && n.push(Is(t)); + return n; + } + static _$Eu(t, n) { + const r = n.attribute; + return r === !1 ? void 0 : typeof r == "string" ? r : typeof t == "string" ? t.toLowerCase() : void 0; + } + constructor() { + super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev(); + } + _$Ev() { + this._$ES = new Promise((t) => this.enableUpdating = t), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach((t) => t(this)); + } + addController(t) { + (this._$EO ??= /* @__PURE__ */ new Set()).add(t), this.renderRoot !== void 0 && this.isConnected && t.hostConnected?.(); + } + removeController(t) { + this._$EO?.delete(t); + } + _$E_() { + const t = /* @__PURE__ */ new Map(), n = this.constructor.elementProperties; + for (const r of n.keys()) this.hasOwnProperty(r) && (t.set(r, this[r]), delete this[r]); + t.size > 0 && (this._$Ep = t); + } + createRenderRoot() { + const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions); + return ((n, r) => { + if (Ri) n.adoptedStyleSheets = r.map((o) => o instanceof CSSStyleSheet ? o : o.styleSheet); + else for (const o of r) { + const i = document.createElement("style"), s = Qn.litNonce; + s !== void 0 && i.setAttribute("nonce", s), i.textContent = o.cssText, n.appendChild(i); + } + })(t, this.constructor.elementStyles), t; + } + connectedCallback() { + this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(!0), this._$EO?.forEach((t) => t.hostConnected?.()); + } + enableUpdating(t) { + } + disconnectedCallback() { + this._$EO?.forEach((t) => t.hostDisconnected?.()); + } + attributeChangedCallback(t, n, r) { + this._$AK(t, r); + } + _$ET(t, n) { + const r = this.constructor.elementProperties.get(t), o = this.constructor._$Eu(t, r); + if (o !== void 0 && r.reflect === !0) { + const i = (r.converter?.toAttribute !== void 0 ? r.converter : ar).toAttribute(n, r.type); + this._$Em = t, i == null ? this.removeAttribute(o) : this.setAttribute(o, i), this._$Em = null; + } + } + _$AK(t, n) { + const r = this.constructor, o = r._$Eh.get(t); + if (o !== void 0 && this._$Em !== o) { + const i = r.getPropertyOptions(o), s = typeof i.converter == "function" ? { fromAttribute: i.converter } : i.converter?.fromAttribute !== void 0 ? i.converter : ar; + this._$Em = o, this[o] = s.fromAttribute(n, i.type) ?? this._$Ej?.get(o) ?? null, this._$Em = null; + } + } + requestUpdate(t, n, r) { + if (t !== void 0) { + const o = this.constructor, i = this[t]; + if (r ??= o.getPropertyOptions(t), !((r.hasChanged ?? Ni)(i, n) || r.useDefault && r.reflect && i === this._$Ej?.get(t) && !this.hasAttribute(o._$Eu(t, r)))) return; + this.C(t, n, r); + } + this.isUpdatePending === !1 && (this._$ES = this._$EP()); + } + C(t, n, { useDefault: r, reflect: o, wrapped: i }, s) { + r && !(this._$Ej ??= /* @__PURE__ */ new Map()).has(t) && (this._$Ej.set(t, s ?? n ?? this[t]), i !== !0 || s !== void 0) || (this._$AL.has(t) || (this.hasUpdated || r || (n = void 0), this._$AL.set(t, n)), o === !0 && this._$Em !== t && (this._$Eq ??= /* @__PURE__ */ new Set()).add(t)); + } + async _$EP() { + this.isUpdatePending = !0; + try { + await this._$ES; + } catch (n) { + Promise.reject(n); + } + const t = this.scheduleUpdate(); + return t != null && await t, !this.isUpdatePending; + } + scheduleUpdate() { + return this.performUpdate(); + } + performUpdate() { + if (!this.isUpdatePending) return; + if (!this.hasUpdated) { + if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) { + for (const [o, i] of this._$Ep) this[o] = i; + this._$Ep = void 0; + } + const r = this.constructor.elementProperties; + if (r.size > 0) for (const [o, i] of r) { + const { wrapped: s } = i, c = this[o]; + s !== !0 || this._$AL.has(o) || c === void 0 || this.C(o, void 0, i, c); + } + } + let t = !1; + const n = this._$AL; + try { + t = this.shouldUpdate(n), t ? (this.willUpdate(n), this._$EO?.forEach((r) => r.hostUpdate?.()), this.update(n)) : this._$EM(); + } catch (r) { + throw t = !1, this._$EM(), r; + } + t && this._$AE(n); + } + willUpdate(t) { + } + _$AE(t) { + this._$EO?.forEach((n) => n.hostUpdated?.()), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t); + } + _$EM() { + this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1; + } + get updateComplete() { + return this.getUpdateComplete(); + } + getUpdateComplete() { + return this._$ES; + } + shouldUpdate(t) { + return !0; + } + update(t) { + this._$Eq &&= this._$Eq.forEach((n) => this._$ET(n, this[n])), this._$EM(); + } + updated(t) { + } + firstUpdated(t) { + } +} +sn.elementStyles = [], sn.shadowRootOptions = { mode: "open" }, sn[wn("elementProperties")] = /* @__PURE__ */ new Map(), sn[wn("finalized")] = /* @__PURE__ */ new Map(), b3?.({ ReactiveElement: sn }), (kr.reactiveElementVersions ??= []).push("2.1.0"); +const $i = globalThis, cr = $i.trustedTypes, Ps = cr ? cr.createPolicy("lit-html", { createHTML: (e) => e }) : void 0, Hs = "$lit$", dt = `lit$${Math.random().toFixed(9).slice(2)}$`, f2 = "?" + dt, m3 = `<${f2}>`, $t = document, lr = () => $t.createComment(""), vn = (e) => e === null || typeof e != "object" && typeof e != "function", No = Array.isArray, Jr = `[ +\f\r]`, an = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Ds = /-->/g, Zs = />/g, Et = RegExp(`>|${Jr}(?:([^\\s"'>=/]+)(${Jr}*=${Jr}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`, "g"), Ws = /'/g, Fs = /"/g, Vs = /^(?:script|style|textarea|title)$/i, Cn = Symbol.for("lit-noChange"), Ee = Symbol.for("lit-nothing"), Gs = /* @__PURE__ */ new WeakMap(), Mt = $t.createTreeWalker($t, 129); +function p2(e, t) { + if (!No(e) || !e.hasOwnProperty("raw")) throw Error("invalid template strings array"); + return Ps !== void 0 ? Ps.createHTML(t) : t; +} +class xn { + constructor({ strings: t, _$litType$: n }, r) { + let o; + this.parts = []; + let i = 0, s = 0; + const c = t.length - 1, a = this.parts, [h, w] = ((g, v) => { + const b = g.length - 1, C = []; + let L, M = v === 2 ? "" : v === 3 ? "" : "", I = an; + for (let U = 0; U < b; U++) { + const q = g[U]; + let Q, A, _ = -1, E = 0; + for (; E < q.length && (I.lastIndex = E, A = I.exec(q), A !== null); ) E = I.lastIndex, I === an ? A[1] === "!--" ? I = Ds : A[1] !== void 0 ? I = Zs : A[2] !== void 0 ? (Vs.test(A[2]) && (L = RegExp("" ? (I = L ?? an, _ = -1) : A[1] === void 0 ? _ = -2 : (_ = I.lastIndex - A[2].length, Q = A[1], I = A[3] === void 0 ? Et : A[3] === '"' ? Fs : Ws) : I === Fs || I === Ws ? I = Et : I === Ds || I === Zs ? I = an : (I = Et, L = void 0); + const T = I === Et && g[U + 1].startsWith("/>") ? " " : ""; + M += I === an ? q + m3 : _ >= 0 ? (C.push(Q), q.slice(0, _) + Hs + q.slice(_) + dt + T) : q + dt + (_ === -2 ? U : T); + } + return [p2(g, M + (g[b] || "") + (v === 2 ? "" : v === 3 ? "" : "")), C]; + })(t, n); + if (this.el = xn.createElement(h, r), Mt.currentNode = this.el.content, n === 2 || n === 3) { + const g = this.el.content.firstChild; + g.replaceWith(...g.childNodes); + } + for (; (o = Mt.nextNode()) !== null && a.length < c; ) { + if (o.nodeType === 1) { + if (o.hasAttributes()) for (const g of o.getAttributeNames()) if (g.endsWith(Hs)) { + const v = w[s++], b = o.getAttribute(g).split(dt), C = /([.?@])?(.*)/.exec(v); + a.push({ type: 1, index: i, name: C[2], strings: b, ctor: C[1] === "." ? C3 : C[1] === "?" ? x3 : C[1] === "@" ? E3 : Sr }), o.removeAttribute(g); + } else g.startsWith(dt) && (a.push({ type: 6, index: i }), o.removeAttribute(g)); + if (Vs.test(o.tagName)) { + const g = o.textContent.split(dt), v = g.length - 1; + if (v > 0) { + o.textContent = cr ? cr.emptyScript : ""; + for (let b = 0; b < v; b++) o.append(g[b], lr()), Mt.nextNode(), a.push({ type: 2, index: ++i }); + o.append(g[v], lr()); + } + } + } else if (o.nodeType === 8) if (o.data === f2) a.push({ type: 2, index: i }); + else { + let g = -1; + for (; (g = o.data.indexOf(dt, g + 1)) !== -1; ) a.push({ type: 7, index: i }), g += dt.length - 1; + } + i++; + } + } + static createElement(t, n) { + const r = $t.createElement("template"); + return r.innerHTML = t, r; + } +} +function Xt(e, t, n = e, r) { + if (t === Cn) return t; + let o = r !== void 0 ? n._$Co?.[r] : n._$Cl; + const i = vn(t) ? void 0 : t._$litDirective$; + return o?.constructor !== i && (o?._$AO?.(!1), i === void 0 ? o = void 0 : (o = new i(e), o._$AT(e, n, r)), r !== void 0 ? (n._$Co ??= [])[r] = o : n._$Cl = o), o !== void 0 && (t = Xt(e, o._$AS(e, t.values), o, r)), t; +} +class v3 { + constructor(t, n) { + this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = n; + } + get parentNode() { + return this._$AM.parentNode; + } + get _$AU() { + return this._$AM._$AU; + } + u(t) { + const { el: { content: n }, parts: r } = this._$AD, o = (t?.creationScope ?? $t).importNode(n, !0); + Mt.currentNode = o; + let i = Mt.nextNode(), s = 0, c = 0, a = r[0]; + for (; a !== void 0; ) { + if (s === a.index) { + let h; + a.type === 2 ? h = new _r(i, i.nextSibling, this, t) : a.type === 1 ? h = new a.ctor(i, a.name, a.strings, this, t) : a.type === 6 && (h = new A3(i, this, t)), this._$AV.push(h), a = r[++c]; + } + s !== a?.index && (i = Mt.nextNode(), s++); + } + return Mt.currentNode = $t, o; + } + p(t) { + let n = 0; + for (const r of this._$AV) r !== void 0 && (r.strings !== void 0 ? (r._$AI(t, r, n), n += r.strings.length - 2) : r._$AI(t[n])), n++; + } +} +class _r { + get _$AU() { + return this._$AM?._$AU ?? this._$Cv; + } + constructor(t, n, r, o) { + this.type = 2, this._$AH = Ee, this._$AN = void 0, this._$AA = t, this._$AB = n, this._$AM = r, this.options = o, this._$Cv = o?.isConnected ?? !0; + } + get parentNode() { + let t = this._$AA.parentNode; + const n = this._$AM; + return n !== void 0 && t?.nodeType === 11 && (t = n.parentNode), t; + } + get startNode() { + return this._$AA; + } + get endNode() { + return this._$AB; + } + _$AI(t, n = this) { + t = Xt(this, t, n), vn(t) ? t === Ee || t == null || t === "" ? (this._$AH !== Ee && this._$AR(), this._$AH = Ee) : t !== this._$AH && t !== Cn && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : ((r) => No(r) || typeof r?.[Symbol.iterator] == "function")(t) ? this.k(t) : this._(t); + } + O(t) { + return this._$AA.parentNode.insertBefore(t, this._$AB); + } + T(t) { + this._$AH !== t && (this._$AR(), this._$AH = this.O(t)); + } + _(t) { + this._$AH !== Ee && vn(this._$AH) ? this._$AA.nextSibling.data = t : this.T($t.createTextNode(t)), this._$AH = t; + } + $(t) { + const { values: n, _$litType$: r } = t, o = typeof r == "number" ? this._$AC(t) : (r.el === void 0 && (r.el = xn.createElement(p2(r.h, r.h[0]), this.options)), r); + if (this._$AH?._$AD === o) this._$AH.p(n); + else { + const i = new v3(o, this), s = i.u(this.options); + i.p(n), this.T(s), this._$AH = i; + } + } + _$AC(t) { + let n = Gs.get(t.strings); + return n === void 0 && Gs.set(t.strings, n = new xn(t)), n; + } + k(t) { + No(this._$AH) || (this._$AH = [], this._$AR()); + const n = this._$AH; + let r, o = 0; + for (const i of t) o === n.length ? n.push(r = new _r(this.O(lr()), this.O(lr()), this, this.options)) : r = n[o], r._$AI(i), o++; + o < n.length && (this._$AR(r && r._$AB.nextSibling, o), n.length = o); + } + _$AR(t = this._$AA.nextSibling, n) { + for (this._$AP?.(!1, !0, n); t && t !== this._$AB; ) { + const r = t.nextSibling; + t.remove(), t = r; + } + } + setConnected(t) { + this._$AM === void 0 && (this._$Cv = t, this._$AP?.(t)); + } +} +class Sr { + get tagName() { + return this.element.tagName; + } + get _$AU() { + return this._$AM._$AU; + } + constructor(t, n, r, o, i) { + this.type = 1, this._$AH = Ee, this._$AN = void 0, this.element = t, this.name = n, this._$AM = o, this.options = i, r.length > 2 || r[0] !== "" || r[1] !== "" ? (this._$AH = Array(r.length - 1).fill(new String()), this.strings = r) : this._$AH = Ee; + } + _$AI(t, n = this, r, o) { + const i = this.strings; + let s = !1; + if (i === void 0) t = Xt(this, t, n, 0), s = !vn(t) || t !== this._$AH && t !== Cn, s && (this._$AH = t); + else { + const c = t; + let a, h; + for (t = i[0], a = 0; a < i.length - 1; a++) h = Xt(this, c[r + a], n, a), h === Cn && (h = this._$AH[a]), s ||= !vn(h) || h !== this._$AH[a], h === Ee ? t = Ee : t !== Ee && (t += (h ?? "") + i[a + 1]), this._$AH[a] = h; + } + s && !o && this.j(t); + } + j(t) { + t === Ee ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? ""); + } +} +class C3 extends Sr { + constructor() { + super(...arguments), this.type = 3; + } + j(t) { + this.element[this.name] = t === Ee ? void 0 : t; + } +} +class x3 extends Sr { + constructor() { + super(...arguments), this.type = 4; + } + j(t) { + this.element.toggleAttribute(this.name, !!t && t !== Ee); + } +} +class E3 extends Sr { + constructor(t, n, r, o, i) { + super(t, n, r, o, i), this.type = 5; + } + _$AI(t, n = this) { + if ((t = Xt(this, t, n, 0) ?? Ee) === Cn) return; + const r = this._$AH, o = t === Ee && r !== Ee || t.capture !== r.capture || t.once !== r.once || t.passive !== r.passive, i = t !== Ee && (r === Ee || o); + o && this.element.removeEventListener(this.name, this, r), i && this.element.addEventListener(this.name, this, t), this._$AH = t; + } + handleEvent(t) { + typeof this._$AH == "function" ? this._$AH.call(this.options?.host ?? this.element, t) : this._$AH.handleEvent(t); + } +} +class A3 { + constructor(t, n, r) { + this.element = t, this.type = 6, this._$AN = void 0, this._$AM = n, this.options = r; + } + get _$AU() { + return this._$AM._$AU; + } + _$AI(t) { + Xt(this, t); + } +} +const k3 = $i.litHtmlPolyfillSupport; +k3?.(xn, _r), ($i.litHtmlVersions ??= []).push("3.3.0"); +const Jn = globalThis, Ii = Jn.ShadowRoot && (Jn.ShadyCSS === void 0 || Jn.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, Ui = Symbol(), js = /* @__PURE__ */ new WeakMap(); +class g2 { + constructor(t, n, r) { + if (this._$cssResult$ = !0, r !== Ui) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); + this.cssText = t, this.t = n; + } + get styleSheet() { + let t = this.o; + const n = this.t; + if (Ii && t === void 0) { + const r = n !== void 0 && n.length === 1; + r && (t = js.get(n)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), r && js.set(n, t)); + } + return t; + } + toString() { + return this.cssText; + } +} +const Lr = (e, ...t) => { + const n = e.length === 1 ? e[0] : t.reduce((r, o, i) => r + ((s) => { + if (s._$cssResult$ === !0) return s.cssText; + if (typeof s == "number") return s; + throw Error("Value passed to 'css' function must be a 'css' function result: " + s + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security."); + })(o) + e[i + 1], e[0]); + return new g2(n, e, Ui); +}, zs = Ii ? (e) => e : (e) => e instanceof CSSStyleSheet ? ((t) => { + let n = ""; + for (const r of t.cssRules) n += r.cssText; + return ((r) => new g2(typeof r == "string" ? r : r + "", void 0, Ui))(n); +})(e) : e, { is: _3, defineProperty: S3, getOwnPropertyDescriptor: L3, getOwnPropertyNames: T3, getOwnPropertySymbols: M3, getPrototypeOf: B3 } = Object, Tr = globalThis, qs = Tr.trustedTypes, R3 = qs ? qs.emptyScript : "", N3 = Tr.reactiveElementPolyfillSupport, yn = (e, t) => e, $o = { toAttribute(e, t) { + switch (t) { + case Boolean: + e = e ? R3 : null; + break; + case Object: + case Array: + e = e == null ? e : JSON.stringify(e); + } + return e; +}, fromAttribute(e, t) { + let n = e; + switch (t) { + case Boolean: + n = e !== null; + break; + case Number: + n = e === null ? null : Number(e); + break; + case Object: + case Array: + try { + n = JSON.parse(e); + } catch { + n = null; + } + } + return n; +} }, w2 = (e, t) => !_3(e, t), Ks = { attribute: !0, type: String, converter: $o, reflect: !1, useDefault: !1, hasChanged: w2 }; +Symbol.metadata ??= Symbol("metadata"), Tr.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap(); +class Ft extends HTMLElement { + static addInitializer(t) { + this._$Ei(), (this.l ??= []).push(t); + } + static get observedAttributes() { + return this.finalize(), this._$Eh && [...this._$Eh.keys()]; + } + static createProperty(t, n = Ks) { + if (n.state && (n.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(t) && ((n = Object.create(n)).wrapped = !0), this.elementProperties.set(t, n), !n.noAccessor) { + const r = Symbol(), o = this.getPropertyDescriptor(t, r, n); + o !== void 0 && S3(this.prototype, t, o); + } + } + static getPropertyDescriptor(t, n, r) { + const { get: o, set: i } = L3(this.prototype, t) ?? { get() { + return this[n]; + }, set(s) { + this[n] = s; + } }; + return { get: o, set(s) { + const c = o?.call(this); + i?.call(this, s), this.requestUpdate(t, c, r); + }, configurable: !0, enumerable: !0 }; + } + static getPropertyOptions(t) { + return this.elementProperties.get(t) ?? Ks; + } + static _$Ei() { + if (this.hasOwnProperty(yn("elementProperties"))) return; + const t = B3(this); + t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties); + } + static finalize() { + if (this.hasOwnProperty(yn("finalized"))) return; + if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(yn("properties"))) { + const n = this.properties, r = [...T3(n), ...M3(n)]; + for (const o of r) this.createProperty(o, n[o]); + } + const t = this[Symbol.metadata]; + if (t !== null) { + const n = litPropertyMetadata.get(t); + if (n !== void 0) for (const [r, o] of n) this.elementProperties.set(r, o); + } + this._$Eh = /* @__PURE__ */ new Map(); + for (const [n, r] of this.elementProperties) { + const o = this._$Eu(n, r); + o !== void 0 && this._$Eh.set(o, n); + } + this.elementStyles = this.finalizeStyles(this.styles); + } + static finalizeStyles(t) { + const n = []; + if (Array.isArray(t)) { + const r = new Set(t.flat(1 / 0).reverse()); + for (const o of r) n.unshift(zs(o)); + } else t !== void 0 && n.push(zs(t)); + return n; + } + static _$Eu(t, n) { + const r = n.attribute; + return r === !1 ? void 0 : typeof r == "string" ? r : typeof t == "string" ? t.toLowerCase() : void 0; + } + constructor() { + super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev(); + } + _$Ev() { + this._$ES = new Promise((t) => this.enableUpdating = t), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach((t) => t(this)); + } + addController(t) { + (this._$EO ??= /* @__PURE__ */ new Set()).add(t), this.renderRoot !== void 0 && this.isConnected && t.hostConnected?.(); + } + removeController(t) { + this._$EO?.delete(t); + } + _$E_() { + const t = /* @__PURE__ */ new Map(), n = this.constructor.elementProperties; + for (const r of n.keys()) this.hasOwnProperty(r) && (t.set(r, this[r]), delete this[r]); + t.size > 0 && (this._$Ep = t); + } + createRenderRoot() { + const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions); + return ((n, r) => { + if (Ii) n.adoptedStyleSheets = r.map((o) => o instanceof CSSStyleSheet ? o : o.styleSheet); + else for (const o of r) { + const i = document.createElement("style"), s = Jn.litNonce; + s !== void 0 && i.setAttribute("nonce", s), i.textContent = o.cssText, n.appendChild(i); + } + })(t, this.constructor.elementStyles), t; + } + connectedCallback() { + this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(!0), this._$EO?.forEach((t) => t.hostConnected?.()); + } + enableUpdating(t) { + } + disconnectedCallback() { + this._$EO?.forEach((t) => t.hostDisconnected?.()); + } + attributeChangedCallback(t, n, r) { + this._$AK(t, r); + } + _$ET(t, n) { + const r = this.constructor.elementProperties.get(t), o = this.constructor._$Eu(t, r); + if (o !== void 0 && r.reflect === !0) { + const i = (r.converter?.toAttribute !== void 0 ? r.converter : $o).toAttribute(n, r.type); + this._$Em = t, i == null ? this.removeAttribute(o) : this.setAttribute(o, i), this._$Em = null; + } + } + _$AK(t, n) { + const r = this.constructor, o = r._$Eh.get(t); + if (o !== void 0 && this._$Em !== o) { + const i = r.getPropertyOptions(o), s = typeof i.converter == "function" ? { fromAttribute: i.converter } : i.converter?.fromAttribute !== void 0 ? i.converter : $o; + this._$Em = o, this[o] = s.fromAttribute(n, i.type) ?? this._$Ej?.get(o) ?? null, this._$Em = null; + } + } + requestUpdate(t, n, r) { + if (t !== void 0) { + const o = this.constructor, i = this[t]; + if (r ??= o.getPropertyOptions(t), !((r.hasChanged ?? w2)(i, n) || r.useDefault && r.reflect && i === this._$Ej?.get(t) && !this.hasAttribute(o._$Eu(t, r)))) return; + this.C(t, n, r); + } + this.isUpdatePending === !1 && (this._$ES = this._$EP()); + } + C(t, n, { useDefault: r, reflect: o, wrapped: i }, s) { + r && !(this._$Ej ??= /* @__PURE__ */ new Map()).has(t) && (this._$Ej.set(t, s ?? n ?? this[t]), i !== !0 || s !== void 0) || (this._$AL.has(t) || (this.hasUpdated || r || (n = void 0), this._$AL.set(t, n)), o === !0 && this._$Em !== t && (this._$Eq ??= /* @__PURE__ */ new Set()).add(t)); + } + async _$EP() { + this.isUpdatePending = !0; + try { + await this._$ES; + } catch (n) { + Promise.reject(n); + } + const t = this.scheduleUpdate(); + return t != null && await t, !this.isUpdatePending; + } + scheduleUpdate() { + return this.performUpdate(); + } + performUpdate() { + if (!this.isUpdatePending) return; + if (!this.hasUpdated) { + if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) { + for (const [o, i] of this._$Ep) this[o] = i; + this._$Ep = void 0; + } + const r = this.constructor.elementProperties; + if (r.size > 0) for (const [o, i] of r) { + const { wrapped: s } = i, c = this[o]; + s !== !0 || this._$AL.has(o) || c === void 0 || this.C(o, void 0, i, c); + } + } + let t = !1; + const n = this._$AL; + try { + t = this.shouldUpdate(n), t ? (this.willUpdate(n), this._$EO?.forEach((r) => r.hostUpdate?.()), this.update(n)) : this._$EM(); + } catch (r) { + throw t = !1, this._$EM(), r; + } + t && this._$AE(n); + } + willUpdate(t) { + } + _$AE(t) { + this._$EO?.forEach((n) => n.hostUpdated?.()), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t); + } + _$EM() { + this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1; + } + get updateComplete() { + return this.getUpdateComplete(); + } + getUpdateComplete() { + return this._$ES; + } + shouldUpdate(t) { + return !0; + } + update(t) { + this._$Eq &&= this._$Eq.forEach((n) => this._$ET(n, this[n])), this._$EM(); + } + updated(t) { + } + firstUpdated(t) { + } +} +Ft.elementStyles = [], Ft.shadowRootOptions = { mode: "open" }, Ft[yn("elementProperties")] = /* @__PURE__ */ new Map(), Ft[yn("finalized")] = /* @__PURE__ */ new Map(), N3?.({ ReactiveElement: Ft }), (Tr.reactiveElementVersions ??= []).push("2.1.0"); +const Oi = globalThis, dr = Oi.trustedTypes, Qs = dr ? dr.createPolicy("lit-html", { createHTML: (e) => e }) : void 0, y2 = "$lit$", ft = `lit$${Math.random().toFixed(9).slice(2)}$`, b2 = "?" + ft, $3 = `<${b2}>`, It = document, En = () => It.createComment(""), An = (e) => e === null || typeof e != "object" && typeof e != "function", Io = Array.isArray, Yr = `[ +\f\r]`, cn = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Js = /-->/g, Ys = />/g, At = RegExp(`>|${Yr}(?:([^\\s"'>=/]+)(${Yr}*=${Yr}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`, "g"), Xs = /'/g, ea = /"/g, m2 = /^(?:script|style|textarea|title)$/i, v2 = (e) => (t, ...n) => ({ _$litType$: e, strings: t, values: n }), W = v2(1), de = v2(2), en = Symbol.for("lit-noChange"), Ae = Symbol.for("lit-nothing"), ta = /* @__PURE__ */ new WeakMap(), Bt = It.createTreeWalker(It, 129); +function C2(e, t) { + if (!Io(e) || !e.hasOwnProperty("raw")) throw Error("invalid template strings array"); + return Qs !== void 0 ? Qs.createHTML(t) : t; +} +const I3 = (e, t) => { + const n = e.length - 1, r = []; + let o, i = t === 2 ? "" : t === 3 ? "" : "", s = cn; + for (let c = 0; c < n; c++) { + const a = e[c]; + let h, w, g = -1, v = 0; + for (; v < a.length && (s.lastIndex = v, w = s.exec(a), w !== null); ) v = s.lastIndex, s === cn ? w[1] === "!--" ? s = Js : w[1] !== void 0 ? s = Ys : w[2] !== void 0 ? (m2.test(w[2]) && (o = RegExp("" ? (s = o ?? cn, g = -1) : w[1] === void 0 ? g = -2 : (g = s.lastIndex - w[2].length, h = w[1], s = w[3] === void 0 ? At : w[3] === '"' ? ea : Xs) : s === ea || s === Xs ? s = At : s === Js || s === Ys ? s = cn : (s = At, o = void 0); + const b = s === At && e[c + 1].startsWith("/>") ? " " : ""; + i += s === cn ? a + $3 : g >= 0 ? (r.push(h), a.slice(0, g) + y2 + a.slice(g) + ft + b) : a + ft + (g === -2 ? c : b); + } + return [C2(e, i + (e[n] || "") + (t === 2 ? "" : t === 3 ? "" : "")), r]; +}; +class kn { + constructor({ strings: t, _$litType$: n }, r) { + let o; + this.parts = []; + let i = 0, s = 0; + const c = t.length - 1, a = this.parts, [h, w] = I3(t, n); + if (this.el = kn.createElement(h, r), Bt.currentNode = this.el.content, n === 2 || n === 3) { + const g = this.el.content.firstChild; + g.replaceWith(...g.childNodes); + } + for (; (o = Bt.nextNode()) !== null && a.length < c; ) { + if (o.nodeType === 1) { + if (o.hasAttributes()) for (const g of o.getAttributeNames()) if (g.endsWith(y2)) { + const v = w[s++], b = o.getAttribute(g).split(ft), C = /([.?@])?(.*)/.exec(v); + a.push({ type: 1, index: i, name: C[2], strings: b, ctor: C[1] === "." ? O3 : C[1] === "?" ? P3 : C[1] === "@" ? H3 : Mr }), o.removeAttribute(g); + } else g.startsWith(ft) && (a.push({ type: 6, index: i }), o.removeAttribute(g)); + if (m2.test(o.tagName)) { + const g = o.textContent.split(ft), v = g.length - 1; + if (v > 0) { + o.textContent = dr ? dr.emptyScript : ""; + for (let b = 0; b < v; b++) o.append(g[b], En()), Bt.nextNode(), a.push({ type: 2, index: ++i }); + o.append(g[v], En()); + } + } + } else if (o.nodeType === 8) if (o.data === b2) a.push({ type: 2, index: i }); + else { + let g = -1; + for (; (g = o.data.indexOf(ft, g + 1)) !== -1; ) a.push({ type: 7, index: i }), g += ft.length - 1; + } + i++; + } + } + static createElement(t, n) { + const r = It.createElement("template"); + return r.innerHTML = t, r; + } +} +function tn(e, t, n = e, r) { + if (t === en) return t; + let o = r !== void 0 ? n._$Co?.[r] : n._$Cl; + const i = An(t) ? void 0 : t._$litDirective$; + return o?.constructor !== i && (o?._$AO?.(!1), i === void 0 ? o = void 0 : (o = new i(e), o._$AT(e, n, r)), r !== void 0 ? (n._$Co ??= [])[r] = o : n._$Cl = o), o !== void 0 && (t = tn(e, o._$AS(e, t.values), o, r)), t; +} +class U3 { + constructor(t, n) { + this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = n; + } + get parentNode() { + return this._$AM.parentNode; + } + get _$AU() { + return this._$AM._$AU; + } + u(t) { + const { el: { content: n }, parts: r } = this._$AD, o = (t?.creationScope ?? It).importNode(n, !0); + Bt.currentNode = o; + let i = Bt.nextNode(), s = 0, c = 0, a = r[0]; + for (; a !== void 0; ) { + if (s === a.index) { + let h; + a.type === 2 ? h = new Mn(i, i.nextSibling, this, t) : a.type === 1 ? h = new a.ctor(i, a.name, a.strings, this, t) : a.type === 6 && (h = new D3(i, this, t)), this._$AV.push(h), a = r[++c]; + } + s !== a?.index && (i = Bt.nextNode(), s++); + } + return Bt.currentNode = It, o; + } + p(t) { + let n = 0; + for (const r of this._$AV) r !== void 0 && (r.strings !== void 0 ? (r._$AI(t, r, n), n += r.strings.length - 2) : r._$AI(t[n])), n++; + } +} +class Mn { + get _$AU() { + return this._$AM?._$AU ?? this._$Cv; + } + constructor(t, n, r, o) { + this.type = 2, this._$AH = Ae, this._$AN = void 0, this._$AA = t, this._$AB = n, this._$AM = r, this.options = o, this._$Cv = o?.isConnected ?? !0; + } + get parentNode() { + let t = this._$AA.parentNode; + const n = this._$AM; + return n !== void 0 && t?.nodeType === 11 && (t = n.parentNode), t; + } + get startNode() { + return this._$AA; + } + get endNode() { + return this._$AB; + } + _$AI(t, n = this) { + t = tn(this, t, n), An(t) ? t === Ae || t == null || t === "" ? (this._$AH !== Ae && this._$AR(), this._$AH = Ae) : t !== this._$AH && t !== en && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : ((r) => Io(r) || typeof r?.[Symbol.iterator] == "function")(t) ? this.k(t) : this._(t); + } + O(t) { + return this._$AA.parentNode.insertBefore(t, this._$AB); + } + T(t) { + this._$AH !== t && (this._$AR(), this._$AH = this.O(t)); + } + _(t) { + this._$AH !== Ae && An(this._$AH) ? this._$AA.nextSibling.data = t : this.T(It.createTextNode(t)), this._$AH = t; + } + $(t) { + const { values: n, _$litType$: r } = t, o = typeof r == "number" ? this._$AC(t) : (r.el === void 0 && (r.el = kn.createElement(C2(r.h, r.h[0]), this.options)), r); + if (this._$AH?._$AD === o) this._$AH.p(n); + else { + const i = new U3(o, this), s = i.u(this.options); + i.p(n), this.T(s), this._$AH = i; + } + } + _$AC(t) { + let n = ta.get(t.strings); + return n === void 0 && ta.set(t.strings, n = new kn(t)), n; + } + k(t) { + Io(this._$AH) || (this._$AH = [], this._$AR()); + const n = this._$AH; + let r, o = 0; + for (const i of t) o === n.length ? n.push(r = new Mn(this.O(En()), this.O(En()), this, this.options)) : r = n[o], r._$AI(i), o++; + o < n.length && (this._$AR(r && r._$AB.nextSibling, o), n.length = o); + } + _$AR(t = this._$AA.nextSibling, n) { + for (this._$AP?.(!1, !0, n); t && t !== this._$AB; ) { + const r = t.nextSibling; + t.remove(), t = r; + } + } + setConnected(t) { + this._$AM === void 0 && (this._$Cv = t, this._$AP?.(t)); + } +} +class Mr { + get tagName() { + return this.element.tagName; + } + get _$AU() { + return this._$AM._$AU; + } + constructor(t, n, r, o, i) { + this.type = 1, this._$AH = Ae, this._$AN = void 0, this.element = t, this.name = n, this._$AM = o, this.options = i, r.length > 2 || r[0] !== "" || r[1] !== "" ? (this._$AH = Array(r.length - 1).fill(new String()), this.strings = r) : this._$AH = Ae; + } + _$AI(t, n = this, r, o) { + const i = this.strings; + let s = !1; + if (i === void 0) t = tn(this, t, n, 0), s = !An(t) || t !== this._$AH && t !== en, s && (this._$AH = t); + else { + const c = t; + let a, h; + for (t = i[0], a = 0; a < i.length - 1; a++) h = tn(this, c[r + a], n, a), h === en && (h = this._$AH[a]), s ||= !An(h) || h !== this._$AH[a], h === Ae ? t = Ae : t !== Ae && (t += (h ?? "") + i[a + 1]), this._$AH[a] = h; + } + s && !o && this.j(t); + } + j(t) { + t === Ae ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? ""); + } +} +class O3 extends Mr { + constructor() { + super(...arguments), this.type = 3; + } + j(t) { + this.element[this.name] = t === Ae ? void 0 : t; + } +} +class P3 extends Mr { + constructor() { + super(...arguments), this.type = 4; + } + j(t) { + this.element.toggleAttribute(this.name, !!t && t !== Ae); + } +} +class H3 extends Mr { + constructor(t, n, r, o, i) { + super(t, n, r, o, i), this.type = 5; + } + _$AI(t, n = this) { + if ((t = tn(this, t, n, 0) ?? Ae) === en) return; + const r = this._$AH, o = t === Ae && r !== Ae || t.capture !== r.capture || t.once !== r.once || t.passive !== r.passive, i = t !== Ae && (r === Ae || o); + o && this.element.removeEventListener(this.name, this, r), i && this.element.addEventListener(this.name, this, t), this._$AH = t; + } + handleEvent(t) { + typeof this._$AH == "function" ? this._$AH.call(this.options?.host ?? this.element, t) : this._$AH.handleEvent(t); + } +} +class D3 { + constructor(t, n, r) { + this.element = t, this.type = 6, this._$AN = void 0, this._$AM = n, this.options = r; + } + get _$AU() { + return this._$AM._$AU; + } + _$AI(t) { + tn(this, t); + } +} +const Z3 = Oi.litHtmlPolyfillSupport; +Z3?.(kn, Mn), (Oi.litHtmlVersions ??= []).push("3.3.0"); +const Pi = globalThis; +class qt extends Ft { + constructor() { + super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0; + } + createRenderRoot() { + const t = super.createRenderRoot(); + return this.renderOptions.renderBefore ??= t.firstChild, t; + } + update(t) { + const n = this.render(); + this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do = ((r, o, i) => { + const s = i?.renderBefore ?? o; + let c = s._$litPart$; + if (c === void 0) { + const a = i?.renderBefore ?? null; + s._$litPart$ = c = new Mn(o.insertBefore(En(), a), a, void 0, i ?? {}); + } + return c._$AI(r), c; + })(n, this.renderRoot, this.renderOptions); + } + connectedCallback() { + super.connectedCallback(), this._$Do?.setConnected(!0); + } + disconnectedCallback() { + super.disconnectedCallback(), this._$Do?.setConnected(!1); + } + render() { + return en; + } +} +qt._$litElement$ = !0, qt.finalized = !0, Pi.litElementHydrateSupport?.({ LitElement: qt }); +const W3 = Pi.litElementPolyfillSupport; +W3?.({ LitElement: qt }), (Pi.litElementVersions ??= []).push("4.2.0"); +const oe = (e) => (t, n) => { + n !== void 0 ? n.addInitializer(() => { + customElements.define(e, t); + }) : customElements.define(e, t); +}, F3 = { attribute: !0, type: String, converter: ar, reflect: !1, hasChanged: Ni }, V3 = (e = F3, t, n) => { + const { kind: r, metadata: o } = n; + let i = globalThis.litPropertyMetadata.get(o); + if (i === void 0 && globalThis.litPropertyMetadata.set(o, i = /* @__PURE__ */ new Map()), r === "setter" && ((e = Object.create(e)).wrapped = !0), i.set(n.name, e), r === "accessor") { + const { name: s } = n; + return { set(c) { + const a = t.get.call(this); + t.set.call(this, c), this.requestUpdate(s, a, e); + }, init(c) { + return c !== void 0 && this.C(s, void 0, e, c), c; + } }; + } + if (r === "setter") { + const { name: s } = n; + return function(c) { + const a = this[s]; + t.call(this, c), this.requestUpdate(s, a, e); + }; + } + throw Error("Unsupported decorator location: " + r); +}; +function me(e) { + return (t, n) => typeof n == "object" ? V3(e, t, n) : ((r, o, i) => { + const s = o.hasOwnProperty(i); + return o.constructor.createProperty(i, r), s ? Object.getOwnPropertyDescriptor(o, i) : void 0; + })(e, t, n); +} +function se(e) { + return me({ ...e, state: !0, attribute: !1 }); +} +let na, ra; +class Hi extends qt { + updated(t) { + var n; + if (super.updated(t), globalThis.document && globalThis.document.documentElement.classList.contains("dark") && (n = this.shadowRoot) != null && (n = n.children) != null && n.length) for (const r of this.shadowRoot.children) r.classList.contains("dark") || r.classList.add("dark"); + } + _getBrandColorLuminance() { + if (!globalThis.window) return 0; + const t = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches; + let n = window.getComputedStyle(this).getPropertyValue(t ? "--bc-color-brand-dark" : "--bc-color-brand") || window.getComputedStyle(this).getPropertyValue("--bc-color-brand") || "#196CE7"; + if (!n.match(/^#[0-9A-F]{6}$/i)) { + const r = document.createElement("div"); + r.style.color = n, r.style.display = "none", document.body.appendChild(r), n = window.getComputedStyle(r).color, r.remove(); + } + return (function(r) { + if (r.startsWith("#")) return r = r.slice(1), (0.299 * parseInt(r.slice(0, 2), 16) + 0.587 * parseInt(r.slice(2, 4), 16) + 0.114 * parseInt(r.slice(4, 6), 16)) / 255; + if (r.startsWith("rgb") || r.startsWith("rgba")) { + const o = r.match(/\d+(\.\d+)?/g); + return (0.299 * parseFloat(o[0]) + 0.587 * parseFloat(o[1]) + 0.114 * parseFloat(o[2])) / 255; + } + throw new Error("Unsupported luminance: " + r); + })(n); + } +} +Hi.styles = [Lr(na || (na = ((e) => e)` + :host { + // global css reset in shadow DOM + all: initial; + font-variant-numeric: slashed-zero; + } + // TODO: move to individual components - only needed by a couple of icons + .hover-animation:hover .hover-right-up { + transform: translateX(2px) translateY(-2px); + transition: all 0.3s; + } + .hover-animation:hover .hover-right { + transform: translateX(3px); + transition: all 0.3s; + } + `))]; +class ae extends Hi { + constructor() { + super(), this._modalOpen = !1, this._connected = !1, this._connecting = !1, this._connectorName = void 0, this._appName = void 0, this._appIcon = void 0, this._filters = void 0, this._error = void 0, this._connected = V.getState().connected, this._connecting = V.getState().connecting, this._connectorName = V.getState().connectorName, this._appName = V.getState().bitcoinConnectConfig.appName, this._appIcon = V.getState().bitcoinConnectConfig.appIcon, this._filters = V.getState().bitcoinConnectConfig.filters, this._error = V.getState().error, this._route = V.getState().route, this._modalOpen = V.getState().modalOpen, V.subscribe((t) => { + this._connected = t.connected, this._connecting = t.connecting, this._connectorName = t.connectorName, this._appName = t.bitcoinConnectConfig.appName, this._appIcon = t.bitcoinConnectConfig.appIcon, this._filters = t.bitcoinConnectConfig.filters, this._error = t.error, this._route = t.route, this._modalOpen = t.modalOpen; + }); + } +} +F([se()], ae.prototype, "_modalOpen", void 0), F([se()], ae.prototype, "_connected", void 0), F([se()], ae.prototype, "_connecting", void 0), F([se()], ae.prototype, "_connectorName", void 0), F([se()], ae.prototype, "_appName", void 0), F([se()], ae.prototype, "_appIcon", void 0), F([se()], ae.prototype, "_filters", void 0), F([se()], ae.prototype, "_error", void 0), F([se()], ae.prototype, "_route", void 0); +const bn = de(ra || (ra = ((e) => e)` + + +`)); +function Di(e) { + return [...e.v, (e.i ? "!" : "") + e.n].join(":"); +} +function G3(e, t = ",") { + return e.map(Di).join(t); +} +let x2 = typeof CSS < "u" && CSS.escape || ((e) => e.replace(/[!"'`*+.,;:\\/<=>?@#$%&^|~()[\]{}]/g, "\\$&").replace(/^\d/, "\\3$& ")); +function ur(e) { + for (var t = 9, n = e.length; n--; ) t = Math.imul(t ^ e.charCodeAt(n), 1597334677); + return "#" + ((t ^ t >>> 9) >>> 0).toString(36); +} +function Zi(e, t = "@media ") { + return t + we(e).map((n) => (typeof n == "string" && (n = { min: n }), n.raw || Object.keys(n).map((r) => `(${r}-width:${n[r]})`).join(" and "))).join(","); +} +function we(e = []) { + return Array.isArray(e) ? e : e == null ? [] : [e]; +} +function oa(e) { + return e; +} +function Uo() { +} +let _e = { d: 0, b: 134217728, c: 268435456, a: 671088640, u: 805306368, o: 939524096 }; +function E2(e) { + return e.match(/[-=:;]/g)?.length || 0; +} +function Oo(e) { + return Math.min(/(?:^|width[^\d]+)(\d+(?:.\d+)?)(p)?/.test(e) ? Math.max(0, 29.63 * (+RegExp.$1 / (RegExp.$2 ? 15 : 1)) ** 0.137 - 43) : 0, 15) << 22 | Math.min(E2(e), 15) << 18; +} +let j3 = ["rst-c", "st-ch", "h-chi", "y-lin", "nk", "sited", "ecked", "pty", "ad-on", "cus-w", "ver", "cus", "cus-v", "tive", "sable", "tiona", "quire"]; +function Wi({ n: e, i: t, v: n = [] }, r, o, i) { + e && (e = Di({ n: e, i: t, v: n })), i = [...we(i)]; + for (let s of n) { + let c = r.theme("screens", s); + for (let a of we(c && Zi(c) || r.v(s))) i.push(a), o |= c ? 67108864 | Oo(a) : s == "dark" ? 1073741824 : a[0] == "@" ? Oo(a) : 1 << ~(/:([a-z-]+)/.test(a) && ~j3.indexOf(RegExp.$1.slice(2, 7)) || -18); + } + return { n: e, p: o, r: i, i: t }; +} +let A2 = /* @__PURE__ */ new Map(); +function Po(e) { + if (e.d) { + let t = [], n = Xr(e.r.reduce((r, o) => o[0] == "@" ? (t.push(o), r) : o ? Xr(r, (i) => Xr(o, (s) => { + let c = /(:merge\(.+?\))(:[a-z-]+|\\[.+])/.exec(s); + if (c) { + let a = i.indexOf(c[1]); + return ~a ? i.slice(0, a) + c[0] + i.slice(a + c[1].length) : eo(i, s); + } + return eo(s, i); + })) : r, "&"), (r) => eo(r, e.n ? "." + x2(e.n) : "")); + return n && t.push(n.replace(/:merge\((.+?)\)/g, "$1")), t.reduceRight((r, o) => o + "{" + r + "}", e.d); + } +} +function Xr(e, t) { + return e.replace(/ *((?:\(.+?\)|\[.+?\]|[^,])+) *(,|$)/g, (n, r, o) => t(r) + o); +} +function eo(e, t) { + return e.replace(/&/g, t); +} +let ia = new Intl.Collator("en", { numeric: !0 }); +function k2(e, t) { + for (var n = 0, r = e.length; n < r; ) { + let o = r + n >> 1; + 0 >= _2(e[o], t) ? n = o + 1 : r = o; + } + return r; +} +function _2(e, t) { + let n = e.p & _e.o; + return n != (t.p & _e.o) || n != _e.b && n != _e.o ? e.p - t.p || e.o - t.o || ia.compare(sa(e.n), sa(t.n)) || ia.compare(aa(e.n), aa(t.n)) : 0; +} +function sa(e) { + return (e || "").split(/:/).pop().split("/").pop() || "\0"; +} +function aa(e) { + return (e || "").replace(/\W/g, (t) => String.fromCharCode(127 + t.charCodeAt(0))) + "\0"; +} +function to(e, t) { + return Math.round(parseInt(e, 16) * t); +} +function gt(e, t = {}) { + if (typeof e == "function") return e(t); + let { opacityValue: n = "1", opacityVariable: r } = t, o = r ? `var(${r})` : n; + if (e.includes("")) return e.replace("", o); + if (e[0] == "#" && (e.length == 4 || e.length == 7)) { + let i = (e.length - 1) / 3, s = [17, 1, 0.062272][i - 1]; + return `rgba(${[to(e.substr(1, i), s), to(e.substr(1 + i, i), s), to(e.substr(1 + 2 * i, i), s), o]})`; + } + return o == "1" ? e : o == "0" ? "#0000" : e.replace(/^(rgb|hsl)(\([^)]+)\)$/, `$1a$2,${o})`); +} +function S2(e, t, n, r, o = []) { + return (function i(s, { n: c, p: a, r: h = [], i: w }, g) { + let v = [], b = "", C = 0, L = 0; + for (let U in s || {}) { + var M, I; + let q = s[U]; + if (U[0] == "@") { + if (!q) continue; + if (U[1] == "a") { + v.push(...Vi(c, a, fr("" + q), g, a, h, w, !0)); + continue; + } + if (U[1] == "l") { + for (let Q of we(q)) v.push(...i(Q, { n: c, p: (M = _e[U[7]], a & -939524097 | M), r: U[7] == "d" ? [] : h, i: w }, g)); + continue; + } + if (U[1] == "i") { + v.push(...we(q).map((Q) => ({ p: -1, o: 0, r: [], d: U + " " + Q }))); + continue; + } + if (U[1] == "k") { + v.push({ p: _e.d, o: 0, r: [U], d: i(q, { p: _e.d }, g).map(Po).join("") }); + continue; + } + if (U[1] == "f") { + v.push(...we(q).map((Q) => ({ p: _e.d, o: 0, r: [U], d: i(Q, { p: _e.d }, g).map(Po).join("") }))); + continue; + } + } + if (typeof q != "object" || Array.isArray(q)) U == "label" && q ? c = q + ur(JSON.stringify([a, w, s])) : (q || q === 0) && (U = U.replace(/[A-Z]/g, (Q) => "-" + Q.toLowerCase()), L += 1, C = Math.max(C, (I = U)[0] == "-" ? 0 : E2(I) + (/^(?:(border-(?!w|c|sty)|[tlbr].{2,4}m?$|c.{7,8}$)|([fl].{5}l|g.{8}$|pl))/.test(I) ? +!!RegExp.$1 || -!!RegExp.$2 : 0) + 1), b += (b ? ";" : "") + we(q).map((Q) => g.s(U, Fi("" + Q, g.theme) + (w ? " !important" : ""))).join(";")); + else if (U[0] == "@" || U.includes("&")) { + let Q = a; + U[0] == "@" && (U = U.replace(/\bscreen\(([^)]+)\)/g, (A, _) => { + let E = g.theme("screens", _); + return E ? (Q |= 67108864, Zi(E, "")) : A; + }), Q |= Oo(U)), v.push(...i(q, { n: c, p: Q, r: [...h, U], i: w }, g)); + } else v.push(...i(q, { p: a, r: [...h, U] }, g)); + } + return v.unshift({ n: c, p: a, o: Math.max(0, 15 - L) + 1.5 * Math.min(C || 15, 15), r: h, d: b }), v.sort(_2); + })(e, Wi(t, n, r, o), n); +} +function Fi(e, t) { + return e.replace(/theme\((["'`])?(.+?)\1(?:\s*,\s*(["'`])?(.+?)\3)?\)/g, (n, r, o, i, s = "") => { + let c = t(o, s); + return typeof c == "function" && /color|fill|stroke/i.test(o) ? gt(c) : "" + we(c).filter((a) => Object(a) !== a); + }); +} +function L2(e, t) { + let n, r = []; + for (let o of e) o.d && o.n ? n?.p == o.p && "" + n.r == "" + o.r ? (n.c = [n.c, o.c].filter(Boolean).join(" "), n.d = n.d + ";" + o.d) : r.push(n = { ...o, n: o.n && t }) : r.push({ ...o, n: o.n && t }); + return r; +} +function hr(e, t, n = _e.u, r, o) { + let i = []; + for (let s of e) for (let c of (function(a, h, w, g, v) { + let b = (function(C, L) { + let M = A2.get(C.n); + return M ? M(C, L) : L.r(C.n, C.v[0] == "dark"); + })(a = { ...a, i: a.i || v }, h); + return b ? typeof b == "string" ? ({ r: g, p: w } = Wi(a, h, w, g), L2(hr(fr(b), h, w, g, a.i), a.n)) : Array.isArray(b) ? b.map((C) => { + var L, M; + return { o: 0, ...C, r: [...we(g), ...we(C.r)], p: (L = w, M = C.p ?? w, L & -939524097 | M) }; + }) : S2(b, a, h, w, g) : [{ c: Di(a), p: 0, o: 0, r: [] }]; + })(s, t, n, r, o)) i.splice(k2(i, c), 0, c); + return i; +} +function Vi(e, t, n, r, o, i, s, c) { + return L2((c ? n.flatMap((a) => hr([a], r, o, i, s)) : hr(n, r, o, i, s)).map((a) => a.p & _e.o && (a.n || t == _e.b) ? { ...a, p: a.p & -939524097 | t, o: 0 } : a), e); +} +function z3(e, t, n, r) { + return A2.set(e, (o, i) => { + let { n: s, p: c, r: a, i: h } = Wi(o, i, t); + return n && Vi(s, t, n, i, c, a, h, r); + }), e; +} +function no(e, t, n) { + if (e[e.length - 1] != "(") { + let r = [], o = !1, i = !1, s = ""; + for (let c of e) if (c != "(" && !/[~@]$/.test(c)) { + if (c[0] == "!" && (c = c.slice(1), o = !o), c.endsWith(":")) { + r[c == "dark:" ? "unshift" : "push"](c.slice(0, -1)); + continue; + } + c[0] == "-" && (c = c.slice(1), i = !i), c.endsWith("-") && (c = c.slice(0, -1)), c && c != "&" && (s += (s && "-") + c); + } + s && (i && (s = "-" + s), t[0].push({ n: s, v: r.filter(q3), i: o })); + } +} +function q3(e, t, n) { + return n.indexOf(e) == t; +} +let ca = /* @__PURE__ */ new Map(); +function fr(e) { + let t = ca.get(e); + if (!t) { + let n = [], r = [[]], o = 0, i = 0, s = null, c = 0, a = (h, w = 0) => { + o != c && (n.push(e.slice(o, c + w)), h && no(n, r)), o = c + 1; + }; + for (; c < e.length; c++) { + let h = e[c]; + if (i) e[c - 1] != "\\" && (i += +(h == "[") || -(h == "]")); + else if (h == "[") i += 1; + else if (s) e[c - 1] != "\\" && s.test(e.slice(c)) && (s = null, o = c + RegExp.lastMatch.length); + else if (h != "/" || e[c - 1] == "\\" || e[c + 1] != "*" && e[c + 1] != "/") if (h == "(") a(), n.push(h); + else if (h == ":") e[c + 1] != ":" && a(!1, 1); + else if (/[\s,)]/.test(h)) { + a(!0); + let w = n.lastIndexOf("("); + if (h == ")") { + let g = n[w - 1]; + if (/[~@]$/.test(g)) { + let v = r.shift(); + n.length = w, no([...n, "#"], r); + let { v: b } = r[0].pop(); + for (let C of v) C.v.splice(+(C.v[0] == "dark") - +(b[0] == "dark"), b.length); + no([...n, z3(g.length > 1 ? g.slice(0, -1) + ur(JSON.stringify([g, v])) : g + "(" + G3(v) + ")", _e.a, v, /@$/.test(g))], r); + } + w = n.lastIndexOf("(", w - 1); + } + n.length = w + 1; + } else /[~@]/.test(h) && e[c + 1] == "(" && r.unshift([]); + else s = e[c + 1] == "*" ? /^\*\// : /^[\r\n]/; + } + a(!0), ca.set(e, t = r[0]); + } + return t; +} +function j(e, t, n) { + return [e, Ho(t, n)]; +} +function Ho(e, t) { + return typeof e == "function" ? e : typeof e == "string" && /^[\w-]+$/.test(e) ? (n, r) => ({ [e]: t ? t(n, r) : Do(n, 1) }) : (n) => e || { [n[1]]: Do(n, 2) }; +} +function Do(e, t, n = e.slice(t).find(Boolean) || e.$$ || e.input) { + return e.input[0] == "-" ? `calc(${n} * -1)` : n; +} +function z(e, t, n, r) { + return [e, K3(t, n, r)]; +} +function K3(e, t, n) { + let r = typeof t == "string" ? (o, i) => ({ [t]: n ? n(o, i) : o._ }) : t || (({ 1: o, _: i }, s, c) => ({ [o || c]: i })); + return (o, i) => { + let s = T2(e || o[1]), c = i.theme(s, o.$$) ?? wt(o.$$, s, i); + if (c != null) return o._ = Do(o, 0, c), r(o, i, s); + }; +} +function Ce(e, t = {}, n) { + return [e, Q3(t, n)]; +} +function Q3(e = {}, t) { + return (n, r) => { + let { section: o = T2(n[0]).replace("-", "") + "Color" } = e, [i, s] = (n.$$.match(/^(\[[^\]]+]|[^/]+?)(?:\/(.+))?$/) || []).slice(1); + if (!i) return; + let c = r.theme(o, i) || wt(i, o, r); + if (!c || typeof c == "object") return; + let { opacityVariable: a = `--tw-${n[0].replace(/-$/, "")}-opacity`, opacitySection: h = o.replace("Color", "Opacity"), property: w = o, selector: g } = e, v = r.theme(h, s || "DEFAULT") || s && wt(s, h, r), b = t || (({ _: L }) => { + let M = Yn(w, L); + return g ? { [g]: M } : M; + }); + n._ = { value: gt(c, { opacityVariable: a || void 0, opacityValue: v || void 0 }), color: (L) => gt(c, L), opacityVariable: a || void 0, opacityValue: v || void 0 }; + let C = b(n, r); + if (!n.dark) { + let L = r.d(o, i, c); + L && L !== c && (n._ = { value: gt(L, { opacityVariable: a || void 0, opacityValue: v || "1" }), color: (M) => gt(L, M), opacityVariable: a || void 0, opacityValue: v || void 0 }, C = { "&": C, [r.v("dark")]: b(n, r) }); + } + return C; + }; +} +function Yn(e, t) { + let n = {}; + return typeof t == "string" ? n[e] = t : (t.opacityVariable && t.value.includes(t.opacityVariable) && (n[t.opacityVariable] = t.opacityValue || "1"), n[e] = t.value), n; +} +function wt(e, t, n) { + if (e[0] == "[" && e.slice(-1) == "]") { + if (e = _n(Fi(e.slice(1, -1), n.theme)), !t) return e; + if (!(/color|fill|stroke/i.test(t) && !/^color:/.test(e) && !/^(#|((hsl|rgb)a?|hwb|lab|lch|color)\(|[a-z]+$)/.test(e) || /image/i.test(t) && !/^image:/.test(e) && !/^[a-z-]+\(/.test(e) || /weight/i.test(t) && !/^(number|any):/.test(e) && !/^\d+$/.test(e) || /position/i.test(t) && /^(length|size):/.test(e))) return e.replace(/^[a-z-]+:/, ""); + } +} +function T2(e) { + return e.replace(/-./g, (t) => t[1].toUpperCase()); +} +function _n(e) { + return e.includes("url(") ? e.replace(/(.*?)(url\(.*?\))(.*?)/g, (t, n = "", r, o = "") => _n(n) + r + _n(o)) : e.replace(/(^|[^\\])_+/g, (t, n) => n + " ".repeat(t.length - n.length)).replace(/\\_/g, "_").replace(/(calc|min|max|clamp)\(.+\)/g, (t) => t.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ")); +} +function la({ presets: e = [], ...t }) { + let n = { darkMode: void 0, darkColor: void 0, preflight: t.preflight !== !1 && [], theme: {}, variants: we(t.variants), rules: we(t.rules), ignorelist: we(t.ignorelist), hash: void 0, stringify: (r, o) => r + ":" + o, finalize: [] }; + for (let r of we([...e, { darkMode: t.darkMode, darkColor: t.darkColor, preflight: t.preflight !== !1 && we(t.preflight), theme: t.theme, hash: t.hash, stringify: t.stringify, finalize: t.finalize }])) { + let { preflight: o, darkMode: i = n.darkMode, darkColor: s = n.darkColor, theme: c, variants: a, rules: h, ignorelist: w, hash: g = n.hash, stringify: v = n.stringify, finalize: b } = typeof r == "function" ? r(n) : r; + n = { preflight: n.preflight !== !1 && o !== !1 && [...n.preflight, ...we(o)], darkMode: i, darkColor: s, theme: { ...n.theme, ...c, extend: { ...n.theme.extend, ...c?.extend } }, variants: [...n.variants, ...we(a)], rules: [...n.rules, ...we(h)], ignorelist: [...n.ignorelist, ...we(w)], hash: g, stringify: v, finalize: [...n.finalize, ...we(b)] }; + } + return n; +} +function da(e, t, n, r, o, i) { + for (let s of t) { + let c = n.get(s); + c || n.set(s, c = r(s)); + let a = c(e, o, i); + if (a) return a; + } +} +function J3(e) { + var t; + return Zo(e[0], typeof (t = e[1]) == "function" ? t : () => t); +} +function Y3(e) { + return Array.isArray(e) ? Zo(e[0], Ho(e[1], e[2])) : Zo(e, Ho(void 0, void 0)); +} +function Zo(e, t) { + return M2(e, (n, r, o, i) => { + let s = r.exec(n); + if (s) return s.$$ = n.slice(s[0].length), s.dark = i, t(s, o); + }); +} +function M2(e, t) { + let n = we(e).map(X3); + return (r, o, i) => { + for (let s of n) { + let c = t(r, s, o, i); + if (c) return c; + } + }; +} +function X3(e) { + return typeof e == "string" ? RegExp("^" + e + (e.includes("$") || e.slice(-1) == "-" ? "" : "$")) : e; +} +function ro(e) { + let t = e?.cssRules ? e : (e && typeof e != "string" ? e : (function(n) { + let r = document.querySelector(n || 'style[data-twind=""]'); + return r && r.tagName == "STYLE" || (r = document.createElement("style"), document.head.prepend(r)), r.dataset.twind = "claimed", r; + })(e)).sheet; + return { target: t, snapshot() { + let n = Array.from(t.cssRules, (r) => r.cssText); + return () => { + this.clear(), n.forEach(this.insert); + }; + }, clear() { + for (let n = t.cssRules.length; n--; ) t.deleteRule(n); + }, destroy() { + t.ownerNode?.remove(); + }, insert(n, r) { + try { + t.insertRule(n, r); + } catch { + t.insertRule(":root{}", r); + } + }, resume: Uo }; +} +let Wo = { screens: { sm: "640px", md: "768px", lg: "1024px", xl: "1280px", "2xl": "1536px" }, columns: { auto: "auto", "3xs": "16rem", "2xs": "18rem", xs: "20rem", sm: "24rem", md: "28rem", lg: "32rem", xl: "36rem", "2xl": "42rem", "3xl": "48rem", "4xl": "56rem", "5xl": "64rem", "6xl": "72rem", "7xl": "80rem" }, spacing: { px: "1px", 0: "0px", .../* @__PURE__ */ Ne(4, "rem", 4, 0.5, 0.5), .../* @__PURE__ */ Ne(12, "rem", 4, 5), 14: "3.5rem", .../* @__PURE__ */ Ne(64, "rem", 4, 16, 4), 72: "18rem", 80: "20rem", 96: "24rem" }, durations: { 75: "75ms", 100: "100ms", 150: "150ms", 200: "200ms", 300: "300ms", 500: "500ms", 700: "700ms", 1e3: "1000ms" }, animation: { none: "none", spin: "spin 1s linear infinite", ping: "ping 1s cubic-bezier(0,0,0.2,1) infinite", pulse: "pulse 2s cubic-bezier(0.4,0,0.6,1) infinite", bounce: "bounce 1s infinite" }, aspectRatio: { auto: "auto", square: "1/1", video: "16/9" }, backdropBlur: /* @__PURE__ */ ce("blur"), backdropBrightness: /* @__PURE__ */ ce("brightness"), backdropContrast: /* @__PURE__ */ ce("contrast"), backdropGrayscale: /* @__PURE__ */ ce("grayscale"), backdropHueRotate: /* @__PURE__ */ ce("hueRotate"), backdropInvert: /* @__PURE__ */ ce("invert"), backdropOpacity: /* @__PURE__ */ ce("opacity"), backdropSaturate: /* @__PURE__ */ ce("saturate"), backdropSepia: /* @__PURE__ */ ce("sepia"), backgroundColor: /* @__PURE__ */ ce("colors"), backgroundImage: { none: "none" }, backgroundOpacity: /* @__PURE__ */ ce("opacity"), backgroundSize: { auto: "auto", cover: "cover", contain: "contain" }, blur: { none: "none", 0: "0", sm: "4px", DEFAULT: "8px", md: "12px", lg: "16px", xl: "24px", "2xl": "40px", "3xl": "64px" }, brightness: { .../* @__PURE__ */ Ne(200, "", 100, 0, 50), .../* @__PURE__ */ Ne(110, "", 100, 90, 5), 75: "0.75", 125: "1.25" }, borderColor: ({ theme: e }) => ({ DEFAULT: e("colors.gray.200", "currentColor"), ...e("colors") }), borderOpacity: /* @__PURE__ */ ce("opacity"), borderRadius: { none: "0px", sm: "0.125rem", DEFAULT: "0.25rem", md: "0.375rem", lg: "0.5rem", xl: "0.75rem", "2xl": "1rem", "3xl": "1.5rem", "1/2": "50%", full: "9999px" }, borderSpacing: /* @__PURE__ */ ce("spacing"), borderWidth: { DEFAULT: "1px", .../* @__PURE__ */ He(8, "px") }, boxShadow: { sm: "0 1px 2px 0 rgba(0,0,0,0.05)", DEFAULT: "0 1px 3px 0 rgba(0,0,0,0.1), 0 1px 2px -1px rgba(0,0,0,0.1)", md: "0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1)", lg: "0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1)", xl: "0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1)", "2xl": "0 25px 50px -12px rgba(0,0,0,0.25)", inner: "inset 0 2px 4px 0 rgba(0,0,0,0.05)", none: "0 0 #0000" }, boxShadowColor: ce("colors"), caretColor: /* @__PURE__ */ ce("colors"), accentColor: ({ theme: e }) => ({ auto: "auto", ...e("colors") }), contrast: { .../* @__PURE__ */ Ne(200, "", 100, 0, 50), 75: "0.75", 125: "1.25" }, content: { none: "none" }, divideColor: /* @__PURE__ */ ce("borderColor"), divideOpacity: /* @__PURE__ */ ce("borderOpacity"), divideWidth: /* @__PURE__ */ ce("borderWidth"), dropShadow: { sm: "0 1px 1px rgba(0,0,0,0.05)", DEFAULT: ["0 1px 2px rgba(0,0,0,0.1)", "0 1px 1px rgba(0,0,0,0.06)"], md: ["0 4px 3px rgba(0,0,0,0.07)", "0 2px 2px rgba(0,0,0,0.06)"], lg: ["0 10px 8px rgba(0,0,0,0.04)", "0 4px 3px rgba(0,0,0,0.1)"], xl: ["0 20px 13px rgba(0,0,0,0.03)", "0 8px 5px rgba(0,0,0,0.08)"], "2xl": "0 25px 25px rgba(0,0,0,0.15)", none: "0 0 #0000" }, fill: ({ theme: e }) => ({ ...e("colors"), none: "none" }), grayscale: { DEFAULT: "100%", 0: "0" }, hueRotate: { 0: "0deg", 15: "15deg", 30: "30deg", 60: "60deg", 90: "90deg", 180: "180deg" }, invert: { DEFAULT: "100%", 0: "0" }, flex: { 1: "1 1 0%", auto: "1 1 auto", initial: "0 1 auto", none: "none" }, flexBasis: ({ theme: e }) => ({ ...e("spacing"), ...ln(2, 6), ...ln(12, 12), auto: "auto", full: "100%" }), flexGrow: { DEFAULT: 1, 0: 0 }, flexShrink: { DEFAULT: 1, 0: 0 }, fontFamily: { sans: 'ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"'.split(","), serif: 'ui-serif,Georgia,Cambria,"Times New Roman",Times,serif'.split(","), mono: 'ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace'.split(",") }, fontSize: { xs: ["0.75rem", "1rem"], sm: ["0.875rem", "1.25rem"], base: ["1rem", "1.5rem"], lg: ["1.125rem", "1.75rem"], xl: ["1.25rem", "1.75rem"], "2xl": ["1.5rem", "2rem"], "3xl": ["1.875rem", "2.25rem"], "4xl": ["2.25rem", "2.5rem"], "5xl": ["3rem", "1"], "6xl": ["3.75rem", "1"], "7xl": ["4.5rem", "1"], "8xl": ["6rem", "1"], "9xl": ["8rem", "1"] }, fontWeight: { thin: "100", extralight: "200", light: "300", normal: "400", medium: "500", semibold: "600", bold: "700", extrabold: "800", black: "900" }, gap: /* @__PURE__ */ ce("spacing"), gradientColorStops: /* @__PURE__ */ ce("colors"), gridAutoColumns: { auto: "auto", min: "min-content", max: "max-content", fr: "minmax(0,1fr)" }, gridAutoRows: { auto: "auto", min: "min-content", max: "max-content", fr: "minmax(0,1fr)" }, gridColumn: { auto: "auto", "span-full": "1 / -1" }, gridRow: { auto: "auto", "span-full": "1 / -1" }, gridTemplateColumns: { none: "none" }, gridTemplateRows: { none: "none" }, height: ({ theme: e }) => ({ ...e("spacing"), ...ln(2, 6), min: "min-content", max: "max-content", fit: "fit-content", auto: "auto", full: "100%", screen: "100vh" }), inset: ({ theme: e }) => ({ ...e("spacing"), ...ln(2, 4), auto: "auto", full: "100%" }), keyframes: { spin: { from: { transform: "rotate(0deg)" }, to: { transform: "rotate(360deg)" } }, ping: { "0%": { transform: "scale(1)", opacity: "1" }, "75%,100%": { transform: "scale(2)", opacity: "0" } }, pulse: { "0%,100%": { opacity: "1" }, "50%": { opacity: ".5" } }, bounce: { "0%, 100%": { transform: "translateY(-25%)", animationTimingFunction: "cubic-bezier(0.8,0,1,1)" }, "50%": { transform: "none", animationTimingFunction: "cubic-bezier(0,0,0.2,1)" } } }, letterSpacing: { tighter: "-0.05em", tight: "-0.025em", normal: "0em", wide: "0.025em", wider: "0.05em", widest: "0.1em" }, lineHeight: { .../* @__PURE__ */ Ne(10, "rem", 4, 3), none: "1", tight: "1.25", snug: "1.375", normal: "1.5", relaxed: "1.625", loose: "2" }, margin: ({ theme: e }) => ({ auto: "auto", ...e("spacing") }), maxHeight: ({ theme: e }) => ({ full: "100%", min: "min-content", max: "max-content", fit: "fit-content", screen: "100vh", ...e("spacing") }), maxWidth: ({ theme: e, breakpoints: t }) => ({ ...t(e("screens")), none: "none", 0: "0rem", xs: "20rem", sm: "24rem", md: "28rem", lg: "32rem", xl: "36rem", "2xl": "42rem", "3xl": "48rem", "4xl": "56rem", "5xl": "64rem", "6xl": "72rem", "7xl": "80rem", full: "100%", min: "min-content", max: "max-content", fit: "fit-content", prose: "65ch" }), minHeight: { 0: "0px", full: "100%", min: "min-content", max: "max-content", fit: "fit-content", screen: "100vh" }, minWidth: { 0: "0px", full: "100%", min: "min-content", max: "max-content", fit: "fit-content" }, opacity: { .../* @__PURE__ */ Ne(100, "", 100, 0, 10), 5: "0.05", 25: "0.25", 75: "0.75", 95: "0.95" }, order: { first: "-9999", last: "9999", none: "0" }, padding: /* @__PURE__ */ ce("spacing"), placeholderColor: /* @__PURE__ */ ce("colors"), placeholderOpacity: /* @__PURE__ */ ce("opacity"), outlineColor: /* @__PURE__ */ ce("colors"), outlineOffset: /* @__PURE__ */ He(8, "px"), outlineWidth: /* @__PURE__ */ He(8, "px"), ringColor: ({ theme: e }) => ({ ...e("colors"), DEFAULT: "#3b82f6" }), ringOffsetColor: /* @__PURE__ */ ce("colors"), ringOffsetWidth: /* @__PURE__ */ He(8, "px"), ringOpacity: ({ theme: e }) => ({ ...e("opacity"), DEFAULT: "0.5" }), ringWidth: { DEFAULT: "3px", .../* @__PURE__ */ He(8, "px") }, rotate: { .../* @__PURE__ */ He(2, "deg"), .../* @__PURE__ */ He(12, "deg", 3), .../* @__PURE__ */ He(180, "deg", 45) }, saturate: /* @__PURE__ */ Ne(200, "", 100, 0, 50), scale: { .../* @__PURE__ */ Ne(150, "", 100, 0, 50), .../* @__PURE__ */ Ne(110, "", 100, 90, 5), 75: "0.75", 125: "1.25" }, scrollMargin: /* @__PURE__ */ ce("spacing"), scrollPadding: /* @__PURE__ */ ce("spacing"), sepia: { 0: "0", DEFAULT: "100%" }, skew: { .../* @__PURE__ */ He(2, "deg"), .../* @__PURE__ */ He(12, "deg", 3) }, space: /* @__PURE__ */ ce("spacing"), stroke: ({ theme: e }) => ({ ...e("colors"), none: "none" }), strokeWidth: /* @__PURE__ */ Ne(2), textColor: /* @__PURE__ */ ce("colors"), textDecorationColor: /* @__PURE__ */ ce("colors"), textDecorationThickness: { "from-font": "from-font", auto: "auto", .../* @__PURE__ */ He(8, "px") }, textUnderlineOffset: { auto: "auto", .../* @__PURE__ */ He(8, "px") }, textIndent: /* @__PURE__ */ ce("spacing"), textOpacity: /* @__PURE__ */ ce("opacity"), transitionDuration: ({ theme: e }) => ({ ...e("durations"), DEFAULT: "150ms" }), transitionDelay: /* @__PURE__ */ ce("durations"), transitionProperty: { none: "none", all: "all", DEFAULT: "color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter", colors: "color,background-color,border-color,text-decoration-color,fill,stroke", opacity: "opacity", shadow: "box-shadow", transform: "transform" }, transitionTimingFunction: { DEFAULT: "cubic-bezier(0.4,0,0.2,1)", linear: "linear", in: "cubic-bezier(0.4,0,1,1)", out: "cubic-bezier(0,0,0.2,1)", "in-out": "cubic-bezier(0.4,0,0.2,1)" }, translate: ({ theme: e }) => ({ ...e("spacing"), ...ln(2, 4), full: "100%" }), width: ({ theme: e }) => ({ min: "min-content", max: "max-content", fit: "fit-content", screen: "100vw", ...e("flexBasis") }), willChange: { scroll: "scroll-position" }, zIndex: { .../* @__PURE__ */ Ne(50, "", 1, 0, 10), auto: "auto" } }; +function ln(e, t) { + let n = {}; + do + for (var r = 1; r < e; r++) n[`${r}/${e}`] = Number((r / e * 100).toFixed(6)) + "%"; + while (++e <= t); + return n; +} +function He(e, t, n = 0) { + let r = {}; + for (; n <= e; n = 2 * n || 1) r[n] = n + t; + return r; +} +function Ne(e, t = "", n = 1, r = 0, o = 1, i = {}) { + for (; r <= e; r += o) i[r] = r / n + t; + return i; +} +function ce(e) { + return ({ theme: t }) => t(e); +} +let e5 = { "*,::before,::after": { boxSizing: "border-box", borderWidth: "0", borderStyle: "solid", borderColor: "theme(borderColor.DEFAULT, currentColor)" }, "::before,::after": { "--tw-content": "''" }, html: { lineHeight: 1.5, WebkitTextSizeAdjust: "100%", MozTabSize: "4", tabSize: 4, fontFamily: `theme(fontFamily.sans, ${Wo.fontFamily.sans})`, fontFeatureSettings: "theme(fontFamily.sans[1].fontFeatureSettings, normal)" }, body: { margin: "0", lineHeight: "inherit" }, hr: { height: "0", color: "inherit", borderTopWidth: "1px" }, "abbr:where([title])": { textDecoration: "underline dotted" }, "h1,h2,h3,h4,h5,h6": { fontSize: "inherit", fontWeight: "inherit" }, a: { color: "inherit", textDecoration: "inherit" }, "b,strong": { fontWeight: "bolder" }, "code,kbd,samp,pre": { fontFamily: `theme(fontFamily.mono, ${Wo.fontFamily.mono})`, fontFeatureSettings: "theme(fontFamily.mono[1].fontFeatureSettings, normal)", fontSize: "1em" }, small: { fontSize: "80%" }, "sub,sup": { fontSize: "75%", lineHeight: 0, position: "relative", verticalAlign: "baseline" }, sub: { bottom: "-0.25em" }, sup: { top: "-0.5em" }, table: { textIndent: "0", borderColor: "inherit", borderCollapse: "collapse" }, "button,input,optgroup,select,textarea": { fontFamily: "inherit", fontSize: "100%", lineHeight: "inherit", color: "inherit", margin: "0", padding: "0" }, "button,select": { textTransform: "none" }, "button,[type='button'],[type='reset'],[type='submit']": { WebkitAppearance: "button", backgroundColor: "transparent", backgroundImage: "none" }, ":-moz-focusring": { outline: "auto" }, ":-moz-ui-invalid": { boxShadow: "none" }, progress: { verticalAlign: "baseline" }, "::-webkit-inner-spin-button,::-webkit-outer-spin-button": { height: "auto" }, "[type='search']": { WebkitAppearance: "textfield", outlineOffset: "-2px" }, "::-webkit-search-decoration": { WebkitAppearance: "none" }, "::-webkit-file-upload-button": { WebkitAppearance: "button", font: "inherit" }, summary: { display: "list-item" }, "blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre": { margin: "0" }, fieldset: { margin: "0", padding: "0" }, legend: { padding: "0" }, "ol,ul,menu": { listStyle: "none", margin: "0", padding: "0" }, textarea: { resize: "vertical" }, "input::placeholder,textarea::placeholder": { opacity: 1, color: "theme(colors.gray.400, #9ca3af)" }, 'button,[role="button"]': { cursor: "pointer" }, ":disabled": { cursor: "default" }, "img,svg,video,canvas,audio,iframe,embed,object": { display: "block", verticalAlign: "middle" }, "img,video": { maxWidth: "100%", height: "auto" }, "[hidden]": { display: "none" } }, t5 = [j("\\[([-\\w]+):(.+)]", ({ 1: e, 2: t }, n) => ({ "@layer overrides": { "&": { [e]: wt(`[${t}]`, "", n) } } })), j("(group|peer)([~/][^-[]+)?", ({ input: e }, { h: t }) => [{ c: t(e) }]), z("aspect-", "aspectRatio"), j("container", (e, { theme: t }) => { + let { screens: n = t("screens"), center: r, padding: o } = t("container"), i = { width: "100%", marginRight: r && "auto", marginLeft: r && "auto", ...s("xs") }; + for (let c in n) { + let a = n[c]; + typeof a == "string" && (i[Zi(a)] = { "&": { maxWidth: a, ...s(c) } }); + } + return i; + function s(c) { + let a = o && (typeof o == "string" ? o : o[c] || o.DEFAULT); + if (a) return { paddingRight: a, paddingLeft: a }; + } +}), z("content-", "content", ({ _: e }) => ({ "--tw-content": e, content: "var(--tw-content)" })), j("(?:box-)?decoration-(slice|clone)", "boxDecorationBreak"), j("box-(border|content)", "boxSizing", ({ 1: e }) => e + "-box"), j("hidden", { display: "none" }), j("table-(auto|fixed)", "tableLayout"), j(["(block|flex|table|grid|inline|contents|flow-root|list-item)", "(inline-(block|flex|table|grid))", "(table-(caption|cell|column|row|(column|row|footer|header)-group))"], "display"), "(float)-(left|right|none)", "(clear)-(left|right|none|both)", "(overflow(?:-[xy])?)-(auto|hidden|clip|visible|scroll)", "(isolation)-(auto)", j("isolate", "isolation"), j("object-(contain|cover|fill|none|scale-down)", "objectFit"), z("object-", "objectPosition"), j("object-(top|bottom|center|(left|right)(-(top|bottom))?)", "objectPosition", On), j("overscroll(-[xy])?-(auto|contain|none)", ({ 1: e = "", 2: t }) => ({ ["overscroll-behavior" + e]: t })), j("(static|fixed|absolute|relative|sticky)", "position"), z("-?inset(-[xy])?(?:$|-)", "inset", ({ 1: e, _: t }) => ({ top: e != "-x" && t, right: e != "-y" && t, bottom: e != "-x" && t, left: e != "-y" && t })), z("-?(top|bottom|left|right)(?:$|-)", "inset"), j("(visible|collapse)", "visibility"), j("invisible", { visibility: "hidden" }), z("-?z-", "zIndex"), j("flex-((row|col)(-reverse)?)", "flexDirection", ua), j("flex-(wrap|wrap-reverse|nowrap)", "flexWrap"), z("(flex-(?:grow|shrink))(?:$|-)"), z("(flex)-"), z("grow(?:$|-)", "flexGrow"), z("shrink(?:$|-)", "flexShrink"), z("basis-", "flexBasis"), z("-?(order)-"), "-?(order)-(\\d+)", z("grid-cols-", "gridTemplateColumns"), j("grid-cols-(\\d+)", "gridTemplateColumns", ga), z("col-", "gridColumn"), j("col-(span)-(\\d+)", "gridColumn", pa), z("col-start-", "gridColumnStart"), j("col-start-(auto|\\d+)", "gridColumnStart"), z("col-end-", "gridColumnEnd"), j("col-end-(auto|\\d+)", "gridColumnEnd"), z("grid-rows-", "gridTemplateRows"), j("grid-rows-(\\d+)", "gridTemplateRows", ga), z("row-", "gridRow"), j("row-(span)-(\\d+)", "gridRow", pa), z("row-start-", "gridRowStart"), j("row-start-(auto|\\d+)", "gridRowStart"), z("row-end-", "gridRowEnd"), j("row-end-(auto|\\d+)", "gridRowEnd"), j("grid-flow-((row|col)(-dense)?)", "gridAutoFlow", (e) => On(ua(e))), j("grid-flow-(dense)", "gridAutoFlow"), z("auto-cols-", "gridAutoColumns"), z("auto-rows-", "gridAutoRows"), z("gap-x(?:$|-)", "gap", "columnGap"), z("gap-y(?:$|-)", "gap", "rowGap"), z("gap(?:$|-)", "gap"), "(justify-(?:items|self))-", j("justify-", "justifyContent", ha), j("(content|items|self)-", (e) => ({ ["align-" + e[1]]: ha(e) })), j("(place-(content|items|self))-", ({ 1: e, $$: t }) => ({ [e]: ("wun".includes(t[3]) ? "space-" : "") + t })), z("p([xytrbl])?(?:$|-)", "padding", Dt("padding")), z("-?m([xytrbl])?(?:$|-)", "margin", Dt("margin")), z("-?space-(x|y)(?:$|-)", "space", ({ 1: e, _: t }) => ({ "&>:not([hidden])~:not([hidden])": { [`--tw-space-${e}-reverse`]: "0", ["margin-" + { y: "top", x: "left" }[e]]: `calc(${t} * calc(1 - var(--tw-space-${e}-reverse)))`, ["margin-" + { y: "bottom", x: "right" }[e]]: `calc(${t} * var(--tw-space-${e}-reverse))` } })), j("space-(x|y)-reverse", ({ 1: e }) => ({ "&>:not([hidden])~:not([hidden])": { [`--tw-space-${e}-reverse`]: "1" } })), z("w-", "width"), z("min-w-", "minWidth"), z("max-w-", "maxWidth"), z("h-", "height"), z("min-h-", "minHeight"), z("max-h-", "maxHeight"), z("font-", "fontWeight"), z("font-", "fontFamily", ({ _: e }) => typeof (e = we(e))[1] == "string" ? { fontFamily: Ze(e) } : { fontFamily: Ze(e[0]), ...e[1] }), j("antialiased", { WebkitFontSmoothing: "antialiased", MozOsxFontSmoothing: "grayscale" }), j("subpixel-antialiased", { WebkitFontSmoothing: "auto", MozOsxFontSmoothing: "auto" }), j("italic", "fontStyle"), j("not-italic", { fontStyle: "normal" }), j("(ordinal|slashed-zero|(normal|lining|oldstyle|proportional|tabular)-nums|(diagonal|stacked)-fractions)", ({ 1: e, 2: t = "", 3: n }) => t == "normal" ? { fontVariantNumeric: "normal" } : { ["--tw-" + (n ? "numeric-fraction" : "pt".includes(t[0]) ? "numeric-spacing" : t ? "numeric-figure" : e)]: e, fontVariantNumeric: "var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)", ...ht({ "--tw-ordinal": "var(--tw-empty,/*!*/ /*!*/)", "--tw-slashed-zero": "var(--tw-empty,/*!*/ /*!*/)", "--tw-numeric-figure": "var(--tw-empty,/*!*/ /*!*/)", "--tw-numeric-spacing": "var(--tw-empty,/*!*/ /*!*/)", "--tw-numeric-fraction": "var(--tw-empty,/*!*/ /*!*/)" }) }), z("tracking-", "letterSpacing"), z("leading-", "lineHeight"), j("list-(inside|outside)", "listStylePosition"), z("list-", "listStyleType"), j("list-", "listStyleType"), z("placeholder-opacity-", "placeholderOpacity", ({ _: e }) => ({ "&::placeholder": { "--tw-placeholder-opacity": e } })), Ce("placeholder-", { property: "color", selector: "&::placeholder" }), j("text-(left|center|right|justify|start|end)", "textAlign"), j("text-(ellipsis|clip)", "textOverflow"), z("text-opacity-", "textOpacity", "--tw-text-opacity"), Ce("text-", { property: "color" }), z("text-", "fontSize", ({ _: e }) => typeof e == "string" ? { fontSize: e } : { fontSize: e[0], ...typeof e[1] == "string" ? { lineHeight: e[1] } : e[1] }), z("indent-", "textIndent"), j("(overline|underline|line-through)", "textDecorationLine"), j("no-underline", { textDecorationLine: "none" }), z("underline-offset-", "textUnderlineOffset"), Ce("decoration-", { section: "textDecorationColor", opacityVariable: !1, opacitySection: "opacity" }), z("decoration-", "textDecorationThickness"), j("decoration-", "textDecorationStyle"), j("(uppercase|lowercase|capitalize)", "textTransform"), j("normal-case", { textTransform: "none" }), j("truncate", { overflow: "hidden", whiteSpace: "nowrap", textOverflow: "ellipsis" }), j("align-", "verticalAlign"), j("whitespace-", "whiteSpace"), j("break-normal", { wordBreak: "normal", overflowWrap: "normal" }), j("break-words", { overflowWrap: "break-word" }), j("break-all", { wordBreak: "break-all" }), j("break-keep", { wordBreak: "keep-all" }), Ce("caret-", { opacityVariable: !1, opacitySection: "opacity" }), Ce("accent-", { opacityVariable: !1, opacitySection: "opacity" }), j("bg-gradient-to-([trbl]|[tb][rl])", "backgroundImage", ({ 1: e }) => `linear-gradient(to ${St(e, " ")},var(--tw-gradient-stops))`), Ce("from-", { section: "gradientColorStops", opacityVariable: !1, opacitySection: "opacity" }, ({ _: e }) => ({ "--tw-gradient-from": e.value, "--tw-gradient-to": e.color({ opacityValue: "0" }), "--tw-gradient-stops": "var(--tw-gradient-from),var(--tw-gradient-to)" })), Ce("via-", { section: "gradientColorStops", opacityVariable: !1, opacitySection: "opacity" }, ({ _: e }) => ({ "--tw-gradient-to": e.color({ opacityValue: "0" }), "--tw-gradient-stops": `var(--tw-gradient-from),${e.value},var(--tw-gradient-to)` })), Ce("to-", { section: "gradientColorStops", property: "--tw-gradient-to", opacityVariable: !1, opacitySection: "opacity" }), j("bg-(fixed|local|scroll)", "backgroundAttachment"), j("bg-origin-(border|padding|content)", "backgroundOrigin", ({ 1: e }) => e + "-box"), j(["bg-(no-repeat|repeat(-[xy])?)", "bg-repeat-(round|space)"], "backgroundRepeat"), j("bg-blend-", "backgroundBlendMode"), j("bg-clip-(border|padding|content|text)", "backgroundClip", ({ 1: e }) => e + (e == "text" ? "" : "-box")), z("bg-opacity-", "backgroundOpacity", "--tw-bg-opacity"), Ce("bg-", { section: "backgroundColor" }), z("bg-", "backgroundImage"), z("bg-", "backgroundPosition"), j("bg-(top|bottom|center|(left|right)(-(top|bottom))?)", "backgroundPosition", On), z("bg-", "backgroundSize"), z("rounded(?:$|-)", "borderRadius"), z("rounded-([trbl]|[tb][rl])(?:$|-)", "borderRadius", ({ 1: e, _: t }) => { + let n = { t: ["tl", "tr"], r: ["tr", "br"], b: ["bl", "br"], l: ["bl", "tl"] }[e] || [e, e]; + return { [`border-${St(n[0])}-radius`]: t, [`border-${St(n[1])}-radius`]: t }; +}), j("border-(collapse|separate)", "borderCollapse"), z("border-opacity(?:$|-)", "borderOpacity", "--tw-border-opacity"), j("border-(solid|dashed|dotted|double|none)", "borderStyle"), z("border-spacing(-[xy])?(?:$|-)", "borderSpacing", ({ 1: e, _: t }) => ({ ...ht({ "--tw-border-spacing-x": "0", "--tw-border-spacing-y": "0" }), ["--tw-border-spacing" + (e || "-x")]: t, ["--tw-border-spacing" + (e || "-y")]: t, "border-spacing": "var(--tw-border-spacing-x) var(--tw-border-spacing-y)" })), Ce("border-([xytrbl])-", { section: "borderColor" }, Dt("border", "Color")), Ce("border-"), z("border-([xytrbl])(?:$|-)", "borderWidth", Dt("border", "Width")), z("border(?:$|-)", "borderWidth"), z("divide-opacity(?:$|-)", "divideOpacity", ({ _: e }) => ({ "&>:not([hidden])~:not([hidden])": { "--tw-divide-opacity": e } })), j("divide-(solid|dashed|dotted|double|none)", ({ 1: e }) => ({ "&>:not([hidden])~:not([hidden])": { borderStyle: e } })), j("divide-([xy]-reverse)", ({ 1: e }) => ({ "&>:not([hidden])~:not([hidden])": { ["--tw-divide-" + e]: "1" } })), z("divide-([xy])(?:$|-)", "divideWidth", ({ 1: e, _: t }) => { + let n = { x: "lr", y: "tb" }[e]; + return { "&>:not([hidden])~:not([hidden])": { [`--tw-divide-${e}-reverse`]: "0", [`border-${St(n[0])}Width`]: `calc(${t} * calc(1 - var(--tw-divide-${e}-reverse)))`, [`border-${St(n[1])}Width`]: `calc(${t} * var(--tw-divide-${e}-reverse))` } }; +}), Ce("divide-", { property: "borderColor", selector: "&>:not([hidden])~:not([hidden])" }), z("ring-opacity(?:$|-)", "ringOpacity", "--tw-ring-opacity"), Ce("ring-offset-", { property: "--tw-ring-offset-color", opacityVariable: !1 }), z("ring-offset(?:$|-)", "ringOffsetWidth", "--tw-ring-offset-width"), j("ring-inset", { "--tw-ring-inset": "inset" }), Ce("ring-", { property: "--tw-ring-color" }), z("ring(?:$|-)", "ringWidth", ({ _: e }, { theme: t }) => ({ ...ht({ "--tw-ring-offset-shadow": "0 0 #0000", "--tw-ring-shadow": "0 0 #0000", "--tw-shadow": "0 0 #0000", "--tw-shadow-colored": "0 0 #0000", "&": { "--tw-ring-inset": "var(--tw-empty,/*!*/ /*!*/)", "--tw-ring-offset-width": t("ringOffsetWidth", "", "0px"), "--tw-ring-offset-color": gt(t("ringOffsetColor", "", "#fff")), "--tw-ring-color": gt(t("ringColor", "", "#93c5fd"), { opacityVariable: "--tw-ring-opacity" }), "--tw-ring-opacity": t("ringOpacity", "", "0.5") } }), "--tw-ring-offset-shadow": "var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)", "--tw-ring-shadow": `var(--tw-ring-inset) 0 0 0 calc(${e} + var(--tw-ring-offset-width)) var(--tw-ring-color)`, boxShadow: "var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)" })), Ce("shadow-", { section: "boxShadowColor", opacityVariable: !1, opacitySection: "opacity" }, ({ _: e }) => ({ "--tw-shadow-color": e.value, "--tw-shadow": "var(--tw-shadow-colored)" })), z("shadow(?:$|-)", "boxShadow", ({ _: e }) => ({ ...ht({ "--tw-ring-offset-shadow": "0 0 #0000", "--tw-ring-shadow": "0 0 #0000", "--tw-shadow": "0 0 #0000", "--tw-shadow-colored": "0 0 #0000" }), "--tw-shadow": Ze(e), "--tw-shadow-colored": Ze(e).replace(/([^,]\s+)(?:#[a-f\d]+|(?:(?:hsl|rgb)a?|hwb|lab|lch|color|var)\(.+?\)|[a-z]+)(,|$)/g, "$1var(--tw-shadow-color)$2"), boxShadow: "var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)" })), z("(opacity)-"), j("mix-blend-", "mixBlendMode"), ...fa(), ...fa("backdrop-"), z("transition(?:$|-)", "transitionProperty", (e, { theme: t }) => ({ transitionProperty: Ze(e), transitionTimingFunction: e._ == "none" ? void 0 : Ze(t("transitionTimingFunction", "")), transitionDuration: e._ == "none" ? void 0 : Ze(t("transitionDuration", "")) })), z("duration(?:$|-)", "transitionDuration", "transitionDuration", Ze), z("ease(?:$|-)", "transitionTimingFunction", "transitionTimingFunction", Ze), z("delay(?:$|-)", "transitionDelay", "transitionDelay", Ze), z("animate(?:$|-)", "animation", (e, { theme: t, h: n, e: r }) => { + let o = Ze(e), i = o.split(" "), s = t("keyframes", i[0]); + return s ? { ["@keyframes " + (i[0] = r(n(i[0])))]: s, animation: i.join(" ") } : { animation: o }; +}), "(transform)-(none)", j("transform", Fo), j("transform-(cpu|gpu)", ({ 1: e }) => ({ "--tw-transform": B2(e == "gpu") })), z("scale(-[xy])?-", "scale", ({ 1: e, _: t }) => ({ ["--tw-scale" + (e || "-x")]: t, ["--tw-scale" + (e || "-y")]: t, ...Fo() })), z("-?(rotate)-", "rotate", oo), z("-?(translate-[xy])-", "translate", oo), z("-?(skew-[xy])-", "skew", oo), j("origin-(center|((top|bottom)(-(left|right))?)|left|right)", "transformOrigin", On), "(appearance)-", z("(columns)-"), "(columns)-(\\d+)", "(break-(?:before|after|inside))-", z("(cursor)-"), "(cursor)-", j("snap-(none)", "scroll-snap-type"), j("snap-(x|y|both)", ({ 1: e }) => ({ ...ht({ "--tw-scroll-snap-strictness": "proximity" }), "scroll-snap-type": e + " var(--tw-scroll-snap-strictness)" })), j("snap-(mandatory|proximity)", "--tw-scroll-snap-strictness"), j("snap-(?:(start|end|center)|align-(none))", "scroll-snap-align"), j("snap-(normal|always)", "scroll-snap-stop"), j("scroll-(auto|smooth)", "scroll-behavior"), z("scroll-p([xytrbl])?(?:$|-)", "padding", Dt("scroll-padding")), z("-?scroll-m([xytrbl])?(?:$|-)", "scroll-margin", Dt("scroll-margin")), j("touch-(auto|none|manipulation)", "touch-action"), j("touch-(pinch-zoom|pan-(?:(x|left|right)|(y|up|down)))", ({ 1: e, 2: t, 3: n }) => ({ ...ht({ "--tw-pan-x": "var(--tw-empty,/*!*/ /*!*/)", "--tw-pan-y": "var(--tw-empty,/*!*/ /*!*/)", "--tw-pinch-zoom": "var(--tw-empty,/*!*/ /*!*/)", "--tw-touch-action": "var(--tw-pan-x) var(--tw-pan-y) var(--tw-pinch-zoom)" }), [`--tw-${t ? "pan-x" : n ? "pan-y" : e}`]: e, "touch-action": "var(--tw-touch-action)" })), j("outline-none", { outline: "2px solid transparent", "outline-offset": "2px" }), j("outline", { outlineStyle: "solid" }), j("outline-(dashed|dotted|double)", "outlineStyle"), z("-?(outline-offset)-"), Ce("outline-", { opacityVariable: !1, opacitySection: "opacity" }), z("outline-", "outlineWidth"), "(pointer-events)-", z("(will-change)-"), "(will-change)-", ["resize(?:-(none|x|y))?", "resize", ({ 1: e }) => ({ x: "horizontal", y: "vertical" })[e] || e || "both"], j("select-(none|text|all|auto)", "userSelect"), Ce("fill-", { section: "fill", opacityVariable: !1, opacitySection: "opacity" }), Ce("stroke-", { section: "stroke", opacityVariable: !1, opacitySection: "opacity" }), z("stroke-", "strokeWidth"), j("sr-only", { position: "absolute", width: "1px", height: "1px", padding: "0", margin: "-1px", overflow: "hidden", whiteSpace: "nowrap", clip: "rect(0,0,0,0)", borderWidth: "0" }), j("not-sr-only", { position: "static", width: "auto", height: "auto", padding: "0", margin: "0", overflow: "visible", whiteSpace: "normal", clip: "auto" })]; +function On(e) { + return (typeof e == "string" ? e : e[1]).replace(/-/g, " ").trim(); +} +function ua(e) { + return (typeof e == "string" ? e : e[1]).replace("col", "column"); +} +function St(e, t = "-") { + let n = []; + for (let r of e) n.push({ t: "top", r: "right", b: "bottom", l: "left" }[r]); + return n.join(t); +} +function Ze(e) { + return e && "" + (e._ || e); +} +function ha({ $$: e }) { + return ({ r: "flex-", "": "flex-", w: "space-", u: "space-", n: "space-" }[e[3] || ""] || "") + e; +} +function Dt(e, t = "") { + return ({ 1: n, _: r }) => { + let o = { x: "lr", y: "tb" }[n] || n + n; + return o ? { ...Yn(e + "-" + St(o[0]) + t, r), ...Yn(e + "-" + St(o[1]) + t, r) } : Yn(e + t, r); + }; +} +function fa(e = "") { + let t = ["blur", "brightness", "contrast", "grayscale", "hue-rotate", "invert", e && "opacity", "saturate", "sepia", !e && "drop-shadow"].filter(Boolean), n = {}; + for (let r of t) n[`--tw-${e}${r}`] = "var(--tw-empty,/*!*/ /*!*/)"; + return n = { ...ht(n), [`${e}filter`]: t.map((r) => `var(--tw-${e}${r})`).join(" ") }, [`(${e}filter)-(none)`, j(`${e}filter`, n), ...t.map((r) => z(`${r[0] == "h" ? "-?" : ""}(${e}${r})(?:$|-)`, r, ({ 1: o, _: i }) => ({ [`--tw-${o}`]: we(i).map((s) => `${r}(${s})`).join(" "), ...n })))]; +} +function oo({ 1: e, _: t }) { + return { ["--tw-" + e]: t, ...Fo() }; +} +function Fo() { + return { ...ht({ "--tw-translate-x": "0", "--tw-translate-y": "0", "--tw-rotate": "0", "--tw-skew-x": "0", "--tw-skew-y": "0", "--tw-scale-x": "1", "--tw-scale-y": "1", "--tw-transform": B2() }), transform: "var(--tw-transform)" }; +} +function B2(e) { + return [e ? "translate3d(var(--tw-translate-x),var(--tw-translate-y),0)" : "translateX(var(--tw-translate-x)) translateY(var(--tw-translate-y))", "rotate(var(--tw-rotate))", "skewX(var(--tw-skew-x))", "skewY(var(--tw-skew-y))", "scaleX(var(--tw-scale-x))", "scaleY(var(--tw-scale-y))"].join(" "); +} +function pa({ 1: e, 2: t }) { + return `${e} ${t} / ${e} ${t}`; +} +function ga({ 1: e }) { + return `repeat(${e},minmax(0,1fr))`; +} +function ht(e) { + return { "@layer defaults": { "*,::before,::after": e, "::backdrop": e } }; +} +let n5 = [["sticky", "@supports ((position: -webkit-sticky) or (position:sticky))"], ["motion-reduce", "@media (prefers-reduced-motion:reduce)"], ["motion-safe", "@media (prefers-reduced-motion:no-preference)"], ["print", "@media print"], ["(portrait|landscape)", ({ 1: e }) => `@media (orientation:${e})`], ["contrast-(more|less)", ({ 1: e }) => `@media (prefers-contrast:${e})`], ["(first-(letter|line)|placeholder|backdrop|before|after)", ({ 1: e }) => `&::${e}`], ["(marker|selection)", ({ 1: e }) => `& *::${e},&::${e}`], ["file", "&::file-selector-button"], ["(first|last|only)", ({ 1: e }) => `&:${e}-child`], ["even", "&:nth-child(2n)"], ["odd", "&:nth-child(odd)"], ["open", "&[open]"], ["(aria|data)-", ({ 1: e, $$: t }, n) => t && `&[${e}-${n.theme(e, t) || wt(t, "", n) || `${t}="true"`}]`], ["((group|peer)(~[^-[]+)?)(-\\[(.+)]|[-[].+?)(\\/.+)?", ({ 2: e, 3: t = "", 4: n, 5: r = "", 6: o = t }, { e: i, h: s, v: c }) => { + let a = _n(r) || (n[0] == "[" ? n : c(n.slice(1))); + return `${(a.includes("&") ? a : "&" + a).replace(/&/g, `:merge(.${i(s(e + o))})`)}${e[0] == "p" ? "~" : " "}&`; +}], ["(ltr|rtl)", ({ 1: e }) => `[dir="${e}"] &`], ["supports-", ({ $$: e }, t) => { + if (e && (e = t.theme("supports", e) || wt(e, "", t)), e) return e.includes(":") || (e += ":var(--tw)"), /^\w*\s*\(/.test(e) || (e = `(${e})`), `@supports ${e.replace(/\b(and|or|not)\b/g, " $1 ").trim()}`; +}], ["max-", ({ $$: e }, t) => { + if (e && (e = t.theme("screens", e) || wt(e, "", t)), typeof e == "string") return `@media not all and (min-width:${e})`; +}], ["min-", ({ $$: e }, t) => (e && (e = wt(e, "", t)), e && `@media (min-width:${e})`)], [/^\[(.+)]$/, ({ 1: e }) => /[&@]/.test(e) && _n(e).replace(/[}]+$/, "").split("{")]], r5 = { __proto__: null, slate: { 50: "#f8fafc", 100: "#f1f5f9", 200: "#e2e8f0", 300: "#cbd5e1", 400: "#94a3b8", 500: "#64748b", 600: "#475569", 700: "#334155", 800: "#1e293b", 900: "#0f172a" }, gray: { 50: "#f9fafb", 100: "#f3f4f6", 200: "#e5e7eb", 300: "#d1d5db", 400: "#9ca3af", 500: "#6b7280", 600: "#4b5563", 700: "#374151", 800: "#1f2937", 900: "#111827" }, zinc: { 50: "#fafafa", 100: "#f4f4f5", 200: "#e4e4e7", 300: "#d4d4d8", 400: "#a1a1aa", 500: "#71717a", 600: "#52525b", 700: "#3f3f46", 800: "#27272a", 900: "#18181b" }, neutral: { 50: "#fafafa", 100: "#f5f5f5", 200: "#e5e5e5", 300: "#d4d4d4", 400: "#a3a3a3", 500: "#737373", 600: "#525252", 700: "#404040", 800: "#262626", 900: "#171717" }, stone: { 50: "#fafaf9", 100: "#f5f5f4", 200: "#e7e5e4", 300: "#d6d3d1", 400: "#a8a29e", 500: "#78716c", 600: "#57534e", 700: "#44403c", 800: "#292524", 900: "#1c1917" }, red: { 50: "#fef2f2", 100: "#fee2e2", 200: "#fecaca", 300: "#fca5a5", 400: "#f87171", 500: "#ef4444", 600: "#dc2626", 700: "#b91c1c", 800: "#991b1b", 900: "#7f1d1d" }, orange: { 50: "#fff7ed", 100: "#ffedd5", 200: "#fed7aa", 300: "#fdba74", 400: "#fb923c", 500: "#f97316", 600: "#ea580c", 700: "#c2410c", 800: "#9a3412", 900: "#7c2d12" }, amber: { 50: "#fffbeb", 100: "#fef3c7", 200: "#fde68a", 300: "#fcd34d", 400: "#fbbf24", 500: "#f59e0b", 600: "#d97706", 700: "#b45309", 800: "#92400e", 900: "#78350f" }, yellow: { 50: "#fefce8", 100: "#fef9c3", 200: "#fef08a", 300: "#fde047", 400: "#facc15", 500: "#eab308", 600: "#ca8a04", 700: "#a16207", 800: "#854d0e", 900: "#713f12" }, lime: { 50: "#f7fee7", 100: "#ecfccb", 200: "#d9f99d", 300: "#bef264", 400: "#a3e635", 500: "#84cc16", 600: "#65a30d", 700: "#4d7c0f", 800: "#3f6212", 900: "#365314" }, green: { 50: "#f0fdf4", 100: "#dcfce7", 200: "#bbf7d0", 300: "#86efac", 400: "#4ade80", 500: "#22c55e", 600: "#16a34a", 700: "#15803d", 800: "#166534", 900: "#14532d" }, emerald: { 50: "#ecfdf5", 100: "#d1fae5", 200: "#a7f3d0", 300: "#6ee7b7", 400: "#34d399", 500: "#10b981", 600: "#059669", 700: "#047857", 800: "#065f46", 900: "#064e3b" }, teal: { 50: "#f0fdfa", 100: "#ccfbf1", 200: "#99f6e4", 300: "#5eead4", 400: "#2dd4bf", 500: "#14b8a6", 600: "#0d9488", 700: "#0f766e", 800: "#115e59", 900: "#134e4a" }, cyan: { 50: "#ecfeff", 100: "#cffafe", 200: "#a5f3fc", 300: "#67e8f9", 400: "#22d3ee", 500: "#06b6d4", 600: "#0891b2", 700: "#0e7490", 800: "#155e75", 900: "#164e63" }, sky: { 50: "#f0f9ff", 100: "#e0f2fe", 200: "#bae6fd", 300: "#7dd3fc", 400: "#38bdf8", 500: "#0ea5e9", 600: "#0284c7", 700: "#0369a1", 800: "#075985", 900: "#0c4a6e" }, blue: { 50: "#eff6ff", 100: "#dbeafe", 200: "#bfdbfe", 300: "#93c5fd", 400: "#60a5fa", 500: "#3b82f6", 600: "#2563eb", 700: "#1d4ed8", 800: "#1e40af", 900: "#1e3a8a" }, indigo: { 50: "#eef2ff", 100: "#e0e7ff", 200: "#c7d2fe", 300: "#a5b4fc", 400: "#818cf8", 500: "#6366f1", 600: "#4f46e5", 700: "#4338ca", 800: "#3730a3", 900: "#312e81" }, violet: { 50: "#f5f3ff", 100: "#ede9fe", 200: "#ddd6fe", 300: "#c4b5fd", 400: "#a78bfa", 500: "#8b5cf6", 600: "#7c3aed", 700: "#6d28d9", 800: "#5b21b6", 900: "#4c1d95" }, purple: { 50: "#faf5ff", 100: "#f3e8ff", 200: "#e9d5ff", 300: "#d8b4fe", 400: "#c084fc", 500: "#a855f7", 600: "#9333ea", 700: "#7e22ce", 800: "#6b21a8", 900: "#581c87" }, fuchsia: { 50: "#fdf4ff", 100: "#fae8ff", 200: "#f5d0fe", 300: "#f0abfc", 400: "#e879f9", 500: "#d946ef", 600: "#c026d3", 700: "#a21caf", 800: "#86198f", 900: "#701a75" }, pink: { 50: "#fdf2f8", 100: "#fce7f3", 200: "#fbcfe8", 300: "#f9a8d4", 400: "#f472b6", 500: "#ec4899", 600: "#db2777", 700: "#be185d", 800: "#9d174d", 900: "#831843" }, rose: { 50: "#fff1f2", 100: "#ffe4e6", 200: "#fecdd3", 300: "#fda4af", 400: "#fb7185", 500: "#f43f5e", 600: "#e11d48", 700: "#be123c", 800: "#9f1239", 900: "#881337" } }; +function o5({ disablePreflight: e } = {}) { + return (function({ colors: t, disablePreflight: n } = {}) { + return { preflight: n ? void 0 : e5, theme: { ...Wo, colors: { inherit: "inherit", current: "currentColor", transparent: "transparent", black: "#000", white: "#fff", ...t } }, variants: n5, rules: t5, finalize: (r) => r.n && r.d && r.r.some((o) => /^&::(before|after)$/.test(o)) && !/(^|;)content:/.test(r.d) ? { ...r, d: "content:var(--tw-content);" + r.d } : r }; + })({ colors: r5, disablePreflight: e }); +} +let i5 = typeof ShadowRoot < "u" && (typeof ShadyCSS > "u" || ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype; +function io(e) { + return e.shadowRoot || e.attachShadow({ mode: "open" }); +} +const so = { "brand-light": "var(--bc-color-brand, #196CE7)", "brand-dark": "var(--bc-color-brand-dark, var(--bc-color-brand, #3994FF))", "brand-button-text-light": "var(--bc-color-brand-button-text)", "brand-button-text-dark": "var(--bc-color-brand-button-text-dark, var(--bc-color-brand-button-text))", "brand-mixed-light": "color-mix(in srgb, var(--bc-color-brand, #196CE7) var(--bc-brand-mix, 100%), black)", "brand-mixed-dark": "color-mix(in srgb, var(--bc-color-brand-dark, var(--bc-color-brand, #3994FF)) var(--bc-brand-mix, 100%), white)", "foreground-light": "#000", "foreground-dark": "#fff", "background-light": "#fff", "background-dark": "#000", "neutral-primary-light": "#262626", "neutral-primary-dark": "#E4E4E4", "neutral-secondary-light": "#525252", "neutral-secondary-dark": "#A2A2A2", "neutral-tertiary-light": "#A2A2A2", "neutral-tertiary-dark": "#525252" }, s5 = { "glass-light": "linear-gradient(180deg, rgba(211, 211, 211, 0.20) 0%, rgba(255, 255, 255, 0.20) 50%);", "glass-dark": "linear-gradient(180deg, rgba(211, 211, 211, 0.10) 0%, rgba(0, 0, 0, 0.20) 50%)" }, he = () => globalThis.window ? (function(e, t = !0) { + let n = (function() { + if (i5) try { + let a = ro(new CSSStyleSheet()); + return a.connect = (h) => { + let w = io(h); + w.adoptedStyleSheets = [...w.adoptedStyleSheets, a.target]; + }, a.disconnect = Uo, a; + } catch { + } + let i = document.createElement("style"); + i.media = "not all", document.head.prepend(i); + let s = [ro(i)], c = /* @__PURE__ */ new WeakMap(); + return { get target() { + return s[0].target; + }, snapshot() { + let a = s.map((h) => h.snapshot()); + return () => a.forEach((h) => h()); + }, clear() { + s.forEach((a) => a.clear()); + }, destroy() { + s.forEach((a) => a.destroy()); + }, insert(a, h, w) { + s[0].insert(a, h, w); + let g = this.target.cssRules[h]; + s.forEach((v, b) => b && v.target.insertRule(g.cssText, h)); + }, resume: (a, h) => s[0].resume(a, h), connect(a) { + let h = document.createElement("style"); + io(a).appendChild(h); + let w = ro(h), { cssRules: g } = this.target; + for (let v = 0; v < g.length; v++) w.target.insertRule(g[v].cssText, v); + s.push(w), c.set(a, w); + }, disconnect(a) { + let h = s.indexOf(c.get(a)); + h >= 0 && s.splice(h, 1); + } }; + })(), r = (function(i, s) { + let c = la(i), a = (function({ theme: b, darkMode: C, darkColor: L = Uo, variants: M, rules: I, hash: U, stringify: q, ignorelist: Q, finalize: A }) { + let _ = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), k = M2(Q, (u, p) => p.test(u)); + M.push(["dark", Array.isArray(C) || C == "class" ? `${we(C)[1] || ".dark"} &` : typeof C == "string" && C != "media" ? C : "@media (prefers-color-scheme:dark)"]); + let d = typeof U == "function" ? (u) => U(u, ur) : U ? ur : oa; + d !== oa && A.push((u) => ({ ...u, n: u.n && d(u.n), d: u.d?.replace(/--(tw(?:-[\w-]+)?)\b/g, (p, f) => "--" + d(f).replace("#", "")) })); + let l = { theme: (function({ extend: u = {}, ...p }) { + let f = {}, y = { get colors() { + return x("colors"); + }, theme: x, negative: () => ({}), breakpoints(R) { + let P = {}; + for (let S in R) typeof R[S] == "string" && (P["screen-" + S] = R[S]); + return P; + } }; + return x; + function x(R, P, S, D) { + if (R) { + if ({ 1: R, 2: D } = /^(\S+?)(?:\s*\/\s*([^/]+))?$/.exec(R) || [, R], /[.[]/.test(R)) { + let X = []; + R.replace(/\[([^\]]+)\]|([^.[]+)/g, (ie, N, $ = N) => X.push($)), R = X.shift(), S = P, P = X.join("-"); + } + let Y = f[R] || Object.assign(Object.assign(f[R] = {}, O(p, R)), O(u, R)); + if (P == null) return Y; + P || (P = "DEFAULT"); + let G = Y[P] ?? P.split("-").reduce((X, ie) => X?.[ie], Y) ?? S; + return D ? gt(G, { opacityValue: Fi(D, x) }) : G; + } + let J = {}; + for (let Y of [...Object.keys(p), ...Object.keys(u)]) J[Y] = x(Y); + return J; + } + function O(R, P) { + let S = R[P]; + return typeof S == "function" && (S = S(y)), S && /color|fill|stroke/i.test(P) ? (function D(J, Y = []) { + let G = {}; + for (let X in J) { + let ie = J[X], N = [...Y, X]; + G[N.join("-")] = ie, X == "DEFAULT" && (N = Y, G[Y.join("-")] = ie), typeof ie == "object" && Object.assign(G, D(ie, N)); + } + return G; + })(S) : S; + } + })(b), e: x2, h: d, s: (u, p) => q(u, p, l), d: (u, p, f) => L(u, p, l, f), v: (u) => (_.has(u) || _.set(u, da(u, M, E, J3, l) || "&:" + u), _.get(u)), r(u, p) { + let f = JSON.stringify([u, p]); + return T.has(f) || T.set(f, !k(u, l) && da(u, I, m, Y3, l, p)), T.get(f); + }, f: (u) => A.reduce((p, f) => f(p, l), u) }; + return l; + })(c), h = /* @__PURE__ */ new Map(), w = [], g = /* @__PURE__ */ new Set(); + function v(b) { + let C = a.f(b), L = Po(C); + if (L && !g.has(L)) { + g.add(L); + let M = k2(w, b); + s.insert(L, M, b), w.splice(M, 0, b); + } + return C.n; + } + return s.resume((b) => h.set(b, b), (b, C) => { + s.insert(b, w.length, C), w.push(C), g.add(b); + }), Object.defineProperties(function(b) { + if (!h.size) for (let L of we(c.preflight)) typeof L == "function" && (L = L(a)), L && (typeof L == "string" ? Vi("", _e.b, fr(L), a, _e.b, [], !1, !0) : S2(L, {}, a, _e.b)).forEach(v); + let C = h.get(b = "" + b); + if (!C) { + let L = /* @__PURE__ */ new Set(); + for (let M of hr(fr(b), a)) L.add(M.c).add(v(M)); + C = [...L].filter(Boolean).join(" "), h.set(b, C).set(C, C); + } + return C; + }, Object.getOwnPropertyDescriptors({ get target() { + return s.target; + }, theme: a.theme, config: c, snapshot() { + let b = s.snapshot(), C = new Set(g), L = new Map(h), M = [...w]; + return () => { + b(), g = C, h = L, w = M; + }; + }, clear() { + s.clear(), g = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Map(), w = []; + }, destroy() { + this.clear(), s.destroy(); + } })); + })({ ...e, hash: e.hash ?? t }, n), o = (function(i) { + let s = new MutationObserver(c); + return { observe(h) { + s.observe(h, { attributeFilter: ["class"], subtree: !0, childList: !0 }), a(h), c([{ target: h, type: "" }]); + }, disconnect() { + s.disconnect(); + } }; + function c(h) { + for (let { type: w, target: g } of h) if (w[0] == "a") a(g); + else for (let v of g.querySelectorAll("[class]")) a(v); + s.takeRecords(); + } + function a(h) { + let w, g = h.getAttribute?.("class"); + g && (function(v, b) { + return v != b && "" + v.split(" ").sort() != "" + b.split(" ").sort(); + })(g, w = i(g)) && h.setAttribute("class", w); + } + })(r); + return function(i) { + return class extends i { + connectedCallback() { + super.connectedCallback?.(), n.connect(this), o.observe(io(this)); + } + disconnectedCallback() { + n.disconnect(this), super.disconnectedCallback?.(); + } + constructor(...s) { + super(...s), this.tw = r; + } + }; + }; +})(la({ darkMode: globalThis.bcDarkMode, theme: { fontFamily: { sans: ["Inter", "sans-serif"], mono: ["Roboto Mono", "monospace"] }, extend: { borderColor: qe({}, so), backgroundColor: qe({}, so), textColor: qe({}, so), backgroundImage: qe({}, s5), animation: { darken: "darken 0.2s ease-out forwards", "fade-in": "fade-in 0.2s ease-out forwards", "slide-up": "slideUp 0.3s ease-out forwards" }, keyframes: { darken: { "0%": { opacity: 0 }, "100%": { opacity: 0.5 } }, lighten: { "0%": { opacity: 0.5 }, "100%": { opacity: 0 } }, "fade-in": { "0%": { opacity: 0 }, "100%": { opacity: 1 } }, "fade-out": { "0%": { opacity: 1 }, "100%": { opacity: 0 } }, slideUp: { from: { transform: "translateY(100%)" }, to: { transform: "translateY(0)" } } } } }, presets: [o5({})], hash: !1 })) : a5; +function a5(e) { + return e; +} +const Le = "transition-all hover:brightness-90 dark:hover:brightness-110 active:scale-95 cursor-pointer", Vo = "hover-animation", be = "text-brand-mixed-light dark:text-brand-mixed-dark", rt = "text-foreground-light dark:text-foreground-dark", Sn = "text-neutral-primary-light dark:text-neutral-primary-dark", re = "text-neutral-secondary-light dark:text-neutral-secondary-dark", Qe = "text-neutral-tertiary-light dark:text-neutral-tertiary-dark", Ut = "border-neutral-secondary-light dark:border-neutral-secondary-dark", Gi = "border-neutral-tertiary-light dark:border-neutral-tertiary-dark"; +let wa, ya, ba, Go = (e) => e; +function R2() { + return W(wa || (wa = Go`
`), Gi); +} +function c5(e) { + V.getState().connected && e(V.getState().provider); + const t = V.subscribe(async (n, r) => { + if (n.connected && !r.connected) { + if (!n.provider) throw new Error("No provider available"); + e(n.provider); + } + }); + return () => { + t(); + }; +} +function n6(e) { + V.getState().connecting && e(); + const t = V.subscribe(async (n, r) => { + n.connecting && !r.connecting && e(); + }); + return () => { + t(); + }; +} +function r6(e) { + const t = V.subscribe(async (n, r) => { + !n.connected && r.connected && e(); + }); + return () => { + t(); + }; +} +function o6(e) { + const t = V.subscribe(async (n, r) => { + n.modalOpen && !r.modalOpen && e(); + }); + return () => { + t(); + }; +} +function N2(e) { + const t = V.subscribe(async (n, r) => { + !n.modalOpen && r.modalOpen && e(); + }); + return () => { + t(); + }; +} +async function i6() { + let e = V.getState().provider; + if (!e && ($2(), await new Promise((t, n) => { + const r = N2(() => { + r(), o(), e && t(), n("Modal closed without connecting"); + }), o = c5((i) => { + e = i; + }); + }), !e)) throw new Error("No WebLN provider available"); + return e; +} +function s6() { + return console.warn("Bitcoin Connect: isConnected is deprecated and will be removed in the next major version"), V.getState().connected; +} +function a6(e = {}) { + V.getState().setBitcoinConnectConfig(e); +} +function c6() { + window.dispatchEvent(new CustomEvent("bc:balancerefresh")); +} +function $2() { + const e = document.createElement("bc-modal"), t = document.createElement("bc-connect"); + t.setAttribute("closable", "closable"), e.appendChild(t), document.body.appendChild(e), V.getState().setModalOpen(!0); +} +function l5({ invoice: e, paymentMethods: t, onPaid: n, onCancelled: r }) { + if (document.querySelector("bc-modal")) throw new Error("bc-modal already in DOM"); + const o = document.createElement("bc-modal"), i = document.createElement("bc-payment"); + i.setAttribute("closable", "closable"), i.setAttribute("invoice", e), t && i.setAttribute("payment-methods", t), o.appendChild(i); + let s = !1; + const c = (h) => { + s = !0, n?.(h.detail); + }; + window.addEventListener("bc:onpaid", c); + const a = N2(() => { + a(), window.removeEventListener("bc:onpaid", c), s || r == null || r(); + }); + return document.body.appendChild(o), V.getState().setModalOpen(!0), { setPaid: (h) => { + i.setAttribute("paid", "paid"), i.dispatchEvent(new CustomEvent("bc:onpaid", { bubbles: !0, composed: !0, detail: h })); + } }; +} +function ji() { + const e = document.querySelector("bc-modal"); + e && document.body.removeChild(e), V.getState().setModalOpen(!1), V.getState().clearRouteHistory(), V.getState().setError(void 0); +} +function l6(e) { + V.getState().connect(e); +} +function d6(e) { + V.getState().connectNWC(e); +} +function u6() { + V.getState().disconnect(); +} +function h6() { + return V.getState().connectorConfig; +} +let ma, d5 = (e) => e, Zt = class extends he()(ae) { + constructor() { + super(), this._loading = !1, this._loadBalance(), window.addEventListener("bc:balancerefresh", () => { + this._loadBalance(); + }), this._selectedCurrency = V.getState().currency, V.subscribe((e, t) => { + this._selectedCurrency = e.currency, e.currency !== t.currency && this._convertBalance(), e.connected !== t.connected && e.connected && this._loadBalance(); + }); + } + render() { + return W(ma || (ma = d5` + ${0} `), be, this._balance || "Loading..."); + } + async _convertBalance() { + if (this._loading || this._balanceSats === void 0) return; + const e = this._selectedCurrency || "sats"; + if (e === "BTC") this._balance = (this._balanceSats / 1e8).toLocaleString(void 0, { minimumFractionDigits: 8, useGrouping: !0 }) + " BTC"; + else if (e !== "sats") { + try { + this._loading = !0; + const t = await i3({ satoshi: this._balanceSats, currency: e }), n = parseFloat(t.toFixed(2)); + this._balance = new Intl.NumberFormat(void 0, { style: "currency", currency: e }).format(n); + } catch (t) { + console.error(t); + } + this._loading = !1; + } else this._balance = this._balanceSats.toLocaleString(void 0, { useGrouping: !0 }) + " sats"; + } + _loadBalance() { + var e = this; + (async function() { + try { + const t = V.getState().provider; + if (t == null || !t.getBalance) return; + const n = await t.getBalance(); + n && (e._balanceSats = n.balance, e._convertBalance()); + } catch (t) { + e._balance = "⚠️", console.error(t); + } + })(); + } +}; +F([se()], Zt.prototype, "_balance", void 0), F([se()], Zt.prototype, "_balanceSats", void 0), F([se()], Zt.prototype, "_loading", void 0), F([se()], Zt.prototype, "_selectedCurrency", void 0), Zt = F([oe("bc-balance")], Zt); +let va, u5 = (e) => e; +const Ot = (e) => de(va || (va = u5` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +`), e || "w-7 h-7"); +let Ca, xa, Ea, Aa, ka, _a, Sa, La, kt = (e) => e, Pn = class extends he()(ae) { + constructor() { + super(), this.title = "Connect Wallet", this._showBalance = void 0, this._showBalance = V.getState().bitcoinConnectConfig.showBalance && V.getState().supports("getBalance"), V.subscribe((e) => { + this._showBalance = e.bitcoinConnectConfig.showBalance && e.supports("getBalance"); + }); + } + render() { + const e = this._connecting || !this._connected && this._modalOpen; + return W(Ca || (Ca = kt`
+
+
+ ${0} + + ${0} + + ${0} + + + ${0} +
+
`), Le, this._onClick, this._connected ? "bg-glass-light dark:bg-glass-dark" : "", this._connected ? R2() : "", e ? W(xa || (xa = kt` ${0} `), Ot("w-11 h-11 -mr-2 mr-1 -ml-2.5")) : this._connected ? null : W(Ea || (Ea = kt`${0}`), bn), e ? W(Aa || (Aa = kt`Connecting...`)) : this._connected ? W(ka || (ka = kt`Connected`)) : W(_a || (_a = kt`${0}`), this.title), this._connected && this._showBalance ? W(Sa || (Sa = kt` `)) : null); + } + _onClick() { + $2(); + } +}; +F([me()], Pn.prototype, "title", void 0), F([se()], Pn.prototype, "_showBalance", void 0), Pn = F([oe("bc-button")], Pn); +const h5 = de(La || (La = ((e) => e)` + + + +`)); +let Ta, Ma, Ba, Ra, Na, $a, Wt = (e) => e, ct = class extends he()(ae) { + constructor() { + super(...arguments), this.title = "Pay Now", this.paymentMethods = "all", this._waitingForInvoice = !1, this._paid = !1; + } + updated(e) { + var t; + super.updated(e), e.has("invoice") && this.invoice && this._waitingForInvoice && this._launchModal(), e.has("invoice") && !this.invoice && (this._waitingForInvoice = !1, this._paid = !1), e.has("preimage") && this.preimage && ((t = this._setPaid) == null || t.call(this, { preimage: this.preimage })); + } + render() { + const e = !this._paid && (this._waitingForInvoice || this._modalOpen); + return W(Ta || (Ta = Wt`
+ + ${0} + + ${0} + + +
`), this._onClick, e ? W(Ma || (Ma = Wt`${0}`), Ot("w-11 h-11 -mr-2 -ml-2.5 ")) : this._paid ? W(Ba || (Ba = Wt`${0}`), h5) : W(Ra || (Ra = Wt`${0}`), bn), e ? W(Na || (Na = Wt`Loading...`)) : W($a || ($a = Wt`${0}`), this._paid ? "Paid" : this.title)); + } + _onClick() { + this._paid || (this._waitingForInvoice = !0, this.invoice && this._launchModal()); + } + _launchModal() { + if (this._waitingForInvoice = !1, !this.invoice) throw new Error("No invoice available"); + const { setPaid: e } = l5({ onPaid: () => { + this._paid = !0; + }, invoice: this.invoice, paymentMethods: this.paymentMethods }); + this._setPaid = e; + } +}; +F([me()], ct.prototype, "title", void 0), F([me()], ct.prototype, "invoice", void 0), F([me({ type: String, attribute: "payment-methods" })], ct.prototype, "paymentMethods", void 0), F([me({})], ct.prototype, "preimage", void 0), F([se()], ct.prototype, "_waitingForInvoice", void 0), F([se()], ct.prototype, "_paid", void 0), ct = F([oe("bc-pay-button")], ct); +let Ia, Ua, f5 = (e) => e, dn = class extends he()(Hi) { + constructor() { + super(...arguments), this.variant = "secondary", this.ghost = !1, this.block = !1; + } + render() { + const e = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches, t = window.getComputedStyle(this).getPropertyValue(e ? "--bc-color-brand-button-text-dark" : "--bc-color-brand-button-text") || window.getComputedStyle(this).getPropertyValue("--bc-color-brand-button-text"); + return W(Ia || (Ia = f5``), this.ghost ? "" : "shadow", Le, this.variant === "primary" ? "bg-brand-light dark:bg-brand-dark" : "", this.variant === "primary" ? t ? "text-brand-button-text-light dark:text-brand-button-text-dark" : this._getBrandColorLuminance() > 0.5 ? "text-black" : "text-white" : this.variant === "secondary" ? `${be}` : `${Qe}`, this.ghost ? null : this.variant === "primary" ? R2() : this.variant === "secondary" ? W(ya || (ya = Go`
`), "border-brand-mixed-light dark:border-brand-mixed-dark") : W(ba || (ba = Go`
`), Gi), this.block ? "w-full" : ""); + } +}; +F([me()], dn.prototype, "variant", void 0), F([me({ type: Boolean })], dn.prototype, "ghost", void 0), F([me({ type: Boolean })], dn.prototype, "block", void 0), dn = F([oe("bci-button")], dn); +const p5 = de(Ua || (Ua = ((e) => e)` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +`)); +let Oa, g5 = (e) => e; +class Ve extends he()(ae) { + constructor(t, n, r, o) { + super(), this._connectorType = t, this._title = n, this._background = r, this._icon = o; + } + render() { + return W(Oa || (Oa = g5``), Le, this._title, this._onClick, this._background, this._icon, re, this._title); + } + _connect(t) { + V.getState().connect(qe({}, t, { connectorName: this._title, connectorType: this._connectorType })); + } +} +let Pa, Ha = class extends Ve { + constructor() { + super("extension.generic", "Browser Extensions", "#F4F4F4", p5); + } + _onClick() { + this._connect({}); + } +}; +Ha = F([oe("bc-extension-connector")], Ha); +const I2 = de(Pa || (Pa = ((e) => e)` + + + +`)), U2 = "Alby Hub"; +let Da, Za = class extends Ve { + constructor() { + super("nwc.albyhub", U2, "#000000", I2); + } + async _onClick() { + V.getState().pushRoute("/alby-hub"); + } +}; +Za = F([oe("bc-alby-hub-connector")], Za); +const w5 = de(Da || (Da = ((e) => e)` + + + + + + + + + + + + +`)), zi = "NWC"; +let Wa, Fa = class extends Ve { + constructor() { + super("nwc.generic", zi, "#ffffff", w5); + } + async _onClick() { + V.getState().pushRoute("/nwc"); + } +}; +Fa = F([oe("bc-nwc-connector")], Fa); +const y5 = de(Wa || (Wa = ((e) => e)``)); +let Va, Ga = class extends Ve { + constructor() { + super("lnc", "Lightning Node Connect", "#101727", y5); + } + async _onClick() { + const e = window.prompt("Enter pairing phrase"); + if (!e) return; + const t = await l2(); + if (!t) throw new Error("LNC not supported"); + t.credentials.pairingPhrase = e, this._connect({}); + } +}; +Ga = F([oe("bc-lnc-connector")], Ga); +const O2 = de(Va || (Va = ((e) => e)` + + +`)), jo = "LNbits"; +let ja = class extends Ve { + constructor() { + super("lnbits", jo, "#673ab7", O2); + } + async _onClick() { + V.getState().pushRoute("/lnbits"); + } +}; +ja = F([oe("bc-lnbits-connector")], ja); +const zo = "LNbits NWC Plugin"; +let za, qa = class extends Ve { + constructor() { + super("lnbits", zo, "#673ab7", O2); + } + async _onClick() { + V.getState().pushRoute("/lnbits-nwc"); + } +}; +qa = F([oe("bc-lnbits-nwc-connector")], qa); +const b5 = de(za || (za = ((e) => e)` + + + + + + + + + +`)), m5 = "LN Link"; +let Ka, Qa = class extends Ve { + constructor() { + super("nwc.generic", m5, "#ffffff", b5); + } + async _onClick() { + V.getState().pushRoute("/lnfi"); + } +}; +Qa = F([oe("bc-lnfi-nwc-connector")], Qa); +const v5 = de(Ka || (Ka = ((e) => e)``)), C5 = "Coinos"; +let Ja, Ya = class extends Ve { + constructor() { + super("nwc.coinos", C5, "#ffffff", v5); + } + async _onClick() { + try { + var e; + const t = V.getState().bitcoinConnectConfig.providerConfig, n = await vt.fromAuthorizationUrl("https://coinos.io/apps/new", qe({}, (t == null || (e = t.nwc) == null ? void 0 : e.authorizationUrlOptions) || {}, { name: this._appName })); + n.close(), await V.getState().connect({ nwcUrl: n.nostrWalletConnectUrl, connectorName: "Coinos", connectorType: "nwc.coinos" }); + } catch (t) { + console.error(t), alert("" + t); + } + } +}; +Ya = F([oe("bc-coinos-connector")], Ya); +const x5 = de(Ja || (Ja = ((e) => e)``)), E5 = "Flash Wallet"; +let Xa, ec = class extends Ve { + constructor() { + super("nwc.flash", E5, "#000000", x5); + } + async _onClick() { + V.getState().pushRoute("/flash-wallet"); + } +}; +ec = F([oe("bc-flash-connector")], ec); +const A5 = de(Xa || (Xa = ((e) => e)` + + + + + + + + +`)), qo = "Rizful"; +let tc = class extends Ve { + constructor() { + super("nwc.rizful", qo, "#000000", A5); + } + async _onClick() { + V.getState().pushRoute("/rizful"); + } +}; +tc = F([oe("bc-rizful-connector")], tc); +let nc, rc, oc, ic, sc, ac, cc, lc, dc, uc, hc, fc, pc, gc, $e = (e) => e, ao = class extends he()(ae) { + constructor() { + super(...arguments), this._showAll = !1; + } + render() { + const e = []; + return e.push({ order: 0, result: W(nc || (nc = $e``)) }), e.push({ order: 0, result: W(rc || (rc = $e``)) }), e.push({ order: 0, result: W(oc || (oc = $e``)) }), e.push({ order: 0, result: W(ic || (ic = $e``)) }), this._filters && this._filters.indexOf("nwc") > -1 && e.push({ order: 0, result: W(sc || (sc = $e``)) }), e.push({ order: 0, result: W(ac || (ac = $e``)) }), e.push({ order: 0, result: W(cc || (cc = $e``)) }), e.push({ order: 10, result: W(lc || (lc = $e``)) }), this._filters && this._filters.indexOf("nwc") !== -1 || (window.webln && e.push({ order: 0, result: W(dc || (dc = $e``)) }), e.push({ order: 7, result: W(uc || (uc = $e``)) }), e.push({ order: 9, result: W(hc || (hc = $e``)) })), e.sort((t, n) => t.order - n.order), W(fc || (fc = $e` +
+
+ ${0} +
+ ${0} +
+ `), this._showAll ? "max-h-96 overflow-y-auto" : "", (this._showAll ? e : e.slice(0, 9)).map((t) => t.result), !this._showAll && e.length > 9 ? W(pc || (pc = $e`
+ +
`), Le, re, e.length, this._toggleShowAll, e.length) : null); + } + _toggleShowAll() { + this._showAll = !0; + } +}; +F([se()], ao.prototype, "_showAll", void 0), ao = F([oe("bc-connector-list")], ao); +const k5 = de(gc || (gc = ((e) => e)` + + + +`)); +let wc, yc, bc = (e) => e; +function qi(e) { + return W(wc || (wc = bc`
+ ${0} + + + ${0} + Disconnect + +
`), e ? W(yc || (yc = bc`Connected through + ${0}`), re, e) : null, _5, Vo, k5, Qe); +} +function _5() { + V.getState().setModalOpen(!1), setTimeout(() => { + V.getState().disconnect(); + }, 200); +} +const mc = (e) => String.fromCodePoint(...e.split("").map((t) => 127397 + t.toUpperCase().charCodeAt(0))); +let vc, co, Cc, xc, Ec, Ac, Hn = (e) => e, Dn = (co = class extends (vc = he()(ae)) { + constructor() { + super(), this._isSwitchingCurrency = !1, this._selectedCurrency = V.getState().currency, V.subscribe((e) => { + this._selectedCurrency = e.currency; + }); + } + render() { + if (!this._isSwitchingCurrency) return W(Cc || (Cc = Hn`
+ +
`), Le, this._selectedCurrency || "sats", this._showSelectVisibility); + const e = (() => { + const n = [{ name: "SATS", value: "sats", flag: "₿" }, { name: "BTC", value: "BTC", flag: "₿" }, { name: "USD", value: "USD", flag: mc("US") }, { name: "EUR", value: "EUR", flag: "🇪🇺" }]; + return n.push(...Object.entries({ JP: "JPY", CN: "CNY", GB: "GBP", CH: "CHF", IN: "INR", AE: "AED", AF: "AFN", AL: "ALL", DZ: "DZD", AO: "AOA", AR: "ARS", AM: "AMD", AW: "AWG", AU: "AUD", AZ: "AZN", BS: "BSD", BH: "BHD", BD: "BDT", BB: "BBD", BY: "BYN", BZ: "BZD", BM: "BMD", BT: "BTN", BO: "BOB", BA: "BAM", BW: "BWP", BR: "BRL", BN: "BND", BG: "BGN", BI: "BIF", CV: "CVE", KH: "KHR", CA: "CAD", KY: "KYD", CF: "XAF", CL: "CLP", CO: "COU", KM: "KMF", CD: "CDF", CR: "CRC", CU: "CUC", CW: "ANG", CZ: "CZK", DK: "DKK", DJ: "DJF", DM: "XCD", DO: "DOP", EG: "EGP", ER: "ERN", ET: "ETB", FJ: "FJD", PF: "XPF", GM: "GMD", GE: "GEL", GH: "GHS", GI: "GIP", GT: "GTQ", GN: "GNF", GY: "GYD", HN: "HNL", HK: "HKD", HU: "HUF", IS: "ISK", ID: "IDR", IR: "XDR", IQ: "IQD", IL: "ILS", JM: "JMD", JO: "JOD", KZ: "KZT", KE: "KES", KR: "KRW", KW: "KWD", KG: "KGS", LA: "LAK", LB: "LBP", LR: "LRD", LY: "LYD", MO: "MOP", MG: "MGA", MW: "MWK", MY: "MYR", MV: "MVR", MR: "MRU", MU: "MUR", MX: "MXN", MD: "MDL", MN: "MNT", MA: "MAD", MZ: "MZN", MM: "MMK", NP: "NPR", NZ: "NZD", NI: "NIO", NE: "XOF", NG: "NGN", MK: "MKD", NO: "NOK", OM: "OMR", PK: "PKR", PG: "PGK", PY: "PYG", PE: "PEN", PH: "PHP", PL: "PLN", QA: "QAR", RO: "RON", RU: "RUB", RW: "RWF", SH: "SHP", WS: "WST", ST: "STN", SA: "SAR", RS: "RSD", SC: "SCR", SL: "SLL", SG: "SGD", SB: "SBD", SO: "SOS", ZA: "ZAR", SS: "SSP", LK: "LKR", SD: "SDG", SR: "SRD", SE: "SEK", SY: "SYP", TW: "TWD", TJ: "TJS", TZ: "TZS", TH: "THB", TO: "TOP", TT: "TTD", TN: "TND", TR: "TRY", TM: "TMT", UG: "UGX", UA: "UAH", UY: "UYU", UZ: "UZS", VU: "VUV", VN: "VND", YE: "YER", ZM: "ZMW", ZW: "ZWL" }).map(([r, o]) => ({ name: r, value: o, flag: mc(r) }))), n; + })(), t = this._selectedCurrency || "sats"; + return W(xc || (xc = Hn`
+ ${0} +
`), e.map((n) => W(Ec || (Ec = Hn` + + `), t === n.value ? "bg-blue-500 text-white" : "", n.value, t === n.value, () => this._selectCurrency(n.value), n.flag, n.value))); + } + _showSelectVisibility() { + this._isSwitchingCurrency = !0; + } + _selectCurrency(e) { + V.getState().setCurrency(e), this._isSwitchingCurrency = !1; + } +}, co.styles = [...vc.styles, Lr(Ac || (Ac = Hn` + .currencies-list { + mask-image: linear-gradient( + to bottom, + black calc(100% - 96px), + transparent 100% + ); + } + /* width */ + ::-webkit-scrollbar { + width: 6px; + height: 18px; + } + + /* Track */ + ::-webkit-scrollbar-track { + background: #66666666; + } + + /* Handle */ + ::-webkit-scrollbar-thumb { + background: #888; + } + + /* Handle on hover */ + ::-webkit-scrollbar-thumb:hover { + background: #555; + } + `))], co); +F([se()], Dn.prototype, "_isSwitchingCurrency", void 0), F([se()], Dn.prototype, "_selectedCurrency", void 0), Dn = F([oe("bc-currency-switcher")], Dn); +let kc, _c, Sc, Lc, Tc, Mc, un = (e) => e, lo = class extends he()(ae) { + constructor() { + super(), this._showBalance = void 0, this._showBalance = V.getState().bitcoinConnectConfig.showBalance && V.getState().supports("getBalance"), V.subscribe((e) => { + this._showBalance = e.bitcoinConnectConfig.showBalance && e.supports("getBalance"); + }); + } + render() { + return W(kc || (kc = un`
+ ${0} +
`), this._connected ? W(_c || (_c = un` + ${0} + ${0} + `), W(this._showBalance ? Sc || (Sc = un`Balance + + + `) : Lc || (Lc = un` Wallet Connected`), re), qi(this._connectorName)) : W(Tc || (Tc = un` +

+ How would you like to + connect${0}? +

+ + + +
+

+ Don't have a bitcoin lightning wallet? + +

+
+ `), Sn, this._appName && this._appName !== Ro.appName ? ` +to ${this._appName}` : "", Sn, Le, be, () => V.getState().pushRoute("/new-wallet"))); + } +}; +F([se()], lo.prototype, "_showBalance", void 0), lo = F([oe("bc-start")], lo); +const S5 = de(Mc || (Mc = ((e) => e)` + + +`)); +let Bc, Rc, L5 = (e) => e, uo = class extends he()(ae) { + constructor() { + super(...arguments), this._goBack = () => { + V.getState().popRoute(), V.getState().setError(void 0); + }; + } + render() { + return W(Bc || (Bc = L5`
+
+ +
+
+ ${0} +
+
`), Le, Qe, this._goBack, S5, Sn, this.heading); + } +}; +F([me()], uo.prototype, "heading", void 0), uo = F([oe("bc-navbar")], uo); +const Nc = de(Rc || (Rc = ((e) => e)` + + +`)); +let $c, Ic, Uc, Oc = (e) => e; +function P2(e) { + const t = `border-t ${Gi} ${e ? "w-24" : "w-full"}`; + return W($c || ($c = Oc`
+
+ ${0} +
`), t, e ? W(Ic || (Ic = Oc` + ${0} +
+ `), Qe, e, t) : null); +} +const T5 = de(Uc || (Uc = ((e) => e)` + + + + + + + + + + + + + + + + + + + + + +`)); +let Pc, M5 = (e) => e, Hc = class extends he()(ae) { + render() { + return W(Pc || (Pc = M5`
+ +
+
+
+ How does it work? +
+

+ Bitcoin Connect is a way to connect to your lightning wallet from + any browser. +

+
+

+ 💾 Your connection is saved in local storage, so next time you + visit the site will connect automatically. +

+

+ 💸 Make sure to set budgets and permissions for sites you do not + trust. +

+
+
+ + + ${0} +
+ Made with love by + ${0} +
+
+
`), be, re, re, Vo, be, Nc, Vo, be, Nc, P2(), Qe, rt, T5); + } +}; +Hc = F([oe("bc-help")], Hc); +let Dc, Zc, B5 = (e) => e, ho = class extends he()(ae) { + constructor() { + super(...arguments), this._nwcUrl = ""; + } + render() { + return W(Dc || (Dc = B5`
+ +
+
+
+ Enter your + Connection Secret + + below +
+ + + + Connect + +
+
+
`), re, this._nwcUrl, this.nwcUrlChanged, Ut, rt, this.onConnect); + } + nwcUrlChanged(e) { + this._nwcUrl = e.target.value; + } + async onConnect() { + this._nwcUrl ? await V.getState().connect({ nwcUrl: this._nwcUrl, connectorName: zi, connectorType: "nwc.generic" }) : V.getState().setError("Please enter a URL"); + } +}; +F([se()], ho.prototype, "_nwcUrl", void 0), ho = F([oe("bc-nwc")], ho); +const R5 = de(Zc || (Zc = ((e) => e)` + +`)); +let Wc; +const N5 = de(Wc || (Wc = ((e) => e)``)); +let Fc; +const $5 = de(Fc || (Fc = ((e) => e)``)); +let Vc, Gc, I5 = (e) => e, jc = class extends he()(ae) { + render() { + return W(Vc || (Vc = I5`
+ +
+
+
+ Choose how to connect +
+ + + ${0} + Alby Cloud + + + + ${0} + Alby Go + + + + ${0} + Connection Secret + +
+
+
`), "Connect " + U2, re, this.onClickAlbyCloud, R5, be, this.onClickAlbyGo, $5, be, this.onClickConnectionSecret, N5, be); + } + async onClickAlbyCloud() { + try { + var e; + const t = V.getState().bitcoinConnectConfig.providerConfig, n = await vt.fromAuthorizationUrl("https://my.albyhub.com/apps/new", qe({}, (t == null || (e = t.nwc) == null ? void 0 : e.authorizationUrlOptions) || {}, { name: this._appName })); + n.close(), await V.getState().connect({ nwcUrl: n.nostrWalletConnectUrl, connectorName: "Alby Hub", connectorType: "nwc.albyhub" }); + } catch (t) { + console.error(t), alert("" + t); + } + } + async onClickConnectionSecret() { + V.getState().pushRoute("/nwc"); + } + async onClickAlbyGo() { + V.getState().pushRoute("/alby-go"); + } +}; +jc = F([oe("bc-alby-hub")], jc); +const Ki = de(Gc || (Gc = ((e) => e)` + + +`)); +let zc; +const Qi = de(zc || (zc = ((e) => e)` + +`)); +let qc, Kc, Qc = (e) => e, Zn = class extends he()(ae) { + constructor() { + super(), this._hasCopiedAuthString = !1, this.initAlbyGo(); + } + disconnectedCallback() { + var e; + super.disconnectedCallback(), (e = this._unsub) == null || e.call(this); + } + render() { + return W(qc || (qc = Qc`
+ +
+
+
+ Scan with your camera, QR code scanner app, or from Alby Go -> Send +
+ +
+ ${0} +

Waiting for connection

+
+ + ${0} + + + ${0} + ${0} + +
+
+
+ `), re, Ot(`w-7 h-7 ${re}`), re, this.renderQR(), this._copyAuthString, be, Le, this._hasCopiedAuthString ? Ki : Qi, this._hasCopiedAuthString ? "Copied!" : "Copy"); + } + renderQR() { + if (!this._authString) return null; + const e = this._authString; + return setTimeout(() => { + var t; + const n = (t = this.shadowRoot) == null ? void 0 : t.getElementById("qr"); + if (!n) return void console.error("qr canvas not found"); + const r = n.getContext("2d"); + if (!r) return void console.error("could not get context for qr canvas"); + const o = Bi(0, "L"); + o.addData(e), o.make(); + const i = o.getModuleCount(); + n.width = 4 * i, n.height = 4 * i, o.renderTo2dContext(r, 4); + }, 100), W(Kc || (Kc = Qc` + + + `)); + } + _copyAuthString() { + this._authString && (navigator.clipboard.writeText(this._authString), this._hasCopiedAuthString = !0, setTimeout(() => { + this._hasCopiedAuthString = !1; + }, 2e3)); + } + async initAlbyGo() { + try { + var e; + const t = (e = V.getState().bitcoinConnectConfig.providerConfig) == null || (e = e.nwc) == null ? void 0 : e.authorizationUrlOptions, n = t?.expiresAt; + let r = t?.requestMethods; + r || (r = ["get_info", "get_balance", "get_budget", "pay_invoice", "list_transactions", "lookup_invoice", "make_invoice"]); + const o = new s2({ name: this._appName, icon: this._appIcon, relayUrls: ["wss://relay.getalby.com/v1"], requestMethods: r, notificationTypes: t?.notificationTypes, maxAmount: t?.maxAmount, budgetRenewal: t?.budgetRenewal, expiresAt: n ? Math.floor(n.getTime() / 1e3) : void 0, isolated: t?.isolated, metadata: t?.metadata, returnTo: t?.returnTo }); + this._authString = o.getConnectionUri("alby"), window.location.href = this._authString; + const { unsub: i } = await o.subscribe({ onSuccess: async function(s) { + s.close(), V.getState().connect({ nwcUrl: s.nostrWalletConnectUrl, connectorName: "Alby Hub", connectorType: "nwc.albyhub" }); + } }); + this._unsub = i; + } catch (t) { + console.error(t), alert("" + t); + } + } +}; +F([se()], Zn.prototype, "_authString", void 0), F([se()], Zn.prototype, "_hasCopiedAuthString", void 0), Zn = F([oe("bc-alby-go")], Zn); +let Jc, Yc, U5 = (e) => e, Wn = class extends he()(ae) { + constructor() { + super(...arguments), this._lnbitsAdminKey = "", this._lnbitsUrl = ""; + } + render() { + return W(Jc || (Jc = U5`
+ +
+
+
+ In LNbits, choose the wallet you want to connect, open it, click on + API docs and copy the Admin Key. Paste it below: +
+ +
+ LNbits Admin Key +
+ +
+ LNbits URL +
+ + + + Connect + +
+
+
`), jo, Sn, re, this._lnbitsAdminKey, this._lnbitsAdminKeyChanged, Ut, rt, re, this._lnbitsUrl, this._lnbitsUrlChanged, Ut, rt, this.onConnect); + } + _lnbitsAdminKeyChanged(e) { + this._lnbitsAdminKey = e.target.value; + } + _lnbitsUrlChanged(e) { + this._lnbitsUrl = e.target.value; + } + async onConnect() { + if (!this._lnbitsAdminKey) return void V.getState().setError("Please enter your admin key"); + if (!this._lnbitsUrl) return void V.getState().setError("Please enter your LNbits instance URL"); + let e = this._lnbitsUrl; + e.endsWith("/") && (e = e.substring(0, e.length - 1)), await V.getState().connect({ lnbitsAdminKey: this._lnbitsAdminKey, lnbitsInstanceUrl: e, connectorName: jo, connectorType: "lnbits" }); + } +}; +F([se()], Wn.prototype, "_lnbitsAdminKey", void 0), F([se()], Wn.prototype, "_lnbitsUrl", void 0), Wn = F([oe("bc-lnbits")], Wn); +const H2 = de(Yc || (Yc = ((e) => e)` + + + + + + + + + + + + + +`)); +let Xc; +const O5 = de(Xc || (Xc = ((e) => e)` + + +`)); +let e1; +const P5 = de(e1 || (e1 = ((e) => e)` + + + + + +`)); +let t1, n1, r1, o1, i1, s1, a1, c1, l1, d1, u1, h1, f1, p1, g1, w1, y1, b1, m1, xe = (e) => e, lt = class extends he()(ae) { + constructor() { + super(...arguments), this._hasCopiedInvoice = !1, this._isPaying = !1, this._showQR = !1, this.paymentMethods = "all"; + } + updated(e) { + super.updated(e), e.has("paid") && this.paid && setTimeout(() => { + ji(); + }, 3e3); + } + renderHeading(e) { + return W(t1 || (t1 = xe` +

+ ${0} sats +

+ `), re, be, e.satoshi.toLocaleString(void 0, { useGrouping: !0 })); + } + renderPaidState() { + return W(n1 || (n1 = xe` +
+

Paid!

+ ${0} +
+ `), be, H2); + } + renderPayingState() { + return W(r1 || (r1 = xe` +
+

Paying...

+ ${0} +
+ `), re, Ot(`w-48 h-48 ${be}`)); + } + renderPaymentConfirmation() { + return W(o1 || (o1 = xe` + + ${0} + Confirm Payment + + ${0} + `), this._payInvoice, bn, qi(this._connectorName)); + } + renderWaitingForPayment() { + return W(i1 || (i1 = xe` +
+ ${0} +

Waiting for payment

+
+ `), Ot(`w-7 h-7 ${be}`), re); + } + renderConnectWalletMobile() { + let e = null, t = null, n = null; + return this.paymentMethods !== "all" && this.paymentMethods !== "internal" || (e = W(s1 || (s1 = xe` + + ${0}Connect Wallet + + `), this._onClickConnectWallet, bn)), this.paymentMethods !== "all" && this.paymentMethods !== "external" || (this._showQR || (t = W(a1 || (a1 = xe` + + ${0} Copy & Display Invoice + + `), this._copyAndDisplayInvoice, P5)), this._showQR && (n = this.renderQR())), W(c1 || (c1 = xe` +
+ ${0} + ${0} ${0} +
+ ${0} + `), this.paymentMethods === "all" || this.paymentMethods === "external" ? W(l1 || (l1 = xe` + + ${0} Open in a Bitcoin Wallet + + `), this.invoice, O5) : null, e, t, n ? W(d1 || (d1 = xe`
${0}
`), n) : null); + } + renderConnectWalletDesktop() { + let e = null; + this.paymentMethods !== "all" && this.paymentMethods !== "internal" || (e = W(u1 || (u1 = xe` +
+ + ${0} + Connect Wallet to Pay + +
+ `), this.paymentMethods !== "internal" ? "mt-8" : "", this._onClickConnectWallet, bn)); + let t = null; + this.paymentMethods === "all" && (t = W(h1 || (h1 = xe`
${0}
`), P2("or"))); + let n = null; + return this.paymentMethods !== "all" && this.paymentMethods !== "external" || (n = W(f1 || (f1 = xe` +
+

+ Scan to Pay +

+ ${0} +
+ `), this.paymentMethods === "external" ? "mt-8" : "", re, this.renderQR())), W(p1 || (p1 = xe` ${0} ${0} ${0} `), e, t, n); + } + renderQR() { + if (!this._showQR || !this.invoice) return null; + const e = this.invoice; + return setTimeout(() => { + var t; + const n = (t = this.shadowRoot) == null ? void 0 : t.getElementById("qr"); + if (!n) return void console.error("qr canvas not found"); + const r = n.getContext("2d"); + if (!r) return void console.error("could not get context for qr canvas"); + const o = Bi(0, "L"); + o.addData(e), o.make(); + const i = o.getModuleCount(); + n.width = 2 * i, n.height = 2 * i, o.renderTo2dContext(r, 2); + }, 100), W(g1 || (g1 = xe` + + + + + + `), this.invoice, this._copyInvoice, be, Le, this._hasCopiedInvoice ? "Invoice copied to clipboard" : "Copy invoice to clipboard", this._hasCopiedInvoice ? Ki : Qi, this._hasCopiedInvoice ? "Copied!" : "Copy Invoice"); + } + renderMemo(e) { + return e.description ? W(w1 || (w1 = xe` +

+ ${0} +

+ `), Qe, e.description) : null; + } + render() { + if (!this.invoice) return null; + let e; + try { + e = new n3({ pr: this.invoice }); + } catch (r) { + return console.error(r), V.getState().setError(r.message), null; + } + const t = window.innerWidth < 600; + let n; + return t || (this._showQR = !0), n = this.paid ? this.renderPaidState() : this._isPaying ? this.renderPayingState() : this._connected ? this.renderPaymentConfirmation() : W(y1 || (y1 = xe` + ${0} + ${0} + `), this.paymentMethods !== "internal" ? this.renderWaitingForPayment() : null, t ? this.renderConnectWalletMobile() : this.renderConnectWalletDesktop()), W(b1 || (b1 = xe` +
+ ${0} ${0} + ${0} +
+ `), this.renderHeading(e), this.renderMemo(e), n); + } + _onClickConnectWallet() { + this.dispatchEvent(new Event("onclickconnectwallet", { bubbles: !0, composed: !0 })); + } + _copyAndDisplayInvoice() { + this._copyInvoice(), this._showQR = !0; + } + _copyInvoice() { + this.invoice && (navigator.clipboard.writeText(this.invoice), this._hasCopiedInvoice = !0, setTimeout(() => { + this._hasCopiedInvoice = !1; + }, 2e3)); + } + async _payInvoice() { + this._isPaying = !0; + try { + const e = V.getState().provider; + if (!e) throw new Error("No WebLN provider available"); + if (!this.invoice) throw new Error("No invoice to pay"); + const t = await e.sendPayment(this.invoice); + if (!t.preimage) throw new Error("No preimage in result"); + this.dispatchEvent(new CustomEvent("bc:onpaid", { bubbles: !0, composed: !0, detail: t })), this.paid = !0; + } catch (e) { + console.error(e), V.getState().setError(e.message); + } + this._isPaying = !1; + } +}; +F([se()], lt.prototype, "_hasCopiedInvoice", void 0), F([se()], lt.prototype, "_isPaying", void 0), F([se()], lt.prototype, "_showQR", void 0), F([me({ type: String })], lt.prototype, "invoice", void 0), F([me({ type: Boolean })], lt.prototype, "paid", void 0), F([me({ type: String, attribute: "payment-methods" })], lt.prototype, "paymentMethods", void 0), lt = F([oe("bc-send-payment")], lt); +const H5 = de(m1 || (m1 = ((e) => e)` + + + + + + + + + + + + + + + + + + + + + +`)); +let v1, D5 = (e) => e, C1 = class extends he()(ae) { + render() { + return W(v1 || (v1 = D5`
+ + +
+
+
+
+ ${0} +
+
+

+ To get the best self-custodial bitcoin lightning wallet that can + connect to apps, try + Alby Hub. +

+
+
+
${0}
+

+ For a quick setup of a custodial wallet, you can choose between + Rizful + and + Coinos. +

+
+
+
`), I2, re, Le, be, H5, re, Le, be, Le, be); + } +}; +C1 = F([oe("bc-new-wallet")], C1); +let x1, Z5 = (e) => e, fo = class extends he()(ae) { + constructor() { + super(...arguments), this._nwcUrl = ""; + } + render() { + return W(x1 || (x1 = Z5`
+ +
+
+
+ 1. Add a new + Wallet Connection + + from + LN Node => Generate NWC + and copy the Connection Secret. +
+
+ 2. Paste the Connection Secret below: +
+ + + + Connect + +
+
+
`), re, Qe, re, this._nwcUrl, this.nwcUrlChanged, Ut, rt, this.onConnect); + } + nwcUrlChanged(e) { + this._nwcUrl = e.target.value; + } + async onConnect() { + this._nwcUrl ? await V.getState().connect({ nwcUrl: this._nwcUrl, connectorName: zi, connectorType: "nwc.generic" }) : V.getState().setError("Please enter a URL"); + } +}; +F([se()], fo.prototype, "_nwcUrl", void 0), fo = F([oe("bc-lnfi")], fo); +let E1, W5 = (e) => e, A1 = class extends he()(ae) { + connectedCallback() { + super.connectedCallback(), this._timeout = setTimeout(() => { + ji(), V.setState({ route: "/start" }); + }, 3e3); + } + disconnectedCallback() { + super.disconnectedCallback(), this._timeout && clearTimeout(this._timeout); + } + render() { + return W(E1 || (E1 = W5`
+

Connected!

+ ${0} +
`), be, H2); + } +}; +A1 = F([oe("bc-connected")], A1); +let k1, _1, S1 = (e) => e, Fn = class extends he()(ae) { + constructor() { + super(), this._hasCopiedAuthString = !1, this.initAlbyGo(); + } + disconnectedCallback() { + var e; + super.disconnectedCallback(), (e = this._unsub) == null || e.call(this); + } + render() { + return W(k1 || (k1 = S1`
+ +
+
+
+ Scan with your camera, or by clicking "Send" in the Flash Wallet +
+ +
+ ${0} +

Waiting for connection

+
+ + + ${0} + + + + ${0} + ${0} + +
+ +
+

+ Don't have the Flash Wallet app? + Download one here +

+
+
+
+ `), re, Ot(`w-7 h-7 ${re}`), re, this.renderQR(), this._copyAuthString, be, Le, this._hasCopiedAuthString ? Ki : Qi, this._hasCopiedAuthString ? "Copied!" : "Copy", Sn, Le, be); + } + renderQR() { + if (!this._authString) return null; + const e = this._authString; + return setTimeout(() => { + var t; + const n = (t = this.shadowRoot) == null ? void 0 : t.getElementById("qr"); + if (!n) return void console.error("qr canvas not found"); + const r = n.getContext("2d"); + if (!r) return void console.error("could not get context for qr canvas"); + const o = Bi(0, "L"); + o.addData(e), o.make(); + const i = o.getModuleCount(); + n.width = 4 * i, n.height = 4 * i, o.renderTo2dContext(r, 4); + }, 100), W(_1 || (_1 = S1` + + + `)); + } + _copyAuthString() { + this._authString && (navigator.clipboard.writeText(this._authString), this._hasCopiedAuthString = !0, setTimeout(() => { + this._hasCopiedAuthString = !1; + }, 2e3)); + } + async initAlbyGo() { + try { + var e; + const t = (e = V.getState().bitcoinConnectConfig.providerConfig) == null || (e = e.nwc) == null ? void 0 : e.authorizationUrlOptions, n = t?.expiresAt; + let r = t?.requestMethods; + r || (r = ["get_info", "get_balance", "get_budget", "pay_invoice", "list_transactions", "lookup_invoice", "make_invoice"]); + const o = new s2({ name: this._appName, icon: this._appIcon, relayUrls: ["wss://nwclay.paywithflash.com"], requestMethods: r, notificationTypes: t?.notificationTypes, maxAmount: t?.maxAmount, budgetRenewal: t?.budgetRenewal, expiresAt: n ? Math.floor(n.getTime() / 1e3) : void 0, isolated: t?.isolated, metadata: t?.metadata, returnTo: t?.returnTo }); + this._authString = o.connectionUri, window.location.href = this._authString; + const { unsub: i } = await o.subscribe({ onSuccess: async function(s) { + s.close(), V.getState().connect({ nwcUrl: s.nostrWalletConnectUrl, connectorName: "Flash Wallet", connectorType: "nwc.flash" }); + } }); + this._unsub = i; + } catch (t) { + console.error(t), alert("" + t); + } + } +}; +F([se()], Fn.prototype, "_authString", void 0), F([se()], Fn.prototype, "_hasCopiedAuthString", void 0), Fn = F([oe("bc-flash-wallet")], Fn); +let L1, T1, F5 = (e) => e, po = class extends he()(ae) { + constructor() { + super(...arguments), this._nwcUrl = ""; + } + render() { + return W(L1 || (L1 = F5`
+ +
+
+
+ 1. In LNBits, go to Plugins and enable the NWC plugin. +
+
+ 2. Create a new connection and update the relay from "nostrclient" + to wss://relay.getalby.com/v1, + then copy the connection secret. +
+
+ 3. Paste the Connection Secret below. +
+ +
+
+ Enter your + Connection Secret + + below +
+ + + + Connect + +
+
+
+
`), zo, re, re, re, re, this._nwcUrl, this.nwcUrlChanged, Ut, rt, this.onConnect); + } + nwcUrlChanged(e) { + this._nwcUrl = e.target.value; + } + async onConnect() { + this._nwcUrl ? await V.getState().connect({ nwcUrl: this._nwcUrl, connectorName: zo, connectorType: "nwc.lnbits" }) : V.getState().setError("Please enter a URL"); + } +}; +F([se()], po.prototype, "_nwcUrl", void 0), po = F([oe("bc-lnbits-nwc")], po); +const V5 = de(T1 || (T1 = ((e) => e)` + + + + + + + + +`)), Ko = "Cashu.me"; +let M1 = class extends Ve { + constructor() { + super("nwc.cashume", Ko, "#7f38ca", V5); + } + async _onClick() { + V.getState().pushRoute("/cashu-me"); + } +}; +M1 = F([oe("bc-cashu-me-connector")], M1); +let B1, G5 = (e) => e, go = class extends he()(ae) { + constructor() { + super(...arguments), this._nwcUrl = ""; + } + render() { + return W(B1 || (B1 = G5`
+ +
+
+
+ 1. Open + Cashu.me + + , click on the hamburger menu on + the top left, then click + Settings. Scroll down to + Nostr Wallet Connect + and enable NWC, and then press the copy button. +
+
+ 2. Keep the Cashu.me browser tab open while using Bitcoin Connect. +
+
+ 3. Paste the Connection Secret below: +
+ +
+
+ Enter your + Connection Secret + + below +
+ + + + Connect + +
+
+
+
`), Ko, re, re, re, re, this._nwcUrl, this.nwcUrlChanged, Ut, rt, this.onConnect); + } + nwcUrlChanged(e) { + this._nwcUrl = e.target.value; + } + async onConnect() { + this._nwcUrl ? await V.getState().connect({ nwcUrl: this._nwcUrl, connectorName: Ko, connectorType: "nwc.cashume" }) : V.getState().setError("Please enter a URL"); + } +}; +F([se()], go.prototype, "_nwcUrl", void 0), go = F([oe("bc-cashu-me")], go); +let R1, j5 = (e) => e, wo = class extends he()(ae) { + constructor() { + super(...arguments), this._nwcUrl = ""; + } + render() { + return W(R1 || (R1 = j5`
+ +
+
+
+ 1. Open + Rizful Wallet + +
+
+ 2. Click on + Hamburger Menu -> NWC -> Get NWC codes -> New Connection. Then click Get Connection Code and + click + Copy Connection Code +
+ +
+ 3. Paste the Connection Secret below: +
+ +
+
+ Enter your + Connection Secret + + below +
+ + + + Connect + +
+
+
+
`), qo, re, re, re, re, this._nwcUrl, this.nwcUrlChanged, Ut, rt, this.onConnect); + } + nwcUrlChanged(e) { + this._nwcUrl = e.target.value; + } + async onConnect() { + this._nwcUrl ? await V.getState().connect({ nwcUrl: this._nwcUrl, connectorName: qo, connectorType: "nwc.rizful" }) : V.getState().setError("Please enter a URL"); + } +}; +F([se()], wo.prototype, "_nwcUrl", void 0), wo = F([oe("bc-rizful")], wo); +let N1, $1, I1, U1, O1, P1, H1, D1, Z1, W1, F1, V1, G1, Ie = (e) => e; +const z5 = { "/start": W(N1 || (N1 = Ie``)), "/help": W($1 || ($1 = Ie``)), "/nwc": W(I1 || (I1 = Ie``)), "/lnfi": W(U1 || (U1 = Ie``)), "/alby-hub": W(O1 || (O1 = Ie``)), "/alby-go": W(P1 || (P1 = Ie``)), "/lnbits": W(H1 || (H1 = Ie``)), "/lnbits-nwc": W(D1 || (D1 = Ie``)), "/flash-wallet": W(Z1 || (Z1 = Ie``)), "/cashu-me": W(W1 || (W1 = Ie``)), "/rizful": W(F1 || (F1 = Ie``)), "/new-wallet": W(V1 || (V1 = Ie``)), "/connected": W(G1 || (G1 = Ie``)) }; +let j1, z1, q5 = (e) => e, q1 = class extends he()(ae) { + render() { + return W(j1 || (j1 = q5`
${0}
`), z5[this._route]); + } +}; +q1 = F([oe("bc-router-outlet")], q1); +const K5 = de(z1 || (z1 = ((e) => e)` + +`)); +let K1; +const Q5 = de(K1 || (K1 = ((e) => e)` + + + + +`)); +let Q1, J1, Y1, yo = (e) => e, Vn = class extends he()(ae) { + render() { + return W(Q1 || (Q1 = yo`
+
+ ${0} + ${0} +
+
+ +
+
`), this.showHelp ? W(J1 || (J1 = yo``), Le, Qe, () => V.getState().pushRoute("/help"), Q5) : null, this.closable ? W(Y1 || (Y1 = yo``), Le, Qe, this._handleClose, K5) : null); + } + _handleClose() { + this.dispatchEvent(new Event("onclose", { bubbles: !0, composed: !0 })); + } +}; +F([me({ type: Boolean })], Vn.prototype, "closable", void 0), F([me({ type: Boolean, attribute: "show-help" })], Vn.prototype, "showHelp", void 0), Vn = F([oe("bc-modal-header")], Vn); +let X1, J5 = (e) => e, el = class extends he()(ae) { + constructor() { + super(...arguments), this._handleClose = () => { + ji(); + }; + } + render() { + return W(X1 || (X1 = J5`
+
+
+ +
+
`), this._handleClose, this._handleClose); + } +}; +el = F([oe("bc-modal")], el); +let tl, nl, Y5 = (e) => e, rl = class extends he()(qt) { + render() { + return W(tl || (tl = Y5` +
+ ${0} +

+ Connecting to wallet... +

+ ${0} +
+ `), Ot(`w-20 h-20 ${Qe} mb-4`), re, qi(void 0)); + } +}; +rl = F([oe("bci-connecting")], rl); +const X5 = de(nl || (nl = ((e) => e)` + + + + + + + + + + + + + + + + +`)); +let ol; +const e6 = de(ol || (ol = ((e) => e)` + + +`)); +let il, bo, sl, al, cl, ll, dl, hn = (e) => e, mo = (bo = class extends (il = he()(ae)) { + render() { + return W(sl || (sl = hn`
+ +
+ ${0} +
+
${0}
+
+
+ ${0} +
+ ${0} +
`), this.closable, be, e6, rt, X5, W(this._connecting ? al || (al = hn``) : cl || (cl = hn` `)), this._error ? W(ll || (ll = hn`

+ ${0} +

`), this._error) : null); + } +}, bo.styles = [...il.styles, Lr(dl || (dl = hn` + :host { + display: flex; + justify-content: center; + width: 100%; + } + `))], bo); +F([me({ type: Boolean })], mo.prototype, "closable", void 0), mo = F([oe("bc-connect")], mo); +let ul, vo, hl, fl, pl, gl, Gn = (e) => e, _t = (vo = class extends (ul = he()(ae)) { + constructor() { + super(), this.paymentMethods = "all", this._showConnect = !1, V.subscribe((e, t) => { + e.connected !== t.connected && e.connected && (this._showConnect = !1); + }); + } + render() { + return this._showConnect && !this.paid ? W(hl || (hl = Gn` `), !0) : W(fl || (fl = Gn`
+ +

+ Payment Request +

+
+
+ +
+ ${0} +
`), this.closable, re, this.invoice, this.paymentMethods, this.paid, this._onClickConnectWallet, this._error ? W(pl || (pl = Gn`

+ ${0} +

`), this._error) : null); + } + _onClickConnectWallet() { + this._showConnect = !0; + } +}, vo.styles = [...ul.styles, Lr(gl || (gl = Gn` + :host { + display: flex; + align-items: center; + justify-content: center; + width: 100%; + } + `))], vo); +F([me({ type: Boolean })], _t.prototype, "closable", void 0), F([me({ type: String })], _t.prototype, "invoice", void 0), F([me({ type: String, attribute: "payment-methods" })], _t.prototype, "paymentMethods", void 0), F([me({ type: Boolean })], _t.prototype, "paid", void 0), F([se()], _t.prototype, "_showConnect", void 0), _t = F([oe("bc-payment")], _t); +const f6 = { NostrWebLNProvider: Ar, LNCWebLNProvider: d2, LnbitsWebLNProvider: u2 }; +export { + Za as AlbyHubConnector, + Zt as Balance, + Pn as Button, + Ya as CoinosConnector, + mo as ConnectFlow, + ao as ConnectorList, + Dn as CurrencySwitcher, + Ha as ExtensionConnector, + ec as FlashConnector, + Fa as GenericNWCConnector, + ja as LNBitsConnector, + Ga as LNCConnector, + qa as LNbitsNWCConnector, + Qa as LnfiNWCConnector, + el as Modal, + ct as PayButton, + tc as RizfulConnector, + lt as SendPayment, + _t as SendPaymentFlow, + f6 as WebLNProviders, + U2 as albyHubConnectorTitle, + ji as closeModal, + C5 as coinosConnectorTitle, + l6 as connect, + d6 as connectNWC, + u6 as disconnect, + E5 as flashConnectorTitle, + zi as genericConnectorTitle, + h6 as getConnectorConfig, + a6 as init, + s6 as isConnected, + $2 as launchModal, + l5 as launchPaymentModal, + jo as lnbitsConnectorTitle, + zo as lnbitsNWCConnectorTitle, + m5 as lnfiConnectorTitle, + c5 as onConnected, + n6 as onConnecting, + r6 as onDisconnected, + N2 as onModalClosed, + o6 as onModalOpened, + c6 as refreshBalance, + i6 as requestProvider, + qo as rizfulConnectorTitle +}; diff --git a/vendor/bitlogin/bitlogin.js b/vendor/bitlogin/bitlogin.js index c2bb0caf..dcd5f41f 100644 --- a/vendor/bitlogin/bitlogin.js +++ b/vendor/bitlogin/bitlogin.js @@ -1,13 +1,13 @@ -import { r as y, e as w, E as v, p as Q, R as k, i as h, a as d } from "./bitlogin-shared-QIBe5Omw.js"; -const x = 6, p = 64; -function u(a = x) { - const e = w(), t = []; - for (let r = 0; r < a; r++) - t.push(e[y(e.length)]); - const s = a * v; - if (s < p) - throw new Error(`Passphrase of ${a} words provides only ~${s.toFixed(1)} bits; must exceed ${p}.`); - return { kind: "passphrase", secret: t.join(" "), entropyBits: s }; +import { r as w, e as k, E as Q, p as x, R as C, i as p, a as d } from "./bitlogin-shared-B2Rc9khL.js"; +const S = 6, f = 64; +function u(r = S) { + const e = k(), t = []; + for (let s = 0; s < r; s++) + t.push(e[w(e.length)]); + const a = r * Q; + if (a < f) + throw new Error(`Passphrase of ${r} words provides only ~${a.toFixed(1)} bits; must exceed ${f}.`); + return { kind: "passphrase", secret: t.join(" "), entropyBits: a }; } const b = 64, m = 12, P = /* @__PURE__ */ new Set([ "password", @@ -41,56 +41,77 @@ const b = 64, m = 12, P = /* @__PURE__ */ new Set([ "passw0rd", "correcthorsebatterystaple" ]); -function L(a) { +function L(r) { let e = 0; - return /[a-z]/u.test(a) && (e += 26), /[A-Z]/u.test(a) && (e += 26), /[0-9]/u.test(a) && (e += 10), /[^a-zA-Z0-9]/u.test(a) && (e += 33), e || 1; + return /[a-z]/u.test(r) && (e += 26), /[A-Z]/u.test(r) && (e += 26), /[0-9]/u.test(r) && (e += 10), /[^a-zA-Z0-9]/u.test(r) && (e += 33), e || 1; } -function S(a) { - return a.length * Math.log2(L(a)); +function E(r) { + return r.length * Math.log2(L(r)); } -function C(a) { - if (/^(.)\1*$/u.test(a) || /(.)\1{2,}/u.test(a)) +function $(r) { + if (/^(.)\1*$/u.test(r) || /(.)\1{2,}/u.test(r)) return !0; - const e = a.toLowerCase(), t = ["0123456789", "abcdefghijklmnopqrstuvwxyz"]; - for (const s of t) - for (let r = 0; r + 4 <= s.length; r++) { - const n = s.slice(r, r + 4), o = [...n].reverse().join(""); + const e = r.toLowerCase(), t = ["0123456789", "abcdefghijklmnopqrstuvwxyz"]; + for (const a of t) + for (let s = 0; s + 4 <= a.length; s++) { + const n = a.slice(s, s + 4), o = [...n].reverse().join(""); if (e.includes(n) || e.includes(o)) return !0; } return !1; } -function g(a, e) { - const t = S(a); - return a.length < m ? { ok: !1, entropyBits: t, reason: `Must be at least ${m} characters.` } : P.has(a.toLowerCase()) ? { ok: !1, entropyBits: t, reason: "This is on a list of extremely common passwords." } : e.length >= 3 && a.toLowerCase().includes(e) ? { ok: !1, entropyBits: t, reason: "Must not contain your login name." } : C(a) ? { ok: !1, entropyBits: t, reason: "Too predictable (repeated characters or a simple sequence)." } : t < b ? { +function g(r, e) { + const t = E(r); + return r.length < m ? { ok: !1, entropyBits: t, reason: `Must be at least ${m} characters.` } : P.has(r.toLowerCase()) ? { ok: !1, entropyBits: t, reason: "This is on a list of extremely common passwords." } : e.length >= 3 && r.toLowerCase().includes(e) ? { ok: !1, entropyBits: t, reason: "Must not contain your login name." } : $(r) ? { ok: !1, entropyBits: t, reason: "Too predictable (repeated characters or a simple sequence)." } : t < b ? { ok: !1, entropyBits: t, reason: `Estimated entropy (~${t.toFixed(0)} bits) is below the required ${b}. Use a longer password or mix character types.` } : { ok: !0, entropyBits: t }; } -class E { +const R = 6e4; +class N { worker; pending = /* @__PURE__ */ new Map(); counter = 0; + dead = !1; constructor() { const e = ["cryptoWorker", ".js"].join(""), t = new URL(e, import.meta.url); this.worker = new Worker(t, { type: "module" }), this.worker.addEventListener("message", (s) => { - const r = s.data, n = this.pending.get(r.id); - if (n) - if (this.pending.delete(r.id), r.ok) - n.resolve(r.result); + const n = s.data; + if (!n || typeof n != "object" || typeof n.id != "string") return; + const o = this.pending.get(n.id); + if (o) + if (this.pending.delete(n.id), clearTimeout(o.timer), n.ok) + o.resolve(n.result); else { - const o = new Error(r.error); - o.name = r.errorName ?? "Error", n.reject(o); + const l = new Error(n.error); + l.name = n.errorName ?? "Error", o.reject(l); } }); + const a = (s) => () => this.failAll(s); + this.worker.addEventListener("error", a("The BitLogin crypto worker stopped unexpectedly.")), this.worker.addEventListener( + "messageerror", + a("The BitLogin crypto worker sent an unreadable message.") + ); + } + /** Settles every outstanding call with an error. Idempotent. */ + failAll(e) { + const t = [...this.pending.values()]; + this.pending.clear(); + for (const a of t) + clearTimeout(a.timer), a.reject(new Error(e)); } call(e, t) { - const s = `${Date.now().toString(36)}-${(this.counter++).toString(36)}`; - return new Promise((r, n) => { - this.pending.set(s, { resolve: r, reject: n }); - const o = { id: s, action: e, payload: t }; - this.worker.postMessage(o); + if (this.dead) + return Promise.reject(new Error("This BitLogin session was torn down; reload the page to sign in again.")); + const a = `${Date.now().toString(36)}-${(this.counter++).toString(36)}`; + return new Promise((s, n) => { + const o = setTimeout(() => { + this.pending.delete(a), n(new Error(`BitLogin's ${e} call timed out.`)); + }, R); + this.pending.set(a, { resolve: s, reject: n, timer: o }); + const l = { id: a, action: e, payload: t }; + this.worker.postMessage(l); }); } configure(e) { @@ -150,64 +171,88 @@ class E { restoreSession() { return this.call("restoreSession", {}); } + vaultStatus() { + return this.call("vaultStatus", {}); + } + vaultList() { + return this.call("vaultList", {}); + } + vaultSaveNwc(e) { + return this.call("vaultSaveNwc", e); + } + vaultFindForOrigin() { + return this.call("vaultFindForOrigin", {}); + } + vaultRevealNwc(e) { + return this.call("vaultRevealNwc", e); + } + vaultSetBinding(e) { + return this.call("vaultSetBinding", e); + } + vaultDelete(e) { + return this.call("vaultDelete", e); + } + vaultOfferCheck(e) { + return this.call("vaultOfferCheck", e); + } logout() { return this.call("logout", {}); } terminate() { - this.worker.terminate(); + this.dead = !0, this.worker.terminate(), this.failAll("The BitLogin crypto worker was terminated."); } } -const N = "BitLogin: no identity is unlocked yet. Add to the page and let the user sign in, or call it programmatically before invoking window.nostr."; -function c(a) { - return a.catch((e) => { - throw e.message.includes("No identity is unlocked") ? new Error(N) : e; +const M = "BitLogin: no identity is unlocked yet. Add to the page and let the user sign in, or call it programmatically before invoking window.nostr."; +function c(r) { + return r.catch((e) => { + throw e.message.includes("No identity is unlocked") ? new Error(M) : e; }); } -function $(a, e) { +function B(r, e) { return { async getPublicKey() { - const { publicKey: t } = await c(a.getPublicKey()); + const { publicKey: t } = await c(r.getPublicKey()); return t; }, async signEvent(t) { - return c(a.signEvent(t)); + return c(r.signEvent(t)); }, async getRelays() { const t = {}; - for (const s of e()) t[s] = { read: !0, write: !0 }; + for (const a of e()) t[a] = { read: !0, write: !0 }; return t; }, nip44: { - async encrypt(t, s) { - const { ciphertext: r } = await c(a.nip44Encrypt({ peerPublicKey: t, plaintext: s })); - return r; + async encrypt(t, a) { + const { ciphertext: s } = await c(r.nip44Encrypt({ peerPublicKey: t, plaintext: a })); + return s; }, - async decrypt(t, s) { - const { plaintext: r } = await c(a.nip44Decrypt({ peerPublicKey: t, payload: s })); - return r; + async decrypt(t, a) { + const { plaintext: s } = await c(r.nip44Decrypt({ peerPublicKey: t, payload: a })); + return s; } }, nip04: { - async encrypt(t, s) { - const { ciphertext: r } = await c(a.nip04Encrypt({ peerPublicKey: t, plaintext: s })); - return r; + async encrypt(t, a) { + const { ciphertext: s } = await c(r.nip04Encrypt({ peerPublicKey: t, plaintext: a })); + return s; }, - async decrypt(t, s) { - const { plaintext: r } = await c(a.nip04Decrypt({ peerPublicKey: t, payload: s })); - return r; + async decrypt(t, a) { + const { plaintext: s } = await c(r.nip04Decrypt({ peerPublicKey: t, payload: a })); + return s; } }, _bitlogin: !0 }; } -function R(a) { - const e = a.getAttribute("vault-relays"), t = a.getAttribute("discovery-relays"); +function T(r) { + const e = r.getAttribute("vault-relays"), t = r.getAttribute("discovery-relays"); return { - vaultRelayUrls: e ? e.split(",").map((s) => s.trim()).filter(Boolean) : void 0, - discoveryRelayUrls: t ? t.split(",").map((s) => s.trim()).filter(Boolean) : void 0 + vaultRelayUrls: e ? e.split(",").map((a) => a.trim()).filter(Boolean) : void 0, + discoveryRelayUrls: t ? t.split(",").map((a) => a.trim()).filter(Boolean) : void 0 }; } -const M = ( +const q = ( /* css */ ` :host { @@ -448,8 +493,60 @@ button.link { } @keyframes bl-spin { to { transform: rotate(360deg); } } ` -); -class F extends HTMLElement { +), y = "bc:config", U = /^nostr\+walletconnect:\/\//iu; +let h = null; +function F(r) { + if (!h) { + try { + localStorage.removeItem(y); + } catch { + } + h = import("./bitlogin-shared-IsyHQNSG.js").then((e) => (e.init({ + appName: r, + filters: ["nwc"], + showBalance: !1, + autoConnect: !1, + persistConnection: !1, + providerConfig: { + nwc: { + authorizationUrlOptions: { + name: r, + requestMethods: ["pay_invoice"] + } + } + } + }), e)).catch((e) => { + throw h = null, e; + }); + } + return h; +} +function I(r) { + const e = r instanceof Error ? r.message : String(r); + return /closed|cancell?ed|dismissed|aborted/iu.test(e); +} +async function O(r) { + const e = await F(r); + try { + const t = await e.requestProvider(), a = e.getConnectorConfig()?.nwcUrl, s = t.client?.nostrWalletConnectUrl, n = typeof a == "string" ? a : typeof s == "string" ? s : ""; + if (!U.test(n.trim())) + throw new Error("The wallet did not return an NWC connection. Try again or paste one manually."); + return n.trim(); + } catch (t) { + if (I(t)) return null; + throw t; + } finally { + try { + e.disconnect(); + } catch { + } + try { + localStorage.removeItem(y); + } catch { + } + } +} +class D extends HTMLElement { root; worker; vaultRelayUrls = []; @@ -500,14 +597,30 @@ class F extends HTMLElement { // signer or dispatching bitlogin-login, and requires an explicit second step to proceed. pendingRollback = null; rollbackMessage = ""; + // ---- Connection Vault request flow (vault-ux.md §2-§4, reveal mode) ---- + // stage "auth": waiting for the user to sign in first; the goto("dashboard") + // hook resumes the request exactly once. stage "active": the vault screens + // own navigation until finishVaultRequest() settles the promise. + vaultRequest = null; + vaultCandidate = null; + /** True when the account cannot store the connection (no vault root); the + * flow still hands the URI to the app, labeled as unsaved. */ + vaultUnsaved = !1; + vaultUnsavedReason; + vaultConnections = null; + /** offerNwcConnection state: the app already holds this URI; the only + * question on screen is whether a copy enters the user's vault. */ + /** Claimed synchronously by offerNwcConnection before any await (see there). */ + offerInFlight = !1; + vaultOffer = null; constructor() { super(), this.root = this.attachShadow({ mode: "open" }); const e = new CSSStyleSheet(); - e.replaceSync(M), this.root.adoptedStyleSheets = [e], this.worker = new E(); + e.replaceSync(q), this.root.adoptedStyleSheets = [e], this.worker = new N(); } connectedCallback() { - const e = R(this); - if (this.vaultRelayUrls = e.vaultRelayUrls ?? [], this.discoveryRelayUrls = e.discoveryRelayUrls ?? [], this.worker.configure({ vaultRelayUrls: this.vaultRelayUrls, discoveryRelayUrls: this.discoveryRelayUrls }).then(() => this.tryRestoreSession()), this.root.addEventListener("click", (t) => this.onClick(t)), this.root.addEventListener("submit", (t) => this.onSubmit(t)), this.root.addEventListener("input", (t) => this.onInput(t)), this.root.addEventListener("change", (t) => void this.onFileChange(t)), this.render(), this.installedProvider = $(this.worker, () => this.vaultRelayUrls), !window.nostr) + const e = T(this); + if (this.vaultRelayUrls = e.vaultRelayUrls ?? [], this.discoveryRelayUrls = e.discoveryRelayUrls ?? [], this.worker.configure({ vaultRelayUrls: this.vaultRelayUrls, discoveryRelayUrls: this.discoveryRelayUrls }).then(() => this.tryRestoreSession()), this.root.addEventListener("click", (t) => this.onClick(t)), this.root.addEventListener("submit", (t) => this.onSubmit(t)), this.root.addEventListener("input", (t) => this.onInput(t)), this.root.addEventListener("change", (t) => void this.onFileChange(t)), this.render(), this.installedProvider = B(this.worker, () => this.vaultRelayUrls), !window.nostr) try { window.nostr = this.installedProvider; } catch { @@ -551,6 +664,186 @@ class F extends HTMLElement { async logout() { await this.worker.logout(), this.session = null, this.releaseSigner(), this.dispatchEvent(new CustomEvent("bitlogin-logout")), this.goto("welcome"); } + /** + * Connection Vault request API (connection-vault.md §12, vault-ux.md §2-§4). + * + * Asks the user to share an NWC wallet connection with THIS page's origin + * and resolves the raw `nostr+walletconnect://` URI, or null if the user + * declines or dismisses. REVEAL MODE, stated plainly: the caller receives + * the full bearer credential and everything its wallet-side budget allows — + * an embedded same-origin widget cannot broker (§CV12.3), so it does not + * pretend to. The consent copy tells the user the same thing. + * + * If nobody is signed in, the widget shows its sign-in flow first and + * resumes the request after. If the account already has a connection bound + * to this origin, the user sees a one-tap approval; otherwise a guided + * import (Bitcoin Connect chooser, or paste). + */ + async requestNwcConnection(e = {}) { + if (this.vaultRequest) throw new Error("A wallet connection request is already in progress."); + const t = window.location.origin, a = e.appName?.trim() || window.location.hostname || "This app"; + return new Promise((s) => { + this.vaultRequest = { appName: a, reason: e.reason, origin: t, stage: "auth", resolve: s }, this.dispatchEvent(new CustomEvent("bitlogin-request-pending")), (async () => { + try { + if (!(await this.worker.getSessionStatus()).unlocked) { + this.goto("login"); + return; + } + await this.continueVaultRequest(); + } catch (n) { + this.fail(n); + } + })(); + }); + } + /** + * Offer-to-save (the inverse of requestNwcConnection): the app OBTAINED an + * NWC URI by its own means — its own wallet chooser, its own paste box — + * and offers the user a portable copy. Consent-gated in this widget's own + * UI, never silent: the write goes to the user's account (encrypted events + * under their vault identity), and nothing enters or leaves the vault + * without the user seeing it happen in BitLogin's chrome. + * + * Resolves "saved", "declined", "already-saved" (same wallet + secret + * exists; its origin binding was refreshed, no UI shown), or "unavailable" + * (no session or no vault root — the offer is quietly impossible, and an + * app should treat that as a no-op rather than an error). + */ + async offerNwcConnection(e, t = {}) { + if (this.vaultOffer || this.vaultRequest || this.offerInFlight) return "unavailable"; + this.offerInFlight = !0; + try { + return await this.runOfferNwcConnection(e, t); + } finally { + this.offerInFlight = !1; + } + } + async runOfferNwcConnection(e, t) { + if (!(await this.worker.getSessionStatus().catch(() => ({ unlocked: !1 }))).unlocked || !(await this.worker.vaultStatus()).enabled) return "unavailable"; + if ((await this.worker.vaultOfferCheck({ uri: e })).duplicate) return "already-saved"; + const o = t.appName?.trim() || window.location.hostname || "This app"; + return new Promise((l) => { + this.vaultOffer = { + uri: e, + appName: o, + label: t.label?.trim() || `${o} wallet`, + resolve: l + }, this.dispatchEvent(new CustomEvent("bitlogin-offer-pending")), this.goto("vault-offer"); + }); + } + finishVaultOffer(e) { + const t = this.vaultOffer; + t && (this.vaultOffer = null, t.resolve(e), this.goto(this.session ? "dashboard" : "welcome")); + } + async acceptVaultOffer() { + const e = this.vaultOffer; + if (e) { + this.setBusy(!0); + try { + const t = this.field("vaultOfferLabel").trim() || e.label; + await this.worker.vaultSaveNwc({ uri: e.uri, label: t }), this.setBusy(!1), this.finishVaultOffer("saved"), this.flashSuccess(this.screen, "Wallet saved"), this.dispatchEvent( + new CustomEvent("bitlogin-connection-granted", { detail: { origin: window.location.origin } }) + ); + } catch (t) { + this.setBusy(!1), this.fail(t); + } + } + } + /** Settles the pending request exactly once and returns to a neutral screen. */ + finishVaultRequest(e) { + const t = this.vaultRequest; + t && (this.vaultRequest = null, this.vaultCandidate = null, this.vaultUnsaved = !1, this.vaultUnsavedReason = void 0, t.resolve(e), e !== null && this.dispatchEvent( + new CustomEvent("bitlogin-connection-granted", { detail: { origin: t.origin } }) + ), this.goto(this.session ? "dashboard" : "welcome")); + } + async continueVaultRequest() { + const e = this.vaultRequest; + if (!e) return; + e.stage = "active"; + const t = await this.worker.vaultStatus(); + if (!t.enabled) { + this.vaultUnsaved = !0, this.vaultUnsavedReason = t.reason, this.goto("vault-import"); + return; + } + this.vaultUnsaved = !1; + const a = await this.worker.vaultFindForOrigin(); + a.connection ? (this.vaultCandidate = a.connection, this.goto("vault-consent")) : this.goto("vault-import"); + } + async approveVaultCandidate() { + const e = this.vaultCandidate; + if (!(!e || !this.vaultRequest)) { + this.setBusy(!0); + try { + const { uri: t } = await this.worker.vaultRevealNwc({ connectionId: e.connectionId }); + this.setBusy(!1), this.finishVaultRequest(t), this.flashSuccess(this.screen, "Wallet shared"); + } catch (t) { + this.setBusy(!1), this.fail(t); + } + } + } + async runVaultBcChooser() { + const e = this.vaultRequest; + if (e) { + this.setBusy(!0); + try { + const t = await O(e.appName); + if (t === null) { + this.setBusy(!1); + return; + } + await this.saveAndShareVaultUri(t, this.field("vaultLabel")); + } catch (t) { + this.setBusy(!1), this.fail(t); + } + } + } + async handleVaultImportSubmit() { + const e = this.field("vaultUri").trim(); + if (e) { + this.setBusy(!0); + try { + await this.saveAndShareVaultUri(e, this.field("vaultLabel")); + } catch (t) { + this.setBusy(!1), this.fail(t); + } + } + } + async saveAndShareVaultUri(e, t) { + const a = this.vaultRequest; + if (!a) return; + if (this.vaultUnsaved) { + this.setBusy(!1), this.finishVaultRequest(e); + return; + } + const s = t.trim() || `${a.appName} wallet`; + await this.worker.vaultSaveNwc({ uri: e, label: s }), this.setBusy(!1), this.finishVaultRequest(e), this.flashSuccess(this.screen, "Wallet connected"); + } + async loadVaultManage() { + this.vaultConnections = null, this.goto("vault-manage"); + try { + const e = await this.worker.vaultList(); + this.vaultConnections = e.connections; + } catch (e) { + this.errorMessage = e instanceof Error ? e.message : String(e), this.vaultConnections = []; + } + this.render(); + } + async vaultUnbind(e) { + this.setBusy(!0); + try { + await this.worker.vaultSetBinding({ connectionId: e, origin: null }), this.busy = !1, await this.loadVaultManage(); + } catch (t) { + this.setBusy(!1), this.fail(t); + } + } + async vaultDeleteConnection(e) { + this.setBusy(!0); + try { + await this.worker.vaultDelete({ connectionId: e }), this.busy = !1, await this.loadVaultManage(); + } catch (t) { + this.setBusy(!1), this.fail(t); + } + } /** * (Re)installs this element's own provider as window.nostr, taking over from whatever is * currently there (an extension, a different BitLogin instance, or nothing). Called @@ -614,6 +907,18 @@ class F extends HTMLElement { return !1; } goto(e) { + if (e === "dashboard" && this.vaultRequest?.stage === "auth") { + this.continueVaultRequest().catch((t) => this.fail(t)); + return; + } + if (e === "welcome" && this.vaultRequest) { + this.finishVaultRequest(null); + return; + } + if (e === "welcome" && this.vaultOffer) { + this.finishVaultOffer("declined"); + return; + } this.screen = e, this.errorMessage = void 0, this.render(); } setBusy(e) { @@ -646,10 +951,10 @@ class F extends HTMLElement { * validation-failure re-render can restore it (see renderManualPasswordFields). */ readManualPassword(e) { - const t = this.field("manualPassword"), s = this.field("manualPasswordConfirm"); - this.manualPasswordDraft = t, this.manualPasswordConfirmDraft = s; - const r = g(t, e); - return r.ok ? t !== s ? { password: "", error: "Passwords do not match. Please re-enter both." } : { password: t } : { password: "", error: `Password not accepted: ${r.reason}` }; + const t = this.field("manualPassword"), a = this.field("manualPasswordConfirm"); + this.manualPasswordDraft = t, this.manualPasswordConfirmDraft = a; + const s = g(t, e); + return s.ok ? t !== a ? { password: "", error: "Passwords do not match. Please re-enter both." } : { password: t } : { password: "", error: `Password not accepted: ${s.reason}` }; } /** * Explicitly asks the browser to offer saving this credential via the Credential @@ -665,17 +970,39 @@ class F extends HTMLElement { */ async offerToSaveCredential(e, t) { try { - const s = window.PasswordCredential; - if (!s || !navigator.credentials?.store) return; - const r = new s({ id: e, password: t, name: e }); - await navigator.credentials.store(r); + const a = window.PasswordCredential; + if (!a || !navigator.credentials?.store) return; + const s = new a({ id: e, password: t, name: e }); + await navigator.credentials.store(s); } catch { } } async onClick(e) { + if (!e.isTrusted) return; const t = e.target.closest("[data-action]"); if (!t) return; switch (t.dataset.action) { + case "vault-offer-save": + return this.acceptVaultOffer(); + case "vault-offer-decline": + this.finishVaultOffer("declined"); + return; + case "vault-approve": + return this.approveVaultCandidate(); + case "vault-different": + this.vaultCandidate = null, this.goto("vault-import"); + return; + case "vault-bc": + return this.runVaultBcChooser(); + case "vault-cancel": + this.finishVaultRequest(null); + return; + case "goto-vault-manage": + return this.loadVaultManage(); + case "vault-unbind": + return this.vaultUnbind(t.dataset.id); + case "vault-delete": + return this.vaultDeleteConnection(t.dataset.id); case "goto-create": this.loginName = "", this.importKey = "", this.importPreviewNpub = "", this.goto("create-name"); return; @@ -717,16 +1044,16 @@ class F extends HTMLElement { this.manualPasswordMode = !this.manualPasswordMode, this.manualPasswordFeedback = null, this.manualPasswordDraft = "", this.manualPasswordConfirmDraft = "", this.savedCheckbox = !1, this.render(); return; case "copy-credential": { - const r = this.root.querySelector("#credential-box"), n = t, o = n.textContent ?? "Copy", l = (f) => { - n.textContent = f, setTimeout(() => { + const s = this.root.querySelector("#credential-box"), n = t, o = n.textContent ?? "Copy", l = (v) => { + n.textContent = v, setTimeout(() => { n.isConnected && (n.textContent = o); }, 2e3); }; - if (!r || !navigator.clipboard?.writeText) { + if (!s || !navigator.clipboard?.writeText) { l("Copy not available — select the text manually"); return; } - navigator.clipboard.writeText(r.textContent ?? "").then( + navigator.clipboard.writeText(s.textContent ?? "").then( () => l("Copied"), () => l("Copy failed — select the text manually") ); @@ -741,8 +1068,8 @@ class F extends HTMLElement { case "logout": return this.logout(); case "rollback-retry": { - const r = this.pendingRollback?.kind; - this.pendingRollback = null, this.goto(r === "change-password" ? "change-password" : "login"); + const s = this.pendingRollback?.kind; + this.pendingRollback = null, this.goto(s === "change-password" ? "change-password" : "login"); return; } case "rollback-continue": @@ -752,10 +1079,10 @@ class F extends HTMLElement { } } async onSubmit(e) { - e.preventDefault(); - const s = e.target.dataset.form; + if (e.preventDefault(), !e.isTrusted) return; + const a = e.target.dataset.form; try { - switch (s) { + switch (a) { case "import-key": return await this.handlePreviewImport(); case "create-name": @@ -772,11 +1099,13 @@ class F extends HTMLElement { return await this.handleRecoverNewCredentialsSubmit(); case "change-password": return await this.handleChangePasswordSubmit(); + case "vault-import": + return await this.handleVaultImportSubmit(); default: return; } - } catch (r) { - this.fail(r); + } catch (s) { + this.fail(s); } } /** @@ -787,8 +1116,8 @@ class F extends HTMLElement { onInput(e) { const t = e.target; if (!(t instanceof HTMLInputElement) || t.name !== "manualPassword" && t.name !== "manualPasswordConfirm") return; - const s = this.root.querySelector('input[name="manualPassword"]')?.value ?? "", r = this.root.querySelector('input[name="manualPasswordConfirm"]')?.value ?? ""; - this.manualPasswordFeedback = s ? g(s, this.loginName) : null; + const a = this.root.querySelector('input[name="manualPassword"]')?.value ?? "", s = this.root.querySelector('input[name="manualPasswordConfirm"]')?.value ?? ""; + this.manualPasswordFeedback = a ? g(a, this.loginName) : null; const n = this.root.querySelector("#manual-password-feedback"); if (n) if (!this.manualPasswordFeedback) @@ -798,7 +1127,7 @@ class F extends HTMLElement { this.manualPasswordFeedback.ok ? (n.textContent = `Looks good (~${l} bits estimated).`, n.className = "notice info") : (n.textContent = `${this.manualPasswordFeedback.reason} (~${l} bits estimated)`, n.className = "notice warn"); } const o = this.root.querySelector("#manual-password-match-feedback"); - o && (r ? r === s ? (o.textContent = "Passwords match.", o.className = "notice info") : (o.textContent = "Passwords do not match.", o.className = "notice warn") : (o.textContent = "", o.className = "notice info")); + o && (s ? s === a ? (o.textContent = "Passwords match.", o.className = "notice info") : (o.textContent = "Passwords do not match.", o.className = "notice warn") : (o.textContent = "", o.className = "notice info")); } /** * Reads and validates an optional recovery-export file (§19.5) for the recover-phrase @@ -808,16 +1137,16 @@ class F extends HTMLElement { async onFileChange(e) { const t = e.target; if (!(t instanceof HTMLInputElement) || t.name !== "offlineExportFile" || t.type !== "file") return; - const s = t.files?.[0]; - if (!s) { + const a = t.files?.[0]; + if (!a) { this.offlineExportFile = null, this.offlineExportFileNotice = void 0, this.render(); return; } try { - const r = await s.text(); - this.offlineExportFile = Q(JSON.parse(r)), this.offlineExportFileNotice = `Loaded recovery export from ${new Date(this.offlineExportFile.created_at * 1e3).toLocaleString()}.`; - } catch (r) { - this.offlineExportFile = null, this.offlineExportFileNotice = r instanceof k || r instanceof SyntaxError ? `Couldn't read that file: ${r.message}` : `Couldn't read that file: ${String(r)}`; + const s = await a.text(); + this.offlineExportFile = x(JSON.parse(s)), this.offlineExportFileNotice = `Loaded recovery export from ${new Date(this.offlineExportFile.created_at * 1e3).toLocaleString()}.`; + } catch (s) { + this.offlineExportFile = null, this.offlineExportFileNotice = s instanceof C || s instanceof SyntaxError ? `Couldn't read that file: ${s.message}` : `Couldn't read that file: ${String(s)}`; } this.render(); } @@ -844,7 +1173,7 @@ class F extends HTMLElement { } handleCreateNameSubmit() { const e = this.field("loginName").trim().toLowerCase(); - if (!h(e)) { + if (!p(e)) { this.errorMessage = "Login name must be 3-32 characters: a-z, 0-9, '.', '_', '-', and not start/end with punctuation.", this.render(); return; } @@ -872,8 +1201,8 @@ class F extends HTMLElement { importKey: this.importKey || void 0 }); this.importKey = "", this.importPreviewNpub = "", this.recoveryPhrase = t.recoveryPhrase; - const s = this.recoveryPhrase.split(" "), r = D(s.length, 3); - this.confirmSlots = r.map((n) => ({ index: n, value: "" })), this.session = { publicKey: t.everydayPublicKey, npub: d(t.everydayPublicKey), accountId: t.accountId }, this.busy = !1, this.goto("confirm-phrase"), this.worker.publishProfileAndRelayLists({ + const a = this.recoveryPhrase.split(" "), s = K(a.length, 3); + this.confirmSlots = s.map((n) => ({ index: n, value: "" })), this.session = { publicKey: t.everydayPublicKey, npub: d(t.everydayPublicKey), accountId: t.accountId }, this.busy = !1, this.goto("confirm-phrase"), this.worker.publishProfileAndRelayLists({ name: this.loginName, generalRelays: this.vaultRelayUrls, dmRelays: this.vaultRelayUrls @@ -919,17 +1248,17 @@ class F extends HTMLElement { * paths grant a session identically -- claimSigner() and the bitlogin-login event only ever * fire once a RollbackDetectedError (if any) has been resolved one way or the other. */ - async attemptLogin(e, t, s = !1) { + async attemptLogin(e, t, a = !1) { this.setBusy(!0); try { - const r = await this.worker.login({ loginName: e, password: t, acknowledgeRollback: s }); - this.loginName = e, this.session = { publicKey: r.everydayPublicKey, npub: d(r.everydayPublicKey), accountId: r.accountId }, this.sessionWarnings = [r.rollbackWarning, r.relayDisagreementWarning].filter((n) => !!n), this.busy = !1, this.noteSignerClaim(this.claimSigner()), this.dispatchEvent(new CustomEvent("bitlogin-login", { detail: { publicKey: r.everydayPublicKey } })), this.flashSuccess("dashboard", "Signed in"), this.offerToSaveCredential(e, t); - } catch (r) { - if (r instanceof Error && r.name === "RollbackDetectedError") { - this.pendingRollback = { kind: "login", loginName: e, password: t }, this.rollbackMessage = r.message, this.busy = !1, this.goto("rollback-confirm"); + const s = await this.worker.login({ loginName: e, password: t, acknowledgeRollback: a }); + this.loginName = e, this.session = { publicKey: s.everydayPublicKey, npub: d(s.everydayPublicKey), accountId: s.accountId }, this.sessionWarnings = [s.rollbackWarning, s.relayDisagreementWarning].filter((n) => !!n), this.busy = !1, this.noteSignerClaim(this.claimSigner()), this.dispatchEvent(new CustomEvent("bitlogin-login", { detail: { publicKey: s.everydayPublicKey } })), this.flashSuccess("dashboard", "Signed in"), this.offerToSaveCredential(e, t); + } catch (s) { + if (s instanceof Error && s.name === "RollbackDetectedError") { + this.pendingRollback = { kind: "login", loginName: e, password: t }, this.rollbackMessage = s.message, this.busy = !1, this.goto("rollback-confirm"); return; } - this.fail(r); + this.fail(s); } } async handleRollbackContinue() { @@ -952,18 +1281,18 @@ class F extends HTMLElement { } async handleRecoverNewCredentialsSubmit() { const e = this.field("newLoginName").trim().toLowerCase(); - if (!h(e)) { + if (!p(e)) { this.errorMessage = "Login name must be 3-32 characters: a-z, 0-9, '.', '_', '-', and not start/end with punctuation.", this.render(); return; } let t = this.newCredentialAfterRecovery; if (this.manualPasswordMode) { - const { password: s, error: r } = this.readManualPassword(e); - if (r) { - this.errorMessage = r, this.render(); + const { password: a, error: s } = this.readManualPassword(e); + if (s) { + this.errorMessage = s, this.render(); return; } - t = s; + t = a; } this.setBusy(!0), await this.worker.completeRecovery({ newLoginName: e, newPassword: t }), this.loginName = e, this.busy = !1, this.sessionWarnings = [], this.noteSignerClaim(this.claimSigner()), this.dispatchEvent(new CustomEvent("bitlogin-login", { detail: { publicKey: this.session?.publicKey } })), this.flashSuccess("dashboard", "Account recovered"), this.offerToSaveCredential(e, t); } @@ -971,36 +1300,36 @@ class F extends HTMLElement { const e = this.field("oldPassword"); let t = this.changePasswordNewCredential; if (this.manualPasswordMode) { - const { password: s, error: r } = this.readManualPassword(this.loginName); - if (r) { - this.errorMessage = r, this.render(); + const { password: a, error: s } = this.readManualPassword(this.loginName); + if (s) { + this.errorMessage = s, this.render(); return; } - t = s; + t = a; } await this.attemptChangePassword(e, t); } /** Shared by the rotation form and the "continue anyway" rollback-confirmation step; see attemptLogin. */ - async attemptChangePassword(e, t, s = !1) { + async attemptChangePassword(e, t, a = !1) { this.setBusy(!0); try { await this.worker.changePassword({ loginName: this.loginName, oldPassword: e, newPassword: t, - acknowledgeRollback: s + acknowledgeRollback: a }), this.busy = !1, this.sessionWarnings = [], this.noteSignerClaim(this.claimSigner()), this.flashSuccess("dashboard", "Password updated"), this.offerToSaveCredential(this.loginName, t); - } catch (r) { - if (r instanceof Error && r.name === "RollbackDetectedError") { - this.pendingRollback = { kind: "change-password", oldPassword: e, newPassword: t }, this.rollbackMessage = r.message, this.busy = !1, this.goto("rollback-confirm"); + } catch (s) { + if (s instanceof Error && s.name === "RollbackDetectedError") { + this.pendingRollback = { kind: "change-password", oldPassword: e, newPassword: t }, this.rollbackMessage = s.message, this.busy = !1, this.goto("rollback-confirm"); return; } - this.fail(r); + this.fail(s); } } async handleDownloadRecoveryExport() { - const e = await this.worker.buildRecoveryExport(), t = new Blob([JSON.stringify(e, null, 2)], { type: "application/json" }), s = URL.createObjectURL(t), r = document.createElement("a"); - r.href = s, r.download = "bitlogin-recovery-export.json", r.click(), URL.revokeObjectURL(s); + const e = await this.worker.buildRecoveryExport(), t = new Blob([JSON.stringify(e, null, 2)], { type: "application/json" }), a = URL.createObjectURL(t), s = document.createElement("a"); + s.href = a, s.download = "bitlogin-recovery-export.json", s.click(), URL.revokeObjectURL(a); } async handleSignTestEvent() { const e = await this.worker.signEvent({ kind: 1, content: `Hello from BitLogin at ${(/* @__PURE__ */ new Date()).toISOString()}` }); @@ -1222,15 +1551,98 @@ class F extends HTMLElement { return `

Signed in

${this.renderWarnings()} -

${this.session?.npub ?? ""}

+

${i(this.session?.npub ?? "")}

${this.renderError()} ${this.lastSignedEventJson ? `
${i(this.lastSignedEventJson)}
` : ""}
+ `; + case "vault-consent": { + const e = this.vaultRequest, t = this.vaultCandidate; + if (!e || !t) return '
No wallet request is in progress.
'; + const a = new Date(t.createdAt * 1e3).toLocaleDateString(); + return ` +

Share a wallet with ${i(e.appName)}?

+ ${e.reason ? `

Reason given: ${i(e.reason)}

` : ""} + ${this.renderError()} +
+ ${i(t.label)}
+ Connected ${i(a)} · wallet ${i((t.walletPubkey ?? "").slice(0, 10))}… +
+
${i(e.appName)} will receive this connection and can spend within the budget your wallet enforces, until you revoke it from Wallet connections.
+ + + + `; + } + case "vault-import": { + const e = this.vaultRequest; + if (!e) return '
No wallet request is in progress.
'; + const t = this.vaultUnsaved ? `
${this.vaultUnsavedReason === "no-vault" ? "This account predates the Connection Vault, so the connection will be handed to the app but not saved to your account. Enable the vault from your account manager (recovery phrase required) to make wallets portable." : "Sign in again to save connections to your account — until then the connection will be handed to the app but not saved."}
` : ""; + return ` +

Connect a wallet for ${i(e.appName)}

+ ${e.reason ? `

Reason given: ${i(e.reason)}

` : ""} + ${t} + ${this.renderError()} + +
+
+ + + + + + +
Set a spending budget on the wallet's own authorization page — the wallet is the only place a budget is actually enforced.
+ + `; + } + case "vault-offer": { + const e = this.vaultOffer; + return e ? ` +

Save this wallet to your BitLogin?

+

${i(e.appName)} just connected a wallet on this device. Saved to your BitLogin, the connection follows you — on a new device it's one tap instead of another paste.

+ ${this.renderError()} + + + + +
Stored encrypted on your account; ${i(e.appName)} keeps working either way. Remove it any time from Wallet connections.
+ ` : '
No wallet offer is in progress.
'; + } + case "vault-manage": { + const e = this.vaultConnections, t = e === null ? '

Loading…

' : e.length === 0 ? `

No connections stored yet. They're added when you connect a wallet inside an app.

` : e.map( + (a) => ` +
+ ${i(a.label)} (${i(a.connectionType)})
+ ${a.origin ? `Linked to ${i(a.origin)}` : "Not linked to an app"} +
+ ${a.origin ? `` : ""} + +
+
` + ).join(""); + return ` +

Wallet connections

+

Connections your apps use, stored encrypted on your account and restored on any device you sign in to.

+ ${this.renderError()} + ${t} +
"Remove from BitLogin" deletes the stored copy only — the connection itself keeps working for any app that already has it. To revoke spending authority, delete the connection inside your wallet app.
+ + `; + } case "rollback-confirm": return `

This looks like a stale or revoked credential

@@ -1278,30 +1690,30 @@ class F extends HTMLElement { } } } -function D(a, e) { - const t = Array.from({ length: a }, (r, n) => n), s = []; - for (let r = 0; r < e && t.length > 0; r++) { +function K(r, e) { + const t = Array.from({ length: r }, (s, n) => n), a = []; + for (let s = 0; s < e && t.length > 0; s++) { const n = Math.floor(Math.random() * t.length); - s.push(t.splice(n, 1)[0]); + a.push(t.splice(n, 1)[0]); } - return s.sort((r, n) => r - n); + return a.sort((s, n) => s - n); } -function i(a) { - return a.replace(/[&<>"']/gu, (e) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[e]); +function i(r) { + return r.replace(/[&<>"']/gu, (e) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[e]); } -customElements.get("bitlogin-auth") || customElements.define("bitlogin-auth", F); +customElements.get("bitlogin-auth") || customElements.define("bitlogin-auth", D); window.bitlogin = { version: "0.1.0", isActiveSigner() { return window.nostr?._bitlogin === !0; }, releaseSigner() { - const a = window; - return a.nostr?._bitlogin === !0 ? (delete a.nostr, window.dispatchEvent(new CustomEvent("bitlogin-signer-released")), !0) : !1; + const r = window; + return r.nostr?._bitlogin === !0 ? (delete r.nostr, window.dispatchEvent(new CustomEvent("bitlogin-signer-released")), !0) : !1; } }; export { - F as BitLoginAuthElement, - E as WorkerClient, - $ as createNip07Provider + D as BitLoginAuthElement, + N as WorkerClient, + B as createNip07Provider }; diff --git a/vendor/bitlogin/cryptoWorker.js b/vendor/bitlogin/cryptoWorker.js index 15aa1275..d0bb1baa 100644 --- a/vendor/bitlogin/cryptoWorker.js +++ b/vendor/bitlogin/cryptoWorker.js @@ -1,58 +1,61 @@ -import { v as le, g as x, s as Z, K as ln, c as un, b as vt, d as Be, f as Ge, h as he, u as ve, j as dn, k as yn, l as ae, m as de, n as Ve, S as He, o as We, q as Le, D as fe, t as Ne, w as pn, x as hn, y as vn, z as fn, A as Oe, B as at, C as ft, F as gn, G as wn, H as bn, I as Ke, J as gt, L as mn, M as kn, N as Fe, O as Ie, P as me, Q as En, T as wt, U as Pn, V as _n, W as Kn, X as bt, Y as ye, Z as Te, _ as mt, $ as xn, a0 as Rn, a1 as An, a2 as Cn, a as it, a3 as Sn } from "./bitlogin-shared-QIBe5Omw.js"; -class pe extends Error { +import { v as ie, g as _, s as ee, c as zn, K as Bn, b as jt, d as it, f as at, h as te, u as ue, j as Gn, k as Fn, l as H, m as J, n as ct, S as st, o as lt, q as $e, D as ke, t as We, w as ut, x as Hn, y as Jn, z as Yn, A as Qn, B as Ge, C as At, F as $t, G as Xn, H as Zn, I as er, J as Le, L as Wt, M as tr, N as nr, O as dt, P as ze, Q as Ce, T as rr, U as zt, V as or, W as ir, X as xe, Y as ge, Z as ar, _ as we, $ as _e, a0 as Bt, a1 as yt, a2 as cr, a3 as Gt, a4 as Ft, a5 as sr, a6 as lr, a as Ct, a7 as ur } from "./bitlogin-shared-B2Rc9khL.js"; +class be extends Error { reason; constructor(t) { super("Account not found or credentials incorrect."), this.name = "AccountNotFoundError", this.reason = t; } } -class ie extends Error { +class ye extends Error { constructor(t) { super(t), this.name = "RegistrationFailedError"; } } -class kt extends Error { +class Ht extends Error { constructor(t = "An account already exists with this login name and password. Sign in instead, or choose different credentials.") { super(t), this.name = "AccountAlreadyExistsError"; } } -class Et extends Error { +class Me extends Error { constructor(t) { super(t), this.name = "RecoveryFailedError"; } } -class Pt extends Error { +class Jt extends Error { seenGeneration; capsuleGeneration; constructor(t, n) { super(`This credential capsule reports generation ${n}, but this device has already seen generation ${t}. Refusing to log in with older, possibly-revoked credentials.`), this.name = "RollbackDetectedError", this.seenGeneration = t, this.capsuleGeneration = n; } } -function _t(e, t) { +function ht(e, t) { const n = t ?? Math.floor(Date.now() / 1e3); return e == null ? n : Math.max(n, e + 1); } -const Ln = { generation: -1, recoveryGeneration: -1 }; -function Kt(e) { +const dr = { generation: -1, recoveryGeneration: -1 }; +function pt(e) { return `bitlogin:hwm:${e}`; } -async function Je(e, t) { - const n = await e.get(Kt(t)); - return n ? JSON.parse(n) : Ln; +async function vt(e, t) { + const n = await e.get(pt(t)); + return n ? JSON.parse(n) : dr; } -async function xt(e, t, n) { - const r = await Je(e, t), o = { +async function Yt(e, t, n) { + const r = await vt(e, t), o = { generation: Math.max(r.generation, n.generation ?? -1), recoveryGeneration: Math.max(r.recoveryGeneration, n.recoveryGeneration ?? -1) }; - return await e.set(Kt(t), JSON.stringify(o)), o; + return await e.set(pt(t), JSON.stringify(o)), o; } -function Nn() { +async function yr(e, t, n = { generation: 0, recoveryGeneration: -1 }) { + await e.set(pt(t), JSON.stringify(n)); +} +function hr() { const e = globalThis.WebSocket; if (!e) throw new Error("No global WebSocket implementation is available in this environment."); return e; } -class In { +class pr { url; ws = null; connectPromise = null; @@ -66,19 +69,19 @@ class In { } async connect() { return this.connectPromise ? this.connectPromise : (this.connectPromise = new Promise((t, n) => { - const r = Nn(), o = new r(this.url); + const r = hr(), o = new r(this.url); this.ws = o; - const a = setTimeout(() => { + const i = setTimeout(() => { n(new Error(`Timed out connecting to relay ${this.url}`)); }, this.connectTimeoutMs); o.addEventListener("open", () => { - clearTimeout(a), t(); + clearTimeout(i), t(); }), o.addEventListener("error", () => { - clearTimeout(a), n(new Error(`WebSocket error connecting to relay ${this.url}`)); + clearTimeout(i), n(new Error(`WebSocket error connecting to relay ${this.url}`)); }), o.addEventListener("close", () => { this.connectPromise = null; - }), o.addEventListener("message", (i) => { - this.handleMessage(String(i.data)); + }), o.addEventListener("message", (a) => { + this.handleMessage(String(a.data)); }); }), this.connectPromise); } @@ -101,33 +104,33 @@ class In { return; const [r, ...o] = n; if (r === "EVENT") { - const [a, i] = o, s = this.subs.get(a); - s && le(i) && s.events.push(i); + const [i, a] = o, c = this.subs.get(i); + c && ie(a) && c.events.push(a); return; } if (r === "EOSE") { - const [a] = o; - this.subs.get(a)?.onEose(); + const [i] = o; + this.subs.get(i)?.onEose(); return; } if (r === "OK") { - const [a, i, s] = o; - this.pendingPublishes.get(a)?.({ ok: i, message: s ?? "" }), this.pendingPublishes.delete(a); + const [i, a, c] = o; + this.pendingPublishes.get(i)?.({ ok: a, message: c ?? "" }), this.pendingPublishes.delete(i); return; } if (r === "AUTH") { - const [a] = o; - this.respondToAuthChallenge(a); + const [i] = o; + this.respondToAuthChallenge(i); return; } } async respondToAuthChallenge(t) { if (!this.authPrivateKey) return; - const n = x(this.authPrivateKey), r = Z({ + const n = _(this.authPrivateKey), r = ee({ pubkey: n, created_at: Math.floor(Date.now() / 1e3), - kind: ln, + kind: Bn, tags: [ ["relay", this.url], ["challenge", t] @@ -144,63 +147,63 @@ class In { const o = setTimeout(() => { this.pendingPublishes.delete(t.id), r({ ok: !1, message: "timeout: no OK received from relay" }); }, n); - this.pendingPublishes.set(t.id, (a) => { - clearTimeout(o), r(a); + this.pendingPublishes.set(t.id, (i) => { + clearTimeout(o), r(i); }), this.send(["EVENT", t]); }); } async queryOnce(t, n = 8e3) { await this.connect(); - const r = un({ + const r = zn({ pubkey: "0".repeat(64), created_at: Date.now(), kind: 0, tags: [], content: JSON.stringify(t) + Math.random() }).slice(0, 16); - return new Promise((o) => { - const a = [], i = () => { - clearTimeout(s), this.subs.delete(r), this.send(["CLOSE", r]), o(a); - }, s = setTimeout(i, n); - this.subs.set(r, { events: a, onEose: i }), this.send(["REQ", r, t]); + return new Promise((o, i) => { + const a = [], c = (l) => { + clearTimeout(s), this.subs.delete(r), this.send(["CLOSE", r]), l ? i(l) : o(a); + }, s = setTimeout(() => c(new Error("relay did not answer the subscription before the timeout")), n); + this.subs.set(r, { events: a, onEose: () => c() }), this.send(["REQ", r, t]); }); } } -class I { +class C { connections = /* @__PURE__ */ new Map(); constructor(t, n = {}) { for (const r of new Set(t)) - this.connections.set(r, new In(r, n)); + this.connections.set(r, new pr(r, n)); } get relayUrls() { return [...this.connections.keys()]; } /** Queries every configured relay and waits for a quorum of responses (or all timeouts) before returning (§16.2). */ async queryQuorum(t, n = 8e3) { - const r = [...this.connections.entries()], o = await Promise.all(r.map(async ([s, c]) => { + const r = [...this.connections.entries()], o = await Promise.all(r.map(async ([c, s]) => { try { - const l = await c.queryOnce(t, n); - return { relayUrl: s, events: l, responded: !0 }; + const l = await s.queryOnce(t, n); + return { relayUrl: c, events: l, responded: !0 }; } catch (l) { - return { relayUrl: s, events: [], responded: !1, error: l.message }; + return { relayUrl: c, events: [], responded: !1, error: l.message }; } - })), a = o.filter((s) => s.responded).length, i = o.length; + })), i = o.filter((c) => c.responded).length, a = o.length; return { outcomes: o, - quorumMet: a >= Math.ceil(i / 2), - respondedCount: a, - totalCount: i + quorumMet: i >= Math.ceil(a / 2), + respondedCount: i, + totalCount: a }; } /** Publishes an event to every configured relay, best-effort (§15.6, §24.4). */ async publishAll(t, n = 8e3) { const r = [...this.connections.entries()]; - return Promise.all(r.map(async ([o, a]) => { + return Promise.all(r.map(async ([o, i]) => { try { - const i = await a.publish(t, n); - return { relayUrl: o, result: i }; - } catch (i) { - return { relayUrl: o, result: { ok: !1, message: i.message } }; + const a = await i.publish(t, n); + return { relayUrl: o, result: a }; + } catch (a) { + return { relayUrl: o, result: { ok: !1, message: a.message } }; } })); } @@ -209,308 +212,349 @@ class I { t.close(); } } -function ne(e) { +function se(e) { return e.filter((t) => t.result.ok).length; } -function Tn(e, t, n) { - return Z({ pubkey: x(e), created_at: n, kind: vt, tags: [], content: JSON.stringify(t) }, e); +function vr(e, t, n) { + return ee({ pubkey: _(e), created_at: n, kind: jt, tags: [], content: JSON.stringify(t) }, e); } -function On(e, t, n) { +function fr(e, t, n) { const r = t.map((o) => { - const a = ["r", o.url]; - return o.read && !o.write && a.push("read"), o.write && !o.read && a.push("write"), a; + const i = ["r", o.url]; + return o.read && !o.write && i.push("read"), o.write && !o.read && i.push("write"), i; }); - return Z({ pubkey: x(e), created_at: n, kind: Be, tags: r, content: "" }, e); + return ee({ pubkey: _(e), created_at: n, kind: it, tags: r, content: "" }, e); } -function Mn(e, t, n) { - return Z({ - pubkey: x(e), +function gr(e, t, n) { + return ee({ + pubkey: _(e), created_at: n, - kind: Ge, + kind: at, tags: t.map((r) => ["relay", r]), content: "" }, e); } -function Un(e) { +function wr(e) { return e.tags.filter((t) => t[0] === "r" && t[1]).map((t) => t[1]); } -function Dn(e) { +function br(e) { return e.tags.filter((t) => t[0] === "relay" && t[1]).map((t) => t[1]); } -async function qn(e) { - const t = x(e.everydayPrivateKey), n = Math.floor(Date.now() / 1e3), r = [.../* @__PURE__ */ new Set([...e.generalRelays, ...e.dmRelays, ...e.discoveryRelays])], o = new I(r), [a, i, s] = await Promise.all([ - o.queryQuorum({ authors: [t], kinds: [vt] }), - o.queryQuorum({ authors: [t], kinds: [Be] }), - o.queryQuorum({ authors: [t], kinds: [Ge] }) +async function mr(e) { + const t = _(e.everydayPrivateKey), n = Math.floor(Date.now() / 1e3), r = [.../* @__PURE__ */ new Set([...e.generalRelays, ...e.dmRelays, ...e.discoveryRelays])], o = new C(r), [i, a, c] = await Promise.all([ + o.queryQuorum({ authors: [t], kinds: [jt] }), + o.queryQuorum({ authors: [t], kinds: [it] }), + o.queryQuorum({ authors: [t], kinds: [at] }) ]); o.closeAll(); - const c = a.outcomes.some((h) => h.events.length > 0), l = i.outcomes.some((h) => h.events.length > 0), u = s.outcomes.some((h) => h.events.length > 0), d = new I(r); - let g = null, w = null, v = null; + const s = i.outcomes.some((p) => p.events.length > 0), l = a.outcomes.some((p) => p.events.length > 0), u = c.outcomes.some((p) => p.events.length > 0), y = new C(r); + let v = null, w = null, g = null; const f = []; - if (!c && (e.name || e.about || e.picture)) { - const h = Tn(e.everydayPrivateKey, { name: e.name, about: e.about, picture: e.picture }, n); - f.push(d.publishAll(h).then((p) => void (g = p))); + if (!s && (e.name || e.about || e.picture)) { + const p = vr(e.everydayPrivateKey, { name: e.name, about: e.about, picture: e.picture }, n); + f.push(y.publishAll(p).then((h) => void (v = h))); } if (!l) { - const h = On(e.everydayPrivateKey, e.generalRelays.map((p) => ({ url: p, read: !0, write: !0 })), n); - f.push(d.publishAll(h).then((p) => void (w = p))); + const p = fr(e.everydayPrivateKey, e.generalRelays.map((h) => ({ url: h, read: !0, write: !0 })), n); + f.push(y.publishAll(p).then((h) => void (w = h))); } if (!u) { - const h = Mn(e.everydayPrivateKey, e.dmRelays, n); - f.push(d.publishAll(h).then((p) => void (v = p))); + const p = gr(e.everydayPrivateKey, e.dmRelays, n); + f.push(y.publishAll(p).then((h) => void (g = h))); } - return await Promise.all(f), d.closeAll(), { - profilePublished: g !== null && ne(g) > 0, - relayListAcknowledgedCount: w !== null ? ne(w) : 0, - dmRelayListAcknowledgedCount: v !== null ? ne(v) : 0, - profileSkippedExisting: c, + return await Promise.all(f), y.closeAll(), { + profilePublished: v !== null && se(v) > 0, + relayListAcknowledgedCount: w !== null ? se(w) : 0, + dmRelayListAcknowledgedCount: g !== null ? se(g) : 0, + profileSkippedExisting: s, relayListSkippedExisting: l, dmRelayListSkippedExisting: u }; } -async function ke(e, t, n) { - const r = n.minAcks ?? 2, o = n.minReadbacks ?? 2, a = await e.publishAll(t, n.timeoutMs), i = ne(a), c = (await e.queryQuorum({ kinds: [he], authors: [t.pubkey], "#d": [n.dTag], limit: 5 }, n.timeoutMs)).outcomes.filter((l) => l.events.some((u) => u.id === t.id)).length; +async function me(e, t, n) { + const r = n.minAcks ?? 2, o = n.minReadbacks ?? 2, i = await e.publishAll(t, n.timeoutMs), a = se(i), s = (await e.queryQuorum({ kinds: [te], authors: [t.pubkey], "#d": [n.dTag], limit: 5 }, n.timeoutMs)).outcomes.filter((l) => l.events.some((u) => u.id === t.id)).length; return { - acknowledgedCount: i, - readbackVerifiedCount: c, - success: i >= r && c >= o + acknowledgedCount: a, + readbackVerifiedCount: s, + success: a >= r && s >= o }; } -function jn(e) { - const t = dn(e); +function kr(e) { + const t = Gn(e); if (t === void 0) throw new Error("Value is not JSON-serializable for canonicalization."); return t; } -function zn(e) { - return ve(jn(e)); +function _r(e) { + return ue(kr(e)); } -const Ae = [1024, 2048, 4096], oe = 4; -function $n(e) { - const t = oe + e.length, n = Ae.find((a) => a >= t); +const De = [1024, 2048, 4096], de = 4; +function Er(e) { + const t = de + e.length, n = De.find((i) => i >= t); if (n === void 0) - throw new Error(`Payload of ${e.length} bytes exceeds the largest padding bucket (${Ae[Ae.length - 1]} bytes minus ${oe}-byte length prefix).`); + throw new Error(`Payload of ${e.length} bytes exceeds the largest padding bucket (${De[De.length - 1]} bytes minus ${de}-byte length prefix).`); const r = new Uint8Array(n); - return new DataView(r.buffer).setUint32(0, e.length, !1), r.set(e, oe), r; + return new DataView(r.buffer).setUint32(0, e.length, !1), r.set(e, de), r; } -function Bn(e) { - if (!Ae.includes(e.length)) +function Pr(e) { + if (!De.includes(e.length)) throw new Error(`Padded plaintext length ${e.length} does not match a known bucket.`); const n = new DataView(e.buffer, e.byteOffset, e.byteLength).getUint32(0, !1); - if (n > e.length - oe) + if (n > e.length - de) throw new Error("Declared payload length exceeds the padded bucket size."); - const r = e.slice(oe, oe + n), o = e.slice(oe + n); - for (const a of o) - if (a !== 0) + const r = e.slice(de, de + n), o = e.slice(de + n); + for (const i of o) + if (i !== 0) throw new Error("Padding bytes are not all zero; capsule plaintext is malformed."); return r; } -function Ye() { +function ft() { const e = globalThis.crypto; if (!e || !e.subtle) throw new Error("WebCrypto SubtleCrypto is not available in this environment."); return e; } -async function Rt(e) { +async function Qt(e) { if (e.length !== 32) throw new Error("AES-256-GCM key must be exactly 32 bytes."); - return Ye().subtle.importKey("raw", e, "AES-GCM", !1, ["encrypt", "decrypt"]); + return ft().subtle.importKey("raw", e, "AES-GCM", !1, ["encrypt", "decrypt"]); } -async function Gn(e, t, n) { - const r = yn(), o = await Rt(e), a = await Ye().subtle.encrypt({ name: "AES-GCM", iv: r, additionalData: n, tagLength: 128 }, o, t); - return { nonce: r, ciphertext: new Uint8Array(a) }; +async function Kr(e, t, n) { + const r = Fn(), o = await Qt(e), i = await ft().subtle.encrypt({ name: "AES-GCM", iv: r, additionalData: n, tagLength: 128 }, o, t); + return { nonce: r, ciphertext: new Uint8Array(i) }; } -async function Vn(e, t, n, r) { - const o = await Rt(e); +async function Rr(e, t, n, r) { + const o = await Qt(e); try { - const a = await Ye().subtle.decrypt({ name: "AES-GCM", iv: t, additionalData: r, tagLength: 128 }, o, n); - return new Uint8Array(a); + const i = await ft().subtle.decrypt({ name: "AES-GCM", iv: t, additionalData: r, tagLength: 128 }, o, n); + return new Uint8Array(i); } catch { throw new Error("AES-256-GCM authentication failed: capsule is corrupted, tampered, or the wrong key was used."); } } -function At(e) { - return ve(`bitlogin|password-capsule|v1|${e}|30078|bitlogin:password:v1`); +function Xt(e) { + return ue(`bitlogin|password-capsule|v1|${e}|30078|bitlogin:password:v1`); } -function Ct(e) { - return ve(`bitlogin|recovery-capsule|v1|${e}|30078|bitlogin:recovery:v1`); +function Zt(e) { + return ue(`bitlogin|recovery-capsule|v1|${e}|30078|bitlogin:recovery:v1`); } -async function St(e, t, n) { - const r = zn(e), o = $n(r), a = await Gn(t, o, n); +async function gt(e, t, n) { + const r = _r(e), o = Er(r), i = await Kr(t, o, n); return { version: 1, algorithm: "aes-256-gcm", - nonce: ae(a.nonce), - ciphertext: ae(a.ciphertext) + nonce: H(i.nonce), + ciphertext: H(i.ciphertext) }; } -async function Lt(e, t, n) { +async function wt(e, t, n) { if (e.version !== 1 || e.algorithm !== "aes-256-gcm") throw new Error(`Unsupported capsule envelope version/algorithm: ${e.version}/${e.algorithm}`); - const r = de(e.nonce), o = de(e.ciphertext), a = await Vn(t, r, o, n), i = Bn(a); - return JSON.parse(Ve(i)); + const r = J(e.nonce), o = J(e.ciphertext), i = await Rr(t, r, o, n), a = Pr(i); + return JSON.parse(ct(a)); } -class Qe extends Error { +class Be extends Error { constructor(t) { super(t), this.name = "CapsuleValidationError"; } } -const Hn = /* @__PURE__ */ new Set(["wss:", "ws:"]), Wn = 1e6, Fn = /^[0-9a-f]{64}$/u; -function R(e, t) { +const Ar = /* @__PURE__ */ new Set(["wss:", "ws:"]), Cr = 1e6, xr = /^[0-9a-f]{64}$/u; +function P(e, t) { if (!e) - throw new Qe(t); + throw new Be(t); } -function Ce(e) { - return typeof e == "string" && Fn.test(e); +function qe(e) { + return typeof e == "string" && xr.test(e); } -function Nt(e) { - R(Array.isArray(e), "vault_relay_hints must be an array (§12.4.7)."); +function en(e) { + P(Array.isArray(e), "vault_relay_hints must be an array (§12.4.7)."); for (const t of e) { - R(typeof t == "string", "Each relay hint must be a string (§12.4.7)."); + P(typeof t == "string", "Each relay hint must be a string (§12.4.7)."); let n; try { n = new URL(t); } catch { - throw new Qe(`Invalid relay URL: ${String(t)} (§12.4.7)`); + throw new Be(`Invalid relay URL: ${String(t)} (§12.4.7)`); } - R(Hn.has(n.protocol), `Relay URL uses a disallowed scheme: ${t} (§12.4.7)`); + P(Ar.has(n.protocol), `Relay URL uses a disallowed scheme: ${t} (§12.4.7)`); } } -function It(e) { - R(typeof e == "string", "account_id must be a string (§12.4.2)."); +function tn(e) { + P(typeof e == "string", "account_id must be a string (§12.4.2)."); let t; try { - t = de(e); + t = J(e); } catch { - throw new Qe("account_id is not valid base64url (§12.4.2)."); + throw new Be("account_id is not valid base64url (§12.4.2)."); } - R(t.length === 16, "account_id must decode to exactly 128 bits (§12.4.2)."); + P(t.length === 16, "account_id must decode to exactly 128 bits (§12.4.2)."); } -function Tt(e, t) { - R(typeof e == "string", "operational_private_key must be a string (§12.4.3)."); - const n = de(e); - R(n.length === 32, "operational_private_key must be exactly 32 bytes (§12.4.3)."), R(We(n), "operational_private_key is not a valid secp256k1 scalar (§12.4.3)."), R(Ce(t), "operational_public_key must be lowercase 64-char hex (§12.4.4)."); - const r = x(n); - R(r === t, "operational_public_key does not match the derived public key (§12.4.4)."); +function nn(e, t) { + P(typeof e == "string", "operational_private_key must be a string (§12.4.3)."); + const n = J(e); + P(n.length === 32, "operational_private_key must be exactly 32 bytes (§12.4.3)."), P(lt(n), "operational_private_key is not a valid secp256k1 scalar (§12.4.3)."), P(qe(t), "operational_public_key must be lowercase 64-char hex (§12.4.4)."); + const r = _(n); + P(r === t, "operational_public_key does not match the derived public key (§12.4.4)."); } -function Ot(e, t) { - R(Number.isInteger(e) && e >= 0 && e <= Wn, `${t} is out of supported bounds (§12.4.8).`); +function rn(e) { + const t = e.connection_vault_root, n = e.vault_sudo_key; + if (!(t === void 0 && n === void 0)) { + P(t !== void 0 && n !== void 0, "connection_vault_root and vault_sudo_key must appear together (§CV5.2)."); + for (const [r, o] of [ + ["connection_vault_root", t], + ["vault_sudo_key", n] + ]) { + P(typeof o == "string", `${r} must be a string (§CV5.2).`); + let i; + try { + i = J(o); + } catch { + throw new Be(`${r} is not valid base64url (§CV5.2).`); + } + P(i.length === 32, `${r} must decode to exactly 32 bytes (§CV5.2).`); + } + } } -function Jn(e) { - R(e.schema === Le, `Unsupported or unknown schema: ${String(e.schema)} (§12.4.1)`), It(e.account_id), Ot(e.generation, "generation"), Tt(e.operational_private_key, e.operational_public_key), R(Ce(e.recovery_public_key), "recovery_public_key must be lowercase 64-char hex (§12.4.5)."), Nt(e.vault_relay_hints); +function on(e, t) { + P(Number.isInteger(e) && e >= 0 && e <= Cr, `${t} is out of supported bounds (§12.4.8).`); +} +function Sr(e) { + P(e.schema === $e, `Unsupported or unknown schema: ${String(e.schema)} (§12.4.1)`), tn(e.account_id), on(e.generation, "generation"), nn(e.operational_private_key, e.operational_public_key), P(qe(e.recovery_public_key), "recovery_public_key must be lowercase 64-char hex (§12.4.5)."), en(e.vault_relay_hints), rn(e); const t = e.recovery_capsule_event; - R(!!t && typeof t == "object", "recovery_capsule_event must be present (§12.4.6)."), R(le(t), "Embedded recovery_capsule_event has an invalid event id or signature (§12.4.6)."), R(t.pubkey === e.recovery_public_key, "Embedded recovery_capsule_event author does not match recovery_public_key (§12.4.5)."); + P(!!t && typeof t == "object", "recovery_capsule_event must be present (§12.4.6)."), P(ie(t), "Embedded recovery_capsule_event has an invalid event id or signature (§12.4.6)."), P(t.pubkey === e.recovery_public_key, "Embedded recovery_capsule_event author does not match recovery_public_key (§12.4.5)."); } -function Yn(e) { - R(e.schema === He, `Unsupported or unknown schema: ${String(e.schema)} (§12.4.1)`), It(e.account_id), Ot(e.recovery_generation, "recovery_generation"), R(e.previous_recovery_event_id === null || Ce(e.previous_recovery_event_id), "previous_recovery_event_id must be null or lowercase 64-char hex (§12.3)."), Tt(e.operational_private_key, e.operational_public_key), R(Ce(e.recovery_public_key), "recovery_public_key must be lowercase 64-char hex."), Nt(e.vault_relay_hints); +function Nr(e) { + P(e.schema === st, `Unsupported or unknown schema: ${String(e.schema)} (§12.4.1)`), tn(e.account_id), on(e.recovery_generation, "recovery_generation"), P(e.previous_recovery_event_id === null || qe(e.previous_recovery_event_id), "previous_recovery_event_id must be null or lowercase 64-char hex (§12.3)."), nn(e.operational_private_key, e.operational_public_key), P(qe(e.recovery_public_key), "recovery_public_key must be lowercase 64-char hex."), en(e.vault_relay_hints), rn(e); } -function Qn(e) { - const t = new Map(e.map((r) => [r.recoveryGeneration, r])), n = [...e].sort((r, o) => r.recoveryGeneration - o.recoveryGeneration); - for (let r = 1; r < n.length; r++) { - const o = n[r], a = t.get(o.recoveryGeneration - 1); - if (o.previousRecoveryEventId === null) - return { consistent: !1, warning: `Generation ${o.recoveryGeneration} has a null previous-event link but is not the first generation.` }; - if (a && o.previousRecoveryEventId !== a.eventId) +function Ir(e) { + const t = /* @__PURE__ */ new Map(); + for (const r of e) { + const o = t.get(r.recoveryGeneration); + if (o && o.eventId !== r.eventId) return { consistent: !1, - warning: `Recovery generation chain is broken between generation ${a.recoveryGeneration} and ${o.recoveryGeneration}: possible replay or relay misbehavior.` + warning: `Two different recovery capsules both claim generation ${r.recoveryGeneration}: possible fork, replay, or relay misbehavior.` + }; + t.set(r.recoveryGeneration, r); + } + const n = [...e].sort((r, o) => r.recoveryGeneration - o.recoveryGeneration); + for (let r = 1; r < n.length; r++) { + const o = n[r]; + if (o.previousRecoveryEventId === null) + return { + consistent: !1, + warning: `Generation ${o.recoveryGeneration} has a null previous-event link but is not the first generation.` + }; + const i = t.get(o.recoveryGeneration - 1); + if (!i) + return { + consistent: !1, + warning: `Recovery generation ${o.recoveryGeneration - 1} is missing, so the chain up to generation ${o.recoveryGeneration} cannot be verified.` + }; + if (o.previousRecoveryEventId !== i.eventId) + return { + consistent: !1, + warning: `Recovery generation chain is broken between generation ${o.recoveryGeneration - 1} and ${o.recoveryGeneration}: possible replay or relay misbehavior.` }; } return { consistent: !0 }; } -async function Xe(e) { - const t = x(e.locatorPrivateKey), n = await St(e.payload, e.capsuleKey, At(t)); - return Z({ +async function bt(e) { + const t = _(e.locatorPrivateKey), n = await gt(e.payload, e.capsuleKey, Xt(t)); + return ee({ pubkey: t, created_at: e.payload.created_at, - kind: he, - tags: [["d", fe]], + kind: te, + tags: [["d", ke]], content: JSON.stringify(n) }, e.locatorPrivateKey); } -function Xn(e) { - const t = x(e.oldLocatorPrivateKey); - return Z({ +function Tr(e) { + const t = _(e.oldLocatorPrivateKey); + return ee({ pubkey: t, created_at: e.createdAt, - kind: he, - tags: [["d", fe]], + kind: te, + tags: [["d", ke]], content: "" }, e.oldLocatorPrivateKey); } -async function Zn(e, t) { - if (!le(e)) +async function Lr(e, t) { + if (!ie(e)) throw new Error("Credential capsule event has an invalid id or signature."); - const n = JSON.parse(e.content), r = await Lt(n, t, At(e.pubkey)); - return Jn(r), r; + const n = JSON.parse(e.content), r = await wt(n, t, Xt(e.pubkey)); + return Sr(r), r; } -async function Mt(e) { - const t = x(e.recoveryPrivateKey), n = await St(e.payload, e.capsuleKey, Ct(t)); - return Z({ +async function an(e) { + const t = _(e.recoveryPrivateKey), n = await gt(e.payload, e.capsuleKey, Zt(t)); + return ee({ pubkey: t, created_at: e.payload.created_at, - kind: he, - tags: [["d", Ne]], + kind: te, + tags: [["d", We]], content: JSON.stringify(n) }, e.recoveryPrivateKey); } -async function Ut(e, t) { - if (!le(e)) +async function cn(e, t) { + if (!ie(e)) throw new Error("Recovery capsule event has an invalid id or signature."); - const n = JSON.parse(e.content), r = await Lt(n, t, Ct(e.pubkey)); - return Yn(r), r; + const n = JSON.parse(e.content), r = await wt(n, t, Zt(e.pubkey)); + return Nr(r), r; } -function er(e) { - const t = /* @__PURE__ */ new Map(); - for (const n of e) - le(n) && t.set(n.id, n); - return [...t.values()].sort((n, r) => r.created_at - n.created_at); +function xt(e, t, n) { + const r = /* @__PURE__ */ new Map(); + for (const o of e) + o.pubkey === t && o.kind === te && ut(o, "d") === n && ie(o) && r.set(o.id, o); + return [...r.values()].sort((o, i) => i.created_at - o.created_at); } -async function Dt(e, t, n, r, o) { - const a = await e.queryQuorum({ kinds: [he], authors: [t], "#d": [n], limit: 5 }, o), i = a.outcomes.flatMap((g) => g.events), s = er(i), c = []; - for (const g of s) +async function sn(e, t, n, r, o) { + const i = await e.queryQuorum({ kinds: [te], authors: [t], "#d": [n], limit: 5 }, o), a = i.outcomes.flatMap((v) => v.events), c = xt(a, t, n), s = []; + for (const v of c) try { - const w = await r(g); - c.push({ event: g, payload: w }); + const w = await r(v); + s.push({ event: v, payload: w }); } catch (w) { - c.push({ event: g, payload: null, error: w.message }); + s.push({ event: v, payload: null, error: w.message }); } - const l = c.find((g) => g.payload !== null) ?? null, u = a.outcomes.filter((g) => g.responded && g.events.length > 0).map((g) => g.events.slice().sort((w, v) => v.created_at - w.created_at)[0].id), d = new Set(u).size > 1; + const l = s.find((v) => v.payload !== null) ?? null, u = i.outcomes.map((v) => ({ + responded: v.responded, + events: xt(v.events, t, n) + })).filter((v) => v.responded && v.events.length > 0).map((v) => v.events[0].id), y = new Set(u).size > 1; return { - quorumMet: a.quorumMet, - respondedCount: a.respondedCount, - totalCount: a.totalCount, - candidates: c, + quorumMet: i.quorumMet, + respondedCount: i.respondedCount, + totalCount: i.totalCount, + candidates: s, best: l, - relayDisagreement: d + relayDisagreement: y }; } async function Se(e, t, n, r = 8e3) { - return Dt(e, t, fe, (o) => Zn(o, n), r); + return sn(e, t, ke, (o) => Lr(o, n), r); } -async function tr(e, t, n, r = 8e3) { - return Dt(e, t, Ne, (o) => Ut(o, n), r); +async function Ur(e, t, n, r = 8e3) { + return sn(e, t, We, (o) => cn(o, n), r); } -function nr(e) { +function Or(e) { const t = e.filter((n) => n.payload !== null); - return t.length < 2 ? { consistent: !0 } : Qn(t.map((n) => ({ + return t.length < 2 ? { consistent: !0 } : Ir(t.map((n) => ({ eventId: n.event.id, recoveryGeneration: n.payload.recovery_generation, previousRecoveryEventId: n.payload.previous_recovery_event_id }))); } -async function rr(e, t, n, r) { - const [o, a] = await Promise.all([ +async function Mr(e, t, n, r) { + const [o, i] = await Promise.all([ e.publishAll(t, r), e.publishAll(n, r) ]); return { - credentialAcknowledgedCount: ne(o), - recoveryAcknowledgedCount: ne(a), + credentialAcknowledgedCount: se(o), + recoveryAcknowledgedCount: se(i), relaysTried: e.relayUrls.length }; } -const qt = `abandon +const ln = `abandon ability able about @@ -2559,192 +2603,198 @@ zero zone zoo`.split(` `); -function or(e, t, n, r) { - vn(e); - const o = fn({ dkLen: 32, asyncTick: 10 }, r), { c: a, dkLen: i, asyncTick: s } = o; - if (Oe(a), Oe(i), Oe(s), a < 1) +function Dr(e, t, n, r) { + Yn(e); + const o = Qn({ dkLen: 32, asyncTick: 10 }, r), { c: i, dkLen: a, asyncTick: c } = o; + if (Ge(i), Ge(a), Ge(c), i < 1) throw new Error("iterations (c) should be >= 1"); - const c = at(t), l = at(n), u = new Uint8Array(i), d = ft.create(e, c), g = d._cloneInto().update(l); - return { c: a, dkLen: i, asyncTick: s, DK: u, PRF: d, PRFSalt: g }; + const s = At(t), l = At(n), u = new Uint8Array(a), y = $t.create(e, s), v = y._cloneInto().update(l); + return { c: i, dkLen: a, asyncTick: c, DK: u, PRF: y, PRFSalt: v }; } -function ar(e, t, n, r, o) { - return e.destroy(), t.destroy(), r && r.destroy(), gn(o), n; +function Vr(e, t, n, r, o) { + return e.destroy(), t.destroy(), r && r.destroy(), Xn(o), n; } -async function ir(e, t, n, r) { - const { c: o, dkLen: a, asyncTick: i, DK: s, PRF: c, PRFSalt: l } = or(e, t, n, r); +async function qr(e, t, n, r) { + const { c: o, dkLen: i, asyncTick: a, DK: c, PRF: s, PRFSalt: l } = Dr(e, t, n, r); let u; - const d = new Uint8Array(4), g = pn(d), w = new Uint8Array(c.outputLen); - for (let v = 1, f = 0; f < a; v++, f += c.outputLen) { - const h = s.subarray(f, f + c.outputLen); - g.setInt32(0, v, !1), (u = l._cloneInto(u)).update(d).digestInto(w), h.set(w.subarray(0, h.length)), await hn(o - 1, i, () => { - c._cloneInto(u).update(w).digestInto(w); - for (let p = 0; p < h.length; p++) - h[p] ^= w[p]; + const y = new Uint8Array(4), v = Hn(y), w = new Uint8Array(s.outputLen); + for (let g = 1, f = 0; f < i; g++, f += s.outputLen) { + const p = c.subarray(f, f + s.outputLen); + v.setInt32(0, g, !1), (u = l._cloneInto(u)).update(y).digestInto(w), p.set(w.subarray(0, p.length)), await Jn(o - 1, a, () => { + s._cloneInto(u).update(w).digestInto(w); + for (let h = 0; h < p.length; h++) + p[h] ^= w[h]; }); } - return ar(c, l, s, u, w); + return Vr(s, l, c, u, w); } /*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */ -const sr = (e) => e[0] === "あいこくしん"; -function jt(e) { +const jr = (e) => e[0] === "あいこくしん"; +function un(e) { if (typeof e != "string") throw new TypeError("invalid mnemonic type: " + typeof e); return e.normalize("NFKD"); } -function zt(e) { - const t = jt(e), n = t.split(" "); +function dn(e) { + const t = un(e), n = t.split(" "); if (![12, 15, 18, 21, 24].includes(n.length)) throw new Error("Invalid mnemonic"); return { nfkd: t, words: n }; } -function $t(e) { - bn(e, 16, 20, 24, 28, 32); +function yn(e) { + er(e, 16, 20, 24, 28, 32); } -const cr = (e) => { +const $r = (e) => { const t = 8 - e.length / 4; - return new Uint8Array([gt(e)[0] >> t << t]); + return new Uint8Array([Wt(e)[0] >> t << t]); }; -function Bt(e) { +function hn(e) { if (!Array.isArray(e) || e.length !== 2048 || typeof e[0] != "string") throw new Error("Wordlist: expected array of 2048 strings"); return e.forEach((t) => { if (typeof t != "string") throw new Error("wordlist: non-string element: " + t); - }), Ke.chain(Ke.checksum(1, cr), Ke.radix2(11, !0), Ke.alphabet(e)); + }), Le.chain(Le.checksum(1, $r), Le.radix2(11, !0), Le.alphabet(e)); } -function lr(e, t) { - const { words: n } = zt(e), r = Bt(t).decode(n); - return $t(r), r; +function Wr(e, t) { + const { words: n } = dn(e), r = hn(t).decode(n); + return yn(r), r; } -function ur(e, t) { - return $t(e), Bt(t).encode(e).join(sr(t) ? " " : " "); +function zr(e, t) { + return yn(e), hn(t).encode(e).join(jr(t) ? " " : " "); } -function dr(e, t) { +function Br(e, t) { try { - lr(e, t); + Wr(e, t); } catch { return !1; } return !0; } -const yr = (e) => jt("mnemonic" + e); -function pr(e, t = "") { - return ir(wn, zt(e).nfkd, yr(t), { c: 2048, dkLen: 64 }); +const Gr = (e) => un("mnemonic" + e); +function Fr(e, t = "") { + return qr(Zn, dn(e).nfkd, Gr(t), { c: 2048, dkLen: 64 }); } -function hr(e) { +function Hr(e) { if (e.length !== 16) throw new Error("Recovery phrase entropy must be exactly 128 bits (16 bytes)."); - return ur(e, qt); + return zr(e, ln); } -function vr(e) { +function Jr(e) { try { - return dr(Gt(e), qt); + return Br(pn(e), ln); } catch { return !1; } } -function Gt(e) { +function pn(e) { return e.trim().normalize("NFKD").split(/\s+/u).join(" "); } -async function Vt(e) { - return pr(Gt(e), ""); +async function vn(e) { + return Fr(pn(e), ""); } -const Ze = mn.id, Ee = "aes-256-gcm-v1", Pe = "bitlogin-bip39-hkdf-v1"; -async function Ht(e) { - const t = Ie(e.loginName), n = e.now ?? Math.floor(Date.now() / 1e3), { locatorPrivateKey: r, capsuleKey: o } = await me(e.password, t), a = x(r), i = new I(e.vaultRelayUrls, { authPrivateKey: r }); - let s; +const mt = tr.id, Ne = "aes-256-gcm-v1", Ie = "bitlogin-bip39-hkdf-v1"; +async function fn(e) { + const t = ze(e.loginName), n = e.now ?? Math.floor(Date.now() / 1e3), { locatorPrivateKey: r, capsuleKey: o } = await Ce(e.password, t), i = _(r), a = new C(e.vaultRelayUrls, { authPrivateKey: r }); + let c; try { - s = await Se(i, a, o, e.timeoutMs); + c = await Se(a, i, o, e.timeoutMs); } finally { - i.closeAll(); + a.closeAll(); } - if (!s.quorumMet) - throw new ie("Couldn't verify this login name and password aren't already registered. Please retry, or add more vault relays."); - if (s.candidates.length > 0) - throw new kt(); - const c = hr(En()), l = await Vt(c), { recoveryPrivateKey: u, capsuleKey: d } = wt(l), g = x(u), w = e.everydayPrivateKey !== void 0; - if (w && !We(e.everydayPrivateKey)) - throw new ie("The provided key is not a valid secp256k1 private key."); - const v = w ? e.everydayPrivateKey : Pn(), f = x(v), h = ae(_n()), p = { - schema: He, - account_id: h, + if (!c.quorumMet) + throw new ye("Couldn't verify this login name and password aren't already registered. Please retry, or add more vault relays."); + if (c.candidates.length > 0) + throw new Ht(); + const s = Hr(rr()), l = await vn(s), { recoveryPrivateKey: u, capsuleKey: y } = zt(l), v = _(u), w = e.everydayPrivateKey !== void 0; + if (w && !lt(e.everydayPrivateKey)) + throw new ye("The provided key is not a valid secp256k1 private key."); + const g = w ? e.everydayPrivateKey : or(), f = _(g), p = H(ir()), h = xe(32), b = xe(32), m = { + schema: st, + account_id: p, recovery_generation: 0, previous_recovery_event_id: null, - operational_private_key: ae(v), + operational_private_key: H(g), operational_public_key: f, - recovery_public_key: g, + recovery_public_key: v, + connection_vault_root: H(h), + vault_sudo_key: H(b), created_at: n, vault_relay_hints: e.vaultRelayUrls, - protocol: { capsule_encryption: Ee, recovery_derivation: Pe } - }, b = await Mt({ + protocol: { capsule_encryption: Ne, recovery_derivation: Ie } + }, K = await an({ recoveryPrivateKey: u, - capsuleKey: d, - payload: p - }), m = { - schema: Le, - account_id: h, + capsuleKey: y, + payload: m + }), F = { + schema: $e, + account_id: p, generation: 0, - operational_private_key: ae(v), + operational_private_key: H(g), operational_public_key: f, - recovery_public_key: g, - recovery_capsule_event: b, + recovery_public_key: v, + recovery_capsule_event: K, + connection_vault_root: H(h), + vault_sudo_key: H(b), created_at: n, vault_relay_hints: e.vaultRelayUrls, protocol: { - password_kdf: Ze, - capsule_encryption: Ee, - recovery_derivation: Pe + password_kdf: mt, + capsule_encryption: Ne, + recovery_derivation: Ie } - }, P = await Xe({ + }, E = await bt({ locatorPrivateKey: r, capsuleKey: o, - payload: m - }), T = new I(e.vaultRelayUrls, { authPrivateKey: u }), E = await ke(T, b, { - dTag: Ne, + payload: F + }), R = new C(e.vaultRelayUrls, { authPrivateKey: u }), A = await me(R, K, { + dTag: We, minAcks: e.minAcknowledgements, timeoutMs: e.timeoutMs }); - T.closeAll(); - const _ = new I(e.vaultRelayUrls, { authPrivateKey: r }), K = await ke(_, P, { - dTag: fe, + R.closeAll(); + const x = new C(e.vaultRelayUrls, { authPrivateKey: r }), N = await me(x, E, { + dTag: ke, minAcks: e.minAcknowledgements, timeoutMs: e.timeoutMs }); - if (_.closeAll(), !E.success || !K.success) - throw new ie("Registration did not reach the required relay acknowledgement and readback quorum. Please retry, or add more vault relays."); + if (x.closeAll(), !A.success || !N.success) + throw new ye("Registration did not reach the required relay acknowledgement and readback quorum. Please retry, or add more vault relays."); return { normalizedLoginName: t, - recoveryPhrase: c, - everydayPrivateKey: v, + recoveryPhrase: s, + everydayPrivateKey: g, everydayPublicKey: f, - recoveryPublicKey: g, - locatorPublicKey: a, - accountId: h, + recoveryPublicKey: v, + locatorPublicKey: i, + accountId: p, imported: w, - credentialEvent: P, - recoveryEvent: b, - credentialPublish: K, - recoveryPublish: E + connectionVaultRoot: h, + vaultSudoKey: b, + credentialEvent: E, + recoveryEvent: K, + credentialPublish: N, + recoveryPublish: A }; } -async function fr(e) { - const { nsecOrHex: t, ...n } = e, r = Wt(t); - return Ht({ ...n, everydayPrivateKey: r }); +async function Yr(e) { + const { nsecOrHex: t, ...n } = e, r = gn(t); + return fn({ ...n, everydayPrivateKey: r }); } -function Wt(e) { +function gn(e) { const t = e.trim(); let n; if (t.startsWith("nsec1")) - n = kn(t); + n = nr(t); else if (/^[0-9a-fA-F]{64}$/u.test(t)) - n = Fe(t.toLowerCase()); + n = dt(t.toLowerCase()); else - throw new ie("Enter a valid nsec (nsec1…) or a 64-character hex private key."); - if (!We(n)) - throw new ie("The provided key is not a valid secp256k1 private key."); + throw new ye("Enter a valid nsec (nsec1…) or a 64-character hex private key."); + if (!lt(n)) + throw new ye("The provided key is not a valid secp256k1 private key."); return n; } -class Ft { +class wn { map = /* @__PURE__ */ new Map(); async get(t) { return this.map.get(t); @@ -2756,76 +2806,80 @@ class Ft { this.map.delete(t); } } -async function gr(e) { - const t = Ie(e.loginName), { locatorPrivateKey: n, capsuleKey: r } = await me(e.password, t), o = x(n), a = new I(e.vaultRelayUrls, { authPrivateKey: n }); +async function Qr(e) { + const t = ze(e.loginName), { locatorPrivateKey: n, capsuleKey: r } = await Ce(e.password, t), o = _(n), i = new C(e.vaultRelayUrls, { authPrivateKey: n }); try { - const i = await Se(a, o, r, e.timeoutMs); - if (!i.quorumMet) - throw new pe("quorum-not-met"); - if (!i.best) - throw new pe(i.candidates.length > 0 ? "no-valid-candidate" : "no-matching-event"); - const s = i.best.payload, c = e.store ?? new Ft(), l = await Je(c, s.operational_public_key), u = s.generation < l.generation; + const a = await Se(i, o, r, e.timeoutMs); + if (!a.quorumMet) + throw new be("quorum-not-met"); + if (!a.best) + throw new be(a.candidates.length > 0 ? "no-valid-candidate" : "no-matching-event"); + const c = a.best.payload, s = e.store ?? new wn(), l = await vt(s, c.operational_public_key), u = c.generation < l.generation; if (u && !e.acknowledgeRollback) - throw new Pt(l.generation, s.generation); - const d = u ? `This device previously saw credential generation ${l.generation}, but the accepted capsule is generation ${s.generation}. Relays may be serving stale data, or an old capsule is being replayed.` : void 0; - await xt(c, s.operational_public_key, { generation: s.generation }); - const g = i.relayDisagreement ? 'Configured relays returned different credential capsules as "latest" for this account. Some relays may be stale, censored, or malicious.' : void 0; + throw new Jt(l.generation, c.generation); + const y = u ? `This device previously saw credential generation ${l.generation}, but the accepted capsule is generation ${c.generation}. Relays may be serving stale data, or an old capsule is being replayed.` : void 0; + await Yt(s, c.operational_public_key, { generation: c.generation }); + const v = a.relayDisagreement ? 'Configured relays returned different credential capsules as "latest" for this account. Some relays may be stale, censored, or malicious.' : void 0; return { - everydayPrivateKey: de(s.operational_private_key), - everydayPublicKey: s.operational_public_key, - recoveryPublicKey: s.recovery_public_key, - accountId: s.account_id, - generation: s.generation, - credentialEvent: i.best.event, - recoveryCapsuleEvent: s.recovery_capsule_event, - rollbackWarning: d, - relayDisagreementWarning: g + everydayPrivateKey: J(c.operational_private_key), + everydayPublicKey: c.operational_public_key, + recoveryPublicKey: c.recovery_public_key, + accountId: c.account_id, + generation: c.generation, + credentialEvent: a.best.event, + recoveryCapsuleEvent: c.recovery_capsule_event, + connectionVaultRoot: c.connection_vault_root ? J(c.connection_vault_root) : void 0, + vaultSudoKey: c.vault_sudo_key ? J(c.vault_sudo_key) : void 0, + rollbackWarning: y, + relayDisagreementWarning: v }; } finally { - a.closeAll(); + i.closeAll(); } } -function st(e) { - return e.filter((t) => le(t)).sort((t, n) => n.created_at - t.created_at)[0]; +function St(e) { + return e.filter((t) => ie(t)).sort((t, n) => n.created_at - t.created_at)[0]; } -async function wr(e) { - if (!vr(e.phrase)) - throw new Et("This does not look like a valid 12-word BitLogin recovery phrase."); - const t = await Vt(e.phrase), { recoveryPrivateKey: n, capsuleKey: r } = wt(t), o = x(n), a = new I(e.vaultRelayUrls, { authPrivateKey: n }); - let i; +async function Xr(e) { + if (!Jr(e.phrase)) + throw new Me("This does not look like a valid 12-word BitLogin recovery phrase."); + const t = await vn(e.phrase), { recoveryPrivateKey: n, capsuleKey: r } = zt(t); + ge(t); + const o = _(n), i = new C(e.vaultRelayUrls, { authPrivateKey: n }); + let a; try { - i = await tr(a, o, r, e.timeoutMs); + a = await Ur(i, o, r, e.timeoutMs); } finally { - a.closeAll(); + i.closeAll(); } if (e.offlineRecoveryCapsuleEvents?.length) { const f = []; for (const m of e.offlineRecoveryCapsuleEvents) - if (le(m)) + if (ie(m)) try { - f.push({ event: m, payload: await Ut(m, r) }); - } catch (P) { - f.push({ event: m, payload: null, error: P.message }); + f.push({ event: m, payload: await cn(m, r) }); + } catch (K) { + f.push({ event: m, payload: null, error: K.message }); } - const h = /* @__PURE__ */ new Map(); - for (const m of [...i.candidates, ...f]) - h.set(m.event.id, m); - const p = [...h.values()].sort((m, P) => P.event.created_at - m.event.created_at), b = p.find((m) => m.payload !== null) ?? null; - i = { ...i, candidates: p, best: b, quorumMet: i.quorumMet || b !== null }; + const p = /* @__PURE__ */ new Map(); + for (const m of [...a.candidates, ...f]) + p.set(m.event.id, m); + const h = [...p.values()].sort((m, K) => K.event.created_at - m.event.created_at), b = h.find((m) => m.payload !== null) ?? null; + a = { ...a, candidates: h, best: b, quorumMet: a.quorumMet || b !== null }; } - if (!i.quorumMet) - throw new pe("quorum-not-met"); - if (!i.best) - throw new pe(i.candidates.length > 0 ? "no-valid-candidate" : "no-matching-event"); - const s = i.best.payload, c = nr(i.candidates), l = de(s.operational_private_key), u = s.operational_public_key, d = [.../* @__PURE__ */ new Set([...e.discoveryRelayUrls, ...s.vault_relay_hints])], g = new I(d); - let w = [], v = []; + if (!a.quorumMet) + throw new be("quorum-not-met"); + if (!a.best) + throw new be(a.candidates.length > 0 ? "no-valid-candidate" : "no-matching-event"); + const c = a.best.payload, s = Or(a.candidates), l = J(c.operational_private_key), u = c.operational_public_key, y = [.../* @__PURE__ */ new Set([...e.discoveryRelayUrls, ...c.vault_relay_hints])], v = new C(y); + let w = [], g = []; try { - const f = await g.queryQuorum({ kinds: [Be], authors: [u], limit: 5 }, e.timeoutMs), h = st(f.outcomes.flatMap((m) => m.events)); - h && (w = Un(h)); - const p = await g.queryQuorum({ kinds: [Ge], authors: [u], limit: 5 }, e.timeoutMs), b = st(p.outcomes.flatMap((m) => m.events)); - b && (v = Dn(b)); + const f = await v.queryQuorum({ kinds: [it], authors: [u], limit: 5 }, e.timeoutMs), p = St(f.outcomes.flatMap((m) => m.events)); + p && (w = wr(p)); + const h = await v.queryQuorum({ kinds: [at], authors: [u], limit: 5 }, e.timeoutMs), b = St(h.outcomes.flatMap((m) => m.events)); + b && (g = br(b)); } finally { - g.closeAll(); + v.closeAll(); } return { everydayPrivateKey: l, @@ -2833,66 +2887,85 @@ async function wr(e) { recoveryPrivateKey: n, recoveryPublicKey: o, recoveryCapsuleKey: r, - accountId: s.account_id, - currentRecoveryEvent: i.best.event, - currentRecoveryPayload: s, + accountId: c.account_id, + currentRecoveryEvent: a.best.event, + currentRecoveryPayload: c, generalRelays: w, - dmRelays: v, - chainWarning: c.consistent ? void 0 : c.warning + dmRelays: g, + chainWarning: s.consistent ? void 0 : s.warning }; } -async function br(e) { - const t = e.now ?? Math.floor(Date.now() / 1e3), n = Ie(e.newLoginName), { recovered: r } = e, o = { - schema: He, +async function Zr(e) { + const t = e.now ?? Math.floor(Date.now() / 1e3), n = ze(e.newLoginName), { recovered: r } = e, o = r.currentRecoveryPayload.connection_vault_root !== void 0 ? { + connection_vault_root: r.currentRecoveryPayload.connection_vault_root, + vault_sudo_key: r.currentRecoveryPayload.vault_sudo_key + } : {}, i = { + schema: st, account_id: r.accountId, recovery_generation: r.currentRecoveryPayload.recovery_generation + 1, previous_recovery_event_id: r.currentRecoveryEvent.id, - operational_private_key: ae(r.everydayPrivateKey), + operational_private_key: H(r.everydayPrivateKey), operational_public_key: r.everydayPublicKey, recovery_public_key: r.recoveryPublicKey, - created_at: _t(r.currentRecoveryEvent.created_at, t), + ...o, + created_at: ht(r.currentRecoveryEvent.created_at, t), vault_relay_hints: e.vaultRelayUrls, - protocol: { capsule_encryption: Ee, recovery_derivation: Pe } - }, a = await Mt({ + protocol: { capsule_encryption: Ne, recovery_derivation: Ie } + }, a = await an({ recoveryPrivateKey: r.recoveryPrivateKey, capsuleKey: r.recoveryCapsuleKey, - payload: o - }), i = new I(e.vaultRelayUrls, { authPrivateKey: r.recoveryPrivateKey }), s = await ke(i, a, { - dTag: Ne, + payload: i + }), c = new C(e.vaultRelayUrls, { authPrivateKey: r.recoveryPrivateKey }), s = await me(c, a, { + dTag: We, minAcks: e.minAcknowledgements, timeoutMs: e.timeoutMs }); - i.closeAll(); - const { locatorPrivateKey: c, capsuleKey: l } = await me(e.newPassword, n), u = x(c), d = { - schema: Le, + c.closeAll(); + const { locatorPrivateKey: l, capsuleKey: u } = await Ce(e.newPassword, n), y = _(l), v = new C(e.vaultRelayUrls, { authPrivateKey: l }); + let w; + try { + w = await Se(v, y, u, e.timeoutMs); + } finally { + v.closeAll(); + } + if (!w.quorumMet) + throw new Me("Couldn't verify the new login name and password aren't already registered. Please retry, or add more vault relays."); + if (w.candidates.length > 0) + throw new Me("Another account is already registered with that login name and password. Pick a different one."); + const g = { + schema: $e, account_id: r.accountId, generation: 0, - operational_private_key: ae(r.everydayPrivateKey), + operational_private_key: H(r.everydayPrivateKey), operational_public_key: r.everydayPublicKey, recovery_public_key: r.recoveryPublicKey, recovery_capsule_event: a, + ...o, created_at: t, vault_relay_hints: e.vaultRelayUrls, protocol: { - password_kdf: Ze, - capsule_encryption: Ee, - recovery_derivation: Pe + password_kdf: mt, + capsule_encryption: Ne, + recovery_derivation: Ie } - }, g = await Xe({ locatorPrivateKey: c, capsuleKey: l, payload: d }), w = new I(e.vaultRelayUrls, { authPrivateKey: c }), v = await ke(w, g, { - dTag: fe, + }, f = await bt({ locatorPrivateKey: l, capsuleKey: u, payload: g }), p = new C(e.vaultRelayUrls, { authPrivateKey: l }), h = await me(p, f, { + dTag: ke, minAcks: e.minAcknowledgements, timeoutMs: e.timeoutMs }); - if (w.closeAll(), !s.success || !v.success) - throw new Et("Could not publish the refreshed recovery and credential capsules to enough relays. Please retry."); - return { normalizedLoginName: n, locatorPublicKey: u, credentialEvent: g, refreshedRecoveryEvent: a, credentialPublish: v, recoveryPublish: s }; + if (p.closeAll(), !s.success || !h.success) + throw new Me("Could not publish the refreshed recovery and credential capsules to enough relays. Please retry."); + return e.store && await yr(e.store, r.everydayPublicKey, { + generation: 0, + recoveryGeneration: r.currentRecoveryPayload.recovery_generation + 1 + }), { normalizedLoginName: n, locatorPublicKey: y, credentialEvent: f, refreshedRecoveryEvent: a, credentialPublish: h, recoveryPublish: s }; } -function mr(e) { - const t = x(e.privateKey); - return Z({ +function bn(e) { + const t = _(e.privateKey); + return ee({ pubkey: t, created_at: e.createdAt, - kind: Kn, + kind: ar, tags: [ ["e", e.eventIdToDelete], ["k", String(e.deletedEventKind)] @@ -2900,353 +2973,356 @@ function mr(e) { content: e.reason ?? "" }, e.privateKey); } -async function kr(e) { - const t = e.now ?? Math.floor(Date.now() / 1e3), n = Ie(e.loginName), r = await me(e.oldPassword, n), o = x(r.locatorPrivateKey), a = new I(e.vaultRelayUrls, { authPrivateKey: r.locatorPrivateKey }); - let i; +async function eo(e) { + const t = e.now ?? Math.floor(Date.now() / 1e3), n = ze(e.loginName), r = await Ce(e.oldPassword, n), o = _(r.locatorPrivateKey), i = new C(e.vaultRelayUrls, { authPrivateKey: r.locatorPrivateKey }); + let a; try { - i = await Se(a, o, r.capsuleKey, e.timeoutMs); + a = await Se(i, o, r.capsuleKey, e.timeoutMs); } finally { - a.closeAll(); + i.closeAll(); } - if (!i.quorumMet) - throw new pe("quorum-not-met"); - if (!i.best) - throw new pe(i.candidates.length > 0 ? "no-valid-candidate" : "no-matching-event"); - const s = i.best.payload, c = i.best.event, l = e.store ?? new Ft(), u = await Je(l, s.operational_public_key); - if (s.generation < u.generation && !e.acknowledgeRollback) - throw new Pt(u.generation, s.generation); - const d = await me(e.newPassword, n), g = x(d.locatorPrivateKey), w = new I(e.vaultRelayUrls, { authPrivateKey: d.locatorPrivateKey }); - let v; + if (!a.quorumMet) + throw new be("quorum-not-met"); + if (!a.best) + throw new be(a.candidates.length > 0 ? "no-valid-candidate" : "no-matching-event"); + const c = a.best.payload, s = a.best.event, l = e.store ?? new wn(), u = await vt(l, c.operational_public_key); + if (c.generation < u.generation && !e.acknowledgeRollback) + throw new Jt(u.generation, c.generation); + const y = await Ce(e.newPassword, n), v = _(y.locatorPrivateKey), w = new C(e.vaultRelayUrls, { authPrivateKey: y.locatorPrivateKey }); + let g; try { - v = await Se(w, g, d.capsuleKey, e.timeoutMs); + g = await Se(w, v, y.capsuleKey, e.timeoutMs); } finally { w.closeAll(); } - if (!v.quorumMet) - throw new ie("Couldn't verify the new password isn't already registered under this login name. Please retry, or add more vault relays."); - if (v.candidates.length > 0) - throw new kt("Another account is already registered with this login name and the new password you chose. Pick a different new password."); - const f = s.generation + 1, h = { - schema: Le, - account_id: s.account_id, + if (!g.quorumMet) + throw new ye("Couldn't verify the new password isn't already registered under this login name. Please retry, or add more vault relays."); + if (g.candidates.length > 0) + throw new Ht("Another account is already registered with this login name and the new password you chose. Pick a different new password."); + const f = c.generation + 1, p = { + schema: $e, + account_id: c.account_id, generation: f, - operational_private_key: s.operational_private_key, - operational_public_key: s.operational_public_key, - recovery_public_key: s.recovery_public_key, - recovery_capsule_event: s.recovery_capsule_event, + operational_private_key: c.operational_private_key, + operational_public_key: c.operational_public_key, + recovery_public_key: c.recovery_public_key, + recovery_capsule_event: c.recovery_capsule_event, + // Carried forward like every other long-lived field (§CV5.2): dropping + // the vault roots on a password change would strand every connection + // record until the next phrase ceremony. + ...c.connection_vault_root !== void 0 ? { connection_vault_root: c.connection_vault_root, vault_sudo_key: c.vault_sudo_key } : {}, created_at: t, vault_relay_hints: e.vaultRelayUrls, protocol: { - password_kdf: Ze, - capsule_encryption: Ee, - recovery_derivation: Pe + password_kdf: mt, + capsule_encryption: Ne, + recovery_derivation: Ie } - }, p = await Xe({ - locatorPrivateKey: d.locatorPrivateKey, - capsuleKey: d.capsuleKey, - payload: h - }), b = new I(e.vaultRelayUrls, { authPrivateKey: d.locatorPrivateKey }), m = await ke(b, p, { - dTag: fe, + }, h = await bt({ + locatorPrivateKey: y.locatorPrivateKey, + capsuleKey: y.capsuleKey, + payload: p + }), b = new C(e.vaultRelayUrls, { authPrivateKey: y.locatorPrivateKey }), m = await me(b, h, { + dTag: ke, minAcks: e.minAcknowledgements, timeoutMs: e.timeoutMs }); - b.closeAll(); - const P = Xn({ + if (b.closeAll(), !m.success) + throw new ye("The new credential capsule did not reach the required relay acknowledgement and readback quorum. Your existing password still works; nothing was changed. Please retry."); + const K = Tr({ oldLocatorPrivateKey: r.locatorPrivateKey, - createdAt: _t(c.created_at, t) - }), T = mr({ + createdAt: ht(s.created_at, t) + }), F = bn({ privateKey: r.locatorPrivateKey, - eventIdToDelete: c.id, - deletedEventKind: he, + eventIdToDelete: s.id, + deletedEventKind: te, createdAt: t - }), E = new I(e.vaultRelayUrls, { authPrivateKey: r.locatorPrivateKey }), [_, K] = await Promise.all([ - E.publishAll(P, e.timeoutMs), - E.publishAll(T, e.timeoutMs) + }), E = new C(e.vaultRelayUrls, { authPrivateKey: r.locatorPrivateKey }), [R, A] = await Promise.all([ + E.publishAll(K, e.timeoutMs), + E.publishAll(F, e.timeoutMs) ]); - if (E.closeAll(), !m.success) - throw new ie("The new credential capsule did not reach the required relay acknowledgement and readback quorum. Please retry."); - return await xt(l, s.operational_public_key, { generation: f }), { + return E.closeAll(), await Yt(l, c.operational_public_key, { generation: f }), { normalizedLoginName: n, oldLocatorPublicKey: o, - newLocatorPublicKey: g, + newLocatorPublicKey: v, newGeneration: f, - recoveryPublicKey: s.recovery_public_key, - recoveryCapsuleEvent: s.recovery_capsule_event, - newCredentialEvent: p, - tombstoneEvent: P, - deletionRequestEvent: T, + recoveryPublicKey: c.recovery_public_key, + recoveryCapsuleEvent: c.recovery_capsule_event, + newCredentialEvent: h, + tombstoneEvent: K, + deletionRequestEvent: F, newCredentialPublish: m, - tombstoneAcknowledgedCount: ne(_), - deletionAcknowledgedCount: ne(K) + tombstoneAcknowledgedCount: se(R), + deletionAcknowledgedCount: se(A) }; } /*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */ -function Er(e) { +function to(e) { return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in e && e.BYTES_PER_ELEMENT === 1; } -function ct(e) { +function Nt(e) { if (typeof e != "boolean") throw new TypeError(`boolean expected, not ${e}`); } -function Me(e) { +function Fe(e) { if (typeof e != "number") throw new TypeError("number expected, got " + typeof e); if (!Number.isSafeInteger(e) || e < 0) throw new RangeError("positive integer expected, got " + e); } -function L(e, t, n = "") { - const r = Er(e), o = e?.length, a = t !== void 0; - if (!r || a && o !== t) { - const i = n && `"${n}" `, s = a ? ` of length ${t}` : "", c = r ? `length=${o}` : `type=${typeof e}`, l = i + "expected Uint8Array" + s + ", got " + c; +function T(e, t, n = "") { + const r = to(e), o = e?.length, i = t !== void 0; + if (!r || i && o !== t) { + const a = n && `"${n}" `, c = i ? ` of length ${t}` : "", s = r ? `length=${o}` : `type=${typeof e}`, l = a + "expected Uint8Array" + c + ", got " + s; throw r ? new RangeError(l) : new TypeError(l); } return e; } -function A(e) { +function S(e) { return new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4)); } -function ce(...e) { +function pe(...e) { for (let t = 0; t < e.length; t++) e[t].fill(0); } -const W = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68, Pr = (e) => e << 24 & 4278190080 | e << 8 & 16711680 | e >>> 8 & 65280 | e >>> 24 & 255, _r = (e) => { +const Y = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68, no = (e) => e << 24 & 4278190080 | e << 8 & 16711680 | e >>> 8 & 65280 | e >>> 24 & 255, ro = (e) => { for (let t = 0; t < e.length; t++) - e[t] = Pr(e[t]); + e[t] = no(e[t]); return e; -}, N = W ? (e) => e : _r; -function Kr(e, t) { +}, L = Y ? (e) => e : ro; +function oo(e, t) { return !e.byteLength || !t.byteLength ? !1 : e.buffer === t.buffer && // best we can do, may fail with an obscure Proxy e.byteOffset < t.byteOffset + t.byteLength && // a starts before b end t.byteOffset < e.byteOffset + e.byteLength; } -function Jt(e, t) { - if (Kr(e, t) && e.byteOffset < t.byteOffset) +function mn(e, t) { + if (oo(e, t) && e.byteOffset < t.byteOffset) throw new Error("complex overlap of input and output is not supported"); } -function xr(e, t) { +function io(e, t) { if (t == null || typeof t != "object") throw new Error("options must be defined"); return Object.assign(e, t); } -const Rr = /* @__NO_SIDE_EFFECTS__ */ (e, t) => { +const ao = /* @__NO_SIDE_EFFECTS__ */ (e, t) => { function n(r, ...o) { - if (L(r, void 0, "key"), e.nonceLength !== void 0) { + if (T(r, void 0, "key"), e.nonceLength !== void 0) { const u = o[0]; - L(u, e.varSizeNonce ? void 0 : e.nonceLength, "nonce"); + T(u, e.varSizeNonce ? void 0 : e.nonceLength, "nonce"); } - const a = e.tagLength; - a && o[1] !== void 0 && L(o[1], void 0, "AAD"); - const i = t(r, ...o), s = (u, d) => { - if (d !== void 0) { + const i = e.tagLength; + i && o[1] !== void 0 && T(o[1], void 0, "AAD"); + const a = t(r, ...o), c = (u, y) => { + if (y !== void 0) { if (u !== 2) throw new Error("cipher output not supported"); - L(d, void 0, "output"); + T(y, void 0, "output"); } }; - let c = !1; + let s = !1; return { - encrypt(u, d) { - if (c) + encrypt(u, y) { + if (s) throw new Error("cannot encrypt() twice with same key + nonce"); - return c = !0, L(u), s(i.encrypt.length, d), i.encrypt(u, d); + return s = !0, T(u), c(a.encrypt.length, y), a.encrypt(u, y); }, - decrypt(u, d) { - if (L(u), a && u.length < a) - throw new Error('"ciphertext" expected length bigger than tagLength=' + a); - return s(i.decrypt.length, d), i.decrypt(u, d); + decrypt(u, y) { + if (T(u), i && u.length < i) + throw new Error('"ciphertext" expected length bigger than tagLength=' + i); + return c(a.decrypt.length, y), a.decrypt(u, y); } }; } return Object.assign(n, e), n; }; -function et(e, t, n = !0) { +function kt(e, t, n = !0) { if (t === void 0) return new Uint8Array(e); - if (L(t, void 0, "output"), t.length !== e) + if (T(t, void 0, "output"), t.length !== e) throw new Error('"output" expected Uint8Array of length ' + e + ", got: " + t.length); - if (n && !X(t)) + if (n && !oe(t)) throw new Error("invalid output, must be aligned"); return t; } -function X(e) { +function oe(e) { return e.byteOffset % 4 === 0; } -function se(e) { - return Uint8Array.from(L(e)); +function he(e) { + return Uint8Array.from(T(e)); } -const Yt = (e) => Uint8Array.from(e.split(""), (t) => t.charCodeAt(0)), Ar = N(A(Yt("expand 16-byte k"))), Cr = N(A(Yt("expand 32-byte k"))); +const kn = (e) => Uint8Array.from(e.split(""), (t) => t.charCodeAt(0)), co = L(S(kn("expand 16-byte k"))), so = L(S(kn("expand 32-byte k"))); function k(e, t) { return e << t | e >>> 32 - t; } -const ge = 64, Sr = 16, qe = 2 ** 32 - 1, lt = /* @__PURE__ */ Uint32Array.of(); -function Lr(e, t, n, r, o, a, i, s) { - const c = o.length, l = new Uint8Array(ge), u = A(l), d = W && X(o) && X(a), g = d ? A(o) : lt, w = d ? A(a) : lt; - if (!W) { - for (let v = 0; v < c; i++) { - if (e(t, n, r, u, i, s), N(u), i >= qe) +const Pe = 64, lo = 16, Ze = 2 ** 32 - 1, It = /* @__PURE__ */ Uint32Array.of(); +function uo(e, t, n, r, o, i, a, c) { + const s = o.length, l = new Uint8Array(Pe), u = S(l), y = Y && oe(o) && oe(i), v = y ? S(o) : It, w = y ? S(i) : It; + if (!Y) { + for (let g = 0; g < s; a++) { + if (e(t, n, r, u, a, c), L(u), a >= Ze) throw new Error("arx: counter overflow"); - const f = Math.min(ge, c - v); - for (let h = 0, p; h < f; h++) - p = v + h, a[p] = o[p] ^ l[h]; - v += f; + const f = Math.min(Pe, s - g); + for (let p = 0, h; p < f; p++) + h = g + p, i[h] = o[h] ^ l[p]; + g += f; } return; } - for (let v = 0; v < c; i++) { - if (e(t, n, r, u, i, s), i >= qe) + for (let g = 0; g < s; a++) { + if (e(t, n, r, u, a, c), a >= Ze) throw new Error("arx: counter overflow"); - const f = Math.min(ge, c - v); - if (d && f === ge) { - const h = v / 4; - if (v % 4 !== 0) + const f = Math.min(Pe, s - g); + if (y && f === Pe) { + const p = g / 4; + if (g % 4 !== 0) throw new Error("arx: invalid block position"); - for (let p = 0, b; p < Sr; p++) - b = h + p, w[b] = g[b] ^ u[p]; - v += ge; + for (let h = 0, b; h < lo; h++) + b = p + h, w[b] = v[b] ^ u[h]; + g += Pe; continue; } - for (let h = 0, p; h < f; h++) - p = v + h, a[p] = o[p] ^ l[h]; - v += f; + for (let p = 0, h; p < f; p++) + h = g + p, i[h] = o[h] ^ l[p]; + g += f; } } -function Nr(e, t) { - const { allowShortKeys: n, extendNonceFn: r, counterLength: o, counterRight: a, rounds: i } = xr({ allowShortKeys: !1, counterLength: 8, counterRight: !1, rounds: 20 }, t); +function yo(e, t) { + const { allowShortKeys: n, extendNonceFn: r, counterLength: o, counterRight: i, rounds: a } = io({ allowShortKeys: !1, counterLength: 8, counterRight: !1, rounds: 20 }, t); if (typeof e != "function") throw new Error("core must be a function"); - return Me(o), Me(i), ct(a), ct(n), (s, c, l, u, d = 0) => { - L(s, void 0, "key"), L(c, void 0, "nonce"), L(l, void 0, "data"); - const g = l.length; - if (u = et(g, u, !1), Me(d), d < 0 || d >= qe) + return Fe(o), Fe(a), Nt(i), Nt(n), (c, s, l, u, y = 0) => { + T(c, void 0, "key"), T(s, void 0, "nonce"), T(l, void 0, "data"); + const v = l.length; + if (u = kt(v, u, !1), Fe(y), y < 0 || y >= Ze) throw new Error("arx: counter overflow"); const w = []; - let v = s.length, f, h; - if (v === 32) - w.push(f = se(s)), h = Cr; - else if (v === 16 && n) - f = new Uint8Array(32), f.set(s), f.set(s, 16), h = Ar, w.push(f); + let g = c.length, f, p; + if (g === 32) + w.push(f = he(c)), p = so; + else if (g === 16 && n) + f = new Uint8Array(32), f.set(c), f.set(c, 16), p = co, w.push(f); else - throw L(s, 32, "arx key"), new Error("invalid key size"); - (!W || !X(c)) && w.push(c = se(c)); - let p = A(f); + throw T(c, 32, "arx key"), new Error("invalid key size"); + (!Y || !oe(s)) && w.push(s = he(s)); + let h = S(f); if (r) { - if (c.length !== 24) + if (s.length !== 24) throw new Error("arx: extended nonce must be 24 bytes"); - const P = c.subarray(0, 16); - if (W) - r(h, p, A(P), p); + const K = s.subarray(0, 16); + if (Y) + r(p, h, S(K), h); else { - const T = N(Uint32Array.from(h)); - r(T, p, A(P), p), ce(T), N(p); + const F = L(Uint32Array.from(p)); + r(F, h, S(K), h), pe(F), L(h); } - c = c.subarray(16); - } else W || N(p); + s = s.subarray(16); + } else Y || L(h); const b = 16 - o; - if (b !== c.length) + if (b !== s.length) throw new Error(`arx: nonce must be ${b} or 16 bytes`); if (b !== 12) { - const P = new Uint8Array(12); - P.set(c, a ? 0 : 12 - c.length), c = P, w.push(c); + const K = new Uint8Array(12); + K.set(s, i ? 0 : 12 - s.length), s = K, w.push(s); } - const m = N(A(c)); + const m = L(S(s)); try { - return Lr(e, h, p, m, l, u, d, i), u; + return uo(e, p, h, m, l, u, y, a), u; } finally { - ce(...w); + pe(...w); } }; } -function Ir(e, t, n, r, o, a = 20) { - let i = e[0], s = e[1], c = e[2], l = e[3], u = t[0], d = t[1], g = t[2], w = t[3], v = t[4], f = t[5], h = t[6], p = t[7], b = o, m = n[0], P = n[1], T = n[2], E = i, _ = s, K = c, S = l, O = u, M = d, U = g, D = w, q = v, j = f, z = h, $ = p, B = b, G = m, V = P, H = T; - for (let ot = 0; ot < a; ot += 2) - E = E + O | 0, B = k(B ^ E, 16), q = q + B | 0, O = k(O ^ q, 12), E = E + O | 0, B = k(B ^ E, 8), q = q + B | 0, O = k(O ^ q, 7), _ = _ + M | 0, G = k(G ^ _, 16), j = j + G | 0, M = k(M ^ j, 12), _ = _ + M | 0, G = k(G ^ _, 8), j = j + G | 0, M = k(M ^ j, 7), K = K + U | 0, V = k(V ^ K, 16), z = z + V | 0, U = k(U ^ z, 12), K = K + U | 0, V = k(V ^ K, 8), z = z + V | 0, U = k(U ^ z, 7), S = S + D | 0, H = k(H ^ S, 16), $ = $ + H | 0, D = k(D ^ $, 12), S = S + D | 0, H = k(H ^ S, 8), $ = $ + H | 0, D = k(D ^ $, 7), E = E + M | 0, H = k(H ^ E, 16), z = z + H | 0, M = k(M ^ z, 12), E = E + M | 0, H = k(H ^ E, 8), z = z + H | 0, M = k(M ^ z, 7), _ = _ + U | 0, B = k(B ^ _, 16), $ = $ + B | 0, U = k(U ^ $, 12), _ = _ + U | 0, B = k(B ^ _, 8), $ = $ + B | 0, U = k(U ^ $, 7), K = K + D | 0, G = k(G ^ K, 16), q = q + G | 0, D = k(D ^ q, 12), K = K + D | 0, G = k(G ^ K, 8), q = q + G | 0, D = k(D ^ q, 7), S = S + O | 0, V = k(V ^ S, 16), j = j + V | 0, O = k(O ^ j, 12), S = S + O | 0, V = k(V ^ S, 8), j = j + V | 0, O = k(O ^ j, 7); - let C = 0; - r[C++] = i + E | 0, r[C++] = s + _ | 0, r[C++] = c + K | 0, r[C++] = l + S | 0, r[C++] = u + O | 0, r[C++] = d + M | 0, r[C++] = g + U | 0, r[C++] = w + D | 0, r[C++] = v + q | 0, r[C++] = f + j | 0, r[C++] = h + z | 0, r[C++] = p + $ | 0, r[C++] = b + B | 0, r[C++] = m + G | 0, r[C++] = P + V | 0, r[C++] = T + H | 0; +function ho(e, t, n, r, o, i = 20) { + let a = e[0], c = e[1], s = e[2], l = e[3], u = t[0], y = t[1], v = t[2], w = t[3], g = t[4], f = t[5], p = t[6], h = t[7], b = o, m = n[0], K = n[1], F = n[2], E = a, R = c, A = s, x = l, N = u, O = y, M = v, D = w, V = g, q = f, j = p, $ = h, W = b, z = m, B = K, G = F; + for (let Rt = 0; Rt < i; Rt += 2) + E = E + N | 0, W = k(W ^ E, 16), V = V + W | 0, N = k(N ^ V, 12), E = E + N | 0, W = k(W ^ E, 8), V = V + W | 0, N = k(N ^ V, 7), R = R + O | 0, z = k(z ^ R, 16), q = q + z | 0, O = k(O ^ q, 12), R = R + O | 0, z = k(z ^ R, 8), q = q + z | 0, O = k(O ^ q, 7), A = A + M | 0, B = k(B ^ A, 16), j = j + B | 0, M = k(M ^ j, 12), A = A + M | 0, B = k(B ^ A, 8), j = j + B | 0, M = k(M ^ j, 7), x = x + D | 0, G = k(G ^ x, 16), $ = $ + G | 0, D = k(D ^ $, 12), x = x + D | 0, G = k(G ^ x, 8), $ = $ + G | 0, D = k(D ^ $, 7), E = E + O | 0, G = k(G ^ E, 16), j = j + G | 0, O = k(O ^ j, 12), E = E + O | 0, G = k(G ^ E, 8), j = j + G | 0, O = k(O ^ j, 7), R = R + M | 0, W = k(W ^ R, 16), $ = $ + W | 0, M = k(M ^ $, 12), R = R + M | 0, W = k(W ^ R, 8), $ = $ + W | 0, M = k(M ^ $, 7), A = A + D | 0, z = k(z ^ A, 16), V = V + z | 0, D = k(D ^ V, 12), A = A + D | 0, z = k(z ^ A, 8), V = V + z | 0, D = k(D ^ V, 7), x = x + N | 0, B = k(B ^ x, 16), q = q + B | 0, N = k(N ^ q, 12), x = x + N | 0, B = k(B ^ x, 8), q = q + B | 0, N = k(N ^ q, 7); + let I = 0; + r[I++] = a + E | 0, r[I++] = c + R | 0, r[I++] = s + A | 0, r[I++] = l + x | 0, r[I++] = u + N | 0, r[I++] = y + O | 0, r[I++] = v + M | 0, r[I++] = w + D | 0, r[I++] = g + V | 0, r[I++] = f + q | 0, r[I++] = p + j | 0, r[I++] = h + $ | 0, r[I++] = b + W | 0, r[I++] = m + z | 0, r[I++] = K + B | 0, r[I++] = F + G | 0; } -const Qt = /* @__PURE__ */ Nr(Ir, { +const _n = /* @__PURE__ */ yo(ho, { counterRight: !1, counterLength: 4, allowShortKeys: !1 -}), Xt = 2, je = 1, Zt = 65536, ze = 4294967295; -function ut(e, t) { - const n = Te(new Uint8Array([2]), Fe(t)), o = mt.getSharedSecret(e, n, !0).slice(1, 33); - return xn(ve("nip44-v2"), o); +}), En = 2, et = 1, Pn = 65536, tt = 4294967295; +function Tt(e, t) { + const n = _e(new Uint8Array([2]), dt(t)), o = Bt.getSharedSecret(e, n, !0).slice(1, 33); + return yt(ue("nip44-v2"), o); } -function en(e, t) { - const n = An(e, t, 76); +function Kn(e, t) { + const n = Gt(e, t, 76); return { chachaKey: n.slice(0, 32), chachaNonce: n.slice(32, 44), hmacKey: n.slice(44, 76) }; } -function tn(e) { +function Rn(e) { if (e <= 32) return 32; const t = 2 ** Math.floor(Math.log2(e - 1) + 1), n = t <= 256 ? 32 : t / 8; return n * (Math.floor((e - 1) / n) + 1); } -function Tr(e) { - if (e < Zt) { +function po(e) { + if (e < Pn) { const n = new Uint8Array(2); return new DataView(n.buffer).setUint16(0, e, !1), n; } const t = new Uint8Array(6); return new DataView(t.buffer).setUint32(2, e, !1), t; } -function Or(e) { +function vo(e) { const t = e.length; - if (t < je || t > ze) - throw new Error(`NIP-44 plaintext length must be between ${je} and ${ze} bytes.`); - const n = Tr(t), r = tn(t), o = new Uint8Array(n.length + r); + if (t < et || t > tt) + throw new Error(`NIP-44 plaintext length must be between ${et} and ${tt} bytes.`); + const n = po(t), r = Rn(t), o = new Uint8Array(n.length + r); return o.set(n, 0), o.set(e, n.length), o; } -function Mr(e) { +function fo(e) { const t = new DataView(e.buffer, e.byteOffset, e.byteLength), n = t.getUint16(0, !1); let r, o; if (n === 0) { - if (r = t.getUint32(2, !1), o = 6, r < Zt) + if (r = t.getUint32(2, !1), o = 6, r < Pn) throw new Error("NIP-44 payload has inconsistent padding."); } else r = n, o = 2; - if (r < je || r > ze || e.length !== o + tn(r)) + if (r < et || r > tt || e.length !== o + Rn(r)) throw new Error("NIP-44 payload has inconsistent padding."); return e.slice(o, o + r); } -function nn(e, t, n) { - return ft(gt, e, Te(t, n)); +function An(e, t, n) { + return $t(Wt, e, _e(t, n)); } -function Ur(e, t, n) { - const r = bt(32), { chachaKey: o, chachaNonce: a, hmacKey: i } = en(e, r), s = Or(ve(t)), c = Qt(o, a, s), l = nn(i, r, c); - return ye.encode(Te(new Uint8Array([Xt]), r, c, l)); +function go(e, t, n) { + const r = xe(32), { chachaKey: o, chachaNonce: i, hmacKey: a } = Kn(e, r), c = vo(ue(t)), s = _n(o, i, c), l = An(a, r, s); + return we.encode(_e(new Uint8Array([En]), r, s, l)); } -function Dr(e, t) { - const n = ye.decode(t); - if (n[0] !== Xt) +function wo(e, t) { + const n = we.decode(t); + if (n[0] !== En) throw new Error(`Unsupported NIP-44 version: ${n[0]}`); - const r = n.slice(1, 33), o = n.slice(n.length - 32), a = n.slice(33, n.length - 32), { chachaKey: i, chachaNonce: s, hmacKey: c } = en(e, r), l = nn(c, r, a); - if (!Rn(o, l)) + const r = n.slice(1, 33), o = n.slice(n.length - 32), i = n.slice(33, n.length - 32), { chachaKey: a, chachaNonce: c, hmacKey: s } = Kn(e, r), l = An(s, r, i); + if (!cr(o, l)) throw new Error("NIP-44 MAC verification failed: payload is corrupted, tampered, or uses the wrong key."); - const u = Qt(i, s, a); - return Ve(Mr(u)); + const u = _n(a, c, i); + return ct(fo(u)); } -const re = 16, qr = 283; -function jr(e) { +const le = 16, bo = 283; +function mo(e) { if (![16, 24, 32].includes(e.length)) throw new Error('"aes key" expected Uint8Array of length 16/24/32, got length=' + e.length); } -function tt(e) { - return e << 1 ^ qr & -(e >> 7); +function _t(e) { + return e << 1 ^ bo & -(e >> 7); } -function ue(e, t) { +function fe(e, t) { let n = 0; for (; t > 0; t >>= 1) - n ^= e & -(t & 1), e = tt(e); + n ^= e & -(t & 1), e = _t(e); return n; } -const $e = /* @__PURE__ */ (() => { +const nt = /* @__PURE__ */ (() => { const e = new Uint8Array(256); - for (let n = 0, r = 1; n < 256; n++, r ^= tt(r)) + for (let n = 0, r = 1; n < 256; n++, r ^= _t(r)) e[n] = r; const t = new Uint8Array(256); t[0] = 99; @@ -3254,102 +3330,102 @@ const $e = /* @__PURE__ */ (() => { let r = e[255 - n]; r |= r << 8, t[e[n]] = (r ^ r >> 4 ^ r >> 5 ^ r >> 6 ^ r >> 7 ^ 99) & 255; } - return ce(e), t; -})(), zr = /* @__PURE__ */ $e.map((e, t) => $e.indexOf(t)), $r = (e) => e << 24 | e >>> 8, Ue = (e) => e << 8 | e >>> 24; -function rn(e, t) { + return pe(e), t; +})(), ko = /* @__PURE__ */ nt.map((e, t) => nt.indexOf(t)), _o = (e) => e << 24 | e >>> 8, He = (e) => e << 8 | e >>> 24; +function Cn(e, t) { if (e.length !== 256) throw new Error("Wrong sbox length"); - const n = new Uint32Array(256).map((l, u) => t(e[u])), r = n.map(Ue), o = r.map(Ue), a = o.map(Ue), i = new Uint32Array(256 * 256), s = new Uint32Array(256 * 256), c = new Uint16Array(256 * 256); + const n = new Uint32Array(256).map((l, u) => t(e[u])), r = n.map(He), o = r.map(He), i = o.map(He), a = new Uint32Array(256 * 256), c = new Uint32Array(256 * 256), s = new Uint16Array(256 * 256); for (let l = 0; l < 256; l++) for (let u = 0; u < 256; u++) { - const d = l * 256 + u; - i[d] = n[l] ^ r[u], s[d] = o[l] ^ a[u], c[d] = e[l] << 8 | e[u]; + const y = l * 256 + u; + a[y] = n[l] ^ r[u], c[y] = o[l] ^ i[u], s[y] = e[l] << 8 | e[u]; } - return { sbox: e, sbox2: c, T0: n, T1: r, T2: o, T3: a, T01: i, T23: s }; + return { sbox: e, sbox2: s, T0: n, T1: r, T2: o, T3: i, T01: a, T23: c }; } -const nt = /* @__PURE__ */ rn($e, (e) => ue(e, 3) << 24 | e << 16 | e << 8 | ue(e, 2)), on = /* @__PURE__ */ rn(zr, (e) => ue(e, 11) << 24 | ue(e, 13) << 16 | ue(e, 9) << 8 | ue(e, 14)), Br = /* @__PURE__ */ (() => { +const Et = /* @__PURE__ */ Cn(nt, (e) => fe(e, 3) << 24 | e << 16 | e << 8 | fe(e, 2)), xn = /* @__PURE__ */ Cn(ko, (e) => fe(e, 11) << 24 | fe(e, 13) << 16 | fe(e, 9) << 8 | fe(e, 14)), Eo = /* @__PURE__ */ (() => { const e = new Uint8Array(16); - for (let t = 0, n = 1; t < 16; t++, n = tt(n)) + for (let t = 0, n = 1; t < 16; t++, n = _t(n)) e[t] = n; return e; })(); -function an(e) { - L(e); +function Sn(e) { + T(e); const t = e.length; - jr(e); - const { sbox2: n } = nt, r = []; - (!W || !X(e)) && r.push(e = se(e)); - const o = N(A(e)), a = o.length, i = (c) => J(n, c, c, c, c), s = new Uint32Array(t + 28); - s.set(o); - for (let c = a; c < s.length; c++) { - let l = s[c - 1]; - c % a === 0 ? l = i($r(l)) ^ Br[c / a - 1] : a > 6 && c % a === 4 && (l = i(l)), s[c] = s[c - a] ^ l; + mo(e); + const { sbox2: n } = Et, r = []; + (!Y || !oe(e)) && r.push(e = he(e)); + const o = L(S(e)), i = o.length, a = (s) => Z(n, s, s, s, s), c = new Uint32Array(t + 28); + c.set(o); + for (let s = i; s < c.length; s++) { + let l = c[s - 1]; + s % i === 0 ? l = a(_o(l)) ^ Eo[s / i - 1] : i > 6 && s % i === 4 && (l = a(l)), c[s] = c[s - i] ^ l; } - return ce(...r), s; + return pe(...r), c; } -function Gr(e) { - const t = an(e), n = t.slice(), r = t.length, { sbox2: o } = nt, { T0: a, T1: i, T2: s, T3: c } = on; +function Po(e) { + const t = Sn(e), n = t.slice(), r = t.length, { sbox2: o } = Et, { T0: i, T1: a, T2: c, T3: s } = xn; for (let l = 0; l < r; l += 4) for (let u = 0; u < 4; u++) n[l + u] = t[r - l - 4 + u]; - ce(t); + pe(t); for (let l = 4; l < r - 4; l++) { - const u = n[l], d = J(o, u, u, u, u); - n[l] = a[d & 255] ^ i[d >>> 8 & 255] ^ s[d >>> 16 & 255] ^ c[d >>> 24]; + const u = n[l], y = Z(o, u, u, u, u); + n[l] = i[y & 255] ^ a[y >>> 8 & 255] ^ c[y >>> 16 & 255] ^ s[y >>> 24]; } return n; } -function te(e, t, n, r, o, a) { - return e[n << 8 & 65280 | r >>> 8 & 255] ^ t[o >>> 8 & 65280 | a >>> 24 & 255]; +function ce(e, t, n, r, o, i) { + return e[n << 8 & 65280 | r >>> 8 & 255] ^ t[o >>> 8 & 65280 | i >>> 24 & 255]; } -function J(e, t, n, r, o) { +function Z(e, t, n, r, o) { return e[t & 255 | n & 65280] | e[r >>> 16 & 255 | o >>> 16 & 65280] << 16; } -function dt(e, t, n, r, o) { - const { sbox2: a, T01: i, T23: s } = nt; - let c = 0; - t ^= e[c++], n ^= e[c++], r ^= e[c++], o ^= e[c++]; +function Lt(e, t, n, r, o) { + const { sbox2: i, T01: a, T23: c } = Et; + let s = 0; + t ^= e[s++], n ^= e[s++], r ^= e[s++], o ^= e[s++]; const l = e.length / 4 - 2; - for (let v = 0; v < l; v++) { - const f = e[c++] ^ te(i, s, t, n, r, o), h = e[c++] ^ te(i, s, n, r, o, t), p = e[c++] ^ te(i, s, r, o, t, n), b = e[c++] ^ te(i, s, o, t, n, r); - t = f, n = h, r = p, o = b; + for (let g = 0; g < l; g++) { + const f = e[s++] ^ ce(a, c, t, n, r, o), p = e[s++] ^ ce(a, c, n, r, o, t), h = e[s++] ^ ce(a, c, r, o, t, n), b = e[s++] ^ ce(a, c, o, t, n, r); + t = f, n = p, r = h, o = b; } - const u = e[c++] ^ J(a, t, n, r, o), d = e[c++] ^ J(a, n, r, o, t), g = e[c++] ^ J(a, r, o, t, n), w = e[c++] ^ J(a, o, t, n, r); - return { s0: u, s1: d, s2: g, s3: w }; + const u = e[s++] ^ Z(i, t, n, r, o), y = e[s++] ^ Z(i, n, r, o, t), v = e[s++] ^ Z(i, r, o, t, n), w = e[s++] ^ Z(i, o, t, n, r); + return { s0: u, s1: y, s2: v, s3: w }; } -function Vr(e, t, n, r, o) { - const { sbox2: a, T01: i, T23: s } = on; - let c = 0; - t ^= e[c++], n ^= e[c++], r ^= e[c++], o ^= e[c++]; +function Ko(e, t, n, r, o) { + const { sbox2: i, T01: a, T23: c } = xn; + let s = 0; + t ^= e[s++], n ^= e[s++], r ^= e[s++], o ^= e[s++]; const l = e.length / 4 - 2; - for (let v = 0; v < l; v++) { - const f = e[c++] ^ te(i, s, t, o, r, n), h = e[c++] ^ te(i, s, n, t, o, r), p = e[c++] ^ te(i, s, r, n, t, o), b = e[c++] ^ te(i, s, o, r, n, t); - t = f, n = h, r = p, o = b; + for (let g = 0; g < l; g++) { + const f = e[s++] ^ ce(a, c, t, o, r, n), p = e[s++] ^ ce(a, c, n, t, o, r), h = e[s++] ^ ce(a, c, r, n, t, o), b = e[s++] ^ ce(a, c, o, r, n, t); + t = f, n = p, r = h, o = b; } - const u = e[c++] ^ J(a, t, o, r, n), d = e[c++] ^ J(a, n, t, o, r), g = e[c++] ^ J(a, r, n, t, o), w = e[c++] ^ J(a, o, r, n, t); - return { s0: u, s1: d, s2: g, s3: w }; + const u = e[s++] ^ Z(i, t, o, r, n), y = e[s++] ^ Z(i, n, t, o, r), v = e[s++] ^ Z(i, r, n, t, o), w = e[s++] ^ Z(i, o, r, n, t); + return { s0: u, s1: y, s2: v, s3: w }; } -function Hr(e) { - if (L(e), e.length % re !== 0) - throw new Error("aes-(cbc/ecb).decrypt ciphertext should consist of blocks with size " + re); +function Ro(e) { + if (T(e), e.length % le !== 0) + throw new Error("aes-(cbc/ecb).decrypt ciphertext should consist of blocks with size " + le); } -function Wr(e, t, n) { - L(e); +function Ao(e, t, n) { + T(e); let r = e.length; - const o = r % re; + const o = r % le; if (!t && o !== 0) throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding"); if (t) { - let s = re - o; - s || (s = re), r = r + s; + let c = le - o; + c || (c = le), r = r + c; } - n = et(r, n), Jt(e, n), (!W || !X(e)) && (e = se(e)); - const a = A(e); - N(a); - const i = A(n); - return { b: a, o: i, out: n }; + n = kt(r, n), mn(e, n), (!Y || !oe(e)) && (e = he(e)); + const i = S(e); + L(i); + const a = S(n); + return { b: i, o: a, out: n }; } -function Fr(e, t) { +function Co(e, t) { if (!t) return e; const n = e.length; @@ -3358,87 +3434,83 @@ function Fr(e, t) { const r = e[n - 1]; let o = 1; o &= r - 1 >>> 31 ^ 1, o &= 16 - r >>> 31 ^ 1; - for (let a = 0; a < 16; a++) { - const i = a - r >>> 31, s = (e[n - 1 - a] ^ r) === 0 ? 1 : 0; - o &= s | i ^ 1; + for (let i = 0; i < 16; i++) { + const a = i - r >>> 31, c = (e[n - 1 - i] ^ r) === 0 ? 1 : 0; + o &= c | a ^ 1; } if (!o) throw new Error("aes/pkcs7: wrong padding"); return e.subarray(0, n - r); } -function Jr(e) { - const t = new Uint8Array(16), n = A(t); +function xo(e) { + const t = new Uint8Array(16), n = S(t); t.set(e); - const r = re - e.length; - for (let o = re - r; o < re; o++) + const r = le - e.length; + for (let o = le - r; o < le; o++) t[o] = r; return n; } -const sn = /* @__PURE__ */ Rr({ blockSize: 16, nonceLength: 16 }, function(t, n, r = {}) { +const Nn = /* @__PURE__ */ ao({ blockSize: 16, nonceLength: 16 }, function(t, n, r = {}) { const o = !r.disablePadding; return { - encrypt(a, i) { - const s = an(t), { b: c, o: l, out: u } = Wr(a, o, i); - let d = n; - const g = [s]; - (!W || !X(d)) && g.push(d = se(d)); - const w = A(d); - N(w); - let v = w[0], f = w[1], h = w[2], p = w[3], b = 0; - for (; b + 4 <= c.length; ) - v ^= c[b + 0], f ^= c[b + 1], h ^= c[b + 2], p ^= c[b + 3], { s0: v, s1: f, s2: h, s3: p } = dt(s, v, f, h, p), l[b++] = v, l[b++] = f, l[b++] = h, l[b++] = p; + encrypt(i, a) { + const c = Sn(t), { b: s, o: l, out: u } = Ao(i, o, a); + let y = n; + const v = [c]; + (!Y || !oe(y)) && v.push(y = he(y)); + const w = S(y); + L(w); + let g = w[0], f = w[1], p = w[2], h = w[3], b = 0; + for (; b + 4 <= s.length; ) + g ^= s[b + 0], f ^= s[b + 1], p ^= s[b + 2], h ^= s[b + 3], { s0: g, s1: f, s2: p, s3: h } = Lt(c, g, f, p, h), l[b++] = g, l[b++] = f, l[b++] = p, l[b++] = h; if (o) { - const m = Jr(a.subarray(b * 4)); - N(m), v ^= m[0], f ^= m[1], h ^= m[2], p ^= m[3], { s0: v, s1: f, s2: h, s3: p } = dt(s, v, f, h, p), l[b++] = v, l[b++] = f, l[b++] = h, l[b++] = p; + const m = xo(i.subarray(b * 4)); + L(m), g ^= m[0], f ^= m[1], p ^= m[2], h ^= m[3], { s0: g, s1: f, s2: p, s3: h } = Lt(c, g, f, p, h), l[b++] = g, l[b++] = f, l[b++] = p, l[b++] = h; } - return N(l), ce(...g), u; + return L(l), pe(...v), u; }, - decrypt(a, i) { - Hr(a); - const s = Gr(t); - let c = n; - const l = [s]; - (!W || !X(c)) && l.push(c = se(c)); - const u = A(c); - N(u), i = et(a.length, i), Jt(a, i), (!W || !X(a)) && l.push(a = se(a)); - const d = A(a), g = A(i); - N(d); - let w = u[0], v = u[1], f = u[2], h = u[3]; - for (let p = 0; p + 4 <= d.length; ) { - const b = w, m = v, P = f, T = h; - w = d[p + 0], v = d[p + 1], f = d[p + 2], h = d[p + 3]; - const { s0: E, s1: _, s2: K, s3: S } = Vr(s, w, v, f, h); - g[p++] = E ^ b, g[p++] = _ ^ m, g[p++] = K ^ P, g[p++] = S ^ T; + decrypt(i, a) { + Ro(i); + const c = Po(t); + let s = n; + const l = [c]; + (!Y || !oe(s)) && l.push(s = he(s)); + const u = S(s); + L(u), a = kt(i.length, a), mn(i, a), (!Y || !oe(i)) && l.push(i = he(i)); + const y = S(i), v = S(a); + L(y); + let w = u[0], g = u[1], f = u[2], p = u[3]; + for (let h = 0; h + 4 <= y.length; ) { + const b = w, m = g, K = f, F = p; + w = y[h + 0], g = y[h + 1], f = y[h + 2], p = y[h + 3]; + const { s0: E, s1: R, s2: A, s3: x } = Ko(c, w, g, f, p); + v[h++] = E ^ b, v[h++] = R ^ m, v[h++] = A ^ K, v[h++] = x ^ F; } - return N(g), ce(...l), Fr(i, o); + return L(v), pe(...l), Co(a, o); } }; }); -function cn(e, t) { - const n = Te(new Uint8Array([2]), Fe(t)); - return mt.getSharedSecret(e, n, !0).slice(1, 33); +function In(e, t) { + const n = _e(new Uint8Array([2]), dt(t)); + return Bt.getSharedSecret(e, n, !0).slice(1, 33); } -function Yr(e, t, n, r) { - const o = cn(e, t), a = bt(16), i = sn(o, a).encrypt(ve(n)); - return `${ye.encode(i)}?iv=${ye.encode(a)}`; +function So(e, t, n, r) { + const o = In(e, t), i = xe(16), a = Nn(o, i).encrypt(ue(n)); + return `${we.encode(a)}?iv=${we.encode(i)}`; } -function Qr(e, t, n) { +function No(e, t, n) { const r = n.indexOf("?iv="); if (r === -1) throw new Error('NIP-04 payload is missing its "?iv=" suffix.'); - const o = ye.decode(n.slice(0, r)), a = ye.decode(n.slice(r + 4)), i = cn(e, t), s = sn(i, a).decrypt(o); - return Ve(s); + const o = we.decode(n.slice(0, r)), i = we.decode(n.slice(r + 4)), a = In(e, t), c = Nn(a, i).decrypt(o); + return ct(c); } -function Xr(...e) { - for (const t of e) - t && t.fill(0); -} -class xe { +class Ue { privateKey; publicKeyHex; destroyed = !1; constructor(t) { - this.privateKey = t, this.publicKeyHex = x(t); + this.privateKey = t, this.publicKeyHex = _(t); } assertAlive() { if (this.destroyed) @@ -3448,7 +3520,7 @@ class xe { return this.assertAlive(), this.publicKeyHex; } signEvent(t) { - return this.assertAlive(), Z({ + return this.assertAlive(), ee({ pubkey: this.publicKeyHex, created_at: t.created_at ?? Math.floor(Date.now() / 1e3), kind: t.kind, @@ -3457,68 +3529,466 @@ class xe { }, this.privateKey); } nip44Encrypt(t, n) { - return this.assertAlive(), Ur(ut(this.privateKey, t), n); + return this.assertAlive(), go(Tt(this.privateKey, t), n); } nip44Decrypt(t, n) { - return this.assertAlive(), Dr(ut(this.privateKey, t), n); + return this.assertAlive(), wo(Tt(this.privateKey, t), n); } /** Legacy relative to nip44Encrypt above, but still what a real NIP-07 extension exposes as * window.nostr.nip04.encrypt -- implemented for drop-in parity. */ nip04Encrypt(t, n) { - return this.assertAlive(), Yr(this.privateKey, t, n); + return this.assertAlive(), So(this.privateKey, t, n); } nip04Decrypt(t, n) { - return this.assertAlive(), Qr(this.privateKey, t, n); + return this.assertAlive(), No(this.privateKey, t, n); } /** Best-practical secret wipe (§11.10, §21.4): overwrites the private key buffer in place. */ destroy() { - Xr(this.privateKey), this.destroyed = !0; + ge(this.privateKey), this.destroyed = !0; } } -const Zr = [ +const Io = [ "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band", "wss://nostr.wine", "wss://relay.snort.social" -], eo = [ +], To = [ "wss://purplepag.es", "wss://relay.nostr.band", "wss://nostr-pub.wellorder.net" -], to = "bitlogin", ee = "kv", F = "device-keys", no = 2; -function ro() { +], Tn = "bitlogin.connection.v1", Ln = "bitlogin.connection.nwc.v1", Lo = "bitlogin/connection-vault-root/v1", Uo = "bitlogin/connection-vault-signing/v1", Oo = "bitlogin/connection-record-encryption/v1", Mo = "bitlogin/connection-vault-personal/v1", rt = "bitlogin:connection:"; +function Do(e) { + if (e.length !== 32) + throw new Error("connection_vault_root must be exactly 32 bytes."); + return yt(Ft(Lo), e); +} +function Ee(e) { + return sr(e, Uo).scalar; +} +function Vo(e) { + return _(Ee(e)); +} +function qo(e, t) { + if (t.length !== 32) + throw new Error("vault_sudo_key must be exactly 32 bytes."); + if (e.length !== 32) + throw new Error("connection_vault_root must be exactly 32 bytes."); + return yt(Ft(Mo), _e(e, t)); +} +function Un(e, t) { + const n = Pt(t); + return Gt(e, _e(ue(Oo), new Uint8Array([0]), n), 32); +} +function jo() { + return H(xe(16)); +} +function Pt(e) { + const t = J(e); + if (t.length !== 16) + throw new Error("connection_id must decode to exactly 16 bytes (§CV7)."); + return t; +} +function On(e) { + return Pt(e), `${rt}${e}`; +} +function Mn(e) { + if (!e.startsWith(rt)) + return null; + const t = e.slice(rt.length); + try { + return Pt(t), t; + } catch { + return null; + } +} +const Ut = 120, $o = /* @__PURE__ */ new Set(["active", "suspended", "deleted"]), Wo = /* @__PURE__ */ new Set(["connectable", "personal"]); +class ve extends Error { + constructor(t) { + super(t), this.name = "ConnectionRecordError"; + } +} +function Dn(e, t) { + return ue(`bitlogin|connection-record|v1|${e}|30078|${t}`); +} +function Vn(e) { + const t = e, n = (i) => { + throw new ve(i); + }; + (!t || typeof t != "object") && n("Connection record must be an object."), t.schema !== Tn && n("Unsupported connection record schema (§CV8.3)."), typeof t.connection_id != "string" && n("connection_id must be a string (§CV7)."), (typeof t.connection_type != "string" || t.connection_type.length === 0) && n("connection_type must be a non-empty string (§CV8.3)."), Wo.has(t.tier) || n("tier must be connectable or personal."), $o.has(t.state) || n("state must be active, suspended, or deleted (§CV8.3)."), (typeof t.label != "string" || t.label.length > Ut) && n(`label must be a string of at most ${Ut} characters.`), (!Number.isInteger(t.created_at) || !Number.isInteger(t.updated_at)) && n("created_at and updated_at must be integers (§CV8.3)."); + const r = t.credential; + (!r || typeof r != "object" || typeof r.schema != "string") && n("credential must be an object naming its profile schema (§CV8.3)."); + const o = t.application_binding; + (!o || typeof o != "object" || o.origin !== null && typeof o.origin != "string" || o.app_pubkey !== null && typeof o.app_pubkey != "string") && n("application_binding must carry origin and app_pubkey (string or null)."), t.notes !== null && typeof t.notes != "string" && n("notes must be a string or null."); +} +async function Je(e) { + Vn(e.record); + const t = Ee(e.vaultPrk), n = _(t), r = On(e.record.connection_id), o = Un(e.recordPrk, e.record.connection_id), i = await gt(e.record, o, Dn(n, r)); + return ee({ + pubkey: n, + created_at: ht(e.previousCreatedAt, e.now), + kind: te, + tags: [["d", r]], + content: JSON.stringify(i) + }, t); +} +async function zo(e, t, n) { + if (!ie(e)) + throw new ve("Connection record event has an invalid id or signature."); + const r = _(Ee(t)); + if (e.pubkey !== r) + throw new ve("Connection record event is not signed by this vault's identity."); + const o = ut(e, "d") ?? "", i = Mn(o); + if (i === null) + throw new ve("Connection record event has a malformed d tag."); + const a = JSON.parse(e.content), c = Dn(e.pubkey, o), s = [ + { prk: t, tier: "connectable" }, + ...n ? [{ prk: n, tier: "personal" }] : [] + ]; + for (const l of s) { + let u; + try { + u = await wt(a, Un(l.prk, i), c); + } catch { + continue; + } + if (Vn(u), u.connection_id !== i) + throw new ve("Connection record id does not match its d tag."); + if (u.tier !== l.tier) + throw new ve("Connection record tier does not match the key that decrypted it."); + return { record: u, tier: l.tier, event: e }; + } + return null; +} +function Bo(e, t) { + return { + ...e, + state: "deleted", + credential: { schema: e.credential.schema }, + notes: null, + updated_at: t + }; +} +const je = /^[0-9a-f]{64}$/u; +class re extends Error { + constructor(t) { + super(t), this.name = "NwcParseError"; + } +} +function Ot(e) { + const t = e.trim(); + if (!/^nostr\+walletconnect:\/\//iu.test(t)) + throw new re("Not an NWC URI: it must start with nostr+walletconnect://"); + let n; + try { + n = new URL(t.replace(/^nostr\+walletconnect:\/\//iu, "http://")); + } catch { + throw new re("The NWC URI is malformed."); + } + const r = n.hostname.toLowerCase(); + if (!je.test(r)) + throw new re("The NWC URI's wallet service pubkey is not 64-char hex."); + const o = [], i = []; + let a = null, c = null; + for (const [s, l] of n.searchParams.entries()) + if (s === "relay") { + let u; + try { + u = new URL(l); + } catch { + throw new re("A relay parameter in the NWC URI is not a valid URL."); + } + if (u.protocol !== "wss:" && u.protocol !== "ws:") + throw new re("A relay parameter in the NWC URI is not a websocket URL."); + o.push(l); + } else if (s === "secret") { + const u = l.toLowerCase(); + if (!je.test(u)) + throw new re("The NWC URI's secret is not a 64-char hex client key."); + a = u; + } else s === "lud16" ? c = l : i.push([s, l]); + if (o.length === 0) + throw new re("The NWC URI names no relay."); + if (a === null) + throw new re("The NWC URI carries no secret."); + return { + schema: Ln, + wallet_pubkey: r, + relays: o, + secret: a, + lud16: c, + extra_params: i + }; +} +function Go(e) { + qn(e); + const t = new URLSearchParams(); + for (const n of e.relays) + t.append("relay", n); + t.append("secret", e.secret), e.lud16 !== null && t.append("lud16", e.lud16); + for (const [n, r] of e.extra_params) + t.append(n, r); + return `nostr+walletconnect://${e.wallet_pubkey}?${t.toString()}`; +} +function Fo(e, t) { + return e.wallet_pubkey === t.wallet_pubkey && e.secret === t.secret; +} +function qn(e) { + const t = e, n = (r) => { + throw new re(r); + }; + (!t || typeof t != "object") && n("NWC credential must be an object."), t.schema !== Ln && n("NWC credential has the wrong schema."), (typeof t.wallet_pubkey != "string" || !je.test(t.wallet_pubkey)) && n("NWC credential wallet_pubkey must be 64-char lowercase hex."), (!Array.isArray(t.relays) || t.relays.length === 0 || t.relays.some((r) => typeof r != "string")) && n("NWC credential must name at least one relay."), (typeof t.secret != "string" || !je.test(t.secret)) && n("NWC credential secret must be 64-char lowercase hex."), t.lud16 !== null && typeof t.lud16 != "string" && n("NWC credential lud16 must be a string or null."), (!Array.isArray(t.extra_params) || t.extra_params.some((r) => !Array.isArray(r) || r.length !== 2 || typeof r[0] != "string" || typeof r[1] != "string")) && n("NWC credential extra_params must be [key, value] string pairs."); +} +function jn(e, t) { + return `bitlogin:vault-hwm:${e}:${t}`; +} +async function $n(e, t, n) { + const r = await e.get(jn(t, n)); + return r ? JSON.parse(r) : null; +} +async function Wn(e, t, n, r) { + const o = await $n(e, t, n); + o && o.createdAt > r.createdAt || o && o.createdAt === r.createdAt && o.eventId <= r.eventId || await e.set(jn(t, n), JSON.stringify(r)); +} +async function Ho(e) { + const t = Ee(e.vaultPrk), n = new C(e.relayUrls, { authPrivateKey: t }); + let r; + try { + r = await me(n, e.event, { + dTag: On(e.connectionId), + minAcks: e.minAcknowledgements, + // The readback bar follows the ack bar: a caller publishing to fewer + // relays (a targeted repair, a test) has already lowered its quorum. + minReadbacks: e.minAcknowledgements, + timeoutMs: e.timeoutMs + }); + } finally { + n.closeAll(); + } + return r.success && await Wn(e.store, e.event.pubkey, e.connectionId, { + createdAt: e.event.created_at, + eventId: e.event.id + }), r; +} +const Mt = 500; +async function Jo(e) { + const t = Ee(e.vaultPrk), n = _(t), r = new C(e.relayUrls, { authPrivateKey: t }); + let o; + try { + o = await r.queryQuorum({ kinds: [te], authors: [n], limit: Mt }, e.timeoutMs); + } finally { + r.closeAll(); + } + const i = o.outcomes.some((l) => l.events.length >= Mt), a = /* @__PURE__ */ new Map(); + for (const l of o.outcomes.flatMap((u) => u.events)) { + if (!ie(l) || l.pubkey !== n) + continue; + const u = Mn(ut(l, "d") ?? ""); + if (u === null) + continue; + const y = a.get(u); + (!y || l.created_at > y.created_at) && a.set(u, l); + } + const c = /* @__PURE__ */ new Map(), s = []; + for (const [l, u] of a) { + const y = await $n(e.store, n, l); + if (y !== null && (u.created_at < y.createdAt || u.created_at === y.createdAt && u.id < y.eventId)) { + s.push(l); + continue; + } + c.set(l, u), await Wn(e.store, n, l, { + createdAt: u.created_at, + eventId: u.id + }); + } + return { + events: c, + rollbackWarnings: s, + quorumMet: o.quorumMet, + respondedCount: o.respondedCount, + truncated: i + }; +} +class Yo { + vaultPrk; + personalPrk = null; + destroyed = !1; + connectionVaultRoot; + vaultPublicKey; + constructor(t) { + this.connectionVaultRoot = t.slice(), this.vaultPrk = Do(this.connectionVaultRoot), this.vaultPublicKey = Vo(this.vaultPrk); + } + get sudoActive() { + return this.personalPrk !== null; + } + /** Opens a sudo window. Consumes (wipes) the caller's sudo key copy. */ + enableSudo(t) { + this.endSudo(), this.personalPrk = qo(this.connectionVaultRoot, t), ge(t); + } + /** Closes the sudo window and wipes the personal-tier key material. */ + endSudo() { + this.personalPrk && ge(this.personalPrk), this.personalPrk = null; + } + /** + * Wipes everything this session holds, permanently. + * + * The ROOT is wiped too, not just the derived prk: the root regenerates the + * prk and (with a sudo key) the personal prk, so leaving it live made + * "wipes everything" false. And the session is marked destroyed rather than + * merely zeroed, because a zeroed prk is not inert -- deriveRecordKey and + * deriveVaultSigningKey over 32 zero bytes are deterministic, WORLD- + * COMPUTABLE values. A stale reference calling createConnection() after + * teardown would otherwise seal a wallet secret under a key any observer + * can derive, sign it with a publicly known identity, and report success. + * Failing loudly is the only safe behaviour. + */ + destroy() { + this.endSudo(), ge(this.vaultPrk, this.connectionVaultRoot), this.destroyed = !0; + } + prkForTier(t) { + if (this.destroyed) + throw new Error("This vault session was destroyed; create a new one from the account's root."); + if (t === "connectable") + return this.vaultPrk; + if (!this.personalPrk) + throw new Error("Personal-tier records require an open sudo window (enableSudo)."); + return this.personalPrk; + } + /** Builds a fresh record + its signed event. Purely local; publish separately. */ + async createConnection(t) { + const n = t.now ?? Math.floor(Date.now() / 1e3), r = { + schema: Tn, + connection_id: jo(), + connection_type: t.connection_type, + tier: t.tier, + state: "active", + label: t.label, + created_at: n, + updated_at: n, + credential: t.credential, + application_binding: t.application_binding ?? { origin: null, app_pubkey: null }, + notes: t.notes ?? null + }, o = await Je({ + vaultPrk: this.vaultPrk, + recordPrk: this.prkForTier(t.tier), + record: r, + now: n + }); + return { record: r, event: o }; + } + /** Replaces a record's content. The tier is immutable — moving a secret + * between tiers is a delete-and-recreate, never a silent re-encryption. */ + async updateConnection(t, n, r) { + const o = r ?? Math.floor(Date.now() / 1e3), i = { + ...t.record, + ...n, + tier: t.record.tier, + connection_id: t.record.connection_id, + created_at: t.record.created_at, + updated_at: o + }, a = await Je({ + vaultPrk: this.vaultPrk, + recordPrk: this.prkForTier(i.tier), + record: i, + previousCreatedAt: t.event.created_at, + now: o + }); + return { record: i, event: a }; + } + /** §CV11 step 2: the encrypted tombstone replacement. */ + async deleteConnection(t, n) { + const r = n ?? Math.floor(Date.now() / 1e3), o = Bo(t.record, r), i = await Je({ + vaultPrk: this.vaultPrk, + recordPrk: this.prkForTier(o.tier), + record: o, + previousCreatedAt: t.event.created_at, + now: r + }); + return { record: o, event: i }; + } + /** Trial-decrypts one event; personal-tier records resolve only inside a sudo window. */ + decryptEvent(t) { + return this.destroyed ? Promise.reject(new Error("This vault session was destroyed; create a new one from the account's root.")) : zo(t, this.vaultPrk, this.personalPrk ?? void 0); + } + /** §CV11 step 3: a NIP-09 deletion request for a replaced record event, + * signed by the vault identity. Best-effort by contract — the encrypted + * tombstone is the durable part of a deletion, this is the courtesy ask. */ + buildDeletionRequest(t, n) { + if (this.destroyed) + throw new Error("This vault session was destroyed; create a new one from the account's root."); + return bn({ + privateKey: Ee(this.vaultPrk), + eventIdToDelete: t, + deletedEventKind: te, + createdAt: n ?? Math.floor(Date.now() / 1e3) + }); + } + publish(t) { + return Ho({ vaultPrk: this.vaultPrk, ...t }); + } + fetchEvents(t) { + return Jo({ vaultPrk: this.vaultPrk, ...t }); + } + /** + * Fetches and decrypts everything decryptable right now. Outside a sudo + * window the personal tier is simply absent from the result — invisible, + * not erroring, exactly like the app-facing API contract. + */ + async listConnections(t) { + const n = await this.fetchEvents(t); + if (!n.quorumMet && !t.acknowledgeIncompleteQuorum) + throw new Error("Not enough vault relays answered to list your connections reliably. Check your connection and retry."); + const r = [], o = []; + for (const i of n.events.values()) + try { + const a = await this.decryptEvent(i); + a && r.push(a); + } catch { + o.push(i.id); + } + return r.sort((i, a) => a.record.updated_at - i.record.updated_at), { + connections: r, + rollbackWarnings: n.rollbackWarnings, + unreadable: o, + truncated: n.truncated, + quorumMet: n.quorumMet + }; + } +} +const Qo = "bitlogin", ae = "kv", Q = "device-keys", Xo = 2; +function Zo() { return new Promise((e, t) => { - const n = indexedDB.open(to, no); + const n = indexedDB.open(Qo, Xo); n.onupgradeneeded = () => { const r = n.result; - r.objectStoreNames.contains(ee) || r.createObjectStore(ee), r.objectStoreNames.contains(F) || r.createObjectStore(F); + r.objectStoreNames.contains(ae) || r.createObjectStore(ae), r.objectStoreNames.contains(Q) || r.createObjectStore(Q); }, n.onsuccess = () => e(n.result), n.onerror = () => t(n.error); }); } -class oo { +class ei { dbPromise = null; db() { - return this.dbPromise || (this.dbPromise = ro()), this.dbPromise; + return this.dbPromise || (this.dbPromise = Zo()), this.dbPromise; } async get(t) { const n = await this.db(); return new Promise((r, o) => { - const i = n.transaction(ee, "readonly").objectStore(ee).get(t); - i.onsuccess = () => r(i.result), i.onerror = () => o(i.error); + const a = n.transaction(ae, "readonly").objectStore(ae).get(t); + a.onsuccess = () => r(a.result), a.onerror = () => o(a.error); }); } async set(t, n) { const r = await this.db(); - return new Promise((o, a) => { - const i = r.transaction(ee, "readwrite"); - i.objectStore(ee).put(n, t), i.oncomplete = () => o(), i.onerror = () => a(i.error); + return new Promise((o, i) => { + const a = r.transaction(ae, "readwrite"); + a.objectStore(ae).put(n, t), a.oncomplete = () => o(), a.onerror = () => i(a.error); }); } async delete(t) { const n = await this.db(); return new Promise((r, o) => { - const a = n.transaction(ee, "readwrite"); - a.objectStore(ee).delete(t), a.oncomplete = () => r(), a.onerror = () => o(a.error); + const i = n.transaction(ae, "readwrite"); + i.objectStore(ae).delete(t), i.oncomplete = () => r(), i.onerror = () => o(i.error); }); } /** @@ -3527,9 +3997,9 @@ class oo { * API so callers cannot accidentally serialize it as application data. */ async getOrCreateDeviceKey(t) { - const n = await this.db(), r = await new Promise((a, i) => { - const s = n.transaction(F, "readonly").objectStore(F).get(t); - s.onsuccess = () => a(s.result), s.onerror = () => i(s.error); + const n = await this.db(), r = await new Promise((i, a) => { + const c = n.transaction(Q, "readonly").objectStore(Q).get(t); + c.onsuccess = () => i(c.result), c.onerror = () => a(c.error); }); if (r) return r; const o = await crypto.subtle.generateKey( @@ -3538,140 +4008,206 @@ class oo { ["encrypt", "decrypt"] ); try { - return await new Promise((a, i) => { - const s = n.transaction(F, "readwrite"); - s.objectStore(F).add(o, t), s.oncomplete = () => a(), s.onerror = () => i(s.error); + return await new Promise((i, a) => { + const c = n.transaction(Q, "readwrite"); + c.objectStore(Q).add(o, t), c.oncomplete = () => i(), c.onerror = () => a(c.error); }), o; } catch { - const a = await new Promise((i, s) => { - const c = n.transaction(F, "readonly").objectStore(F).get(t); - c.onsuccess = () => i(c.result), c.onerror = () => s(c.error); + const i = await new Promise((a, c) => { + const s = n.transaction(Q, "readonly").objectStore(Q).get(t); + s.onsuccess = () => a(s.result), s.onerror = () => c(s.error); }); - if (a) return a; + if (i) return i; throw new Error("Unable to create the browser-bound session key."); } } async deleteDeviceKey(t) { const n = await this.db(); return new Promise((r, o) => { - const a = n.transaction(F, "readwrite"); - a.objectStore(F).delete(t), a.oncomplete = () => r(), a.onerror = () => o(a.error); + const i = n.transaction(Q, "readwrite"); + i.objectStore(Q).delete(t), i.oncomplete = () => r(), i.onerror = () => o(i.error); }); } } -const _e = "bitlogin:session:v1", rt = "bitlogin:session-device-key:v1"; -function yt(e) { +const Te = "bitlogin:session:v1", Kt = "bitlogin:session-device-key:v1"; +function Dt(e) { let t = ""; for (const n of e) t += String.fromCharCode(n); return btoa(t); } -function pt(e) { +function Vt(e) { const t = atob(e); return Uint8Array.from(t, (n) => n.charCodeAt(0)); } -function ht(e) { +function qt(e) { const t = new Uint8Array(e.byteLength); return t.set(e), t.buffer; } -function ao(e) { +function ti(e) { return !!(e && typeof e == "object" && e.v === 2 && typeof e.iv == "string" && typeof e.ciphertext == "string"); } -async function io(e, t) { +async function ni(e, t) { const n = { everydayPrivateKeyHex: Array.from(t.everydayPrivateKey, (r) => r.toString(16).padStart(2, "0")).join(""), accountId: t.accountId, recoveryPublicKey: t.recoveryPublicKey, activeCredentialEvent: t.activeCredentialEvent, - activeRecoveryEvent: t.activeRecoveryEvent + activeRecoveryEvent: t.activeRecoveryEvent, + ...t.connectionVaultRoot ? { + connectionVaultRootHex: Array.from( + t.connectionVaultRoot, + (r) => r.toString(16).padStart(2, "0") + ).join("") + } : {}, + ...t.vaultEnabled !== void 0 ? { vaultEnabled: t.vaultEnabled } : {} }; try { if (typeof e.getOrCreateDeviceKey != "function") { - await e.delete(_e); + await e.delete(Te); return; } - const r = await e.getOrCreateDeviceKey(rt), o = crypto.getRandomValues(new Uint8Array(12)), a = new TextEncoder().encode(JSON.stringify(n)), i = await crypto.subtle.encrypt({ name: "AES-GCM", iv: o }, r, a), s = { + const r = await e.getOrCreateDeviceKey(Kt), o = crypto.getRandomValues(new Uint8Array(12)), i = new TextEncoder().encode(JSON.stringify(n)), a = await crypto.subtle.encrypt({ name: "AES-GCM", iv: o }, r, i), c = { v: 2, - iv: yt(o), - ciphertext: yt(new Uint8Array(i)) + iv: Dt(o), + ciphertext: Dt(new Uint8Array(a)) }; - await e.set(_e, JSON.stringify(s)); + await e.set(Te, JSON.stringify(c)); } catch { } } -async function so(e) { +async function ri(e) { let t; try { - t = await e.get(_e); + t = await e.get(Te); } catch { return null; } if (!t) return null; try { const n = JSON.parse(t); - if (!ao(n) || typeof e.getOrCreateDeviceKey != "function") - return await e.delete(_e), null; - const r = await e.getOrCreateDeviceKey(rt), o = await crypto.subtle.decrypt( - { name: "AES-GCM", iv: ht(pt(n.iv)) }, + if (!ti(n) || typeof e.getOrCreateDeviceKey != "function") + return await e.delete(Te), null; + const r = await e.getOrCreateDeviceKey(Kt), o = await crypto.subtle.decrypt( + { name: "AES-GCM", iv: qt(Vt(n.iv)) }, r, - ht(pt(n.ciphertext)) - ), a = JSON.parse(new TextDecoder().decode(o)); - return typeof a.everydayPrivateKeyHex != "string" || typeof a.accountId != "string" || typeof a.recoveryPublicKey != "string" || !a.activeCredentialEvent || !a.activeRecoveryEvent ? null : { + qt(Vt(n.ciphertext)) + ), i = JSON.parse(new TextDecoder().decode(o)); + return typeof i.everydayPrivateKeyHex != "string" || typeof i.accountId != "string" || typeof i.recoveryPublicKey != "string" || !i.activeCredentialEvent || !i.activeRecoveryEvent ? null : { everydayPrivateKey: Uint8Array.from( - a.everydayPrivateKeyHex.match(/.{1,2}/g) || [], - (i) => Number.parseInt(i, 16) + i.everydayPrivateKeyHex.match(/.{1,2}/g) || [], + (a) => Number.parseInt(a, 16) ), - accountId: a.accountId, - recoveryPublicKey: a.recoveryPublicKey, - activeCredentialEvent: a.activeCredentialEvent, - activeRecoveryEvent: a.activeRecoveryEvent + accountId: i.accountId, + recoveryPublicKey: i.recoveryPublicKey, + activeCredentialEvent: i.activeCredentialEvent, + activeRecoveryEvent: i.activeRecoveryEvent, + ...typeof i.connectionVaultRootHex == "string" ? { + connectionVaultRoot: Uint8Array.from( + i.connectionVaultRootHex.match(/.{1,2}/g) || [], + (a) => Number.parseInt(a, 16) + ) + } : {}, + ...typeof i.vaultEnabled == "boolean" ? { vaultEnabled: i.vaultEnabled } : {} }; } catch { return null; } } -async function co(e) { +async function oi(e) { try { - await e.delete(_e), typeof e.deleteDeviceKey == "function" && await e.deleteDeviceKey(rt); + await e.delete(Te), typeof e.deleteDeviceKey == "function" && await e.deleteDeviceKey(Kt); } catch { } } -const y = { +const d = { signer: null, everydayPrivateKey: null, accountId: null, recoveryPublicKey: null, activeCredentialEvent: null, activeRecoveryEvent: null, - pendingRecovery: null + pendingRecovery: null, + connectionVaultRoot: null, + vaultKnown: !1, + vault: null }; -let Y = [...Zr], De = [...eo]; -const be = new oo(); -function Q() { - if (!y.signer || !y.everydayPrivateKey) +let U = [...Io], Ye = [...To]; +const X = new ei(); +function ne() { + if (!d.signer || !d.everydayPrivateKey) throw new Error("No identity is unlocked in this session."); - return { signer: y.signer, everydayPrivateKey: y.everydayPrivateKey }; + return { signer: d.signer, everydayPrivateKey: d.everydayPrivateKey }; } -function we() { - y.signer?.destroy(), y.everydayPrivateKey && y.everydayPrivateKey.fill(0), y.signer = null, y.everydayPrivateKey = null, y.accountId = null, y.recoveryPublicKey = null, y.activeCredentialEvent = null, y.activeRecoveryEvent = null, y.pendingRecovery && (y.pendingRecovery.recoveryPrivateKey.fill(0), y.pendingRecovery.everydayPrivateKey.fill(0), y.pendingRecovery = null); +function Ke() { + d.signer?.destroy(), d.everydayPrivateKey && d.everydayPrivateKey.fill(0), d.signer = null, d.everydayPrivateKey = null, d.accountId = null, d.recoveryPublicKey = null, d.activeCredentialEvent = null, d.activeRecoveryEvent = null, d.vault?.destroy(), d.vault = null, d.connectionVaultRoot && d.connectionVaultRoot.fill(0), d.connectionVaultRoot = null, d.vaultKnown = !1, d.pendingRecovery && (d.pendingRecovery.recoveryPrivateKey.fill(0), d.pendingRecovery.everydayPrivateKey.fill(0), d.pendingRecovery = null); } -async function Re() { - !y.everydayPrivateKey || !y.accountId || !y.recoveryPublicKey || !y.activeCredentialEvent || !y.activeRecoveryEvent || await io(be, { - everydayPrivateKey: y.everydayPrivateKey, - accountId: y.accountId, - recoveryPublicKey: y.recoveryPublicKey, - activeCredentialEvent: y.activeCredentialEvent, - activeRecoveryEvent: y.activeRecoveryEvent +function Qe(e, t) { + d.connectionVaultRoot = e ?? null, d.vaultKnown = !0, d.vault = null, t && ge(t); +} +async function Oe() { + !d.everydayPrivateKey || !d.accountId || !d.recoveryPublicKey || !d.activeCredentialEvent || !d.activeRecoveryEvent || await ni(X, { + everydayPrivateKey: d.everydayPrivateKey, + accountId: d.accountId, + recoveryPublicKey: d.recoveryPublicKey, + activeCredentialEvent: d.activeCredentialEvent, + activeRecoveryEvent: d.activeRecoveryEvent, + ...d.connectionVaultRoot ? { connectionVaultRoot: d.connectionVaultRoot } : {}, + ...d.vaultKnown ? { vaultEnabled: d.connectionVaultRoot !== null } : {} }); } -async function lo(e, t) { +function Re() { + try { + return new URL(self.location.href).origin; + } catch { + return ""; + } +} +function ot() { + if (!d.signer) throw new Error("No identity is unlocked in this session."); + if (!d.connectionVaultRoot) + throw new Error( + d.vaultKnown ? "This account predates the Connection Vault. Enable it from your BitLogin account manager (recovery phrase required)." : "Sign in again to use wallet connections on this device." + ); + return d.vault ??= new Yo(d.connectionVaultRoot.slice()), d.vault; +} +function Ae(e) { + const { record: t } = e, n = { + connectionId: t.connection_id, + connectionType: t.connection_type, + label: t.label, + state: t.state, + origin: t.application_binding.origin, + createdAt: t.created_at, + updatedAt: t.updated_at + }; + if (t.connection_type === "nwc" && t.state !== "deleted") { + const r = t.credential; + n.walletPubkey = r.wallet_pubkey, n.relayCount = r.relays?.length; + } + return n; +} +async function Ve() { + const e = ot(), t = await e.listConnections({ relayUrls: U, store: X }); + return { + vault: e, + connections: t.connections.filter((n) => n.record.state !== "deleted"), + rollbackWarnings: t.rollbackWarnings + }; +} +async function Xe(e) { + const { vault: t, connections: n } = await Ve(), r = n.find((o) => o.record.connection_id === e); + if (!r) throw new Error("That connection no longer exists."); + return { vault: t, connection: r }; +} +async function ii(e, t) { switch (e) { case "configure": { const n = t; - return n.vaultRelayUrls?.length && (Y = n.vaultRelayUrls), n.discoveryRelayUrls?.length && (De = n.discoveryRelayUrls), {}; + return n.vaultRelayUrls?.length && (U = n.vaultRelayUrls), n.discoveryRelayUrls?.length && (Ye = n.discoveryRelayUrls), {}; } case "register": { - const n = t, r = n.importKey ? await fr({ nsecOrHex: n.importKey, loginName: n.loginName, password: n.password, vaultRelayUrls: Y }) : await Ht({ loginName: n.loginName, password: n.password, vaultRelayUrls: Y }); - return we(), y.signer = new xe(r.everydayPrivateKey), y.everydayPrivateKey = r.everydayPrivateKey, y.accountId = r.accountId, y.recoveryPublicKey = r.recoveryPublicKey, y.activeCredentialEvent = r.credentialEvent, y.activeRecoveryEvent = r.recoveryEvent, await Re(), { + const n = t, r = n.importKey ? await Yr({ nsecOrHex: n.importKey, loginName: n.loginName, password: n.password, vaultRelayUrls: U }) : await fn({ loginName: n.loginName, password: n.password, vaultRelayUrls: U }); + return Ke(), d.signer = new Ue(r.everydayPrivateKey), d.everydayPrivateKey = r.everydayPrivateKey, d.accountId = r.accountId, d.recoveryPublicKey = r.recoveryPublicKey, d.activeCredentialEvent = r.credentialEvent, d.activeRecoveryEvent = r.recoveryEvent, Qe(r.connectionVaultRoot, r.vaultSudoKey), await Oe(), { recoveryPhrase: r.recoveryPhrase, everydayPublicKey: r.everydayPublicKey, recoveryPublicKey: r.recoveryPublicKey, @@ -3682,18 +4218,18 @@ async function lo(e, t) { }; } case "previewImportKey": { - const r = Wt(t.nsecOrHex), o = x(r), a = { everydayPublicKey: o, npub: it(o) }; - return r.fill(0), a; + const r = gn(t.nsecOrHex), o = _(r), i = { everydayPublicKey: o, npub: Ct(o) }; + return r.fill(0), i; } case "login": { - const n = t, r = await gr({ + const n = t, r = await Qr({ loginName: n.loginName, password: n.password, - vaultRelayUrls: Y, - store: be, + vaultRelayUrls: U, + store: X, acknowledgeRollback: n.acknowledgeRollback }); - return we(), y.signer = new xe(r.everydayPrivateKey), y.everydayPrivateKey = r.everydayPrivateKey, y.accountId = r.accountId, y.recoveryPublicKey = r.recoveryPublicKey, y.activeCredentialEvent = r.credentialEvent, y.activeRecoveryEvent = r.recoveryCapsuleEvent, await Re(), { + return Ke(), d.signer = new Ue(r.everydayPrivateKey), d.everydayPrivateKey = r.everydayPrivateKey, d.accountId = r.accountId, d.recoveryPublicKey = r.recoveryPublicKey, d.activeCredentialEvent = r.credentialEvent, d.activeRecoveryEvent = r.recoveryCapsuleEvent, Qe(r.connectionVaultRoot, r.vaultSudoKey), await Oe(), { everydayPublicKey: r.everydayPublicKey, accountId: r.accountId, generation: r.generation, @@ -3702,13 +4238,15 @@ async function lo(e, t) { }; } case "recover": { - const n = t, r = await wr({ + const n = t, r = await Xr({ phrase: n.phrase, - vaultRelayUrls: Y, - discoveryRelayUrls: De, + vaultRelayUrls: U, + discoveryRelayUrls: Ye, offlineRecoveryCapsuleEvents: n.offlineExportFile?.recovery_capsule_events }); - return we(), y.pendingRecovery = r, y.signer = new xe(r.everydayPrivateKey), y.everydayPrivateKey = r.everydayPrivateKey, y.accountId = r.accountId, y.recoveryPublicKey = r.recoveryPublicKey, y.activeRecoveryEvent = r.currentRecoveryEvent, { + return Ke(), d.pendingRecovery = r, d.signer = new Ue(r.everydayPrivateKey), d.everydayPrivateKey = r.everydayPrivateKey, d.accountId = r.accountId, d.recoveryPublicKey = r.recoveryPublicKey, d.activeRecoveryEvent = r.currentRecoveryEvent, Qe( + r.currentRecoveryPayload.connection_vault_root ? J(r.currentRecoveryPayload.connection_vault_root) : void 0 + ), { everydayPublicKey: r.everydayPublicKey, accountId: r.accountId, generalRelays: r.generalRelays, @@ -3718,29 +4256,30 @@ async function lo(e, t) { } case "completeRecovery": { const n = t; - if (!y.pendingRecovery) throw new Error("No recovery is in progress in this session."); - const r = await br({ - recovered: y.pendingRecovery, + if (!d.pendingRecovery) throw new Error("No recovery is in progress in this session."); + const r = await Zr({ + recovered: d.pendingRecovery, newLoginName: n.newLoginName, newPassword: n.newPassword, - vaultRelayUrls: Y + vaultRelayUrls: U, + store: X }); - return y.activeCredentialEvent = r.credentialEvent, y.activeRecoveryEvent = r.refreshedRecoveryEvent, y.pendingRecovery.recoveryPrivateKey.fill(0), y.pendingRecovery = null, await Re(), { + return d.activeCredentialEvent = r.credentialEvent, d.activeRecoveryEvent = r.refreshedRecoveryEvent, d.pendingRecovery.recoveryPrivateKey.fill(0), d.pendingRecovery = null, await Oe(), { locatorPublicKey: r.locatorPublicKey, credentialEventId: r.credentialEvent.id, refreshedRecoveryEventId: r.refreshedRecoveryEvent.id }; } case "changePassword": { - const n = t, r = await kr({ + const n = t, r = await eo({ loginName: n.loginName, oldPassword: n.oldPassword, newPassword: n.newPassword, - vaultRelayUrls: Y, - store: be, + vaultRelayUrls: U, + store: X, acknowledgeRollback: n.acknowledgeRollback }); - return y.activeCredentialEvent = r.newCredentialEvent, y.recoveryPublicKey = r.recoveryPublicKey, y.activeRecoveryEvent = r.recoveryCapsuleEvent, await Re(), { + return d.activeCredentialEvent = r.newCredentialEvent, d.recoveryPublicKey = r.recoveryPublicKey, d.activeRecoveryEvent = r.recoveryCapsuleEvent, await Oe(), { newLocatorPublicKey: r.newLocatorPublicKey, newGeneration: r.newGeneration, tombstoneAcknowledgedCount: r.tombstoneAcknowledgedCount, @@ -3748,88 +4287,205 @@ async function lo(e, t) { }; } case "publishProfileAndRelayLists": { - const n = t, { everydayPrivateKey: r } = Q(); - return qn({ + const n = t, { everydayPrivateKey: r } = ne(); + return mr({ everydayPrivateKey: r, name: n.name, about: n.about, picture: n.picture, generalRelays: n.generalRelays, dmRelays: n.dmRelays, - discoveryRelays: De + discoveryRelays: Ye }); } case "getPublicKey": { - const { signer: n } = Q(); + const { signer: n } = ne(); return { publicKey: n.getPublicKey() }; } case "signEvent": { - const { signer: n } = Q(), r = t; + const { signer: n } = ne(), r = t; return n.signEvent({ kind: r.kind, tags: r.tags, content: r.content, created_at: r.created_at }); } case "nip44Encrypt": { - const { signer: n } = Q(), r = t; + const { signer: n } = ne(), r = t; return { ciphertext: n.nip44Encrypt(r.peerPublicKey, r.plaintext) }; } case "nip44Decrypt": { - const { signer: n } = Q(), r = t; + const { signer: n } = ne(), r = t; return { plaintext: n.nip44Decrypt(r.peerPublicKey, r.payload) }; } case "nip04Encrypt": { - const { signer: n } = Q(), r = t; + const { signer: n } = ne(), r = t; return { ciphertext: n.nip04Encrypt(r.peerPublicKey, r.plaintext) }; } case "nip04Decrypt": { - const { signer: n } = Q(), r = t; + const { signer: n } = ne(), r = t; return { plaintext: n.nip04Decrypt(r.peerPublicKey, r.payload) }; } case "exportIdentity": { - const { everydayPrivateKey: n, signer: r } = Q(); - return { nsec: Sn(n), npub: it(r.getPublicKey()) }; + const { everydayPrivateKey: n, signer: r } = ne(); + return { nsec: ur(n), npub: Ct(r.getPublicKey()) }; } case "buildRecoveryExport": { - if (Q(), !y.recoveryPublicKey || !y.activeRecoveryEvent) + if (ne(), !d.recoveryPublicKey || !d.activeRecoveryEvent) throw new Error("No recovery capsule is known in this session yet."); - return Cn({ - recoveryPublicKeyHex: y.recoveryPublicKey, - vaultRelayUrls: Y, - recoveryCapsuleEvents: [y.activeRecoveryEvent], + return lr({ + recoveryPublicKeyHex: d.recoveryPublicKey, + vaultRelayUrls: U, + recoveryCapsuleEvents: [d.activeRecoveryEvent], relayListEvents: [] }); } case "repairReplicas": { - if (!y.activeCredentialEvent || !y.activeRecoveryEvent) + if (!d.activeCredentialEvent || !d.activeRecoveryEvent) throw new Error("No active capsule events are known in this session yet."); - const n = new I(Y), r = await rr(n, y.activeCredentialEvent, y.activeRecoveryEvent); + const n = new C(U), r = await Mr(n, d.activeCredentialEvent, d.activeRecoveryEvent); return n.closeAll(), r; } case "getSessionStatus": - return { unlocked: !!y.signer, everydayPublicKey: y.signer?.getPublicKey() }; + return { unlocked: !!d.signer, everydayPublicKey: d.signer?.getPublicKey() }; // Called once, right after "configure", before the widget renders its welcome // screen -- restores whatever persistSession() last cached for this origin, so // a page reload doesn't ask for the login name + password again. A missing or // corrupt cache is not an error: it just means the widget falls through to its // normal welcome screen, exactly like it always has. case "restoreSession": { - const n = await so(be); - return n ? (we(), y.signer = new xe(n.everydayPrivateKey), y.everydayPrivateKey = n.everydayPrivateKey, y.accountId = n.accountId, y.recoveryPublicKey = n.recoveryPublicKey, y.activeCredentialEvent = n.activeCredentialEvent, y.activeRecoveryEvent = n.activeRecoveryEvent, { restored: !0, everydayPublicKey: y.signer.getPublicKey(), accountId: n.accountId }) : { restored: !1 }; + const n = await ri(X); + return n ? (Ke(), d.signer = new Ue(n.everydayPrivateKey), d.everydayPrivateKey = n.everydayPrivateKey, d.accountId = n.accountId, d.recoveryPublicKey = n.recoveryPublicKey, d.activeCredentialEvent = n.activeCredentialEvent, d.activeRecoveryEvent = n.activeRecoveryEvent, d.connectionVaultRoot = n.connectionVaultRoot ?? null, d.vaultKnown = n.vaultEnabled !== void 0, { restored: !0, everydayPublicKey: d.signer.getPublicKey(), accountId: n.accountId }) : { restored: !1 }; } case "logout": - return we(), await co(be), {}; + return Ke(), await oi(X), {}; + // ---- Connection Vault (connection-vault.md §12, reveal mode) ---- + case "vaultStatus": + return d.signer ? d.connectionVaultRoot ? { enabled: !0, vaultPublicKey: ot().vaultPublicKey } : { enabled: !1, reason: d.vaultKnown ? "no-vault" : "stale-cache" } : { enabled: !1 }; + case "vaultList": { + const { connections: n, rollbackWarnings: r } = await Ve(); + return { connections: n.map(Ae), rollbackWarnings: r }; + } + case "vaultSaveNwc": { + const n = t, r = Re(), o = ot(), i = Ot(n.uri), a = n.label.trim().slice(0, 120) || "Wallet connection", { record: c, event: s } = await o.createConnection({ + connection_type: "nwc", + tier: "connectable", + label: a, + credential: i, + application_binding: { origin: r, app_pubkey: null } + }); + if (!(await o.publish({ + event: s, + connectionId: c.connection_id, + relayUrls: U, + store: X + })).success) + throw new Error("The connection could not be saved to enough relays. Please try again."); + const u = await o.decryptEvent(s); + return Ae(u); + } + case "vaultFindForOrigin": { + const n = Re(), { connections: r } = await Ve(), o = r.find( + (i) => i.record.connection_type === "nwc" && i.record.state === "active" && i.record.application_binding.origin === n + ); + return { connection: o ? Ae(o) : null }; + } + case "vaultRevealNwc": { + const n = t, { connection: r } = await Xe(n.connectionId); + if (r.record.connection_type !== "nwc" || r.record.state !== "active") + throw new Error("That connection is not an active wallet connection."); + const o = r.record.application_binding.origin; + if (o !== null && o !== Re()) + throw new Error("That connection belongs to a different site."); + const i = r.record.credential; + return qn(i), { uri: Go(i) }; + } + case "vaultSetBinding": { + const n = t, { vault: r, connection: o } = await Xe(n.connectionId), i = n.origin === null ? null : Re(), { record: a, event: c } = await r.updateConnection(o, { + application_binding: { origin: i, app_pubkey: null } + }); + if (!(await r.publish({ + event: c, + connectionId: a.connection_id, + relayUrls: U, + store: X + })).success) throw new Error("The change could not reach enough relays. Please try again."); + const l = await r.decryptEvent(c); + return Ae(l); + } + case "vaultDelete": { + const n = t, { vault: r, connection: o } = await Xe(n.connectionId), { record: i, event: a } = await r.deleteConnection(o); + if (!(await r.publish({ + event: a, + connectionId: i.connection_id, + relayUrls: U, + store: X + })).success) throw new Error("The deletion could not reach enough relays. Please try again."); + try { + const s = r.buildDeletionRequest(o.event.id), l = new C(U); + await l.publishAll(s), l.closeAll(); + } catch { + } + return {}; + } + case "vaultOfferCheck": { + const n = t, r = Re(), o = Ot(n.uri), { connections: i } = await Ve(), a = i.find( + (c) => c.record.connection_type === "nwc" && Fo(c.record.credential, o) + ); + return a ? a.record.application_binding.origin !== r ? { duplicate: !1 } : { duplicate: !0, connection: Ae(a) } : { duplicate: !1 }; + } default: throw new Error(`Unknown worker action: ${e}`); } } +const ai = /* @__PURE__ */ new Set([ + "configure", + "register", + "previewImportKey", + "login", + "recover", + "completeRecovery", + "changePassword", + "publishProfileAndRelayLists", + "getPublicKey", + "signEvent", + "nip44Encrypt", + "nip44Decrypt", + "nip04Encrypt", + "nip04Decrypt", + "exportIdentity", + "buildRecoveryExport", + "repairReplicas", + "getSessionStatus", + "restoreSession", + "logout", + "vaultStatus", + "vaultList", + "vaultSaveNwc", + "vaultFindForOrigin", + "vaultRevealNwc", + "vaultSetBinding", + "vaultDelete", + "vaultOfferCheck" +]); self.addEventListener("message", (e) => { - const { id: t, action: n, payload: r } = e.data; - lo(n, r).then( - (o) => { - const a = { id: t, ok: !0, result: o }; + const t = e.data; + if (!t || typeof t != "object" || typeof t.id != "string") return; + if (typeof t.action != "string" || !ai.has(t.action)) { + const i = { + id: t.id, + ok: !1, + error: `Unknown worker action: ${String(t.action)}`, + errorName: "Error" + }; + self.postMessage(i); + return; + } + const { id: n, action: r, payload: o } = e.data; + ii(r, o).then( + (i) => { + const a = { id: n, ok: !0, result: i }; self.postMessage(a); }, - (o) => { - const a = o instanceof Error ? o : new Error(String(o)), i = { id: t, ok: !1, error: a.message, errorName: a.name }; - self.postMessage(i); + (i) => { + const a = i instanceof Error ? i : new Error(String(i)), c = { id: n, ok: !1, error: a.message, errorName: a.name }; + self.postMessage(c); } ); });