using DeepDrftModels.Enums;
using Models.Models;

namespace DeepDrftModels.DTOs;

// Mirror of ReleaseEntity (Phase 8 §8.0). Inherits Id, CreatedAt, UpdatedAt from BaseModel
// (Cerebellum.BlazorBlocks.Models). No `required` members — BlazorBlocks's Manager<> generic
// constraint requires `new()`, which does not compose with required members (see TrackDto header).
// TrackConverter assigns every field on the round-trip, so an empty default is never observable.
public class ReleaseDto : BaseModel
{
    // The release's public handle — the GUID string the public site/API address it by (Phase 11 §3e).
    // Mirrors TrackDto's EntryKey. No `required` (BaseModel/Manager<> need new()); TrackConverter
    // assigns it on every round-trip, so an empty default is never observable.
    public string EntryKey { get; set; } = string.Empty;
    public string Title { get; set; } = string.Empty;
    public string Artist { get; set; } = string.Empty;
    public string? Genre { get; set; }
    public string? Description { get; set; }
    public DateOnly? ReleaseDate { get; set; }
    public string? ImagePath { get; set; }
    public ReleaseMedium Medium { get; set; } = ReleaseMedium.Cut;

    // Nullable: meaningful only for Cut releases. TrackConverter nulls it for Session/Mix at the
    // mapping point. One producer enforces the rule; no consumer depends on a non-null value.
    public ReleaseType? ReleaseType { get; set; }

    // Medium-specific satellites. Populated only for the matching medium; null otherwise.
    public SessionMetadataDto? SessionMetadata { get; set; }
    public MixMetadataDto? MixMetadata { get; set; }

    public long? CreatedByUserId { get; set; }

    // Read-model field: count of non-deleted tracks in this release. Not on ReleaseEntity — the
    // service projects it from the joined Tracks collection so the /albums browse grid and the CMS
    // dashboard can show a per-album track count. Defaults to 0 when not populated.
    public int TrackCount { get; set; }
}
