import { Breadcrumbs } from '@/components/Breadcrumbs';
import SettingsPanel from '@/components/SettingsPanel';
import { Button } from '@/components/ui/button';
import { SidebarTrigger } from '@/components/ui/sidebar';
import { type BreadcrumbItem as BreadcrumbItemType } from '@/types';
import { Settings } from 'lucide-react';
import { useState } from 'react';

export function AppSidebarHeader({
    breadcrumbs = [],
}: {
    breadcrumbs?: BreadcrumbItemType[];
}) {
    const [settingsOpen, setSettingsOpen] = useState(false);

    return (
        <header className="flex h-16 shrink-0 items-center gap-2 border-b border-sidebar-border/50 px-6 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12 md:px-4">
            <div className="flex items-center gap-2">
                <SidebarTrigger className="-ml-1" />
                <Breadcrumbs breadcrumbs={breadcrumbs} />
            </div>

            <div className="ml-auto flex items-center">
                <Button
                    variant="ghost"
                    size="icon"
                    className="h-9 w-9"
                    onClick={() => setSettingsOpen(true)}
                >
                    <Settings className="h-5 w-5 opacity-80" />
                    <span className="sr-only">Settings</span>
                </Button>
            </div>

            <SettingsPanel onOpenChange={setSettingsOpen} />
        </header>
    );
}
