import APIClient
import Foundation

public struct CommentsTotalCountMap: Equatable {
    public static let defaultValue: CommentsTotalCountMap = .init(counts: [:])

    public enum CountStyle: Equatable {
        case known(Int)
        case unknown
    }

    public init(counts: [String: Int] = [:]) {
        self.counts = counts
    }

    // Entity ID (i.e. hookId, clipId, etc.) : Comment Count
    private let counts: [String: Int]

    public func commentCountForEntity(_ entityId: String, entityType: CommentEntity.CommentEntityType) -> CountStyle {
        let cacheKey = "\(entityType.rawValue):\(entityId)"
        guard let count = counts[cacheKey] else { return .unknown }
        return .known(count)
    }
}
