import { StrictMode, useState, useEffect } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.jsx'
import Landing from './Landing.jsx'
import Legal from './Legal.jsx'
import { AuthProvider, useAuth } from './contexts/AuthContext'
import PricingSection from './components/PricingSection'
import AccountPage from './components/AccountPage'
import LoginModal from './components/LoginModal'
function PageShell({ title, children }) {
return (
{title && {title}
}
{children}
);
}
function PricingView() {
const [showLogin, setShowLogin] = useState(false);
return (
setShowLogin(true)} />
{showLogin && setShowLogin(false)} />}
);
}
function AccountView() {
const { isSignedIn, loading } = useAuth();
useEffect(() => {
if (!loading && !isSignedIn) window.location.hash = '#/pricing';
}, [loading, isSignedIn]);
return ;
}
function Root() {
const resolveView = () => {
const hash = window.location.hash || '';
if (hash.startsWith('#/auth/')) return 'auth'; // AuthContext consumes then redirects
if (hash.startsWith('#/account')) return 'account';
if (hash.startsWith('#/pricing')) return 'pricing';
if (hash === '#legal') return 'legal';
if (hash === '#app' || localStorage.getItem('openshorts_skip_landing') === '1') return 'app';
return 'landing';
};
const [view, setView] = useState(resolveView);
useEffect(() => {
const handleHashChange = () => setView(resolveView());
window.addEventListener('hashchange', handleHashChange);
return () => window.removeEventListener('hashchange', handleHashChange);
}, []);
const handleLaunchApp = () => {
localStorage.setItem('openshorts_skip_landing', '1');
window.location.hash = '#app';
setView('app');
};
if (view === 'legal') return ;
if (view === 'pricing') return ;
if (view === 'account') return ;
if (view === 'auth') {
return Signing you in…
;
}
if (view === 'app') return ;
return ;
}
createRoot(document.getElementById('root')).render(
,
)