<?php
/**
 * @wordpress-plugin
 * Plugin Name:       Replyan AI – AI Chatbot, Customer Support & AI Agents
 * Plugin URI:        https://replyanai.online
 * Description:       Adds a configurable AI chatbot to the WordPress frontend with admin settings.
 * Version:           1.1.5
 * Requires at least: 6.0
 * Requires PHP:      7.4
 * Author:            Stephen Anino
 * Author URI:        https://replyanai.online
 * License:           GPL-2.0-or-later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * GitHub Plugin URI: https://github.com/aninostephen/replyan-ai
 * Text Domain:       replyan-ai
 * Domain Path:       /languages
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

define( 'REPLYAN_AI_VERSION', '1.1.5' );
define( 'REPLYAN_AI_DB_VERSION', '1.7' );
define( 'REPLYAN_AI_FILE', __FILE__ );
define( 'REPLYAN_AI_DIR', plugin_dir_path( __FILE__ ) );
define( 'REPLYAN_AI_URL', plugin_dir_url( __FILE__ ) );
define( 'REPLYAN_AI_SAAS_URL', 'https://api.replyanai.online' );

require_once REPLYAN_AI_DIR . 'includes/class-replyan-ai-settings.php';
require_once REPLYAN_AI_DIR . 'includes/class-replyan-ai-license.php';
require_once REPLYAN_AI_DIR . 'includes/class-replyan-ai-assets.php';
require_once REPLYAN_AI_DIR . 'includes/class-replyan-ai-admin.php';
require_once REPLYAN_AI_DIR . 'includes/class-replyan-ai-frontend.php';
require_once REPLYAN_AI_DIR . 'includes/class-replyan-ai-ajax.php';
require_once REPLYAN_AI_DIR . 'includes/class-replyan-ai-dashboard.php';
require_once REPLYAN_AI_DIR . 'includes/class-replyan-ai-db.php';
require_once REPLYAN_AI_DIR . 'includes/class-replyan-ai-upload.php';
require_once REPLYAN_AI_DIR . 'includes/Enums/AIProviderEndpoint.php';
require_once REPLYAN_AI_DIR . 'includes/AI-Models/class-replyan-ai-openai.php';
require_once REPLYAN_AI_DIR . 'includes/AI-Models/class-replyan-ai-anthropic.php';
require_once REPLYAN_AI_DIR . 'includes/AI-Models/class-replyan-ai-gemini.php';
require_once REPLYAN_AI_DIR . 'includes/AI-Models/class-replyan-ai-openrouter.php';
require_once REPLYAN_AI_DIR . 'includes/utils/logs.php';
require_once REPLYAN_AI_DIR . 'includes/utils/helper.php';
require_once REPLYAN_AI_DIR . 'includes/intent/class-replyan-ai-intent-engine.php';
require_once REPLYAN_AI_DIR . 'includes/context-awareness/class-replyan-ai-context-awareness.php';
require_once REPLYAN_AI_DIR . 'includes/class-replyan-ai-optimization-instruction.php';
require_once REPLYAN_AI_DIR . 'includes/class-replyan-ai-plugin.php';

register_activation_hook( __FILE__, 'replyan_ai_activate' );
register_deactivation_hook( __FILE__, 'replyan_ai_deactivate' );

function replyan_ai_activate(): void {
	Replyan_AI_Settings::activate();
	Replyan_AI_DB::create_tables();

	if ( class_exists( 'Replyan_AI_Context_Awareness_DB' ) ) {
		Replyan_AI_Context_Awareness_DB::create_table();
	}

	require_once REPLYAN_AI_DIR . 'includes/premium/index.php';
	replyan_ai_premium_create_tables();

	if ( ! wp_next_scheduled( 'replyan_ai_daily_license_check' ) ) {
		wp_schedule_event( time(), 'daily', 'replyan_ai_daily_license_check' );
	}
}

function replyan_ai_deactivate(): void {
	wp_clear_scheduled_hook( 'replyan_ai_daily_license_check' );
}

Replyan_AI_Plugin::instance();

