@inherits CmsMediumBrowserBase<CmsCutBrowser.CutRow>
@using DeepDrftModels.DTOs
@using DeepDrftModels.Enums

@* CUTS tab content (Phase 9 §8.A/§8.C): the rich CmsAlbumBrowser grid filtered to Cut releases, so the
   tab carries expand-tracks, delete, the Type chip, and per-row edit identically to the ALL tab — no
   forked grid. Cuts have no medium-specific action, so no SpecialColumns are supplied; the grid renders
   its shared edit/delete only. Embedded as tab content only; no standalone @page route. *@
<CmsAlbumBrowser @ref="_albumBrowser"
                 Releases="Releases"
                 IsLoading="Loading"
                 OnReleasesChanged="ReloadAsync"
                 OnWaveformGenerated="OnWaveformGenerated" />

@code {
    /// <summary>
    /// Forwarded from the inner <see cref="CmsAlbumBrowser"/>: fires after any per-row waveform
    /// generate succeeds so the parent page can refresh its catalogue-wide missing-count badges.
    /// </summary>
    [Parameter] public EventCallback OnWaveformGenerated { get; set; }

    private CmsAlbumBrowser? _albumBrowser;

    protected override ReleaseMedium Medium => ReleaseMedium.Cut;
    protected override string MediumNoun => "cuts";

    protected override CutRow ToRow(ReleaseDto release) => new() { Release = release };
    protected override ReleaseDto ReleaseOf(CutRow row) => row.Release;

    /// <summary>
    /// Clears the inner grid's cached per-track waveform status so the next row expand re-fetches.
    /// Called by the parent page after a catalogue-wide bulk run.
    /// </summary>
    public Task InvalidateWaveformStatusAsync() =>
        _albumBrowser?.InvalidateWaveformStatusAsync() ?? Task.CompletedTask;

    public sealed class CutRow
    {
        public required ReleaseDto Release { get; set; }
    }
}
