<?php
if (!defined('ABSPATH')) {
    die('You are not allowed to call this page directly.');
}

class FormShieldAdvancedProtection {
    private static $instance = null;
    private $mouse_movements = 0;
    private $keyboard_events = 0;
    private $form_start_time = 0;
    
    public static function get_instance() {
        if (null === self::$instance) {
            self::$instance = new self();
        }
        return self::$instance;
    }
    
    private function __construct() {
        add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
        add_action('wp_footer', array($this, 'add_protection_script'));
    }
    
    public function enqueue_scripts() {
        wp_enqueue_script(
            'formshield-protection',
            form_shield()->plugin_url . 'js/formshield-protection.js',
            array('jquery'),
            FORMSHIELD_VERSION,
            true
        );
    }
    
    public function add_protection_script() {
        // Enqueue advanced protection script
        wp_enqueue_script( 'formshield-protection-advanced', plugins_url( 'js/advanced-protection.js', dirname(__FILE__) ), array('jquery'), FORMSHIELD_VERSION, true );
        
        // Localize script with AJAX data
        wp_localize_script( 'formshield-protection-advanced', 'formshieldData', array(
            'ajaxurl' => admin_url('admin-ajax.php'),
            'nonce' => wp_create_nonce('formshield_validation')
        ) );
    }
}

// Инициализираме класа
FormShieldAdvancedProtection::get_instance();
