@namespace Oqtane.Themes.Controls
@inherits MenuItemsBase

@if (ParentPage != null)
{
    <div class="dropdown-menu" aria-labelledby="@($"navbarDropdown{ParentPage.PageId}")">
        @foreach (var childPage in GetChildPages())
        {
            if (childPage.PageId == PageState.Page.PageId)
            {
                <a class="nav-link active px-3" href="@GetUrl(childPage)" target="@GetTarget(childPage)">
                        <span class="@childPage.Icon" aria-hidden="true" />
                        @childPage.Name <span class="sr-only">(current)</span>
                </a>
            }
            else
            {
                <a class="nav-link px-3" href="@GetUrl(childPage)" target="@GetTarget(childPage)">
                    <span class="@childPage.Icon" aria-hidden="true" />
                    @childPage.Name
                </a>
            }
        }
    </div>
}
else
{
    <ul class="navbar-nav mr-auto">
        @foreach (var childPage in GetChildPages())
        {
            if (!Pages.Any(e => e.ParentId == childPage.PageId))
            {
                if (childPage.PageId == PageState.Page.PageId)
                {
                    <li class="nav-item active">
                        <a class="nav-link" href="@GetUrl(childPage)" target="@GetTarget(childPage)">
                            <span class="@childPage.Icon" aria-hidden="true" />
                            @childPage.Name <span class="sr-only">(current)</span>
                        </a>
                    </li>
                }
                else
                {
                    <li class="nav-item">
                        <a class="nav-link" href="@GetUrl(childPage)" target="@GetTarget(childPage)">
                            <span class="@childPage.Icon" aria-hidden="true" />
                            @childPage.Name
                        </a>
                    </li>
                }
            }
            else
            {
                if (childPage.PageId == PageState.Page.PageId)
                {
                    <li class="nav-item dropdown active">
                        <a class="nav-link dropdown-toggle" href="@GetUrl(childPage)" target="@GetTarget(childPage)" id="@($"navbarDropdown{childPage.PageId}")" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            <span class="@childPage.Icon" aria-hidden="true" />
                            @childPage.Name <span class="sr-only">(current)</span>
                        </a>
                        <MenuItemsHorizontal ParentPage="childPage" Pages="Pages" />
                    </li>
                }
                else
                {
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="@GetUrl(childPage)" target="@GetTarget(childPage)" id="@($"navbarDropdown{childPage.PageId}")" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            <span class="@childPage.Icon" aria-hidden="true" />
                            @childPage.Name
                        </a>
                        <MenuItemsHorizontal ParentPage="childPage" Pages="Pages" />
                    </li>
                }
            }
        }
    </ul>
}
