<script module lang="ts">
	import { resolve } from "$app/paths";

	export const searchUrl = (type: string, q: string) =>
		resolve(`/search?type=${type}&q=${encodeURIComponent(q)}` as "/");
</script>

<script lang="ts">
	import Tabs, { type TabDef } from "$lib/components/ui/Tabs.svelte";

	interface Props {
		query: string;
		active: string;
	}

	let { query, active }: Props = $props();

	const tabs = $derived<TabDef[]>([
		{ id: "repo", label: "Repositories", href: searchUrl("repo", query) },
		{ id: "code", label: "Code", href: searchUrl("code", query) }
	]);
</script>

<Tabs {tabs} {active} label="Search type" vertical />
