import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native';
import { Stack } from 'expo-router';
import 'react-native-reanimated';

import { AuthProvider } from '@/components/auth/auth-provider';
import { useColorScheme } from '@/hooks/use-color-scheme';
import { Platform } from 'react-native';
import { useEffect } from 'react';

// Clarity 只支持 android 和 iOS，web 平台跳过初始化
if (Platform.OS === 'android' || Platform.OS === 'ios') {
  const Clarity = require('@microsoft/react-native-clarity').default;
  Clarity.initialize('tyq6bmjzo1', {
    logLevel: Clarity.LogLevel.Verbose,
  });
}
export const unstable_settings = {
  anchor: '(tabs)',
};

export default function RootLayout() {
  const colorScheme = useColorScheme();
  useEffect(()=>{
    console.log(`app start`)
  }, [])
  return (
    <ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
      <AuthProvider>
        <Stack>
          <Stack.Screen name="(tabs)" options={{ headerShown: false }} />
          <Stack.Screen name="modal" options={{ presentation: 'modal', title: 'Modal' }} />
          <Stack.Screen name="result" options={{ headerShown: false }} />
          <Stack.Screen name="exchange" options={{ headerShown: false }} />
          <Stack.Screen name="recharge" options={{ headerShown: false }} />
        </Stack>
      </AuthProvider>
    </ThemeProvider>
  );
}
