import * as React from "react"
import * as TabsPrimitive from "@radix-ui/react-tabs"

import { cn } from "@/lib/utils"

const Tabs = TabsPrimitive.Root

const TabsList = React.forwardRef<
  React.ElementRef<typeof TabsPrimitive.List>,
  React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
>(({ className, ...props }, ref) => (
  <TabsPrimitive.List
    ref={ref}
    className={cn(
      "smx-inline-flex smx-h-10 smx-items-center smx-justify-center smx-rounded-md smx-bg-muted smx-p-1 smx-text-muted-foreground",
      className
    )}
    {...props}
  />
))
TabsList.displayName = TabsPrimitive.List.displayName

const TabsTrigger = React.forwardRef<
  React.ElementRef<typeof TabsPrimitive.Trigger>,
  React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
>(({ className, ...props }, ref) => (
  <TabsPrimitive.Trigger
    ref={ref}
    className={cn(
      "smx-inline-flex smx-items-center smx-justify-center smx-whitespace-nowrap smx-rounded-sm smx-px-3 smx-py-1.5 smx-text-sm smx-font-medium smx-ring-offset-background smx-transition-all focus-visible:smx-outline-none focus-visible:smx-ring-2 focus-visible:smx-ring-ring focus-visible:smx-ring-offset-2 disabled:smx-pointer-events-none disabled:smx-opacity-50 data-[state=active]:smx-bg-background data-[state=active]:smx-text-foreground data-[state=active]:smx-shadow-sm",
      className
    )}
    {...props}
  />
))
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName

const TabsContent = React.forwardRef<
  React.ElementRef<typeof TabsPrimitive.Content>,
  React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
>(({ className, ...props }, ref) => (
  <TabsPrimitive.Content
    ref={ref}
    className={cn(
      "smx-mt-2 smx-ring-offset-background focus-visible:smx-outline-none focus-visible:smx-ring-2 focus-visible:smx-ring-ring focus-visible:smx-ring-offset-2",
      className
    )}
    {...props}
  />
))
TabsContent.displayName = TabsPrimitive.Content.displayName

export { Tabs, TabsList, TabsTrigger, TabsContent }
