{{define "tabler_navbar_menu"}}
<ul class="navbar-nav">
{{range $key, $item := .NavbarMenu}}
  <li class="nav-item{{if $item.Active}} active{{end}}{{if $item.Children}} dropdown{{end}}">
    <a class="nav-link{{if $item.Children}} dropdown-toggle{{end}}{{if $item.Disabled}} disabled{{end}}" {{if $item.Children}}href="#navbar-{{$key}}" data-bs-toggle="dropdown" data-bs-auto-close="outside" role="button" aria-haspopup="true" aria-expanded="false"{{else}}href="{{$item.URL}}"{{end}}{{if $item.Active}} aria-current="page"{{end}}>
      <span class="nav-link-icon d-md-none d-lg-inline-block">
        {{template "tabler_icon" $item.Icon}}
      </span>
      <span class="nav-link-title">{{$item.Title}}</span>
      {{if $item.Badge}}<span class="badge badge-sm bg-red text-red-fg">{{$item.Badge}}</span>{{end}}
    </a>

    {{if $item.Children}}
    <div class="dropdown-menu{{if $item.Active}} show{{end}}">
      {{if gt $item.Columns 0}}
      <div class="dropdown-menu-columns">
        <div class="dropdown-menu-column">
      {{end}}

      {{range $childIndex, $child := $item.Children}}
        {{if $child.Children}}<div class="dropend">{{end}}
        <a class="dropdown-item{{if $child.Children}} dropdown-toggle{{end}}{{if $child.Color}} text-{{$child.Color}}{{end}}" {{if $child.Children}}href="#sidebar-{{$child.URL}}" data-bs-toggle="dropdown" data-bs-auto-close="outside" role="button" aria-haspopup="true" aria-expanded="false"{{else}}href="{{$child.URL}}"{{end}}{{if $child.URL}}{{end}}>
          {{if $child.Icon}}{{template "tabler_icon_small" $child.Icon}}{{end}}
          {{$child.Title}}
          {{if $child.Badge}}<span class="badge badge-sm bg-green-lt text-uppercase ms-auto">{{$child.Badge}}</span>{{end}}
        </a>
        {{if $child.Children}}
        <div class="dropdown-menu">
          {{range $subchild := $child.Children}}
          <a href="{{$subchild.URL}}" class="dropdown-item">
            {{$subchild.Title}}
            {{if $subchild.Badge}}<span class="badge badge-sm bg-green-lt text-uppercase ms-auto">{{$subchild.Badge}}</span>{{end}}
          </a>
          {{end}}
        </div>
        {{end}}
        {{if $child.Children}}</div>{{end}}
      {{end}}

      {{if gt $item.Columns 0}}
        </div>
      </div>
      {{end}}
    </div>
    {{end}}
  </li>
{{end}}
</ul>
{{end}}
