import Foundation

// MARK: - Common Error Messages
// Note: The comprehensive ErrorMessageParser is in Helpers/ErrorMessageParser.swift
// This file provides additional helper messages for common error scenarios

struct ErrorMessages {
    static let networkError = "Network connection error. Please check your internet connection."
    static let unknownError = "An unexpected error occurred. Please try again."
    static let timeoutError = "Request timed out. Please try again."
    static let serverError = "A server error occurred. Please try again later."
    static let notFoundError = "The requested resource was not found."
    static let unauthorizedError = "Your session has expired. Please log in again."
    static let forbiddenError = "You don't have permission to perform this action."

    static let invalidEmail = "Please enter a valid email address."
    static let invalidPassword = "Password must be at least 8 characters."
    static let passwordMismatch = "Passwords do not match."
    static let requiredField = "This field is required."

    static func required(_ fieldName: String) -> String {
        "\(fieldName) is required"
    }

    static func invalid(_ fieldName: String) -> String {
        "Please enter a valid \(fieldName.lowercased())"
    }

    static func tooShort(_ fieldName: String, minLength: Int) -> String {
        "\(fieldName) must be at least \(minLength) characters"
    }

    static func tooLong(_ fieldName: String, maxLength: Int) -> String {
        "\(fieldName) must be at most \(maxLength) characters"
    }
}

// MARK: - Error Checking Helpers

struct ErrorChecks {
    /// Checks if error is a network error
    static func isNetworkError(_ message: String) -> Bool {
        message.lowercased().contains("network") ||
        message.lowercased().contains("internet") ||
        message.lowercased().contains("connection")
    }

    /// Checks if error is an authentication error
    static func isAuthError(_ message: String) -> Bool {
        message.contains("401") ||
        message.contains("403") ||
        message.lowercased().contains("unauthorized") ||
        message.lowercased().contains("forbidden")
    }
}
