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