<script lang="ts">
	import { ArrowUpRight } from 'lucide-svelte';
	import type { HTMLAnchorAttributes } from 'svelte/elements';

	import { cn } from '$lib/utils';

	type $$Props = HTMLAnchorAttributes & {
		external?: boolean;
	};

	let className: string | undefined | null = undefined;
	export { className as class };

	export let href: $$Props['href'] = '';
	export let external = false;
</script>

<a
	{href}
	target={external ? '_blank' : undefined}
	class={cn(external && 'flex items-center gap-0.5', className)}
	{...$$restProps}
>
	<slot />
	{#if external}
		<ArrowUpRight class="h-3 w-3" />
	{/if}
</a>
