@using Iceshrimp.Shared.Schemas.Web
@using Iceshrimp.Assets.PhosphorIcons
@inject NavigationManager Nav

@if (Indented == false)
{
    <UserAvatar User="@User" OnClick="@OpenProfile" Role="link"/>
}
<div class="name-section">
    <span class="display-name"><UserDisplayName User="@User"/></span>
    <span class="identifier">
        @@@User.Username
        @if (User.Host != null)
        {
            <span class="host">@@@User.Host</span>
        }
        @if (User.IsBot)
        {
            <Icon Name="Icons.Robot" Size="1.3em" title="Automated"/>
        }
    </span>
</div>

@code {
    [Parameter] [EditorRequired] public required UserResponse User     { get; set; }
    [Parameter] [EditorRequired] public required bool         Indented { get; set; }

    private void OpenProfile()
    {
        var path = $"@{User.Username}";
        if (User.Host?.Length > 0)
        {
            path += $"@{User.Host}";
        }

        Nav.NavigateTo($"/{path}");
    }
}