import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:krow_core/core.dart';

import 'data/repositories/profile_repository_impl.dart';
import 'domain/repositories/profile_repository.dart';
import 'domain/usecases/get_profile_usecase.dart';
import 'domain/usecases/sign_out_usecase.dart';
import 'presentation/blocs/profile_cubit.dart';
import 'presentation/pages/staff_profile_page.dart';

/// The entry module for the Staff Profile feature.
///
/// This module provides dependency injection bindings for the profile feature
/// following Clean Architecture principles.
///
/// Dependency flow:
/// - Repository implementation (ProfileRepositoryImpl) delegates to data_connect
/// - Use cases depend on repository interface
/// - Cubit depends on use cases
class StaffProfileModule extends Module {
  @override
  void binds(Injector i) {
    // Repository implementation - delegates to data_connect
    i.addLazySingleton<ProfileRepositoryInterface>(
      ProfileRepositoryImpl.new,
    );

    // Use cases - depend on repository interface
    i.addLazySingleton<GetProfileUseCase>(
      () => GetProfileUseCase(i.get<ProfileRepositoryInterface>()),
    );
    i.addLazySingleton<SignOutUseCase>(
      () => SignOutUseCase(i.get<ProfileRepositoryInterface>()),
    );

    // Presentation layer - Cubit depends on use cases
    i.add<ProfileCubit>(
      () => ProfileCubit(i.get<GetProfileUseCase>(), i.get<SignOutUseCase>()),
    );
  }

  @override
  void routes(RouteManager r) {
    r.child(
      StaffPaths.childRoute(StaffPaths.profile, StaffPaths.profile),
      child: (BuildContext context) => const StaffProfilePage(),
    );
  }
}
