import {
    Bell,
    Briefcase,
    CalendarDays,
    ClipboardList,
    History,
    LayoutDashboard,
    MapPin,
    MessageSquare,
    Mic,
    Settings,
    Smartphone,
    Ticket,
    Users,
} from '@lucide/vue';
import type { Role, SpotNavItem } from '@/types';

const item = (
    key: string,
    href: string,
    icon: SpotNavItem['icon'],
    extra: Partial<SpotNavItem> = {},
): SpotNavItem => ({ key, title: `common.nav.${key}`, href, icon, ...extra });

export const notificationsItem = item('notifications', '/notifications', Bell, {
    badge: 'notifications',
});
export const settingsItem = item('settings', '/settings/profile', Settings);

const managerHome = item('home', '/manager', LayoutDashboard, { exact: true });
const managerCalendar = item('calendar', '/manager/calendar', CalendarDays);
const managerShows = item('shows', '/manager/shows', Mic);
const inbox = item('inbox', '/inbox', MessageSquare, { badge: 'messages' });

const comedianOverview = item('overview', '/home', LayoutDashboard, { exact: true });
const comedianCalendar = item('calendar', '/calendar', CalendarDays);
const comedianBookings = item('bookings', '/bookings', Ticket);

export type RoleNavigation = {
    /** Everything, in sidebar order (excluding notifications/settings). */
    main: SpotNavItem[];
    /** Items pinned in the mobile bottom tab bar (4). */
    tabs: SpotNavItem[];
    /** Items behind the mobile "More" sheet (excluding notifications/settings, added by the bar). */
    more: SpotNavItem[];
};

export function navigationFor(role: Role | string | undefined): RoleNavigation {
    if (role === 'manager') {
        const rest = [
            item('proposals', '/manager/proposals', ClipboardList),
            item('roster', '/manager/roster', Users),
            item('venues', '/manager/venues', MapPin),
            item('activity', '/manager/activity', History),
            item('deliveries', '/manager/deliveries', Smartphone),
        ];

        return {
            main: [managerHome, managerCalendar, managerShows, ...rest.slice(0, 3), inbox, ...rest.slice(3)],
            tabs: [managerHome, managerCalendar, managerShows, inbox],
            more: rest,
        };
    }

    const engagements = item('engagements', '/engagements', Briefcase);

    return {
        main: [comedianOverview, comedianCalendar, inbox, comedianBookings, engagements],
        tabs: [comedianOverview, comedianCalendar, inbox, comedianBookings],
        more: [engagements],
    };
}
