import { jsx, jsxs } from 'react/jsx-runtime';
import { forwardRef } from 'react';
import { useTranslation } from 'react-i18next';
import { c as cn } from './utils-BJnb9o5c.js';
import { r as renderIcon } from './renderIcon-C6twJSqH.js';
import { Badge as Badge$1 } from './primitives/Badge.js';
import { X } from './x-_o2T3n6D.js';

const SIZE_CONFIG = {
  sm: {
    iconPl: "pl-1",
    iconPr: "pr-1",
    dismissPr: "pr-0.5",
    btnSize: "size-3",
    iconSize: "size-2"
  },
  default: {
    iconPl: "pl-1.5",
    iconPr: "pr-1.5",
    dismissPr: "pr-1",
    btnSize: "size-3.5",
    iconSize: "size-2.5"
  },
  lg: {
    iconPl: "pl-2",
    iconPr: "pr-2",
    dismissPr: "pr-1",
    btnSize: "size-4.5",
    iconSize: "size-3"
  }
};
const INDICATOR_COLORS = {
  default: "bg-primary",
  secondary: "bg-muted-foreground",
  destructive: "bg-destructive",
  blue: "bg-blue-600",
  green: "bg-green-600",
  amber: "bg-amber-400",
  red: "bg-red-600",
  purple: "bg-purple-700",
  pink: "bg-pink-600",
  teal: "bg-teal-600",
  gray: "bg-gray-400"
};

const Badge = forwardRef(
  ({
    variant = "default",
    size = "default",
    shape = "pill",
    label,
    icon,
    iconPosition = "left",
    indicator,
    onDismiss,
    disabled = false,
    className,
    asChild = false,
    children,
    ...otherProps
  }, ref) => {
    const { t } = useTranslation();
    if (asChild) {
      return /* @__PURE__ */ jsx(
        Badge$1,
        {
          ref,
          asChild: true,
          variant,
          size,
          shape,
          className,
          ...otherProps,
          children
        }
      );
    }
    const renderLabel = label || children;
    const iconElement = icon ? renderIcon(icon) : null;
    const hasDismiss = !!onDismiss && !disabled;
    return /* @__PURE__ */ jsxs(
      Badge$1,
      {
        ref,
        variant,
        size,
        shape,
        className: cn(
          disabled && "opacity-50 pointer-events-none",
          icon && iconPosition === "left" && SIZE_CONFIG[size].iconPl,
          icon && iconPosition === "right" && SIZE_CONFIG[size].iconPr,
          hasDismiss && SIZE_CONFIG[size].dismissPr,
          className
        ),
        ...otherProps,
        children: [
          indicator && /* @__PURE__ */ jsx(
            "span",
            {
              "aria-hidden": "true",
              className: cn(
                "size-1.5 shrink-0 rounded-full",
                INDICATOR_COLORS[indicator]
              )
            }
          ),
          iconPosition === "left" && iconElement,
          renderLabel,
          iconPosition === "right" && iconElement,
          onDismiss && !disabled && /* @__PURE__ */ jsx(
            "button",
            {
              type: "button",
              "aria-label": t("neetoatoms.badge.dismiss", "Dismiss"),
              onClick: onDismiss,
              className: cn(
                "inline-flex shrink-0 items-center justify-center rounded-full bg-current/15 transition-[background-color,opacity] hover:bg-current/25 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",
                SIZE_CONFIG[size].btnSize
              ),
              children: /* @__PURE__ */ jsx(X, { className: SIZE_CONFIG[size].iconSize })
            }
          )
        ]
      }
    );
  }
);
Badge.displayName = "Badge";

export { Badge as B };
//# sourceMappingURL=Badge-DC6zxOwS.js.map
