@using DeepDrftModels.Enums
@using Microsoft.AspNetCore.Components.Forms

@* The single dispatch point for medium-conditional form fields. All five upload/edit forms embed this
   one component; the @switch below is the ONLY place medium-specific form shape is decided. Adding a
   medium is one new section component + one new switch arm here — nowhere else. *@
<MudGrid>
    <MudItem xs="12" sm="6">
        <MudSelect T="ReleaseMedium"
                   Value="Medium"
                   ValueChanged="@(v => MediumChanged.InvokeAsync(v))"
                   Label="Medium"
                   Variant="Variant.Outlined"
                   Disabled="Disabled">
            @foreach (var medium in Enum.GetValues<ReleaseMedium>())
            {
                <MudSelectItem T="ReleaseMedium" Value="medium">@medium</MudSelectItem>
            }
        </MudSelect>
    </MudItem>

    @switch (Medium)
    {
        case ReleaseMedium.Cut:
            <CutFields ReleaseType="ReleaseType"
                       ReleaseTypeChanged="ReleaseTypeChanged"
                       Disabled="Disabled" />
            break;
        case ReleaseMedium.Session:
            <SessionFields HeroImageFile="HeroImageFile"
                           HeroImageFileChanged="HeroImageFileChanged"
                           AllowHeroUpload="AllowHeroUpload"
                           Disabled="Disabled" />
            break;
        case ReleaseMedium.Mix:
            <MixFields />
            break;
    }
</MudGrid>

@code {
    [Parameter] public ReleaseMedium Medium { get; set; } = ReleaseMedium.Cut;
    [Parameter] public EventCallback<ReleaseMedium> MediumChanged { get; set; }

    // Cut-only — bound through to CutFields. Ignored for Session/Mix.
    [Parameter] public ReleaseType ReleaseType { get; set; } = ReleaseType.Single;
    [Parameter] public EventCallback<ReleaseType> ReleaseTypeChanged { get; set; }

    // Session-only — the held hero-image file, uploaded after create. Ignored for Cut/Mix.
    [Parameter] public IBrowserFile? HeroImageFile { get; set; }
    [Parameter] public EventCallback<IBrowserFile?> HeroImageFileChanged { get; set; }

    // Gates the hero file picker in SessionFields. True on the BatchUpload create path;
    // false/absent on all edit paths so SessionFields falls back to the guidance alert.
    [Parameter] public bool AllowHeroUpload { get; set; }

    [Parameter] public bool Disabled { get; set; }
}
