"use client"
import { HeroUIProvider, cn } from "@heroui/react"
import { ToastProvider } from "@heroui/toast"
import { platform } from "@tauri-apps/plugin-os"
import { ThemeProvider as NextThemesProvider } from "next-themes"
import { useEffect, useState } from "react"

export default function Providers({ children }: { children: React.ReactNode }) {
  const [os, setOs] = useState("windows")
  useEffect(() => {
    setOs(platform())
  }, [])

  return (
    <HeroUIProvider
      className={cn(
        "h-full bg-zinc-100/90 dark:bg-zinc-900",
        os === "macos" && "rounded-lg",
      )}
    >
      <NextThemesProvider attribute="class" defaultTheme="light">
        <ToastProvider toastOffset={10} placement="top-center" />
        {children}
      </NextThemesProvider>
    </HeroUIProvider>
  )
}
