import { createRoot } from 'react-dom/client'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { AuthProvider } from './hooks/AuthProvider'
import { RouterProvider } from 'react-router-dom'
import { router } from './routes'
import { Toaster } from '@/client/components/ui/sonner'

// 创建QueryClient实例
const queryClient = new QueryClient();

// 应用入口组件
const App = () => {
  return (
    <QueryClientProvider client={queryClient}>
      <AuthProvider>
        <RouterProvider router={router} />
        <Toaster 
          position="top-right"
          expand={false}
          richColors
          closeButton
          duration={3000}
        />
      </AuthProvider>
    </QueryClientProvider>
  )
};

const rootElement = document.getElementById('root')
if (rootElement) {
  const root = createRoot(rootElement)
  root.render(
    <App />
  )
}