import * as i from "react";
import { useContext as x } from "react";
import { presetPrimaryColors as y } from "../../../@ant-design/colors/es/index.mjs";
import { devUseWarning as w } from "../_util/warning.mjs";
import { getSize as E, validProgress as l, getSuccessPercent as S } from "./utils.mjs";
import "../config-provider/index.mjs";
import { ConfigContext as j } from "../config-provider/context.mjs";
var N = globalThis && globalThis.__rest || function(t, n) {
  var o = {};
  for (var e in t)
    Object.prototype.hasOwnProperty.call(t, e) && n.indexOf(e) < 0 && (o[e] = t[e]);
  if (t != null && typeof Object.getOwnPropertySymbols == "function")
    for (var r = 0, e = Object.getOwnPropertySymbols(t); r < e.length; r++)
      n.indexOf(e[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, e[r]) && (o[e[r]] = t[e[r]]);
  return o;
};
const _ = (t) => {
  let n = [];
  return Object.keys(t).forEach((o) => {
    const e = parseFloat(o.replace(/%/g, ""));
    isNaN(e) || n.push({
      key: e,
      value: t[o]
    });
  }), n = n.sort((o, e) => o.key - e.key), n.map((o) => {
    let {
      key: e,
      value: r
    } = o;
    return `${r} ${e}%`;
  }).join(", ");
}, z = (t, n) => {
  const {
    from: o = y.blue,
    to: e = y.blue,
    direction: r = n === "rtl" ? "to left" : "to right"
  } = t, c = N(t, ["from", "to", "direction"]);
  if (Object.keys(c).length !== 0) {
    const s = _(c);
    return {
      backgroundImage: `linear-gradient(${r}, ${s})`
    };
  }
  return {
    backgroundImage: `linear-gradient(${r}, ${o}, ${e})`
  };
}, W = (t) => {
  const {
    prefixCls: n,
    direction: o,
    percent: e,
    size: r,
    strokeWidth: c,
    strokeColor: s,
    strokeLinecap: g = "round",
    children: b,
    trailColor: h = null,
    success: a
  } = t, {
    direction: p
  } = x(j), k = s && typeof s != "string" ? z(s, o) : {
    backgroundColor: s
  }, d = g === "square" || g === "butt" ? 0 : void 0, v = {
    backgroundColor: h || void 0,
    borderRadius: d
  }, $ = r ?? [-1, c || (r === "small" ? 6 : 8)], [f, u] = E($, "line", {
    strokeWidth: c
  });
  process.env.NODE_ENV !== "production" && w("Progress").deprecated(!("strokeWidth" in t), "strokeWidth", "size");
  const O = Object.assign({
    width: "100%",
    height: u,
    borderRadius: d,
    clipPath: p === "rtl" ? `inset(0 0 0 ${100 - l(e)}% round 100px)` : `inset(0 ${100 - l(e)}% 0 0 round 100px)`
  }, k), m = S(t), P = {
    width: "100%",
    height: u,
    borderRadius: d,
    clipPath: p === "rtl" ? `inset(0 0 0 ${100 - l(m)}% round 100px)` : `inset(0 ${100 - l(m)}% 0 0 round 100px)`,
    backgroundColor: a == null ? void 0 : a.strokeColor
  }, C = {
    width: f < 0 ? "100%" : f,
    height: u
  };
  return /* @__PURE__ */ i.createElement(i.Fragment, null, /* @__PURE__ */ i.createElement("div", {
    className: `${n}-outer`,
    style: C
  }, /* @__PURE__ */ i.createElement("div", {
    className: `${n}-inner`,
    style: v
  }, /* @__PURE__ */ i.createElement("div", {
    className: `${n}-bg`,
    style: O
  }), m !== void 0 ? /* @__PURE__ */ i.createElement("div", {
    className: `${n}-success-bg`,
    style: P
  }) : null)), b);
}, A = W;
export {
  A as default,
  z as handleGradient,
  _ as sortGradient
};
