package gateway

import (
	"go.uber.org/zap"

	"codeberg.org/mapleopentech/monorepo/cloud/maplepress-backend/internal/service"
	gatewayuc "codeberg.org/mapleopentech/monorepo/cloud/maplepress-backend/internal/usecase/gateway"
	tenantuc "codeberg.org/mapleopentech/monorepo/cloud/maplepress-backend/internal/usecase/tenant"
	userusecase "codeberg.org/mapleopentech/monorepo/cloud/maplepress-backend/internal/usecase/user"
	"codeberg.org/mapleopentech/monorepo/cloud/maplepress-backend/pkg/distributedmutex"
	"codeberg.org/mapleopentech/monorepo/cloud/maplepress-backend/pkg/security/jwt"
)

// ProvideRegisterService creates a new RegisterService for dependency injection
func ProvideRegisterService(
	validateInputUC *gatewayuc.ValidateRegistrationInputUseCase,
	checkTenantSlugUC *gatewayuc.CheckTenantSlugAvailabilityUseCase,
	checkPasswordBreachUC *gatewayuc.CheckPasswordBreachUseCase,
	hashPasswordUC *gatewayuc.HashPasswordUseCase,
	validateTenantSlugUC *tenantuc.ValidateTenantSlugUniqueUseCase,
	createTenantEntityUC *tenantuc.CreateTenantEntityUseCase,
	saveTenantToRepoUC *tenantuc.SaveTenantToRepoUseCase,
	validateUserEmailUC *userusecase.ValidateUserEmailUniqueUseCase,
	createUserEntityUC *userusecase.CreateUserEntityUseCase,
	saveUserToRepoUC *userusecase.SaveUserToRepoUseCase,
	deleteTenantUC *tenantuc.DeleteTenantUseCase,
	deleteUserUC *userusecase.DeleteUserUseCase,
	distributedMutex distributedmutex.Adapter,
	sessionService service.SessionService,
	jwtProvider jwt.Provider,
	logger *zap.Logger,
) RegisterService {
	return NewRegisterService(
		validateInputUC,
		checkTenantSlugUC,
		checkPasswordBreachUC,
		hashPasswordUC,
		validateTenantSlugUC,
		createTenantEntityUC,
		saveTenantToRepoUC,
		validateUserEmailUC,
		createUserEntityUC,
		saveUserToRepoUC,
		deleteTenantUC,
		deleteUserUC,
		distributedMutex,
		sessionService,
		jwtProvider,
		logger,
	)
}

// ProvideLoginService creates a new LoginService for dependency injection
func ProvideLoginService(
	loginUC *gatewayuc.LoginUseCase,
	sessionService service.SessionService,
	jwtProvider jwt.Provider,
	logger *zap.Logger,
) LoginService {
	return NewLoginService(loginUC, sessionService, jwtProvider, logger)
}

// ProvideRefreshTokenService creates a new RefreshTokenService for dependency injection
func ProvideRefreshTokenService(
	sessionService service.SessionService,
	jwtProvider jwt.Provider,
	logger *zap.Logger,
) RefreshTokenService {
	return NewRefreshTokenService(sessionService, jwtProvider, logger)
}
