content: import 'package:eshop/domain/usecases/delivery_info/delete_local_delivery_info_usecase.dart';
  import 'package:eshop/domain/usecases/delivery_info/edit_delivery_info_usecase.dart';
  import 'package:eshop/domain/usecases/delivery_info/get_selected_delivery_info_usecase.dart';
  import 'package:eshop/domain/usecases/delivery_info/select_delivery_info_usecase.dart';
  import 'package:eshop/domain/usecases/order/delete_local_order_usecase.dart';
  import 'package:flutter_secure_storage/flutter_secure_storage.dart';
  import 'package:get_it/get_it.dart';
  import 'package:http/http.dart' as http;
  import 'package:internet_connection_checker/internet_connection_checker.dart';
  import 'package:shared_preferences/shared_preferences.dart';
  
  import '../../data/data_sources/local/cart_local_data_source.dart';
  import '../../data/data_sources/local/category_local_data_source.dart';
  import '../../data/data_sources/local/delivery_info_local_data_source.dart';
  import '../../data/data_sources/local/order_local_data_source.dart';
  import '../../data/data_sources/local/product_local_data_source.dart';
  import '../../data/data_sources/local/user_local_data_source.dart';
  import '../../data/data_sources/remote/cart_remote_data_source.dart';
  import '../../data/data_sources/remote/category_remote_data_source.dart';
  import '../../data/data_sources/remote/delivery_info_remote_data_source.dart';
  import '../../data/data_sources/remote/order_remote_data_source.dart';
  import '../../data/data_sources/remote/product_remote_data_source.dart';
  import '../../data/data_sources/remote/user_remote_data_source.dart';
  import '../../data/repositories/cart_repository_impl.dart';
  import '../../data/repositories/category_repository_impl.dart';
  import '../../data/repositories/delivery_info_impl.dart';
  import '../../data/repositories/order_repository_impl.dart';
  import '../../data/repositories/product_repository_impl.dart';
  import '../../data/repositories/user_repository_impl.dart';
  import '../../domain/repositories/cart_repository.dart';
  import '../../domain/repositories/category_repository.dart';
  import '../../domain/repositories/delivery_info_repository.dart';
  import '../../domain/repositories/order_repository.dart';
  import '../../domain/repositories/product_repository.dart';
  import '../../domain/repositories/user_repository.dart';
  import '../../domain/usecases/cart/add_cart_item_usecase.dart';
  import '../../domain/usecases/cart/delete_cart_usecase.dart';
  import '../../domain/usecases/cart/get_local_cart_items_usecase.dart';
  import '../../domain/usecases/cart/get_remote_cart_items_usecase.dart';
  import '../../domain/usecases/category/filter_category_usecase.dart';
  import '../../domain/usecases/category/get_local_category_usecase.dart';
  import '../../domain/usecases/category/get_remote_category_usecase.dart';
  import '../../domain/usecases/delivery_info/add_dilivey_info_usecase.dart';
  import '../../domain/usecases/delivery_info/get_local_delivery_info_usecase.dart';
  import '../../domain/usecases/delivery_info/get_remote_delivery_info_usecase.dart';
  import '../../domain/usecases/order/add_order_usecase.dart';
  import '../../domain/usecases/order/get_local_orders_usecase.dart';
  import '../../domain/usecases/order/get_remote_orders_usecase.dart';
  import '../../domain/usecases/product/get_product_usecase.dart';
  import '../../domain/usecases/user/get_local_user_usecase.dart';
  import '../../domain/usecases/user/sign_in_usecase.dart';
  import '../../domain/usecases/user/sign_out_usecase.dart';
  import '../../domain/usecases/user/sign_up_usecase.dart';
  import '../../presentation/blocs/cart/cart_bloc.dart';
  import '../../presentation/blocs/category/category_bloc.dart';
  import '../../presentation/blocs/delivery_info/delivery_info_action/delivery_info_action_cubit.dart';
  import '../../presentation/blocs/delivery_info/delivery_info_fetch/delivery_info_fetch_cubit.dart';
  import '../../presentation/blocs/order/order_add/order_add_cubit.dart';
  import '../../presentation/blocs/order/order_fetch/order_fetch_cubit.dart';
  import '../../presentation/blocs/product/product_bloc.dart';
  import '../../presentation/blocs/user/user_bloc.dart';
  import '../network/network_info.dart';
  
  final sl = GetIt.instance;
  
  Future<void> init() async {
    //Features - Product
    // Bloc
    sl.registerFactory(
      () => ProductBloc(sl()),
    );
    // Use cases
    sl.registerLazySingleton(() => GetProductUseCase(sl()));
    // Repository
    sl.registerLazySingleton<ProductRepository>(
      () => ProductRepositoryImpl(
        remoteDataSource: sl(),
        localDataSource: sl(),
        networkInfo: sl(),
      ),
    );
    // Data sources
    sl.registerLazySingleton<ProductRemoteDataSource>(
      () => ProductRemoteDataSourceImpl(client: sl()),
    );
    sl.registerLazySingleton<ProductLocalDataSource>(
      () => ProductLocalDataSourceImpl(sharedPreferences: sl()),
    );
  
    //Features - Category
    // Bloc
    sl.registerFactory(
      () => CategoryBloc(sl(), sl(), sl()),
    );
    // Use cases
    sl.registerLazySingleton(() => GetRemoteCategoryUseCase(sl()));
    sl.registerLazySingleton(() => GetLocalCategoryUseCase(sl()));
    sl.registerLazySingleton(() => FilterCategoryUseCase(sl()));
    // Repository
    sl.registerLazySingleton<CategoryRepository>(
      () => CategoryRepositoryImpl(
        remoteDataSource: sl(),
        localDataSource: sl(),
        networkInfo: sl(),
      ),
    );
    // Data sources
    sl.registerLazySingleton<CategoryRemoteDataSource>(
      () => CategoryRemoteDataSourceImpl(client: sl()),
    );
    sl.registerLazySingleton<CategoryLocalDataSource>(
      () => CategoryLocalDataSourceImpl(sharedPreferences: sl()),
    );
  
    //Features - Cart
    // Bloc
    sl.registerFactory(
      () => CartBloc(sl(), sl(), sl(), sl()),
    );
    // Use cases
    sl.registerLazySingleton(() => GetLocalCartItemsUseCase(sl()));
    sl.registerLazySingleton(() => AddCartUseCase(sl()));
    sl.registerLazySingleton(() => GetRemoteCardItemsUseCase(sl()));
    sl.registerLazySingleton(() => DeleteCartUseCase(sl()));
    // Repository
    sl.registerLazySingleton<CartRepository>(
      () => CartRepositoryImpl(
        remoteDataSource: sl(),
        localDataSource: sl(),
        networkInfo: sl(),
        userLocalDataSource: sl(),
      ),
    );
    // Data sources
    sl.registerLazySingleton<CartRemoteDataSource>(
      () => CartRemoteDataSourceSourceImpl(client: sl()),
    );
    sl.registerLazySingleton<CartLocalDataSource>(
      () => CartLocalDataSourceImpl(sharedPreferences: sl()),
    );
  
    //Features - Delivery Info
    // Bloc
    sl.registerFactory(
      () => DeliveryInfoActionCubit(sl(), sl(), sl()),
    );
    sl.registerFactory(
      () => DeliveryInfoFetchCubit(sl(), sl(), sl(), sl()),
    );
    // Use cases
    sl.registerLazySingleton(() => GetRemoteDeliveryInfoUseCase(sl()));
    sl.registerLazySingleton(() => GetLocalDeliveryInfoUseCase(sl()));
    sl.registerLazySingleton(() => AddDeliveryInfoUseCase(sl()));
    sl.registerLazySingleton(() => EditDeliveryInfoUseCase(sl()));
    sl.registerLazySingleton(() => SelectDeliveryInfoUseCase(sl()));
    sl.registerLazySingleton(() => GetSelectedDeliveryInfoInfoUseCase(sl()));
    sl.registerLazySingleton(() => DeleteLocalDeliveryInfoUseCase(sl()));
    // Repository
    sl.registerLazySingleton<DeliveryInfoRepository>(
      () => DeliveryInfoRepositoryImpl(
        remoteDataSource: sl(),
        localDataSource: sl(),
        networkInfo: sl(),
        userLocalDataSource: sl(),
      ),
    );
    // Data sources
    sl.registerLazySingleton<DeliveryInfoRemoteDataSource>(
      () => DeliveryInfoRemoteDataSourceImpl(client: sl()),
    );
    sl.registerLazySingleton<DeliveryInfoLocalDataSource>(
      () => DeliveryInfoLocalDataSourceImpl(sharedPreferences: sl()),
    );
  
    //Features - Order
    // Bloc
    sl.registerFactory(
      () => OrderAddCubit(sl()),
    );
    sl.registerFactory(
      () => OrderFetchCubit(sl(), sl(), sl()),
    );
    // Use cases
    sl.registerLazySingleton(() => AddOrderUseCase(sl()));
    sl.registerLazySingleton(() => GetRemoteOrdersUseCase(sl()));
    sl.registerLazySingleton(() => GetLocalOrdersUseCase(sl()));
    sl.registerLazySingleton(() => DeleteLocalOrdersUseCase(sl()));
    // Repository
    sl.registerLazySingleton<OrderRepository>(
      () => OrderRepositoryImpl(
        remoteDataSource: sl(),
        localDataSource: sl(),
        networkInfo: sl(),
        userLocalDataSource: sl(),
      ),
    );
    // Data sources
    sl.registerLazySingleton<OrderRemoteDataSource>(
      () => OrderRemoteDataSourceSourceImpl(client: sl()),
    );
    sl.registerLazySingleton<OrderLocalDataSource>(
      () => OrderLocalDataSourceImpl(sharedPreferences: sl()),
    );
  
    //Features - User
    // Bloc
    sl.registerFactory(
      () => UserBloc(sl(), sl(), sl(), sl()),
    );
    // Use cases
    sl.registerLazySingleton(() => GetLocalUserUseCase(sl()));
    sl.registerLazySingleton(() => SignInUseCase(sl()));
    sl.registerLazySingleton(() => SignUpUseCase(sl()));
    sl.registerLazySingleton(() => SignOutUseCase(sl()));
    // Repository
    sl.registerLazySingleton<UserRepository>(
      () => UserRepositoryImpl(
        remoteDataSource: sl(),
        localDataSource: sl(),
        networkInfo: sl(),
      ),
    );
    // Data sources
    sl.registerLazySingleton<UserLocalDataSource>(
      () => UserLocalDataSourceImpl(sharedPreferences: sl(), secureStorage: sl()),
    );
    sl.registerLazySingleton<UserRemoteDataSource>(
      () => UserRemoteDataSourceImpl(client: sl()),
    );
  
    ///***********************************************
    ///! Core
    /// sl.registerLazySingleton(() => InputConverter());
    sl.registerLazySingleton<NetworkInfo>(() => NetworkInfoImpl(sl()));
  
    ///! External
    final sharedPreferences = await SharedPreferences.getInstance();
    const secureStorage = FlutterSecureStorage();
    sl.registerLazySingleton(() => sharedPreferences);
    sl.registerLazySingleton(() => secureStorage);
    sl.registerLazySingleton(() => http.Client());
    sl.registerLazySingleton(() => InternetConnectionChecker());
  }