/*
|--------------------------------------------------------------------------
| Agência PSI
|--------------------------------------------------------------------------
| Criado e desenvolvido por Leonardo Nohama
|
| Tecnologia aplicada à escuta.
| Estrutura para o cuidado.
|
| Arquivo: src/navigation/menus/saas.menu.js
| Data: 2026
| Local: São Carlos/SP — Brasil
|--------------------------------------------------------------------------
| © 2026 — Todos os direitos reservados
|--------------------------------------------------------------------------
*/

export default function saasMenu(sessionCtx, opts = {}) {
    if (!sessionCtx?.isSaasAdmin) return [];

    const mismatchCount = Number(opts?.mismatchCount || 0);
    const docsAtencaoCount = Number(opts?.docsAtencaoCount || 0);

    const mismatchBadge = mismatchCount > 0 ? { badge: String(mismatchCount), badgeClass: 'p-badge p-badge-danger' } : {};

    const docsBadge = docsAtencaoCount > 0 ? { badge: String(docsAtencaoCount), badgeClass: 'p-badge p-badge-danger' } : {};

    return [
        {
            label: 'Início',
            items: [{ label: 'Dashboard', icon: 'pi pi-fw pi-chart-bar', to: '/saas' }]
        },

        {
            label: 'Planos',
            items: [
                { label: 'Planos e Preços', icon: 'pi pi-fw pi-list', to: '/saas/plans' },
                { label: 'Vitrine Pública', icon: 'pi pi-fw pi-megaphone', to: '/saas/plans-public' },
                { label: 'Recursos', icon: 'pi pi-fw pi-bolt', to: '/saas/features' },
                { label: 'Controle de Recursos', icon: 'pi pi-fw pi-th-large', to: '/saas/plan-features' },
                { label: 'Limites por Plano', icon: 'pi pi-fw pi-sliders-h', to: '/saas/plan-limits' }
            ]
        },

        {
            label: 'Assinaturas',
            items: [
                { label: 'Listagem', icon: 'pi pi-fw pi-list', to: '/saas/subscriptions' },
                { label: 'Intenções', icon: 'pi pi-fw pi-inbox', to: '/saas/subscription-intents' },
                { label: 'Histórico', icon: 'pi pi-fw pi-history', to: '/saas/subscription-events' },
                {
                    label: 'Saúde das Assinaturas',
                    icon: 'pi pi-fw pi-shield',
                    to: '/saas/subscription-health',
                    ...mismatchBadge
                }
            ]
        },

        {
            label: 'Operações',
            items: [
                { label: 'Usuários / Donos', icon: 'pi pi-fw pi-id-card', to: '/saas/usuarios' },
                { label: 'Clínicas (Tenants)', icon: 'pi pi-fw pi-users', to: '/saas/tenants' },
                { label: 'Recursos por Clínica', icon: 'pi pi-fw pi-key', to: '/saas/tenant-features' },
                { label: 'Segurança / Bots', icon: 'pi pi-fw pi-shield', to: '/saas/security' },
                { label: 'Config / Bloqueios', icon: 'pi pi-fw pi-cog', to: '/saas/app-config' },
                { label: 'Feriados', icon: 'pi pi-fw pi-star', to: '/saas/feriados' },
                { label: 'Suporte Técnico', icon: 'pi pi-fw pi-headphones', to: '/saas/support' }
            ]
        },

        {
            label: 'Canais',
            items: [
                { label: 'WhatsApp (Evolution API)', icon: 'pi pi-fw pi-whatsapp', to: '/saas/whatsapp' },
                { label: 'WhatsApp Twilio (Subcontas)', icon: 'pi pi-fw pi-whatsapp', to: '/saas/twilio-whatsapp' },
                { label: 'Config Twilio (Master)', icon: 'pi pi-fw pi-cog', to: '/saas/twilio-config' },
                { label: 'Templates WhatsApp/SMS', icon: 'pi pi-fw pi-comment', to: '/saas/notification-templates' },
                { label: 'Add-ons / Créditos SMS', icon: 'pi pi-fw pi-box', to: '/saas/addons' }
            ]
        },

        {
            label: 'Conteúdo',
            items: [
                {
                    label: 'Documentação',
                    icon: 'pi pi-fw pi-question-circle',
                    to: '/saas/docs',
                    ...docsBadge
                },
                { label: 'FAQ', icon: 'pi pi-fw pi-comments', to: '/saas/faq' },
                { label: 'Carrossel Login', icon: 'pi pi-fw pi-images', to: '/saas/login-carousel' },
                { label: 'Avisos Globais', icon: 'pi pi-fw pi-megaphone', to: '/saas/global-notices' },
                { label: 'Templates de E-mail', icon: 'pi pi-fw pi-envelope', to: '/saas/email-templates' },
                { label: 'Templates de Documentos', icon: 'pi pi-fw pi-file-edit', to: '/saas/document-templates' }
            ]
        },

        {
            label: 'Desenvolvimento',
            items: [{ label: 'Área de Dev', icon: 'pi pi-fw pi-code', to: '/saas/desenvolvimento' }]
        }
    ];
}
