<?php
if (!defined('ABSPATH')) {
    exit;
}

class Aysa_Monitoring_Admin_Controller {
    private $admin;

    public function __construct($admin) {
        $this->admin = $admin;
    }

    public function register_hooks() {
        add_action('wp_ajax_aysa_monitoring_get_associations', array($this->admin, 'handle_monitoring_get_associations'));
        add_action('wp_ajax_aysa_monitoring_get_project_id', array($this->admin, 'handle_monitoring_get_project_id'));
        add_action('wp_ajax_aysa_monitoring_get_context', array($this->admin, 'handle_monitoring_get_context'));
        add_action('wp_ajax_aysa_monitoring_rank_plan', array($this->admin, 'handle_monitoring_rank_plan'));
        add_action('wp_ajax_aysa_monitoring_keywords_overview', array($this->admin, 'handle_monitoring_keywords_overview'));
        add_action('wp_ajax_aysa_monitoring_keywords_async_start', array($this->admin, 'handle_monitoring_keywords_async_start'));
        add_action('wp_ajax_aysa_monitoring_keywords_async_status', array($this->admin, 'handle_monitoring_keywords_async_status'));
        add_action('wp_ajax_aysa_monitoring_rank_latest_from_db', array($this->admin, 'handle_monitoring_rank_latest_from_db'));
        add_action('wp_ajax_aysa_monitoring_rank_refresh_due', array($this->admin, 'handle_monitoring_rank_refresh_due'));
        add_action('wp_ajax_aysa_monitoring_rank_refresh_start_background', array($this->admin, 'handle_monitoring_rank_refresh_start_background'));
        add_action('wp_ajax_aysa_monitoring_rank_refresh_status', array($this->admin, 'handle_monitoring_rank_refresh_status'));
        add_action('wp_ajax_aysa_monitoring_conversation', array($this->admin, 'handle_monitoring_conversation'));
        add_action('wp_ajax_aysa_monitoring_get_ai_overview', array($this->admin, 'handle_monitoring_get_ai_overview'));
        add_action('wp_ajax_aysa_monitoring_refresh_ai_snapshot', array($this->admin, 'handle_monitoring_refresh_ai_snapshot'));
        add_action('wp_ajax_aysa_monitoring_start_ai_refresh', array($this->admin, 'handle_monitoring_start_ai_refresh'));
        add_action('wp_ajax_aysa_monitoring_get_ai_refresh_status', array($this->admin, 'handle_monitoring_get_ai_refresh_status'));
        add_action('wp_ajax_aysa_monitoring_get_ai_snapshot_history', array($this->admin, 'handle_monitoring_get_ai_snapshot_history'));
        add_action('wp_ajax_aysa_monitoring_get_ai_snapshot_detail', array($this->admin, 'handle_monitoring_get_ai_snapshot_detail'));
        add_action('wp_ajax_aysa_monitoring_ai_async_start', array($this->admin, 'handle_monitoring_ai_async_start'));
        add_action('wp_ajax_aysa_monitoring_ai_async_status', array($this->admin, 'handle_monitoring_ai_async_status'));
        add_action('wp_ajax_aysa_monitoring_save_ai_query_pack', array($this->admin, 'handle_monitoring_save_ai_query_pack'));
        add_action('aysa_monitoring_ai_refresh_event', array($this->admin, 'run_monitoring_ai_refresh_event'), 10, 1);
        add_action('aysa_monitoring_ai_async_event', array($this->admin, 'run_monitoring_ai_async_event'), 10, 1);
        add_action('aysa_monitoring_keywords_async_event', array($this->admin, 'run_monitoring_keywords_async_event'), 10, 1);
        add_action('aysa_monitoring_rank_refresh_background_event', array($this->admin, 'handle_monitoring_rank_refresh_background_event'), 10, 1);
        add_action('aysa_monitoring_rank_refresh_cron_tick', array($this->admin, 'handle_monitoring_rank_refresh_background_event'), 10, 1);
        add_action('admin_init', array($this->admin, 'aysa_monitoring_history_maybe_create_table'));
        add_action('admin_init', array($this->admin, 'aysa_monitoring_ai_history_maybe_create_table'));
    }
}
