import { jsxs as u, jsx as a } from "react/jsx-runtime";
import { cloneElement as B } from "react";
import C from "../../foundation/Icon/Generated/IconCross.es.js";
import { IconSize as c } from "../../foundation/Icon/IconSize.es.js";
import { FOCUS_VISIBLE_STYLE as g } from "../../utilities/focusStyle.es.js";
import { merge as m } from "../../utilities/merge.es.js";
import { BadgeStatusIcon as j } from "./BadgeStatusIcon.es.js";
import { getStyleClasses as v, getCircularSizeClasses as z, getSizeClasses as E } from "./helpers.es.js";
import { BadgeEmphasis as d, BadgeStyle as $ } from "./types.es.js";
const h = ({
  children: e,
  status: r,
  icon: i,
  style: x = $.Primary,
  size: w = "medium",
  emphasis: b = d.None,
  disabled: s = !1,
  onClick: o,
  onDismiss: l,
  "data-test-id": n = "badge",
  withTitleAttribute: S = !0
}) => {
  if (!e && !i && !r)
    return null;
  const y = o ? "button" : "span", p = (t) => ["string", "number"].includes(typeof t) ? t : Array.isArray(t) ? t.map(p).join("") : t && typeof t == "object" && "props" in t ? p(t.props.children) : "", f = p(e), N = !e && !l && !!(r || i);
  return /* @__PURE__ */ u(
    "div",
    {
      className: m([
        "tw-relative tw-rounded-full tw-inline-flex tw-items-center tw-align-top tw-min-w-0 tw-flex-initial tw-transition-color",
        s ? "tw-bg-box-disabled tw-text-box-disabled-inverse" : v(x, !!o, b === d.Strong)
      ]),
      "data-test-id": n,
      children: [
        /* @__PURE__ */ u(
          y,
          {
            onClick: () => o && o(),
            className: m([
              "tw-inline-flex tw-items-center tw-justify-center tw-rounded-full tw-select-none tw-flex-initial tw-min-w-0",
              o && !s ? "hover:tw-cursor-pointer" : "tw-cursor-default",
              N ? z(w) : E(e, r, i, w, !!l),
              g
            ]),
            "data-test-id": `${n}-button`,
            title: S ? f : void 0,
            children: [
              r && /* @__PURE__ */ a(j, { status: r, disabled: s, "data-test-id": n }),
              i && /* @__PURE__ */ a(
                "span",
                {
                  "data-test-id": `${n}-icon`,
                  className: m([
                    "tw-flex-none tw-leading-none",
                    s && "tw-opacity-30",
                    !!e && "tw-pr-1"
                  ]),
                  children: B(i, { size: c.Size16 })
                }
              ),
              e && /* @__PURE__ */ a("span", { className: "tw-text-center tw-text-xxs tw-font-sans tw-font-normal tw-truncate tw-px-0.5", children: e })
            ]
          }
        ),
        l && /* @__PURE__ */ a(
          "button",
          {
            type: "button",
            "data-test-id": `${n}-dismiss`,
            className: m([
              "tw-absolute tw-rounded tw-leading-4",
              g,
              w === "medium" ? "tw-right-1.5" : "tw-right-1"
            ]),
            onClick: () => l(),
            "aria-label": `Dismiss ${f}`,
            children: /* @__PURE__ */ a(C, { size: c.Size16 })
          }
        )
      ]
    }
  );
};
h.displayName = "FondueBadge";
export {
  h as Badge
};
//# sourceMappingURL=Badge.es.js.map
