import * as e from "react";
import R from "../../../@ant-design/icons/es/icons/CloseOutlined.mjs";
import z from "../../../classnames/index.mjs";
import { isPresetColor as F, isPresetStatusColor as U } from "../_util/colors.mjs";
import q from "../_util/hooks/useClosable.mjs";
import { devUseWarning as A } from "../_util/warning.mjs";
import B from "../_util/wave/index.mjs";
import "../config-provider/index.mjs";
import G from "./CheckableTag.mjs";
import H from "./style/index.mjs";
import J from "./style/presetCmp.mjs";
import K from "./style/statusCmp.mjs";
import { ConfigContext as L } from "../config-provider/context.mjs";
var M = globalThis && globalThis.__rest || function(s, f) {
  var c = {};
  for (var o in s)
    Object.prototype.hasOwnProperty.call(s, o) && f.indexOf(o) < 0 && (c[o] = s[o]);
  if (s != null && typeof Object.getOwnPropertySymbols == "function")
    for (var r = 0, o = Object.getOwnPropertySymbols(s); r < o.length; r++)
      f.indexOf(o[r]) < 0 && Object.prototype.propertyIsEnumerable.call(s, o[r]) && (c[o[r]] = s[o[r]]);
  return c;
};
const Q = (s, f) => {
  const {
    prefixCls: c,
    className: o,
    rootClassName: r,
    style: O,
    children: m,
    icon: E,
    color: n,
    onClose: p,
    closeIcon: h,
    closable: x,
    bordered: T = !0
  } = s, a = M(s, ["prefixCls", "className", "rootClassName", "style", "children", "icon", "color", "onClose", "closeIcon", "closable", "bordered"]), {
    getPrefixCls: k,
    direction: P,
    tag: i
  } = e.useContext(L), [S, C] = e.useState(!0);
  process.env.NODE_ENV !== "production" && A("Tag").deprecated(!("visible" in a), "visible", "visible && <Tag />"), e.useEffect(() => {
    "visible" in a && C(a.visible);
  }, [a.visible]);
  const g = F(n), b = U(n), d = g || b, $ = Object.assign(Object.assign({
    backgroundColor: n && !d ? n : void 0
  }, i == null ? void 0 : i.style), O), t = k("tag", c), [j, w, I] = H(t), _ = z(t, i == null ? void 0 : i.className, {
    [`${t}-${n}`]: d,
    [`${t}-has-color`]: n && !d,
    [`${t}-hidden`]: !S,
    [`${t}-rtl`]: P === "rtl",
    [`${t}-borderless`]: !T
  }, o, r, w, I), v = (l) => {
    l.stopPropagation(), p == null || p(l), !l.defaultPrevented && C(!1);
  }, [, V] = q(x, h, (l) => l === null ? /* @__PURE__ */ e.createElement(R, {
    className: `${t}-close-icon`,
    onClick: v
  }) : /* @__PURE__ */ e.createElement("span", {
    className: `${t}-close-icon`,
    onClick: v
  }, l), null, !1), W = typeof a.onClick == "function" || m && m.type === "a", y = E || null, D = y ? /* @__PURE__ */ e.createElement(e.Fragment, null, y, m && /* @__PURE__ */ e.createElement("span", null, m)) : m, N = /* @__PURE__ */ e.createElement("span", Object.assign({}, a, {
    ref: f,
    className: _,
    style: $
  }), D, V, g && /* @__PURE__ */ e.createElement(J, {
    key: "preset",
    prefixCls: t
  }), b && /* @__PURE__ */ e.createElement(K, {
    key: "status",
    prefixCls: t
  }));
  return j(W ? /* @__PURE__ */ e.createElement(B, {
    component: "Tag"
  }, N) : N);
}, u = /* @__PURE__ */ e.forwardRef(Q);
process.env.NODE_ENV !== "production" && (u.displayName = "Tag");
u.CheckableTag = G;
const ce = u;
export {
  ce as default
};
