@namespace DeepDrftPublic.Client.Controls

<MudTooltip Text="Share">
    <MudIconButton Icon="@Icons.Material.Filled.Share"
                   Size="Size.Large"
                   Color="Color.Secondary"
                   Disabled="@(!RendererInfo.IsInteractive)"
                   OnClick="@Toggle"
                   aria-label="@(IsReleaseMode ? "Share this release" : "Share this track")" />
</MudTooltip>

<MudOverlay Visible="@_open" OnClick="@Close" AutoClose="true" />

<MudPopover Open="@_open"
            Fixed="false"
            AnchorOrigin="Origin.BottomRight"
            TransformOrigin="Origin.TopRight"
            Class="deepdrft-share-popover">
    <MudStack Spacing="2" Class="deepdrft-share-popover-body">

        <MudStack Row AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween">
            <MudButton StartIcon="@Icons.Material.Filled.Link"
                       Variant="Variant.Text"
                       Color="Color.Primary"
                       OnClick="@CopyLink">
                Copy link
            </MudButton>
            @if (_linkCopied)
            {
                <MudText Typo="Typo.caption" Color="Color.Success">Copied!</MudText>
            }
        </MudStack>

        @* Embed is a single-track affordance only; a release page is not a single-track embed (§3b.3). *@
        @if (!IsReleaseMode)
        {
            <MudDivider />

            <MudCheckBox @bind-Value="Embed" Color="Color.Primary" Label="Embed player" Dense="true" />

            @if (_embed)
            {
                <MudStack Row AlignItems="AlignItems.Center" Spacing="1">
                    <MudTextField Value="@EmbedSnippet"
                                  T="string"
                                  ReadOnly="true"
                                  Variant="Variant.Outlined"
                                  Lines="3"
                                  Margin="Margin.Dense"
                                  Class="deepdrft-share-embed-field" />
                    <MudStack AlignItems="AlignItems.Center" Spacing="0">
                        <MudIconButton Icon="@Icons.Material.Filled.ContentCopy"
                                       Color="Color.Primary"
                                       OnClick="@CopyEmbed"
                                       aria-label="Copy embed snippet" />
                        @if (_embedCopied)
                        {
                            <MudText Typo="Typo.caption" Color="Color.Success">Copied!</MudText>
                        }
                    </MudStack>
                </MudStack>
            }
        }

    </MudStack>
</MudPopover>
