import React from "react";
import { Slot } from "@radix-ui/react-slot";
import { cva } from "class-variance-authority";

const badgeVariants = cva(
  "inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 gap-1 transition overflow-hidden",
  {
    variants: {
      variant: {

        default:
          "border-transparent bg-primary text-white",

        secondary:
          "border-transparent bg-secondary text-white",

        destructive:
          "border-transparent bg-red-500 text-white",

        outline:
          "border text-gray-800 hover:bg-gray-100",

      },
    },

    defaultVariants: {
      variant: "default",
    },
  }
);

function Badge({
  className = "",
  variant = "default",
  asChild = false,
  ...props
}) {

  const Comp = asChild ? Slot : "span";

  return (

    <Comp
      className={`${badgeVariants({ variant })} ${className}`}
      {...props}
    />

  );

}

export { Badge };
