import { aZ as rn, a_ as an, a$ as l, aY as on, b0 as j, b1 as F, b2 as E, b3 as un, b4 as cn, b5 as Y, b6 as y, aW as D, b7 as yn, b8 as sn, b9 as en } from "./index-Bh-wTBlD.js";
function fn(r) {
  return r.innerRadius;
}
function ln(r) {
  return r.outerRadius;
}
function gn(r) {
  return r.startAngle;
}
function pn(r) {
  return r.endAngle;
}
function xn(r) {
  return r && r.padAngle;
}
function mn(r, d, q, P, v, b, H, a) {
  var C = q - r, s = P - d, n = H - v, p = a - b, u = p * C - n * s;
  if (!(u * u < l))
    return u = (n * (d - b) - p * (r - v)) / u, [r + u * C, d + u * s];
}
function N(r, d, q, P, v, b, H) {
  var a = r - q, C = d - P, s = (H ? b : -b) / Y(a * a + C * C), n = s * C, p = -s * a, u = r + n, i = d + p, e = q + n, f = P + p, I = (u + e) / 2, o = (i + f) / 2, x = e - u, g = f - i, T = x * x + g * g, A = v - b, O = u * f - e * i, _ = (g < 0 ? -1 : 1) * Y(yn(0, A * A * T - O * O)), $ = (O * g - x * _) / T, B = (-O * x - g * _) / T, R = (O * g + x * _) / T, m = (-O * x + g * _) / T, h = $ - I, t = B - o, c = R - I, L = m - o;
  return h * h + t * t > c * c + L * L && ($ = R, B = m), {
    cx: $,
    cy: B,
    x01: -n,
    y01: -p,
    x11: $ * (v / A - 1),
    y11: B * (v / A - 1)
  };
}
function dn() {
  var r = fn, d = ln, q = D(0), P = null, v = gn, b = pn, H = xn, a = null, C = rn(s);
  function s() {
    var n, p, u = +r.apply(this, arguments), i = +d.apply(this, arguments), e = v.apply(this, arguments) - an, f = b.apply(this, arguments) - an, I = un(f - e), o = f > e;
    if (a || (a = n = C()), i < u && (p = i, i = u, u = p), !(i > l)) a.moveTo(0, 0);
    else if (I > on - l)
      a.moveTo(i * j(e), i * F(e)), a.arc(0, 0, i, e, f, !o), u > l && (a.moveTo(u * j(f), u * F(f)), a.arc(0, 0, u, f, e, o));
    else {
      var x = e, g = f, T = e, A = f, O = I, _ = I, $ = H.apply(this, arguments) / 2, B = $ > l && (P ? +P.apply(this, arguments) : Y(u * u + i * i)), R = E(un(i - u) / 2, +q.apply(this, arguments)), m = R, h = R, t, c;
      if (B > l) {
        var L = sn(B / u * F($)), Z = sn(B / i * F($));
        (O -= L * 2) > l ? (L *= o ? 1 : -1, T += L, A -= L) : (O = 0, T = A = (e + f) / 2), (_ -= Z * 2) > l ? (Z *= o ? 1 : -1, x += Z, g -= Z) : (_ = 0, x = g = (e + f) / 2);
      }
      var z = i * j(x), S = i * F(x), k = u * j(A), G = u * F(A);
      if (R > l) {
        var X = i * j(g), M = i * F(g), Q = u * j(T), U = u * F(T), W;
        if (I < cn)
          if (W = mn(z, S, Q, U, X, M, k, G)) {
            var V = z - W[0], w = S - W[1], J = X - W[0], K = M - W[1], nn = 1 / F(en((V * J + w * K) / (Y(V * V + w * w) * Y(J * J + K * K))) / 2), tn = Y(W[0] * W[0] + W[1] * W[1]);
            m = E(R, (u - tn) / (nn - 1)), h = E(R, (i - tn) / (nn + 1));
          } else
            m = h = 0;
      }
      _ > l ? h > l ? (t = N(Q, U, z, S, i, h, o), c = N(X, M, k, G, i, h, o), a.moveTo(t.cx + t.x01, t.cy + t.y01), h < R ? a.arc(t.cx, t.cy, h, y(t.y01, t.x01), y(c.y01, c.x01), !o) : (a.arc(t.cx, t.cy, h, y(t.y01, t.x01), y(t.y11, t.x11), !o), a.arc(0, 0, i, y(t.cy + t.y11, t.cx + t.x11), y(c.cy + c.y11, c.cx + c.x11), !o), a.arc(c.cx, c.cy, h, y(c.y11, c.x11), y(c.y01, c.x01), !o))) : (a.moveTo(z, S), a.arc(0, 0, i, x, g, !o)) : a.moveTo(z, S), !(u > l) || !(O > l) ? a.lineTo(k, G) : m > l ? (t = N(k, G, X, M, u, -m, o), c = N(z, S, Q, U, u, -m, o), a.lineTo(t.cx + t.x01, t.cy + t.y01), m < R ? a.arc(t.cx, t.cy, m, y(t.y01, t.x01), y(c.y01, c.x01), !o) : (a.arc(t.cx, t.cy, m, y(t.y01, t.x01), y(t.y11, t.x11), !o), a.arc(0, 0, u, y(t.cy + t.y11, t.cx + t.x11), y(c.cy + c.y11, c.cx + c.x11), o), a.arc(c.cx, c.cy, m, y(c.y11, c.x11), y(c.y01, c.x01), !o))) : a.arc(0, 0, u, A, T, o);
    }
    if (a.closePath(), n) return a = null, n + "" || null;
  }
  return s.centroid = function() {
    var n = (+r.apply(this, arguments) + +d.apply(this, arguments)) / 2, p = (+v.apply(this, arguments) + +b.apply(this, arguments)) / 2 - cn / 2;
    return [j(p) * n, F(p) * n];
  }, s.innerRadius = function(n) {
    return arguments.length ? (r = typeof n == "function" ? n : D(+n), s) : r;
  }, s.outerRadius = function(n) {
    return arguments.length ? (d = typeof n == "function" ? n : D(+n), s) : d;
  }, s.cornerRadius = function(n) {
    return arguments.length ? (q = typeof n == "function" ? n : D(+n), s) : q;
  }, s.padRadius = function(n) {
    return arguments.length ? (P = n == null ? null : typeof n == "function" ? n : D(+n), s) : P;
  }, s.startAngle = function(n) {
    return arguments.length ? (v = typeof n == "function" ? n : D(+n), s) : v;
  }, s.endAngle = function(n) {
    return arguments.length ? (b = typeof n == "function" ? n : D(+n), s) : b;
  }, s.padAngle = function(n) {
    return arguments.length ? (H = typeof n == "function" ? n : D(+n), s) : H;
  }, s.context = function(n) {
    return arguments.length ? (a = n ?? null, s) : a;
  }, s;
}
export {
  dn as h
};
