package middleware

import (
	"go.uber.org/zap"

	"codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/config"
	uc_user "codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/internal/usecase/user"
	"codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/pkg/ratelimit"
	"codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/pkg/security/jwt"
)

// Wire provider for middleware

func ProvideMiddleware(
	logger *zap.Logger,
	jwtProvider jwt.JWTProvider,
	userGetByIDUseCase uc_user.UserGetByIDUseCase,
) Middleware {
	return NewMiddleware(logger, jwtProvider, userGetByIDUseCase)
}

// ProvideRateLimitMiddleware provides the rate limit middleware for Wire DI
func ProvideRateLimitMiddleware(
	logger *zap.Logger,
	loginRateLimiter ratelimit.LoginRateLimiter,
) *RateLimitMiddleware {
	return NewRateLimitMiddleware(logger, loginRateLimiter)
}

// ProvideSecurityHeadersMiddleware provides the security headers middleware for Wire DI
func ProvideSecurityHeadersMiddleware(
	config *config.Config,
) *SecurityHeadersMiddleware {
	return NewSecurityHeadersMiddleware(config)
}
