import Y from "../../../@babel/runtime/helpers/esm/extends.mjs";
import h from "../../../@babel/runtime/helpers/esm/typeof.mjs";
import B from "../../../@babel/runtime/helpers/esm/objectSpread2.mjs";
import ee from "../../../@babel/runtime/helpers/esm/objectWithoutProperties.mjs";
import * as C from "react";
import re from "../../../classnames/index.mjs";
import { defaultProps as te, useTransitionDuration as oe } from "../common.mjs";
import ae from "../hooks/useId.mjs";
import ie from "./PtgCircle.mjs";
import { VIEW_BOX_SIZE as S, getCircleStyle as D } from "./util.mjs";
var se = ["id", "prefixCls", "steps", "strokeWidth", "trailWidth", "gapDegree", "gapPosition", "trailColor", "strokeLinecap", "style", "className", "strokeColor", "percent"];
function F(f) {
  var a = f ?? [];
  return Array.isArray(a) ? a : [a];
}
var ce = function(a) {
  var e = B(B({}, te), a), E = e.id, d = e.prefixCls, P = e.steps, r = e.strokeWidth, G = e.trailWidth, I = e.gapDegree, t = I === void 0 ? 0 : I, L = e.gapPosition, W = e.trailColor, M = e.strokeLinecap, O = e.style, R = e.className, T = e.strokeColor, X = e.percent, Z = ee(e, se), i = S / 2, q = ae(E), j = "".concat(q, "-gradient"), m = i - r / 2, u = Math.PI * 2 * m, _ = t > 0 ? 90 + t / 2 : -90, s = u * ((360 - t) / 360), x = h(P) === "object" ? P : {
    count: P,
    space: 2
  }, c = x.count, A = x.space, V = F(X), n = F(T), $ = n.find(function(g) {
    return g && h(g) === "object";
  }), H = $ && h($) === "object", v = H ? "butt" : M, J = D(u, s, 0, 100, _, t, L, W, v, r), w = oe(), K = function() {
    var k = 0;
    return V.map(function(l, o) {
      var N = n[o] || n[n.length - 1], p = D(u, s, k, l, _, t, L, N, v, r);
      return k += l, /* @__PURE__ */ C.createElement(ie, {
        key: o,
        color: N,
        ptg: l,
        radius: m,
        prefixCls: d,
        gradientId: j,
        style: p,
        strokeLinecap: v,
        strokeWidth: r,
        gapDegree: t,
        ref: function(b) {
          w[o] = b;
        },
        size: S
      });
    }).reverse();
  }, Q = function() {
    var k = Math.round(c * (V[0] / 100)), l = 100 / c, o = 0;
    return new Array(c).fill(null).map(function(N, p) {
      var y = p <= k - 1 ? n[0] : W, b = y && h(y) === "object" ? "url(#".concat(j, ")") : void 0, z = D(u, s, o, l, _, t, L, y, "butt", r, A);
      return o += (s - z.strokeDashoffset + A) * 100 / s, /* @__PURE__ */ C.createElement("circle", {
        key: p,
        className: "".concat(d, "-circle-path"),
        r: m,
        cx: i,
        cy: i,
        stroke: b,
        strokeWidth: r,
        opacity: 1,
        style: z,
        ref: function(U) {
          w[p] = U;
        }
      });
    });
  };
  return /* @__PURE__ */ C.createElement("svg", Y({
    className: re("".concat(d, "-circle"), R),
    viewBox: "0 0 ".concat(S, " ").concat(S),
    style: O,
    id: E,
    role: "presentation"
  }, Z), !c && /* @__PURE__ */ C.createElement("circle", {
    className: "".concat(d, "-circle-trail"),
    r: m,
    cx: i,
    cy: i,
    stroke: W,
    strokeLinecap: v,
    strokeWidth: G || r,
    style: J
  }), c ? Q() : K());
};
process.env.NODE_ENV !== "production" && (ce.displayName = "Circle");
export {
  ce as default
};
