"use client"

import { Toaster as Sonner, type ToasterProps } from "sonner"
import { useTranslation } from "@/contexts/LanguageContext"

function Toaster({ ...props }: ToasterProps) {
  const { isRtl } = useTranslation();

  return (
    <Sonner
      position={isRtl ? "top-left" : "top-right"}
      dir={isRtl ? "rtl" : "ltr"}
      className="toaster group"
      style={
        {
          "--normal-bg": "var(--popover)",
          "--normal-text": "var(--popover-foreground)",
          "--normal-border": "var(--border)",
        } as React.CSSProperties
      }
      toastOptions={{
        classNames: {
          toast:
            "group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",
          description: "group-[.toast]:text-muted-foreground",
          actionButton:
            "group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",
          cancelButton:
            "group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",
        },
      }}
      {...props}
    />
  )
}

export { Toaster }
