@inherits LayoutComponentBase
@using DeepDrftShared.Client.Common
@using AuthBlocksWeb.Components.Layout

<MudThemeProvider IsDarkMode="false" Theme="@DeepDrftPalettes.Cms" />
<MudPopoverProvider />
<MudDialogProvider />
<MudSnackbarProvider />

<MudLayout>
    <MudAppBar Dense="true" Elevation="1" Color="Color.Primary">
        <MudIconButton Icon="@Icons.Material.Filled.Menu"
                       Color="Color.Inherit"
                       Edge="Edge.Start"
                       OnClick="ToggleDrawer" />
        <a href="/" class="mx-2">
            <MudStack Row AlignItems="AlignItems.Center">
                <MudImage Src="img/deepdrft-logo-l.webp" 
                          Alt="Deep Drft Ornamental Logo Left"
                          Width="24"
                          Height="24 "
                          Style="filter: invert(1);"/>
                
                <MudText Typo="Typo.button" Style="color: var(--deepdrft-white);">Deep DRFT Management</MudText>
                
                <MudImage Src="img/deepdrft-logo-r.webp" 
                          Alt="Deep Drft Ornamental Logo Right"
                          Width="24"
                          Height="24"
                          Style="filter: invert(1);"/>
            </MudStack>
        </a>
        <MudSpacer />
        <MudTooltip Text="Catalogue">
            <MudIconButton Icon="@Icons.Material.Filled.Home"
                           Href="/catalogue"
                           Color="Color.Inherit" />
        </MudTooltip>
    </MudAppBar>
    <MudDrawer @bind-Open="_drawerOpen" Elevation="2" Variant="DrawerVariant.Responsive" ClipMode="DrawerClipMode.Always">
        <MudNavMenu>
            <MudNavLink Href="/catalogue" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Dashboard">Catalogue</MudNavLink>
            <MudNavLink Href="/releases" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.LibraryMusic">Releases</MudNavLink>
            <MudNavLink Href="/tracks/upload" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.UploadFile">Upload</MudNavLink>
            <UserAdminMenu />
            <HierarchicalRoleAuthorizeView RolesList="@([SystemRoleConstants.UserAdmin])">
                <Authorized>
                    <MudNavLink Href="/useradmin/users/new" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.PersonAdd">Provision User</MudNavLink>
                </Authorized>
            </HierarchicalRoleAuthorizeView>
            <AccountNavMenu />
        </MudNavMenu>
    </MudDrawer>
    <MudMainContent Class="pt-14 pb-8">
        <MudContainer MaxWidth="MaxWidth.False" Class="pa-4">
            @Body
        </MudContainer>
    </MudMainContent>
</MudLayout>

@code {
    private bool _drawerOpen = true;

    private void ToggleDrawer() => _drawerOpen = !_drawerOpen;
}

<div id="blazor-error-ui" data-nosnippet>
    An unhandled error has occurred.
    <a href="." class="reload">Reload</a>
    <span class="dismiss">🗙</span>
</div>

