<script>
	import { appState } from '$lib/stores.svelte';
	import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index';
	import { Button } from '$lib/components/ui/button';
	import Gear from 'svelte-radix/Gear.svelte';
	import Dashboard from './dashboard.svelte';

	let closeFocus = 'textarea#doc.textarea';
</script>

<DropdownMenu.Root
	open={appState.menuOpen}
	onOpenChange={(v) => {
		appState.menuOpen = v;
	}}
	{closeFocus}
>
	<DropdownMenu.Trigger asChild let:builder>
		<Button builders={[builder]} variant="ghost" class="absolute right-2 top-2" size="icon">
			<Gear class="h-4 w-4" />
		</Button>
	</DropdownMenu.Trigger>
	<DropdownMenu.Content class="w-56">
		<DropdownMenu.Label>Inställningar</DropdownMenu.Label>
		<DropdownMenu.Item
			on:click={() => {
				appState.open = 'dashboard';
			}}
		>
			Dashboard
			<DropdownMenu.Shortcut>F10</DropdownMenu.Shortcut>
		</DropdownMenu.Item>
		<DropdownMenu.Separator />
		<DropdownMenu.Group>
			<DropdownMenu.Item
				on:click={() => {
					appState.open = 'create';
				}}
			>
				Lägg till förkortning
				<DropdownMenu.Shortcut>F2</DropdownMenu.Shortcut>
			</DropdownMenu.Item>
			<DropdownMenu.Item>
				Statistik
				<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
			</DropdownMenu.Item>
		</DropdownMenu.Group>
		<DropdownMenu.Separator />
		<DropdownMenu.Group>
			<DropdownMenu.Item
				on:click={() => {
					appState.open = 'selectLists';
				}}
			>
				Välj listor
				<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
			</DropdownMenu.Item>
			<DropdownMenu.Item>
				Förkortningar
				<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
			</DropdownMenu.Item>
			<DropdownMenu.Item
				on:click={() => {
					appState.open = 'statistics';
				}}
			>
				Statistik
				<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
			</DropdownMenu.Item>
			<DropdownMenu.Item>
				Textinställningar
				<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
			</DropdownMenu.Item>
			<DropdownMenu.Item
				on:click={() => {
					appState.open = 'hotkeys';
				}}
			>
				Kortkommandon
				<DropdownMenu.Shortcut>Ctrl+K</DropdownMenu.Shortcut>
			</DropdownMenu.Item>
			<DropdownMenu.Item>
				Tangentbord
				<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
			</DropdownMenu.Item>
		</DropdownMenu.Group>
		<DropdownMenu.Separator />
		<DropdownMenu.Group>
			<DropdownMenu.Sub>
				<DropdownMenu.SubTrigger>Anslut</DropdownMenu.SubTrigger>
				<DropdownMenu.SubContent>
					<DropdownMenu.Item>
						Distanstolkning
						<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
					</DropdownMenu.Item>
					<DropdownMenu.Item>
						Lokalt nätverk
						<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
					</DropdownMenu.Item>
				</DropdownMenu.SubContent>
			</DropdownMenu.Sub>
		</DropdownMenu.Group>
		<DropdownMenu.Separator />
		<DropdownMenu.Item>
			Hjälp
			<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
		</DropdownMenu.Item>
		<DropdownMenu.Item
			>Feedback
			<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
		</DropdownMenu.Item>
		<DropdownMenu.Item
			>Användarkonto
			<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
		</DropdownMenu.Item>
		<DropdownMenu.Separator />
		<DropdownMenu.Item>
			Logga ut
			<DropdownMenu.Shortcut>⇧⌘Q</DropdownMenu.Shortcut>
		</DropdownMenu.Item>
	</DropdownMenu.Content>
</DropdownMenu.Root>
