1<script lang="ts">
 2	import { cn, type WithElementRef } from '$lib/components/ui/utils.js';
 3	import type { Snippet } from 'svelte';
 4	import type { HTMLButtonAttributes } from 'svelte/elements';
 5
 6	let {
 7		ref = $bindable(null),
 8		class: className,
 9		children,
10		child,
11		...restProps
12	}: WithElementRef<HTMLButtonAttributes> & {
13		child?: Snippet<[{ props: Record<string, unknown> }]>;
14	} = $props();
15
16	const mergedProps = $derived({
17		class: cn(
18			'text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground outline-hidden absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
19			// Increases the hit area of the button on mobile.
20			'after:absolute after:-inset-2 md:after:hidden',
21			'group-data-[collapsible=icon]:hidden',
22			className
23		),
24		'data-slot': 'sidebar-group-action',
25		'data-sidebar': 'group-action',
26		...restProps
27	});
28</script>
29
30{#if child}
31	{@render child({ props: mergedProps })}
32{:else}
33	<button bind:this={ref} {...mergedProps}>
34		{@render children?.()}
35	</button>
36{/if}