<?php
namespace AIAutoTool\Features\ImageScanner;

if ( ! defined( 'ABSPATH' ) ) exit; // Thoát nếu truy cập trực tiếp

/**
 * AI Auto Tool - Image Scanner Feature
 * 
 * @package AIAutoTool\Features\ImageScanner
 * @namespace AIAutoTool\Features\ImageScanner
 */

// Include the full Image Scanner implementation with all features
require_once dirname(__FILE__) . '/images.php';

// Create namespace wrapper
if (!class_exists('AIAutoTool\\Features\\ImageScanner\\ImageScanner')) {
    class ImageScanner extends \AIAutotool_Image404Scanner {
        public $active_option_name = 'Aiautotool_Image404Scanner_active';
        public $icon = '<i class="fa-solid fa-image"></i>';
        
        public function __construct() {
            parent::__construct();
        }
        
        /**
         * Render feature for integrations page
         */
        public function render_feature() {
            // Load feature descriptions
            require_once plugin_dir_path(dirname(__FILE__)) . 'lib/feature-descriptions.php';
            
            $description = \AiAutoTool_Feature_Descriptions::get('thumb_fix');
            if (!$description) {
                $description = __('Automatically scan and fix 404 images in your posts. Find broken images and remove them to improve site quality.', 'ai-auto-tool');
            }
            
            $autoToolBox = new \AutoToolBox(
                esc_html__('Image 404 Scanner & Fixer', 'ai-auto-tool'),
                $description,
                "https://doc.aiautotool.com/features/image-404-scanner",
                $this->active_option_name,
                $this->active,
                plugins_url('../../images/logo.svg', __FILE__)
            );
            
            echo $autoToolBox->generateHTML();
        }
        
        /**
         * Render tab setting - Already inherited from parent class AIAutotool_Image404Scanner
         * But we override to ensure it works correctly
         */
        public function render_tab_setting() {
            if ($this->active == 'true') {
                echo '<button href="#tab-image404-setting" class="nav-tab sotab"><i class="fa-solid fa-image"></i> ' . esc_html__('Image 404 Scanner', 'ai-auto-tool') . '</button>';
            }
        }
        
        /**
         * Render settings page - Already inherited from parent class AIAutotool_Image404Scanner
         * This method is already implemented in parent class, no need to override
         */
    }
}
