import 'package:flutter/widgets.dart';

import 'bootstrap.dart';
import 'i18n/strings.g.dart';
import 'ui/restart_widget.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  // Start from the device language, then let an explicit in-app choice win —
  // it's the only reliable way to reach languages the OS picker doesn't offer
  // (e.g. Asturian). The saved choice is restored inside [Bootstrap], after DI.
  LocaleSettings.useDeviceLocaleSync();
  // Paint immediately: [Bootstrap] shows a splash and runs the heavy init off
  // the first frame. Wrapped in [RestartWidget] so switching the social identity
  // (which re-registers the social singletons) can rebuild the whole tree —
  // Bootstrap re-reads its dependencies from the locator on each rebuild.
  runApp(
    RestartWidget(
      builder: () => TranslationProvider(child: const Bootstrap()),
    ),
  );
}
