"""User-related domain exceptions."""

from src.core.domain.exceptions.base import DomainException, ValidationException


class UserNotFoundException(DomainException):
    """User not found exception."""
    
    def __init__(self, user_id: int = None, email: str = None):
        """Initialize exception.
        
        Args:
            user_id: User ID
            email: User email
        """
        if user_id:
            message = f"User with ID {user_id} not found"
        elif email:
            message = f"User with email {email} not found"
        else:
            message = "User not found"
        super().__init__(message, "USER_NOT_FOUND")


class EmailAlreadyExistsException(DomainException):
    """Email already exists exception."""
    
    def __init__(self, email: str):
        """Initialize exception.
        
        Args:
            email: Email address
        """
        super().__init__(
            f"Email {email} is already registered",
            "EMAIL_ALREADY_EXISTS"
        )


class InvalidEmailException(ValidationException):
    """Invalid email format exception."""
    
    def __init__(self, email: str):
        """Initialize exception.
        
        Args:
            email: Invalid email
        """
        super().__init__(
            f"Invalid email format: {email}",
            field="email"
        )


class WeakPasswordException(ValidationException):
    """Weak password exception."""
    
    def __init__(self, reason: str = "Password does not meet requirements"):
        """Initialize exception.
        
        Args:
            reason: Reason why password is weak
        """
        super().__init__(reason, field="password")


class InvalidCredentialsException(DomainException):
    """Invalid login credentials exception."""
    
    def __init__(self):
        """Initialize exception."""
        super().__init__(
            "Invalid email or password",
            "INVALID_CREDENTIALS"
        )


class AccountLockedException(DomainException):
    """Account is locked exception."""
    
    def __init__(self, reason: str = "Account is locked"):
        """Initialize exception.
        
        Args:
            reason: Reason for lock
        """
        super().__init__(reason, "ACCOUNT_LOCKED")


class InsufficientBalanceException(DomainException):
    """Insufficient wallet balance exception."""
    
    def __init__(self, required: str, available: str):
        """Initialize exception.
        
        Args:
            required: Required amount
            available: Available amount
        """
        super().__init__(
            f"Insufficient balance. Required: {required}, Available: {available}",
            "INSUFFICIENT_BALANCE"
        )

