// Generated by GitHub Copilot
import React, { useEffect, useState } from 'react';
import AsyncStorage from '@react-native-async-storage/async-storage';
import Navigator from './src/navigation/AppNavigator';

/**
 * App root — checks for a stored JWT to decide the initial navigation route.
 */
export default function App() {
  const [isAuthenticated, setIsAuthenticated] = useState(false);
  const [loading, setLoading] = useState(true);

  useEffect(() => {
    AsyncStorage.getItem('jwt_token').then(token => {
      setIsAuthenticated(!!token);
      setLoading(false);
    });
  }, []);

  if (loading) return null;

  return <Navigator isAuthenticated={isAuthenticated} />;
}
