import Foundation

struct TypeDiff: Identifiable {
    let id: String
    let typeIdentifier: String
    let displayName: String
    let currentCount: Int
    let previousCount: Int
    let previousTracked: Bool
    let appearedCount: Int
    let disappearedCount: Int
    let representationChangedCount: Int

    var delta: Int { currentCount - previousCount }

    var recordChangeCount: Int {
        appearedCount + disappearedCount + representationChangedCount
    }

    var hasChanges: Bool {
        delta != 0 || recordChangeCount > 0
    }

    var percentChange: Double? {
        guard previousTracked, previousCount > 0 else { return nil }
        return Double(delta) / Double(previousCount) * 100
    }
}

enum DiffFilter: String, CaseIterable {
    case all        = "All"
    case changed    = "Changed"
    case increased  = "Increased"
    case decreased  = "Decreased"
}
