import CJS_COMPAT_NODE_URL from 'node:url';
import CJS_COMPAT_NODE_PATH from 'node:path';
import CJS_COMPAT_NODE_MODULE from "node:module";

const __filename = CJS_COMPAT_NODE_URL.fileURLToPath(import.meta.url);
const __dirname = CJS_COMPAT_NODE_PATH.dirname(__filename);
const require = CJS_COMPAT_NODE_MODULE.createRequire(import.meta.url);
// ------------------------------------------------------------
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
// ------------------------------------------------------------
import {
  a as c,
  b as Bt,
  c as Rt,
  d as vt,
  f as Mt
} from "./chunk-HRN2KQZP.js";

// ../node_modules/big-integer/BigInteger.js
var Ot = vt((te, at) => {
  var P = function(h) {
    "use strict";
    var w = 1e7, O = 7, T = 9007199254740992, M = Z(T), z = "0123456789abcdefghijklmnopqrstuvwxyz", U = typeof BigInt == "function";
    function y(t, e, r, n) {
      return typeof t > "u" ? y[0] : typeof e < "u" ? +e == 10 && !r ? g(t) : Ut(t, e, r, n) : g(t);
    }
    c(y, "Integer");
    function s(t, e) {
      this.value = t, this.sign = e, this.isSmall = !1;
    }
    c(s, "BigInteger"), s.prototype = Object.create(y.prototype);
    function p(t) {
      this.value = t, this.sign = t < 0, this.isSmall = !0;
    }
    c(p, "SmallInteger"), p.prototype = Object.create(y.prototype);
    function f(t) {
      this.value = t;
    }
    c(f, "NativeBigInt"), f.prototype = Object.create(y.prototype);
    function v(t) {
      return -T < t && t < T;
    }
    c(v, "isPrecise");
    function Z(t) {
      return t < 1e7 ? [t] : t < 1e14 ? [t % 1e7, Math.floor(t / 1e7)] : [t % 1e7, Math.floor(t / 1e7) % 1e7, Math.floor(t / 1e14)];
    }
    c(Z, "smallToArray");
    function R(t) {
      q(t);
      var e = t.length;
      if (e < 4 && $(t, M) < 0)
        switch (e) {
          case 0:
            return 0;
          case 1:
            return t[0];
          case 2:
            return t[0] + t[1] * w;
          default:
            return t[0] + (t[1] + t[2] * w) * w;
        }
      return t;
    }
    c(R, "arrayToSmall");
    function q(t) {
      for (var e = t.length; t[--e] === 0; ) ;
      t.length = e + 1;
    }
    c(q, "trim");
    function tt(t) {
      for (var e = new Array(t), r = -1; ++r < t; )
        e[r] = 0;
      return e;
    }
    c(tt, "createArray");
    function C(t) {
      return t > 0 ? Math.floor(t) : Math.ceil(t);
    }
    c(C, "truncate");
    function it(t, e) {
      var r = t.length, n = e.length, i = new Array(r), o = 0, u = w, a, l;
      for (l = 0; l < n; l++)
        a = t[l] + e[l] + o, o = a >= u ? 1 : 0, i[l] = a - o * u;
      for (; l < r; )
        a = t[l] + o, o = a === u ? 1 : 0, i[l++] = a - o * u;
      return o > 0 && i.push(o), i;
    }
    c(it, "add");
    function G(t, e) {
      return t.length >= e.length ? it(t, e) : it(e, t);
    }
    c(G, "addAny");
    function et(t, e) {
      var r = t.length, n = new Array(r), i = w, o, u;
      for (u = 0; u < r; u++)
        o = t[u] - i + e, e = Math.floor(o / i), n[u] = o - e * i, e += 1;
      for (; e > 0; )
        n[u++] = e % i, e = Math.floor(e / i);
      return n;
    }
    c(et, "addSmall"), s.prototype.add = function(t) {
      var e = g(t);
      if (this.sign !== e.sign)
        return this.subtract(e.negate());
      var r = this.value, n = e.value;
      return e.isSmall ? new s(et(r, Math.abs(n)), this.sign) : new s(G(r, n), this.sign);
    }, s.prototype.plus = s.prototype.add, p.prototype.add = function(t) {
      var e = g(t), r = this.value;
      if (r < 0 !== e.sign)
        return this.subtract(e.negate());
      var n = e.value;
      if (e.isSmall) {
        if (v(r + n)) return new p(r + n);
        n = Z(Math.abs(n));
      }
      return new s(et(n, Math.abs(r)), r < 0);
    }, p.prototype.plus = p.prototype.add, f.prototype.add = function(t) {
      return new f(this.value + g(t).value);
    }, f.prototype.plus = f.prototype.add;
    function V(t, e) {
      var r = t.length, n = e.length, i = new Array(r), o = 0, u = w, a, l;
      for (a = 0; a < n; a++)
        l = t[a] - o - e[a], l < 0 ? (l += u, o = 1) : o = 0, i[a] = l;
      for (a = n; a < r; a++) {
        if (l = t[a] - o, l < 0) l += u;
        else {
          i[a++] = l;
          break;
        }
        i[a] = l;
      }
      for (; a < r; a++)
        i[a] = t[a];
      return q(i), i;
    }
    c(V, "subtract");
    function ut(t, e, r) {
      var n;
      return $(t, e) >= 0 ? n = V(t, e) : (n = V(e, t), r = !r), n = R(n), typeof n == "number" ? (r && (n = -n), new p(n)) : new s(n, r);
    }
    c(ut, "subtractAny");
    function X(t, e, r) {
      var n = t.length, i = new Array(n), o = -e, u = w, a, l;
      for (a = 0; a < n; a++)
        l = t[a] + o, o = Math.floor(l / u), l %= u, i[a] = l < 0 ? l + u : l;
      return i = R(i), typeof i == "number" ? (r && (i = -i), new p(i)) : new s(i, r);
    }
    c(X, "subtractSmall"), s.prototype.subtract = function(t) {
      var e = g(t);
      if (this.sign !== e.sign)
        return this.add(e.negate());
      var r = this.value, n = e.value;
      return e.isSmall ? X(r, Math.abs(n), this.sign) : ut(r, n, this.sign);
    }, s.prototype.minus = s.prototype.subtract, p.prototype.subtract = function(t) {
      var e = g(t), r = this.value;
      if (r < 0 !== e.sign)
        return this.add(e.negate());
      var n = e.value;
      return e.isSmall ? new p(r - n) : X(n, Math.abs(r), r >= 0);
    }, p.prototype.minus = p.prototype.subtract, f.prototype.subtract = function(t) {
      return new f(this.value - g(t).value);
    }, f.prototype.minus = f.prototype.subtract, s.prototype.negate = function() {
      return new s(this.value, !this.sign);
    }, p.prototype.negate = function() {
      var t = this.sign, e = new p(-this.value);
      return e.sign = !t, e;
    }, f.prototype.negate = function() {
      return new f(-this.value);
    }, s.prototype.abs = function() {
      return new s(this.value, !1);
    }, p.prototype.abs = function() {
      return new p(Math.abs(this.value));
    }, f.prototype.abs = function() {
      return new f(this.value >= 0 ? this.value : -this.value);
    };
    function rt(t, e) {
      var r = t.length, n = e.length, i = r + n, o = tt(i), u = w, a, l, d, b, S;
      for (d = 0; d < r; ++d) {
        b = t[d];
        for (var N = 0; N < n; ++N)
          S = e[N], a = b * S + o[d + N], l = Math.floor(a / u), o[d + N] = a - l * u, o[d + N + 1] += l;
      }
      return q(o), o;
    }
    c(rt, "multiplyLong");
    function K(t, e) {
      var r = t.length, n = new Array(r), i = w, o = 0, u, a;
      for (a = 0; a < r; a++)
        u = t[a] * e + o, o = Math.floor(u / i), n[a] = u - o * i;
      for (; o > 0; )
        n[a++] = o % i, o = Math.floor(o / i);
      return n;
    }
    c(K, "multiplySmall");
    function m(t, e) {
      for (var r = []; e-- > 0; ) r.push(0);
      return r.concat(t);
    }
    c(m, "shiftLeft");
    function E(t, e) {
      var r = Math.max(t.length, e.length);
      if (r <= 30) return rt(t, e);
      r = Math.ceil(r / 2);
      var n = t.slice(r), i = t.slice(0, r), o = e.slice(r), u = e.slice(0, r), a = E(i, u), l = E(n, o), d = E(G(i, n), G(u, o)), b = G(G(a, m(V(V(d, a), l), r)), m(l, 2 * r));
      return q(b), b;
    }
    c(E, "multiplyKaratsuba");
    function B(t, e) {
      return -0.012 * t - 0.012 * e + 15e-6 * t * e > 0;
    }
    c(B, "useKaratsuba"), s.prototype.multiply = function(t) {
      var e = g(t), r = this.value, n = e.value, i = this.sign !== e.sign, o;
      if (e.isSmall) {
        if (n === 0) return y[0];
        if (n === 1) return this;
        if (n === -1) return this.negate();
        if (o = Math.abs(n), o < w)
          return new s(K(r, o), i);
        n = Z(o);
      }
      return B(r.length, n.length) ? new s(E(r, n), i) : new s(rt(r, n), i);
    }, s.prototype.times = s.prototype.multiply;
    function I(t, e, r) {
      return t < w ? new s(K(e, t), r) : new s(rt(e, Z(t)), r);
    }
    c(I, "multiplySmallAndArray"), p.prototype._multiplyBySmall = function(t) {
      return v(t.value * this.value) ? new p(t.value * this.value) : I(Math.abs(t.value), Z(Math.abs(this.value)), this.sign !== t.sign);
    }, s.prototype._multiplyBySmall = function(t) {
      return t.value === 0 ? y[0] : t.value === 1 ? this : t.value === -1 ? this.negate() : I(Math.abs(t.value), this.value, this.sign !== t.sign);
    }, p.prototype.multiply = function(t) {
      return g(t)._multiplyBySmall(this);
    }, p.prototype.times = p.prototype.multiply, f.prototype.multiply = function(t) {
      return new f(this.value * g(t).value);
    }, f.prototype.times = f.prototype.multiply;
    function A(t) {
      var e = t.length, r = tt(e + e), n = w, i, o, u, a, l;
      for (u = 0; u < e; u++) {
        a = t[u], o = 0 - a * a;
        for (var d = u; d < e; d++)
          l = t[d], i = 2 * (a * l) + r[u + d] + o, o = Math.floor(i / n), r[u + d] = i - o * n;
        r[u + e] = o;
      }
      return q(r), r;
    }
    c(A, "square"), s.prototype.square = function() {
      return new s(A(this.value), !1);
    }, p.prototype.square = function() {
      var t = this.value * this.value;
      return v(t) ? new p(t) : new s(A(Z(Math.abs(this.value))), !1);
    }, f.prototype.square = function(t) {
      return new f(this.value * this.value);
    };
    function _(t, e) {
      var r = t.length, n = e.length, i = w, o = tt(e.length), u = e[n - 1], a = Math.ceil(i / (2 * u)), l = K(t, a), d = K(e, a), b, S, N, F, D, ht, yt;
      for (l.length <= r && l.push(0), d.push(0), u = d[n - 1], S = r - n; S >= 0; S--) {
        for (b = i - 1, l[S + n] !== u && (b = Math.floor((l[S + n] * i + l[S + n - 1]) / u)), N = 0, F = 0, ht = d.length, D = 0; D < ht; D++)
          N += b * d[D], yt = Math.floor(N / i), F += l[S + D] - (N - yt * i), N = yt, F < 0 ? (l[S + D] = F + i, F = -1) : (l[S + D] = F, F = 0);
        for (; F !== 0; ) {
          for (b -= 1, N = 0, D = 0; D < ht; D++)
            N += l[S + D] - i + d[D], N < 0 ? (l[S + D] = N + i, N = 0) : (l[S + D] = N, N = 1);
          F += N;
        }
        o[S] = b;
      }
      return l = J(l, a)[0], [R(o), R(l)];
    }
    c(_, "divMod1");
    function L(t, e) {
      for (var r = t.length, n = e.length, i = [], o = [], u = w, a, l, d, b, S; r; ) {
        if (o.unshift(t[--r]), q(o), $(o, e) < 0) {
          i.push(0);
          continue;
        }
        l = o.length, d = o[l - 1] * u + o[l - 2], b = e[n - 1] * u + e[n - 2], l > n && (d = (d + 1) * u), a = Math.ceil(d / b);
        do {
          if (S = K(e, a), $(S, o) <= 0) break;
          a--;
        } while (a);
        i.push(a), o = V(o, S);
      }
      return i.reverse(), [R(i), R(o)];
    }
    c(L, "divMod2");
    function J(t, e) {
      var r = t.length, n = tt(r), i = w, o, u, a, l;
      for (a = 0, o = r - 1; o >= 0; --o)
        l = a * i + t[o], u = C(l / e), a = l - u * e, n[o] = u | 0;
      return [n, a | 0];
    }
    c(J, "divModSmall");
    function Y(t, e) {
      var r, n = g(e);
      if (U)
        return [new f(t.value / n.value), new f(t.value % n.value)];
      var i = t.value, o = n.value, u;
      if (o === 0) throw new Error("Cannot divide by zero");
      if (t.isSmall)
        return n.isSmall ? [new p(C(i / o)), new p(i % o)] : [y[0], t];
      if (n.isSmall) {
        if (o === 1) return [t, y[0]];
        if (o == -1) return [t.negate(), y[0]];
        var a = Math.abs(o);
        if (a < w) {
          r = J(i, a), u = R(r[0]);
          var l = r[1];
          return t.sign && (l = -l), typeof u == "number" ? (t.sign !== n.sign && (u = -u), [new p(u), new p(l)]) : [new s(u, t.sign !== n.sign), new p(l)];
        }
        o = Z(a);
      }
      var d = $(i, o);
      if (d === -1) return [y[0], t];
      if (d === 0) return [y[t.sign === n.sign ? 1 : -1], y[0]];
      i.length + o.length <= 200 ? r = _(i, o) : r = L(i, o), u = r[0];
      var b = t.sign !== n.sign, S = r[1], N = t.sign;
      return typeof u == "number" ? (b && (u = -u), u = new p(u)) : u = new s(u, b), typeof S == "number" ? (N && (S = -S), S = new p(S)) : S = new s(S, N), [u, S];
    }
    c(Y, "divModAny"), s.prototype.divmod = function(t) {
      var e = Y(this, t);
      return {
        quotient: e[0],
        remainder: e[1]
      };
    }, f.prototype.divmod = p.prototype.divmod = s.prototype.divmod, s.prototype.divide = function(t) {
      return Y(this, t)[0];
    }, f.prototype.over = f.prototype.divide = function(t) {
      return new f(this.value / g(t).value);
    }, p.prototype.over = p.prototype.divide = s.prototype.over = s.prototype.divide, s.prototype.mod = function(t) {
      return Y(this, t)[1];
    }, f.prototype.mod = f.prototype.remainder = function(t) {
      return new f(this.value % g(t).value);
    }, p.prototype.remainder = p.prototype.mod = s.prototype.remainder = s.prototype.mod, s.prototype.pow = function(t) {
      var e = g(t), r = this.value, n = e.value, i, o, u;
      if (n === 0) return y[1];
      if (r === 0) return y[0];
      if (r === 1) return y[1];
      if (r === -1) return e.isEven() ? y[1] : y[-1];
      if (e.sign)
        return y[0];
      if (!e.isSmall) throw new Error("The exponent " + e.toString() + " is too large.");
      if (this.isSmall && v(i = Math.pow(r, n)))
        return new p(C(i));
      for (o = this, u = y[1]; n & !0 && (u = u.times(o), --n), n !== 0; )
        n /= 2, o = o.square();
      return u;
    }, p.prototype.pow = s.prototype.pow, f.prototype.pow = function(t) {
      var e = g(t), r = this.value, n = e.value, i = BigInt(0), o = BigInt(1), u = BigInt(2);
      if (n === i) return y[1];
      if (r === i) return y[0];
      if (r === o) return y[1];
      if (r === BigInt(-1)) return e.isEven() ? y[1] : y[-1];
      if (e.isNegative()) return new f(i);
      for (var a = this, l = y[1]; (n & o) === o && (l = l.times(a), --n), n !== i; )
        n /= u, a = a.square();
      return l;
    }, s.prototype.modPow = function(t, e) {
      if (t = g(t), e = g(e), e.isZero()) throw new Error("Cannot take modPow with modulus 0");
      var r = y[1], n = this.mod(e);
      for (t.isNegative() && (t = t.multiply(y[-1]), n = n.modInv(e)); t.isPositive(); ) {
        if (n.isZero()) return y[0];
        t.isOdd() && (r = r.multiply(n).mod(e)), t = t.divide(2), n = n.square().mod(e);
      }
      return r;
    }, f.prototype.modPow = p.prototype.modPow = s.prototype.modPow;
    function $(t, e) {
      if (t.length !== e.length)
        return t.length > e.length ? 1 : -1;
      for (var r = t.length - 1; r >= 0; r--)
        if (t[r] !== e[r]) return t[r] > e[r] ? 1 : -1;
      return 0;
    }
    c($, "compareAbs"), s.prototype.compareAbs = function(t) {
      var e = g(t), r = this.value, n = e.value;
      return e.isSmall ? 1 : $(r, n);
    }, p.prototype.compareAbs = function(t) {
      var e = g(t), r = Math.abs(this.value), n = e.value;
      return e.isSmall ? (n = Math.abs(n), r === n ? 0 : r > n ? 1 : -1) : -1;
    }, f.prototype.compareAbs = function(t) {
      var e = this.value, r = g(t).value;
      return e = e >= 0 ? e : -e, r = r >= 0 ? r : -r, e === r ? 0 : e > r ? 1 : -1;
    }, s.prototype.compare = function(t) {
      if (t === 1 / 0)
        return -1;
      if (t === -1 / 0)
        return 1;
      var e = g(t), r = this.value, n = e.value;
      return this.sign !== e.sign ? e.sign ? 1 : -1 : e.isSmall ? this.sign ? -1 : 1 : $(r, n) * (this.sign ? -1 : 1);
    }, s.prototype.compareTo = s.prototype.compare, p.prototype.compare = function(t) {
      if (t === 1 / 0)
        return -1;
      if (t === -1 / 0)
        return 1;
      var e = g(t), r = this.value, n = e.value;
      return e.isSmall ? r == n ? 0 : r > n ? 1 : -1 : r < 0 !== e.sign ? r < 0 ? -1 : 1 : r < 0 ? 1 : -1;
    }, p.prototype.compareTo = p.prototype.compare, f.prototype.compare = function(t) {
      if (t === 1 / 0)
        return -1;
      if (t === -1 / 0)
        return 1;
      var e = this.value, r = g(t).value;
      return e === r ? 0 : e > r ? 1 : -1;
    }, f.prototype.compareTo = f.prototype.compare, s.prototype.equals = function(t) {
      return this.compare(t) === 0;
    }, f.prototype.eq = f.prototype.equals = p.prototype.eq = p.prototype.equals = s.prototype.eq = s.prototype.equals, s.prototype.notEquals = function(t) {
      return this.compare(t) !== 0;
    }, f.prototype.neq = f.prototype.notEquals = p.prototype.neq = p.prototype.notEquals = s.prototype.neq = s.prototype.notEquals, s.prototype.greater = function(t) {
      return this.compare(t) > 0;
    }, f.prototype.gt = f.prototype.greater = p.prototype.gt = p.prototype.greater = s.prototype.gt = s.prototype.greater, s.prototype.lesser = function(t) {
      return this.compare(t) < 0;
    }, f.prototype.lt = f.prototype.lesser = p.prototype.lt = p.prototype.lesser = s.prototype.lt = s.prototype.lesser, s.prototype.greaterOrEquals = function(t) {
      return this.compare(t) >= 0;
    }, f.prototype.geq = f.prototype.greaterOrEquals = p.prototype.geq = p.prototype.greaterOrEquals = s.prototype.geq = s.prototype.greaterOrEquals, s.prototype.lesserOrEquals = function(t) {
      return this.compare(t) <= 0;
    }, f.prototype.leq = f.prototype.lesserOrEquals = p.prototype.leq = p.prototype.lesserOrEquals = s.prototype.leq = s.prototype.lesserOrEquals, s.prototype.isEven = function() {
      return (this.value[0] & 1) === 0;
    }, p.prototype.isEven = function() {
      return (this.value & 1) === 0;
    }, f.prototype.isEven = function() {
      return (this.value & BigInt(1)) === BigInt(0);
    }, s.prototype.isOdd = function() {
      return (this.value[0] & 1) === 1;
    }, p.prototype.isOdd = function() {
      return (this.value & 1) === 1;
    }, f.prototype.isOdd = function() {
      return (this.value & BigInt(1)) === BigInt(1);
    }, s.prototype.isPositive = function() {
      return !this.sign;
    }, p.prototype.isPositive = function() {
      return this.value > 0;
    }, f.prototype.isPositive = p.prototype.isPositive, s.prototype.isNegative = function() {
      return this.sign;
    }, p.prototype.isNegative = function() {
      return this.value < 0;
    }, f.prototype.isNegative = p.prototype.isNegative, s.prototype.isUnit = function() {
      return !1;
    }, p.prototype.isUnit = function() {
      return Math.abs(this.value) === 1;
    }, f.prototype.isUnit = function() {
      return this.abs().value === BigInt(1);
    }, s.prototype.isZero = function() {
      return !1;
    }, p.prototype.isZero = function() {
      return this.value === 0;
    }, f.prototype.isZero = function() {
      return this.value === BigInt(0);
    }, s.prototype.isDivisibleBy = function(t) {
      var e = g(t);
      return e.isZero() ? !1 : e.isUnit() ? !0 : e.compareAbs(2) === 0 ? this.isEven() : this.mod(e).isZero();
    }, f.prototype.isDivisibleBy = p.prototype.isDivisibleBy = s.prototype.isDivisibleBy;
    function mt(t) {
      var e = t.abs();
      if (e.isUnit()) return !1;
      if (e.equals(2) || e.equals(3) || e.equals(5)) return !0;
      if (e.isEven() || e.isDivisibleBy(3) || e.isDivisibleBy(5)) return !1;
      if (e.lesser(49)) return !0;
    }
    c(mt, "isBasicPrime");
    function lt(t, e) {
      for (var r = t.prev(), n = r, i = 0, o, u, a, l; n.isEven(); ) n = n.divide(2), i++;
      t: for (a = 0; a < e.length; a++)
        if (!t.lesser(e[a]) && (l = P(e[a]).modPow(n, t), !(l.isUnit() || l.equals(r)))) {
          for (o = i - 1; o != 0; o--) {
            if (l = l.square().mod(t), l.isUnit()) return !1;
            if (l.equals(r)) continue t;
          }
          return !1;
        }
      return !0;
    }
    c(lt, "millerRabinTest"), s.prototype.isPrime = function(t) {
      var e = mt(this);
      if (e !== h) return e;
      var r = this.abs(), n = r.bitLength();
      if (n <= 64)
        return lt(r, [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]);
      for (var i = Math.log(2) * n.toJSNumber(), o = Math.ceil(t === !0 ? 2 * Math.pow(i, 2) : i), u = [], a = 0; a < o; a++)
        u.push(P(a + 2));
      return lt(r, u);
    }, f.prototype.isPrime = p.prototype.isPrime = s.prototype.isPrime, s.prototype.isProbablePrime = function(t, e) {
      var r = mt(this);
      if (r !== h) return r;
      for (var n = this.abs(), i = t === h ? 5 : t, o = [], u = 0; u < i; u++)
        o.push(P.randBetween(2, n.minus(2), e));
      return lt(n, o);
    }, f.prototype.isProbablePrime = p.prototype.isProbablePrime = s.prototype.isProbablePrime, s.prototype.modInv = function(t) {
      for (var e = P.zero, r = P.one, n = g(t), i = this.abs(), o, u, a; !i.isZero(); )
        o = n.divide(i), u = e, a = n, e = r, n = i, r = u.subtract(o.multiply(r)), i = a.subtract(o.multiply(i));
      if (!n.isUnit()) throw new Error(this.toString() + " and " + t.toString() + " are not co-prime");
      return e.compare(0) === -1 && (e = e.add(t)), this.isNegative() ? e.negate() : e;
    }, f.prototype.modInv = p.prototype.modInv = s.prototype.modInv, s.prototype.next = function() {
      var t = this.value;
      return this.sign ? X(t, 1, this.sign) : new s(et(t, 1), this.sign);
    }, p.prototype.next = function() {
      var t = this.value;
      return t + 1 < T ? new p(t + 1) : new s(M, !1);
    }, f.prototype.next = function() {
      return new f(this.value + BigInt(1));
    }, s.prototype.prev = function() {
      var t = this.value;
      return this.sign ? new s(et(t, 1), !0) : X(t, 1, this.sign);
    }, p.prototype.prev = function() {
      var t = this.value;
      return t - 1 > -T ? new p(t - 1) : new s(M, !0);
    }, f.prototype.prev = function() {
      return new f(this.value - BigInt(1));
    };
    for (var H = [1]; 2 * H[H.length - 1] <= w; ) H.push(2 * H[H.length - 1]);
    var nt = H.length, W = H[nt - 1];
    function dt(t) {
      return Math.abs(t) <= w;
    }
    c(dt, "shift_isSmall"), s.prototype.shiftLeft = function(t) {
      var e = g(t).toJSNumber();
      if (!dt(e))
        throw new Error(String(e) + " is too large for shifting.");
      if (e < 0) return this.shiftRight(-e);
      var r = this;
      if (r.isZero()) return r;
      for (; e >= nt; )
        r = r.multiply(W), e -= nt - 1;
      return r.multiply(H[e]);
    }, f.prototype.shiftLeft = p.prototype.shiftLeft = s.prototype.shiftLeft, s.prototype.shiftRight = function(t) {
      var e, r = g(t).toJSNumber();
      if (!dt(r))
        throw new Error(String(r) + " is too large for shifting.");
      if (r < 0) return this.shiftLeft(-r);
      for (var n = this; r >= nt; ) {
        if (n.isZero() || n.isNegative() && n.isUnit()) return n;
        e = Y(n, W), n = e[1].isNegative() ? e[0].prev() : e[0], r -= nt - 1;
      }
      return e = Y(n, H[r]), e[1].isNegative() ? e[0].prev() : e[0];
    }, f.prototype.shiftRight = p.prototype.shiftRight = s.prototype.shiftRight;
    function pt(t, e, r) {
      e = g(e);
      for (var n = t.isNegative(), i = e.isNegative(), o = n ? t.not() : t, u = i ? e.not() : e, a = 0, l = 0, d = null, b = null, S = []; !o.isZero() || !u.isZero(); )
        d = Y(o, W), a = d[1].toJSNumber(), n && (a = W - 1 - a), b = Y(u, W), l = b[1].toJSNumber(), i && (l = W - 1 - l), o = d[0], u = b[0], S.push(r(a, l));
      for (var N = r(n ? 1 : 0, i ? 1 : 0) !== 0 ? P(-1) : P(0), F = S.length - 1; F >= 0; F -= 1)
        N = N.multiply(W).add(P(S[F]));
      return N;
    }
    c(pt, "bitwise"), s.prototype.not = function() {
      return this.negate().prev();
    }, f.prototype.not = p.prototype.not = s.prototype.not, s.prototype.and = function(t) {
      return pt(this, t, function(e, r) {
        return e & r;
      });
    }, f.prototype.and = p.prototype.and = s.prototype.and, s.prototype.or = function(t) {
      return pt(this, t, function(e, r) {
        return e | r;
      });
    }, f.prototype.or = p.prototype.or = s.prototype.or, s.prototype.xor = function(t) {
      return pt(this, t, function(e, r) {
        return e ^ r;
      });
    }, f.prototype.xor = p.prototype.xor = s.prototype.xor;
    var ft = 1 << 30, _t = (w & -w) * (w & -w) | ft;
    function st(t) {
      var e = t.value, r = typeof e == "number" ? e | ft : typeof e == "bigint" ? e | BigInt(ft) : e[0] + e[1] * w | _t;
      return r & -r;
    }
    c(st, "roughLOB");
    function wt(t, e) {
      if (e.compareTo(t) <= 0) {
        var r = wt(t, e.square(e)), n = r.p, i = r.e, o = n.multiply(e);
        return o.compareTo(t) <= 0 ? { p: o, e: i * 2 + 1 } : { p: n, e: i * 2 };
      }
      return { p: P(1), e: 0 };
    }
    c(wt, "integerLogarithm"), s.prototype.bitLength = function() {
      var t = this;
      return t.compareTo(P(0)) < 0 && (t = t.negate().subtract(P(1))), t.compareTo(P(0)) === 0 ? P(0) : P(wt(t, P(2)).e).add(P(1));
    }, f.prototype.bitLength = p.prototype.bitLength = s.prototype.bitLength;
    function St(t, e) {
      return t = g(t), e = g(e), t.greater(e) ? t : e;
    }
    c(St, "max");
    function ct(t, e) {
      return t = g(t), e = g(e), t.lesser(e) ? t : e;
    }
    c(ct, "min");
    function bt(t, e) {
      if (t = g(t).abs(), e = g(e).abs(), t.equals(e)) return t;
      if (t.isZero()) return e;
      if (e.isZero()) return t;
      for (var r = y[1], n, i; t.isEven() && e.isEven(); )
        n = ct(st(t), st(e)), t = t.divide(n), e = e.divide(n), r = r.multiply(n);
      for (; t.isEven(); )
        t = t.divide(st(t));
      do {
        for (; e.isEven(); )
          e = e.divide(st(e));
        t.greater(e) && (i = e, e = t, t = i), e = e.subtract(t);
      } while (!e.isZero());
      return r.isUnit() ? t : t.multiply(r);
    }
    c(bt, "gcd");
    function Dt(t, e) {
      return t = g(t).abs(), e = g(e).abs(), t.divide(bt(t, e)).multiply(e);
    }
    c(Dt, "lcm");
    function jt(t, e, r) {
      t = g(t), e = g(e);
      var n = r || Math.random, i = ct(t, e), o = St(t, e), u = o.subtract(i).add(1);
      if (u.isSmall) return i.add(Math.floor(n() * u));
      for (var a = ot(u, w).value, l = [], d = !0, b = 0; b < a.length; b++) {
        var S = d ? a[b] + (b + 1 < a.length ? a[b + 1] / w : 0) : w, N = C(n() * S);
        l.push(N), N < a[b] && (d = !1);
      }
      return i.add(y.fromArray(l, w, !1));
    }
    c(jt, "randBetween");
    var Ut = /* @__PURE__ */ c(function(t, e, r, n) {
      r = r || z, t = String(t), n || (t = t.toLowerCase(), r = r.toLowerCase());
      var i = t.length, o, u = Math.abs(e), a = {};
      for (o = 0; o < r.length; o++)
        a[r[o]] = o;
      for (o = 0; o < i; o++) {
        var l = t[o];
        if (l !== "-" && l in a && a[l] >= u) {
          if (l === "1" && u === 1) continue;
          throw new Error(l + " is not a valid digit in base " + e + ".");
        }
      }
      e = g(e);
      var d = [], b = t[0] === "-";
      for (o = b ? 1 : 0; o < t.length; o++) {
        var l = t[o];
        if (l in a) d.push(g(a[l]));
        else if (l === "<") {
          var S = o;
          do
            o++;
          while (t[o] !== ">" && o < t.length);
          d.push(g(t.slice(S + 1, o)));
        } else throw new Error(l + " is not a valid character");
      }
      return Et(d, e, b);
    }, "parseBase");
    function Et(t, e, r) {
      var n = y[0], i = y[1], o;
      for (o = t.length - 1; o >= 0; o--)
        n = n.add(t[o].times(i)), i = i.times(e);
      return r ? n.negate() : n;
    }
    c(Et, "parseBaseFromArray");
    function Ft(t, e) {
      return e = e || z, t < e.length ? e[t] : "<" + t + ">";
    }
    c(Ft, "stringify");
    function ot(t, e) {
      if (e = P(e), e.isZero()) {
        if (t.isZero()) return { value: [0], isNegative: !1 };
        throw new Error("Cannot convert nonzero numbers to base 0.");
      }
      if (e.equals(-1)) {
        if (t.isZero()) return { value: [0], isNegative: !1 };
        if (t.isNegative())
          return {
            value: [].concat.apply(
              [],
              Array.apply(null, Array(-t.toJSNumber())).map(Array.prototype.valueOf, [1, 0])
            ),
            isNegative: !1
          };
        var r = Array.apply(null, Array(t.toJSNumber() - 1)).map(Array.prototype.valueOf, [0, 1]);
        return r.unshift([1]), {
          value: [].concat.apply([], r),
          isNegative: !1
        };
      }
      var n = !1;
      if (t.isNegative() && e.isPositive() && (n = !0, t = t.abs()), e.isUnit())
        return t.isZero() ? { value: [0], isNegative: !1 } : {
          value: Array.apply(null, Array(t.toJSNumber())).map(Number.prototype.valueOf, 1),
          isNegative: n
        };
      for (var i = [], o = t, u; o.isNegative() || o.compareAbs(e) >= 0; ) {
        u = o.divmod(e), o = u.quotient;
        var a = u.remainder;
        a.isNegative() && (a = e.minus(a).abs(), o = o.next()), i.push(a.toJSNumber());
      }
      return i.push(o.toJSNumber()), { value: i.reverse(), isNegative: n };
    }
    c(ot, "toBase");
    function It(t, e, r) {
      var n = ot(t, e);
      return (n.isNegative ? "-" : "") + n.value.map(function(i) {
        return Ft(i, r);
      }).join("");
    }
    c(It, "toBaseString"), s.prototype.toArray = function(t) {
      return ot(this, t);
    }, p.prototype.toArray = function(t) {
      return ot(this, t);
    }, f.prototype.toArray = function(t) {
      return ot(this, t);
    }, s.prototype.toString = function(t, e) {
      if (t === h && (t = 10), t !== 10 || e) return It(this, t, e);
      for (var r = this.value, n = r.length, i = String(r[--n]), o = "0000000", u; --n >= 0; )
        u = String(r[n]), i += o.slice(u.length) + u;
      var a = this.sign ? "-" : "";
      return a + i;
    }, p.prototype.toString = function(t, e) {
      return t === h && (t = 10), t != 10 || e ? It(this, t, e) : String(this.value);
    }, f.prototype.toString = p.prototype.toString, f.prototype.toJSON = s.prototype.toJSON = p.prototype.toJSON = function() {
      return this.toString();
    }, s.prototype.valueOf = function() {
      return parseInt(this.toString(), 10);
    }, s.prototype.toJSNumber = s.prototype.valueOf, p.prototype.valueOf = function() {
      return this.value;
    }, p.prototype.toJSNumber = p.prototype.valueOf, f.prototype.valueOf = f.prototype.toJSNumber = function() {
      return parseInt(this.toString(), 10);
    };
    function Nt(t) {
      if (v(+t)) {
        var e = +t;
        if (e === C(e))
          return U ? new f(BigInt(e)) : new p(e);
        throw new Error("Invalid integer: " + t);
      }
      var r = t[0] === "-";
      r && (t = t.slice(1));
      var n = t.split(/e/i);
      if (n.length > 2) throw new Error("Invalid integer: " + n.join("e"));
      if (n.length === 2) {
        var i = n[1];
        if (i[0] === "+" && (i = i.slice(1)), i = +i, i !== C(i) || !v(i)) throw new Error("Invalid integer: " + i + " is not a valid exponent.");
        var o = n[0], u = o.indexOf(".");
        if (u >= 0 && (i -= o.length - u - 1, o = o.slice(0, u) + o.slice(u + 1)), i < 0) throw new Error("Cannot include negative exponent part for integers");
        o += new Array(i + 1).join("0"), t = o;
      }
      var a = /^([0-9][0-9]*)$/.test(t);
      if (!a) throw new Error("Invalid integer: " + t);
      if (U)
        return new f(BigInt(r ? "-" + t : t));
      for (var l = [], d = t.length, b = O, S = d - b; d > 0; )
        l.push(+t.slice(S, d)), S -= b, S < 0 && (S = 0), d -= b;
      return q(l), new s(l, r);
    }
    c(Nt, "parseStringValue");
    function zt(t) {
      if (U)
        return new f(BigInt(t));
      if (v(t)) {
        if (t !== C(t)) throw new Error(t + " is not an integer.");
        return new p(t);
      }
      return Nt(t.toString());
    }
    c(zt, "parseNumberValue");
    function g(t) {
      return typeof t == "number" ? zt(t) : typeof t == "string" ? Nt(t) : typeof t == "bigint" ? new f(t) : t;
    }
    c(g, "parseValue");
    for (var Q = 0; Q < 1e3; Q++)
      y[Q] = g(Q), Q > 0 && (y[-Q] = g(-Q));
    return y.one = y[1], y.zero = y[0], y.minusOne = y[-1], y.max = St, y.min = ct, y.gcd = bt, y.lcm = Dt, y.isInstance = function(t) {
      return t instanceof s || t instanceof p || t instanceof f;
    }, y.randBetween = jt, y.fromArray = function(t, e, r) {
      return Et(t.map(g), g(e || 10), r);
    }, y;
  }();
  typeof at < "u" && at.hasOwnProperty("exports") && (at.exports = P);
  typeof define == "function" && define.amd && define(function() {
    return P;
  });
});

// ../node_modules/bplist-parser/bplistParser.js
var qt = vt((x) => {
  "use strict";
  var Zt = Bt("fs"), Jt = Ot(), k = !1;
  x.maxObjectSize = 100 * 1e3 * 1e3;
  x.maxObjectCount = 32768;
  var Ct = 9783072e5, Ht = x.UID = function(h) {
    this.UID = h;
  }, re = x.parseFile = function(h, w) {
    return new Promise(function(O, T) {
      function M(z) {
        let U = null, y;
        try {
          y = kt(z), O(y);
        } catch (s) {
          U = s, T(U);
        } finally {
          w && w(U, y);
        }
      }
      if (c(M, "tryParseBuffer"), Buffer.isBuffer(h))
        return M(h);
      Zt.readFile(h, function(z, U) {
        if (z)
          return T(z), w(z);
        M(U);
      });
    });
  }, kt = x.parseBuffer = function(h) {
    if (h.slice(0, 6).toString("utf8") !== "bplist")
      throw new Error("Invalid binary plist. Expected 'bplist' at offset 0.");
    let O = h.slice(h.length - 32, h.length), T = O.readUInt8(6);
    k && console.log("offsetSize: " + T);
    let M = O.readUInt8(7);
    k && console.log("objectRefSize: " + M);
    let z = gt(O, 8);
    k && console.log("numObjects: " + z);
    let U = gt(O, 16);
    k && console.log("topObject: " + U);
    let y = gt(O, 24);
    if (k && console.log("offsetTableOffset: " + y), z > x.maxObjectCount)
      throw new Error("maxObjectCount exceeded");
    let s = [];
    for (let f = 0; f < z; f++) {
      let v = h.slice(y + f * T, y + (f + 1) * T);
      s[f] = j(v, 0), k && console.log("Offset for Object #" + f + " is " + s[f] + " [" + s[f].toString(16) + "]");
    }
    function p(f) {
      let v = s[f], Z = h[v], R = (Z & 240) >> 4, q = Z & 15;
      switch (R) {
        case 0:
          return tt();
        case 1:
          return it();
        case 8:
          return G();
        case 2:
          return et();
        case 3:
          return V();
        case 4:
          return ut();
        case 5:
          return X();
        case 6:
          return X(!0);
        case 10:
          return rt();
        case 13:
          return K();
        default:
          throw new Error("Unhandled type 0x" + R.toString(16));
      }
      function tt() {
        switch (q) {
          case 0:
            return null;
          case 8:
            return !1;
          case 9:
            return !0;
          case 15:
            return null;
          default:
            throw new Error("Unhandled simple type 0x" + R.toString(16));
        }
      }
      c(tt, "parseSimple");
      function C(m) {
        let E = "", B;
        for (B = 0; B < m.length && m[B] == 0; B++)
          ;
        for (; B < m.length; B++) {
          let I = "00" + m[B].toString(16);
          E += I.substr(I.length - 2);
        }
        return E;
      }
      c(C, "bufferToHexString");
      function it() {
        let m = Math.pow(2, q);
        if (q == 4) {
          let E = h.slice(v + 1, v + 1 + m), B = C(E);
          return Jt(B, 16);
        }
        if (q == 3)
          return h.readInt32BE(v + 1);
        if (m < x.maxObjectSize)
          return j(h.slice(v + 1, v + 1 + m));
        throw new Error("To little heap space available! Wanted to read " + m + " bytes, but only " + x.maxObjectSize + " are available.");
      }
      c(it, "parseInteger");
      function G() {
        let m = q + 1;
        if (m < x.maxObjectSize)
          return new Ht(j(h.slice(v + 1, v + 1 + m)));
        throw new Error("To little heap space available! Wanted to read " + m + " bytes, but only " + x.maxObjectSize + " are available.");
      }
      c(G, "parseUID");
      function et() {
        let m = Math.pow(2, q);
        if (m < x.maxObjectSize) {
          let E = h.slice(v + 1, v + 1 + m);
          if (m === 4)
            return E.readFloatBE(0);
          if (m === 8)
            return E.readDoubleBE(0);
        } else
          throw new Error("To little heap space available! Wanted to read " + m + " bytes, but only " + x.maxObjectSize + " are available.");
      }
      c(et, "parseReal");
      function V() {
        q != 3 && console.error("Unknown date type :" + q + ". Parsing anyway...");
        let m = h.slice(v + 1, v + 9);
        return new Date(Ct + 1e3 * m.readDoubleBE(0));
      }
      c(V, "parseDate");
      function ut() {
        let m = 1, E = q;
        if (q == 15) {
          let B = h[v + 1], I = (B & 240) / 16;
          I != 1 && console.error("0x4: UNEXPECTED LENGTH-INT TYPE! " + I);
          let A = B & 15, _ = Math.pow(2, A);
          m = 2 + _, _ < 3, E = j(h.slice(v + 2, v + 2 + _));
        }
        if (E < x.maxObjectSize)
          return h.slice(v + m, v + m + E);
        throw new Error("To little heap space available! Wanted to read " + E + " bytes, but only " + x.maxObjectSize + " are available.");
      }
      c(ut, "parseData");
      function X(m) {
        m = m || 0;
        let E = "utf8", B = q, I = 1;
        if (q == 15) {
          let A = h[v + 1], _ = (A & 240) / 16;
          _ != 1 && console.err("UNEXPECTED LENGTH-INT TYPE! " + _);
          let L = A & 15, J = Math.pow(2, L);
          I = 2 + J, J < 3, B = j(h.slice(v + 2, v + 2 + J));
        }
        if (B *= m + 1, B < x.maxObjectSize) {
          let A = Buffer.from(h.slice(v + I, v + I + B));
          return m && (A = Gt(A), E = "ucs2"), A.toString(E);
        }
        throw new Error("To little heap space available! Wanted to read " + B + " bytes, but only " + x.maxObjectSize + " are available.");
      }
      c(X, "parsePlistString");
      function rt() {
        let m = q, E = 1;
        if (q == 15) {
          let I = h[v + 1], A = (I & 240) / 16;
          A != 1 && console.error("0xa: UNEXPECTED LENGTH-INT TYPE! " + A);
          let _ = I & 15, L = Math.pow(2, _);
          E = 2 + L, L < 3, m = j(h.slice(v + 2, v + 2 + L));
        }
        if (m * M > x.maxObjectSize)
          throw new Error("To little heap space available!");
        let B = [];
        for (let I = 0; I < m; I++) {
          let A = j(h.slice(v + E + I * M, v + E + (I + 1) * M));
          B[I] = p(A);
        }
        return B;
      }
      c(rt, "parseArray");
      function K() {
        let m = q, E = 1;
        if (q == 15) {
          let I = h[v + 1], A = (I & 240) / 16;
          A != 1 && console.error("0xD: UNEXPECTED LENGTH-INT TYPE! " + A);
          let _ = I & 15, L = Math.pow(2, _);
          E = 2 + L, L < 3, m = j(h.slice(v + 2, v + 2 + L));
        }
        if (m * 2 * M > x.maxObjectSize)
          throw new Error("To little heap space available!");
        k && console.log("Parsing dictionary #" + f);
        let B = {};
        for (let I = 0; I < m; I++) {
          let A = j(h.slice(v + E + I * M, v + E + (I + 1) * M)), _ = j(h.slice(v + E + m * M + I * M, v + E + m * M + (I + 1) * M)), L = p(A), J = p(_);
          k && console.log("  DICT #" + f + ": Mapped " + L + " to " + J), B[L] = J;
        }
        return B;
      }
      c(K, "parseDictionary");
    }
    return c(p, "parseObject"), [p(U)];
  };
  function j(h, w) {
    w = w || 0;
    let O = 0;
    for (let T = w; T < h.length; T++)
      O <<= 8, O |= h[T] & 255;
    return O;
  }
  c(j, "readUInt");
  function gt(h, w) {
    return h.slice(w, w + 8).readUInt32BE(4, 8);
  }
  c(gt, "readUInt64BE");
  function Gt(h) {
    let w = h.length;
    for (let O = 0; O < w; O += 2) {
      let T = h[O];
      h[O] = h[O + 1], h[O + 1] = T;
    }
    return h;
  }
  c(Gt, "swapBytes");
});

// ../node_modules/untildify/index.js
var Pt = vt((ie, At) => {
  "use strict";
  var Vt = Bt("os"), Tt = Vt.homedir();
  At.exports = (h) => {
    if (typeof h != "string")
      throw new TypeError(`Expected a string, got ${typeof h}`);
    return Tt ? h.replace(/^~(?=$|\/|\\)/, Tt) : h;
  };
});

// ../node_modules/@aw-web-design/x-default-browser/node_modules/default-browser-id/index.js
import Xt from "os";
import { promises as Kt } from "fs";
async function Wt() {
  if (process.platform !== "darwin")
    throw new Error("macOS only");
  let h = "com.apple.Safari", w;
  try {
    w = await Kt.readFile($t);
  } catch (M) {
    if (M.code === "ENOENT")
      return h;
    throw M;
  }
  let O = xt.default.parseBuffer(w), T = O && O[0].LSHandlers;
  if (!T || T.length === 0)
    return h;
  for (let M of T)
    if (M.LSHandlerURLScheme === "http" && M.LSHandlerRoleAll) {
      h = M.LSHandlerRoleAll;
      break;
    }
  return h;
}
var xt, Lt, Yt, $t, Qt = Rt(() => {
  xt = Mt(qt(), 1), Lt = Mt(Pt(), 1), Yt = Number(Xt.release().split(".")[0]), $t = (0, Lt.default)(Yt >= 14 ? "~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist" : "~/Library/Preferences/com.apple.LaunchServices.plist");
  c(Wt, "defaultBrowserId");
});
Qt();
export {
  Wt as default
};
