import Foundation

enum ResourceKind: String, Codable, CaseIterable, Hashable {
    case video
    case audio
    case pdf
    case other

    var label: String {
        switch self {
        case .video: return "Video"
        case .audio: return "Audio"
        case .pdf: return "PDF"
        case .other: return "Other"
        }
    }

    static func from(extension ext: String) -> ResourceKind {
        switch ext.lowercased() {
        case "mp4", "webm", "mkv", "mov", "avi", "m4v":
            return .video
        case "mp3", "wav", "m4a", "aac", "ogg", "flac", "wma":
            return .audio
        case "pdf":
            return .pdf
        default:
            return .other
        }
    }

    static func from(url: URL) -> ResourceKind {
        from(extension: url.pathExtension)
    }
}
