import * as React from "react";
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
import { Circle } from "lucide-react";

import { cn } from "../lib/utils";

const RadioGroup = React.forwardRef<
  React.ElementRef<typeof RadioGroupPrimitive.Root>,
  React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
>(({ className, ...props }, ref) => {
  return (
    <RadioGroupPrimitive.Root
      className={cn(
        "tw-figr-grid tw-figr-gap-2 tw-figr-font-secondary tw-figr-text-desktop-caption-accent ",
        className
      )}
      {...props}
      ref={ref}
    />
  );
});
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;

const RadioGroupItem = React.forwardRef<
  React.ElementRef<typeof RadioGroupPrimitive.Item>,
  React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
>(({ className, ...props }, ref) => {
  return (
    <RadioGroupPrimitive.Item
      ref={ref}
      className={cn(
        "tw-figr-ring-offset-background focus-visible:tw-figr-ring-2 focus-visible:tw-figr-ring-ring focus-visible:tw-figr-ring-offset-2 tw-figr-border-primary tw-figr-text-primary tw-figr-h-4 tw-figr-w-4 tw-figr-rounded-full focus:tw-figr-outline-none disabled:tw-figr-cursor-not-allowed disabled:tw-figr-opacity-50 tw-figr-aspect-square tw-figr-border",
        className
      )}
      {...props}
    >
      <RadioGroupPrimitive.Indicator className="tw-figr-flex tw-figr-items-center tw-figr-justify-center">
        <Circle className="tw-figr-text-current tw-figr-h-2.5 tw-figr-w-2.5 tw-figr-fill-current" />
      </RadioGroupPrimitive.Indicator>
    </RadioGroupPrimitive.Item>
  );
});
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;

export { RadioGroup, RadioGroupItem };
