"use client"
import * as React from "react"
import * as SliderPrimitive from "@radix-ui/react-slider"
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "../../lib/utils"


const sliderVariants = cva(
  "",
  {
    variants:{
      variant:{
        orange:"bg-primary",
        slate:"bg-accent"
      },
      track:{
        orange:"bg-primary/30",
        slate:"bg-accent/30"
      },
      thumb:{
        orange:"border-primary/50",
        slate:"border-accent/50"
      }
    }
  }
)

const Slider = React.forwardRef<
  React.ElementRef<typeof SliderPrimitive.Root>,
  React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root> & 
  VariantProps<typeof sliderVariants> 
>(({ className, variant , thumb , track , ...props }, ref) => (
  <SliderPrimitive.Root
    ref={ref}
    className={cn(
      "relative h- flex w-44 touch-none select-none items-center",
      className
    )}
    {...props}
  >
    <SliderPrimitive.Track className={cn(sliderVariants({track}), "relative h-1.5 w-full overflow-hidden rounded-full" )}>
      <SliderPrimitive.Range className={cn(sliderVariants({variant}),"absolute h-full")} />
    </SliderPrimitive.Track>
    <SliderPrimitive.Thumb className={cn(sliderVariants({thumb}),"block h-4 w-4 rounded-full border bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50")} />
  </SliderPrimitive.Root>
))
Slider.displayName = SliderPrimitive.Root.displayName

export { Slider }
