import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:intl/intl.dart' as intl;

import 'app_localizations_de.dart';
import 'app_localizations_en.dart';
import 'app_localizations_hu.dart';

// ignore_for_file: type=lint

/// Callers can lookup localized strings with an instance of AppLocalizations
/// returned by `AppLocalizations.of(context)`.
///
/// Applications need to include `AppLocalizations.delegate()` in their app's
/// `localizationDelegates` list, and the locales they support in the app's
/// `supportedLocales` list. For example:
///
/// ```dart
/// import 'l10n/app_localizations.dart';
///
/// return MaterialApp(
///   localizationsDelegates: AppLocalizations.localizationsDelegates,
///   supportedLocales: AppLocalizations.supportedLocales,
///   home: MyApplicationHome(),
/// );
/// ```
///
/// ## Update pubspec.yaml
///
/// Please make sure to update your pubspec.yaml to include the following
/// packages:
///
/// ```yaml
/// dependencies:
///   # Internationalization support.
///   flutter_localizations:
///     sdk: flutter
///   intl: any # Use the pinned version from flutter_localizations
///
///   # Rest of dependencies
/// ```
///
/// ## iOS Applications
///
/// iOS applications define key application metadata, including supported
/// locales, in an Info.plist file that is built into the application bundle.
/// To configure the locales supported by your app, you’ll need to edit this
/// file.
///
/// First, open your project’s ios/Runner.xcworkspace Xcode workspace file.
/// Then, in the Project Navigator, open the Info.plist file under the Runner
/// project’s Runner folder.
///
/// Next, select the Information Property List item, select Add Item from the
/// Editor menu, then select Localizations from the pop-up menu.
///
/// Select and expand the newly-created Localizations item then, for each
/// locale your application supports, add a new item and select the locale
/// you wish to add from the pop-up menu in the Value field. This list should
/// be consistent with the languages listed in the AppLocalizations.supportedLocales
/// property.
abstract class AppLocalizations {
  AppLocalizations(String locale)
    : localeName = intl.Intl.canonicalizedLocale(locale.toString());

  final String localeName;

  static AppLocalizations? of(BuildContext context) {
    return Localizations.of<AppLocalizations>(context, AppLocalizations);
  }

  static const LocalizationsDelegate<AppLocalizations> delegate =
      _AppLocalizationsDelegate();

  /// A list of this localizations delegate along with the default localizations
  /// delegates.
  ///
  /// Returns a list of localizations delegates containing this delegate along with
  /// GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
  /// and GlobalWidgetsLocalizations.delegate.
  ///
  /// Additional delegates can be added by appending to this list in
  /// MaterialApp. This list does not have to be used at all if a custom list
  /// of delegates is preferred or required.
  static const List<LocalizationsDelegate<dynamic>> localizationsDelegates =
      <LocalizationsDelegate<dynamic>>[
        delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
      ];

  /// A list of this localizations delegate's supported locales.
  static const List<Locale> supportedLocales = <Locale>[
    Locale('de'),
    Locale('en'),
    Locale('hu'),
  ];

  /// The title of the application
  ///
  /// In en, this message translates to:
  /// **'ZenTap'**
  String get appTitle;

  /// App subtitle description
  ///
  /// In en, this message translates to:
  /// **'A stress relief tapping game'**
  String get appSubtitle;

  /// Description for play button
  ///
  /// In en, this message translates to:
  /// **'Tap to earn Relaxation Points'**
  String get playDescription;

  /// Description for zen mode button
  ///
  /// In en, this message translates to:
  /// **'Pure relaxation, no score'**
  String get zenModeDescription;

  /// Description for statistics button
  ///
  /// In en, this message translates to:
  /// **'View your progress and achievements'**
  String get statisticsDescription;

  /// Description for exit button
  ///
  /// In en, this message translates to:
  /// **'Close the application'**
  String get exitDescription;

  /// Exit button text
  ///
  /// In en, this message translates to:
  /// **'Exit'**
  String get exit;

  /// Today's relaxation points display
  ///
  /// In en, this message translates to:
  /// **'Today\'s Relaxation Points: {points}'**
  String todayRelaxationPoints(int points);

  /// Hint text on main menu
  ///
  /// In en, this message translates to:
  /// **'Tap anywhere to feel the calm'**
  String get tapToFeelCalm;

  /// Button text to start playing
  ///
  /// In en, this message translates to:
  /// **'Play'**
  String get play;

  /// Button text for zen mode
  ///
  /// In en, this message translates to:
  /// **'Zen Mode'**
  String get zenMode;

  /// Settings menu title
  ///
  /// In en, this message translates to:
  /// **'Settings'**
  String get settings;

  /// Statistics menu title
  ///
  /// In en, this message translates to:
  /// **'Stats'**
  String get stats;

  /// Pause button text
  ///
  /// In en, this message translates to:
  /// **'Pause'**
  String get pause;

  /// Resume button text
  ///
  /// In en, this message translates to:
  /// **'Resume'**
  String get resume;

  /// Menu button text
  ///
  /// In en, this message translates to:
  /// **'Menu'**
  String get menu;

  /// Score label
  ///
  /// In en, this message translates to:
  /// **'Score'**
  String get score;

  /// Relaxation points label
  ///
  /// In en, this message translates to:
  /// **'Relaxation Points'**
  String get relaxationPoints;

  /// Total score label
  ///
  /// In en, this message translates to:
  /// **'Total Score'**
  String get totalScore;

  /// Games played counter
  ///
  /// In en, this message translates to:
  /// **'Games Played'**
  String get gamesPlayed;

  /// Best score label
  ///
  /// In en, this message translates to:
  /// **'Best Score'**
  String get bestScore;

  /// Average score label
  ///
  /// In en, this message translates to:
  /// **'Average Score'**
  String get averageScore;

  /// Total playtime label
  ///
  /// In en, this message translates to:
  /// **'Playtime'**
  String get playtime;

  /// Total bubbles popped counter
  ///
  /// In en, this message translates to:
  /// **'Bubbles Popped'**
  String get bubblesPopped;

  /// Sound setting toggle
  ///
  /// In en, this message translates to:
  /// **'Sound'**
  String get soundEnabled;

  /// Haptics/vibration setting toggle
  ///
  /// In en, this message translates to:
  /// **'Vibration'**
  String get hapticsEnabled;

  /// Tilt controls setting toggle
  ///
  /// In en, this message translates to:
  /// **'Tilt Controls'**
  String get tiltEnabled;

  /// Google Play Games section
  ///
  /// In en, this message translates to:
  /// **'Google Play Games'**
  String get googlePlayGames;

  /// Language setting label
  ///
  /// In en, this message translates to:
  /// **'Language'**
  String get language;

  /// Donate button text
  ///
  /// In en, this message translates to:
  /// **'Donate'**
  String get donate;

  /// Tutorial welcome message
  ///
  /// In en, this message translates to:
  /// **'Welcome to ZenTap!'**
  String get tutorialWelcome;

  /// Tutorial instructions
  ///
  /// In en, this message translates to:
  /// **'Tap bubbles to pop them and earn relaxation points. Tilt your device to move bubbles around!'**
  String get tutorialInstructions;

  /// Tutorial close button
  ///
  /// In en, this message translates to:
  /// **'Got it!'**
  String get tutorialClose;

  /// Game over message
  ///
  /// In en, this message translates to:
  /// **'Game Over'**
  String get gameOver;

  /// Final score display
  ///
  /// In en, this message translates to:
  /// **'Final Score: {score}'**
  String finalScore(int score);

  /// Play again button
  ///
  /// In en, this message translates to:
  /// **'Play Again'**
  String get playAgain;

  /// Back button text
  ///
  /// In en, this message translates to:
  /// **'Back'**
  String get back;

  /// English language name
  ///
  /// In en, this message translates to:
  /// **'English'**
  String get englishLanguage;

  /// German language name
  ///
  /// In en, this message translates to:
  /// **'Deutsch'**
  String get germanLanguage;

  /// Hungarian language name
  ///
  /// In en, this message translates to:
  /// **'Magyar'**
  String get hungarianLanguage;

  /// Statistics screen title
  ///
  /// In en, this message translates to:
  /// **'Statistics'**
  String get statistics;

  /// Overview tab title
  ///
  /// In en, this message translates to:
  /// **'Overview'**
  String get overview;

  /// Charts tab title
  ///
  /// In en, this message translates to:
  /// **'Charts'**
  String get charts;

  /// Stats section header
  ///
  /// In en, this message translates to:
  /// **'Your Relaxation Journey'**
  String get yourRelaxationJourney;

  /// Today's points stat card
  ///
  /// In en, this message translates to:
  /// **'Today\'s Points'**
  String get todaysPoints;

  /// Total points stat card
  ///
  /// In en, this message translates to:
  /// **'Total Points'**
  String get totalPoints;

  /// Daily average stat card
  ///
  /// In en, this message translates to:
  /// **'Daily Average'**
  String get dailyAverage;

  /// Current streak stat card
  ///
  /// In en, this message translates to:
  /// **'Current Streak'**
  String get currentStreak;

  /// Best day stat card
  ///
  /// In en, this message translates to:
  /// **'Best Day'**
  String get bestDay;

  /// Streak in days
  ///
  /// In en, this message translates to:
  /// **'{days} days'**
  String streakDays(int days);

  /// Achievements section title
  ///
  /// In en, this message translates to:
  /// **'Achievements'**
  String get achievements;

  /// First Steps achievement
  ///
  /// In en, this message translates to:
  /// **'First Steps'**
  String get firstSteps;

  /// Zen Apprentice achievement
  ///
  /// In en, this message translates to:
  /// **'Zen Apprentice'**
  String get zenApprentice;

  /// Bubble Master achievement
  ///
  /// In en, this message translates to:
  /// **'Bubble Master'**
  String get bubbleMaster;

  /// Consistent achievement
  ///
  /// In en, this message translates to:
  /// **'Consistent'**
  String get consistent;

  /// Dedicated achievement
  ///
  /// In en, this message translates to:
  /// **'Dedicated'**
  String get dedicated;

  /// Zen Master achievement
  ///
  /// In en, this message translates to:
  /// **'Zen Master'**
  String get zenMaster;

  /// Last 7 days section title
  ///
  /// In en, this message translates to:
  /// **'Last 7 Days'**
  String get last7Days;

  /// Daily progress chart title
  ///
  /// In en, this message translates to:
  /// **'Daily Progress (Last 14 Days)'**
  String get dailyProgress14Days;

  /// Weekly summary chart title
  ///
  /// In en, this message translates to:
  /// **'Weekly Summary (Last 8 Weeks)'**
  String get weeklySummary8Weeks;

  /// Monday abbreviation
  ///
  /// In en, this message translates to:
  /// **'Mon'**
  String get monday;

  /// Tuesday abbreviation
  ///
  /// In en, this message translates to:
  /// **'Tue'**
  String get tuesday;

  /// Wednesday abbreviation
  ///
  /// In en, this message translates to:
  /// **'Wed'**
  String get wednesday;

  /// Thursday abbreviation
  ///
  /// In en, this message translates to:
  /// **'Thu'**
  String get thursday;

  /// Friday abbreviation
  ///
  /// In en, this message translates to:
  /// **'Fri'**
  String get friday;

  /// Saturday abbreviation
  ///
  /// In en, this message translates to:
  /// **'Sat'**
  String get saturday;

  /// Sunday abbreviation
  ///
  /// In en, this message translates to:
  /// **'Sun'**
  String get sunday;

  /// Zen mode indicator in game
  ///
  /// In en, this message translates to:
  /// **'Zen Mode'**
  String get zenModeGame;

  /// Play mode indicator in game
  ///
  /// In en, this message translates to:
  /// **'Play Mode'**
  String get playModeGame;

  /// Short zen mode indicator
  ///
  /// In en, this message translates to:
  /// **'ZEN'**
  String get zenModeShort;

  /// Short play mode indicator
  ///
  /// In en, this message translates to:
  /// **'PLAY'**
  String get playModeShort;

  /// In-game relaxation points display
  ///
  /// In en, this message translates to:
  /// **'Relaxation Points: {points}'**
  String relaxationPointsGame(int points);

  /// In-game time display
  ///
  /// In en, this message translates to:
  /// **'Time: {time}'**
  String timeGame(String time);

  /// Time label
  ///
  /// In en, this message translates to:
  /// **'Time'**
  String get time;

  /// Paused overlay title
  ///
  /// In en, this message translates to:
  /// **'Paused'**
  String get paused;

  /// Pause overlay subtitle
  ///
  /// In en, this message translates to:
  /// **'Take a moment to breathe'**
  String get takeAMomentToBreathe;

  /// Exit dialog title
  ///
  /// In en, this message translates to:
  /// **'Leave Game?'**
  String get leaveGame;

  /// Exit dialog confirmation message
  ///
  /// In en, this message translates to:
  /// **'Are you sure you want to return to the main menu?'**
  String get leaveGameConfirm;

  /// Cancel button text
  ///
  /// In en, this message translates to:
  /// **'Cancel'**
  String get cancel;

  /// Leave button text
  ///
  /// In en, this message translates to:
  /// **'Leave'**
  String get leave;

  /// Audio settings section
  ///
  /// In en, this message translates to:
  /// **'Audio'**
  String get audio;

  /// Background music setting
  ///
  /// In en, this message translates to:
  /// **'Background Music'**
  String get backgroundMusic;

  /// Background music description
  ///
  /// In en, this message translates to:
  /// **'Enable relaxing ambient sounds'**
  String get backgroundMusicDesc;

  /// Music volume setting
  ///
  /// In en, this message translates to:
  /// **'Music Volume'**
  String get musicVolume;

  /// Sound effects volume setting
  ///
  /// In en, this message translates to:
  /// **'Sound Effects Volume'**
  String get soundEffectsVolume;

  /// Feedback settings section
  ///
  /// In en, this message translates to:
  /// **'Feedback'**
  String get feedback;

  /// Haptic feedback setting
  ///
  /// In en, this message translates to:
  /// **'Haptic Feedback'**
  String get hapticFeedback;

  /// Haptic feedback description
  ///
  /// In en, this message translates to:
  /// **'Feel gentle vibrations on tap'**
  String get hapticFeedbackDesc;

  /// Help section
  ///
  /// In en, this message translates to:
  /// **'Help'**
  String get help;

  /// Show tutorial option
  ///
  /// In en, this message translates to:
  /// **'Show Tutorial'**
  String get showTutorial;

  /// Show tutorial description
  ///
  /// In en, this message translates to:
  /// **'Learn how to use ZenTap'**
  String get showTutorialDesc;

  /// Support section title
  ///
  /// In en, this message translates to:
  /// **'Support ZenTap'**
  String get supportZenTap;

  /// Support development option
  ///
  /// In en, this message translates to:
  /// **'Support Development'**
  String get supportDevelopment;

  /// Support development description
  ///
  /// In en, this message translates to:
  /// **'Help keep ZenTap free and ad-free'**
  String get supportDevelopmentDesc;

  /// App description
  ///
  /// In en, this message translates to:
  /// **'A stress relief tapping game'**
  String get stressReliefGame;

  /// Tutorial dialog title
  ///
  /// In en, this message translates to:
  /// **'How to Use ZenTap'**
  String get howToUseZenTap;

  /// Tutorial step 1
  ///
  /// In en, this message translates to:
  /// **'Tap anywhere on the screen to pop bubbles'**
  String get tapToPopBubbles;

  /// Tutorial step 2
  ///
  /// In en, this message translates to:
  /// **'Earn Relaxation Points in Play mode'**
  String get earnRelaxationPoints;

  /// Tutorial step 3
  ///
  /// In en, this message translates to:
  /// **'Choose Zen Mode for pure relaxation'**
  String get chooseZenMode;

  /// Tutorial step 4
  ///
  /// In en, this message translates to:
  /// **'Tap pause anytime to take a break'**
  String get tapPauseAnytime;

  /// Tutorial dialog button
  ///
  /// In en, this message translates to:
  /// **'Got it!'**
  String get gotIt;

  /// Support dialog title
  ///
  /// In en, this message translates to:
  /// **'Support ZenTap'**
  String get supportZenTapTitle;

  /// Support dialog message
  ///
  /// In en, this message translates to:
  /// **'ZenTap is free and ad-free. If you enjoy using it, consider supporting development:'**
  String get supportMessage;

  /// Ko-fi donation option
  ///
  /// In en, this message translates to:
  /// **'Buy me a coffee'**
  String get buyMeACoffee;

  /// Ko-fi donation description
  ///
  /// In en, this message translates to:
  /// **'Ko-fi (one-time)'**
  String get kofiOneTime;

  /// PayPal donation option
  ///
  /// In en, this message translates to:
  /// **'PayPal Donation'**
  String get paypalDonation;

  /// PayPal donation description
  ///
  /// In en, this message translates to:
  /// **'Direct donation'**
  String get directDonation;

  /// GitHub Sponsors option
  ///
  /// In en, this message translates to:
  /// **'GitHub Sponsors'**
  String get githubSponsors;

  /// GitHub Sponsors description
  ///
  /// In en, this message translates to:
  /// **'Monthly support'**
  String get monthlySupport;

  /// Thank you message in support dialog
  ///
  /// In en, this message translates to:
  /// **'Thank you for supporting indie development! 💜'**
  String get thankYouMessage;

  /// Support dialog dismiss button
  ///
  /// In en, this message translates to:
  /// **'Maybe later'**
  String get maybeLater;

  /// Error message for donation link
  ///
  /// In en, this message translates to:
  /// **'Could not open donation link'**
  String get couldNotOpenDonationLink;

  /// Error message for donation link exception
  ///
  /// In en, this message translates to:
  /// **'Error opening donation link'**
  String get errorOpeningDonationLink;

  /// Language dialog title
  ///
  /// In en, this message translates to:
  /// **'Select Language'**
  String get selectLanguage;

  /// Appearance settings section
  ///
  /// In en, this message translates to:
  /// **'Appearance'**
  String get appearance;

  /// Color theme setting
  ///
  /// In en, this message translates to:
  /// **'Color Theme'**
  String get colorTheme;

  /// Color theme description
  ///
  /// In en, this message translates to:
  /// **'Choose your preferred color scheme'**
  String get colorThemeDesc;

  /// Theme dialog title
  ///
  /// In en, this message translates to:
  /// **'Select Theme'**
  String get selectTheme;

  /// Default theme name
  ///
  /// In en, this message translates to:
  /// **'Default (fSociety)'**
  String get defaultTheme;

  /// Spring theme name
  ///
  /// In en, this message translates to:
  /// **'Spring Bloom'**
  String get springTheme;

  /// Summer theme name
  ///
  /// In en, this message translates to:
  /// **'Summer Bright'**
  String get summerTheme;

  /// Autumn theme name
  ///
  /// In en, this message translates to:
  /// **'Autumn Leaves'**
  String get autumnTheme;

  /// Winter theme name
  ///
  /// In en, this message translates to:
  /// **'Winter Frost'**
  String get winterTheme;
}

class _AppLocalizationsDelegate
    extends LocalizationsDelegate<AppLocalizations> {
  const _AppLocalizationsDelegate();

  @override
  Future<AppLocalizations> load(Locale locale) {
    return SynchronousFuture<AppLocalizations>(lookupAppLocalizations(locale));
  }

  @override
  bool isSupported(Locale locale) =>
      <String>['de', 'en', 'hu'].contains(locale.languageCode);

  @override
  bool shouldReload(_AppLocalizationsDelegate old) => false;
}

AppLocalizations lookupAppLocalizations(Locale locale) {
  // Lookup logic when only language code is specified.
  switch (locale.languageCode) {
    case 'de':
      return AppLocalizationsDe();
    case 'en':
      return AppLocalizationsEn();
    case 'hu':
      return AppLocalizationsHu();
  }

  throw FlutterError(
    'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
    'an issue with the localizations generation tool. Please file an issue '
    'on GitHub with a reproducible sample app and the gen-l10n configuration '
    'that was used.',
  );
}
