'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { ChevronRight, Home } from 'lucide-react';
const LABEL_MAP = {
    posts: 'Posts',
    pages: 'Pages',
    media: 'Media Library',
    forms: 'Forms',
    seo: 'SEO',
    redirects: 'Redirects',
    canonicals: 'Canonicalization',
    links: 'Link Health',
    users: 'Users',
    'script-tags': 'Script Tags',
    settings: 'Settings',
    profile: 'Your Profile',
    collections: 'Collections',
    submissions: 'Submissions',
    new: 'New',
    edit: 'Edit',
};
function labelFor(segment) {
    return (LABEL_MAP[segment] ?? segment.replace(/[-_]/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase()));
}
function isId(segment) {
    return /^\d+$/.test(segment) || /^[0-9a-f]{8,}$/i.test(segment);
}
export function Breadcrumbs({ currentPath, onNavigate }) {
    // Strip query string + hash so tab-driven routes (e.g. `/settings?tab=users`,
    // `/seo?tab=audit`) don't leak the raw query into a crumb label.
    const cleanPath = currentPath.split('?')[0].split('#')[0];
    const segments = cleanPath.split('/').filter(Boolean);
    if (segments.length === 0)
        return null;
    const crumbs = [];
    let accumulated = '';
    for (let i = 0; i < segments.length; i++) {
        const seg = segments[i];
        accumulated += `/${seg}`;
        let label;
        if (isId(seg)) {
            const parentLabel = i > 0 ? labelFor(segments[i - 1]) : '';
            label = parentLabel ? `Edit ${parentLabel.replace(/s$/, '')}` : `#${seg}`;
        }
        else {
            label = labelFor(seg);
        }
        crumbs.push({ label, path: accumulated });
    }
    return (_jsxs("nav", { "aria-label": "Breadcrumb", className: "flex items-center gap-1 overflow-x-auto border-b border-gray-200 bg-white px-4 py-2.5 text-sm", children: [_jsxs("button", { type: "button", onClick: () => onNavigate('/'), className: "flex shrink-0 items-center gap-1 text-gray-500 transition-colors hover:text-blue-600", children: [_jsx(Home, { className: "h-3.5 w-3.5" }), _jsx("span", { className: "hidden sm:inline", children: "Dashboard" })] }), crumbs.map((crumb, i) => {
                const isLast = i === crumbs.length - 1;
                return (_jsxs("span", { className: "flex shrink-0 items-center gap-1", children: [_jsx(ChevronRight, { className: "h-3.5 w-3.5 text-gray-400" }), isLast ? (_jsx("span", { className: "font-medium text-gray-900", children: crumb.label })) : (_jsx("button", { type: "button", onClick: () => onNavigate(crumb.path), className: "text-gray-500 transition-colors hover:text-blue-600", children: crumb.label }))] }, crumb.path));
            })] }));
}
//# sourceMappingURL=Breadcrumbs.js.map