UNPKG

jobsys-explore

Version:

Enhanced component based on vant

1,587 lines 66.8 kB
var Fe = Object.defineProperty; var Ke = (t, n, e) => n in t ? Fe(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e; var L = (t, n, e) => (Ke(t, typeof n != "symbol" ? n + "" : n, e), e); import { isString as Ht, isObject as Mt, reduce as ze, find as je, flatMapDeep as Ye, isNull as Me, isUndefined as Ae, isFunction as Gt, cloneDeep as Ge, isDate as We, isBoolean as Je, isArray as Qe } from "lodash-es"; import de from "axios"; import { closeToast as Xe, allowMultipleToast as Zt, showLoadingToast as Dt, showSuccessToast as tn, showFailToast as Nt } from "vant"; import ge from "dayjs"; const ht = { STATE_CODE_SUCCESS: "SUCCESS", // 成功 STATE_CODE_FAIL: "FAIL", // 失败 STATE_CODE_NOT_FOUND: "NOT_FOUND", // 找不到资源 STATE_CODE_INFO_NOT_COMPLETE: "INCOMPLETE", // 信息不完整 STATE_CODE_NOT_ALLOWED: "NOT_ALLOWED" //没有权限 }; function Sr(t) { Object.keys(t).forEach((n) => { ht[n] = t[n]; }); } function Br(t) { let n = null; return t || (t = {}), t.loading = !0, { /** * get请求 * @param url * @param {Object} [config] - axios config * @returns {Promise<unknown>} */ get(e, o) { return new Promise((r, s) => { de.get(e, o).then((l) => { r(l); }).catch((l) => { s(l); }).finally(() => { n && (Zt(!1), n.close()), t.loading = !1; }); }); }, /** * post请求 * @param {string} url * @param {Object} data * @param {Object} [config] - axios config * @returns {Promise<unknown>} */ post(e, o, r) { return new Promise((s, l) => { de.post(e, o, r).then((i) => { s(i); }).catch((i) => { l(i); }).finally(() => { n && (Zt(!1), n.close()), t.loading = !1; }); }); }, /** * 参数为 * @param {String|Object} [message] Toast 的 Message 或者是 Toast 的配置 * @return {*} */ loading(e) { return Xe(!0), Zt(), Ht(e) ? n = Dt({ message: e || "加载中...", duration: 0, forbidClick: !0 }) : Mt(e) ? n = Dt({ duration: 0, ...e }) : n = Dt({ message: "加载中...", duration: 0, forbidClick: !0 }), this; } }; } function Ar(t, n, e) { if (!n) return ""; e = e || { value: "value", label: "text" }; const o = n.find((r) => r[e.value] === t); return o ? o[e.label] : ""; } function Tr(t, n, e) { e = e || { value: "value", label: "text", children: "children" }; const o = []; function r(s) { var l; n.includes(s[e.value]) && o.push(s[e.label]), (l = s[e.children]) != null && l.length && s[e.children].forEach((i) => { r(i); }); } return t.forEach((s) => { r(s); }), o; } function en(t, n, e) { e = e || { value: "value", label: "text", children: "children" }; let o = []; return ze( n, (r, s) => { const l = je(r, { [e.value]: s }); if (l) return o.push(l[e.label]), l[e.children]; }, t ), o; } function nn(t, n, e) { e = e || { value: "value", label: "text", children: "children" }; for (let o of t) { if (o[e.value] === n) return o; if (o[e.children] && o[e.children].length) { const r = nn(o[e.children], n, e); if (r) return r; } } return null; } function Ir(t, n, e) { return e = e || { value: "value", label: "text", children: "children" }, en(t, n, e); } function rn(t, n, e) { return Ye(t, (o, r) => r === n ? o : r === e ? rn(o, n, e) : []); } function Or(t, n, e) { e = e || { value: "value", label: "text", children: "children" }; const o = []; function r(s, l, i) { for (const c of s) if (c[e.value] === l) { i.unshift(c[e.label]); break; } else if (c[e.children] && r(c[e.children], l, i).length > 0) { i.unshift(c[e.label]); break; } return i; } return r(t, n, o); } function Pr(t, n, e) { e = e || { value: "value", label: "text", children: "children" }; const o = []; function r(s, l, i) { for (const c of s) if (c[e.value] === l) { i.unshift(c[e.value]); break; } else if (c[e.children] && r(c[e.children], l, i).length > 0) { i.unshift(c[e.value]); break; } return i; } return r(t, n, o); } const Lt = {}, on = { setItem(t, n) { Lt[t] = n; }, getItem(t) { return Lt[t]; }, removeItem(t) { delete Lt[t]; } }; window._printCache = () => { console.log(JSON.parse(JSON.stringify(Lt, null, 2))); }; function Ur(t, n) { const e = n || on, o = !!n; return { get(r) { const s = e.getItem(t); return Me(s) || Ae(s) ? r : o ? JSON.parse(s) : s; }, set(r) { e.setItem(t, o ? JSON.stringify(r) : r); }, remove() { e.removeItem(t); } }; } function Cr(t) { const { url: n, data: e, csrfToken: o } = t; let { method: r } = t; r = r || "post"; const s = document.createElement("form"); if (s.action = n, s.method = r, s.target = "_blank", s.style.display = "none", Object.keys(e).forEach((l) => { const i = document.createElement("input"); i.type = "hidden", i.name = l, i.value = e[l], s.appendChild(i); }), !o) { const l = document.createElement("input"); l.type = "hidden", l.name = "_token", l.value = document.querySelector('meta[name="csrf-token"]').getAttribute("content"), s.appendChild(l); } return document.body.appendChild(s), s; } function sn(t, n) { const { status: e } = t, o = t.result, r = {}; r.default = "请求失败, 请检查数据并重试", r[ht.STATE_CODE_FAIL] = "系统错误,请稍候再试", r[ht.STATE_CODE_NOT_FOUND] = "请求的内容不存在", r[ht.STATE_CODE_INFO_NOT_COMPLETE] = "信息不完整", r[ht.STATE_CODE_NOT_ALLOWED] = "没有权限"; const s = { [ht.STATE_CODE_SUCCESS]: "success" }, l = n[e] || n[s[e]] || r[e] || r.default; Ht(l) ? e === ht.STATE_CODE_SUCCESS ? tn(l) : Nt(o || l) : Gt(l) && l(); } function Nr(t, n) { sn(t, { success: n }); } function Lr(t) { t && t.errorFields ? t.errorFields.forEach((n) => { Nt(n.errors.join(" ")); }) : t && t.response ? Nt("网络异常") : Nt("请检查填写项"); } function Hr(t, n) { const e = Ge(t); n = n || {}; const o = (r) => { var s, l; for (let i in r) { let c; if (ge.isDayjs(r[i]) ? c = r[i] : We(r[i]) && (c = ge(r[i])), c && n.date) { Ht(n.date) ? r[i] = c.format(n.date) : Gt(n.date) ? r[i] = n.date(c) : r[i] = c.unix(); continue; } if (Je(r[i]) && n.boolean) { n.boolean === !0 ? r[i] = r[i] ? 1 : 0 : Array.isArray(n.boolean) && (r[i] = r[i] ? ((s = n.boolean) == null ? void 0 : s[0]) || 1 : ((l = n.boolean) == null ? void 0 : l[1]) || 0); continue; } if (n.attachment) { const u = n.attachment; if (Mt(r[i]) && r[i]._type === "file" && Ht(u) && !Ae(r[i][u])) { r[i] = r[i][u]; continue; } else if (Mt(r[i]) && Gt(u) && r[i]._type === "file") { r[i] = u(r[i]); continue; } } Qe(r[i]) && (r[i] = o(r[i])); } return r; }; return o(e); } /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ const Te = BigInt(0), qt = BigInt(1), cn = BigInt(2), Vt = (t) => t instanceof Uint8Array, ln = Array.from({ length: 256 }, (t, n) => n.toString(16).padStart(2, "0")); function nt(t) { if (!Vt(t)) throw new Error("Uint8Array expected"); let n = ""; for (let e = 0; e < t.length; e++) n += ln[t[e]]; return n; } function $(t) { const n = t.toString(16); return n.length & 1 ? `0${n}` : n; } function _(t) { if (typeof t != "string") throw new Error("hex string expected, got " + typeof t); return BigInt(t === "" ? "0" : `0x${t}`); } function St(t) { if (typeof t != "string") throw new Error("hex string expected, got " + typeof t); const n = t.length; if (n % 2) throw new Error("padded hex string expected, got unpadded hex of length " + n); const e = new Uint8Array(n / 2); for (let o = 0; o < e.length; o++) { const r = o * 2, s = t.slice(r, r + 2), l = Number.parseInt(s, 16); if (Number.isNaN(l) || l < 0) throw new Error("Invalid byte sequence"); e[o] = l; } return e; } function yt(t) { return _(nt(t)); } function Qt(t) { if (!Vt(t)) throw new Error("Uint8Array expected"); return _(nt(Uint8Array.from(t).reverse())); } function pt(t, n) { return St(t.toString(16).padStart(n * 2, "0")); } function Ie(t, n) { return pt(t, n).reverse(); } function un(t) { return St($(t)); } function M(t, n, e) { let o; if (typeof n == "string") try { o = St(n); } catch (s) { throw new Error(`${t} must be valid hex string, got "${n}". Cause: ${s}`); } else if (Vt(n)) o = Uint8Array.from(n); else throw new Error(`${t} must be hex string or Uint8Array`); const r = o.length; if (typeof e == "number" && r !== e) throw new Error(`${t} expected ${e} bytes, got ${r}`); return o; } function j(...t) { const n = new Uint8Array(t.reduce((o, r) => o + r.length, 0)); let e = 0; return t.forEach((o) => { if (!Vt(o)) throw new Error("Uint8Array expected"); n.set(o, e), e += o.length; }), n; } function fn(t, n) { if (t.length !== n.length) return !1; for (let e = 0; e < t.length; e++) if (t[e] !== n[e]) return !1; return !0; } function an(t) { if (typeof t != "string") throw new Error(`utf8ToBytes expected string, got ${typeof t}`); return new Uint8Array(new TextEncoder().encode(t)); } function hn(t) { let n; for (n = 0; t > Te; t >>= qt, n += 1) ; return n; } function dn(t, n) { return t >> BigInt(n) & qt; } const gn = (t, n, e) => t | (e ? qt : Te) << BigInt(n), Xt = (t) => (cn << BigInt(t - 1)) - qt, Ft = (t) => new Uint8Array(t), we = (t) => Uint8Array.from(t); function Oe(t, n, e) { if (typeof t != "number" || t < 2) throw new Error("hashLen must be a number"); if (typeof n != "number" || n < 2) throw new Error("qByteLen must be a number"); if (typeof e != "function") throw new Error("hmacFn must be a function"); let o = Ft(t), r = Ft(t), s = 0; const l = () => { o.fill(1), r.fill(0), s = 0; }, i = (...f) => e(r, o, ...f), c = (f = Ft()) => { r = i(we([0]), f), o = i(), f.length !== 0 && (r = i(we([1]), f), o = i()); }, u = () => { if (s++ >= 1e3) throw new Error("drbg: tried 1000 values"); let f = 0; const m = []; for (; f < n; ) { o = i(); const b = o.slice(); m.push(b), f += o.length; } return j(...m); }; return (f, m) => { l(), c(f); let b; for (; !(b = m(u())); ) c(); return l(), b; }; } const wn = { bigint: (t) => typeof t == "bigint", function: (t) => typeof t == "function", boolean: (t) => typeof t == "boolean", string: (t) => typeof t == "string", isSafeInteger: (t) => Number.isSafeInteger(t), array: (t) => Array.isArray(t), field: (t, n) => n.Fp.isValid(t), hash: (t) => typeof t == "function" && Number.isSafeInteger(t.outputLen) }; function Ot(t, n, e = {}) { const o = (r, s, l) => { const i = wn[s]; if (typeof i != "function") throw new Error(`Invalid validator "${s}", expected function`); const c = t[r]; if (!(l && c === void 0) && !i(c, t)) throw new Error(`Invalid param ${String(r)}=${c} (${typeof c}), expected ${s}`); }; for (const [r, s] of Object.entries(n)) o(r, s, !1); for (const [r, s] of Object.entries(e)) o(r, s, !0); return t; } const yn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, bitGet: dn, bitLen: hn, bitMask: Xt, bitSet: gn, bytesToHex: nt, bytesToNumberBE: yt, bytesToNumberLE: Qt, concatBytes: j, createHmacDrbg: Oe, ensureBytes: M, equalBytes: fn, hexToBytes: St, hexToNumber: _, numberToBytesBE: pt, numberToBytesLE: Ie, numberToHexUnpadded: $, numberToVarBytesBE: un, utf8ToBytes: an, validateObject: Ot }, Symbol.toStringTag, { value: "Module" })); /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ const V = BigInt(0), H = BigInt(1), dt = BigInt(2), pn = BigInt(3), Wt = BigInt(4), ye = BigInt(5), pe = BigInt(8); BigInt(9); BigInt(16); function Z(t, n) { const e = t % n; return e >= V ? e : n + e; } function mn(t, n, e) { if (e <= V || n < V) throw new Error("Expected power/modulo > 0"); if (e === H) return V; let o = H; for (; n > V; ) n & H && (o = o * t % e), t = t * t % e, n >>= H; return o; } function Jt(t, n) { if (t === V || n <= V) throw new Error(`invert: expected positive integers, got n=${t} mod=${n}`); let e = Z(t, n), o = n, r = V, s = H; for (; e !== V; ) { const i = o / e, c = o % e, u = r - s * i; o = e, e = c, r = s, s = u; } if (o !== H) throw new Error("invert: does not exist"); return Z(r, n); } function En(t) { const n = (t - H) / dt; let e, o, r; for (e = t - H, o = 0; e % dt === V; e /= dt, o++) ; for (r = dt; r < t && mn(r, n, t) !== t - H; r++) ; if (o === 1) { const l = (t + H) / Wt; return function(c, u) { const h = c.pow(u, l); if (!c.eql(c.sqr(h), u)) throw new Error("Cannot find square root"); return h; }; } const s = (e + H) / dt; return function(i, c) { if (i.pow(c, n) === i.neg(i.ONE)) throw new Error("Cannot find square root"); let u = o, h = i.pow(i.mul(i.ONE, r), e), f = i.pow(c, s), m = i.pow(c, e); for (; !i.eql(m, i.ONE); ) { if (i.eql(m, i.ZERO)) return i.ZERO; let b = 1; for (let a = i.sqr(m); b < u && !i.eql(a, i.ONE); b++) a = i.sqr(a); const g = i.pow(h, H << BigInt(u - b - 1)); h = i.sqr(g), f = i.mul(f, g), m = i.mul(m, h), u = b; } return f; }; } function bn(t) { if (t % Wt === pn) { const n = (t + H) / Wt; return function(o, r) { const s = o.pow(r, n); if (!o.eql(o.sqr(s), r)) throw new Error("Cannot find square root"); return s; }; } if (t % pe === ye) { const n = (t - ye) / pe; return function(o, r) { const s = o.mul(r, dt), l = o.pow(s, n), i = o.mul(r, l), c = o.mul(o.mul(i, dt), l), u = o.mul(i, o.sub(c, o.ONE)); if (!o.eql(o.sqr(u), r)) throw new Error("Cannot find square root"); return u; }; } return En(t); } const vn = [ "create", "isValid", "is0", "neg", "inv", "sqrt", "sqr", "eql", "add", "sub", "mul", "pow", "div", "addN", "subN", "mulN", "sqrN" ]; function xn(t) { const n = { ORDER: "bigint", MASK: "bigint", BYTES: "isSafeInteger", BITS: "isSafeInteger" }, e = vn.reduce((o, r) => (o[r] = "function", o), n); return Ot(t, e); } function Sn(t, n, e) { if (e < V) throw new Error("Expected power > 0"); if (e === V) return t.ONE; if (e === H) return n; let o = t.ONE, r = n; for (; e > V; ) e & H && (o = t.mul(o, r)), r = t.sqr(r), e >>= H; return o; } function Bn(t, n) { const e = new Array(n.length), o = n.reduce((s, l, i) => t.is0(l) ? s : (e[i] = s, t.mul(s, l)), t.ONE), r = t.inv(o); return n.reduceRight((s, l, i) => t.is0(l) ? s : (e[i] = t.mul(s, e[i]), t.mul(s, l)), r), e; } function te(t, n) { const e = n !== void 0 ? n : t.toString(2).length, o = Math.ceil(e / 8); return { nBitLength: e, nByteLength: o }; } function Pe(t, n, e = !1, o = {}) { if (t <= V) throw new Error(`Expected Fp ORDER > 0, got ${t}`); const { nBitLength: r, nByteLength: s } = te(t, n); if (s > 2048) throw new Error("Field lengths over 2048 bytes are not supported"); const l = bn(t), i = Object.freeze({ ORDER: t, BITS: r, BYTES: s, MASK: Xt(r), ZERO: V, ONE: H, create: (c) => Z(c, t), isValid: (c) => { if (typeof c != "bigint") throw new Error(`Invalid field element: expected bigint, got ${typeof c}`); return V <= c && c < t; }, is0: (c) => c === V, isOdd: (c) => (c & H) === H, neg: (c) => Z(-c, t), eql: (c, u) => c === u, sqr: (c) => Z(c * c, t), add: (c, u) => Z(c + u, t), sub: (c, u) => Z(c - u, t), mul: (c, u) => Z(c * u, t), pow: (c, u) => Sn(i, c, u), div: (c, u) => Z(c * Jt(u, t), t), // Same as above, but doesn't normalize sqrN: (c) => c * c, addN: (c, u) => c + u, subN: (c, u) => c - u, mulN: (c, u) => c * u, inv: (c) => Jt(c, t), sqrt: o.sqrt || ((c) => l(i, c)), invertBatch: (c) => Bn(i, c), // TODO: do we really need constant cmov? // We don't have const-time bigints anyway, so probably will be not very useful cmov: (c, u, h) => h ? u : c, toBytes: (c) => e ? Ie(c, s) : pt(c, s), fromBytes: (c) => { if (c.length !== s) throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`); return e ? Qt(c) : yt(c); } }); return Object.freeze(i); } function An(t, n, e = !1) { t = M("privateHash", t); const o = t.length, r = te(n).nByteLength + 8; if (r < 24 || o < r || o > 1024) throw new Error(`hashToPrivateScalar: expected ${r}-1024 bytes of input, got ${o}`); const s = e ? Qt(t) : yt(t); return Z(s, n - H) + H; } /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ const Tn = BigInt(0), Kt = BigInt(1); function In(t, n) { const e = (r, s) => { const l = s.negate(); return r ? l : s; }, o = (r) => { const s = Math.ceil(n / r) + 1, l = 2 ** (r - 1); return { windows: s, windowSize: l }; }; return { constTimeNegate: e, // non-const time multiplication ladder unsafeLadder(r, s) { let l = t.ZERO, i = r; for (; s > Tn; ) s & Kt && (l = l.add(i)), i = i.double(), s >>= Kt; return l; }, /** * 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. * @returns precomputed point tables flattened to a single array */ precomputeWindow(r, s) { const { windows: l, windowSize: i } = o(s), c = []; let u = r, h = u; for (let f = 0; f < l; f++) { h = u, c.push(h); for (let m = 1; m < i; m++) h = h.add(u), c.push(h); u = h.double(); } return c; }, /** * Implements ec multiplication using precomputed tables and w-ary non-adjacent form. * @param W window size * @param precomputes precomputed tables * @param n scalar (we don't check here, but should be less than curve order) * @returns real and fake (for const-time) points */ wNAF(r, s, l) { const { windows: i, windowSize: c } = o(r); let u = t.ZERO, h = t.BASE; const f = BigInt(2 ** r - 1), m = 2 ** r, b = BigInt(r); for (let g = 0; g < i; g++) { const a = g * c; let w = Number(l & f); l >>= b, w > c && (w -= m, l += Kt); const y = a, v = a + Math.abs(w) - 1, S = g % 2 !== 0, I = w < 0; w === 0 ? h = h.add(e(S, s[y])) : u = u.add(e(I, s[v])); } return { p: u, f: h }; }, wNAFCached(r, s, l, i) { const c = r._WINDOW_SIZE || 1; let u = s.get(r); return u || (u = this.precomputeWindow(r, c), c !== 1 && s.set(r, i(u))), this.wNAF(c, u, l); } }; } function Ue(t) { return xn(t.Fp), Ot(t, { n: "bigint", h: "bigint", Gx: "field", Gy: "field" }, { nBitLength: "isSafeInteger", nByteLength: "isSafeInteger" }), Object.freeze({ ...te(t.n, t.nBitLength), ...t, p: t.Fp.ORDER }); } /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ function On(t) { const n = Ue(t); Ot(n, { a: "field", b: "field" }, { allowedPrivateKeyLengths: "array", wrapPrivateKey: "boolean", isTorsionFree: "function", clearCofactor: "function", allowInfinityPoint: "boolean", fromBytes: "function", toBytes: "function" }); const { endo: e, Fp: o, a: r } = n; if (e) { if (!o.eql(r, o.ZERO)) throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0"); if (typeof e != "object" || typeof e.beta != "bigint" || typeof e.splitScalar != "function") throw new Error("Expected endomorphism with beta: bigint and splitScalar: function"); } return Object.freeze({ ...n }); } const { bytesToNumberBE: Pn, hexToBytes: Un } = yn, gt = { // asn.1 DER encoding utils Err: class extends Error { constructor(n = "") { super(n); } }, _parseInt(t) { const { Err: n } = gt; if (t.length < 2 || t[0] !== 2) throw new n("Invalid signature integer tag"); const e = t[1], o = t.subarray(2, e + 2); if (!e || o.length !== e) throw new n("Invalid signature integer: wrong length"); if (o[0] & 128) throw new n("Invalid signature integer: negative"); if (o[0] === 0 && !(o[1] & 128)) throw new n("Invalid signature integer: unnecessary leading zero"); return { d: Pn(o), l: t.subarray(e + 2) }; }, toSig(t) { const { Err: n } = gt, e = typeof t == "string" ? Un(t) : t; if (!(e instanceof Uint8Array)) throw new Error("ui8a expected"); let o = e.length; if (o < 2 || e[0] != 48) throw new n("Invalid signature tag"); if (e[1] !== o - 2) throw new n("Invalid signature: incorrect length"); const { d: r, l: s } = gt._parseInt(e.subarray(2)), { d: l, l: i } = gt._parseInt(s); if (i.length) throw new n("Invalid signature: left bytes after parsing"); return { r, s: l }; }, hexFromSig(t) { const n = (u) => Number.parseInt(u[0], 16) & 8 ? "00" + u : u, e = (u) => { const h = u.toString(16); return h.length & 1 ? `0${h}` : h; }, o = n(e(t.s)), r = n(e(t.r)), s = o.length / 2, l = r.length / 2, i = e(s), c = e(l); return `30${e(l + s + 4)}02${c}${r}02${i}${o}`; } }, et = BigInt(0), G = BigInt(1); BigInt(2); const me = BigInt(3); BigInt(4); function Cn(t) { const n = On(t), { Fp: e } = n, o = n.toBytes || ((g, a, w) => { const y = a.toAffine(); return j(Uint8Array.from([4]), e.toBytes(y.x), e.toBytes(y.y)); }), r = n.fromBytes || ((g) => { const a = g.subarray(1), w = e.fromBytes(a.subarray(0, e.BYTES)), y = e.fromBytes(a.subarray(e.BYTES, 2 * e.BYTES)); return { x: w, y }; }); function s(g) { const { a, b: w } = n, y = e.sqr(g), v = e.mul(y, g); return e.add(e.add(v, e.mul(g, a)), w); } if (!e.eql(e.sqr(n.Gy), s(n.Gx))) throw new Error("bad generator point: equation left != right"); function l(g) { return typeof g == "bigint" && et < g && g < n.n; } function i(g) { if (!l(g)) throw new Error("Expected valid bigint: 0 < bigint < curve.n"); } function c(g) { const { allowedPrivateKeyLengths: a, nByteLength: w, wrapPrivateKey: y, n: v } = n; if (a && typeof g != "bigint") { if (g instanceof Uint8Array && (g = nt(g)), typeof g != "string" || !a.includes(g.length)) throw new Error("Invalid key"); g = g.padStart(w * 2, "0"); } let S; try { S = typeof g == "bigint" ? g : yt(M("private key", g, w)); } catch { throw new Error(`private key must be ${w} bytes, hex or bigint, not ${typeof g}`); } return y && (S = Z(S, v)), i(S), S; } const u = /* @__PURE__ */ new Map(); function h(g) { if (!(g instanceof f)) throw new Error("ProjectivePoint expected"); } class f { constructor(a, w, y) { if (this.px = a, this.py = w, this.pz = y, a == null || !e.isValid(a)) throw new Error("x required"); if (w == null || !e.isValid(w)) throw new Error("y required"); if (y == null || !e.isValid(y)) throw new Error("z required"); } // Does not validate if the point is on-curve. // Use fromHex instead, or call assertValidity() later. static fromAffine(a) { const { x: w, y } = a || {}; if (!a || !e.isValid(w) || !e.isValid(y)) throw new Error("invalid affine point"); if (a instanceof f) throw new Error("projective point not allowed"); const v = (S) => e.eql(S, e.ZERO); return v(w) && v(y) ? f.ZERO : new f(w, y, e.ONE); } get x() { return this.toAffine().x; } get y() { return this.toAffine().y; } /** * Takes a bunch of Projective Points but executes only one * inversion on all of them. Inversion is very slow operation, * so this improves performance massively. * Optimization: converts a list of projective points to a list of identical points with Z=1. */ static normalizeZ(a) { const w = e.invertBatch(a.map((y) => y.pz)); return a.map((y, v) => y.toAffine(w[v])).map(f.fromAffine); } /** * Converts hash string or Uint8Array to Point. * @param hex short/long ECDSA hex */ static fromHex(a) { const w = f.fromAffine(r(M("pointHex", a))); return w.assertValidity(), w; } // Multiplies generator point by privateKey. static fromPrivateKey(a) { return f.BASE.multiply(c(a)); } // "Private method", don't use it directly _setWindowSize(a) { this._WINDOW_SIZE = a, u.delete(this); } // A point on curve is valid if it conforms to equation. assertValidity() { if (this.is0()) { if (n.allowInfinityPoint) return; throw new Error("bad point: ZERO"); } const { x: a, y: w } = this.toAffine(); if (!e.isValid(a) || !e.isValid(w)) throw new Error("bad point: x or y not FE"); const y = e.sqr(w), v = s(a); if (!e.eql(y, v)) throw new Error("bad point: equation left != right"); if (!this.isTorsionFree()) throw new Error("bad point: not in prime-order subgroup"); } hasEvenY() { const { y: a } = this.toAffine(); if (e.isOdd) return !e.isOdd(a); throw new Error("Field doesn't support isOdd"); } /** * Compare one point to another. */ equals(a) { h(a); const { px: w, py: y, pz: v } = this, { px: S, py: I, pz: T } = a, E = e.eql(e.mul(w, T), e.mul(S, v)), x = e.eql(e.mul(y, T), e.mul(I, v)); return E && x; } /** * Flips point to one corresponding to (x, -y) in Affine coordinates. */ negate() { return new f(this.px, e.neg(this.py), this.pz); } // 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, b: w } = n, y = e.mul(w, me), { px: v, py: S, pz: I } = this; let T = e.ZERO, E = e.ZERO, x = e.ZERO, A = e.mul(v, v), Y = e.mul(S, S), C = e.mul(I, I), O = e.mul(v, S); return O = e.add(O, O), x = e.mul(v, I), x = e.add(x, x), T = e.mul(a, x), E = e.mul(y, C), E = e.add(T, E), T = e.sub(Y, E), E = e.add(Y, E), E = e.mul(T, E), T = e.mul(O, T), x = e.mul(y, x), C = e.mul(a, C), O = e.sub(A, C), O = e.mul(a, O), O = e.add(O, x), x = e.add(A, A), A = e.add(x, A), A = e.add(A, C), A = e.mul(A, O), E = e.add(E, A), C = e.mul(S, I), C = e.add(C, C), A = e.mul(C, O), T = e.sub(T, A), x = e.mul(C, Y), x = e.add(x, x), x = e.add(x, x), new f(T, E, x); } // 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(a) { h(a); const { px: w, py: y, pz: v } = this, { px: S, py: I, pz: T } = a; let E = e.ZERO, x = e.ZERO, A = e.ZERO; const Y = n.a, C = e.mul(n.b, me); let O = e.mul(w, S), D = e.mul(y, I), F = e.mul(v, T), rt = e.add(w, y), d = e.add(S, I); rt = e.mul(rt, d), d = e.add(O, D), rt = e.sub(rt, d), d = e.add(w, v); let p = e.add(S, T); return d = e.mul(d, p), p = e.add(O, F), d = e.sub(d, p), p = e.add(y, v), E = e.add(I, T), p = e.mul(p, E), E = e.add(D, F), p = e.sub(p, E), A = e.mul(Y, d), E = e.mul(C, F), A = e.add(E, A), E = e.sub(D, A), A = e.add(D, A), x = e.mul(E, A), D = e.add(O, O), D = e.add(D, O), F = e.mul(Y, F), d = e.mul(C, d), D = e.add(D, F), F = e.sub(O, F), F = e.mul(Y, F), d = e.add(d, F), O = e.mul(D, d), x = e.add(x, O), O = e.mul(p, d), E = e.mul(rt, E), E = e.sub(E, O), O = e.mul(rt, D), A = e.mul(p, A), A = e.add(A, O), new f(E, x, A); } subtract(a) { return this.add(a.negate()); } is0() { return this.equals(f.ZERO); } wNAF(a) { return b.wNAFCached(this, u, a, (w) => { const y = e.invertBatch(w.map((v) => v.pz)); return w.map((v, S) => v.toAffine(y[S])).map(f.fromAffine); }); } /** * 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 private key e.g. sig verification, which works over *public* keys. */ multiplyUnsafe(a) { const w = f.ZERO; if (a === et) return w; if (i(a), a === G) return this; const { endo: y } = n; if (!y) return b.unsafeLadder(this, a); let { k1neg: v, k1: S, k2neg: I, k2: T } = y.splitScalar(a), E = w, x = w, A = this; for (; S > et || T > et; ) S & G && (E = E.add(A)), T & G && (x = x.add(A)), A = A.double(), S >>= G, T >>= G; return v && (E = E.negate()), I && (x = x.negate()), x = new f(e.mul(x.px, y.beta), x.py, x.pz), E.add(x); } /** * 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(a) { i(a); let w = a, y, v; const { endo: S } = n; if (S) { const { k1neg: I, k1: T, k2neg: E, k2: x } = S.splitScalar(w); let { p: A, f: Y } = this.wNAF(T), { p: C, f: O } = this.wNAF(x); A = b.constTimeNegate(I, A), C = b.constTimeNegate(E, C), C = new f(e.mul(C.px, S.beta), C.py, C.pz), y = A.add(C), v = Y.add(O); } else { const { p: I, f: T } = this.wNAF(w); y = I, v = T; } return f.normalizeZ([y, v])[0]; } /** * Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly. * Not using Strauss-Shamir trick: precomputation tables are faster. * The trick could be useful if both P and Q are not G (not in our case). * @returns non-zero affine point */ multiplyAndAddUnsafe(a, w, y) { const v = f.BASE, S = (T, E) => E === et || E === G || !T.equals(v) ? T.multiplyUnsafe(E) : T.multiply(E), I = S(this, w).add(S(a, y)); return I.is0() ? void 0 : I; } // Converts Projective point to affine (x, y) coordinates. // Can accept precomputed Z^-1 - for example, from invertBatch. // (x, y, z) ∋ (x=x/z, y=y/z) toAffine(a) { const { px: w, py: y, pz: v } = this, S = this.is0(); a == null && (a = S ? e.ONE : e.inv(v)); const I = e.mul(w, a), T = e.mul(y, a), E = e.mul(v, a); if (S) return { x: e.ZERO, y: e.ZERO }; if (!e.eql(E, e.ONE)) throw new Error("invZ was invalid"); return { x: I, y: T }; } isTorsionFree() { const { h: a, isTorsionFree: w } = n; if (a === G) return !0; if (w) return w(f, this); throw new Error("isTorsionFree() has not been declared for the elliptic curve"); } clearCofactor() { const { h: a, clearCofactor: w } = n; return a === G ? this : w ? w(f, this) : this.multiplyUnsafe(n.h); } toRawBytes(a = !0) { return this.assertValidity(), o(f, this, a); } toHex(a = !0) { return nt(this.toRawBytes(a)); } } f.BASE = new f(n.Gx, n.Gy, e.ONE), f.ZERO = new f(e.ZERO, e.ONE, e.ZERO); const m = n.nBitLength, b = In(f, n.endo ? Math.ceil(m / 2) : m); return { CURVE: n, ProjectivePoint: f, normPrivateKeyToScalar: c, weierstrassEquation: s, isWithinCurveOrder: l }; } function Nn(t) { const n = Ue(t); return Ot(n, { hash: "hash", hmac: "function", randomBytes: "function" }, { bits2int: "function", bits2int_modN: "function", lowS: "boolean" }), Object.freeze({ lowS: !0, ...n }); } function Ln(t) { const n = Nn(t), { Fp: e, n: o } = n, r = e.BYTES + 1, s = 2 * e.BYTES + 1; function l(d) { return et < d && d < e.ORDER; } function i(d) { return Z(d, o); } function c(d) { return Jt(d, o); } const { ProjectivePoint: u, normPrivateKeyToScalar: h, weierstrassEquation: f, isWithinCurveOrder: m } = Cn({ ...n, toBytes(d, p, B) { const U = p.toAffine(), P = e.toBytes(U.x), q = j; return B ? q(Uint8Array.from([p.hasEvenY() ? 2 : 3]), P) : q(Uint8Array.from([4]), P, e.toBytes(U.y)); }, fromBytes(d) { const p = d.length, B = d[0], U = d.subarray(1); if (p === r && (B === 2 || B === 3)) { const P = yt(U); if (!l(P)) throw new Error("Point is not on curve"); const q = f(P); let K = e.sqrt(q); const z = (K & G) === G; return (B & 1) === 1 !== z && (K = e.neg(K)), { x: P, y: K }; } else if (p === s && B === 4) { const P = e.fromBytes(U.subarray(0, e.BYTES)), q = e.fromBytes(U.subarray(e.BYTES, 2 * e.BYTES)); return { x: P, y: q }; } else throw new Error(`Point of length ${p} was invalid. Expected ${r} compressed bytes or ${s} uncompressed bytes`); } }), b = (d) => nt(pt(d, n.nByteLength)); function g(d) { const p = o >> G; return d > p; } function a(d) { return g(d) ? i(-d) : d; } const w = (d, p, B) => yt(d.slice(p, B)); class y { constructor(p, B, U) { this.r = p, this.s = B, this.recovery = U, this.assertValidity(); } // pair (bytes of r, bytes of s) static fromCompact(p) { const B = n.nByteLength; return p = M("compactSignature", p, B * 2), new y(w(p, 0, B), w(p, B, 2 * B)); } // DER encoded ECDSA signature // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script static fromDER(p) { const { r: B, s: U } = gt.toSig(M("DER", p)); return new y(B, U); } assertValidity() { if (!m(this.r)) throw new Error("r must be 0 < r < CURVE.n"); if (!m(this.s)) throw new Error("s must be 0 < s < CURVE.n"); } addRecoveryBit(p) { return new y(this.r, this.s, p); } recoverPublicKey(p) { const { r: B, s: U, recovery: P } = this, q = x(M("msgHash", p)); if (P == null || ![0, 1, 2, 3].includes(P)) throw new Error("recovery id invalid"); const K = P === 2 || P === 3 ? B + n.n : B; if (K >= e.ORDER) throw new Error("recovery id 2 or 3 invalid"); const z = P & 1 ? "03" : "02", ot = u.fromHex(z + b(K)), it = c(K), mt = i(-q * it), Tt = i(U * it), st = u.BASE.multiplyAndAddUnsafe(ot, mt, Tt); if (!st) throw new Error("point at infinify"); return st.assertValidity(), st; } // Signatures should be low-s, to prevent malleability. hasHighS() { return g(this.s); } normalizeS() { return this.hasHighS() ? new y(this.r, i(-this.s), this.recovery) : this; } // DER-encoded toDERRawBytes() { return St(this.toDERHex()); } toDERHex() { return gt.hexFromSig({ r: this.r, s: this.s }); } // padded bytes of r, then padded bytes of s toCompactRawBytes() { return St(this.toCompactHex()); } toCompactHex() { return b(this.r) + b(this.s); } } const v = { isValidPrivateKey(d) { try { return h(d), !0; } catch { return !1; } }, normPrivateKeyToScalar: h, /** * Produces cryptographically secure private key from random of size (nBitLength+64) * as per FIPS 186 B.4.1 with modulo bias being neglible. */ randomPrivateKey: () => { const d = n.randomBytes(e.BYTES + 8), p = An(d, o); return pt(p, n.nByteLength); }, /** * Creates precompute table for an arbitrary EC point. Makes point "cached". * Allows to massively speed-up `point.multiply(scalar)`. * @returns cached point * @example * const fast = utils.precompute(8, ProjectivePoint.fromHex(someonesPubKey)); * fast.multiply(privKey); // much faster ECDH now */ precompute(d = 8, p = u.BASE) { return p._setWindowSize(d), p.multiply(BigInt(3)), p; } }; function S(d, p = !0) { return u.fromPrivateKey(d).toRawBytes(p); } function I(d) { const p = d instanceof Uint8Array, B = typeof d == "string", U = (p || B) && d.length; return p ? U === r || U === s : B ? U === 2 * r || U === 2 * s : d instanceof u; } function T(d, p, B = !0) { if (I(d)) throw new Error("first arg must be private key"); if (!I(p)) throw new Error("second arg must be public key"); return u.fromHex(p).multiply(h(d)).toRawBytes(B); } const E = n.bits2int || function(d) { const p = yt(d), B = d.length * 8 - n.nBitLength; return B > 0 ? p >> BigInt(B) : p; }, x = n.bits2int_modN || function(d) { return i(E(d)); }, A = Xt(n.nBitLength); function Y(d) { if (typeof d != "bigint") throw new Error("bigint expected"); if (!(et <= d && d < A)) throw new Error(`bigint expected < 2^${n.nBitLength}`); return pt(d, n.nByteLength); } function C(d, p, B = O) { if (["recovered", "canonical"].some((ft) => ft in B)) throw new Error("sign() legacy options not supported"); const { hash: U, randomBytes: P } = n; let { lowS: q, prehash: K, extraEntropy: z } = B; q == null && (q = !0), d = M("msgHash", d), K && (d = M("prehashed msgHash", U(d))); const ot = x(d), it = h(p), mt = [Y(it), Y(ot)]; if (z != null) { const ft = z === !0 ? P(e.BYTES) : z; mt.push(M("extraEntropy", ft, e.BYTES)); } const Tt = j(...mt), st = ot; function kt(ft) { const Et = E(ft); if (!m(Et)) return; const fe = c(Et), bt = u.BASE.multiply(Et).toAffine(), J = i(bt.x); if (J === et) return; const vt = i(fe * i(st + J * it)); if (vt === et) return; let ae = (bt.x === J ? 0 : 2) | Number(bt.y & G), he = vt; return q && g(vt) && (he = a(vt), ae ^= 1), new y(J, he, ae); } return { seed: Tt, k2sig: kt }; } const O = { lowS: n.lowS, prehash: !1 }, D = { lowS: n.lowS, prehash: !1 }; function F(d, p, B = O) { const { seed: U, k2sig: P } = C(d, p, B), q = n; return Oe(q.hash.outputLen, q.nByteLength, q.hmac)(U, P); } u.BASE._setWindowSize(8); function rt(d, p, B, U = D) { var bt; const P = d; if (p = M("msgHash", p), B = M("publicKey", B), "strict" in U) throw new Error("options.strict was renamed to lowS"); const { lowS: q, prehash: K } = U; let z, ot; try { if (typeof P == "string" || P instanceof Uint8Array) try { z = y.fromDER(P); } catch (J) { if (!(J instanceof gt.Err)) throw J; z = y.fromCompact(P); } else if (typeof P == "object" && typeof P.r == "bigint" && typeof P.s == "bigint") { const { r: J, s: vt } = P; z = new y(J, vt); } else throw new Error("PARSE"); ot = u.fromHex(B); } catch (J) { if (J.message === "PARSE") throw new Error("signature must be Signature instance, Uint8Array or hex string"); return !1; } if (q && z.hasHighS()) return !1; K && (p = n.hash(p)); const { r: it, s: mt } = z, Tt = x(p), st = c(mt), kt = i(Tt * st), ft = i(it * st), Et = (bt = u.BASE.multiplyAndAddUnsafe(ot, kt, ft)) == null ? void 0 : bt.toAffine(); return Et ? i(Et.x) === it : !1; } return { CURVE: n, getPublicKey: S, getSharedSecret: T, sign: F, verify: rt, ProjectivePoint: u, Signature: y, utils: v }; } var Hn = Object.defineProperty, Ce = (t, n) => { for (var e in n) Hn(t, e, { get: n[e], enumerable: !0 }); }, Ne = {}; Ce(Ne, { EmptyArray: () => se, arrayToHex: () => $t, arrayToUtf8: () => ie, calculateSharedKey: () => sr, comparePublicKeyHex: () => or, compressPublicKeyHex: () => nr, doDecrypt: () => lr, doEncrypt: () => cr, doSignature: () => ur, doVerifySignature: () => fr, generateKeyPairHex: () => oe, getHash: () => ce, getPoint: () => Ze, getPublicKeyFromPrivateKey: () => ke, getZ: () => Rt, hexToArray: () => k, initRNGPool: () => ee, leftPad: () => R, precomputePublicKey: () => ar, utf8ToHex: () => At, verifyPublicKey: () => rr }); var _t = BigInt(0), It = BigInt(1), _n = BigInt(2); BigInt(3); function Rn(t) { let n = t.toString(16); if (n[0] !== "-") n.length % 2 === 1 ? n = "0" + n : n.match(/^[0-7]/) || (n = "00" + n); else { n = n.substring(1); let e = n.length; e % 2 === 1 ? e += 1 : n.match(/^[0-7]/) || (e += 2); let o = ""; for (let l = 0; l < e; l++) o += "f"; n = ((_(o) ^ t) + It).toString(16).replace(/^-/, ""); } return n; } var Le = class { constructor(t = null, n = "00", e = "00", o = "") { this.tlv = t, this.t = n, this.l = e, this.v = o; } getEncodedHex() { return this.tlv || (this.v = this.getValue(), this.l = this.getLength(), this.tlv = this.t + this.l + this.v), this.tlv; } getLength() { const t = this.v.length / 2; let n = t.toString(16); return n.length % 2 === 1 && (n = "0" + n), t < 128 ? n : (128 + n.length / 2).toString(16) + n; } getValue() { return ""; } }, Ee = class extends Le { constructor(t) { super(), this.t = "02", t && (this.v = Rn(t)); } getValue() { return this.v; } }, qn = class extends Le { constructor(n) { super(); L(this, "t", "30"); this.asn1Array = n; } getValue() { return this.v = this.asn1Array.map((n) => n.getEncodedHex()).join(""), this.v; } }; function He(t, n) { return +t[n + 2] < 8 ? 1 : +t.substring(n + 2, n + 4) & 127 + 1; } function be(t, n) { const e = He(t, n), o = t.substring(n + 2, n + 2 + e * 2); return o ? +(+o[0] < 8 ? _(o) : _(o.substring(2))).toString() : -1; } function zt(t, n) { const e = He(t, n); return n + (e + 1) * 2; } function Vn(t, n) { const e = new Ee(t), o = new Ee(n); return new qn([e, o]).getEncodedHex(); } function $n(t) { const n = zt(t, 0), e = zt(t, n), o = be(t, n), r = t.substr(e, o * 2), s = e + r.length, l = zt(t, s), i = be(t, s), c = t.substring(l, l + i * 2), u = _(r), h = _(c); return { r: u, s: h }; } var jt = 16384, wt = new Uint8Array(0), xt; async function ee() { if ("crypto" in globalThis) { xt = globalThis.crypto; return; } if (!(wt.length > jt / 2)) if ("wx" in globalThis && "getRandomValues" in globalThis.wx) wt = await new Promise((t) => { wx.getRandomValues({ length: jt, success(n) { t(new Uint8Array(n.randomValues)); } }); }); else try { globalThis.crypto ? xt = globalThis.crypto : xt = (await import( /* webpackIgnore: true */ "./__vite-browser-external-2447137e.js" )).webcrypto; const t = new Uint8Array(jt); xt.getRandomValues(t), wt = t; } catch { throw new Error("no available csprng, abort."); } } ee(); function kn(t) { if (wt.length > t) { const n = wt.slice(0, t); return wt = wt.slice(t), ee(), n; } else throw new Error("random number pool is not ready or insufficient, prevent getting too long random values or too often."); } function Zn(t = 0) { const n = new Uint8Array(t); return xt ? xt.getRandomValues(n) : kn(t); } var _e = (t) => t instanceof Uint8Array, Yt = (t) => new DataView(t.buffer, t.byteOffset, t.byteLength), Dn = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68; if (!Dn) throw new Error("Non little-endian hardware is not supported"); var Fn = Array.from({ length: 256 }, (t, n) => n.toString(16).padStart(2, "0")); function Bt(t) { if (!_e(t)) throw new Error("Uint8Array expected"); let n = ""; for (let e = 0; e < t.length; e++) n += Fn[t[e]]; return n; } function Kn(t) { if (typeof t != "string") throw new Error(`utf8ToBytes expected string, got ${typeof t}`); return new Uint8Array(new TextEncoder().encode(t)); } function ne(t) { if (typeof t == "string" && (t = Kn(t)), !_e(t)) throw new Error(`expected Uint8Array, got ${typeof t}`); return t; } var Re = class { clone() { return this._cloneInto(); } }; function zn(t) { const n = (o) => t().update(ne(o)).digest(), e = t(); return n.outputLen = e.outputLen, n.blockLen = e.blockLen, n.create = () => t(), n; } var jn = (t, n, e) => t & n | t & e | n & e, ve = (t, n, e) => t ^ n ^ e, Yn = (t, n, e) => t & n | ~t & e; function Mn(t, n, e, o) { if (typeof t.setBigUint64 == "function") return t.setBigUint64(n, e, o); const r = BigInt(32), s = BigInt(4294967295), l = Number(e >> r & s), i = Number(e & s), c = o ? 4 : 0, u = o ? 0 : 4; t.setUint32(n + c, l, o), t.setUint32(n + u, i, o); } function W(t, n) { const e = n & 31; return t << e | t >>> 32 - e; } function Gn(t) { return t ^ W(t, 9) ^ W(t, 17); } function Wn(t) { return t ^ W(t, 15) ^ W(t, 23); } var Jn = class extends Re { constructor(n, e, o, r) { super(); L(this, "buffer"); L(this, "view"); L(this, "finished", !1); L(this, "length", 0); L(this, "pos", 0); L(this, "destroyed", !1); this.blockLen = n, this.outputLen = e, this.padOffset = o, this.isLE = r, this.buffer = new Uint8Array(n), this.view = Yt(this.buffer); } update(n) { const { view: e, buffer: o, blockLen: r } = this; n = ne(n); const s = n.length; for (let l = 0; l < s; ) { const i = Math.min(r - this.pos, s - l); if (i === r) { const c = Yt(n); for (; r <= s - l; l += r) this.process(c, l); continue; } o.set(n.subarray(l, l + i), this.pos), this.pos += i, l += i, this.pos === r && (this.process(e, 0), this.pos = 0); } return this.length += n.length, this.roundClean(), this; } digestInto(n) { this.finished = !0; const { buffer: e, view: o, blockLen: r, isLE: s } = this; let { pos: l } = this; e[l++] = 128, this.buffer.subarray(l).fill(0), this.padOffset > r - l && (this.process(o, 0), l = 0); for (let f = l; f < r; f++) e[f] = 0; Mn(o, r - 8, BigInt(this.length * 8), s), this.process(o, 0); const i = Yt(n), c = this.outputLen; if (c % 4) throw new Error("_sha2: outputLen should be aligned to 32bit"); const u = c / 4, h = this.get(); if (u > h.length) throw new Error("_sha2: outputLen bigger than state"); for (let f = 0; f < u; f++) i.setUint32(4 * f, h[f], s); } digest() { const { buffer: n, outputLen: e } = this; this.digestInto(n); const o = n.slice(0, e); return this.destroy(), o; } _cloneInto(n) { n || (n = new this.constructor()), n.set(...this.get()); const { blockLen: e, buffer: o, length: r, finished: s, destroyed: l, pos: i } = this; return n.length = r, n.pos = i, n.finished = s, n.destroyed = l, r % e && n.buffer.set(o), n; } }, ct = new Uint32Array([1937774191, 1226093241, 388252375, 3666478592, 2842636476, 372324522, 3817729613, 2969243214]), Q = new Uint32Array(68), xe = new Uint32Array(64), Qn = 2043430169, Xn = 2055708042, tr = class extends Jn { constructor() { super(64, 32, 8, !1); L(this, "A", ct[0] | 0); L(this, "B", ct[1] | 0); L(this, "C", ct[2] | 0); L(this, "D", ct[3] | 0); L(this, "E", ct[4] | 0); L(this, "F", ct[5] | 0); L(this, "G", ct[6] | 0); L(this, "H", ct[7] | 0); } get() { const { A: n, B: e, C: o, D: r, E: s, F: l, G: i, H: c } = this; return [n, e, o, r, s, l, i, c]; } set(n, e, o, r, s, l, i, c) { this.A = n | 0, this.B = e | 0, this.C = o | 0, this.D = r | 0, this.E = s | 0, this.F = l | 0, this.G = i | 0, this.H = c | 0; } process(n, e) { for (let f = 0; f < 16; f++, e += 4) Q[f] = n.getUint32(e, !1); for (let f = 16; f < 68; f++) Q[f] = Wn(Q[f - 16] ^ Q[f - 9] ^ W(Q[f - 3], 15)) ^ W(Q[f - 13], 7) ^ Q[f - 6]; for (let f = 0; f < 64; f++) xe[f] = Q[f] ^ Q[f + 4]; let { A: o, B: r, C: s, D: l, E: i, F: c, G: u, H: h } = this; for (let f = 0; f < 64; f++) { let m = f >= 0 && f <= 15, b = m ? Qn : Xn, g = W(W(o, 12) + i + W(b, f), 7), a = g ^ W(o, 12), w = (m ? ve(o, r, s) : jn(o, r, s)) + l + a + xe[f] | 0, y = (m ? ve(i, c, u) : Yn(i, c, u)) + h + g + Q[f] | 0; l = s, s = W(r, 9), r = o, o = w, h = u, u = W(c, 19), c = i, i = Gn(y); } o = o ^ this.A | 0, r = r ^ this.B | 0, s = s ^ this.C | 0, l = l ^ this.D | 0, i = i ^ this.E | 0, c = c ^ this.F | 0, u = u ^ this.G | 0, h = h ^ this.H | 0, this.set(o, r, s, l, i, c, u, h); } roundClean() { Q.fill(0); } destroy() { this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0); } }, tt = zn(() => new tr()), qe = class extends Re { constructor(n, e) { super(); L(this, "oHash"); L(this, "iHash"); L(this, "blockLen"); L(this, "output