import 'package:flutter/foundation.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:krow/core/application/routing/routes.gr.dart';
import 'package:krow/core/presentation/gen/assets.gen.dart';
import 'package:krow/features/profile/profile_main/domain/bloc/user_profile_state.dart';
import 'package:krow/features/profile/role_kit/domain/staff_role_kit_repository_impl.dart';

class MenuTree {
  final MenuRoutItem root;
  final MenuRoutItem profileSettings;
  final MenuRoutItem personalInfo;
  final MenuRoutItem bankAccount;
  final MenuRoutItem workSettings;
  final MenuRoutItem workingArea;
  final MenuRoutItem schedule;
  final MenuRoutItem verificationCenter;
  final MenuRoutItem certification;
  final MenuRoutItem livePhoto;
  final MenuRoutItem wagesForm;
  final MenuRoutItem equipment;
  final MenuRoutItem uniform;
  final MenuRoutItem employeeResources;
  final MenuRoutItem training;
  final MenuRoutItem benefits;
  final MenuRoutItem helpSupport;
  final MenuRoutItem faq;
  final MenuRoutItem termsConditions;
  final MenuRoutItem contactSupport;

  MenuTree()
      : root = MenuRoutItem(),
        profileSettings = MenuRoutItem(
          title: 'account_settings',
          icon: Assets.images.userProfile.menu.profileCircle.svg(),
        ),
        personalInfo = MenuRoutItem(
          title: 'profile_settings',
          icon: Assets.images.userProfile.menu.userEdit.svg(),
          route: const ProfileSettingsFlowRoute(),
        ),
        bankAccount = MenuRoutItem(
          title: 'bank_account',
          icon: Assets.images.userProfile.menu.emptyWallet.svg(),
          route: const BankAccountFlowRoute(),
        ),
        workSettings = MenuRoutItem(
          title: 'work_settings',
          showBadge: true,
          icon: Assets.images.userProfile.menu.briefcase.svg(),
        ),
        workingArea = MenuRoutItem(
          title: 'working_area',
          icon: Assets.images.userProfile.menu.map.svg(),
          route: WorkingAreaRoute(),
        ),
        schedule = MenuRoutItem(
          title: 'schedule',
          icon: Assets.images.userProfile.menu.calendar.svg(),
          route: ScheduleRoute(),
        ),
        verificationCenter = MenuRoutItem(
          title: 'verification_center',
          showBadge: true,
          icon: Assets.images.userProfile.menu.shieldTick.svg(),
        ),
        certification = MenuRoutItem(
          title: 'certification',
          icon: Assets.images.userProfile.menu.medalStar.svg(),
          route: const CertificatesRoute(),
        ),
        livePhoto = MenuRoutItem(
          title: 'live_photo',
          icon: Assets.images.userProfile.menu.gallery.svg(),
          route: const LivePhotoRoute(),
        ),
        wagesForm = MenuRoutItem(
          title: 'wages_form',
          icon: Assets.images.userProfile.menu.note.svg(),
          route: const WagesFormsFlowRoute(),
        ),
        equipment = MenuRoutItem(
          title: 'equipment',
          icon: Assets.images.userProfile.menu.pot.svg(),
          route: RoleKitFlowRoute(roleKitType: RoleKitType.equipment),
        ),
        uniform = MenuRoutItem(
          title: 'uniform',
          icon: Assets.images.userProfile.menu.chef.svg(),
          route: RoleKitFlowRoute(roleKitType: RoleKitType.uniform),
        ),
        employeeResources = MenuRoutItem(
          title: 'employee_resources',
          icon: Assets.images.userProfile.menu.star.svg(),
        ),
        training = MenuRoutItem(
          title: 'training',
          icon: Assets.images.userProfile.menu.teacher.svg(),
        ),
        benefits = MenuRoutItem(
          title: 'benefits',
          icon: Assets.images.userProfile.menu.star.svg(),
          route: const BenefitsRoute(),
        ),
        helpSupport = MenuRoutItem(
          title: 'help_support',
          icon: Assets.images.userProfile.menu.message.svg(),
        ),
        faq = MenuRoutItem(
          title: 'faq',
          icon: Assets.images.userProfile.menu.helpCircle.svg(),
          route: const FaqRoute(),
        ),
        termsConditions = MenuRoutItem(
          title: 'terms_conditions',
          icon: Assets.images.userProfile.menu.securitySafe.svg(),
        ),
        contactSupport = MenuRoutItem(
          title: 'contact_support',
          icon: Assets.images.userProfile.menu.headphone.svg(),
          route: const SupportRoute(),
        );

  MenuRoutItem buildMenuTree() {
    profileSettings.children.addAll(
      [
        personalInfo..parent = profileSettings,
        bankAccount..parent = profileSettings
      ],
    );
    workSettings.children.addAll(
      [workingArea..parent = workSettings, schedule..parent = workSettings],
    );
    verificationCenter.children.addAll(
      [
        certification..parent = verificationCenter,
        livePhoto..parent = verificationCenter,
        equipment..parent = verificationCenter,
        uniform..parent = verificationCenter
      ],
    );
    employeeResources.children.addAll(
      [
        if (kDebugMode) benefits..parent = employeeResources
      ],
    );
    helpSupport.children.addAll(
      [
        faq..parent = helpSupport,
        contactSupport..parent = helpSupport
      ],
    );

    root.children.addAll(
      [
        profileSettings..parent = root,
        workSettings..parent = root,
        verificationCenter..parent = root,
        employeeResources..parent = root,
        helpSupport..parent = root,
      ],
    );

    return root;
  }
}