import { RouterProvider } from 'react-router-dom';
import { router } from './router';


import { ThemeProvider, PrivacyProvider, NotificationProvider, GuideProvider, useAutoTokenRefresh } from './hooks';
import { SettingsProvider } from './contexts/SettingsContext';
import { Toaster } from 'react-hot-toast';

/**
 * App Content Component
 * Wrapped by providers, uses hooks
 */
function AppContent() {
  // Enable automatic token refresh
  useAutoTokenRefresh();

  return <RouterProvider router={router} />;
}

/**
 * Main Application Component
 * Local-first accounting application
 */
function App() {
  return (
    <ThemeProvider>
      <PrivacyProvider>
        <NotificationProvider>
          <GuideProvider>
            <SettingsProvider>
              <AppContent />
              <Toaster position="top-center" reverseOrder={false} />
            </SettingsProvider>
          </GuideProvider>
        </NotificationProvider>
      </PrivacyProvider>
    </ThemeProvider>
  );
}

export default App;
