import './bootstrap';
import '../css/app.css';

import React, { lazy, useEffect } from 'react'
import { createRoot } from 'react-dom/client';
import { createInertiaApp } from '@inertiajs/react';
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
import store from '../js/Auth/store';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom';
import Header from '@/Components/Header';
import LeftSidebar from '@/Components/LeftSidebar';

const appName = import.meta.env.VITE_APP_NAME || 'Laravel';
const Layout = lazy(() => import('./Components/Layout'))
// const Login = lazy(() => import('./pages/Login'))
// const ForgotPassword = lazy(() => import('./pages/ForgotPassword'))
// const Register = lazy(() => import('./pages/Register'))
// const Documentation = lazy(() => import('./pages/Documentation'))

useEffect(() => {
    // 👆 daisy UI themes initialization
    themeChange(false)
}, [])

createInertiaApp({
    title: (title) => `${title} - ${appName}`,
    resolve: (name) => resolvePageComponent(`./Pages/${name}.jsx`, import.meta.glob('./Pages/**/*.jsx')),
    setup({ el, App, props }) {
        const root = createRoot(el);

        root.render(
            <Provider store={store}>
                <BrowserRouter>
                    <Header />
                    <LeftSidebar />
                    <App {...props} />
                </BrowserRouter>
            </Provider>
        );
    },
    progress: {
        color: '#4B5563',
    },
});

// export default App