import Layout from '@/components/layouts'
import Theme from '@/components/template/Theme'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { StoreProvider } from 'easy-peasy'
import { BrowserRouter } from 'react-router-dom'
import './locales'
import { store } from './store'
import { DynamicRoutesProvider } from './routes/dynamicRoutesContext'
import { ComponentProvider } from './contexts/ComponentContext'
import ComponentRegistryProvider from './contexts/ComponentRegistryContext'

const queryClient = new QueryClient()

function App() {
  return (
    <StoreProvider store={store}>
      <BrowserRouter>
        <DynamicRoutesProvider>
          <ComponentProvider>
            <ComponentRegistryProvider>
              <QueryClientProvider client={queryClient}>
                <Theme>
                  <Layout />
                </Theme>
              </QueryClientProvider>
            </ComponentRegistryProvider>
          </ComponentProvider>
        </DynamicRoutesProvider>
      </BrowserRouter>
    </StoreProvider>
  )
}

export default App
