import * as s from "react";
import F from "../../../@ant-design/icons/es/icons/CheckCircleFilled.mjs";
import L from "../../../@ant-design/icons/es/icons/CheckOutlined.mjs";
import M from "../../../@ant-design/icons/es/icons/CloseCircleFilled.mjs";
import R from "../../../@ant-design/icons/es/icons/CloseOutlined.mjs";
import W from "../../../classnames/index.mjs";
import G from "../../../rc-util/es/omit.mjs";
import { devUseWarning as U } from "../_util/warning.mjs";
import "../config-provider/index.mjs";
import q from "./Circle.mjs";
import B from "./Line.mjs";
import H from "./Steps.mjs";
import J from "./style/index.mjs";
import { getSuccessPercent as S, validProgress as w, getSize as K } from "./utils.mjs";
import { ConfigContext as Q } from "../config-provider/context.mjs";
var X = globalThis && globalThis.__rest || function(e, p) {
  var d = {};
  for (var t in e)
    Object.prototype.hasOwnProperty.call(e, t) && p.indexOf(t) < 0 && (d[t] = e[t]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
    for (var i = 0, t = Object.getOwnPropertySymbols(e); i < t.length; i++)
      p.indexOf(t[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[i]) && (d[t[i]] = e[t[i]]);
  return d;
};
const Y = ["normal", "exception", "active", "success"], $ = /* @__PURE__ */ s.forwardRef((e, p) => {
  const {
    prefixCls: d,
    className: t,
    rootClassName: i,
    steps: C,
    strokeColor: a,
    percent: u = 0,
    size: g = "default",
    showInfo: v = !0,
    type: o = "line",
    status: b,
    format: O,
    style: k
  } = e, j = X(e, ["prefixCls", "className", "rootClassName", "steps", "strokeColor", "percent", "size", "showInfo", "type", "status", "format", "style"]), y = s.useMemo(() => {
    var c, n;
    const m = S(e);
    return parseInt(m !== void 0 ? (c = m ?? 0) === null || c === void 0 ? void 0 : c.toString() : (n = u ?? 0) === null || n === void 0 ? void 0 : n.toString(), 10);
  }, [u, e.success, e.successPercent]), l = s.useMemo(() => !Y.includes(b) && y >= 100 ? "success" : b || "normal", [b, y]), {
    getPrefixCls: _,
    direction: x,
    progress: f
  } = s.useContext(Q), r = _("progress", d), [z, A, I] = J(r), P = s.useMemo(() => {
    if (!v)
      return null;
    const c = S(e);
    let n;
    const m = O || ((T) => `${T}%`), E = o === "line";
    return O || l !== "exception" && l !== "success" ? n = m(w(u), w(c)) : l === "exception" ? n = E ? /* @__PURE__ */ s.createElement(M, null) : /* @__PURE__ */ s.createElement(R, null) : l === "success" && (n = E ? /* @__PURE__ */ s.createElement(F, null) : /* @__PURE__ */ s.createElement(L, null)), /* @__PURE__ */ s.createElement("span", {
      className: `${r}-text`,
      title: typeof n == "string" ? n : void 0
    }, n);
  }, [v, u, y, l, o, r, O]);
  if (process.env.NODE_ENV !== "production") {
    const c = U("Progress");
    c.deprecated(!("successPercent" in e), "successPercent", "success.percent"), c.deprecated(!("width" in e), "width", "size"), (o === "circle" || o === "dashboard") && Array.isArray(g) && process.env.NODE_ENV !== "production" && c(!1, "usage", 'Type "circle" and "dashboard" do not accept array as `size`, please use number or preset size instead.'), e.success && "progress" in e.success && c.deprecated(!1, "success.progress", "success.percent");
  }
  const N = Array.isArray(a) ? a[0] : a, V = typeof a == "string" || Array.isArray(a) ? a : void 0;
  let h;
  o === "line" ? h = C ? /* @__PURE__ */ s.createElement(H, Object.assign({}, e, {
    strokeColor: V,
    prefixCls: r,
    steps: C
  }), P) : /* @__PURE__ */ s.createElement(B, Object.assign({}, e, {
    strokeColor: N,
    prefixCls: r,
    direction: x
  }), P) : (o === "circle" || o === "dashboard") && (h = /* @__PURE__ */ s.createElement(q, Object.assign({}, e, {
    strokeColor: N,
    prefixCls: r,
    progressStatus: l
  }), P));
  const D = W(r, `${r}-status-${l}`, `${r}-${o === "dashboard" && "circle" || C && "steps" || o}`, {
    [`${r}-inline-circle`]: o === "circle" && K(g, "circle")[0] <= 20,
    [`${r}-show-info`]: v,
    [`${r}-${g}`]: typeof g == "string",
    [`${r}-rtl`]: x === "rtl"
  }, f == null ? void 0 : f.className, t, i, A, I);
  return z(/* @__PURE__ */ s.createElement("div", Object.assign({
    ref: p,
    style: Object.assign(Object.assign({}, f == null ? void 0 : f.style), k),
    className: D,
    role: "progressbar",
    "aria-valuenow": y
  }, G(j, ["trailColor", "strokeWidth", "width", "gapDegree", "gapPosition", "strokeLinecap", "success", "successPercent"])), h));
});
process.env.NODE_ENV !== "production" && ($.displayName = "Progress");
const de = $;
export {
  de as default
};
