<?php

if (! defined('ABSPATH')) {
    exit;
} class PufferGo_Admin_Loader
{
    private $plugin_dir;

    private static $instance = null;

    public static function get_instance($plugin_dir = '')
    {
        if (self::$instance === null) {
            self::$instance = new self($plugin_dir);
        }

return self::$instance;
    }

    private function __construct($plugin_dir)
    {
        $this->plugin_dir = $plugin_dir;
        $this->init();
    }

    private function init()
    {
        require_once $this->plugin_dir . '/php/dashboard.php';
        require_once $this->plugin_dir . '/php/settings.php';
        require_once $this->plugin_dir . '/php/class-deactivation-survey.php';
        require_once $this->plugin_dir . '/php/class-admin-notice-guard.php';
        PufferGo_Admin_Notice_Guard::init();
        require_once $this->plugin_dir . '/php/class-fse-theme-notice.php';
        PufferGo_Fse_Theme_Notice::init();
        require_once $this->plugin_dir . '/php/class-puffergo-homepage-guard.php';
        PufferGo_Homepage_Guard::init();
        require_once $this->plugin_dir . '/php/pattern-generator.php';
        require_once $this->plugin_dir . '/php/class-puffergo-admin-menu.php';
        add_action('admin_menu', array('PufferGo_Admin_Menu', 'register_menus'), 9);
        add_action('admin_enqueue_scripts', array($this, 'load_admin_tailwind'), 9);
    }

    public function load_admin_tailwind()
    {
        $screen = get_current_screen();

        if (! $screen) {
            return;
        } $is_plugin_page = ($screen->id === 'puffergo_page_puffergo-ai-site-builder' || $screen->id === 'puffergo_page_puffergo-settings' || $screen->id === 'puffergo_page_puffergo-site-profile' || in_array($screen->base, array('post', 'post-new'), true) || strpos($screen->id, 'puffergo') !== false);

        if (! $is_plugin_page) {
            return;
        } $profile = get_option('puffergo_site_profile', array());
        $site_language = ! empty($profile['language']) ? $profile['language'] : 'en';
        echo '<script>window.puffergoConfig=window.puffergoConfig||{};window.puffergoConfig.siteLanguage=' . wp_json_encode($site_language) . ';</script>' . "\n";
        $plugin_url = plugin_dir_url($this->plugin_dir . '/puffergo.php');
        $tailwind_css_file = $this->plugin_dir . '/build/blocks/ai-admin-app/index.css';

        if (file_exists($tailwind_css_file)) {
            wp_enqueue_style('puffergo-admin-tailwind', $plugin_url . 'build/blocks/ai-admin-app/index.css', array(), filemtime($tailwind_css_file));
        }
    }
}
