<template>
	<nav class="navbar navbar-expand-lg fixed-top navbar-dark bg-dark">
		<div class="container-fluid">
			<router-link class="navbar-brand" to="/"><img src="/icon.svg" style="height: 1.875rem;" /></router-link>
			<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
				<span class="navbar-toggler-icon"></span>
			</button>
			<div class="collapse navbar-collapse" id="navbarSupportedContent">
				<ul class="navbar-nav me-auto mb-2 mb-lg-0">
					<li v-if="menustate.length > 0" v-for="item in menustate[0].items" class="nav-item">
						<router-link class="nav-link" :to="item.href">{{item.name}}</router-link>
					</li>
					<li v-if="menustate.length > 1" v-for="menu in menustate.slice(1)" class="nav-item dropdown">
						<button class="nav-link btn dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">{{menu.name}}</button>
						<ul class="dropdown-menu dropdown-menu-dark">
							<li v-for="item in menu.items" class="nav-item">
								<router-link class="nav-link" :to="item.href">{{item.name}}</router-link>
							</li>
						</ul>
					</li>
				</ul>
				<div class="navbar-nav" v-if="server">
					<a class="nav-link disabled"><template v-if="user">{{user[2]}} @ </template>{{server.domain}}</a>
				</div>
			</div>
		</div>
	</nav>
</template>

<style scoped>
	.navbar-nav .nav-link.router-link-exact-active {
		color: #fff;
	}
</style>

<script>
	import vistax from './vistax.mjs';
	import { menustate } from './common.mjs';

	export default {
		props: {
			server: {
				type: Object,
				default: null
			},
			user: {
				type: Array,
				default: null
			}
		},
		data() {
			return {
				menustate
			};
		}
	};
</script>
