import { BrowserRouter, Routes, Route } from 'react-router-dom'
import { BusinessDomainGuard } from './components/BusinessDomainGuard'
import { DashboardDocumentTitle } from './components/DashboardDocumentTitle'
import { AuthProvider } from './context/AuthContext'
import { BusinessThemeProvider } from './context/BusinessThemeContext'
import { TenantBrandingProvider } from './context/TenantBrandingContext'
import { LocaleProvider } from '@meshkee/dashboard-ui'
import { ToastProvider } from './context/ToastContext'
import { ProtectedRoute } from './components/ProtectedRoute'
import { GuestRoute } from './components/GuestRoute'
import { PageLayout } from './components/PageLayout'
import { HomePage } from './pages/HomePage'
import { ProductsPage } from './pages/ProductsPage'
import { CategoriesPage } from './pages/CategoriesPage'
import { BrandsPage } from './pages/BrandsPage'
import { AddNewProductPage } from './pages/AddNewProductPage'
import { MyProductsPage } from './pages/MyProductsPage'
import { ProductDetailsPage } from './pages/ProductDetailsPage'
import { ProductSettingsPage } from './pages/ProductSettingsPage'
import { BusinessProfilePage } from './pages/BusinessProfilePage'
import { ProfilePage } from './pages/ProfilePage'
import { StorePage } from './pages/StorePage'
import { StoreItemsPage } from './pages/StoreItemsPage'
import { StoreSpecialsPage } from './pages/StoreSpecialsPage'
import { CustomersPage } from './pages/CustomersPage'
import { OrdersPage } from './pages/OrdersPage'
import { LoginPage } from './pages/LoginPage'
import { ShoppingCardsPage } from './pages/ShoppingCardsPage'
import { StoreSettingsPage } from './pages/StoreSettingsPage'
import { BlogPage } from './pages/BlogPage'
import { BlogListPage } from './pages/BlogListPage'
import { AddNewBlogPage } from './pages/AddNewBlogPage'
import { BlogCategoriesPage } from './pages/BlogCategoriesPage'
import { BlogSettingsPage } from './pages/BlogSettingsPage'
import { BlogDetailsPage } from './pages/BlogDetailsPage'
import { PortfoliosPage } from './pages/PortfoliosPage'
import { PortfolioListPage } from './pages/PortfolioListPage'
import { AddNewPortfolioPage } from './pages/AddNewPortfolioPage'
import { PortfolioCategoriesPage } from './pages/PortfolioCategoriesPage'
import { PortfolioSettingsPage } from './pages/PortfolioSettingsPage'
import { PortfolioDetailsPage } from './pages/PortfolioDetailsPage'
import { WebsitePage } from './pages/WebsitePage'
import { WebsiteContactPage } from './pages/WebsiteContactPage'
import { WebsiteSubscriptionsPage } from './pages/WebsiteSubscriptionsPage'
import { WebsiteFaqPage } from './pages/WebsiteFaqPage'
import { WebsiteBadgesPage } from './pages/WebsiteBadgesPage'
import { WebsiteEPaymentPage } from './pages/WebsiteEPaymentPage'
import { WebsiteSlidersPage } from './pages/WebsiteSlidersPage'
import { WebsiteSpecialCategoriesPage } from './pages/WebsiteSpecialCategoriesPage'
import { WebsiteSpecialBrandsPage } from './pages/WebsiteSpecialBrandsPage'

function App() {
  return (
    <BusinessDomainGuard>
    <LocaleProvider>
    <BrowserRouter>
      <TenantBrandingProvider>
        <DashboardDocumentTitle />
      <AuthProvider>
        <BusinessThemeProvider>
          <ToastProvider>
          <Routes>
          <Route element={<GuestRoute />}>
            <Route path="login" element={<LoginPage />} />
          </Route>

          <Route element={<ProtectedRoute />}>
            <Route element={<PageLayout />}>
              <Route index element={<HomePage />} />
              <Route path="profile" element={<ProfilePage />} />
              <Route path="business-profile" element={<BusinessProfilePage />} />
              <Route path="products" element={<ProductsPage />} />
              <Route path="products/categories" element={<CategoriesPage />} />
              <Route path="products/brands" element={<BrandsPage />} />
              <Route path="products/new" element={<AddNewProductPage />} />
              <Route path="products/edit/:id" element={<AddNewProductPage />} />
              <Route path="products/list" element={<MyProductsPage />} />
              <Route path="products/detail/:id" element={<ProductDetailsPage />} />
              <Route path="products/settings" element={<ProductSettingsPage />} />
              <Route path="store" element={<StorePage />} />
              <Route path="store/items" element={<StoreItemsPage />} />
              <Route path="store/orders" element={<OrdersPage />} />
              <Route path="store/cards" element={<ShoppingCardsPage />} />
              <Route path="store/settings" element={<StoreSettingsPage />} />
              <Route path="customers" element={<CustomersPage />} />
              <Route path="blog" element={<BlogPage />} />
              <Route path="blog/list" element={<BlogListPage />} />
              <Route path="blog/detail/:id" element={<BlogDetailsPage />} />
              <Route path="blog/new" element={<AddNewBlogPage />} />
              <Route path="blog/edit/:id" element={<AddNewBlogPage />} />
              <Route path="blog/categories" element={<BlogCategoriesPage />} />
              <Route path="blog/settings" element={<BlogSettingsPage />} />
              <Route path="portfolios" element={<PortfoliosPage />} />
              <Route path="portfolios/list" element={<PortfolioListPage />} />
              <Route path="portfolios/detail/:id" element={<PortfolioDetailsPage />} />
              <Route path="portfolios/new" element={<AddNewPortfolioPage />} />
              <Route path="portfolios/edit/:id" element={<AddNewPortfolioPage />} />
              <Route path="portfolios/categories" element={<PortfolioCategoriesPage />} />
              <Route path="portfolios/settings" element={<PortfolioSettingsPage />} />
              <Route path="website" element={<WebsitePage />} />
              <Route path="website/sliders" element={<WebsiteSlidersPage />} />
              <Route path="website/special-categories" element={<WebsiteSpecialCategoriesPage />} />
              <Route path="website/special-brands" element={<WebsiteSpecialBrandsPage />} />
              <Route path="website/special-items" element={<StoreSpecialsPage />} />
              <Route path="website/contact" element={<WebsiteContactPage />} />
              <Route path="website/subscriptions" element={<WebsiteSubscriptionsPage />} />
              <Route path="website/faq" element={<WebsiteFaqPage />} />
              <Route path="website/badges" element={<WebsiteBadgesPage />} />
              <Route path="website/e-payment" element={<WebsiteEPaymentPage />} />
            </Route>
          </Route>
        </Routes>
        </ToastProvider>
        </BusinessThemeProvider>
      </AuthProvider>
      </TenantBrandingProvider>
    </BrowserRouter>
    </LocaleProvider>
    </BusinessDomainGuard>
  )
}

export default App
