'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useId } from 'react';
import { SettingsSourceBadge } from './components.js';
import { SecurityCard, StatusRow } from './securityPrimitives.js';
function secretValue(status) {
    switch (status) {
        case 'pass':
            return 'Configured';
        case 'warning':
            return 'Not configured';
        case 'fail':
            return 'Missing / invalid';
        default:
            return 'Unknown';
    }
}
export function SecretsAuditCard({ secrets, auditEnabled, failedLogins24h, users, apiKeys, sources, onNavigate, }) {
    const headingId = useId();
    return (_jsxs(SecurityCard, { headingId: headingId, title: "Secrets, Encryption & Audit", description: "Platform secret status (values are never shown), audit logging, and cross-module risk.", children: [_jsxs("div", { className: "space-y-2", children: [_jsx(StatusRow, { status: secrets.cmsSecret, label: "CMS signing secret", value: secretValue(secrets.cmsSecret), badge: _jsx(SettingsSourceBadge, { meta: sources.cmsSecret }) }), _jsx(StatusRow, { status: secrets.encryptionKey, label: "Encryption key", value: secretValue(secrets.encryptionKey), badge: _jsx(SettingsSourceBadge, { meta: sources.encryptionKey }) }), _jsx(StatusRow, { status: "pass", label: "API keys hashed at rest", value: "Yes" }), _jsx(StatusRow, { status: secrets.webhookSecretsEncrypted ? 'pass' : 'warning', label: "Webhook secrets encrypted", value: secrets.webhookSecretsEncrypted ? 'Yes' : 'Plaintext fallback' })] }), _jsxs("div", { className: "border-border mt-4 space-y-2 border-t pt-4", children: [_jsx(StatusRow, { status: auditEnabled ? 'pass' : 'warning', label: "Audit logging", value: auditEnabled ? 'Enabled' : 'Disabled', badge: _jsx(SettingsSourceBadge, { meta: sources.audit }) }), _jsx(StatusRow, { status: failedLogins24h >= 20 ? 'warning' : 'pass', label: "Failed logins (24h)", value: String(failedLogins24h) })] }), _jsxs("div", { className: "border-border mt-4 space-y-3 border-t pt-4", children: [_jsxs("div", { className: "flex items-start justify-between gap-3", children: [_jsxs("div", { className: "text-sm", children: [_jsx("p", { className: "text-foreground font-medium", children: "Users" }), _jsxs("p", { className: "text-muted-foreground", children: [users.totalAdmins, " admin", users.totalAdmins === 1 ? '' : 's', ",", ' ', users.adminsWithoutMfa, " without MFA", users.inactive > 0 ? `, ${users.inactive} inactive` : ''] })] }), onNavigate && (_jsx("button", { type: "button", onClick: () => onNavigate('/settings?tab=users'), className: "text-brand shrink-0 text-sm hover:underline", children: "Review users \u2192" }))] }), _jsxs("div", { className: "flex items-start justify-between gap-3", children: [_jsxs("div", { className: "text-sm", children: [_jsx("p", { className: "text-foreground font-medium", children: "API keys" }), _jsxs("p", { className: "text-muted-foreground", children: [apiKeys.active, " active, ", apiKeys.broadScope, " broad-scope, ", apiKeys.withoutExpiration, ' ', "without expiry"] })] }), onNavigate && (_jsx("button", { type: "button", onClick: () => onNavigate('/settings?tab=api-keys'), className: "text-brand shrink-0 text-sm hover:underline", children: "Review API keys \u2192" }))] })] })] }));
}
//# sourceMappingURL=SecretsAuditCard.js.map