/**
 * HVAC Testing Framework - Security Module Index
 * 
 * Central export point for all security components with initialization
 * and configuration management.
 * 
 * @author Claude Code - Emergency Security Response
 * @version 1.0.0
 * @security CRITICAL - Main security module export
 */

const { getCredentialManager } = require('./SecureCredentialManager');
const { getCommandExecutor } = require('./SecureCommandExecutor');
const { getBrowserManager } = require('./SecureBrowserManager');
const { getInputValidator } = require('./SecureInputValidator');
const { getWordPressSecurityHelpers } = require('./WordPressSecurityHelpers');

/**
 * Initialize all security components
 * @returns {Object} Security components
 */
function initializeSecurity() {
    console.log('🔐 Initializing HVAC Security Framework...');
    
    try {
        const credentialManager = getCredentialManager();
        const commandExecutor = getCommandExecutor();
        const browserManager = getBrowserManager();
        const inputValidator = getInputValidator();
        const wpSecurity = getWordPressSecurityHelpers();

        console.log('✅ Security framework initialized successfully');
        
        return {
            credentialManager,
            commandExecutor,
            browserManager,
            inputValidator,
            wpSecurity,
            
            // Convenience methods
            async cleanup() {
                await browserManager.cleanup();
                credentialManager.secureCleanup();
                wpSecurity.cleanupCaches();
                console.log('🔒 Security cleanup completed');
            },

            getSecurityStatus() {
                return {
                    timestamp: new Date().toISOString(),
                    components: {
                        credentials: 'initialized',
                        commands: 'initialized', 
                        browser: 'initialized',
                        validation: 'initialized',
                        wordpress: 'initialized'
                    },
                    wpSecurity: wpSecurity.getSecurityStatus()
                };
            }
        };
        
    } catch (error) {
        console.error('❌ Security framework initialization failed:', error.message);
        throw error;
    }
}

module.exports = {
    // Main initialization
    initializeSecurity,
    
    // Individual components
    getCredentialManager,
    getCommandExecutor,
    getBrowserManager,
    getInputValidator,
    getWordPressSecurityHelpers,
    
    // Component classes (for advanced usage)
    SecureCredentialManager: require('./SecureCredentialManager').SecureCredentialManager,
    SecureCommandExecutor: require('./SecureCommandExecutor').SecureCommandExecutor,
    SecureBrowserManager: require('./SecureBrowserManager').SecureBrowserManager,
    SecureInputValidator: require('./SecureInputValidator').SecureInputValidator,
    WordPressSecurityHelpers: require('./WordPressSecurityHelpers').WordPressSecurityHelpers
};