using System.Text.Json.Serialization;

namespace Lumi.Companion.SongOverlay;

internal sealed record MediaTrack(
    string Key,
    string Title,
    string Artist,
    string Album,
    string ReleaseYear,
    string Link,
    long DurationMilliseconds,
    CoverPayload? Cover);

internal sealed record MediaSnapshot(
    string Provider,
    string Status,
    long PositionMilliseconds,
    long DurationMilliseconds,
    double PlaybackRate,
    MediaTrack? Track,
    DateTimeOffset CapturedAt);

internal sealed record CoverPayload(
    [property: JsonPropertyName("mime")] string Mime,
    [property: JsonPropertyName("base64")] string Base64,
    [property: JsonPropertyName("primary")] string Primary,
    [property: JsonPropertyName("secondary")] string Secondary);

internal sealed record TrackPayload(
    [property: JsonPropertyName("key")] string Key,
    [property: JsonPropertyName("title")] string Title,
    [property: JsonPropertyName("artist")] string Artist,
    [property: JsonPropertyName("album")] string Album,
    [property: JsonPropertyName("release_year")] string ReleaseYear,
    [property: JsonPropertyName("link")] string Link,
    [property: JsonPropertyName("cover")] CoverPayload? Cover);

internal sealed record PlaybackPayload(
    [property: JsonPropertyName("status")] string Status,
    [property: JsonPropertyName("position_ms")] long PositionMilliseconds,
    [property: JsonPropertyName("duration_ms")] long DurationMilliseconds,
    [property: JsonPropertyName("rate")] double Rate);

internal sealed record NowPlayingEventPayload(
    [property: JsonPropertyName("protocol_version")] int ProtocolVersion,
    [property: JsonPropertyName("provider")] string Provider,
    [property: JsonPropertyName("session_id")] string SessionId,
    [property: JsonPropertyName("sequence")] long Sequence,
    [property: JsonPropertyName("event")] string Event,
    [property: JsonPropertyName("occurred_at")] long OccurredAt,
    [property: JsonPropertyName("playback")] PlaybackPayload Playback,
    [property: JsonPropertyName("track")] TrackPayload? Track);
