import Foundation

public enum HooksFeedSource: Equatable, Sendable {
    case hooksFeed
    case profile(id: String)
    case myHooks
    case notification
    case deeplink(sourceUrl: String, hookId: String)
    case clip(clipId: String)
    case profileGrid(handle: String) // When viewing hooks in a profile's grid (after tapping "More")
    case libraryGrid // When viewing hooks in a library grid view (My Hooks grid)
    case unknown // For cases where we can't determine the source

    public var canFetchMore: Bool {
        switch self {
        case .deeplink, .notification, .unknown:
            return false
        default:
            return true
        }
    }

    public var analyticsContext: (contextType: String?, contextId: String?, sourceUrl: String?) {
        switch self {
        case .hooksFeed:
            return (contextType: "hooks_feed", contextId: nil, sourceUrl: nil)
        case .profile(let id):
            return (contextType: "profile", contextId: id, sourceUrl: nil)
        case .myHooks:
            return (contextType: "library", contextId: nil, sourceUrl: nil)
        case .clip(let clipId):
            return (contextType: "clip", contextId: clipId, sourceUrl: nil)
        case .notification:
            return (contextType: "notification", contextId: nil, sourceUrl: nil)
        case .deeplink(let sourceUrl, let hookId):
            return (contextType: "hook", contextId: hookId, sourceUrl: sourceUrl)
        case .profileGrid(let handle):
            return (contextType: "profileGrid", contextId: handle, sourceUrl: nil)
        case .libraryGrid:
            return (contextType: "libraryGrid", contextId: nil, sourceUrl: nil)
        case .unknown:
            return (contextType: nil, contextId: nil, sourceUrl: nil)
        }
    }

    public var shouldPlayInHooksTab: Bool {
        switch self {
        case .hooksFeed, .deeplink:
            return true
        default:
            return false
        }
    }
}
