import Foundation

/// Navigation options when opening a hook (i.e. open comments, reply to comment).
/// Used for deep linking from in-app notifications, deeplinks, and contextual navigation.
///
/// Ex:
/// - `.openComments(nil)` - Open feed and show the comments sheets
/// - `.openComments(.replyToComment("123"))` - Open feed, show comments sheet, focus reply to comment with ID "123"
/// - `nil` - Just open feed normally
///
public enum HookNavigationOptions: Equatable {
    case openComments(CommentNavigationOptions?)
    // Add more cases as needed
    // ex: case openShare, openMoreMenu, etc.

    public enum CommentNavigationOptions: Equatable {
        case replyToComment(_ commentId: String)
        // Add more cases as needed.
    }
}

public extension HookNavigationOptions {
    var shouldOpenComments: Bool {
        switch self {
        case .openComments:
            return true
        default:
            return false
        }
    }

    var replyToCommentID: String? {
        switch self {
        case .openComments(.replyToComment(let commentId)):
            return commentId
        default:
            return nil
        }
    }

    /// Analytics mapping for navigation intent
    var analyticsIntent: String {
        switch self {
        case .openComments(.replyToComment):
            return "reply_to_comment"
        case .openComments(.none):
            return "open_comments"
        }
    }

    /// Target comment ID for analytics
    var analyticsTargetCommentId: String? {
        return replyToCommentID
    }

    /// Check if this navigation has a specific intent beyond normal hook viewing
    var hasSpecificIntent: Bool {
        switch self {
        case .openComments:
            return true
        }
    }

    /// Get a human-readable description for debugging/logging
    var debugDescription: String {
        switch self {
        case .openComments(.none):
            return "Open Comments"
        case .openComments(.replyToComment(let commentId)):
            return "Reply to Comment: \(commentId)"
        }
    }

    /// Create navigation options for opening comments
    static func openCommentsOnly() -> HookNavigationOptions {
        return .openComments(nil)
    }

    /// Create navigation options for replying to a specific comment
    static func replyToComment(_ commentId: String) -> HookNavigationOptions {
        return .openComments(.replyToComment(commentId))
    }
}
