<?php

/**
 * The admin-specific functionality of the plugin.
 *
 * @link       https://ays-pro.com/
 * @since      1.0.0
 *
 * @package    Ays_Chatgpt_Assistant
 * @subpackage Ays_Chatgpt_Assistant/admin
 */

/**
 * The admin-specific functionality of the plugin.
 *
 * Defines the plugin name, version, and two examples hooks for how to
 * enqueue the admin-specific stylesheet and JavaScript.
 *
 * @package    Ays_Chatgpt_Assistant
 * @subpackage Ays_Chatgpt_Assistant/admin
 * @author     Ays_ChatGPT Assistant Team <info@ays-pro.com>
 */
class Chatgpt_Assistant_Admin {

	/**
	 * The ID of this plugin.
	 *
	 * @since    1.0.0
	 * @access   private
	 * @var      string    $plugin_name    The ID of this plugin.
	 */
	private $plugin_name;

	/**
	 * The version of this plugin.
	 *
	 * @since    1.0.0
	 * @access   private
	 * @var      string    $version    The current version of this plugin.
	 */
	private $version;

	/**
	 * @var Chatgpt_Assistant_DB_Actions
	 */

     
	/**
	 * DB properties of this plugin.
    */
	private $dashboard_chat_db_name;
	private $front_chat_db_name;
	private $settings_db_name;
	private $general_settings_db_name;
	private $data_db_name;
	private $db_obj;
    private $embedding_db_name;
	private $capability;
         
	/**
	 * Set options of this plugin.
    */
    private $api_key;
	private $chatgpt_assistant_full_screen_mode;
	private $chatbox_position;
    private $chatbox_position_mobile;
    private $chatbox_enable_position_mobile;
	private $chatbox_icon_position;
    private $chatbox_icon_position_mobile;
    private $chatbox_enable_icon_position_mobile;
    private $chatgpt_assistant_show_dashboard_chat;
    private $chatgpt_assistant_show_dashboard_chat_mobile;
	private $chatgpt_assistant_chat_icon_size;
    private $chatgpt_assistant_chat_icon_size_mobile;
    private $chatgpt_assistant_enable_chat_icon_size_mobile;
	private $chatgpt_assistant_chat_width;
	private $chatgpt_assistant_chat_width_format;
    private $chatgpt_assistant_chat_width_mobile;
    private $chatgpt_assistant_chat_width_mobile_format;
    private $chatgpt_assistant_enable_chat_width_mobile;
	private $chatgpt_assistant_chat_height;
	private $chatgpt_assistant_chat_height_format;
    private $chatgpt_assistant_chat_height_mobile;
    private $chatgpt_assistant_chat_height_mobile_format;
    private $chatgpt_assistant_enable_chat_height_mobile;
	private $chatgpt_assistant_auto_opening_chatbox;
	private $chatgpt_assistant_auto_opening_chatbox_delay;
    private $chatgpt_assistant_auto_opening_chatbox_mobile;
	private $chatgpt_assistant_regenerate_response;
	private $chatgpt_assistant_message_placeholder;
	private $chatgpt_assistant_chatbot_name;
	private $chatgpt_assistant_compliance_text;
	private $chatgpt_assistant_chat_model;
	private $chatgpt_assistant_chat_temprature;
	private $chatgpt_assistant_chat_top_p;
	private $chatgpt_assistant_max_tokens;
	private $chatgpt_assistant_frequency_penalty;
	private $chatgpt_assistant_presence_penalty;
	private $chatgpt_assistant_best_of;
	private $chatgpt_assistant_context;
	private $chatgpt_assistant_profession;
	private $chatgpt_assistant_tone;
	private $chatgpt_assistant_language;
	private $chatgpt_assistant_name;
	private $chatgpt_assistant_greeting_message;
	private $chatgpt_assistant_greeting_message_default_text;
	private $chatgpt_assistant_greeting_message_text;
	private $chatbox_mode;
    private $chatbox_theme;
    private $chat_icon;
    private $chat_avatar;
	private $user_profile_picture;
    private $chatgpt_assistant_enable_rate_chat;
    private $chatgpt_assistant_rate_chat_text;
	private $chatgpt_assistant_rate_chat_like;
	private $chatgpt_assistant_rate_chat_dislike;

	private $chatgpt_assistant_chatbox_background_color;
	private $chatgpt_assistant_chatbox_header_text_color;
	private $chatgpt_assistant_chatbox_header_text_letter_spacing;
	private $chatgpt_assistant_chatbox_header_text_font_size;
	private $chatgpt_assistant_end_chat_button_bg_color;
	private $chatgpt_assistant_end_chat_button_text_color;
	private $chatgpt_assistant_end_chat_button_text_font_size;
	private $chatgpt_assistant_end_chat_button_text_letter_spacing;
	private $chatgpt_assistant_message_font_size;
    private $chatgpt_assistant_message_font_size_mobile;
    private $chatgpt_assistant_enable_message_font_size_mobile;
	private $chatgpt_assistant_message_letter_spacing;
	private $chatgpt_assistant_send_button_font_size;
	private $chatgpt_assistant_send_button_padding;
	private $chatgpt_assistant_message_spacing;
    private $chatgpt_assistant_message_spacing_mobile;
    private $chatgpt_assistant_enable_message_spacing_mobile;
	private $chatgpt_assistant_message_border_radius;
    private $chatgpt_assistant_message_border_radius_mobile;
    private $chatgpt_assistant_enable_message_border_radius_mobile;
	private $chatgpt_assistant_chatbot_border_radius;
    private $chatgpt_assistant_chatbot_border_radius_mobile;
    private $chatgpt_assistant_enable_chatbot_border_radius_mobile;
	private $chatgpt_assistant_send_message_icon;
	private $chatgpt_assistant_send_message_icon_text;
	private $chatgpt_assistant_send_message_text;
	private $message_bg_color;
	private $message_text_color;
	private $response_text_color;
	private $response_icons_color;
	private $response_bg_color;
    private $rates_table_obj;
    public $settings_obj;
	public $general_settings_obj;
	public $front_settings_obj;
    private $embedding_settings_obj;

	/**
	 * Initialize the class and set its properties.
	 *
	 * @since    1.0.0
	 * @param      string    $plugin_name       The name of this plugin.
	 * @param      string    $version    The version of this plugin.
	 */
	public function __construct( $plugin_name, $version ) {
        global $wpdb;
		$this->plugin_name = $plugin_name;
		$this->version = $version;

        $this->dashboard_chat_db_name = $wpdb->prefix . CHATGPT_ASSISTANT_DB_PREFIX . 'dashboard_settings';
		$this->front_chat_db_name = $wpdb->prefix . CHATGPT_ASSISTANT_DB_PREFIX . 'front_settings';
		$this->settings_db_name = $wpdb->prefix . CHATGPT_ASSISTANT_DB_PREFIX . 'settings';
		$this->general_settings_db_name = $wpdb->prefix . CHATGPT_ASSISTANT_DB_PREFIX . 'general_settings';
        $this->embedding_db_name = $wpdb->prefix . CHATGPT_ASSISTANT_DB_PREFIX . 'embedding_settings';
		$this->data_db_name = $wpdb->prefix . CHATGPT_ASSISTANT_DB_PREFIX . 'data';

        $this->db_obj = new Chatgpt_Assistant_DB_Actions( $this->plugin_name, $this->data_db_name );
	}

	/**
	 * Register the stylesheets for the admin area.
	 *
	 * @since    1.0.0
	 */
	public function enqueue_styles($hook_suffix) {
        wp_enqueue_style($this->plugin_name . '-admin', plugin_dir_url(__FILE__) . 'css/admin.css', array(), $this->version, 'all');
		wp_enqueue_style( $this->plugin_name . '-chatbox', plugin_dir_url( __FILE__ ) . 'css/chatgpt-assistant-chat-bot.css', array(), $this->version . time(), 'all' );
		if (false === strpos($hook_suffix, $this->plugin_name))
            return;

        wp_enqueue_style( $this->plugin_name . '-font-awesome', plugin_dir_url(__FILE__) .  'css/chatgpt-assistant-font-awesome.min.css', array(), $this->version, 'all');
		wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/chatgpt-assistant-admin.css', array(), $this->version . time(), 'all' );
        wp_enqueue_style( $this->plugin_name . "-pro-features", plugin_dir_url( __FILE__ ) . 'css/chatgpt-assistant-pro-features.css', array(), time(), 'all' );
		
		if ( false !== strpos($hook_suffix, $this->plugin_name) || false !== strpos( $hook_suffix, 'embedding' ) || strpos($hook_suffix, $this->plugin_name.'-front-chat') !== false || false !== strpos( $hook_suffix, 'logs' ) || false !== strpos( $hook_suffix, 'rates' )) {
			wp_enqueue_style( $this->plugin_name . '-select2', plugin_dir_url(__FILE__) .  'css/ays-select2.min.css', array(), $this->version, 'all');
			wp_enqueue_style( $this->plugin_name . '-bootstrap', plugin_dir_url(__FILE__) . 'css/bootstrap.min.css', array(), $this->version, 'all');
		}

        if ( false !== strpos( $hook_suffix, 'image-generator' ) ) {
			wp_enqueue_script( $this->plugin_name . '-sweetalert-js', plugin_dir_url( __FILE__ ) . 'js/ays-chatgpt-assistant-sweetalert2.all.min.js', array('jquery'), $this->version, true );
			wp_enqueue_script( $this->plugin_name . '-image-generator', plugin_dir_url( __FILE__ ) . 'js/chatgpt-assistant-admin-image-generator.js', array( 'jquery' ), $this->version, true );
		}
		
		// wp_enqueue_style( $this->plugin_name . '-sale-banner', plugin_dir_url(__FILE__) . 'css/chatgpt-banner.css', array(), $this->version, 'all');
		wp_enqueue_style( $this->plugin_name . '-banner', plugin_dir_url( __FILE__ ) . 'css/banner.css', array(), $this->version, 'all' );

	}

	/**
	 * Register the JavaScript for the admin area.
	 *
	 * @since    1.0.0
	 */
	public function enqueue_scripts($hook_suffix) {

        if (false !== strpos($hook_suffix, "plugins.php")){
            wp_enqueue_script( $this->plugin_name . '-sweetalert-js', plugin_dir_url( __FILE__ ) . 'js/ays-chatgpt-assistant-sweetalert2.all.min.js', array('jquery'), $this->version, true );
            wp_enqueue_script( $this->plugin_name . '-admin', plugin_dir_url(__FILE__) . 'js/admin.js', array( 'jquery' ), $this->version, true );
            wp_localize_script( $this->plugin_name . '-admin', 'AysChatGptAdmin', array( 
            	'ajaxUrl' => admin_url( 'admin-ajax.php' ),
                'nonce'   => wp_create_nonce( 'ajax-nonce' ),
            ) );
        }

		wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/chatgpt-assistant-admin.js', array( 'jquery' ), $this->version, true );
        wp_enqueue_script( $this->plugin_name . '-main-functions', CHATGPT_ASSISTANT_ASSETS_URL . '/js/chatgpt-assistant-main-functions.js',  array( 'jquery' ), $this->version, false );
        wp_enqueue_script( $this->plugin_name . '-autosize', plugin_dir_url( __FILE__ ) . '/js/chatgpt-assistant-autosize.js', array( 'jquery' ), $this->version, false );
		if (false === strpos($hook_suffix, $this->plugin_name)) return;
        
        wp_enqueue_script( $this->plugin_name . '-sweetalert-js', plugin_dir_url( __FILE__ ) . 'js/ays-chatgpt-assistant-sweetalert2.all.min.js', array('jquery'), $this->version, true );
		wp_enqueue_script( $this->plugin_name . "-general-js", plugin_dir_url( __FILE__ ) . 'js/chatgpt-assistant-admin-general.js', array( 'jquery' ), $this->version, true );
        wp_localize_script( $this->plugin_name . "-general-js", 'aysChatGptAssistantGeneral', array(
            'ajaxUrl' 						=> admin_url( 'admin-ajax.php' ),
            'nonce'   						=> wp_create_nonce( 'ajax-nonce' ),
			'addImage'               		=> __( 'Add Image', 'ays-chatgpt-assistant' ),
            'editImage'              		=> __( 'Edit Image', 'ays-chatgpt-assistant' ),
            'removeImage'            		=> __( 'Remove Image', 'ays-chatgpt-assistant' ),
            'activated'              		=> __( "Activated", "ays-chatgpt-assistant" ),
            'errorMsg'               		=> __( "Error", "ays-chatgpt-assistant" ),
            'loadResource'           		=> __( "Can't load resource.", "ays-chatgpt-assistant" ),
            'somethingWentWrong'     		=> __( "Maybe something went wrong.", "ays-chatgpt-assistant" ),
            'successCopyCoupon'     		=> esc_html__( "Coupon code copied!", 'ays-chatgpt-assistant' ),
            'failedCopyCoupon'       		=> esc_html__( "Failed to copy coupon code", 'ays-chatgpt-assistant' ),
            'translations' => array(
                'chatGreetingMessage'    	=> __( 'Hello! I\'m an AI Assistant, and I\'m here to assist you with anything you need. How can I help you today?', "ays-chatgpt-assistant" ),
                'errorOpenAi'            	=> __('Error: Please Connect to OpenAI.','ays-chatgpt-assistant'),
                'successfullyEmbeded'    	=> __('Successfully embedded!','ays-chatgpt-assistant'),
                'embeddingFailed'        	=> __('Embedding failed!','ays-chatgpt-assistant'),
                'errorWords'             	=> __('Error: You are not allowed to add more than 5000 words.','ays-chatgpt-assistant'),
                'errorEmptyText'         	=> __('Error: Make sure to add text for embedding.','ays-chatgpt-assistant'),
                'errorConnectingPinecone'	=> __('Error connecting to pinecone. Check your API key and index.','ays-chatgpt-assistant'),
                'pineconeDbEmpty'        	=> __('Pinecone database is not empty. You are not allowed to connect.','ays-chatgpt-assistant'),
                'connectedPinecone'      	=> __('Successfully connected to pinecone.','ays-chatgpt-assistant'),
            )
		) );

		$chatgpt_banner_date = $this->ays_chatgpt_update_banner_time();
		if ( false !== strpos($hook_suffix, $this->plugin_name) || strpos($hook_suffix, $this->plugin_name.'-front-chat') !== false || false !== strpos( $hook_suffix, 'logs' ) || strpos($hook_suffix, $this->plugin_name.'-rates') !== false ) {
			wp_enqueue_script( $this->plugin_name . "-popper", plugin_dir_url(__FILE__) . 'js/popper.min.js', array( 'jquery' ), $this->version, true );
			wp_enqueue_script( $this->plugin_name . "-bootstrap", plugin_dir_url(__FILE__) . 'js/bootstrap.min.js', array( 'jquery' ), $this->version, true );
			wp_enqueue_script( $this->plugin_name . '-select2js', plugin_dir_url( __FILE__ ) . 'js/ays-select2.min.js', array('jquery'), $this->version, true);
			wp_enqueue_script( $this->plugin_name . '-settings', plugin_dir_url( __FILE__ ) . 'js/chatgpt-assistant-admin-settings.js', array( 'jquery' ), $this->version, true );

            wp_enqueue_media();

			wp_localize_script( $this->plugin_name . '-settings', 'aysChatGptAssistantAdminSettings', array(
                'ajaxUrl'                   => admin_url( 'admin-ajax.php' ),
                'nonce'                     => wp_create_nonce( 'ajax-nonce' ),
				'selectUserRoles'           => __( 'Select user roles', "ays-chatgpt-assistant" ),
				'delete'                    => __( 'Delete', "ays-chatgpt-assistant" ),
				'selectQuestionDefaultType' => __( 'Select question default type', "ays-chatgpt-assistant" ),
				'yes'                       => __( 'Yes', "ays-chatgpt-assistant" ),
				'cancel'                    => __( 'Cancel', "ays-chatgpt-assistant" ),
				'errorMsg'                  => __( 'Error', "ays-chatgpt-assistant" ),
                'somethingWentWrong'        => __( "Maybe something went wrong.", "ays-chatgpt-assistant" ),      
                'successCopyCoupon'         => esc_html__( "Coupon code copied!", 'ays-chatgpt-assistant' ),
                'failedCopyCoupon'          => esc_html__( "Failed to copy coupon code", 'ays-chatgpt-assistant' ),
				'failed'                    => __( 'Failed', "ays-chatgpt-assistant" ),
				'selectPage'                => __( 'Select page', "ays-chatgpt-assistant" ),
				'selectPostType'            => __( 'Select post type', "ays-chatgpt-assistant" ),
				'copied'                    => __( 'Copied!', "ays-chatgpt-assistant"),
				'clickForCopy'              => __( 'Click to copy', "ays-chatgpt-assistant"),
				'selectForm'                => __( 'Select form', "ays-chatgpt-assistant"),
				'chatgptBannerDate'         => $chatgpt_banner_date,
			) );
		}
		wp_localize_script( $this->plugin_name, 'aysChatGptAssistantAdminSettings', array(
			'chatgptBannerDate' => $chatgpt_banner_date,
		) );
        if ( false !== strpos( $hook_suffix, 'embedding' ) ) {
			
			wp_enqueue_script( $this->plugin_name . '-embedding', plugin_dir_url( __FILE__ ) . 'js/chatgpt-assistant-admin-embedding.js', array( 'jquery' ), $this->version, true );
		}
	}

    /**
	 * De-register JavaScript files for the admin area.
	 *
	 * @since    1.0.0
	 */
	public function disable_scripts($hook_suffix) {
        if (false !== strpos($hook_suffix, $this->plugin_name)) {
            if (is_plugin_active('ai-engine/ai-engine.php')) {
                wp_deregister_script('mwai');
                wp_deregister_script('mwai-vendor');
                wp_dequeue_script('mwai');
                wp_dequeue_script('mwai-vendor');
            }
            
            if (is_plugin_active('html5-video-player/html5-video-player.php')) {
                wp_dequeue_style('h5vp-admin');
                wp_dequeue_style('fs_common');
            }
            
            if (is_plugin_active('panorama/panorama.php')) {
                wp_dequeue_style('bppiv_admin_custom_css');
                wp_dequeue_style('bppiv-custom-style');
            }
            
            if (is_plugin_active('wp-social/wp-social.php')) {
                wp_dequeue_style('wp_social_select2_css');
                wp_deregister_script('wp_social_select2_js');
                wp_dequeue_script('wp_social_select2_js');
            }

            if (is_plugin_active('real-media-library-lite/index.php')) {
                wp_dequeue_style('real-media-library-lite-rml');
            }

            if (is_plugin_active('happyforms/happyforms.php')) {
                wp_dequeue_style('happyforms-admin');
            }

            if (is_plugin_active('ultimate-viral-quiz/index.php')) {
                wp_dequeue_style('select2');
                wp_dequeue_style('dataTables');
                
                wp_dequeue_script('sweetalert');
                wp_dequeue_script('select2');
                wp_dequeue_script('dataTables');
            }

            if (is_plugin_active('forms-by-made-it/madeit-form.php')) {
                wp_dequeue_style('madeit-form-admin-style');
            }

            if (is_plugin_active('search-replace-for-block-editor/search-replace-for-block-editor.php')) {
                wp_deregister_script('search-replace-for-block-editor');
                wp_dequeue_script('search-replace-for-block-editor');
            }

            // Theme | Pixel Ebook Store
            wp_dequeue_style('pixel-ebook-store-free-demo-content-style');

            // Theme | Interactive Education
            wp_dequeue_style('interactive-education-free-demo-content-style');

            // Theme | Phlox 2.17.6
            wp_dequeue_style('auxin-admin-style');

            // Theme | Mavix Education 1.0
            wp_dequeue_style('mavix-education-admin-style');

            // Theme | RT Education School 1.1.9
            wp_dequeue_style('rt-education-school-custom-admin-style');
            wp_dequeue_style('rt-education-school-custom-admin-notice-style');

        }
    }

	/**
     * Register the administration menu for this plugin into the WordPress Dashboard menu.
     *
     * @since    1.0.0
     */
    public function add_plugin_admin_menu(){
        global $wpdb;

        $this->capability = 'manage_options';

        add_menu_page(
            __('ChatGPT Assistant', 'ays-chatgpt-assistant'),
			__('ChatGPT Assistant', 'ays-chatgpt-assistant'),
            $this->capability,
            $this->plugin_name,
			array($this, 'display_plugin_main_page'),
            CHATGPT_ASSISTANT_ADMIN_URL . '/images/icons/chatgpt-icon-menu-bw.svg',
            '6.224'
        );

        $this->general_settings_obj = new ChatGPT_Assistant_General_Settings_DB_Actions( $this->plugin_name , $this->general_settings_db_name );
        $this->settings_obj = new ChatGPT_Assistant_Settings_DB_Actions( $this->plugin_name , $this->settings_db_name );
    }

	public function add_plugin_settings_submenu(){
		$hook_settings = add_submenu_page( $this->plugin_name,
			__('Settings','ays-chatgpt-assistant'),
			__('Settings', 'ays-chatgpt-assistant'),
			'manage_options',
			$this->plugin_name,
			array($this, 'display_plugin_main_page')
		);

        $this->general_settings_obj = new ChatGPT_Assistant_General_Settings_DB_Actions( $this->plugin_name , $this->general_settings_db_name );
        $this->settings_obj = new ChatGPT_Assistant_Settings_DB_Actions( $this->plugin_name , $this->settings_db_name );
	}

	// Front settings
	public function add_plugin_front_chat_submenu(){
		$this->capability = 'manage_options';

		$hook_settings = add_submenu_page( $this->plugin_name,
			__('Front chat', 'ays-chatgpt-assistant'),
			__('Front chat', 'ays-chatgpt-assistant'),
			$this->capability,
			$this->plugin_name . '-front-chat',
			array($this, 'display_plugin_front_chat_page')
		);

        $this->general_settings_obj = new ChatGPT_Assistant_General_Settings_DB_Actions( $this->plugin_name , $this->general_settings_db_name );
        $this->settings_obj = new ChatGPT_Assistant_Settings_DB_Actions( $this->plugin_name , $this->settings_db_name );
		$this->front_settings_obj = new ChatGPT_Assistant_Front_Chat_DB_Actions( $this->plugin_name , $this->front_chat_db_name);
	}

    // Embedding settings 
	public function add_plugin_embedding_submenu(){
		$this->capability = 'manage_options';
        $menu_item =  __('Embeddings', 'ays-chatgpt-assistant') . '<span class="ays_menu_badge ays_results_bage">' .  __('New', 'ays-chatgpt-assistant') . '</span>';

		$hook_settings = add_submenu_page( $this->plugin_name,
			__('Embeddings', 'ays-chatgpt-assistant'),
			$menu_item,
			$this->capability,
			$this->plugin_name . '-embedding',
			array($this, 'display_plugin_embedding_page')
		);
        $this->embedding_settings_obj = new ChatGPT_Assistant_Embedding_DB_Actions( $this->plugin_name , $this->embedding_db_name);
	}

    public function add_plugin_logs_submenu(){
		$this->capability = 'manage_options';

		$hook_settings = add_submenu_page( $this->plugin_name,
			__('Logs', 'ays-chatgpt-assistant'),
			__('Logs', 'ays-chatgpt-assistant'),
			$this->capability,
			$this->plugin_name . '-logs',
			array($this, 'display_plugin_logs_page')
		);
	}

    public function add_plugin_rates_submenu(){
		$this->capability = 'manage_options';

		$hook_settings = add_submenu_page( $this->plugin_name,
			__('Rates','ays-chatgpt-assistant'),
			__('Rates', 'ays-chatgpt-assistant'),
			$this->capability,
			$this->plugin_name . '-rates',
			array($this, 'display_plugin_rates_page')
		);

		$this->rates_table_obj = new ChatGPT_Assistant_Rates_List_Table( $this->plugin_name);
	}

    public function add_plugin_content_generator_submenu(){
		$this->capability = 'manage_options';

        $hook_pro_features = add_submenu_page(
            $this->plugin_name,
            __('Content Generator', 'ays-chatgpt-assistant'),
            __('Content Generator', 'ays-chatgpt-assistant'),
			$this->capability,
            $this->plugin_name . '-content-generator',
            array($this, 'display_plugin_content_generator_page')
        );
    }
    
    public function add_plugin_image_generator_submenu(){
		$this->capability = 'manage_options';

        $hook_pro_features = add_submenu_page(
            $this->plugin_name,
            __('Image Generator', 'ays-chatgpt-assistant'),
            __('Image Generator', 'ays-chatgpt-assistant'),
			$this->capability,
            $this->plugin_name . '-image-generator',
            array($this, 'display_plugin_image_generator_page')
        );

		$this->general_settings_obj = new ChatGPT_Assistant_General_Settings_DB_Actions( $this->plugin_name , $this->general_settings_db_name );
    }
    
    public function add_plugin_how_to_use_submenu(){
		$this->capability = 'manage_options';

        $hook_pro_features = add_submenu_page(
            $this->plugin_name,
            __('How to Use', 'ays-chatgpt-assistant'),
            __('How to Use', 'ays-chatgpt-assistant'),
			$this->capability,
            $this->plugin_name . '-how-to-use',
            array($this, 'display_plugin_how_to_use_page')
        );
    }
    
    public function add_plugin_general_settings_submenu(){
		$this->capability = 'manage_options';
		
        $hook_settings = add_submenu_page( $this->plugin_name,
			__('General Settings', 'ays-chatgpt-assistant'),
			__('General Settings', 'ays-chatgpt-assistant'),
			'manage_options',
			$this->plugin_name . '-general-settings',
			array($this, 'display_plugin_general_settings_page')
		);

        $this->general_settings_obj = new ChatGPT_Assistant_General_Settings_DB_Actions( $this->plugin_name , $this->general_settings_db_name );
	}

    public function add_plugin_our_products_submenu(){
		$this->capability = 'manage_options';

        $hook_pro_features = add_submenu_page(
            $this->plugin_name,
            __('Our Products', 'ays-chatgpt-assistant'),
            __('Our Products', 'ays-chatgpt-assistant'),
			$this->capability,
            $this->plugin_name . '-our-products',
            array($this, 'display_plugin_our_products_page')
        );
    }
    
    public function add_plugin_features_submenu(){
		$this->capability = 'manage_options';

        $hook_pro_features = add_submenu_page(
            $this->plugin_name,
            __('PRO Features', 'ays-chatgpt-assistant'),
            __('PRO Features', 'ays-chatgpt-assistant'),
			$this->capability,
            $this->plugin_name . '-features',
            array($this, 'display_plugin_features_page')
        );
    }
    
    public function add_plugin_gift_submenu(){
		$this->capability = 'manage_options';

        $hook_pro_features = add_submenu_page(
            $this->plugin_name,
            __('Get 50% discount', 'ays-chatgpt-assistant'),
            __('Get 50% discount', 'ays-chatgpt-assistant'),
			$this->capability,
            $this->plugin_name . '-gift',
            array($this, 'display_plugin_gift_page')
        );
    }

	public function display_plugin_main_page(){
		if (isset( $_POST[CHATGPT_ASSISTANT_NAME_PREFIX.'_save_bttn'] )) {
			$this->db_obj->store_data( $_POST );
		}
		include_once('partials/settings/chatgpt-assistant-settings.php');
    }

	public function display_plugin_settings_page(){
		include_once('partials/settings/chatgpt-assistant-settings.php');
	}

	public function display_plugin_front_chat_page(){
		include_once('partials/front-chat/chatgpt-assistant-front-chat-display.php');
	}

	public function display_plugin_embedding_page(){
		include_once('partials/embeddings/chatgpt-assistant-embedding-display.php');
	}

    public function display_plugin_logs_page(){
		include_once('partials/logs/chatgpt-assistant-logs-display.php');
	}

    public function display_plugin_rates_page(){
		include_once('partials/rates/chatgpt-assistant-rates-display.php');
	}

    public function display_plugin_how_to_use_page(){
        include_once('partials/chatgpt-assistant-data-display.php');
    }

    public function display_plugin_general_settings_page(){
		include_once('partials/general-settings/chatgpt-assistant-general-settings.php');
	}
    
    public function display_plugin_content_generator_page(){
		include_once('partials/content-generator/chatgpt-assistant-content-generator-display.php');
    }

    public function display_plugin_image_generator_page(){
		include_once('partials/image-generator/chatgpt-assistant-image-generator-display.php');
    }

    public function display_plugin_our_products_page(){
        include_once('partials/features/chatgpt-assistant-plugin-features-display.php');
    }
    
    public function display_plugin_features_page(){
        include_once('partials/features/chatgpt-assistant-features-display.php');
    }
    
    public function display_plugin_gift_page(){
        include_once('partials/gifts/chatgpt-assistant-gifts-display.php');
    }

	public function chatgpt_display_chat_icon(){
        $this->settings_obj = new ChatGPT_Assistant_Settings_DB_Actions( $this->plugin_name , $this->settings_db_name );
        include_once(plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/chatgpt-assistant-chatbox-display.php');
    }
    
	public function set_global_settings(){
        $data = $this->db_obj->get_data();
		$this->api_key = isset( $data['api_key'] ) && $data['api_key'] != '' ? esc_attr( $data['api_key'] ) : '';

		$options = ($this->settings_obj->get_setting('options') === false) ? array() : json_decode($this->settings_obj->get_setting('options'), true);
		

        // * GENERAL SETTINGS *
            // ===== Shortcode settings =====
                // Full Screen Mode
                $this->chatgpt_assistant_full_screen_mode = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'full_screen_mode'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'full_screen_mode'] == 'on' ) ? true : false; 
            // ===== General settings =====
                // Chatbot position
                $this->chatbox_position = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'position'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'position'] != '' ) ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'position']) : 'right';
                // Chatbot position Mobile
                if( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'position_mobile'] )){
                    $this->chatbox_position_mobile = ($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'position_mobile'] != '') ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'position_mobile']) : 'right';
                } else{
                    $this->chatbox_position_mobile = $this->chatbox_position ;
                }
                // Enable chatbox position mobile
                $this->chatbox_enable_position_mobile = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'enable_position_mobile'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'enable_position_mobile'] == 'on' ) ? true : false; 
                // Chatbot icon position
                $this->chatbox_icon_position = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'icon_position'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'icon_position'] != '' ) ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'icon_position']) : 'bottom-'.$this->chatbox_position;
                // Chatbot icon position mobile
                $this->chatbox_icon_position_mobile = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'icon_position_mobile'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'icon_position_mobile'] != '' ) ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'icon_position_mobile']) : 'bottom-'.$this->chatbox_position;
                // Enable chatbox position mobile
                $this->chatbox_enable_icon_position_mobile = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'enable_icon_position_mobile'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'enable_icon_position_mobile'] == 'on' ) ? true : false; 
                // Chat icon size
                $this->chatgpt_assistant_chat_icon_size = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_icon_size'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_icon_size'] != '' ) ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_icon_size']) : 70;
                // Chat icon size Mobile
                $this->chatgpt_assistant_chat_icon_size_mobile = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_icon_size_mobile'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_icon_size_mobile'] != '' ) ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_icon_size_mobile']) : 70;
                // Enable Chat icon size Mobile
                $this->chatgpt_assistant_enable_chat_icon_size_mobile = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'enable_chat_icon_size_mobile'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'enable_chat_icon_size_mobile'] == 'on' ) ? true : false; 
                // Chat width
                $this->chatgpt_assistant_chat_width = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_width'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_width'] != '' ) ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_width']) : 28;
                // Chat width format
                $this->chatgpt_assistant_chat_width_format = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_width_format'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_width_format'] != '' ) ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_width_format']) : '%';
                // Chat width Mobile
                $this->chatgpt_assistant_chat_width_mobile = (isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_width_mobile'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_width_mobile'] != '') ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_width_mobile']) : 95;               
                // Chat width mobile format
                $this->chatgpt_assistant_chat_width_mobile_format = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_width_mobile_format'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_width_mobile_format'] != '' ) ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_width_mobile_format']) : '%';
                // Enable Chat width mobile
                $this->chatgpt_assistant_enable_chat_width_mobile = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'enable_chat_width_mobile'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'enable_chat_width_mobile'] == 'off' ) ? false : true; 
                // Chat height
                $this->chatgpt_assistant_chat_height = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_height'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_height'] != '' ) ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_height']) : 55;
                // Chat height format
                $this->chatgpt_assistant_chat_height_format = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_height_format'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_height_format'] != '' ) ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_height_format']) : '%';
                // Chat height Mobile
                $this->chatgpt_assistant_chat_height_mobile = (isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_height_mobile'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_height_mobile'] != '') ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_height_mobile']) : 95;               
                // Chat height mobile format
                $this->chatgpt_assistant_chat_height_mobile_format = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_height_mobile_format'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_height_mobile_format'] != '' ) ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_height_mobile_format']) : '%';
                // Enable Chat height mobile
                $this->chatgpt_assistant_enable_chat_height_mobile = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'enable_chat_height_mobile'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'enable_chat_height_mobile'] == 'on' ) ? true : false; 
                // Auto opening Chatbox
                $this->chatgpt_assistant_auto_opening_chatbox = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'auto_opening_chatbox'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'auto_opening_chatbox'] == 'on' ) ? true : false;
                // Auto opening Chatbox delay
                $this->chatgpt_assistant_auto_opening_chatbox_delay = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'auto_opening_chatbox_delay'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'auto_opening_chatbox_delay'] != '' ) ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'auto_opening_chatbox_delay']) : 0;
                // Auto opening Chatbox Mobile
                if( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'auto_opening_chatbox_mobile'] )){
                    $this->chatgpt_assistant_auto_opening_chatbox_mobile = ($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'auto_opening_chatbox_mobile'] == 'on') ? true : false;
                } else{
                    $this->chatgpt_assistant_auto_opening_chatbox_mobile = $this->chatgpt_assistant_auto_opening_chatbox ;
                }
                // Show dashboard chat
                $this->chatgpt_assistant_show_dashboard_chat = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'show_dashboard_chat'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'show_dashboard_chat'] == 'off' ) ? false : true;
                // Show dashboard chat
                $this->chatgpt_assistant_show_dashboard_chat_mobile = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'show_dashboard_chat_mobile'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'show_dashboard_chat_mobile'] == 'off' ) ? false : true;
                // Regenerate Response
                $this->chatgpt_assistant_regenerate_response = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'regenerate_response'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'regenerate_response'] == 'on' ) ? true : false;

                // Enable rate chat
                $this->chatgpt_assistant_enable_rate_chat = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'enable_rate_chat'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'enable_rate_chat'] == 'on' ) ? true : false;

                // Rate chat text
                $this->chatgpt_assistant_rate_chat_text = isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'rate_chat_text'] ) ? stripslashes(sanitize_text_field($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'rate_chat_text'])) : __('How Satisfied are You?', 'ays-chatgpt-assistant');

				// Rate chat options
				$chatgpt_assistant_rate_chat = (isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'rate_chat']) && !empty($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'rate_chat'])) ? $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'rate_chat'] : array();

				$this->chatgpt_assistant_rate_chat_like = isset($chatgpt_assistant_rate_chat['like']) && !empty($chatgpt_assistant_rate_chat['like']) ? $chatgpt_assistant_rate_chat['like'] : array();
				$this->chatgpt_assistant_rate_chat_like['action'] = (isset($this->chatgpt_assistant_rate_chat_like['action']) && ($this->chatgpt_assistant_rate_chat_like['action'] == 'feedback')) ? sanitize_text_field($this->chatgpt_assistant_rate_chat_like['action']) : 'feedback';
				$this->chatgpt_assistant_rate_chat_like['text'] = (isset($this->chatgpt_assistant_rate_chat_like['text']) && $this->chatgpt_assistant_rate_chat_like['text'] != '') ? stripslashes(sanitize_text_field($this->chatgpt_assistant_rate_chat_like['text'])) : '';

				$this->chatgpt_assistant_rate_chat_dislike = isset($chatgpt_assistant_rate_chat['dislike']) && !empty($chatgpt_assistant_rate_chat['dislike']) ? $chatgpt_assistant_rate_chat['dislike'] : array();
				$this->chatgpt_assistant_rate_chat_dislike['action'] = (isset($this->chatgpt_assistant_rate_chat_dislike['action']) && ($this->chatgpt_assistant_rate_chat_dislike['action'] == 'feedback')) ? sanitize_text_field($this->chatgpt_assistant_rate_chat_dislike['action']) : 'feedback';
				$this->chatgpt_assistant_rate_chat_dislike['text'] = (isset($this->chatgpt_assistant_rate_chat_dislike['text']) && $this->chatgpt_assistant_rate_chat_dislike['text'] != '') ? stripslashes(sanitize_text_field($this->chatgpt_assistant_rate_chat_dislike['text'])) : '';

                // Greeting message
                $this->chatgpt_assistant_greeting_message = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'greeting_message'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'greeting_message'] == 'on' ) ? true : false;
                // Greeting message text
                $this->chatgpt_assistant_greeting_message_default_text = 'Hello! I\'m an AI Assistant, and I\'m here to assist you with anything you need. How can I help you today?';
                $this->chatgpt_assistant_greeting_message_text = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'greeting_message_text'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'greeting_message_text'] != '' ) ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'greeting_message_text']) : $this->chatgpt_assistant_greeting_message_default_text;
                // Message placeholder
                $this->chatgpt_assistant_message_placeholder = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_placeholder'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_placeholder'] != '' ) ? stripslashes(esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_placeholder'])) : __('Enter your message ', 'ays-chatgpt-assistant');
                // Message placeholder
                $this->chatgpt_assistant_chatbot_name = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chatbot_name'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chatbot_name'] != '' ) ? stripslashes(esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chatbot_name'])) : __('AI Assistant', 'ays-chatgpt-assistant');
                // compliance text
                $this->chatgpt_assistant_compliance_text = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'compliance_text'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'compliance_text'] != '' ) ? stripslashes(esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'compliance_text'])) : '';
            // ===== Chat settings =====
                // Model
                $this->chatgpt_assistant_chat_model = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_model'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_model'] != '' ) ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_model']) : 'gpt-3.5-turbo-16k';
                // Temprature
                $this->chatgpt_assistant_chat_temprature = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_temprature'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_temprature'] != '' ) ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_temprature']) : '0.8';
                // Top P
                $this->chatgpt_assistant_chat_top_p = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_top_p'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_top_p'] != '' ) ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chat_top_p']) : '1';
                // Max tokens
                $this->chatgpt_assistant_max_tokens = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'max_tokens'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'max_tokens'] != '' ) ? intval($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'max_tokens']) : 1500;
                // Frequency penalty
                $this->chatgpt_assistant_frequency_penalty = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'frequency_penalty'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'frequency_penalty'] != '' ) ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'frequency_penalty']) : '0.01';
                // Presence penalty
                $this->chatgpt_assistant_presence_penalty = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'presence_penalty'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'presence_penalty'] != '' ) ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'presence_penalty']) : '0.01';
                // Best of
                $this->chatgpt_assistant_best_of = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'best_of'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'best_of'] != '' ) ? intval($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'best_of']) : 1;   
                // Context
                $this->chatgpt_assistant_context = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'context'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'context'] != '' ) ? stripslashes(esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'context'])) : '';
                // Profession (Act as)
                $this->chatgpt_assistant_profession = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'profession'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'profession'] != '' ) ? stripslashes(esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'profession'])) : '';
                // Tone
                $this->chatgpt_assistant_tone = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'tone'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'tone'] != '' ) ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'tone']) : '';                
                // Language
                $this->chatgpt_assistant_language = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'language'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'language'] != '' ) ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'language']) : 'en';                
                // Name
                $this->chatgpt_assistant_name = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'name'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'name'] != '' ) ? stripslashes(esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'name'])) : '';                
        //

        // * STYLE SETTINGS *
            // Chat theme
			$this->chatbox_theme = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX . 'chatbox_theme'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX . 'chatbox_theme'] != '' ) ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX . 'chatbox_theme']) : 'default';
            // Chat dark mode
            $this->chatbox_mode = ( isset( $options['chatbox_mode'] ) && $options['chatbox_mode'] != '' ) ? esc_attr($options['chatbox_mode']) : 'light';
            // Chat Widget background color
            $this->chatgpt_assistant_chatbox_background_color = isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chatbox_background_color']) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chatbox_background_color'] != '' ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chatbox_background_color']) : '#ffffff';   
            $this->chatgpt_assistant_chatbox_background_color = !isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chatbox_background_color']) && $this->chatbox_mode == 'dark' ? '#343541' : $this->chatgpt_assistant_chatbox_background_color;
            // Chat Widget header text color
            $this->chatgpt_assistant_chatbox_header_text_color = isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chatbox_header_text_color']) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chatbox_header_text_color'] != '' ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chatbox_header_text_color']) : '#ffffff';   
            // Chat Widget header text letter_spacing
            $this->chatgpt_assistant_chatbox_header_text_letter_spacing = isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chatbox_header_text_letter_spacing']) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chatbox_header_text_letter_spacing'] != '' ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chatbox_header_text_letter_spacing']) : '0';   
            // Chat Widget header text font_size
            $this->chatgpt_assistant_chatbox_header_text_font_size = isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chatbox_header_text_font_size']) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chatbox_header_text_font_size'] != '' ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chatbox_header_text_font_size']) : '16';   
            // Message font size
            $this->chatgpt_assistant_message_font_size = isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_font_size']) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_font_size'] != '' ? $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_font_size'] : 16;
            // Message font size mobile
            if( isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_font_size_mobile'] )){
                $this->chatgpt_assistant_message_font_size_mobile = ($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_font_size_mobile'] != '') ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_font_size_mobile']) : 16;
            } else{
                $this->chatgpt_assistant_message_font_size_mobile = $this->chatgpt_assistant_message_font_size ;
            }
            // Enable font size mobile
            $this->chatgpt_assistant_enable_message_font_size_mobile = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'enable_message_font_size_mobile'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'enable_message_font_size_mobile'] == 'on' ) ? true : false; 
            // Message letter spacing
            $this->chatgpt_assistant_message_letter_spacing = isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_letter_spacing']) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_letter_spacing'] != '' ? $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_letter_spacing'] : 0;
            // Message spacing
            $this->chatgpt_assistant_message_spacing = isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_spacing']) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_spacing'] != '' ? $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_spacing'] : 7;
            // Message spacing mobile
            if( isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_spacing_mobile'] )){
                $this->chatgpt_assistant_message_spacing_mobile = ($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_spacing_mobile'] != '') ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_spacing_mobile']) : 7;
            } else{
                $this->chatgpt_assistant_message_spacing_mobile = $this->chatgpt_assistant_message_spacing ;
            }
            // Enable spacing mobile
            $this->chatgpt_assistant_enable_message_spacing_mobile= ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'enable_message_spacing_mobile'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'enable_message_spacing_mobile'] == 'on' ) ? true : false; 
            // Message border radius
            $this->chatgpt_assistant_message_border_radius = isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_border_radius']) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_border_radius'] != '' ? absint(esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_border_radius'])) : 10;
            // Message border radius mobile
            if( isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_border_radius_mobile'] )){
                $this->chatgpt_assistant_message_border_radius_mobile = ($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_border_radius_mobile'] != '') ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_border_radius_mobile']) : 10;
            } else{
                $this->chatgpt_assistant_message_border_radius_mobile = $this->chatgpt_assistant_message_border_radius ;
            }
            // Enable Message border radius mobile
            $this->chatgpt_assistant_enable_message_border_radius_mobile = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'enable_message_border_radius_mobile'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'enable_message_border_radius_mobile'] == 'on' ) ? true : false; 
            // chatbot border radius
            $this->chatgpt_assistant_chatbot_border_radius = isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chatbot_border_radius']) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chatbot_border_radius'] != '' ? absint(esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chatbot_border_radius'])) : 10;
            // chatbot border radius mobile
            if( isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chatbot_border_radius_mobile'] )){
                $this->chatgpt_assistant_chatbot_border_radius_mobile = ($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chatbot_border_radius_mobile'] != '') ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'chatbot_border_radius_mobile']) : 10;
            } else{
                $this->chatgpt_assistant_chatbot_border_radius_mobile = $this->chatgpt_assistant_chatbot_border_radius ;
            }
            // Enable chatbot border radius mobile
            $this->chatgpt_assistant_enable_chatbot_border_radius_mobile = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'enable_chatbot_border_radius_mobile'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'enable_chatbot_border_radius_mobile'] == 'on' ) ? true : false; 
            // send message icon
            $this->chatgpt_assistant_send_message_icon = (isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX . 'send_message_icon']) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX . 'send_message_icon'] != '') ? stripslashes ( esc_attr( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX . 'send_message_icon'] ) ) : esc_attr(CHATGPT_ASSISTANT_ADMIN_URL) . "/images/icons/send-button-icon.svg";
            // send message text
            $this->chatgpt_assistant_send_message_text = (isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX . 'send_message_text']) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX . 'send_message_text'] != '') ? stripslashes ( esc_attr( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX . 'send_message_text'] ) ) : "";
            // Send button font size
            $this->chatgpt_assistant_send_button_font_size = isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'send_button_font_size']) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'send_button_font_size'] != '' ? $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'send_button_font_size'] : 16;
            // Send button padding
            $this->chatgpt_assistant_send_button_padding = isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'send_button_padding']) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'send_button_padding'] != '' ? $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'send_button_padding'] : 6;

			$this->chatgpt_assistant_send_message_icon_text = __('Upload Image', 'ays-chatgpt-assistant');
			if ( $this->chatgpt_assistant_send_message_icon != '' ) {
				$this->chatgpt_assistant_send_message_icon_text = __('Edit Image', 'ays-chatgpt-assistant');
			}

            /* === END CHAT MODAL STYLES START === */

            // Button bg color
            $this->chatgpt_assistant_end_chat_button_bg_color = isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'end_chat_button_bg_color']) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'end_chat_button_bg_color'] != '' ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'end_chat_button_bg_color']) : '#d93311';   
            // text color
            $this->chatgpt_assistant_end_chat_button_text_color = isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'end_chat_button_text_color']) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'end_chat_button_text_color'] != '' ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'end_chat_button_text_color']) : '#ffffff';   
            // text font size
            $this->chatgpt_assistant_end_chat_button_text_font_size = isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'end_chat_button_text_font_size']) && intval($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'end_chat_button_text_font_size']) != 0 ? absint(esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'end_chat_button_text_font_size'])) : '16';   
            // text letter spacing
            $this->chatgpt_assistant_end_chat_button_text_letter_spacing = isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'end_chat_button_text_letter_spacing']) ? absint(esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'end_chat_button_text_letter_spacing'])) : '0';   

            /* === END CHAT MODAL STYLES END === */
            
            /* === USER MESSAGE STYLES START === */

                // User message background color
                if(isset($options['message_color']) && $options['message_color'] != ''){
                    $this->message_bg_color = $options['message_color'];
                }else{
                    if ( !(isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_bg_color']) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_bg_color'] != '') ) {
                        $this->message_bg_color = '#4e426d';
                        if ($this->chatbox_mode == 'dark') {
                            $this->message_bg_color = '#343541';
                        }
                    } else {
                        $this->message_bg_color = esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_bg_color']);
                    }
                }

                // User message text color
                if ( !(isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_text_color']) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_text_color'] != '') ) {
                    $this->message_text_color = '#ffffff';
                    if ($this->chatbox_mode == 'dark') {
                        $this->message_text_color = '#f1f1f1';
                    }
                } else {
                    $this->message_text_color = esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'message_text_color']);
                }

            /* === USER MESSAGE STYLES END === */

            /* === CHATBOT MESSAGE STYLES START === */

                // Chatbot response background color
                if(isset($options['response_color']) && $options['response_color'] != ''){
                    $this->response_bg_color = $options['response_color'];
                }else{
                    if ( !(isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'response_bg_color']) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'response_bg_color'] != '') ) {
                        $this->response_bg_color = '#d3d3d3';
                        if ($this->chatbox_mode == 'dark') {
                            $this->response_bg_color = '#4b4d56';
                        }
                    } else {
                        $this->response_bg_color = esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'response_bg_color']);
                    }

                }

                // Chatbot response text color
                 if ( !(isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'response_text_color']) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'response_text_color'] != '') ) {
                    $this->response_text_color = '#000000';
                    if ($this->chatbox_mode == 'dark') {
                        $this->response_text_color = '#ffffff';
                    }
                } else {
                    $this->response_text_color = esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'response_text_color']);
                }

                $this->response_icons_color = isset($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'response_icons_color']) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'response_icons_color'] != '' ? esc_attr($options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'response_icons_color']) : '#636a84';   

            /* === CHATBOT MESSAGE STYLES END === */
                $guest_icon_index = wp_rand(1, 10);

                $this->chat_icon = CHATGPT_ASSISTANT_ADMIN_URL . "/images/icons/chatgpt-icon.png";
                $this->chat_avatar = $this->chat_icon;
                /* === USER PROFILE PICTURE START === */
                $this->user_profile_picture = '<img alt="" src="' . CHATGPT_ASSISTANT_ADMIN_URL . '/images/icons/guest_icon_'.$guest_icon_index.'.png">';
                if ( is_user_logged_in() ) {
                    $current_user = wp_get_current_user();
                    $this->user_profile_picture = (get_avatar( $current_user->ID, 32 ));
                }
                /* === USER PROFILE PICTURE END === */

        //

        // Set Chatbot options for JS
        // $generate_hush_api =  base64_encode($this->api_key . uniqid(uniqid('chgafr') . 'eds'));
		wp_localize_script( $this->plugin_name , 'AysChatGPTChatSettings', array(
            'ajaxUrl'                          => admin_url( 'admin-ajax.php' ),
            'nonce'                            => wp_create_nonce( 'ajax-nonce' ),  
		    'chatModel'                        => $this->chatgpt_assistant_chat_model,
		    'chatTemprature'                   => $this->chatgpt_assistant_chat_temprature,
		    'chatTopP'                         => $this->chatgpt_assistant_chat_top_p,
		    'chatMaxTokents'                   => $this->chatgpt_assistant_max_tokens,
		    'chatFrequencyPenalty'             => $this->chatgpt_assistant_frequency_penalty,
		    'chatPresencePenalty'              => $this->chatgpt_assistant_presence_penalty,
		    'chatBestOf'                       => $this->chatgpt_assistant_best_of,
		    'chatContext'                      => $this->chatgpt_assistant_context,
		    'chatProfession'                   => $this->chatgpt_assistant_profession,
		    'chatTone'                         => $this->chatgpt_assistant_tone,
		    'chatLanguage'                     => $this->chatgpt_assistant_language,
		    'chatName'                         => $this->chatgpt_assistant_name,
		    'chatGreetingMessage'              => $this->chatgpt_assistant_greeting_message,
		    'chatMessagePlaceholder'           => $this->chatgpt_assistant_message_placeholder,
		    'chatBotName'                      => $this->chatgpt_assistant_chatbot_name,
            'chatboxTheme'                     => $this->chatbox_theme,
			'chatIcon'                         => $this->chat_icon,
			'chatAvatar'                       => $this->chat_avatar,
            'userProfilePicture'               => $this->user_profile_picture,
		    'chatAutoOpening'                  => $this->chatgpt_assistant_auto_opening_chatbox,
		    'chatAutoOpeningDelay'             => $this->chatgpt_assistant_auto_opening_chatbox_delay,
            'chatAutoOpeningMobile'            => $this->chatgpt_assistant_auto_opening_chatbox_mobile,
		    'chatRegenerateResponse'           => $this->chatgpt_assistant_regenerate_response,
		    'chatboxPosition'                  => $this->chatbox_position,
            'chatboxPositionMobile'            => $this->chatbox_position_mobile,
            'chatboxEnablePositionMobile'      => $this->chatbox_enable_position_mobile,
		    'chatboxIconPosition'              => $this->chatbox_icon_position,
            'chatboxIconPositionMobile'        => $this->chatbox_icon_position_mobile,
            'chatboxEnableIconPositionMobile'  => $this->chatbox_enable_icon_position_mobile,
		    'chatboxIconSize'                  => $this->chatgpt_assistant_chat_icon_size,
            'chatboxIconSizeMobile'            => $this->chatgpt_assistant_chat_icon_size_mobile,
            'enableChatboxIconSizeMobile'      => $this->chatgpt_assistant_enable_chat_icon_size_mobile,
            'showDashboardChat'                => $this->chatgpt_assistant_show_dashboard_chat,
            'showDashboardChatMobile'          => $this->chatgpt_assistant_show_dashboard_chat_mobile,
            'chatGreetingMessageText'          => $this->chatgpt_assistant_greeting_message_text,
            'translations'                     => array(
                'endChat' => array(
					'warningMsg' 	=> __( "Do you really want to leave the current chat?", "ays-chatgpt-assistant" ),
					'buttonMsg' 	=> __( "End chat", "ays-chatgpt-assistant" ),
					'modalIcon' 	=> esc_attr(CHATGPT_ASSISTANT_ADMIN_URL) . "/images/icons/leave-icon.svg"
				),
				// 'ka' => $generate_hush_api,

            )
		) );
	}

	public function ays_chatgpt_update_banner_time(){

        $date = time() + ( 3 * 24 * 60 * 60 ) + (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS);
        // $date = time() + ( 60 ) + (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS); // for testing | 1 min
        $next_3_days = gmdate('M d, Y H:i:s', $date);

        $ays_chatgpt_banner_time = get_option('ays_chatgpt_banner_time');

        if ( !$ays_chatgpt_banner_time || is_null( $ays_chatgpt_banner_time ) ) {
            update_option('ays_chatgpt_banner_time', $next_3_days ); 
        }

        $get_ays_chatgpt_banner_time = get_option('ays_chatgpt_banner_time');

        $val = 60*60*24*0.5; // half day
        // $val = 60; // for testing | 1 min

        $current_date = current_time( 'mysql' );
        $date_diff = strtotime($current_date) - intval(strtotime($get_ays_chatgpt_banner_time));

        $days_diff = $date_diff / $val;
        if(intval($days_diff) > 0 ){
            update_option('ays_chatgpt_banner_time', $next_3_days);
			$get_ays_chatgpt_banner_time = get_option('ays_chatgpt_banner_time');
        }

        return $get_ays_chatgpt_banner_time;
    }
	
	public function ays_chatgpt_sale_baner(){

        
        // if (isset($_POST['ays_chatgpt_sale_btn']) && (isset( $_POST[CHATGPT_ASSISTANT_NAME . '-sale-banner'] ) && wp_verify_nonce( $_POST[CHATGPT_ASSISTANT_NAME . '-sale-banner'], CHATGPT_ASSISTANT_NAME . '-sale-banner' )) && current_user_can( 'manage_options' )) {
        //     update_option('ays_chatgpt_sale_btn', 1);
        //     update_option('ays_chatgpt_sale_date', current_time( 'mysql' ));
        // }
    
        $ays_chatgpt_sale_date = get_option('ays_chatgpt_sale_date');

        $val = 60*60*24*5;

        $current_date = current_time( 'mysql' );
        $date_diff = strtotime($current_date) - intval(strtotime($ays_chatgpt_sale_date)) ;
        
        $days_diff = $date_diff / $val;
    
        if(intval($days_diff) > 0 ){
            update_option('ays_chatgpt_sale_btn', 0);
        }
    
        $ays_chatgpt_maker_flag = intval(get_option('ays_chatgpt_sale_btn'));
        if( $ays_chatgpt_maker_flag == 0 ){
            // phpcs:ignore WordPress.Security.NonceVerification.Recommended
            if (isset($_GET['page']) && strpos(sanitize_text_field(wp_unslash($_GET['page'])), CHATGPT_ASSISTANT_NAME) !== false) {
                // $this->ays_chatgpt_sale_message_30_emma($ays_chatgpt_maker_flag);
				//$this->ays_chatgpt_sale_message20($ays_chatgpt_maker_flag);
                //$this->ays_chatgpt_new_bundle_message_2025($ays_chatgpt_maker_flag);
                $this->ays_chatgpt_footer_sale_banner_2026($ays_chatgpt_maker_flag);
                // $this->ays_chatgpt_discounted_licenses_banner_message();
				// $this->ays_chatgpt_helloween_message($ays_chatgpt_maker_flag);
				// $this->ays_chatgpt_black_friday_message_2024($ays_chatgpt_maker_flag);
				// $this->ays_chatgpt_christmas_message_2024($ays_chatgpt_maker_flag);
                // $this->ays_chatgpt_new_halloween_bundle_message_2025($ays_chatgpt_maker_flag);
                // $this->ays_chatgpt_black_friday_message($ays_chatgpt_maker_flag);
                // $this->ays_chatgpt_christmas_banner_message_2025($ays_chatgpt_maker_flag);
            }
        }
    }
 public function ays_chatgpt_footer_sale_banner_2026($ishmar){
        if($ishmar == 0 ){
            $content = array();

            $chatgpt_cta_button_link = esc_url('https://ays-pro.com/wordpress/chatgpt-assistant?utm_source=dashboard&utm_medium=chatgpt-free&utm_campaign=private-offer-20-off-' . CHATGPT_ASSISTANT_VERSION);

            $content[] = '
                <div class="ays-chatgpt-footer-banner-bottom-banner-wrapper" style="display: none;">
                    <div class="ays-chatgpt-footer-banner-bottom-banner-container">
                        <div class="ays-chatgpt-footer-banner-bottom-banner-content">
                            <div class="ays-chatgpt-footer-banner-bottom-banner-inner">
                                <div class="ays-chatgpt-footer-banner-bottom-banner-left">
                                    <div class="ays-chatgpt-footer-banner-bottom-banner-icon">
                                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
                                            <path d="M12 7v14"></path>
                                            <path d="M20 11v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8"></path>
                                            <path d="M7.5 7a1 1 0 0 1 0-5A4.8 8 0 0 1 12 7a4.8 8 0 0 1 4.5-5 1 1 0 0 1 0 5"></path>
                                            <rect x="3" y="7" width="18" height="4" rx="1"></rect>
                                        </svg>
                                    </div>
                                    <span class="ays-chatgpt-footer-banner-bottom-banner-title">'. esc_html__('ChatGPT Assistant by AYS', 'ays-chatgpt-assistant') .'</span>
                                </div>
                                <span class="ays-chatgpt-footer-banner-bottom-banner-separator"></span>
                                <span class="ays-chatgpt-footer-banner-bottom-banner-discount">'. esc_html__('20% Off', 'ays-chatgpt-assistant') .'</span>
                                <div class="ays-chatgpt-footer-banner-bottom-banner-code" onclick="aysChatgptFooterBannerCopyToClipboard()" title="'. esc_html__('Copy Coupon Code', 'ays-chatgpt-assistant') .'">
                                    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
                                        <path d="M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"></path>
                                        <path d="M13 5v2"></path>
                                        <path d="M13 17v2"></path>
                                        <path d="M13 11v2"></path>
                                    </svg>
                                    <span>GPTPRO20</span>
                                    <button type="button" class="ays-chatgpt-footer-banner-bottom-banner-copy" aria-label="'. esc_html__('Copy Coupon Code', 'ays-chatgpt-assistant') .'">
                                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
                                            <rect width="14" height="14" x="8" y="8" rx="2" ry="2"></rect>
                                            <path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"></path>
                                        </svg>
                                    </button>
                                </div>
                                <button type="button" class="ays-chatgpt-footer-banner-bottom-banner-cta">
                                    '. esc_html__('Get Deal', 'ays-chatgpt-assistant') .'
                                </button>
                                <button type="button" class="ays-chatgpt-footer-banner-bottom-banner-close" aria-label="'. esc_html__('Close popup', 'ays-chatgpt-assistant') .'">
                                    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
                                        <path d="M18 6 6 18"></path>
                                        <path d="m6 6 12 12"></path>
                                    </svg>
                                </button>
                                    </div>
                        </div>
                    </div>
                </div>';

            $content[] = '<style id="ays-chatgpt-footer-banner-styles-inline-css">';

            $content[] = '@keyframes ays-pro-slide-up{0%{opacity:0;transform:translateY(24px)}100%{opacity:1;transform:translateY(0)}}@keyframes ays-pro-slide-down{0%{opacity:1;transform:translateY(0)}100%{opacity:0;transform:translateY(24px)}}.ays-chatgpt-footer-banner-bottom-banner-wrapper{position:fixed;bottom:0;left:0;right:0;z-index:9999;padding:0 16px 28px;text-align:center;animation:.45s cubic-bezier(.16,1,.3,1) forwards ays-pro-slide-up}.ays-chatgpt-footer-banner-bottom-banner-wrapper.ays-pro-banner-closing{animation:.32s cubic-bezier(.16,1,.3,1) forwards ays-pro-slide-down}.ays-chatgpt-footer-banner-bottom-banner-container{display:inline-block;max-width:100%;border-radius:16px;background:linear-gradient(90deg,#2f6bff 0,#3e7bff 100%);box-shadow:0 20px 40px -15px rgba(47,107,255,.55),0 8px 20px -10px rgba(47,107,255,.35);overflow:hidden}.ays-chatgpt-footer-banner-bottom-banner-code,.ays-chatgpt-footer-banner-bottom-banner-content,.ays-chatgpt-footer-banner-bottom-banner-inner,.ays-chatgpt-footer-banner-bottom-banner-left{display:flex;align-items:center}.ays-chatgpt-footer-banner-bottom-banner-inner{gap:16px;padding:8px 14px 8px 10px;color:#fff;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif}.ays-chatgpt-footer-banner-bottom-banner-left{gap:14px}.ays-chatgpt-footer-banner-bottom-banner-icon{display:flex;align-items:center;justify-content:center;flex:0 0 auto;width:48px;height:48px;border-radius:50%;background:rgba(255,255,255,.15);color:#fff}.ays-chatgpt-footer-banner-bottom-banner-icon svg{width:24px;height:24px}.ays-chatgpt-footer-banner-bottom-banner-discount,.ays-chatgpt-footer-banner-bottom-banner-title{font-size:17px;font-weight:600;line-height:1.25;letter-spacing:0;white-space:nowrap;color:#fff}.ays-chatgpt-footer-banner-bottom-banner-separator{display:block;width:1px;height:24px;background:rgba(255,255,255,.4)}.ays-chatgpt-footer-banner-bottom-banner-code{gap:6px;border:1px dashed rgba(255,255,255,.7);border-radius:999px;padding:6px 9px;color:#fff;cursor:pointer;transition:background-color .15s,border-color .15s}.ays-chatgpt-footer-banner-bottom-banner-code:hover{background:rgba(255,255,255,.1);border-color:#fff}.ays-chatgpt-footer-banner-bottom-banner-code button svg,.ays-chatgpt-footer-banner-bottom-banner-code>svg{width:16px;height:16px}.ays-chatgpt-footer-banner-bottom-banner-code span{font-size:14px;font-weight:600;line-height:1;letter-spacing:.05em;color:#fff}.ays-chatgpt-footer-banner-bottom-banner-close,.ays-chatgpt-footer-banner-bottom-banner-copy{display:flex;align-items:center;justify-content:center;margin:0;padding:0;background:0 0;border:0;color:rgba(255,255,255,.9);cursor:pointer;box-shadow:none;transition:color .15s,background-color .15s}.ays-chatgpt-footer-banner-bottom-banner-close:hover,.ays-chatgpt-footer-banner-bottom-banner-copy:hover{color:#fff;background:0 0}.ays-chatgpt-footer-banner-bottom-banner-wrapper .ays-chatgpt-footer-banner-bottom-banner-cta{display:inline-flex;align-items:center;justify-content:center;min-height:40px;padding:8px 20px;border:0;border-radius:999px;background:#fff;color:#2f6bff;font-size:15px;font-weight:600;line-height:1;white-space:nowrap;cursor:pointer;box-shadow:0 1px 2px rgba(0,0,0,.08);transition:background-color .15s,transform .15s}.ays-chatgpt-footer-banner-bottom-banner-wrapper .ays-chatgpt-footer-banner-bottom-banner-cta:hover{background:rgba(255,255,255,.95);color:#2f6bff;transform:translateY(-1px)}.ays-chatgpt-footer-banner-bottom-banner-close{width:22px;height:22px;margin-left:2px}.ays-chatgpt-footer-banner-bottom-banner-close svg{width:20px;height:20px}.ays-chatgpt-footer-banner-copy-notification{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);background:rgba(0,0,0,.8);color:#fff;padding:12px 24px;border-radius:8px;font-size:14px;z-index:10000;opacity:0;transition:opacity .3s}.ays-chatgpt-footer-banner-copy-notification.show{opacity:1}@media (max-width:768px){.ays-chatgpt-footer-banner-bottom-banner-wrapper{display:none}}';
            $content[] = '</style>';

            $content[] = '<script>';

            $content[] = "
            /**
             * Footer Banner JavaScript - ES5 Compatible
             * With delayed popup and visit tracking
             */
            
            (function() {
              'use strict';
              
              // Configuration
              var STORAGE_KEY = 'ays_chatgpt_footer_banner_data';
              var POPUP_RULES = [
                { visit: 1, delay: 10000 },   // 1st visit: 10 seconds
                { visit: 2, delay: 10000 },   // 2nd visit: 10 seconds
                { visit: 3, delay: 15000 },   // 3th visit: 15 seconds
                { visit: 4, delay: 15000 },   // 4th visit: 15 seconds
                { visit: 5, delay: 20000 },   // 5th visit: 20 seconds
                { visit: 7, delay: 20000 },   // 7th visit: 20 seconds
                { visit: 10, delay: 30000 }   // 10th visit: 30 seconds
              ];
              var MAX_SHOWS_PER_DAY = 7;
              
              // Wait for DOM to be ready
              if (document.readyState === 'loading') {
                document.addEventListener('DOMContentLoaded', initBanner);
              } else {
                initBanner();
              }
              
              function initBanner() {
                var banner = document.querySelector('.ays-chatgpt-footer-banner-bottom-banner-wrapper');
                var closeButton = document.querySelector('.ays-chatgpt-footer-banner-bottom-banner-close');
                var ctaButton = document.querySelector('.ays-chatgpt-footer-banner-bottom-banner-cta');
                
                if (!banner) {
                  return;
                }
                
                // Hide banner initially
                banner.style.display = 'none';
                
                // Get or initialize banner data
                var bannerData = getBannerData();
                
                // Check if we need to reset daily data
                if (shouldResetData(bannerData.lastResetDate)) {
                  bannerData = resetDailyData();
                }
                
                // Increment visit count
                bannerData.visitCount++;
                saveBannerData(bannerData);
                
                // Check if banner should be shown
                var shouldShow = shouldShowBanner(bannerData);
                
                if (shouldShow.show) {
                  // Show banner after delay
                  setTimeout(function() {
                    banner.style.display = 'block';
                    
                    // Increment show count
                    bannerData.showCount++;
                    saveBannerData(bannerData);
                  }, shouldShow.delay);
                }
                
                // Close button handler
                if (closeButton) {
                  closeButton.addEventListener('click', function() {
                    closeBanner(banner);
                  });
                }
                
                // CTA button handler
                if (ctaButton) {
                  ctaButton.addEventListener('click', function() {
                    window.open('https://ays-pro.com/wordpress/chatgpt-assistant?utm_source=dashboard&utm_medium=chatgpt-free&utm_campaign=private-offer-20-off-". CHATGPT_ASSISTANT_VERSION ."', '_blank');
                    // Optionally close banner after click
                    closeBanner(banner);
                  });
                }
              }
              
              /**
               * Get banner data from localStorage
               */
              function getBannerData() {
                try {
                  var data = localStorage.getItem(STORAGE_KEY);
                  if (data) {
                    return JSON.parse(data);
                  }
                } catch (e) {
                  // localStorage not available or parsing error
                }
                
                // Return default data
                return {
                  visitCount: 0,
                  showCount: 0,
                  lastResetDate: getTodayDate()
                };
              }
              
              /**
               * Save banner data to localStorage
               */
              function saveBannerData(data) {
                try {
                  localStorage.setItem(STORAGE_KEY, JSON.stringify(data));
                } catch (e) {
                  // localStorage not available
                }
              }
              
              /**
               * Check if data should be reset (new day)
               */
              function shouldResetData(lastResetDate) {
                var today = getTodayDate();
                return lastResetDate !== today;
              }
              
              /**
               * Reset daily data
               */
              function resetDailyData() {
                var newData = {
                  visitCount: 0,
                  showCount: 0,
                  lastResetDate: getTodayDate()
                };
                saveBannerData(newData);
                return newData;
              }
              
              /**
               * Get today's date as string (YYYY-MM-DD)
               */
              function getTodayDate() {
                var date = new Date();
                var year = date.getFullYear();
                var month = String(date.getMonth() + 1).padStart(2, '0');
                var day = String(date.getDate()).padStart(2, '0');
                return year + '-' + month + '-' + day;
              }
              
              /**
               * Check if banner should be shown based on rules
               */
              function shouldShowBanner(bannerData) {
                // Check if already shown max times today
                if (bannerData.showCount >= MAX_SHOWS_PER_DAY) {
                  return { show: false, delay: 0 };
                }
                
                // Check visit count against rules
                for (var i = 0; i < POPUP_RULES.length; i++) {
                  var rule = POPUP_RULES[i];
                  if (bannerData.visitCount === rule.visit) {
                    return { show: true, delay: rule.delay };
                  }
                }
                
                return { show: false, delay: 0 };
              }
              
              /**
               * Close banner with animation
               */
              function closeBanner(banner) {
                if (!banner) {
                  return;
                }
                
                // Add closing animation class
                banner.classList.add('ays-pro-banner-closing');
                
                // Wait for animation to complete
                setTimeout(function() {
                  banner.style.display = 'none';
                }, 400);
              }
              
              // Polyfill for String.padStart (for older browsers)
              if (!String.prototype.padStart) {
                String.prototype.padStart = function(targetLength, padString) {
                  targetLength = targetLength >> 0;
                  padString = String(typeof padString !== 'undefined' ? padString : ' ');
                  if (this.length >= targetLength) {
                    return String(this);
                  } else {
                    targetLength = targetLength - this.length;
                    if (targetLength > padString.length) {
                      padString += padString.repeat(targetLength / padString.length);
                    }
                    return padString.slice(0, targetLength) + String(this);
                  }
                };
              }
            })();
            
            function aysChatgptFooterBannerCopyToClipboard() {
                var textarea = document.createElement('textarea');
                textarea.value = 'GPTPRO20';
                textarea.style.position = 'fixed';
                textarea.style.opacity = '0';
                document.body.appendChild(textarea);
                
                textarea.select();
                textarea.setSelectionRange(0, 99999);
                
                try {
                    document.execCommand('copy');
                    aysChatgptFooterBannerShowCopyNotification('". esc_html__('Coupon code copied', 'ays-chatgpt-assistant') ."');
                } catch (err) {
                    console.error('Failed to copy text: ', err);
                }
                
                document.body.removeChild(textarea);
            }

            function aysChatgptFooterBannerShowCopyNotification(message) {
                var existingNotification = document.querySelector('.ays-chatgpt-footer-banner-copy-notification');
                if (existingNotification) {
                    document.body.removeChild(existingNotification);
                }
                
                var notification = document.createElement('div');
                notification.className = 'ays-chatgpt-footer-banner-copy-notification';
                notification.textContent = message;
                document.body.appendChild(notification);
                
                setTimeout(function() {
                    notification.classList.add('show');
                }, 10);
                
                setTimeout(function() {
                    notification.classList.remove('show');
                    setTimeout(function() {
                        if (notification.parentNode) {
                            document.body.removeChild(notification);
                        }
                    }, 300);
                }, 2000);
            }";

            $content[] = '</script>';

            $content = implode( '', $content );
            echo ($content);
        }
    }
    public function ays_chatgpt_dismiss_button(){

        $data = array(
            'status' => false,
        );

        if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'ays_chatgpt_dismiss_button') { 
            if ( isset( $_REQUEST['_ajax_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_ajax_nonce'] ) ), CHATGPT_ASSISTANT_NAME . '-sale-banner' ) && current_user_can( 'manage_options' ) ) {
                update_option('ays_chatgpt_sale_btn', 1);
                update_option('ays_chatgpt_sale_date', current_time( 'mysql' ));
                $data['status'] = true;
            } else if ( isset( $_REQUEST['_ajax_nonce'] ) && wp_verify_nonce(sanitize_text_field(  wp_unslash( $_REQUEST['_ajax_nonce'] ) ), CHATGPT_ASSISTANT_NAME . '-gift-banner' ) && current_user_can( 'manage_options' ) ) {
                update_option('ays_chatgpt_gift_btn', 1);
                update_option('ays_chatgpt_gift_date', current_time( 'mysql' ));
                $data['status'] = true;
            }
        }

        ob_end_clean();
        $ob_get_clean = ob_get_clean();
        echo json_encode($data);
        wp_die();

    }

     public function ays_chatgpt_discounted_licenses_banner_message(){
        
        $content = array();
        $date = time() + (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS);
        $now_date = date('M d, Y H:i:s', $date);
        $start_date = strtotime('2025-09-24');
        $end_date = strtotime('2025-10-25');
        $diff_end = $end_date - $date;
        $style_attr = '';
        if( $diff_end < 0 ){
            $style_attr = 'style="display:none;"';
        }
        $total_licenses = 50;
        $progression_pattern = array(3, 2, 1, 4, 2, 3, 1, 2, 4, 3, 2, 1, 3, 2, 4, 1, 3, 2, 2, 3, 1, 2);
        $days_passed = floor(($date - $start_date) / (24 * 60 * 60));
        $used_licenses = 0;
        for ($i = 0; $i < min($days_passed, count($progression_pattern)); $i++) {
            $used_licenses += $progression_pattern[$i];
        }
        $used_licenses = min($used_licenses, $total_licenses);
        $remaining_licenses = $total_licenses - $used_licenses;
        $progress_percentage = ($used_licenses / $total_licenses) * 100;
        $ays_chatgpt_cta_button_link = esc_url('https://ays-pro.com/wordpress/chatgpt-assistant?utm_source=dashboard&utm_medium=chatgpt-free&utm_campaign=chatgpt-license-banner-' . CHATGPT_ASSISTANT_VERSION);
        $content[] = '<div id="ays-chatgpt-progress-banner-main" class="ays-chatgpt-progress-banner-main ays-chatgpt-admin-notice notice notice-success is-dismissible" ' . $style_attr . '>';
            $content[] = '<div class="ays-chatgpt-progress-banner-content">';
                $content[] = '<div class="ays-chatgpt-progress-banner-left">';
                    $content[] = '<div class="ays-chatgpt-progress-banner-icon">';
                        $content[] = '<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
                                        <path d="M1.33325 22.6668L11.9999 13.3335L33.3333 14.6668L34.6666 36.0002L25.3333 46.6668C25.3333 46.6668 25.3346 38.6682 17.3333 30.6668C9.33192 22.6655 1.33325 22.6668 1.33325 22.6668Z" fill="#A0041E"/>
                                        <path d="M1.29739 46.6665C1.29739 46.6665 1.24939 36.0278 5.27739 31.9998C9.30539 27.9718 20.0001 28.2492 20.0001 28.2492C20.0001 28.2492 19.9987 38.6665 15.9987 42.6665C11.9987 46.6665 1.29739 46.6665 1.29739 46.6665Z" fill="#FFAC33"/>
                                        <path d="M11.9986 41.3332C14.9441 41.3332 17.3319 38.9454 17.3319 35.9998C17.3319 33.0543 14.9441 30.6665 11.9986 30.6665C9.0531 30.6665 6.66528 33.0543 6.66528 35.9998C6.66528 38.9454 9.0531 41.3332 11.9986 41.3332Z" fill="#FFCC4D"/>
                                        <path d="M47.9986 0C47.9986 0 34.6653 0 18.6653 13.3333C10.6653 20 10.6653 32 13.3319 34.6667C15.9986 37.3333 27.9986 37.3333 34.6653 29.3333C47.9986 13.3333 47.9986 0 47.9986 0Z" fill="#55ACEE"/>
                                        <path d="M35.9987 6.6665C33.8347 6.6665 31.9814 7.96117 31.144 9.81317C31.8134 9.5105 32.5507 9.33317 33.332 9.33317C36.2774 9.33317 38.6654 11.7212 38.6654 14.6665C38.6654 15.4478 38.488 16.1852 38.1867 16.8532C40.0387 16.0172 41.332 14.1638 41.332 11.9998C41.332 9.0545 38.944 6.6665 35.9987 6.6665Z" fill="black"/>
                                        <path d="M10.6667 37.3332C10.6667 37.3332 10.6667 31.9998 12.0001 30.6665C13.3334 29.3332 29.3347 16.0012 30.6667 17.3332C31.9987 18.6652 18.6654 34.6665 17.3321 35.9998C15.9987 37.3332 10.6667 37.3332 10.6667 37.3332Z" fill="#A0041E"/>
                                        </svg>';
                    $content[] = '</div>';
                    $content[] = '<div class="ays-chatgpt-progress-banner-text">';
                        $content[] = '<h2 class="ays-chatgpt-progress-banner-title">' . sprintf( __('Get the Pro Version of %s ChatGPT Assistant%s – 20%% OFF', 'ays-chatgpt-assistant'), '<a href="'. $ays_chatgpt_cta_button_link .'" target="_blank">', '</a>' ) . '</h2>';
                        $content[] = '<p class="ays-chatgpt-progress-banner-subtitle">' . __('Unlock advanced features + 30 day Money Back Guarantee', 'ays-chatgpt-assistant') . '</p>';
                    $content[] = '</div>';
                $content[] = '</div>';
                
                $content[] = '<div class="ays-chatgpt-progress-banner-center">';
                    $content[] = '<div class="ays-chatgpt-progress-banner-coupon">';
                        $content[] = '<div class="ays-chatgpt-progress-banner-coupon-box" onclick="chatgptCopyToClipboard(\'FREE2PRO20\')" title="' . __('Click to copy', 'ays-chatgpt-assistant') . '">';
                            $content[] = '<span class="ays-chatgpt-progress-banner-coupon-text">FREE2PRO20</span>';
                            $content[] = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" class="ays-chatgpt-progress-banner-copy-icon">';
                                $content[] = '<path d="M13.5 2.5H6.5C5.67 2.5 5 3.17 5 4V10C5 10.83 5.67 11.5 6.5 11.5H13.5C14.33 11.5 15 10.83 15 10V4C15 3.17 14.33 2.5 13.5 2.5ZM13.5 10H6.5V4H13.5V10ZM2.5 6.5V12.5C2.5 13.33 3.17 14 4 14H10V12.5H4V6.5H2.5Z" fill="white"/>';
                            $content[] = '</svg>';
                        $content[] = '</div>';
                    $content[] = '</div>';
                    
                    $content[] = '<div class="ays-chatgpt-progress-banner-progress">';
                        $content[] = '<p class="ays-chatgpt-progress-banner-progress-text">' . __('Only', 'ays-chatgpt-assistant') . ' <span id="remaining-licenses">' . $remaining_licenses . '</span> ' . __('of 50 discounted licenses left', 'ays-chatgpt-assistant') . '</p>';
                        $content[] = '<div class="ays-chatgpt-progress-banner-progress-bar">';
                            $content[] = '<div class="ays-chatgpt-progress-banner-progress-fill" id="progress-fill" style="width: ' . $progress_percentage . '%;"></div>';
                        $content[] = '</div>';
                    $content[] = '</div>';
                $content[] = '</div>';
                
                $content[] = '<div class="ays-chatgpt-progress-banner-right">';
                    $content[] = '<a href="'. $ays_chatgpt_cta_button_link .'" class="ays-chatgpt-progress-banner-upgrade" target="_blank">';
                    $content[] = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">';
                        $content[] = '<path d="M14.6392 6.956C14.5743 6.78222 14.4081 6.66667 14.2223 6.66667H8.85565L11.9512 0.648C12.0485 0.458667 11.9983 0.227111 11.8308 0.0955556C11.7499 0.0315556 11.6525 0 11.5556 0C11.4521 0 11.3485 0.0364444 11.2654 0.108L8.00009 2.928L1.48765 8.55244C1.3472 8.67378 1.29653 8.86978 1.36142 9.04356C1.42631 9.21733 1.59209 9.33333 1.77787 9.33333H7.14454L4.04898 15.352C3.95165 15.5413 4.00187 15.7729 4.16942 15.9044C4.25031 15.9684 4.34765 16 4.44453 16C4.54809 16 4.65165 15.9636 4.73476 15.892L8.00009 13.072L14.5125 7.44756C14.6534 7.32622 14.7036 7.13022 14.6392 6.956Z" fill="white"/>';
                    $content[] = '</svg>';
                     $content[] = ' ' . __('Upgrade Now', 'ays-chatgpt-assistant');
                    $content[] = '</a>';
                $content[] = '</div>';
            $content[] = '</div>';
            
            if( current_user_can( 'manage_options' ) ){
            $content[] = '<div id="ays-chatgpt-dismiss-buttons-content">';
                $content[] = '<form action="" method="POST" style="position: absolute; bottom: 0; right: 0; color: #fff;">';
                        $content[] = '<button class="btn btn-link ays-button" name="ays_chatgpt_sale_btn" style="color: darkgrey; font-size: 11px;">'. __( "Dismiss ad", 'ays-chatgpt-assistant' ) .'</button>';
                        $content[] = wp_nonce_field( CHATGPT_ASSISTANT_NAME . '-sale-banner' ,  CHATGPT_ASSISTANT_NAME . '-sale-banner' );
                $content[] = '</form>';
            $content[] = '</div>';
            }
        $content[] = '</div>';
        // Fox LMS Pro Banner Styles
        $content[] = '<style id="ays-chatgpt-progress-banner-styles-inline-css">';
        $content[] = '
            .ays-chatgpt-progress-banner-main {
                background: linear-gradient(135deg, #6344ED 0%, #8C2ABE 100%);
                padding: 20px 30px;
                border-radius: 16px;
                color: white;
                position: relative;
                margin: 20px 0;
                box-shadow: 0 8px 32px rgba(99, 68, 237, 0.3);
                border: 0;
            }
            .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-content {
                display: flex;
                align-items: center;
                justify-content: space-between;
                gap: 30px;
            }
            .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-left {
                display: flex;
                align-items: center;
                gap: 20px;
                flex: 1;
            }
            .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-center {
                display: flex;
                align-items: center;
                gap: 15px;
                flex: 1;
            }
            .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-right {
                display: flex;
                align-items: center;
                gap: 20px;
                flex-shrink: 0;
            }
            .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-icon {
                font-size: 32px;
                filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
            }
            .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-title {
                font-size: 21px;
                font-weight: 700;
                margin: 0 0 8px 0;
                line-height: 1.2;
                color: #fff;
            }
            .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-title a {
                text-decoration: underline;
                color: #fff;
            }
            .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-subtitle {
                font-size: 16px;
                margin: 0;
                opacity: 0.9;
                font-weight: 400;
            }
            .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-coupon {
                margin-bottom: 5px;
            }
            .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-coupon-box {
                border: 2px dotted rgba(255, 255, 255, 0.6);
                padding: 8px 16px;
                border-radius: 8px;
                background: rgba(255, 255, 255, 0.1);
                cursor: pointer;
                transition: all 0.3s ease;
                display: flex;
                align-items: center;
                gap: 8px;
                backdrop-filter: blur(10px);
            }
            .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-coupon-box:hover {
                background: rgba(255, 255, 255, 0.2);
                border-color: rgba(255, 255, 255, 0.8);
                transform: translateY(-1px);
            }
            .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-coupon-text {
                font-size: 16px;
                font-weight: 700;
                letter-spacing: 1px;
                color: #fff;
                font-family: monospace;
            }
            .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-copy-icon {
                opacity: 0.8;
                transition: opacity 0.3s ease;
            }
            .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-coupon-box:hover .ays-chatgpt-progress-banner-copy-icon {
                opacity: 1;
            }
            .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-progress {
                text-align: center;
                width: 100%;
            }
            .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-progress-text {
                font-size: 14px;
                margin: 0 0 10px 0;
                opacity: 0.9;
            }
            .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-progress-bar {
                width: 300px;
                height: 10px;
                background: rgba(255, 255, 255, 0.2);
                border-radius: 4px;
                overflow: hidden;
                margin: 0 auto;
            }
            .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-progress-fill {
                height: 100%;
                background: linear-gradient(90deg, #4ADE80 0%, #22C55E 100%);
                border-radius: 4px;
                transition: width 0.8s ease;
                width: 70%;
            }
            .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-upgrade {
                background: linear-gradient(135deg, #F59E0B 0%, #F97316 100%);
                color: white;
                border: none;
                padding: 12px 24px;
                border-radius: 8px;
                font-size: 16px;
                font-weight: 600;
                cursor: pointer;
                transition: all 0.3s ease;
                box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
                text-decoration: none;
                display: inline-flex;
                align-items: center;
                gap: 8px;
            }
            .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-upgrade:hover {
                transform: translateY(-2px);
                box-shadow: 0 6px 20px rgba(245, 158, 11, 0.6);
                text-decoration: none;
                color: white;
            }
            .ays-chatgpt-progress-banner-main .notice-dismiss:before {
                color: #fff;
            }
            /* Copy notification */
            .ays-chatgpt-copy-notification {
                position: fixed;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
                background: rgba(0, 0, 0, 0.8);
                color: white;
                padding: 12px 24px;
                border-radius: 8px;
                font-size: 14px;
                z-index: 10000;
                opacity: 0;
                transition: opacity 0.3s ease;
            }
            .ays-chatgpt-copy-notification.show {
                opacity: 1;
            }
            @media (max-width: 1400px) {
                .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-center {
                    flex-direction: column;
                }
            }
            @media (max-width: 1200px) {
                .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-content {
                    flex-direction: column;
                    gap: 20px;
                }
                .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-left {
                    width: 100%;
                    justify-content: center;
                    text-align: center;
                    flex-direction: column;
                }
                .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-center {
                    width: 100%;
                }
                .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-right {
                    width: 100%;
                    justify-content: center;
                }
            }
            @media (max-width: 768px) {
                #ays-chatgpt-progress-banner-main {
                    display: none !important;
                }
                .ays-chatgpt-progress-banner-main {
                    padding: 15px 20px;
                    margin: 15px 0;
                }
                
                .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-title {
                    font-size: 18px;
                }
                
                .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-subtitle {
                    font-size: 14px;
                }
                
                .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-progress-bar {
                    width: 100%;
                    max-width: 280px;
                }
                
                .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-upgrade {
                    padding: 10px 20px;
                    font-size: 14px;
                }
            }
            @media (max-width: 480px) {
                .ays-chatgpt-progress-banner-main {
                    padding: 12px 15px;
                }
                
                .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-coupon-text {
                    font-size: 14px;
                }
                
                .ays-chatgpt-progress-banner-main .ays-chatgpt-progress-banner-progress-bar {
                    max-width: 250px;
                }
            }
        ';
        $content[] = '</style>';
        $content = implode( '', $content );
        echo ($content);   
    }

    public function ays_chatgpt_gift_baner(){
        
        // if (isset($_POST['ays_chatgpt_gift_btn']) && (isset( $_POST[CHATGPT_ASSISTANT_NAME . '-gift-banner'] ) && wp_verify_nonce( $_POST[CHATGPT_ASSISTANT_NAME . '-gift-banner'], CHATGPT_ASSISTANT_NAME . '-gift-banner' )) && current_user_can( 'manage_options' )) {
        //     update_option('ays_chatgpt_gift_btn', 1);
        //     update_option('ays_chatgpt_gift_date', current_time( 'mysql' ));
        // }
    
        $ays_chatgpt_gift_date = get_option('ays_chatgpt_gift_date');

        $val = 60*60*24*5;

        $current_date = current_time( 'mysql' );
        $date_diff = strtotime($current_date) - intval(strtotime($ays_chatgpt_gift_date)) ;
        
        $days_diff = $date_diff / $val;
    
        if(intval($days_diff) > 0 ){
            update_option('ays_chatgpt_gift_btn', 0);
        }
    
        $ays_chatgpt_maker_flag = intval(get_option('ays_chatgpt_gift_btn'));
        if( $ays_chatgpt_maker_flag == 0 ){
            // phpcs:ignore WordPress.Security.NonceVerification.Recommended
            if ( isset( $_GET['page'] ) && strpos( sanitize_text_field( wp_unslash( $_GET['page'] ) ), CHATGPT_ASSISTANT_NAME ) !== false ) {
				$this->ays_chatgpt_gift_message($ays_chatgpt_maker_flag);
            }
        }
    }

    // Gift banner
    public function ays_chatgpt_gift_message($ishmar){
        if($ishmar == 0 ){
            $content = array();

            $content[] = '<div id="ays-chatgpt-dicount-month-main" class="notice notice-success is-dismissible ays_chatgpt_dicount_info" style="padding-top:10px;padding-bottom:10px">';
                $content[] = '<div id="ays-chatgpt-dicount-month" class="ays_chatgpt_dicount_month">';
                    $content[] = '<a href="' . admin_url('admin.php?page='.$this->plugin_name.'-gift') . '" target="_blank" class="ays-chatgpt-sale-banner-link" ><img src="' . esc_attr(CHATGPT_ASSISTANT_ADMIN_URL) . '/images/icons/chatgpt-icon.png"></a>';

                    $content[] = '<div class="ays-chatgpt-dicount-wrap-box">';

                        $content[] = '<strong style="font-weight:bold;width:100%;font-size:20px">';
                            $content[] = 'Get the <a style="color:#1FAB90;" href="' . admin_url('admin.php?page='.$this->plugin_name.'-gift') . '" target="_blank">PRO Version</a> for free.';
                        $content[] = '</strong>';
                            
                    $content[] = '</div>';

                    $content[] = '<div class="ays-chatgpt-dicount-wrap-box ays-buy-now-button-box" style="width:20%">';
                        $content[] = '<a href="' . admin_url('admin.php?page='.$this->plugin_name.'-gift') . '" class="button button-primary ays-button" id="ays-button-top-buy-now" target="_blank">' . __( 'Learn more!', "ays-chatgpt-assistant" ) . '</a>';
                    $content[] = '</div>';

                $content[] = '</div>';

                $content[] = '<div style="position: absolute;right: 0;bottom: 1px;" class="ays-chatgpt-dismiss-buttons-container-for-form">';
                    $content[] = '<form action="" method="POST">';
                        $content[] = '<div id="ays-chatgpt-dismiss-buttons-content">';
                            if (current_user_can( 'manage_options' )) {
                                $content[] = '<button class="btn btn-link ays-button" name="ays_chatgpt_gift_btn" style="height: 32px; margin-left: 0;padding-left: 0; color: #979797;">Dismiss ad</button>';
                                $content[] = wp_nonce_field( CHATGPT_ASSISTANT_NAME . '-gift-banner' ,  CHATGPT_ASSISTANT_NAME . '-gift-banner' );
                            }
                        $content[] = '</div>';
                    $content[] = '</form>';
                $content[] = '</div>';

            $content[] = '</div>';

            $content = implode( '', $content );
            echo html_entity_decode(esc_html( $content ));// phpcs:ignore
        }
    }

    // 30% Sale Emma
    public function ays_chatgpt_sale_message_30_emma($ishmar){
        if($ishmar == 0 ){
            $content = array();
            $content[] = '<div id="ays-chatgpt-new-mega-bundle-dicount-month-main-2024" class="notice notice-success is-dismissible ays_chatgpt_dicount_info">';
                $content[] = '<div id="ays-chatgpt-dicount-month" class="ays_chatgpt_dicount_month">';

                    $content[] = '<div class="ays-chatgpt-discount-box-sale-image"></div>';
                    $content[] = '<div class="ays-chatgpt-dicount-wrap-box ays-chatgpt-dicount-wrap-text-box">';

                        $content[] = '<div class="ays-chatgpt-dicount-wrap-text-box-texts">';
                            $content[] = '<div>
                                            <a href="https://ays-pro.com/wordpress/chatgpt-assistant?utm_source=dashboard&utm_medium=gpt-free&utm_campaign=sale-banner" target="_blank" style="color:#30499B;">
                                            <span class="ays-chatgpt-new-mega-bundle-limited-text">Limited</span> Offer for ChatGPT Assistant </a> <br> 
                                          </div>';
                        $content[] = '</div>';

                        $content[] = '<div style="font-size: 17px;">';
                            $content[] = '<img style="width: 24px;height: 24px;" src="' . esc_attr(CHATGPT_ASSISTANT_ADMIN_URL) . '/images/icons/guarantee-new.png">';
                            $content[] = '<span style="padding-left: 4px; font-size: 14px; font-weight: 600;"> 30 Day Money Back Guarantee</span>';
                            
                        $content[] = '</div>';

                       

                        $content[] = '<div style="position: absolute;right: 10px;bottom: 1px;" class="ays-chatgpt-dismiss-buttons-container-for-chatgpt">';

                            $content[] = '<form action="" method="POST">';
                                $content[] = '<div id="ays-chatgpt-dismiss-buttons-content">';
                                    if( current_user_can( 'manage_options' ) ){
                                        $content[] = '<button class="btn btn-link ays-button" name="ays_chatgpt_sale_btn" style="height: 32px; margin-left: 0;padding-left: 0; color: #30499B;
                                        ">Dismiss ad</button>';
                                        $content[] = wp_nonce_field( $this->plugin_name . '-sale-banner' ,  $this->plugin_name . '-sale-banner' );
                                    }
                                $content[] = '</div>';
                            $content[] = '</form>';
                            
                        $content[] = '</div>';

                    $content[] = '</div>';

                    $content[] = '<div class="ays-chatgpt-dicount-wrap-box ays-chatgpt-dicount-wrap-countdown-box">';

                        $content[] = '<div id="ays-chatgpt-countdown-main-container">';
                            $content[] = '<div class="ays-chatgpt-countdown-container">';

                                $content[] = '<div id="ays-chatgpt-countdown">';

                                    $content[] = '<div style="font-weight: 500;">';
                                        $content[] = __( "Offer ends in:", "ays-chatgpt-assistant" );
                                    $content[] = '</div>';

                                    $content[] = '<ul>';
                                        $content[] = '<li><span id="ays-chatgpt-countdown-days"></span>days</li>';
                                        $content[] = '<li><span id="ays-chatgpt-countdown-hours"></span>Hours</li>';
                                        $content[] = '<li><span id="ays-chatgpt-countdown-minutes"></span>Minutes</li>';
                                        $content[] = '<li><span id="ays-chatgpt-countdown-seconds"></span>Seconds</li>';
                                    $content[] = '</ul>';
                                $content[] = '</div>';

                                $content[] = '<div id="ays-chatgpt-countdown-content" class="emoji">';
                                    $content[] = '<span>🚀</span>';
                                    $content[] = '<span>⌛</span>';
                                    $content[] = '<span>🔥</span>';
                                    $content[] = '<span>💣</span>';
                                $content[] = '</div>';

                            $content[] = '</div>';
                        $content[] = '</div>';
                            
                    $content[] = '</div>';

                    $content[] = '<div class="ays-chatgpt-dicount-wrap-box ays-chatgpt-dicount-wrap-button-box">';
                        $content[] = '<a href="https://ays-pro.com/wordpress/chatgpt-assistant?utm_source=dashboard&utm_medium=gpt-free&utm_campaign=sale-banner" class="button button-primary ays-button" id="ays-button-top-buy-now" target="_blank">' . __( 'Buy Now !', 'ays-chatgpt-assistant' ) . '</a>';
                        $content[] = '<span >One-time payment</span>';
                    $content[] = '</div>';
                $content[] = '</div>';
            $content[] = '</div>';

            $content = implode( '', $content );
            echo html_entity_decode(esc_html( $content ));// phpcs:ignore
        }        
    }

	// Self 20% sale
    public static function ays_chatgpt_sale_message20($ishmar){
        if($ishmar == 0 ){
            $content = array();

            $content[] = '<div id="ays-chatgpt-dicount-month-main" class="notice notice-success is-dismissible ays_chatgpt_dicount_info">';
                $content[] = '<div id="ays-chatgpt-dicount-month" class="ays_chatgpt_dicount_month">';
                    // $content[] = '<a href="https://ays-pro.com/wordpress/chatgpt-assistant" target="_blank" class="ays-chatgpt-sale-banner-link"><img src="' . CHATGPT_ASSISTANT_ADMIN_URL . '/images/ays_chatgpt_logo.png"></a>';

                    $content[] = '<div class="ays-chatgpt-dicount-wrap-box ays-chatgpt-dicount-wrap-text-box">';

                        $content[] = '<div class="ays-chatgpt-dicount-sale-name-discount-box">';
							$content[] = '<span class="ays-chatgpt-new-chatgpt-pro-title">';
                            $content[] = sprintf(
                                            /* translators: %s is the URL for the ChatGPT Assistant */
                                            __( "<span><a href='%s' target='_blank' style='color:#ffffff; text-decoration: underline;'>ChatGPT Assistant</a></span>", "ays-chatgpt-assistant" ),
                                            esc_url("https://ays-pro.com/wordpress/chatgpt-assistant?utm_source=dashboard&utm_medium=gpt-free&utm_campaign=sale-banner" . CHATGPT_ASSISTANT_VERSION)
                                        );
							$content[] = '</span>';
							$content[] = '<div>';
								$content[] = '<img src="' . CHATGPT_ASSISTANT_ADMIN_URL . '/images/ays-chatgpt-banner-sale-30.svg" style="width: 70px;">';
							$content[] = '</div>';
						$content[] = '</div>';

                        $content[] = '<span class="ays-chatgpt-new-chatgpt-pro-desc">';
							$content[] = '<img class="ays-chatgpt-new-chatgpt-pro-guaranteeicon" src="' . CHATGPT_ASSISTANT_ADMIN_URL . '/images/chatgpt-assistant-guaranteeicon.webp" style="width: 30px;">';
							$content[] = __( "30 Days Money Back Guarantee", 'ays-chatgpt-assistant' );
						$content[] = '</span>';
     
                        $content[] = '<div style="position: absolute;right: 10px;bottom: 1px;" class="ays-chatgpt-dismiss-buttons-container-for-chatgpt">';
                            $content[] = '<form action="" method="POST">';
                                $content[] = '<div id="ays-chatgpt-dismiss-buttons-content">';
                                    if (current_user_can( 'manage_options' )) {
                                        $content[] = '<button class="btn btn-link ays-button" name="ays_chatgpt_sale_btn" style="height: 32px; margin-left: 0;padding-left: 0">Dismiss ad</button>';
                                        $content[] = wp_nonce_field( CHATGPT_ASSISTANT_NAME . '-sale-banner' ,  CHATGPT_ASSISTANT_NAME . '-sale-banner' );
                                    }
                                $content[] = '</div>';
                            $content[] = '</form>';
                        $content[] = '</div>';

                    $content[] = '</div>';

                    $content[] = '<div class="ays-chatgpt-dicount-wrap-box ays-chatgpt-dicount-wrap-countdown-box">';

                        $content[] = '<div id="ays-chatgpt-countdown-main-container">';
                            $content[] = '<div class="ays-chatgpt-countdown-container">';
                                $content[] = '<div id="ays-chatgpt-countdown" style="display: block;">';
                                    $content[] = __( "Offer ends in:", 'ays-chatgpt-assistant' );
                                    
                                    $content[] = '<ul style="padding: 0">';
                                        $content[] = '<li><span id="ays-chatgpt-countdown-days">0</span>' . __( 'Days', 'ays-chatgpt-assistant' ) . '</li>';
                                        $content[] = '<li><span id="ays-chatgpt-countdown-hours">0</span>' . __( 'Hours', 'ays-chatgpt-assistant' ) . '</li>';
                                        $content[] = '<li><span id="ays-chatgpt-countdown-minutes">0</span>' . __( 'Minutes', 'ays-chatgpt-assistant' ) . '</li>';
                                        $content[] = '<li><span id="ays-chatgpt-countdown-seconds">0</span>' . __( 'Seconds', 'ays-chatgpt-assistant' ) . '</li>';
                                    $content[] = '</ul>';
                                $content[] = '</div>';

                                $content[] = '<div id="ays-chatgpt-countdown-content" class="emoji" style="display: none;">';
                                    $content[] = '<span>🚀</span>';
                                    $content[] = '<span>⌛</span>';
                                    $content[] = '<span>🔥</span>';
                                    $content[] = '<span>💣</span>';
                                $content[] = '</div>';
                            $content[] = '</div>';
                        $content[] = '</div>';
                            
                    $content[] = '</div>';

                    $content[] = '<div class="ays-chatgpt-dicount-wrap-box ays-chatgpt-dicount-wrap-button-box">';
                        $content[] = '<a href="https://ays-pro.com/wordpress/chatgpt-assistant?utm_source=dashboard&utm_medium=gpt-free&utm_campaign=sale-banner'.CHATGPT_ASSISTANT_VERSION.'" class="button button-primary ays-button" id="ays-button-top-buy-now" target="_blank" style="" >' . __( 'Buy Now', 'ays-chatgpt-assistant' ) . '</a>';
                        $content[] = '<span class="ays-chatgpt-dicount-one-time-text">';
                            $content[] = __( "One-time payment", 'ays-chatgpt-assistant' );
                        $content[] = '</span>';
                    $content[] = '</div>';

                $content[] = '</div>';

            $content[] = '</div>';

            $content = implode( '', $content );
            echo $content;// phpcs:ignore
        }
    }

    // Helloween banner
    public static function ays_chatgpt_helloween_message($ishmar){
        if($ishmar == 0 ){
            $content = array();

            $content[] = '<div id="ays-chatgpt-dicount-month-main-helloween" class="notice notice-success is-dismissible ays_chatgpt_dicount_info">';
                $content[] = '<div id="ays-chatgpt-dicount-month-helloween" class="ays_chatgpt_dicount_month_helloween">';
                    $content[] = '<div class="ays-chatgpt-dicount-wrap-box-helloween-limited">';

                        $content[] = '<p>';
                            $content[] = __( "Limited Time 
                            <span class='ays-chatgpt-dicount-wrap-color-helloween' style='color:#b2ff00;'>30%</span> 
                            <span>
                                SALE on
                            </span> 
                            <br>
                            <span style='' class='ays-chatgpt-helloween-bundle'>
                                <a href='https://ays-pro.com/wordpress/chatgpt-assistant?utm_source=dashboard&utm_medium=gpt-free&utm_campaign=halloween-sale-banner' target='_blank' class='ays-chatgpt-dicount-wrap-color-helloween ays-chatgpt-dicount-wrap-text-decoration-helloween' style='display:block; color:#b2ff00;margin-right:6px;'>
                                    ChatGPT Assistant
                                </a>
                            </span>", 'ays-chatgpt-assistant' );
                        $content[] = '</p>';
                        $content[] = '<p>';
                                $content[] = __( "Hurry up! 
                                                <a href='https://ays-pro.com/wordpress/chatgpt-assistant?utm_source=dashboard&utm_medium=gpt-free&utm_campaign=halloween-sale-banner' target='_blank' style='color:#ffc700;'>
                                                    Check it out!
                                                </a>", 'ays-chatgpt-assistant' );
                        $content[] = '</p>';
                            
                    $content[] = '</div>';

                    
                    $content[] = '<div class="ays-chatgpt-helloween-bundle-buy-now-timer">';
                        $content[] = '<div class="ays-chatgpt-dicount-wrap-box-helloween-timer">';
                            $content[] = '<div id="ays-chatgpt-countdown-main-container" class="ays-chatgpt-countdown-main-container-helloween">';
                                $content[] = '<div class="ays-chatgpt-countdown-container-helloween">';
                                    $content[] = '<div id="ays-chatgpt-countdown">';
                                        $content[] = '<ul>';
                                            $content[] = '<li><p><span id="ays-chatgpt-countdown-days"></span><span>days</span></p></li>';
                                            $content[] = '<li><p><span id="ays-chatgpt-countdown-hours"></span><span>Hours</span></p></li>';
                                            $content[] = '<li><p><span id="ays-chatgpt-countdown-minutes"></span><span>Mins</span></p></li>';
                                            $content[] = '<li><p><span id="ays-chatgpt-countdown-seconds"></span><span>Secs</span></p></li>';
                                        $content[] = '</ul>';
                                    $content[] = '</div>';

                                    $content[] = '<div id="ays-chatgpt-countdown-content" class="emoji">';
                                        $content[] = '<span>🚀</span>';
                                        $content[] = '<span>⌛</span>';
                                        $content[] = '<span>🔥</span>';
                                        $content[] = '<span>💣</span>';
                                    $content[] = '</div>';

                                $content[] = '</div>';

                            $content[] = '</div>';
                                
                        $content[] = '</div>';
                        $content[] = '<div class="ays-chatgpt-dicount-wrap-box ays-buy-now-button-box-helloween">';
                            $content[] = '<a href="https://ays-pro.com/wordpress/chatgpt-assistant?utm_source=dashboard&utm_medium=gpt-free&utm_campaign=halloween-sale-banner" class="button button-primary ays-buy-now-button-helloween" id="ays-button-top-buy-now-helloween" target="_blank" style="" >' . __( 'Buy Now !', 'ays-chatgpt-assistant' ) . '</a>';
                        $content[] = '</div>';
                    $content[] = '</div>';

                $content[] = '</div>';

                $content[] = '<div style="position: absolute;right: 0;bottom: 1px;"  class="ays-chatgpt-dismiss-buttons-container-for-form-helloween">';
                    $content[] = '<form action="" method="POST">';
                        $content[] = '<div id="ays-chatgpt-dismiss-buttons-content-helloween">';
                        if( current_user_can( 'manage_options' ) ){
                            $content[] = '<button class="btn btn-link ays-button-helloween" name="ays_chatgpt_sale_btn" style="height: 32px; margin-left: 0;padding-left: 0">Dismiss ad</button>';
                            $content[] = wp_nonce_field( CHATGPT_ASSISTANT_NAME . '-sale-banner' ,  CHATGPT_ASSISTANT_NAME . '-sale-banner' );
                        }
                        $content[] = '</div>';
                    $content[] = '</form>';

                $content[] = '</div>';
                // $content[] = '<button type="button" class="notice-dismiss">';
                // $content[] = '</button>';
            $content[] = '</div>';

            $content = implode( '', $content );

            echo $content;// phpcs:ignore
        }
    }

    // Christmas Top Banner 2024
    public function ays_chatgpt_christmas_message_2024($ishmar){
        if($ishmar == 0 ){
            $content = array();
            $content[] = '<div id="ays-chatgpt-christmas-top-bundle-dicount-month-main" class="notice notice-success is-dismissible ays_chatgpt_dicount_info">';
                $content[] = '<div id="ays-chatgpt-dicount-month" class="ays_chatgpt_dicount_month">';
                    $content[] = '<div class="ays-chatgpt-dicount-wrap-box ays-chatgpt-dicount-wrap-countdown-box">';
                        $content[] = '<div id="ays-chatgpt-countdown-main-container">';
                            $content[] = '<div class="ays-chatgpt-countdown-container">';
                                $content[] = '<div id="ays-chatgpt-countdown">';
                                    $content[] = '<div>';
                                        $content[] = __( "Offer ends in:", 'ays-chatgpt-assistant' );
                                    $content[] = '</div>';
                                    $content[] = '<ul style="padding-left: 0;">';
                                        $content[] = '<li><span id="ays-chatgpt-countdown-days"></span>'. __( "Days", 'ays-chatgpt-assistant' ) .'</li>';
                                        $content[] = '<li><span id="ays-chatgpt-countdown-hours"></span>'. __( "Hours", 'ays-chatgpt-assistant' ) .'</li>';
                                        $content[] = '<li><span id="ays-chatgpt-countdown-minutes"></span>'. __( "Minutes", 'ays-chatgpt-assistant' ) .'</li>';
                                        $content[] = '<li><span id="ays-chatgpt-countdown-seconds"></span>'. __( "Seconds", 'ays-chatgpt-assistant' ) .'</li>';
                                    $content[] = '</ul>';
                                $content[] = '</div>';
                                $content[] = '<div id="ays-chatgpt-countdown-content" class="emoji">';
                                    $content[] = '<span>🚀</span>';
                                    $content[] = '<span>⌛</span>';
                                    $content[] = '<span>🔥</span>';
                                    $content[] = '<span>💣</span>';
                                $content[] = '</div>';
                            $content[] = '</div>';
                        $content[] = '</div>';
                            
                    $content[] = '</div>';
                    $content[] = '<div class="ays-chatgpt-dicount-wrap-box ays-chatgpt-dicount-wrap-text-box">';
                        $content[] = '<div>';
                            $content[] = '<span class="ays-chatgpt-christmas-top-bundle-title">';
                            $content[] = sprintf(
                                            /* translators: %s is the URL for the ChatGPT Assistant Christmas Sale */
                                            __( "<span><a href='%s' target='_blank' style='color:#ffffff; text-decoration: underline;'>ChatGPT Assistant</a></span>", "ays-chatgpt-assistant" ),
                                            esc_url("https://ays-pro.com/wordpress/chatgpt-assistant?utm_source=dashboard&utm_medium=gpt-free&utm_campaign=sale-banner" . CHATGPT_ASSISTANT_VERSION)
                                        );
                            $content[] = '</span>';
                            $content[] = '</br>';
                            $content[] = '<span class="ays-chatgpt-christmas-top-bundle-desc">';
                                $content[] = '<a class="ays-chatgpt-christmas-top-bundle-desc" href="https://ays-pro.com/wordpress/chatgpt-assistant?utm_source=dashboard&utm_medium=chatgpt-free&utm_campaign=christmas-sale-banner'.CHATGPT_ASSISTANT_VERSION.'" class="ays-chatgpt-christmas-top-bundle-title-link" target="_blank">';
                                    $content[] = __( "20% Extra OFF", 'ays-chatgpt-assistant' );
                                $content[] = '</a>';
                            $content[] = '</span>';
                        $content[] = '</div>';
                        $content[] = '<div style="position: absolute;right: 10px;bottom: 1px;" class="ays-chatgpt-dismiss-buttons-container-for-form">';
                            $content[] = '<form action="" method="POST">';
                                $content[] = '<div id="ays-chatgpt-dismiss-buttons-content">';
                                if( current_user_can( 'manage_options' ) ){
                                    $content[] = '<button class="btn btn-link ays-button" name="ays_chatgpt_sale_btn" style="height: 32px; margin-left: 0;padding-left: 0">'. __( "Dismiss ad", 'ays-chatgpt-assistant' ) .'</button>';
                                    $content[] = wp_nonce_field( CHATGPT_ASSISTANT_NAME . '-sale-banner' ,  CHATGPT_ASSISTANT_NAME . '-sale-banner' );
                                }
                                $content[] = '</div>';
                            $content[] = '</form>';
                            
                        $content[] = '</div>';
                    $content[] = '</div>';
                    $content[] = '<div class="ays-chatgpt-dicount-wrap-box ays-chatgpt-christmas-top-bundle-coupon-text-box">';
                        $content[] = '<div class="ays-chatgpt-christmas-top-bundle-coupon-row">';
                            $content[] = 'xmas20off';
                        $content[] = '</div>';
                        $content[] = '<div class="ays-chatgpt-christmas-top-bundle-text-row">';
                            $content[] = __( '20% Extra Discount Coupon', 'ays-chatgpt-assistant' );
                        $content[] = '</div>';
                    $content[] = '</div>';
                    $content[] = '<div class="ays-chatgpt-dicount-wrap-box ays-chatgpt-dicount-wrap-button-box">';
                        $content[] = '<a href="https://ays-pro.com/wordpress/chatgpt-assistant?utm_source=dashboard&utm_medium=chatgpt-free&utm_campaign=christmas-sale-banner'.CHATGPT_ASSISTANT_VERSION.'" class="button button-primary ays-button" id="ays-button-top-buy-now" target="_blank">' . __( 'Get Your Deal', 'ays-chatgpt-assistant' ) . '</a>';
                        $content[] = '<span class="ays-chatgpt-dicount-one-time-text">';
                            $content[] = __( "One-time payment", 'ays-chatgpt-assistant' );
                        $content[] = '</span>';
                    $content[] = '</div>';
                $content[] = '</div>';
            $content[] = '</div>';
            $content = implode( '', $content );
            echo esc_html($content);
        }
    }

    //new 2025 bundle
    public function ays_chatgpt_new_bundle_message_2025($ishmar){
        if($ishmar == 0 ){
            $content = array();

            $content[] = '<div id="ays-chatgpt-new-bundle-2025-dicount-month-main" class="notice notice-success is-dismissible ays_chatgpt_dicount_info">';
                $content[] = '<div id="ays-chatgpt-dicount-month" class="ays_chatgpt_dicount_month">';

                    $content[] = '<div class="ays-chatgpt-dicount-wrap-box ays-chatgpt-dicount-wrap-text-box">';
                        $content[] = '<div>';

                            $content[] = '<span class="ays-chatgpt-new-bundle-2025-title">';
                            
                                $content[] = sprintf(
                                            /* translators: %s is the URL for the ChatGPT Assistant */
                                            __( "<span><a href='%s' target='_blank' style='color:#ffffff; text-decoration: underline;'>ChatGPT Assistant</a></span>", "ays-chatgpt-assistant" ),
                                            esc_url("https://ays-pro.com/wordpress/chatgpt-assistant?utm_source=dashboard&utm_medium=gpt-free&utm_campaign=sale-banner" . CHATGPT_ASSISTANT_VERSION)
                                        );
                               
                            $content[] = '</span>';

                            $content[] = '</br>';

                            $content[] = '<span class="ays-chatgpt-new-bundle-2025-desc">';
                                $content[] = __( "30 Day Money Back Guarantee", 'ays-chatgpt-assistant' );
                            $content[] = '</span>';
                        $content[] = '</div>';
                        $content[] = '<div>';
                            $content[] = '<img class="ays-chatgpt-new-bundle-guaranteeicon" src="' . CHATGPT_ASSISTANT_ADMIN_URL . '/images/ays-chatgpt-new-bundle-2025-discount.svg" style="width: 70px; margin-left:10px;">';
                        $content[] = '</div>';
                        $content[] = '<div style="position: absolute;right: 10px;bottom: 1px;" class="ays-chatgpt-dismiss-buttons-container-for-form">';

                            $content[] = '<form action="" method="POST">';
                                $content[] = '<div id="ays-chatgpt-dismiss-buttons-content">';
                                if( current_user_can( 'manage_options' ) ){
                                    $content[] = '<button class="btn btn-link ays-button" name="ays_chatgpt_sale_btn" style="height: 32px; margin-left: 0;padding-left: 0">'. __( "Dismiss ad", 'ays-chatgpt-assistant' ) .'</button>';
                                    $content[] = wp_nonce_field( CHATGPT_ASSISTANT_NAME . '-sale-banner' ,  CHATGPT_ASSISTANT_NAME . '-sale-banner' );
                                }
                                $content[] = '</div>';
                            $content[] = '</form>';
                            
                        $content[] = '</div>';

                    $content[] = '</div>';

                    $content[] = '<div class="ays-chatgpt-dicount-wrap-box ays-chatgpt-dicount-wrap-countdown-box">';

                        $content[] = '<div id="ays-chatgpt-countdown-main-container">';
                            $content[] = '<div class="ays-chatgpt-countdown-container">';

                                $content[] = '<div id="ays-chatgpt-countdown">';

                                    $content[] = '<ul>';
                                        $content[] = '<li><span id="ays-chatgpt-countdown-days"></span>'. __( "Days", 'ays-chatgpt-assistant' ) .'</li>';
                                        $content[] = '<li><span id="ays-chatgpt-countdown-hours"></span>'. __( "Hours", 'ays-chatgpt-assistant' ) .'</li>';
                                        $content[] = '<li><span id="ays-chatgpt-countdown-minutes"></span>'. __( "Minutes", 'ays-chatgpt-assistant' ) .'</li>';
                                        $content[] = '<li><span id="ays-chatgpt-countdown-seconds"></span>'. __( "Seconds", 'ays-chatgpt-assistant' ) .'</li>';
                                    $content[] = '</ul>';
                                $content[] = '</div>';

                                $content[] = '<div id="ays-chatgpt-countdown-content" class="emoji">';
                                    $content[] = '<span></span>';
                                    $content[] = '<span></span>';
                                    $content[] = '<span></span>';
                                    $content[] = '<span></span>';
                                $content[] = '</div>';

                            $content[] = '</div>';
                        $content[] = '</div>';
                            
                    $content[] = '</div>';
                    $content[] = '<div class="ays-chatgpt-dicount-wrap-box ays-chatgpt-dicount-wrap-coupon-text-box">';
                        $content[] = '<div class="ays-chatgpt-dicount-wrap-coupon-row">';
                            $content[] = 'freetopro10off';
                        $content[] = '</div>';
                        $content[] = '<div class="ays-chatgpt-dicount-wrap-text-row">';
                            $content[] = __( '10% extra coupon', 'ays-chatgpt-assistant' );
                        $content[] = '</div>';
                    $content[] = '</div>';
                    $content[] = '<div class="ays-chatgpt-dicount-wrap-box ays-chatgpt-dicount-wrap-button-box">';
                        $content[] = '<a href="https://ays-pro.com/wordpress/chatgpt-assistant?utm_source=dashboard&utm_medium=gpt-free&utm_campaign=sale-banner'.CHATGPT_ASSISTANT_VERSION.'" class="button button-primary ays-button" id="ays-button-top-buy-now" target="_blank" style="" >' . __( 'Buy Now', 'ays-chatgpt-assistant' ) . '</a>';
                        $content[] = '<span class="ays-chatgpt-dicount-one-time-text">';
                            $content[] = __( "One-time payment", 'ays-chatgpt-assistant' );
                        $content[] = '</span>';
                    $content[] = '</div>';
                $content[] = '</div>';
            $content[] = '</div>';

            $content = implode( '', $content );
            echo wp_kses_post($content);
        }
    }

    public function ays_chatgpt_new_business_bundle($ishmar){
        $content = array();

	    $date = time() + (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS);
	    $now_date = date('M d, Y H:i:s', $date);

	    $chatgpt_banner_date = strtotime( $this->ays_chatgpt_update_banner_time() );

	    $diff = $chatgpt_banner_date - $date;

	    $style_attr = '';
	    if( $diff < 0 ){
	        $style_attr = 'style="display:none;"';
	    }

	    $chatgpt_cta_button_link = esc_url( 'https://ays-pro.com/business-bundle?utm_source=dashboard&utm_medium=gpt-free&utm_campaign=business-bundle-sale-banner-' . CHATGPT_ASSISTANT_VERSION );

	    $content[] = '<div id="ays-chatgpt-new-mega-bundle-dicount-month-main" class="ays-chatgpt-admin-notice notice notice-success is-dismissible ays_chatgpt_dicount_info">';
	        $content[] = '<div id="ays-chatgpt-dicount-month" class="ays_chatgpt_dicount_month">';

	            $content[] = '<div class="ays-chatgpt-dicount-wrap-box ays-chatgpt-dicount-wrap-text-box">';
	                $content[] = '<div>';
	                    $content[] = '<div class="ays-chatgpt-dicount-logo-box">';
	                        $content[] = '<a href="' . $chatgpt_cta_button_link . '" target="_blank" class="ays-chatgpt-sale-banner-link"><img src="' . CHATGPT_ASSISTANT_ADMIN_URL . '/images/mega_bundle_logo_box.webp"></a>';

	                        $content[] = '<div>';
	                            $content[] = '<span class="ays-chatgpt-new-mega-bundle-title">';
	                                $content[] = sprintf(
	                                /* translators: 1: opening link wrapper with <a> tag, 2: closing </a> tag */
	                                __( '%1$s Business Bundle %2$s', 'ays-chatgpt-assistant' ),
	                                '<span style="display:inline-block; margin-right:5px;"><a href="' . esc_url( $chatgpt_cta_button_link ) . '" target="_blank" rel="noopener noreferrer" style="color:#ffffff !important; text-decoration: underline;">',
	                                '</a></span>'
	                            );
	                            $content[] = '</span>';
	                            $content[] = '</br>';
	                            $content[] = '<span class="ays-chatgpt-new-mega-bundle-desc">';
	                                $content[] = __( "30 Day Money Back Guarantee", 'ays-chatgpt-assistant' );
	                            $content[] = '</span>';
	                        $content[] = '</div>';

	                        $content[] = '<div class="ays-chatgpt-new-mega-bundle-title-icon-row" style="display: inline-block;">';
	                            $content[] = '<img src="' . CHATGPT_ASSISTANT_ADMIN_URL . '/images/ays-chatgpt-banner-50.svg" class="ays-chatgpt-new-mega-bundle-mobile-image-display-none" style="width: 70px;">';
	                        $content[] = '</div>';

	                    $content[] = '</div>';

	                    $content[] = '<div class="ays-chatgpt-new-mega-bundle-mobile-image-display-block display_none">';
	                        $content[] = '<img src="' . CHATGPT_ASSISTANT_ADMIN_URL . '/images/ays-chatgpt-banner-50.svg" style="width: 70px;">';
	                    $content[] = '</div>';
	                $content[] = '</div>';

	                $content[] = '<div style="position: absolute;right: 10px;bottom: 1px;" class="ays-chatgpt-dismiss-buttons-container-for-form">';

	                    $content[] = '<form action="" method="POST">';
	                        $content[] = '<div id="ays-chatgpt-dismiss-buttons-content">';
	                        if( current_user_can( 'manage_options' ) ){
	                            $content[] = '<button class="btn btn-link ays-button" name="ays_chatgpt_sale_btn" style="height: 32px; margin-left: 0;padding-left: 0">'. __( "Dismiss ad", 'ays-chatgpt-assistant' ) .'</button>';
	                            $content[] = wp_nonce_field( CHATGPT_ASSISTANT_NAME . '-sale-banner' ,  CHATGPT_ASSISTANT_NAME . '-sale-banner' );
	                        }
	                        $content[] = '</div>';
	                    $content[] = '</form>';
	                    
	                $content[] = '</div>';

	            $content[] = '</div>';

	            $content[] = '<div class="ays-chatgpt-dicount-wrap-box ays-chatgpt-dicount-wrap-countdown-box">';

	                $content[] = '<div id="ays-chatgpt-maker-countdown-main-container">';
	                    $content[] = '<div class="ays-chatgpt-maker-countdown-container">';

	                        $content[] = '<div ' . $style_attr . ' id="ays-chatgpt-countdown">';

	                            $content[] = '<ul>';

	                            $content[] = '<li><span id="ays-chatgpt-countdown-days"></span></li>';
	                                $content[] = '<li><span id="ays-chatgpt-countdown-hours"></span></li>';
	                                $content[] = '<li><span id="ays-chatgpt-countdown-minutes"></span></li>';
	                                $content[] = '<li><span id="ays-chatgpt-countdown-seconds"></span></li>';
	                            $content[] = '</ul>';
	                        $content[] = '</div>';

	                        $content[] = '<div id="ays-chatgpt-countdown-content" class="emoji">';
	                        $content[] = '</div>';

	                    $content[] = '</div>';
	                $content[] = '</div>';
	                    
	            $content[] = '</div>';

	            $content[] = '<div class="ays-chatgpt-dicount-wrap-box ays-chatgpt-dicount-wrap-button-box">';
	                $content[] = '<a href="'. $chatgpt_cta_button_link .'" class="button button-primary ays-button" id="ays-button-top-buy-now" target="_blank">' . __( 'Buy Now', 'ays-chatgpt-assistant' ) . '</a>';
	                $content[] = '<span class="ays-chatgpt-dicount-one-time-text">';
	                    $content[] = __( "One-time payment", 'ays-chatgpt-assistant' );
	                $content[] = '</span>';
	            $content[] = '</div>';
	        $content[] = '</div>';
	    $content[] = '</div>';

	    // /* New Mega Bundle Banner Quiz | Start */
	    $content[] = '<style id="ays-chatgpt-mega-bundle-styles-inline-css">';
	    $content[] = '
	    div#ays-chatgpt-new-mega-bundle-dicount-month-main{border:0;background:#fff;border-radius:20px;box-shadow:unset;position:relative;z-index:1;min-height:80px}div#ays-chatgpt-new-mega-bundle-dicount-month-main.ays_chatgpt_dicount_info button{display:flex;align-items:center}div#ays-chatgpt-new-mega-bundle-dicount-month-main div#ays-chatgpt-dicount-month a.ays-chatgpt-sale-banner-link:focus{outline:0;box-shadow:0}div#ays-chatgpt-new-mega-bundle-dicount-month-main .btn-link{color:#007bff;background-color:transparent;display:inline-block;font-weight:400;text-align:center;white-space:nowrap;vertical-align:middle;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;border:1px solid transparent;padding:.375rem .75rem;font-size:1rem;line-height:1.5;border-radius:.25rem}div#ays-chatgpt-new-mega-bundle-dicount-month-main.ays_chatgpt_dicount_info{background-image:url("'. CHATGPT_ASSISTANT_ADMIN_URL .'/images/chatgpt-assistant-banner-background-50.svg");background-position:center right;background-repeat:no-repeat;background-size:cover;background-color:#5551ff;padding:1px 38px 1px 12px}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays_chatgpt_dicount_month{display:flex;align-items:center;justify-content:space-between;color:#fff}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays_chatgpt_dicount_month img{width:60px}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-sale-banner-link{display:flex;justify-content:center;align-items:center;width:60px}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box{font-size:14px;padding:12px;text-align:center}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box.ays-chatgpt-dicount-wrap-text-box{text-align:left;width:auto;display:flex;justify-content:space-around;align-items:flex-start}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box.ays-chatgpt-dicount-wrap-countdown-box{width:30%;display:flex;justify-content:center;align-items:center}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box.ays-chatgpt-dicount-wrap-button-box{width:20%;display:flex;justify-content:center;align-items:center;flex-direction:column}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box .ays-chatgpt-dicount-logo-box{display:flex;justify-content:flex-start;align-items:center;gap:20px}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box.ays-chatgpt-dicount-wrap-text-box .ays-chatgpt-new-mega-bundle-title{color:#fdfdfd;font-size:19px;font-style:normal;font-weight:600;line-height:normal}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box.ays-chatgpt-dicount-wrap-text-box .ays-chatgpt-new-mega-bundle-title-icon-row{display:inline-block}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box.ays-chatgpt-dicount-wrap-text-box .ays-chatgpt-new-mega-bundle-desc{display:inline-block;color:#fff;font-size:15px;font-style:normal;font-weight:400;line-height:normal;margin-top:10px}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box strong{font-size:17px;font-weight:700;letter-spacing:.8px}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-color{color:#971821}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-text-decoration{text-decoration:underline}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box.ays-buy-now-button-box{display:flex;justify-content:flex-end;align-items:center;width:30%}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box .ays-button,#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box .ays-buy-now-button{align-items:center;font-weight:500}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box .ays-buy-now-button{background:#971821;border-color:#fff;display:flex;justify-content:center;align-items:center;padding:5px 15px;font-size:16px;border-radius:5px}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box .ays-buy-now-button:hover{background:#7d161d;border-color:#971821}#ays-chatgpt-new-mega-bundle-dicount-month-main #ays-chatgpt-dismiss-buttons-content{display:flex;justify-content:center}#ays-chatgpt-new-mega-bundle-dicount-month-main #ays-chatgpt-dismiss-buttons-content .ays-button{margin:0!important;font-size:13px;color:#fff}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-opacity-box{width:19%}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-buy-now-opacity-button{padding:40px 15px;display:flex;justify-content:center;align-items:center;opacity:0}#ays-chatgpt-maker-countdown-main-container .ays-chatgpt-maker-countdown-container{margin:0 auto;text-align:center}#ays-chatgpt-maker-countdown-main-container #ays-chatgpt-countdown-headline{letter-spacing:.125rem;text-transform:uppercase;font-size:18px;font-weight:400;margin:0;padding:9px 0 4px;line-height:1.3}#ays-chatgpt-maker-countdown-main-container li,#ays-chatgpt-maker-countdown-main-container ul{margin:0}#ays-chatgpt-maker-countdown-main-container li{display:inline-block;font-size:14px;list-style-type:none;padding:14px;text-transform:lowercase}#ays-chatgpt-maker-countdown-main-container li span{display:flex;justify-content:center;align-items:center;font-size:22px;min-height:40px;min-width:40px;border-radius:4.273px;border:.534px solid #f4f4f4;background:#9896ed;color:#fff}#ays-chatgpt-maker-countdown-main-container .emoji{display:none;padding:1rem}#ays-chatgpt-maker-countdown-main-container .emoji span{font-size:30px;padding:0 .5rem}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box li{position:relative}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box li span:after{content:":";color:#fff;position:absolute;top:0;right:-5px;font-size:40px}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box li span#ays-chatgpt-countdown-seconds:after{content:unset}#ays-chatgpt-new-mega-bundle-dicount-month-main #ays-button-top-buy-now{display:flex;align-items:center;border-radius:6.409px;background:#f66123;padding:12px 32px;color:#fff;font-size:15px;font-style:normal;line-height:normal;margin:0!important}div#ays-chatgpt-new-mega-bundle-dicount-month-main button.notice-dismiss:before{color:#fff;content:"\f00d";font-family:fontawesome;font-size:22px}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-new-mega-bundle-guaranteeicon{width:30px;margin-right:5px}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-one-time-text{color:#fff;font-size:12px;font-style:normal;font-weight:600;line-height:normal}@media all and (max-width:768px){div#ays-chatgpt-new-mega-bundle-dicount-month-main.ays_chatgpt_dicount_info.notice{display:none!important;background-position:bottom right;background-repeat:no-repeat;background-size:cover;border-radius:32px}div#ays-chatgpt-new-mega-bundle-dicount-month-main{padding-right:0}div#ays-chatgpt-new-mega-bundle-dicount-month-main .ays_chatgpt_dicount_month{display:flex;align-items:center;justify-content:space-between;align-content:center;flex-wrap:wrap;flex-direction:column;padding:10px 0}div#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box{width:100%!important;text-align:center}#ays-chatgpt-maker-countdown-main-container #ays-chatgpt-countdown-headline{font-size:15px;font-weight:600}#ays-chatgpt-maker-countdown-main-container ul{font-weight:500}div#ays-chatgpt-maker-countdown-main-container li{padding:10px}div#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-new-mega-bundle-mobile-image-display-none{display:none!important}div#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-new-mega-bundle-mobile-image-display-block{display:block!important;margin-top:5px}div#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box.ays-chatgpt-dicount-wrap-text-box{width:100%!important;text-align:center;flex-direction:column;margin-top:20px;justify-content:center;align-items:center}div#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box li span:after{top:unset}div#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box.ays-chatgpt-dicount-wrap-countdown-box{width:100%;display:flex;justify-content:center;align-items:center}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-button{margin:0 auto!important}#ays-chatgpt-new-mega-bundle-dicount-month-main #ays-chatgpt-dismiss-buttons-content .ays-button{padding-left:unset!important}div#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box.ays-buy-now-button-box{justify-content:center}div#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box .ays-buy-now-button{font-size:14px;padding:5px 10px}div#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-buy-now-opacity-button{display:none}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dismiss-buttons-container-for-form{position:static!important}.comparison .product img{width:70px}.ays-chatgpt-features-wrap .comparison a.price-buy{padding:8px 5px;font-size:11px}}@media screen and (max-width:1350px) and (min-width:768px){div#ays-chatgpt-new-mega-bundle-dicount-month-main.ays_chatgpt_dicount_info.notice{background-position:bottom right;background-repeat:no-repeat;background-size:cover}div#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box strong{font-size:15px}#ays-chatgpt-maker-countdown-main-container li{font-size:11px}div#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-opacity-box{display:none}}@media screen and (max-width:1680px) and (min-width:1551px){div#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box.ays-chatgpt-dicount-wrap-text-box{width:29%}div#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box.ays-chatgpt-dicount-wrap-countdown-box{width:30%}}@media screen and (max-width:1410px){#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-coupon-row{width:150px}}@media screen and (max-width:1550px) and (min-width:1400px){div#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box.ays-chatgpt-dicount-wrap-countdown-box{width:35%}}@media screen and (max-width:1400px) and (min-width:1250px){div#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box.ays-chatgpt-dicount-wrap-countdown-box{width:35%}div#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box.ays-chatgpt-dicount-wrap-text-box{width:40%}}@media screen and (max-width:1274px){#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box.ays-chatgpt-dicount-wrap-text-box .ays-chatgpt-new-mega-bundle-title{font-size:15px}}@media screen and (max-width:1200px){#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box.ays-chatgpt-dicount-wrap-button-box{margin-bottom:16px}#ays-chatgpt-maker-countdown-main-container ul{padding-left:0}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-coupon-row{width:120px;font-size:18px}#ays-chatgpt-new-mega-bundle-dicount-month-main #ays-button-top-buy-now{padding:12px 20px}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box{font-size:12px}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box.ays-chatgpt-dicount-wrap-text-box .ays-chatgpt-new-mega-bundle-desc{font-size:13px}}@media screen and (max-width:1076px) and (min-width:769px){#ays-chatgpt-maker-countdown-main-container li{padding:10px}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-coupon-row{width:100px;font-size:16px}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box.ays-chatgpt-dicount-wrap-button-box{margin-bottom:16px}#ays-chatgpt-new-mega-bundle-dicount-month-main #ays-button-top-buy-now{padding:12px 15px}#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box{font-size:11px;padding:12px 0}}@media screen and (max-width:1250px) and (min-width:769px){div#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box.ays-chatgpt-dicount-wrap-countdown-box{width:45%}div#ays-chatgpt-new-mega-bundle-dicount-month-main .ays-chatgpt-dicount-wrap-box.ays-chatgpt-dicount-wrap-text-box{width:35%}}';
	    $content[] = '</style>';
	    // /* New Mega Bundle Banner Quiz | End */

	    $content = implode( '', $content );
	    echo ($content);        
    }
    
    // Halloween Bundle 2025
    public function ays_chatgpt_new_halloween_bundle_message_2025($ishmar){
        if($ishmar == 0 ){
            $content = array();

            $date = time() + (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS);
            $now_date = date('M d, Y H:i:s', $date);

            $start_date = strtotime('2025-09-08');
            $end_date = strtotime('2025-10-31');
            $diff_end = $end_date - $date;

            $style_attr = '';
            if( $diff_end < 0 ){
                $style_attr = 'style="display:none;"';
            }

            $ays_chatgpt_cta_button_link = esc_url('https://ays-pro.com/wordpress/chatgpt-assistant?utm_source=dashboard&utm_medium=chatgpt-free&utm_campaign=chatgpt-halloween-banner-' . CHATGPT_ASSISTANT_VERSION);

            $content[] = '
                <div id="ays-chatgpt-halloween-banner-2025-main" class="ays-chatgpt-halloween-banner-2025-main ays_chatgpt_dicount_info notice notice-success is-dismissible">
                    <div class="ays-chatgpt-halloween-banner-2025-content">
                        <div class="ays-chatgpt-halloween-banner-2025-left">
                            <div class="ays-chatgpt-halloween-banner-2025-text">
                                <h2 class="ays-chatgpt-halloween-banner-2025-title">Boo! Grab Your <a href="'. $ays_chatgpt_cta_button_link .'" class="" target="_blank">Halloween Deal</a> <br/> Before It Vanishes!</h2>
                                <p class="ays-chatgpt-halloween-banner-2025-subtitle">Don’t get spooked by missing out!<br/> Get 25% discount using the coupon code while the magic lasts!</p>
                            </div>
                        </div>

                        <div class="ays-chatgpt-halloween-banner-2025-center">';

                        $content[] = '<div id="ays-chatgpt-halloween-banner-2025-countdown" class="ays-chatgpt-halloween-banner-2025-countdown" ' . $style_attr . '>';
                            $content[] = '<div class="ays-chatgpt-halloween-banner-2025-countdown-timer">';
                                $content[] = '<div class="ays-chatgpt-halloween-banner-2025-countdown-item">';
                                    $content[] = '<div class="ays-chatgpt-halloween-banner-2025-countdown-value" id="ays-chatgpt-halloween-banner-2025-days">00</div>';
                                    $content[] = '<div class="ays-chatgpt-halloween-banner-2025-countdown-label">' . __('days', 'ays-chatgpt-assistant') . '</div>';
                                $content[] = '</div>';
                                $content[] = '<div class="ays-chatgpt-halloween-banner-2025-countdown-separator">:</div>';
                                $content[] = '<div class="ays-chatgpt-halloween-banner-2025-countdown-item">';
                                    $content[] = '<div class="ays-chatgpt-halloween-banner-2025-countdown-value" id="ays-chatgpt-halloween-banner-2025-hours">00</div>';
                                    $content[] = '<div class="ays-chatgpt-halloween-banner-2025-countdown-label">' . __('hours', 'ays-chatgpt-assistant') . '</div>';
                                $content[] = '</div>';
                                $content[] = '<div class="ays-chatgpt-halloween-banner-2025-countdown-separator">:</div>';
                                $content[] = '<div class="ays-chatgpt-halloween-banner-2025-countdown-item">';
                                    $content[] = '<div class="ays-chatgpt-halloween-banner-2025-countdown-value" id="ays-chatgpt-halloween-banner-2025-minutes">00</div>';
                                    $content[] = '<div class="ays-chatgpt-halloween-banner-2025-countdown-label">' . __('minutes', 'ays-chatgpt-assistant') . '</div>';
                                $content[] = '</div>';
                                $content[] = '<div class="ays-chatgpt-halloween-banner-2025-countdown-separator">:</div>';
                                $content[] = '<div class="ays-chatgpt-halloween-banner-2025-countdown-item">';
                                    $content[] = '<div class="ays-chatgpt-halloween-banner-2025-countdown-value" id="ays-chatgpt-halloween-banner-2025-seconds">00</div>';
                                    $content[] = '<div class="ays-chatgpt-halloween-banner-2025-countdown-label">' . __('seconds', 'ays-chatgpt-assistant') . '</div>';
                                $content[] = '</div>';
                            $content[] = '</div>';
                        $content[] = '</div>';

                        $content[] = '</div>
                                                
                        <div class="ays-chatgpt-halloween-banner-2025-right">
                            <div class="ays-chatgpt-halloween-banner-2025-pumpkin">
                                <svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
                                    <g clip-path="url(#clip0_177_40)">
                                    <path d="M32.664 8.519C29.364 5.134 23.42 4.75 18 4.75C12.58 4.75 6.636 5.134 3.336 8.519C0.582 11.344 0 15.751 0 19.791C0 25.054 1.982 31.102 6.357 34.035C9.364 36.051 13.95 35.871 18 35.871C22.05 35.871 26.636 36.051 29.643 34.035C34.018 31.101 36 25.054 36 19.791C36 15.751 35.418 11.344 32.664 8.519Z" fill="#F4900C"/>
                                    <path d="M20.783 5.44401C20.852 5.86401 20.561 6.20801 20.136 6.20801H15.685C15.259 6.20801 14.968 5.86401 15.038 5.44401L15.783 0.972008C15.853 0.551008 16.259 0.208008 16.685 0.208008H19.136C19.562 0.208008 19.968 0.552008 20.037 0.972008L20.783 5.44401Z" fill="#3F7123"/>
                                    <path d="M20.6541 21.159L19.0561 18.563C18.7651 18.021 18.3831 17.75 17.9991 17.746C17.6161 17.75 17.2331 18.021 16.9421 18.563L15.3441 21.159C14.7571 22.252 16.2171 22.875 17.9981 22.875C19.7791 22.875 21.2411 22.251 20.6541 21.159ZM30.1621 24.351C30.1171 24.276 30.0361 24.23 29.9481 24.23H29.1071C29.0391 24.23 28.9731 24.258 28.9261 24.307L26.6951 26.641L23.9971 24.472C23.9461 24.431 23.8801 24.414 23.8121 24.419C23.7461 24.426 23.6851 24.46 23.6441 24.513L21.2361 27.575L18.1821 24.309C18.1691 24.295 18.1491 24.292 18.1341 24.281C18.1191 24.271 18.1091 24.254 18.0911 24.247C18.0851 24.245 18.0781 24.247 18.0721 24.245C18.0481 24.238 18.0251 24.24 18.0001 24.24C17.9751 24.24 17.9521 24.238 17.9281 24.246C17.9221 24.248 17.9151 24.245 17.9081 24.248C17.8901 24.255 17.8811 24.272 17.8651 24.282C17.8491 24.292 17.8301 24.295 17.8171 24.309L14.7641 27.575L12.3551 24.513C12.3141 24.46 12.2531 24.426 12.1871 24.419C12.1211 24.413 12.0541 24.431 12.0021 24.472L9.30411 26.641L7.07411 24.307C7.02711 24.258 6.96211 24.23 6.89311 24.23H6.05211C5.96511 24.23 5.88311 24.276 5.83811 24.351C5.79311 24.426 5.79011 24.519 5.83111 24.596L8.58511 29.815C8.61911 29.879 8.6781 29.925 8.7491 29.942C8.8201 29.959 8.8941 29.944 8.9521 29.902L10.9861 28.444L13.9901 32.077C14.0331 32.13 14.0961 32.162 14.1641 32.167L14.1831 32.168C14.2451 32.168 14.3041 32.146 14.3501 32.105L18.0001 28.836L21.6501 32.104C21.6961 32.145 21.7551 32.167 21.8171 32.167L21.8361 32.166C21.9041 32.161 21.9671 32.129 22.0101 32.076L25.0151 28.443L27.0491 29.901C27.1091 29.944 27.1821 29.961 27.2521 29.941C27.3221 29.924 27.3821 29.879 27.4151 29.815L30.1701 24.596C30.2101 24.519 30.2081 24.426 30.1621 24.351ZM27.9761 15.421C28.1051 17.548 27.1921 19.227 24.7711 19.374C22.3511 19.52 21.2421 17.963 21.1131 15.837C20.9841 13.711 22.3451 10.717 24.2401 10.603C26.1361 10.487 27.8481 13.294 27.9761 15.421ZM8.02411 15.421C7.89511 17.548 8.80811 19.227 11.2291 19.374C13.6491 19.52 14.7581 17.963 14.8871 15.837C15.0161 13.711 13.6551 10.717 11.7601 10.603C9.86511 10.489 8.15211 13.294 8.02411 15.421Z" fill="#642116"/>
                                    </g>
                                    <defs>
                                    <clipPath id="clip0_177_40">
                                    <rect width="36" height="36" fill="white"/>
                                    </clipPath>
                                    </defs>
                                </svg>
                            </div>



                            <div class="ays-chatgpt-halloween-banner-2025-discount-section">
                                <div class="ays-chatgpt-halloween-banner-2025-discount">25% OFF</div>
                                <div class="ays-chatgpt-halloween-banner-2025-coupon-wrapper">
                                    <div class="ays-chatgpt-halloween-banner-2025-coupon-box" onclick="aysChatgptHalloweenCopyToClipboard(\'HALLOWEEN25\')" title="Click to copy">
                                        <span class="ays-chatgpt-halloween-banner-2025-coupon-text">HALLOWEEN25</span>
                                        <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" class="ays-chatgpt-halloween-banner-2025-copy-icon">
                                            <path d="M13.5 2.5H6.5C5.67 2.5 5 3.17 5 4V10C5 10.83 5.67 11.5 6.5 11.5H13.5C14.33 11.5 15 10.83 15 10V4C15 3.17 14.33 2.5 13.5 2.5ZM13.5 10H6.5V4H13.5V10ZM2.5 6.5V12.5C2.5 13.33 3.17 14 4 14H10V12.5H4V6.5H2.5Z" fill="white"/>
                                        </svg>
                                    </div>
                                </div>
                                <a href="'. $ays_chatgpt_cta_button_link .'" class="ays-chatgpt-halloween-banner-2025-upgrade" target="_blank">Upgrade Now</a>
                            </div>';

                            if( current_user_can( 'manage_options' ) ){
                                $content[] = '<div id="ays-chatgpt-dismiss-buttons-content">';
                                    $content[] = '<form action="" method="POST" style="position: absolute; bottom: -5px; right: 0; color: #fff;">';
                                            $content[] = '<button class="btn btn-link ays-button" name="ays_chatgpt_sale_btn" style="color: darkgrey; font-size: 11px;">'. __( "Dismiss ad", 'ays-chatgpt-assistant' ) .'</button>';
                                            $content[] = wp_nonce_field( CHATGPT_ASSISTANT_NAME . '-sale-banner' ,  CHATGPT_ASSISTANT_NAME . '-sale-banner' );
                                    $content[] = '</form>';
                                $content[] = '</div>';
                            }

                            $content[] = '
                        </div>
                    </div>
                </div>';

            $content[] = '<style id="ays-chatgpt-progress-banner-styles-inline-css">';
            $content[] = '
                .ays-chatgpt-halloween-banner-2025-main {
                    background: linear-gradient(135deg, #1A0F2E 100%, #2D1B4E 0%);
                    background-image: url("' . esc_attr( CHATGPT_ASSISTANT_ADMIN_URL ) . '/images/halloween-banner-background-image-remove.png"), linear-gradient(135deg, #2D1B4E 0%, #1A0F2E 100%);
                    background-position: left center, center;
                    background-repeat: no-repeat, no-repeat;
                    background-size: auto 100%, cover;
                    padding: 20px 30px 20px 130px;
                    border-radius: 12px;
                    color: white;
                    margin: 20px 0;
                    border: 0;
                    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
                    overflow: hidden;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-content {
                    display: flex;
                    align-items: center;
                    justify-content: space-between;
                    gap: 30px;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-left {
                    display: flex;
                    align-items: center;
                    gap: 20px;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-center {
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    flex: 1;
                    max-width: 350px;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-right {
                    display: flex;
                    align-items: center;
                    gap: 15px;
                    flex-shrink: 0;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-icon {
                    flex-shrink: 0;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-pumpkin svg {
                    display: inline !important;
                    border: none !important;
                    box-shadow: none !important;
                    height: 1em !important;
                    width: 1em !important;
                    margin: 0 0.07em !important;
                    vertical-align: -0.1em !important;
                    background: none !important;
                    padding: 0 !important;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-orb {
                    width: 80px;
                    height: 80px;
                    background: linear-gradient(135deg, #8B5CF6 0%, #6D28D9 100%);
                    border-radius: 50%;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    box-shadow: 0 0 30px rgba(139, 92, 246, 0.6);
                    border: 3px solid rgba(168, 85, 247, 0.4);
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-question {
                    font-size: 48px;
                    font-weight: 700;
                    color: #E9D5FF;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-bat {
                    font-size: 20px;
                    opacity: 0.8;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-bat-1 {
                    margin-left: -100px;
                    margin-top: -40px;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-bat-2 {
                    margin-left: -110px;
                    margin-top: 35px;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-sparkle {
                    font-size: 12px;
                    opacity: 0.7;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-sparkle-1 {
                    margin-left: -95px;
                    margin-top: -60px;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-sparkle-2 {
                    margin-left: -70px;
                    margin-top: -15px;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-sparkle-3 {
                    margin-left: -120px;
                    margin-top: 10px;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-text {
                    flex: 1;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-title {
                    font-size: 24px;
                    font-weight: 700;
                    margin: 0 0 8px 0;
                    line-height: 1.2;
                    color: #fff;
                    text-transform: uppercase;
                    letter-spacing: 1px;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-title a {
                    color: #FB923C;
                    text-decoration: underline;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-subtitle {
                    font-size: 16px;
                    margin: 0;
                    opacity: 0.9;
                    font-weight: 400;
                    color: #E9D5FF;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-description {
                    font-size: 14px;
                    margin: 0;
                    opacity: 0.85;
                    line-height: 1.5;
                    color: #D8B4FE;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-pumpkin {
                    font-size: 64px;
                    filter: drop-shadow(0 0 20px rgba(251, 146, 60, 0.8));
                    flex-shrink: 0;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-discount-section {
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                    gap: 10px;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-discount {
                    font-size: 36px;
                    font-weight: 700;
                    color: #FB923C;
                    text-shadow: 0 0 20px rgba(251, 146, 60, 0.6);
                    margin: 0;
                    line-height: 1;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-coupon-wrapper {
                    margin-bottom: 5px;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-coupon-box {
                    border: 2px dashed rgba(255, 255, 255, 0.4);
                    padding: 6px 12px;
                    border-radius: 6px;
                    background: rgba(255, 255, 255, 0.1);
                    cursor: pointer;
                    transition: all 0.3s ease;
                    display: flex;
                    align-items: center;
                    gap: 6px;
                    backdrop-filter: blur(10px);
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-coupon-box:hover {
                    background: rgba(255, 255, 255, 0.2);
                    border-color: rgba(255, 255, 255, 0.6);
                    transform: translateY(-1px);
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-coupon-text {
                    font-size: 14px;
                    font-weight: 700;
                    letter-spacing: 1px;
                    color: #fff;
                    font-family: monospace;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-copy-icon {
                    opacity: 0.8;
                    transition: opacity 0.3s ease;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-coupon-box:hover .ays-chatgpt-halloween-banner-2025-copy-icon {
                    opacity: 1;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-upgrade {
                    background: linear-gradient(135deg, #FB923C 0%, #F97316 100%);
                    color: white;
                    border: none;
                    padding: 12px 28px;
                    border-radius: 8px;
                    font-size: 16px;
                    font-weight: 600;
                    cursor: pointer;
                    transition: all 0.3s ease;
                    box-shadow: 0 4px 16px rgba(251, 146, 60, 0.5);
                    text-decoration: none;
                    display: inline-flex;
                    align-items: center;
                    text-align: center;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-upgrade:hover {
                    transform: translateY(-2px);
                    box-shadow: 0 6px 20px rgba(251, 146, 60, 0.7);
                    text-decoration: none;
                    color: white;
                }

                .ays-chatgpt-halloween-banner-2025-main .notice-dismiss:before {
                    color: #fff;
                }

                .ays-chatgpt-halloween-banner-2025-copy-notification {
                    position: fixed;
                    top: 50%;
                    left: 50%;
                    transform: translate(-50%, -50%);
                    background: rgba(0, 0, 0, 0.8);
                    color: white;
                    padding: 12px 24px;
                    border-radius: 8px;
                    font-size: 14px;
                    z-index: 10000;
                    opacity: 0;
                    transition: opacity 0.3s ease;
                }

                .ays-chatgpt-halloween-banner-2025-copy-notification.show {
                    opacity: 1;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-countdown-timer {
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    gap: 8px;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-countdown-item {
                    background: rgba(255, 255, 255, 0.15);
                    border-radius: 8px;
                    padding: 8px 12px;
                    min-width: 60px;
                    backdrop-filter: blur(10px);
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-countdown-value {
                    font-size: 24px;
                    font-weight: 700;
                    line-height: 1;
                    margin-bottom: 4px;
                    color: #fff;
                    text-align: center;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-countdown-label {
                    font-size: 11px;
                    opacity: 0.8;
                    text-transform: lowercase;
                    text-align: center;
                }

                .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-countdown-separator {
                    font-size: 24px;
                    font-weight: 700;
                    opacity: 0.6;
                    margin: 0 4px;
                }

                @media (min-width: 1200px) {
                    .ays-chatgpt-halloween-banner-2025-main .wp-core-ui .notice.is-dismissible {
                        padding-right: 60px;
                    }
                }

                @media (max-width: 1200px) {

                    div.ays-chatgpt-halloween-banner-2025-main {
                        padding: 20px 30px;
                    }

                    div.ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-pumpkin {
                        display: none;
                    }

                    .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-subtitle,
                    .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-title {
                        text-align: center;
                    }

                    .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-content {
                        flex-wrap: wrap;
                        gap: 20px;
                    }

                    .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-left {
                        width: 100%;
                    }

                    .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-center {
                        width: 100%;
                        max-width: 100%;
                        text-align: center;
                    }

                    .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-right {
                        width: 100%;
                        justify-content: center;
                    }
                }

                @media (max-width: 786px) {
                    #ays-chatgpt-halloween-banner-2025-main {
                        display: none !important;
                    }
                }

                @media (max-width: 768px) {
                    .ays-chatgpt-halloween-banner-2025-main {
                        padding: 15px 20px;
                        margin: 15px 0;
                    }

                    .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-title {
                        font-size: 20px;
                    }

                    .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-subtitle {
                        font-size: 14px;
                    }

                    .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-description {
                        font-size: 13px;
                    }

                    .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-pumpkin {
                        font-size: 48px;
                    }

                    .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-discount {
                        font-size: 28px;
                    }

                    .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-upgrade {
                        padding: 10px 20px;
                        font-size: 14px;
                    }
                }

                @media (max-width: 480px) {
                    .ays-chatgpt-halloween-banner-2025-main {
                        padding: 12px 15px;
                    }

                    .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-orb {
                        width: 60px;
                        height: 60px;
                    }

                    .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-question {
                        font-size: 36px;
                    }

                    .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-title {
                        font-size: 18px;
                    }

                    .ays-chatgpt-halloween-banner-2025-main .ays-chatgpt-halloween-banner-2025-coupon-text {
                        font-size: 12px;
                    }
                }
            ';

            $content[] = '</style>';

            $content[] = '<script>';
            $content[] = "
                    function aysChatgptHalloweenCopyToClipboard(text) {
                        // Create a temporary textarea element
                        var textarea = document.createElement('textarea');
                        textarea.value = text;
                        textarea.style.position = 'fixed';
                        textarea.style.opacity = '0';
                        document.body.appendChild(textarea);
                        
                        // Select and copy the text
                        textarea.select();
                        textarea.setSelectionRange(0, 99999); // For mobile devices
                        
                        try {
                            document.execCommand('copy');
                            aysChatgptHalloweenShowCopyNotification('Coupon code copied!');
                        } catch (err) {
                            console.error('Failed to copy text: ', err);
                        }
                        
                        // Remove the temporary textarea
                        document.body.removeChild(textarea);
                    }

                    function aysChatgptHalloweenShowCopyNotification(message) {
                        // Check if notification already exists
                        var existingNotification = document.querySelector('.ays-chatgpt-halloween-banner-2025-copy-notification');
                        if (existingNotification) {
                            document.body.removeChild(existingNotification);
                        }
                        
                        // Create notification element
                        var notification = document.createElement('div');
                        notification.className = 'ays-chatgpt-halloween-banner-2025-copy-notification';
                        notification.textContent = message;
                        document.body.appendChild(notification);
                        
                        // Show notification with animation
                        setTimeout(function() {
                            notification.classList.add('show');
                        }, 10);
                        
                        // Hide and remove notification after 2 seconds
                        setTimeout(function() {
                            notification.classList.remove('show');
                            setTimeout(function() {
                                if (notification.parentNode) {
                                    document.body.removeChild(notification);
                                }
                            }, 300);
                        }, 2000);
                    }

                    (function() {
                        var endDate = new Date('". date('Y-m-d H:i:s', $end_date) ."').getTime();
                    
                        function updateCountdown() {
                            var now = new Date().getTime();
                            var distance = endDate - now;
                            
                            if (distance < 0) {
                                clearInterval(updateCountdown);
                                document.getElementById('ays-chatgpt-halloween-banner-2025-progress-banner-countdown').style.display = 'none';
                                return;
                            }
                            
                            var days = Math.floor(distance / (1000 * 60 * 60 * 24));
                            var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
                            var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
                            var seconds = Math.floor((distance % (1000 * 60)) / 1000);
                            
                            function padZero(num) {
                                return num < 10 ? '0' + num : num;
                            }
                            
                            document.getElementById('ays-chatgpt-halloween-banner-2025-days').textContent = padZero(days);
                            document.getElementById('ays-chatgpt-halloween-banner-2025-hours').textContent = padZero(hours);
                            document.getElementById('ays-chatgpt-halloween-banner-2025-minutes').textContent = padZero(minutes);
                            document.getElementById('ays-chatgpt-halloween-banner-2025-seconds').textContent = padZero(seconds);
                        }
                        
                        updateCountdown();
                        setInterval(updateCountdown, 1000);
                    })()";
            $content[] = '</script>';

            $content = implode( '', $content );
            echo ($content);
        }
    }

    // Black Friday
    public static function ays_chatgpt_black_friday_message($ishmar){
        if($ishmar == 0 ){
            $content = array();
            $ays_chatgpt_cta_button_link = esc_url('https://ays-pro.com/wordpress/chatgpt-assistant?utm_source=dashboard&utm_medium=chatgpt-free&utm_campaign=black-friday-sale-banner-' . CHATGPT_ASSISTANT_VERSION);
            $content[] = '<div id="ays-chatgpt-dicount-black-friday-month-main" class="ays-chatgpt notice notice-success is-dismissible ays_chatgpt_dicount_info">';
                $content[] = '<div id="ays-chatgpt-dicount-black-friday-month" class="ays_chatgpt_dicount_month">';
                    $content[] = '<div class="ays-chatgpt-dicount-black-friday-box">';
                        $content[] = '<div class="ays-chatgpt-dicount-black-friday-wrap-box ays-chatgpt-dicount-black-friday-wrap-box-80" style="width: 70%;">';
                            $content[] = '<div class="">';
                                $content[] = '<div class="ays-chatgpt-dicount-black-friday-title-row" >' . __( 'Coupon Code', "ays-popup-box" ) .' ' . '</div>';
                                $content[] = '<div class="ays-chatgpt-dicount-black-friday-title-row">';
                                $content[] = '
                                    <span class="ays-chatgpt-dicount-black-friday-banner-2025-coupon-wrapper">
                                        <span class="ays-chatgpt-dicount-black-friday-banner-2025-coupon-box" onclick="aysChatgptHalloweenCopyToClipboard(\'FREE2PROBF\')" title="Click to copy">
                                            <span class="ays-chatgpt-dicount-black-friday-banner-2025-coupon-text">FREE2PROBF</span>
                                            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" class="ays-chatgpt-dicount-black-friday-banner-2025-copy-icon">
                                                <path d="M13.5 2.5H6.5C5.67 2.5 5 3.17 5 4V10C5 10.83 5.67 11.5 6.5 11.5H13.5C14.33 11.5 15 10.83 15 10V4C15 3.17 14.33 2.5 13.5 2.5ZM13.5 10H6.5V4H13.5V10ZM2.5 6.5V12.5C2.5 13.33 3.17 14 4 14H10V12.5H4V6.5H2.5Z" fill="white"/>
                                            </svg>
                                        </span>
                                    </span>';
                                $content[] = '</div> ';
                            $content[] = '</div>';
                        $content[] = '</div>';
                        $content[] = '<div class="ays-chatgpt-dicount-black-friday-wrap-box ays-chatgpt-dicount-black-friday-wrap-text-box">';
                            $content[] = '<div class="ays-chatgpt-dicount-black-friday-text-row">' . '30% off' . '</div>';
                        $content[] = '</div>';
                        $content[] = '<div class="ays-chatgpt-dicount-black-friday-wrap-box" style="width: 25%;">';
                            $content[] = '<div id="ays-chatgpt-countdown-main-container">';
                                $content[] = '<div class="ays-chatgpt-countdown-container">';
                                    $content[] = '<div id="ays-chatgpt-countdown" style="display: block;">';
                                        $content[] = '<ul>';
                                            $content[] = '<li><span id="ays-chatgpt-countdown-days"></span>' . __( 'Days', "ays-popup-box" ) . '</li>';
                                            $content[] = '<li><span id="ays-chatgpt-countdown-hours"></span>' . __( 'Hours', "ays-popup-box" ) . '</li>';
                                            $content[] = '<li><span id="ays-chatgpt-countdown-minutes"></span>' . __( 'Minutes', "ays-popup-box" ) . '</li>';
                                            $content[] = '<li><span id="ays-chatgpt-countdown-seconds"></span>' . __( 'Seconds', "ays-popup-box" ) . '</li>';
                                        $content[] = '</ul>';
                                    $content[] = '</div>';
                                    $content[] = '<div id="ays-chatgpt-countdown-content" class="emoji" style="display: none;">';
                                        $content[] = '<span></span>';
                                        $content[] = '<span></span>';
                                        $content[] = '<span></span>';
                                        $content[] = '<span></span>';
                                    $content[] = '</div>';
                                $content[] = '</div>';
                            $content[] = '</div>';
                        $content[] = '</div>';
                        $content[] = '<div class="ays-chatgpt-dicount-black-friday-wrap-box" style="width: 25%;">';
                            $content[] = '<a href="'. $ays_chatgpt_cta_button_link .'" class="ays-chatgpt-dicount-black-friday-button-buy-now" target="_blank">' . __( 'Get Your Deal', "ays-popup-box" ) . '</a>';
                        $content[] = '</div>';
                    $content[] = '</div>';
                $content[] = '</div>';
                $content[] = '<div style="position: absolute;right: 0;bottom: 1px;"  class="ays-chatgpt-dismiss-buttons-container-for-form-black-friday">';
                    $content[] = '<form action="" method="POST">';
                        $content[] = '<div id="ays-chatgpt-dismiss-buttons-content">';
                            if( current_user_can( 'manage_options' ) ){
                                $content[] = '<button class="btn btn-link ays-button" name="ays_chatgpt_sale_btn" style="height: 32px; margin-left: 0;padding-left: 0">Dismiss ad</button>';
                                $content[] = wp_nonce_field( CHATGPT_ASSISTANT_NAME . '-sale-banner' ,  CHATGPT_ASSISTANT_NAME . '-sale-banner' );
                            }
                        $content[] = '</div>';
                    $content[] = '</form>';
                $content[] = '</div>';
            $content[] = '</div>';
            $content[] = '<script>';
            $content[] = "
                    function aysChatgptHalloweenCopyToClipboard(text) {
                        // Create a temporary textarea element
                        var textarea = document.createElement('textarea');
                        textarea.value = text;
                        textarea.style.position = 'fixed';
                        textarea.style.opacity = '0';
                        document.body.appendChild(textarea);
                        
                        // Select and copy the text
                        textarea.select();
                        textarea.setSelectionRange(0, 99999); // For mobile devices
                        
                        try {
                            document.execCommand('copy');
                            aysChatgptHalloweenShowCopyNotification('Coupon code copied!');
                        } catch (err) {
                            console.error('Failed to copy text: ', err);
                        }
                        
                        // Remove the temporary textarea
                        document.body.removeChild(textarea);
                    }
                    function aysChatgptHalloweenShowCopyNotification(message) {
                        // Check if notification already exists
                        var existingNotification = document.querySelector('.ays-chatgpt-discount-black-friday-banner-2025-copy-notification');
                        if (existingNotification) {
                            document.body.removeChild(existingNotification);
                        }
                        
                        // Create notification element
                        var notification = document.createElement('div');
                        notification.className = 'ays-chatgpt-discount-black-friday-banner-2025-copy-notification';
                        notification.textContent = message;
                        document.body.appendChild(notification);
                        
                        // Show notification with animation
                        setTimeout(function() {
                            notification.classList.add('show');
                        }, 10);
                        
                        // Hide and remove notification after 2 seconds
                        setTimeout(function() {
                            notification.classList.remove('show');
                            setTimeout(function() {
                                if (notification.parentNode) {
                                    document.body.removeChild(notification);
                                }
                            }, 300);
                        }, 2000);
                    }";
            $content[] = '</script>';
            $content[] = '<style>';
            $content[] = '
                /* Black friday banner start */
                div#ays-chatgpt-dicount-black-friday-month-main *{color:#fff}div#ays-chatgpt-dicount-black-friday-month-main div#ays-chatgpt-dicount-black-friday-month a.ays-chatgpt-sale-banner-link:focus{outline:0;box-shadow:0}div#ays-chatgpt-dicount-black-friday-month-main .btn-link{background-color:transparent;display:inline-block;font-weight:400;text-align:center;white-space:nowrap;vertical-align:middle;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;border:1px solid transparent;padding:.375rem .75rem;font-size:12px;line-height:1.5;border-radius:.25rem;color:rgba(255,255,255,.6)}div#ays-chatgpt-dicount-black-friday-month-main.ays_chatgpt_dicount_info{background-image:linear-gradient(45deg,#1e101d,#c60af4);padding:unset;border-left:0}#ays-chatgpt-dicount-black-friday-month-main .ays_chatgpt_dicount_month{position:relative;background-image:url("'. esc_attr(CHATGPT_ASSISTANT_ADMIN_URL) .'/images/black-friday-plugins-background-image.webp");background-position:center right;background-repeat:no-repeat;background-size:100% 100%}#ays-chatgpt-dicount-black-friday-month-main .ays_chatgpt_dicount_month img{width:80px}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-sale-banner-link{display:flex;justify-content:center;align-items:center;width:200px}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-button-sale{font-style:normal;font-weight:600;font-size:24px;text-align:center;color:#b2ff00;text-transform:uppercase}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-wrap-box{font-size:14px;padding:12px;text-align:center;width:50%;white-space:nowrap}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-wrap-box strong{font-size:17px;font-weight:700;letter-spacing:.8px}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-wrap-color{color:#971821}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-wrap-text-decoration{text-decoration:underline}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-wrap-box.ays-buy-now-button-box{display:flex;justify-content:flex-end;align-items:center;width:30%}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-wrap-box .ays-button,#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-wrap-box .ays-buy-now-button{align-items:center;font-weight:500}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-wrap-box .ays-buy-now-button{background:#971821;border-color:#fff;display:flex;justify-content:center;align-items:center;padding:5px 15px;font-size:16px;border-radius:5px}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-wrap-box .ays-buy-now-button:hover{background:#7d161d;border-color:#971821}#ays-chatgpt-dicount-black-friday-month-main #ays-chatgpt-dismiss-buttons-content{display:flex;justify-content:center}#ays-chatgpt-dicount-black-friday-month-main #ays-chatgpt-dismiss-buttons-content .ays-button{margin:0!important;font-size:13px;color:#969393b0}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-wrap-opacity-box{width:19%}#ays-chatgpt-dicount-black-friday-month-main .ays-buy-now-opacity-button{padding:40px 15px;display:flex;justify-content:center;align-items:center;opacity:0}#ays-chatgpt-countdown-main-container .ays-chatgpt-countdown-container{margin:0 auto;text-align:center}#ays-chatgpt-countdown-main-container #ays-chatgpt-countdown-headline{letter-spacing:.125rem;text-transform:uppercase;font-size:18px;font-weight:400;margin:0;padding:9px 0 4px;line-height:1.3}#ays-chatgpt-countdown-main-container li,#ays-chatgpt-countdown-main-container ul{margin:0;font-weight:600}#ays-chatgpt-countdown-main-container li{display:inline-block;font-size:10px;list-style-type:none;padding:10px;text-transform:uppercase}#ays-chatgpt-countdown-main-container li span{display:block;font-size:22px;min-height:33px}#ays-chatgpt-countdown-main-container .emoji{display:none;padding:1rem}#ays-chatgpt-countdown-main-container .emoji span{font-size:25px;padding:0 .5rem}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-box{display:flex;justify-content:space-between;align-items:center;width:95%;margin:auto}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-title-row{text-align:center;padding-right:50px;font-style:normal;font-weight:900;font-size:19px;color:#fff;}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-button-buy-now{border:none;outline:0;padding:10px 20px;font-size:22px;text-transform:uppercase;font-weight:700;text-decoration:none;background:linear-gradient(180deg,#dd0bef 0,#82008d 100%);border-radius:16px}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-text-row{text-transform:uppercase;text-shadow:-1.5px 0 #dd0bef,0 1.5px #dd0bef,1.5px 0 #dd0bef,0 -1.5px #dd0bef;font-weight:900;font-style:normal;font-size:40px;line-height:40px;color:#fff}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-wrap-text-box{position:absolute;width:25%;top:10px;bottom:0;right:0;left:0;margin:0 auto}#ays-chatgpt-countdown ul{padding:0}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-banner-2025-coupon-box{border:2px dashed rgba(255,255,255,.4);padding:0 12px;border-radius:6px;background:rgba(255,255,255,.1);cursor:pointer;transition:.3s;display:flex;align-items:center;justify-content:center;gap:6px;backdrop-filter:blur(10px);width:fit-content;margin:0 auto}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-banner-2025-coupon-box:hover{background:rgba(255,255,255,.2);border-color:rgba(255,255,255,.6);transform:translateY(-1px)}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-discount-black-friday-banner-2025-coupon-text{font-size:14px;font-weight:700;letter-spacing:1px;color:#fff;font-family:monospace}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-discount-black-friday-banner-2025-copy-icon{opacity:.8;transition:opacity .3s}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-discount-black-friday-banner-banner-2025-coupon-box:hover .ays-chatgpt-discount-black-friday-banner-2025-copy-icon,.ays-chatgpt-discount-black-friday-banner-2025-copy-notification.show{opacity:1}.ays-chatgpt-discount-black-friday-banner-2025-copy-notification{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);background:rgba(0,0,0,.8);color:#fff;padding:12px 24px;border-radius:8px;font-size:14px;z-index:10000;opacity:0;transition:opacity .3s}@media screen and (max-width:1400px) and (min-width:1200px){div#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-title-row{font-size:15px}div#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-text-row{font-size:27px}div#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-box{width:100%}div#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-button-buy-now{font-size:13px}div#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-wrap-box-80{width:80%!important}}@media all and (max-width:1200px){div#ays-chatgpt-dicount-black-friday-month-main .ays_chatgpt_dicount_month{background:unset}div#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-text-row{font-size:30px}div#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-box{width:100%}div#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-button-buy-now{font-size:15px}div#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-wrap-box-80{width:80%!important}}@media all and (max-width:1200px) and (min-width:1150px){div#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-title-row{font-size:15px}div#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-button-buy-now{font-size:10px}}@media all and (max-width:1150px){div#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-wrap-box-80{width:80%!important}div#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-box{flex-direction:column}div#ays-chatgpt-dicount-black-friday-month-main{padding-right:0}div#ays-chatgpt-dicount-black-friday-month-main .ays_chatgpt_dicount_month{display:flex;align-items:center;justify-content:space-between;align-content:center;flex-wrap:wrap;flex-direction:column;padding:10px 0}div#ays-chatgpt-dicount-black-friday-month-main div.ays-chatgpt-dicount-black-friday-wrap-box{width:100%!important;text-align:center}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-title-row,div#ays-chatgpt-dicount-black-friday-month-main #ays-chatgpt-countdown-main-container ul{padding:0;font-size:13px}#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-button-sale,div#ays-chatgpt-countdown-main-container li{font-size:15px}div#ays-chatgpt-countdown-main-container li span{font-size:25px}div#ays-chatgpt-dicount-black-friday-month-main div.ays-chatgpt-dicount-black-friday-wrap-text-box{position:unset}#ays-chatgpt-countdown-main-container #ays-chatgpt-countdown-headline{font-size:15px;font-weight:600}#ays-chatgpt-countdown-main-container ul{font-weight:500}#ays-chatgpt-countdown-main-container li span{font-size:20px}#ays-chatgpt-dicount-black-friday-month-main .ays-button{margin:0 auto!important}div#ays-chatgpt-dicount-black-friday-month-main.ays_chatgpt_dicount_info.notice{background-position:bottom right;background-repeat:no-repeat;background-size:contain;display:flex;justify-content:center;background-image:linear-gradient(45deg,#1e101d,#c60af4)}div#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-wrap-box.ays-buy-now-button-box{justify-content:center}div#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-wrap-box .ays-buy-now-button{font-size:14px;padding:5px 10px}div#ays-chatgpt-dicount-black-friday-month-main .ays-chatgpt-dicount-black-friday-button-buy-now{padding:10px 18px;font-size:15px}}@media all and (max-width:768px){#ays-chatgpt-dicount-black-friday-month-main{display:none!important}}
                ';
            $content[] = '</style>';
            $content = implode( '', $content );
            echo $content;
        }
    }

    // Christmas Banner 2025
    public static function ays_chatgpt_christmas_banner_message_2025($ishmar){
        if($ishmar == 0 ){
            $content = array();

           $svg_icon = '<svg width="21" height="22" viewBox="0 0 21 22" fill="none" xmlns="http://www.w3.org/2000/svg">
            <path fill-rule="evenodd" clip-rule="evenodd" d="M10.0445 0C10.4587 0 10.7945 0.33579 10.7945 0.75V2.93934L12.5141 1.21967C12.807 0.92678 13.2819 0.92678 13.5748 1.21967C13.8677 1.51256 13.8677 1.98744 13.5748 2.28033L10.7945 5.06066V9.451L14.5965 7.25588L15.6142 3.45788C15.7214 3.05778 16.1326 2.82034 16.5327 2.92755C16.9328 3.03475 17.1703 3.44601 17.0631 3.84611L16.4336 6.19522L18.3296 5.10055C18.6884 4.89344 19.147 5.01635 19.3542 5.37507C19.5613 5.73379 19.4384 6.19248 19.0796 6.39959L17.1836 7.49426L19.5327 8.1237C19.9328 8.23091 20.1703 8.64216 20.0631 9.0423C19.9558 9.4424 19.5446 9.6798 19.1445 9.5726L15.3465 8.55492L11.5445 10.75L15.3467 12.9452L19.1447 11.9275C19.5448 11.8203 19.956 12.0578 20.0633 12.4579C20.1705 12.858 19.933 13.2692 19.5329 13.3764L17.1838 14.0059L19.0798 15.1005C19.4386 15.3077 19.5615 15.7663 19.3544 16.1251C19.1472 16.4838 18.6886 16.6067 18.3298 16.3996L16.4338 15.3049L17.0633 17.654C17.1705 18.0541 16.933 18.4654 16.5329 18.5726C16.1328 18.6798 15.7216 18.4424 15.6144 18.0423L14.5967 14.2443L10.7945 12.049V16.4393L13.5748 19.2197C13.8677 19.5126 13.8677 19.9874 13.5748 20.2803C13.2819 20.5732 12.807 20.5732 12.5141 20.2803L10.7945 18.5607V20.75C10.7945 21.1642 10.4587 21.5 10.0445 21.5C9.63033 21.5 9.29453 21.1642 9.29453 20.75V18.5607L7.57484 20.2803C7.28195 20.5732 6.80707 20.5732 6.51418 20.2803C6.22129 19.9874 6.22129 19.5126 6.51418 19.2197L9.29453 16.4393V12.049L5.4923 14.2443L4.47463 18.0423C4.36742 18.4424 3.95617 18.6798 3.55607 18.5726C3.15597 18.4654 2.91853 18.0541 3.02574 17.654L3.65518 15.3049L1.75916 16.3996C1.40044 16.6067 0.941743 16.4838 0.734643 16.1251C0.527533 15.7663 0.650443 15.3077 1.00916 15.1005L2.90518 14.0059L0.556073 13.3764C0.155973 13.2692 -0.081467 12.858 0.0257431 12.4579C0.132943 12.0578 0.544203 11.8203 0.944303 11.9275L4.7423 12.9452L8.54453 10.75L4.74249 8.55492L0.944493 9.5726C0.544393 9.6798 0.133143 9.4424 0.0259331 9.0423C-0.0812669 8.64216 0.156163 8.23091 0.556263 8.1237L2.90538 7.49426L1.00935 6.39959C0.650633 6.19248 0.527733 5.73379 0.734833 5.37507C0.941943 5.01635 1.40063 4.89344 1.75935 5.10055L3.65538 6.19522L3.02593 3.84611C2.91873 3.44601 3.15616 3.03475 3.55626 2.92755C3.95636 2.82034 4.36762 3.05778 4.47482 3.45788L5.49249 7.25588L9.29453 9.451V5.06066L6.51418 2.28033C6.22129 1.98744 6.22129 1.51256 6.51418 1.21967C6.80707 0.92678 7.28195 0.92678 7.57484 1.21967L9.29453 2.93934V0.75C9.29453 0.33579 9.63033 0 10.0445 0Z" fill="white" fill-opacity="0.2"/>
            </svg>
            ';

            $ays_chatgpt_cta_button_link = esc_url('https://ays-pro.com/wordpress/chatgpt-assistant?utm_source=dashboard&utm_medium=chatgpt-free&utm_campaign=christmas-sale-banner-' . CHATGPT_ASSISTANT_VERSION);

            $content[] = '<div id="ays-chatgpt-christmas-banner-main" class="notice notice-success is-dismissible ays-chatgpt-christmas-banner-info ays_chatgpt_dicount_info">';
                $content[] = '<div id="ays-chatgpt-christmas-banner-month" class="ays-chatgpt-christmas-banner-month">';
                    
                    // Background effects
                    $content[] = '<div class="ays-chatgpt-christmas-banner-bg-effects">';
                        $content[] = '<div class="ays-chatgpt-christmas-banner-bg-gradient-1"></div>';
                        $content[] = '<div class="ays-chatgpt-christmas-banner-bg-gradient-2"></div>';
                        
                        // Snowflakes
                        $content[] = '<div class="ays-chatgpt-christmas-banner-snowflake" style="left: 5%; animation-delay: 0s; animation-duration: 8s;">'. $svg_icon .'</div>';
                        $content[] = '<div class="ays-chatgpt-christmas-banner-snowflake" style="left: 15%; animation-delay: 2s; animation-duration: 10s;">'. $svg_icon .'</div>';
                        $content[] = '<div class="ays-chatgpt-christmas-banner-snowflake" style="left: 25%; animation-delay: 4s; animation-duration: 9s;">'. $svg_icon .'</div>';
                        $content[] = '<div class="ays-chatgpt-christmas-banner-snowflake" style="left: 75%; animation-delay: 1s; animation-duration: 11s;">'. $svg_icon .'</div>';
                        $content[] = '<div class="ays-chatgpt-christmas-banner-snowflake" style="left: 85%; animation-delay: 3s; animation-duration: 8s;">'. $svg_icon .'</div>';
                        $content[] = '<div class="ays-chatgpt-christmas-banner-snowflake" style="left: 92%; animation-delay: 5s; animation-duration: 10s;">'. $svg_icon .'</div>';
                        
                        // Sparkles
                        $content[] = '<svg class="ays-chatgpt-christmas-banner-sparkle" style="top: 20%; left: 8%; animation-delay: 0s; width: 14px; height: 14px;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">';
                            $content[] = '<path d="M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"/>';
                        $content[] = '</svg>';
                        $content[] = '<svg class="ays-chatgpt-christmas-banner-sparkle" style="top: 60%; left: 3%; animation-delay: 0.5s; width: 10px; height: 10px;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">';
                            $content[] = '<path d="M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"/>';
                        $content[] = '</svg>';
                        $content[] = '<svg class="ays-chatgpt-christmas-banner-sparkle" style="top: 30%; right: 12%; animation-delay: 1s; width: 12px; height: 12px;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">';
                            $content[] = '<path d="M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"/>';
                        $content[] = '</svg>';
                    $content[] = '</div>';

                    // Main content
                    $content[] = '<div class="ays-chatgpt-christmas-banner-content">';
                        $content[] = '<div class="ays-chatgpt-christmas-banner-left">';
                            // Gift icon with hat
                            $content[] = '<div class="ays-chatgpt-christmas-banner-gift-wrapper">';
                                $content[] = '<svg class="ays-chatgpt-christmas-banner-gift-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">';
                                    $content[] = '<rect x="3" y="8" width="18" height="4" rx="1"></rect>';
                                    $content[] = '<path d="M12 8v13"></path>';
                                    $content[] = '<path d="M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7"></path>';
                                    $content[] = '<path d="M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5"></path>';
                                $content[] = '</svg>';
                                $content[] = '<div class="ays-chatgpt-christmas-banner-hat">';
                                    $content[] = '<svg viewBox="0 0 24 24" fill="none" class="ays-chatgpt-christmas-banner-hat-svg">';
                                        $content[] = '<path d="M12 2L4 14h16L12 2z" fill="hsl(0 80% 45%)"></path>';
                                        $content[] = '<path d="M4 14c0 2 3.5 3 8 3s8-1 8-3" fill="hsl(0 0% 100%)"></path>';
                                        $content[] = '<circle cx="12" cy="3" r="2" fill="hsl(0 0% 100%)"></circle>';
                                    $content[] = '</svg>';
                                $content[] = '</div>';
                            $content[] = '</div>';

                            $content[] = '<div class="ays-chatgpt-christmas-banner-special-label">';
                                $content[] = '<div class="ays-chatgpt-christmas-banner-special-label-name">';
                                    $content[] = '<a href="'. $ays_chatgpt_cta_button_link .'" class="ays-chatgpt-christmas-banner-special-label-name-link" target="_blank">';
                                        $content[] = __( 'Chatgpt Assistant', "ays-chatgpt-assistant" );
                                    $content[] = '</a>';
                                $content[] = '</div>';

                                $content[] = '<div>✦ ' . __( 'CHRISTMAS SPECIAL', "ays-chatgpt-assistant" ) . ' ✦</div>';
                            $content[] = '</div>';
                        $content[] = '</div>';

                        $content[] = '<div class="ays-chatgpt-christmas-banner-center">';
                            $content[] = '<div class="ays-chatgpt-christmas-banner-discount-text">25% OFF</div>';
                            $content[] = '<div class="ays-chatgpt-christmas-banner-limited-offer">' . __( 'Limited time offer', "ays-chatgpt-assistant" ) . '</div>';
                        $content[] = '</div>';

                        $content[] = '<div class="ays-chatgpt-christmas-banner-right">';
                            $content[] = '<div class="ays-chatgpt-christmas-banner-coupon-box" onclick="aysChatgptChristmasCopyToClipboard(\'XMAS25\')" title="' . __( 'Click to copy', "ays-chatgpt-assistant" ) . '">';
                                $content[] = '<span class="ays-chatgpt-christmas-banner-coupon-text">XMAS25</span>';
                                $content[] = '<svg class="ays-chatgpt-christmas-banner-copy-icon" width="16" height="16" viewBox="0 0 16 16" fill="none">';
                                    $content[] = '<path d="M13.5 2.5H6.5C5.67 2.5 5 3.17 5 4V10C5 10.83 5.67 11.5 6.5 11.5H13.5C14.33 11.5 15 10.83 15 10V4C15 3.17 14.33 2.5 13.5 2.5ZM13.5 10H6.5V4H13.5V10ZM2.5 6.5V12.5C2.5 13.33 3.17 14 4 14H10V12.5H4V6.5H2.5Z" fill="white"/>';
                                $content[] = '</svg>';
                            $content[] = '</div>';

                            $content[] = '<a href="'. $ays_chatgpt_cta_button_link .'" class="ays-chatgpt-christmas-banner-buy-now-btn" target="_blank">';
                                $content[] = __( 'Buy Now', "ays-chatgpt-assistant" );
                            $content[] = '</a>';
                        $content[] = '</div>';
                    $content[] = '</div>';

                $content[] = '</div>';

                if( current_user_can( 'manage_options' ) ){
                $content[] = '<div id="ays-chatgpt-dismiss-buttons-content">';
                    $content[] = '<form action="" method="POST" style="position: absolute; bottom: 0; right: 0; color: #fff;">';
                            $content[] = '<button class="btn btn-link ays-button" name="ays_chatgpt_sale_btn" style="color: darkgrey; font-size: 11px; padding: 0 .75rem;">'. __( "Dismiss ad", 'ays-chatgpt-assistant' ) .'</button>';
                            $content[] = wp_nonce_field( CHATGPT_ASSISTANT_NAME . '-sale-banner' ,  CHATGPT_ASSISTANT_NAME . '-sale-banner' );
                    $content[] = '</form>';
                $content[] = '</div>';
                }

            $content[] = '</div>';

            $content[] = '<script>';
            $content[] = "
                function aysChatgptChristmasCopyToClipboard(text) {
                    var textarea = document.createElement('textarea');
                    textarea.value = text;
                    textarea.style.position = 'fixed';
                    textarea.style.opacity = '0';
                    document.body.appendChild(textarea);
                    
                    textarea.select();
                    textarea.setSelectionRange(0, 99999);
                    
                    try {
                        document.execCommand('copy');
                        aysChatgptChristmasShowCopyNotification('" . __( 'Coupon code copied!', "ays-chatgpt-assistant" ) . "');
                    } catch (err) {
                        console.error('Failed to copy text: ', err);
                    }
                    
                    document.body.removeChild(textarea);
                }

                function aysChatgptChristmasShowCopyNotification(message) {
                    var existingNotification = document.querySelector('.ays-chatgpt-christmas-banner-copy-notification');
                    if (existingNotification) {
                        document.body.removeChild(existingNotification);
                    }
                    
                    var notification = document.createElement('div');
                    notification.className = 'ays-chatgpt-christmas-banner-copy-notification';
                    notification.textContent = message;
                    document.body.appendChild(notification);
                    
                    setTimeout(function() {
                        notification.classList.add('show');
                    }, 10);
                    
                    setTimeout(function() {
                        notification.classList.remove('show');
                        setTimeout(function() {
                            if (notification.parentNode) {
                                document.body.removeChild(notification);
                            }
                        }, 300);
                    }, 2000);
                }";
            $content[] = '</script>';                

            $content[] = '<style>';
            $content[] = '
                /* Christmas banner start */

                div#ays-chatgpt-christmas-banner-main .btn-link {
                    background-color: transparent;
                    display: inline-block;
                    font-weight: 400;
                    text-align: center;
                    white-space: nowrap;
                    vertical-align: middle;
                    -webkit-user-select: none;
                    -moz-user-select: none;
                    -ms-user-select: none;
                    user-select: none;
                    border: 1px solid transparent;
                    padding: .375rem .75rem;
                    font-size: 12px;
                    line-height: 1.5;
                    border-radius: .25rem;
                    color: rgba(255, 255, 255, .6);
                }
                
                div#ays-chatgpt-christmas-banner-main.ays-chatgpt-christmas-banner-info {
                    background: linear-gradient(to right, hsl(0, 70%, 28%), hsl(0, 65%, 38%), hsl(0, 70%, 28%));
                    padding: unset;
                    border-left: 0;
                    position: relative;
                }
                
                #ays-chatgpt-christmas-banner-main .ays-chatgpt-christmas-banner-month {
                    position: relative;
                    padding: 15px 40px;
                    overflow: hidden;
                }
                
                /* Background effects */
                .ays-chatgpt-christmas-banner-bg-effects {
                    position: absolute;
                    top: 0;
                    left: 0;
                    right: 0;
                    bottom: 0;
                    pointer-events: none;
                    z-index: 1;
                }
                
                .ays-chatgpt-christmas-banner-bg-gradient-1 {
                    position: absolute;
                    top: 0;
                    left: 30%;
                    width: 40%;
                    height: 100%;
                    background: radial-gradient(circle, rgba(202, 43, 43, 0.5) 0%, transparent 60%);
                    opacity: 0.4;
                }
                
                .ays-chatgpt-christmas-banner-bg-gradient-2 {
                    position: absolute;
                    top: 0;
                    right: 15%;
                    width: 35%;
                    height: 100%;
                    background: radial-gradient(circle, rgba(246, 201, 85, 0.15) 0%, transparent 50%);
                    opacity: 0.3;
                }
                
                .ays-chatgpt-christmas-banner-snowflake {
                    position: absolute;
                    color: rgba(255, 255, 255, 0.2);
                    font-size: 20px;
                    animation: ays-chatgpt-christmas-snowfall linear infinite;
                    top: -10px;
                }
                
                @keyframes ays-chatgpt-christmas-snowfall {
                    0% {
                        transform: translateY(-10px) rotate(0deg);
                        opacity: 0;
                    }
                    10% {
                        opacity: 0.8;
                    }
                    90% {
                        opacity: 0.8;
                    }
                    100% {
                        transform: translateY(100%) rotate(360deg);
                        opacity: 0;
                    }
                }
                
                .ays-chatgpt-christmas-banner-sparkle {
                    position: absolute;
                    color: hsl(43, 90%, 65%);
                    animation: ays-chatgpt-christmas-twinkle 2s ease-in-out infinite;
                }
                
                @keyframes ays-chatgpt-christmas-twinkle {
                    0%, 100% {
                        opacity: 0.3;
                        transform: scale(0.8);
                    }
                    50% {
                        opacity: 1;
                        transform: scale(1.2);
                    }
                }
                
                /* Main content */
                .ays-chatgpt-christmas-banner-content {
                    position: relative;
                    display: flex;
                    align-items: center;
                    justify-content: space-between;
                    z-index: 2;
                }
                
                /* Left section */
                .ays-chatgpt-christmas-banner-left {
                    display: flex;
                    align-items: center;
                    gap: 50px;
                }
                
                .ays-chatgpt-christmas-banner-gift-wrapper {
                    position: relative;
                    animation: ays-chatgpt-christmas-float 3s ease-in-out infinite;
                }
                
                .ays-chatgpt-christmas-banner-gift-icon {
                    width: 48px;
                    height: 48px;
                    color: rgba(255, 247, 237, 0.9);
                }
                
                @keyframes ays-chatgpt-christmas-float {
                    0%, 100% {
                        transform: translateY(0);
                    }
                    50% {
                        transform: translateY(-5px);
                    }
                }
                
                .ays-chatgpt-christmas-banner-hat {
                    position: absolute;
                    top: -12px;
                    right: -4px;
                    width: 24px;
                    height: 24px;
                }
                
                .ays-chatgpt-christmas-banner-hat-svg {
                    width: 100%;
                    height: 100%;
                }
                
                .ays-chatgpt-christmas-banner-special-label {
                    color: hsl(43, 90%, 65%);
                    font-size: 14px;
                    font-weight: 500;
                    text-transform: uppercase;
                    letter-spacing: 1px;
                    /* font-family: "Outfit", sans-serif; */
                }

                .ays-chatgpt-christmas-banner-special-label-name {
                    color: #fffaf0;
                    text-align: center;
                }

                div#ays-chatgpt-christmas-banner-main .ays-chatgpt-christmas-banner-special-label-name-link {
                    color: #fffaf0;
                    box-shadow: unset;
                }
                
                /* Center section */
                .ays-chatgpt-christmas-banner-center {
                    display: flex;
                    flex-direction: row;
                    text-align: center;
                    justify-content: center;
                    align-items: center;
                    gap: 30px;
                }
                
                .ays-chatgpt-christmas-banner-discount-text {
                    font-family: "Outfit", sans-serif;
                    font-weight: 800;
                    font-size: 30px;
                    color: hsl(40, 100%, 97%);
                    letter-spacing: -1px;
                    line-height: 1;
                }
                
                .ays-chatgpt-christmas-banner-limited-offer {
                    color: rgba(255, 247, 237, 0.7);
                    font-size: 13px;
                    font-weight: 500;
                }
                
                /* Right section */
                .ays-chatgpt-christmas-banner-right {
                    display: flex;
                    align-items: center;
                    gap: 20px;
                }
                
                .ays-chatgpt-christmas-banner-coupon-box {
                    border: 2px dashed rgba(255, 255, 255, 0.4);
                    padding: 8px 16px;
                    border-radius: 6px;
                    background: rgba(255, 255, 255, 0.1);
                    cursor: pointer;
                    transition: all 0.3s;
                    display: flex;
                    align-items: center;
                    gap: 8px;
                    backdrop-filter: blur(10px);
                }
                
                .ays-chatgpt-christmas-banner-coupon-box:hover {
                    background: rgba(255, 255, 255, 0.2);
                    border-color: rgba(255, 255, 255, 0.6);
                    transform: translateY(-1px);
                }
                
                .ays-chatgpt-christmas-banner-coupon-text {
                    font-size: 16px;
                    font-weight: 700;
                    letter-spacing: 1px;
                    color: #fff;
                    font-family: monospace;
                }
                
                .ays-chatgpt-christmas-banner-copy-icon {
                    opacity: 0.8;
                    transition: opacity 0.3s;
                }
                
                .ays-chatgpt-christmas-banner-coupon-box:hover .ays-chatgpt-christmas-banner-copy-icon {
                    opacity: 1;
                }
                
                #ays-chatgpt-christmas-banner-main .ays-chatgpt-christmas-banner-buy-now-btn {
                    background-color: #fbe19f;
                    color: hsl(0, 72%, 35%);
                    padding: 10px 30px;
                    border-radius: 9999px;
                    font-size: 16px;
                    font-weight: 600;
                    font-family: "Outfit", sans-serif;
                    border: none;
                    cursor: pointer;
                    transition: all 0.3s;
                    text-decoration: none;
                    display: flex;
                    align-items: center;
                    gap: 6px;
                    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 0 30px rgba(246, 201, 85, 0.2);
                }
                
                #ays-chatgpt-christmas-banner-main .ays-chatgpt-christmas-banner-buy-now-btn:hover {
                    background-color: #f2d58c;
                    transform: scale(1.05);
                    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2), 0 0 40px rgba(246, 201, 85, 0.3);
                }
                
                .ays-chatgpt-christmas-banner-btn-arrow {
                    display: inline-block;
                    transition: transform 0.3s;
                }
                
                .ays-chatgpt-christmas-banner-buy-now-btn:hover .ays-chatgpt-christmas-banner-btn-arrow {
                    transform: translateX(4px);
                }
                
                /* Notification */
                .ays-chatgpt-christmas-banner-copy-notification {
                    position: fixed;
                    top: 50%;
                    left: 50%;
                    transform: translate(-50%, -50%);
                    background: rgba(0, 0, 0, 0.8);
                    color: #fff;
                    padding: 12px 24px;
                    border-radius: 8px;
                    font-size: 14px;
                    z-index: 10000;
                    opacity: 0;
                    transition: opacity 0.3s;
                }
                
                .ays-chatgpt-christmas-banner-copy-notification.show {
                    opacity: 1;
                }
                
                /* Dismiss button */
                #ays-chatgpt-christmas-banner-main #ays-chatgpt-christmas-banner-dismiss-content {
                    display: flex;
                    justify-content: center;
                }
                
                #ays-chatgpt-christmas-banner-main #ays-chatgpt-christmas-banner-dismiss-content .ays-button {
                    margin: 0 !important;
                    font-size: 13px;
                    color: rgba(150, 147, 147, 0.69);
                }
                
                /* Responsive */
                @media (max-width: 1024px) {
                    .ays-chatgpt-christmas-banner-discount-text {
                        font-size: 40px;
                    }
                    .ays-chatgpt-christmas-banner-content {
                        flex-wrap: wrap;
                    }
                }
                
                @media (max-width: 768px) {
                    #ays-chatgpt-christmas-banner-main {
                        display: none !important;
                    }
                }
                /* Christmas banner end */
            ';
            $content[] = '</style>';

            $content = implode( '', $content );

            echo $content;
        }
    }

    	public function ays_chatgpt_add_body_class( $classes ) {
        global $pagenow;

        if ( $pagenow === 'admin.php' ) {
            $page = isset( $_GET['page'] ) ? sanitize_key( $_GET['page'] ) : '';
            
            if ( strpos( $page, $this->plugin_name ) === 0 ) {
                $classes .= ' ays-chatgpt-assistant-admin';
            }
        }

        return $classes;
    }

    
    /**
     * Determine if the plugin/addon installations are allowed.
     *
     * @since 6.4.0.4
     *
     * @param string $type Should be `plugin` or `addon`.
     *
     * @return bool
     */
    public static function ays_chatgpt_can_install( $type ) {

        return self::ays_chatgpt_can_do( 'install', $type );
    }

    /**
     * Determine if the plugin/addon activations are allowed.
     *
     * @since 6.4.0.4
     *
     * @param string $type Should be `plugin` or `addon`.
     *
     * @return bool
     */
    public static function ays_chatgpt_can_activate( $type ) {

        return self::ays_chatgpt_can_do( 'activate', $type );
    }

    /**
     * Determine if the plugin/addon installations/activations are allowed.
     *
     * @since 6.4.0.4
     *
     * @param string $what Should be 'activate' or 'install'.
     * @param string $type Should be `plugin` or `addon`.
     *
     * @return bool
     */
    public static function ays_chatgpt_can_do( $what, $type ) {

        if ( ! in_array( $what, array( 'install', 'activate' ), true ) ) {
            return false;
        }

        if ( ! in_array( $type, array( 'plugin', 'addon' ), true ) ) {
            return false;
        }

        $capability = $what . '_plugins';

        if ( ! current_user_can( $capability ) ) {
            return false;
        }

        // Determine whether file modifications are allowed and it is activation permissions checking.
        if ( $what === 'install' && ! wp_is_file_mod_allowed( 'ays_chatgpt_can_install' ) ) {
            return false;
        }

        // All plugin checks are done.
        if ( $type === 'plugin' ) {
            return true;
        }
        return false;
    }

    /**
     * Activate plugin.
     *
     * @since 1.0.0
     * @since 6.4.0.4 Updated the permissions checking.
     */
    public function ays_chatgpt_activate_plugin() {

        // Run a security check.
        if ( isset( $_REQUEST['_ajax_nonce'] ) ) {
            check_ajax_referer( $this->plugin_name . '-install-plugin-nonce', sanitize_key( $_REQUEST['_ajax_nonce'] ) );
        } 

        // Check for permissions.
        if ( ! current_user_can( 'activate_plugins' ) ) {
            wp_send_json_error( esc_html__( 'Plugin activation is disabled for you on this site.', 'ays-chatgpt-assistant' ) );
        }

        $type = 'addon';

        if ( isset( $_POST['plugin'] ) ) {

            if ( ! empty( $_POST['type'] ) ) {
                $type = sanitize_key( $_POST['type'] );
            }

            $plugin   = sanitize_text_field( wp_unslash( $_POST['plugin'] ) );
            $activate = activate_plugins( $plugin );

            if ( ! is_wp_error( $activate ) ) {
                if ( $type === 'plugin' ) {
                    wp_send_json_success( esc_html__( 'Plugin activated.', 'ays-chatgpt-assistant' ) );
                } else {
                        ( esc_html__( 'Addon activated.', 'ays-chatgpt-assistant' ) );
                }
            }
        }

        if ( $type === 'plugin' ) {
            wp_send_json_error( esc_html__( 'Could not activate the plugin. Please activate it on the Plugins page.', 'ays-chatgpt-assistant' ) );
        }

        wp_send_json_error( esc_html__( 'Could not activate the addon. Please activate it on the Plugins page.', 'ays-chatgpt-assistant' ) );
    }

    /**
     * Install addon.
     *
     * @since 1.0.0
     * @since 6.4.0.4 Updated the permissions checking.
     */
    public function ays_chatgpt_install_plugin() {
       
        // Run a security check.
        if ( isset( $_REQUEST['_ajax_nonce'] ) ) {
            check_ajax_referer( $this->plugin_name . '-install-plugin-nonce', sanitize_key( $_REQUEST['_ajax_nonce'] ) );
        } 

        $generic_error = esc_html__( 'There was an error while performing your request.', 'ays-chatgpt-assistant' );
        $type          = ! empty( $_POST['type'] ) ? sanitize_key( $_POST['type'] ) : '';

        // Check if new installations are allowed.
        if ( ! self::ays_chatgpt_can_install( $type ) ) {
            wp_send_json_error( $generic_error );
        }

        $error = $type === 'plugin'
            ? esc_html__( 'Could not install the plugin. Please download and install it manually.', 'ays-chatgpt-assistant' )
            : "";

        $plugin_url = ! empty( $_POST['plugin'] ) ? esc_url_raw( wp_unslash( $_POST['plugin'] ) ) : '';

        if ( empty( $plugin_url ) ) {
            wp_send_json_error( $error );
        }

        // Prepare variables.
        $url = esc_url_raw(
            add_query_arg(
                [
                    'page' => 'ays-chatgpt-assistant-featured-plugins',
                ],
                admin_url( 'admin.php' )
            )
        );

        ob_start();
        $creds = request_filesystem_credentials( $url, '', false, false, null );

        // Hide the filesystem credentials form.
        ob_end_clean();

        // Check for file system permissions.
        if ( $creds === false ) {
            wp_send_json_error( $error );
        }
        
        if ( ! WP_Filesystem( $creds ) ) {
            wp_send_json_error( $error );
        }

        /*
         * We do not need any extra credentials if we have gotten this far, so let's install the plugin.
         */
        require_once CHATGPT_ASSISTANT_DIR . 'includes/admin/class-chatgpt-assistant-upgrader.php';
        require_once CHATGPT_ASSISTANT_DIR . 'includes/admin/class-chatgpt-assistant-install-skin.php';
        require_once CHATGPT_ASSISTANT_DIR . 'includes/admin/class-chatgpt-assistant-skin.php';


        // Do not allow WordPress to search/download translations, as this will break JS output.
        remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );

        // Create the plugin upgrader with our custom skin.
        $installer = new ChatgptAssistant\Helpers\ChatgptAssistantSilentUpgrader( new Chatgpt_Assistant_Install_Skin() );

        // Error check.
        if ( ! method_exists( $installer, 'install' ) ) {
            wp_send_json_error( $error );
        }

        $installer->install( $plugin_url );

        // Flush the cache and return the newly installed plugin basename.
        wp_cache_flush();

        $plugin_basename = $installer->plugin_info();

        if ( empty( $plugin_basename ) ) {
            wp_send_json_error( $error );
        }

        $result = array(
            'msg'          => $generic_error,
            'is_activated' => false,
            'basename'     => $plugin_basename,
        );

        // Check for permissions.
        if ( ! current_user_can( 'activate_plugins' ) ) {
            $result['msg'] = $type === 'plugin' ? esc_html__( 'Plugin installed.', 'ays-chatgpt-assistant' ) : "";

            wp_send_json_success( $result );
        }

        // Activate the plugin silently.
        $activated = activate_plugin( $plugin_basename );
        remove_action( 'activated_plugin', array( 'ays_sccp_activation_redirect_method', 'gallery_p_gallery_activation_redirect_method', 'poll_maker_activation_redirect_method' ), 100 );

        if ( ! is_wp_error( $activated ) ) {

            $result['is_activated'] = true;
            $result['msg']          = $type === 'plugin' ? esc_html__( 'Plugin installed and activated.', 'ays-chatgpt-assistant' ) : esc_html__( 'Addon installed and activated.', 'ays-chatgpt-assistant' );

            wp_send_json_success( $result );
        }

        // Fallback error just in case.
        wp_send_json_error( $result );
    }

    protected function ays_chatgpt_get_latest_plugin_version( $slug ){

        if ( is_null( $slug ) || empty($slug) ) {
            return "";
        }

        $version_latest = "";

        if ( ! function_exists( 'plugins_api' ) ) {
              require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
        }

        // set the arguments to get latest info from repository via API ##
        $args = array(
            'slug'   => $slug,
            'fields' => array(
                'version' => true,
            )
        );

        /** Prepare our query */
        $call_api = plugins_api( 'plugin_information', $args );

        /** Check for Errors & Display the results */
        if ( is_wp_error( $call_api ) ) {
            $api_error = $call_api->get_error_message();
        } else {

            //echo $call_api; 
            // everything ##
            if ( ! empty( $call_api->version ) ) {
                $version_latest = $call_api->version;
            }
        }

        return $version_latest;
    }

    /**
     * List of AM plugins that we propose to install.
     *
     * @since 6.4.0.4
     *
     * @return array
     */
    protected function get_am_plugins() {
        if ( !isset( $_SESSION ) ) {
            session_start();
        }

        $images_url = CHATGPT_ASSISTANT_ADMIN_URL . '/images/icons/';

        $plugin_slug = array(
            'fox-lms',
            'quiz-maker',
            'survey-maker',
            'poll-maker',
            'ays-popup-box',
            'secure-copy-content-protection',
            'gallery-photo-gallery',
            'chart-builder',
            'easy-form',
        );

        $plugin_url_arr = array();
        foreach ($plugin_slug as $key => $slug) {
            if ( isset( $_SESSION['ays_assistant_our_product_links'] ) && !empty( $_SESSION['ays_assistant_our_product_links'] ) 
                && isset( $_SESSION['ays_assistant_our_product_links'][$slug] ) && !empty( $_SESSION['ays_assistant_our_product_links'][$slug] ) ) {
                $plugin_url = (isset( $_SESSION['ays_assistant_our_product_links'][$slug] ) && $_SESSION['ays_assistant_our_product_links'][$slug] != "") ? esc_url_raw(sanitize_text_field($_SESSION['ays_assistant_our_product_links'][$slug])) : "";
            } else {
                $latest_version = $this->ays_chatgpt_get_latest_plugin_version($slug);
                $plugin_url = 'https://downloads.wordpress.org/plugin/'. $slug .'.zip';
                if ( $latest_version != '' ) {
                    $plugin_url = 'https://downloads.wordpress.org/plugin/'. $slug .'.'. $latest_version .'.zip';
                    $_SESSION['ays_assistant_our_product_links'][$slug] = $plugin_url;
                }
            }

            $plugin_url_arr[$slug] = $plugin_url;
        }

        $plugins_array = array(
            'fox-lms/fox-lms.php'        => array(
                'icon'        => $images_url . 'icon-fox-lms-128x128.png',
                'name'        => __( 'Fox LMS', 'ays-chatgpt-assistant' ),
                'desc'        => __( 'Build and manage online courses directly on your WordPress site.', 'ays-chatgpt-assistant' ),
                'desc_hidden' => __( 'With the FoxLMS plugin, you can create, sell, and organize courses, lessons, and quizzes, transforming your website into a dynamic e-learning platform.', 'ays-chatgpt-assistant' ),
                'wporg'       => 'https://wordpress.org/plugins/fox-lms/',
                'buy_now'     => 'https://foxlms.com/pricing/?utm_source=dashboard&utm_medium=chatgpt-free&utm_campaign=fox-lms-our-products-page',
                'url'         => $plugin_url_arr['fox-lms'],
            ),
            'quiz-maker/quiz-maker.php'        => array(
                'icon'        => $images_url . 'icon-quiz-128x128.png',
                'name'        => __( 'Quiz Maker', 'ays-chatgpt-assistant' ),
                'desc'        => __( 'Create powerful and engaging quizzes, tests, and exams in minutes.', 'ays-chatgpt-assistant' ),
                'desc_hidden' => __( 'Build an unlimited number of quizzes and questions.', 'ays-chatgpt-assistant' ),
                'wporg'       => 'https://wordpress.org/plugins/quiz-maker/',
                'buy_now'     => 'https://ays-pro.com/wordpress/quiz-maker/',
                'url'         => $plugin_url_arr['quiz-maker'],
            ),
            'survey-maker/survey-maker.php'        => array(
                'icon'        => $images_url . 'icon-survey-128x128.png',
                'name'        => __( 'Survey Maker', 'ays-chatgpt-assistant' ),
                'desc'        => __( 'Make amazing online surveys and get real-time feedback quickly and easily.', 'ays-chatgpt-assistant' ),
                'desc_hidden' => __( 'Learn what your website visitors want, need, and expect with the help of Survey Maker. Build surveys without limiting your needs.', 'ays-chatgpt-assistant' ),
                'wporg'       => 'https://wordpress.org/plugins/survey-maker/',
                'buy_now'     => 'https://ays-pro.com/wordpress/survey-maker',
                'url'         => $plugin_url_arr['survey-maker'],
            ),
            'poll-maker/poll-maker-ays.php'        => array(
                'icon'        => $images_url . 'icon-poll-128x128.png',
                'name'        => __( 'Poll Maker', 'ays-chatgpt-assistant' ),
                'desc'        => __( 'Create amazing online polls for your WordPress website super easily.', 'ays-chatgpt-assistant' ),
                'desc_hidden' => __( 'Build up various types of polls in a minute and get instant feedback on any topic or product.', 'ays-chatgpt-assistant' ),
                'wporg'       => 'https://wordpress.org/plugins/poll-maker/',
                'buy_now'     => 'https://ays-pro.com/wordpress/poll-maker/',
                'url'         => $plugin_url_arr['poll-maker'],
            ),
            'ays-popup-box/ays-pb.php'        => array(
                'icon'        => $images_url . 'icon-popup-128x128.png',
                'name'        => __( 'Popup Box', 'ays-chatgpt-assistant' ),
                'desc'        => __( 'Popup everything you want! Create informative and promotional popups all in one plugin.', 'ays-chatgpt-assistant' ),
                'desc_hidden' => __( 'Attract your visitors and convert them into email subscribers and paying customers.', 'ays-chatgpt-assistant' ),
                'wporg'       => 'https://wordpress.org/plugins/ays-popup-box/',
                'buy_now'     => 'https://ays-pro.com/wordpress/popup-box/',
                'url'         => $plugin_url_arr['ays-popup-box'],
            ),
            'secure-copy-content-protection/secure-copy-content-protection.php'        => array(
                'icon'        => $images_url . 'icon-sccp-128x128.png',
                'name'        => __( 'Secure Copy Content Protection', 'ays-chatgpt-assistant' ),
                'desc'        => __( 'Disable the right click, copy paste, content selection and copy shortcut keys on your website.', 'ays-chatgpt-assistant' ),
                'desc_hidden' => __( 'Protect web content from being plagiarized. Prevent plagiarism from your website with this easy to use plugin.', 'ays-chatgpt-assistant' ),
                'wporg'       => 'https://wordpress.org/plugins/secure-copy-content-protection/',
                'buy_now'     => 'https://ays-pro.com/wordpress/secure-copy-content-protection/',
                'url'         => $plugin_url_arr['secure-copy-content-protection'],
            ),
            'gallery-photo-gallery/gallery-photo-gallery.php'        => array(
                'icon'        => $images_url . 'icon-gallery-128x128.png',
                'name'        => __( 'Gallery Photo Gallery', 'ays-chatgpt-assistant' ),
                'desc'        => __( 'Create unlimited galleries and include unlimited images in those galleries.', 'ays-chatgpt-assistant' ),
                'desc_hidden' => __( 'Represent images in an attractive way. Attract people with your own single and multiple free galleries from your photo library.', 'ays-chatgpt-assistant' ),
                'wporg'       => 'https://wordpress.org/plugins/gallery-photo-gallery/',
                'buy_now'     => 'https://ays-pro.com/wordpress/photo-gallery/',
                'url'         => $plugin_url_arr['gallery-photo-gallery'],
            ),
            'chart-builder/chart-builder.php'        => array(
                'icon'        => $images_url . 'icon-chart-128x128.png',
                'name'        => __( 'Chart Builder', 'ays-chatgpt-assistant' ),
                'desc'        => __( 'Chartify – Best Chart Builder Plugin', 'ays-chatgpt-assistant' ),
                'desc_hidden' => __( 'Chart Builder plugin allows you to create beautiful charts and graphs easily and quickly.', 'ays-chatgpt-assistant' ),
                'wporg'       => 'https://wordpress.org/plugins/chart-builder/',
                'buy_now'     => 'https://ays-pro.com/wordpress/chart-builder',
                'url'         => $plugin_url_arr['chart-builder'],
            ),
            'easy-form/easy-form.php'        => array(
                'icon'        => $images_url . 'icon-form-128x128.png',
                'name'        => __( 'Easy Form', 'ays-chatgpt-assistant' ),
                'desc'        => __( 'Choose the best WordPress form builder plugin. ', 'ays-chatgpt-assistant' ),
                'desc_hidden' => __( 'Create contact forms, payment forms, surveys, and many more custom forms. Build forms easily with us.', 'ays-chatgpt-assistant' ),
                'wporg'       => 'https://wordpress.org/plugins/easy-form/',
                'buy_now'     => 'https://ays-pro.com/wordpress/easy-form',
                'url'         => $plugin_url_arr['easy-form'],
            ),
        );

        return $plugins_array;
    }

    protected function get_plugin_data( $plugin, $details, $all_plugins ) {

        $have_pro = ( ! empty( $details['pro'] ) && ! empty( $details['pro']['plug'] ) );
        $show_pro = false;

        $plugin_data = array();

        if ( $have_pro ) {
            if ( array_key_exists( $plugin, $all_plugins ) ) {
                if ( is_plugin_active( $plugin ) ) {
                    $show_pro = true;
                }
            }
            if ( array_key_exists( $details['pro']['plug'], $all_plugins ) ) {
                $show_pro = true;
            }
            if ( $show_pro ) {
                $plugin  = $details['pro']['plug'];
                $details = $details['pro'];
            }
        }

        if ( array_key_exists( $plugin, $all_plugins ) ) {
            if ( is_plugin_active( $plugin ) ) {
                // Status text/status.
                $plugin_data['status_class'] = 'status-active';
                $plugin_data['status_text']  = esc_html__( 'Active', 'ays-chatgpt-assistant' );
                // Button text/status.
                $plugin_data['action_class'] = $plugin_data['status_class'] . ' ays-assistant-card__btn-info disabled';
                $plugin_data['action_text']  = esc_html__( 'Activated', 'ays-chatgpt-assistant' );
                $plugin_data['plugin_src']   = esc_attr( $plugin );
            } else {
                // Status text/status.
                $plugin_data['status_class'] = 'status-installed';
                $plugin_data['status_text']  = esc_html__( 'Inactive', 'ays-chatgpt-assistant' );
                // Button text/status.
                $plugin_data['action_class'] = $plugin_data['status_class'] . ' ays-assistant-card__btn-info';
                $plugin_data['action_text']  = esc_html__( 'Activate', 'ays-chatgpt-assistant' );
                $plugin_data['plugin_src']   = esc_attr( $plugin );
            }
        } else {
            // Doesn't exist, install.
            // Status text/status.
            $plugin_data['status_class'] = 'status-missing';

            if ( isset( $details['act'] ) && 'go-to-url' === $details['act'] ) {
                $plugin_data['status_class'] = 'status-go-to-url';
            }
            $plugin_data['status_text'] = esc_html__( 'Not Installed', 'ays-chatgpt-assistant' );
            // Button text/status.
            $plugin_data['action_class'] = $plugin_data['status_class'] . ' ays-assistant-card__btn-info';
            $plugin_data['action_text']  = esc_html__( 'Install Plugin', 'ays-chatgpt-assistant' );
            $plugin_data['plugin_src']   = esc_url( $details['url'] );
        }

        $plugin_data['details'] = $details;

        return $plugin_data;
    }

    /**
     * Display the Addons section of About tab.
     *
     * @since 6.4.0.4
     */
    public function output_about_addons() {

        if ( ! function_exists( 'get_plugins' ) ) {
            require_once ABSPATH . 'wp-admin/includes/plugin.php';
        }

        $all_plugins          = get_plugins();
        $am_plugins           = $this->get_am_plugins();
        $can_install_plugins  = self::ays_chatgpt_can_install( 'plugin' );
        $can_activate_plugins = self::ays_chatgpt_can_activate( 'plugin' );

        $content = '';
        $content.= '<div class="ays-assistant-cards-block">';
        foreach ( $am_plugins as $plugin => $details ){

            $plugin_data              = $this->get_plugin_data( $plugin, $details, $all_plugins );
            $plugin_ready_to_activate = $can_activate_plugins
                && isset( $plugin_data['status_class'] )
                && $plugin_data['status_class'] === 'status-installed';
            $plugin_not_activated     = ! isset( $plugin_data['status_class'] )
                || $plugin_data['status_class'] !== 'status-active';

            $plugin_action_class = ( isset( $plugin_data['action_class'] ) && esc_attr( $plugin_data['action_class'] ) != "" ) ? esc_attr( $plugin_data['action_class'] ) : "";

            $plugin_action_class_disbaled = "";
            if ( strpos($plugin_action_class, 'status-active') !== false ) {
                $plugin_action_class_disbaled = "disbaled='true'";
            }

            $content .= '
                <div class="ays-assistant-card">
                    <div class="ays-assistant-card__content flexible">
                        <div class="ays-assistant-card__content-img-box">
                            <img class="ays-assistant-card__img" src="'. esc_url( $plugin_data['details']['icon'] ) .'" alt="'. esc_attr( $plugin_data['details']['name'] ) .'">
                        </div>
                        <div class="ays-assistant-card__text-block">
                            <h5 class="ays-assistant-card__title">'. esc_html( $plugin_data['details']['name'] ) .'</h5>
                            <p class="ays-assistant-card__text">'. wp_kses_post( $plugin_data['details']['desc'] ) .'
                                <span class="ays-assistant-card__text-hidden">
                                    '. wp_kses_post( $plugin_data['details']['desc_hidden'] ) .'
                                </span>
                            </p>
                        </div>
                    </div>
                    <div class="ays-assistant-card__footer">';
                        if ( $can_install_plugins || $plugin_ready_to_activate || ! $details['wporg'] ) {
                            $content .= '<button class="'. esc_attr( $plugin_data['action_class'] ) .'" data-plugin="'. esc_attr( $plugin_data['plugin_src'] ) .'" data-type="plugin" '. $plugin_action_class_disbaled .'>
                                '. wp_kses_post( $plugin_data['action_text'] ) .'
                            </button>';
                        }
                        elseif ( $plugin_not_activated ) {
                            $content .= '<a href="'. esc_url( $details['wporg'] ) .'" target="_blank" rel="noopener noreferrer">
                                '. esc_html_e( 'WordPress.org', 'cys-chatgpt-assistant' ) .'
                                <span aria-hidden="true" class="dashicons dashicons-external"></span>
                            </a>';
                        }
            $content .='
                        <a target="_blank" href="'. esc_url( $plugin_data['details']['buy_now'] ) .'" class="ays-assistant-card__btn-primary">'. __('Buy Now', 'ays-chatgpt-assistant') .'</a>
                    </div>
                </div>';
        }
        $install_plugin_nonce = wp_create_nonce( $this->plugin_name . '-install-plugin-nonce' );
        
        $content.= '<input type="hidden" id="ays_assistant_ajax_install_plugin_nonce" name="ays_assistant_ajax_install_plugin_nonce" value="'. $install_plugin_nonce .'">';
        $content.= '</div>';

        echo html_entity_decode($content);
    }

    public function add_action_links($links){
        /*
        *  Documentation : https://codex.wordpress.org/Plugin_API/Filter_Reference/plugin_action_links_(plugin_file_name)
        */

        $chatgpt_assistant_ajax_deactivate_plugin_nonce = wp_create_nonce( 'chatgpt-assistant-ajax-deactivate-plugin-nonce' );


        $settings_link = array(
            '<a href="' . admin_url('admin.php?page=' . $this->plugin_name) . '">' . __('Settings', "ays-chatgpt-assistant") . '</a>',
            '<a href="https://plugins.ays-demo.com/wordpress-chatgpt-plugin-demo/" target="_blank">' . __('Demo', "ays-chatgpt-assistant") . '</a>',
            '<a href="https://ays-pro.com/wordpress/chatgpt-assistant?utm_source=dashboard&utm_medium=gpt-free&utm_campaign=plugins-buy-now-button" target="_blank" id="ays-chatgpt-plugins-buy-now-button">' . __('Upgrade 30% sale', "ays-chatgpt-assistant") . '</a>',
            '<input type="hidden" id="ays_chatgpt_assistant_ajax_deactivate_plugin_nonce" name="ays_chatgpt_assistant_ajax_deactivate_plugin_nonce" value="' . $chatgpt_assistant_ajax_deactivate_plugin_nonce .'">',
        );
        return array_merge($settings_link, $links);

    }

    public function deactivate_plugin_option_ai(){
        // Verify capability check
        if ( ! current_user_can( 'manage_options' ) ) {
            return json_encode( array( 'status' => false, 'message' => 'Unauthorized' ) );
        }
        
        // phpcs:ignore WordPress.Security.NonceVerification.Recommended


        // Run a security check.
        check_ajax_referer( 'chatgpt-assistant-ajax-deactivate-plugin-nonce', sanitize_key( $_REQUEST['_ajax_nonce'] ) );

        // Check for permissions.
        if ( ! current_user_can( 'manage_options' ) ) {
            ob_end_clean();
            $ob_get_clean = ob_get_clean();
            echo json_encode(array(
                'option' => ''
            ));
            wp_die();
        }

        if( is_user_logged_in() ) {
            $request_value = esc_sql( sanitize_text_field( $_REQUEST['upgrade_plugin'] ) );
            $upgrade_option = get_option( 'ays_chatgpt_assistant_upgrade_plugin', '' );
        if($upgrade_option === ''){
            add_option( 'ays_chatgpt_assistant_upgrade_plugin', $request_value );
        }else{
            update_option( 'ays_chatgpt_assistant_upgrade_plugin', $request_value );
        }
         ob_end_clean();
            $ob_get_clean = ob_get_clean();
            echo json_encode(array(
                'option' => get_option('ays_chatgpt_assistant_upgrade_plugin', '')
            ));
        wp_die();
         } else {
            ob_end_clean();
            $ob_get_clean = ob_get_clean();
            echo json_encode(array(
                'option' => ''
            ));
            wp_die();
        }

    }

    public function ays_chatgpt_admin_footer($a){
        if(isset($_REQUEST['page'])){// phpcs:ignore WordPress.Security.NonceVerification.Recommended
            if(false !== strpos( sanitize_text_field(wp_unslash( $_REQUEST['page'] )), $this->plugin_name)){// phpcs:ignore WordPress.Security.NonceVerification.Recommended
                ?>
                <div class="ays-chatgpt-assistant-footer-support-box">
                    <span class="ays-chatgpt-assistant-footer-link-row"><a href="https://wordpress.org/support/plugin/ays-chatgpt-assistant/" target="_blank"><?php echo esc_html(__( "Support", "ays-chatgpt-assistant")); ?></a></span>
                    <span class="ays-chatgpt-assistant-footer-slash-row">/</span>
                    <span class="ays-chatgpt-assistant-footer-link-row"><a href="https://ays-pro.com/wordpress-chatgpt-assistant-user-manual" target="_blank"><?php echo esc_html(__( "Docs", "ays-chatgpt-assistant")); ?></a></span>
                    <span class="ays-chatgpt-assistant-footer-slash-row">/</span>
                    <span class="ays-chatgpt-assistant-footer-link-row"><a href="https://ays-demo.com/chatgpt-ai-assistant-plugin-feedback-survey/" target="_blank"><?php echo esc_html(__( "Suggest a Feature", "ays-chatgpt-assistant")); ?></a></span>
                </div>
                <p style="font-size:13px;text-align:center;font-style:italic;">
                    <span style="margin-left:0px;margin-right:10px;" class="ays_heart_beat"><i class="ays_fa ays_fa_heart_o animated"></i></span>
                    <span><?php echo esc_html(__( "If you love our plugin, please do big favor and rate us on", "ays-chatgpt-assistant")); ?></span>
                    <a target="_blank" href='https://wordpress.org/support/plugin/ays-chatgpt-assistant/reviews/'>WordPress.org</a>
                    <span class="ays_heart_beat"><i class="ays_fa ays_fa_heart_o animated"></i></span>
                </p>
            <?php
            }
        }
    }

    public function ays_chatgpt_admin_ajax(){
		global $wpdb;

		$response = array(
			"status" => false
		);
        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
		$function = isset($_REQUEST['function']) ? sanitize_text_field( wp_unslash($_REQUEST['function'] )) : null;

		if($function !== null){
			// List of public functions that don't require any authentication
			$public_functions = array(
				'ays_chatgpt_connect',
				'get_chatgpt_api_key',
				'ays_chatgpt_pinecone_query',
				'ays_chatgpt_save_feedback',
				'ays_chatgpt_make_request',
				'ays_chatgpt_get_embedding',
				'ays_chatgpt_get_embedding_context',
			);
			
			// Check if function is public
			$is_public = in_array( $function, $public_functions, true );
			
			// Check if user is authenticated admin
			$is_admin = current_user_can( 'manage_options' );
			
			// Allow if: function is public OR user is admin
			if ( ! $is_public && ! $is_admin ) {
				$response = array( 
					"status" => false, 
					"message" => "Unauthorized request"
				);
				ob_end_clean();
				$ob_get_clean = ob_get_clean();
				echo json_encode( $response );
				wp_die();
			}

			$response = array();
			if( is_callable( array( $this, $function ) ) ){
				$response = $this->$function();

	            ob_end_clean();
	            $ob_get_clean = ob_get_clean();
				echo json_encode( $response );
				wp_die();
			}
        }
        ob_end_clean();
        $ob_get_clean = ob_get_clean();
		echo json_encode( $response );
		wp_die();
	}

    public function ays_chatgpt_connect(){

        if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce(sanitize_text_field ( wp_unslash( $_REQUEST['nonce'] ) ), 'ajax-nonce' ) || ! current_user_can( 'manage_options' ) ) {
            wp_send_json_error( [ 'message' => 'Request failed', 'error' => [] ] );
        }

        $settings_obj = new ChatGPT_Assistant_Settings_DB_Actions( $this->plugin_name , $this->settings_db_name );
        $api_key      = isset($_REQUEST[CHATGPT_ASSISTANT_NAME_PREFIX.'_api_key']) && $_REQUEST[CHATGPT_ASSISTANT_NAME_PREFIX.'_api_key'] != '' ? esc_attr(sanitize_text_field(wp_unslash($_REQUEST[CHATGPT_ASSISTANT_NAME_PREFIX.'_api_key']))) : '';
		$method       = isset($_REQUEST['rMethod']) && $_REQUEST['rMethod'] != '' ? esc_attr(sanitize_text_field(wp_unslash($_REQUEST['rMethod']))) : '';
		$request_type = isset($_REQUEST['request_type']) && $_REQUEST['request_type'] != '' ? esc_attr(sanitize_text_field(wp_unslash($_REQUEST['request_type']))) : '';
		$check_openai_connection_code = false;
		$check_openai_connection = ChatGPT_assistant_Data::makeRequest($api_key, 'GET', 'models');
        $response_data = array('status' => false);
        
        if(is_array($check_openai_connection)){
            $check_openai_connection_code = isset($check_openai_connection['openai_response_code']) && $check_openai_connection['openai_response_code'] == 200 ? true : false; 
		}

		if($check_openai_connection_code){
			$this->db_obj->store_data();
            $response_data['status'] = true;
            $options = ($settings_obj->get_setting('options') === false) ? array() : json_decode($settings_obj->get_setting('options'), true);
			$chatbox_mode = ( isset( $options['chatbox_mode'] ) && $options['chatbox_mode'] != '' ) ? $options['chatbox_mode'] : 'light';
			$chatgpt_assistant_show_dashboard_chat = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'show_dashboard_chat'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'show_dashboard_chat'] == 'off' ) ? false : true;
            $chatgpt_assistant_show_dashboard_chat_mobile = ( isset( $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'show_dashboard_chat_mobile'] ) && $options[CHATGPT_ASSISTANT_OPTIONS_PREFIX.'show_dashboard_chat_mobile'] == 'off' ) ? false : true;
			if ($chatgpt_assistant_show_dashboard_chat) {
				$response_data['chatbot_html'] = ChatGPT_assistant_Data::get_chatbot_main_box($chatbox_mode, $api_key, $options);
			} else {
				$response_data['chatbot_html'] = '';
			}
		}
        $response_data['openai_connection'] = $check_openai_connection;


		return $response_data;
	}

    public function ays_chatgpt_pinecone_check_connection(){
		$pinecone_key = isset($_REQUEST['pinecone_key']) && $_REQUEST['pinecone_key'] != '' ? esc_attr($_REQUEST['pinecone_key']) : '';
		$pinecone_url = isset($_REQUEST['pinecone_url']) && $_REQUEST['pinecone_url'] != '' ? esc_attr($_REQUEST['pinecone_url']) : '';
		$headers = array(
			"Content-Type"  => "application/json",
			"Api-Key" => $pinecone_key
		);

		$request_data = array(
			"headers" => $headers,
		);
		
		$response = wp_safe_remote_post($pinecone_url , $request_data);
      
		if (is_wp_error($response) || wp_remote_retrieve_response_code($response) != 200) {
			return json_encode(["status" => false]);
		}

		$response_body = wp_remote_retrieve_body($response);
        $data = json_decode($response_body, true);

        if (isset($data['totalVectorCount'])) {
            
            $record_count = $data['totalVectorCount'];
            if ($data['totalVectorCount'] > 0) {
               
                return json_encode([
                    "status" => true,
                    "message" => __("Database has records. Embedding not allowed.",'ays-chatgpt-assistant'),
                    "allow_embedding" => false,
                ]);
            }
            return json_encode([
                "status" => true,
                "message" => "",
                "allow_embedding" => true,
                "record_count" => $record_count,
            ]);
            
        }
        return json_encode(["status" => false]);
	}
    public function ays_chatgpt_pinecone_delete(){
        global $wpdb;
        $embedding_settings = $wpdb->prefix . CHATGPT_ASSISTANT_DB_PREFIX . 'embedding_all_settings';
        
        $pinecone_key = isset($_REQUEST['pinecone_key']) ? esc_attr($_REQUEST['pinecone_key']) : '';
        $pinecone_url = isset($_REQUEST['pinecone_url']) ? esc_attr($_REQUEST['pinecone_url']) : '';
        $post_id = isset($_REQUEST['pinecone_id']) ? strval($_REQUEST['pinecone_id']) : ''; 
        $request_data = array(
			"Api-Key" => $pinecone_key,
            "Content-Type" => "application/json"
		);
       
        $delete_data = json_encode(array(
            "ids" => [$post_id] 
        ));
    
        $response = wp_safe_remote_post($pinecone_url, array(
            'headers' => $request_data,
            'body'    => $delete_data
        ));
		if (is_wp_error($response)) {
			return $response->get_error_message();
		}
        if (wp_remote_retrieve_response_code($response) == 200) {
            return true; 
        } else {
            return false;  
        }
    }
   
	public function ays_chatgpt_pinecone_query(){
		// Security: Verify nonce for CSRF protection
		if ( !isset( $_REQUEST['nonce'] ) || !wp_verify_nonce(sanitize_text_field ( wp_unslash( $_REQUEST['nonce'] ) ), 'ajax-nonce' ) ) {
			return array(
				'status' => false,
				'response' => 'Invalid request'
			);
		}
		
		$pinecone_key = isset($_REQUEST['pinecone_key']) && $_REQUEST['pinecone_key'] != '' ? esc_attr($_REQUEST['pinecone_key']) : '';
		$pinecone_url = isset($_REQUEST['pinecone_url']) && $_REQUEST['pinecone_url'] != '' ? esc_attr($_REQUEST['pinecone_url']) : '';
		$query_data = isset($_REQUEST['query_data']) && $_REQUEST['query_data'] != '' ? str_replace("\\", '', stripslashes($_REQUEST['query_data'])) : '';
		
		// Security: Validate Pinecone URL to prevent SSRF
		if ( !$this->is_allowed_pinecone_url( $pinecone_url ) ) {
			return array(
				'status' => false,
				'response' => 'Invalid Pinecone URL'
			);
		}
		
		$headers = array(
			"Content-Type"  => "application/json",
			"Api-Key" => $pinecone_key
		);

		$request_data = array(
			"headers" => $headers,
			"body" => $query_data
		);

		$response = wp_safe_remote_post($pinecone_url , $request_data);
		
		if (is_wp_error($response)) {
			return json_encode(array(
				'status' => false,
				'response' => $response->get_error_message()
			));
		}

		$data = json_decode(wp_remote_retrieve_body($response), true);
		if (isset($data['code']) && $data['code'] === 3) {
            return  json_encode(array(
				'status' => false,
				'response' => $data['message']
			));
		}

		foreach ($data['matches'] as &$match) {
			$text = $match['metadata']['text'];

			$decoded_text = stripcslashes(json_decode('"' . $text . '"'));

			$match['metadata']['text'] = $decoded_text;
		}
		
            return array(
			    'status' => true,
			    'response' => $data
		    );
	}

	/**
	 * Unified server-side proxy: embedding + Pinecone query for guest users.
	 * Accepts: input (prompt text), model (optional)
	 * Returns: context matches from Pinecone, using stored API keys (never exposed to client).
	 */
	public function ays_chatgpt_get_embedding_context() {
		// Verify nonce
		if ( !isset( $_REQUEST['nonce'] ) || !wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['nonce'] ) ), 'ajax-nonce' ) ) {
			wp_send_json_error( array( 'message' => 'Invalid request' ) );
			wp_die();
		}

		$input = isset( $_REQUEST['input'] ) && $_REQUEST['input'] !== '' ? sanitize_text_field( wp_unslash( $_REQUEST['input'] ) ) : '';
		$model = isset( $_REQUEST['model'] ) && $_REQUEST['model'] !== '' ? sanitize_text_field( $_REQUEST['model'] ) : 'text-embedding-ada-002';

		if ( empty( $input ) ) {
			wp_send_json_error( array( 'message' => 'No input provided' ) );
			wp_die();
		}

		// --- Step 1: Get API key from DB (same source used elsewhere in the plugin) ---
		$data = $this->db_obj ? $this->db_obj->get_data() : array();
		$apiKey = isset( $data['api_key'] ) && $data['api_key'] !== '' ? esc_attr( $data['api_key'] ) : '';

		if ( empty( $apiKey ) ) {
			wp_send_json_error( array( 'message' => 'API key not configured' ) );
			wp_die();
		}

		// --- Step 2: Get embedding from OpenAI ---
		$embedding_response = wp_safe_remote_post( 'https://api.openai.com/v1/embeddings', array(
			'method'  => 'POST',
			'headers' => array(
				'Content-Type'  => 'application/json',
				'Authorization' => 'Bearer ' . $apiKey,
			),
			'body'    => json_encode( array(
				'model' => $model,
				'input' => $input,
			) ),
			'timeout' => 20,
		) );

		if ( is_wp_error( $embedding_response ) ) {
			wp_send_json_error( array( 'message' => $embedding_response->get_error_message() ) );
			wp_die();
		}

		$embedding_body = json_decode( wp_remote_retrieve_body( $embedding_response ), true );
		if ( !isset( $embedding_body['data'][0]['embedding'] ) ) {
			wp_send_json_error( array( 'message' => 'Embedding failed', 'raw' => $embedding_body ) );
			wp_die();
		}

		$vector = $embedding_body['data'][0]['embedding'];

		// --- Step 3: Load Pinecone settings from DB ---
		global $wpdb;
		$embedding_table = $wpdb->prefix . CHATGPT_ASSISTANT_DB_PREFIX . 'embedding_settings';
		$rows = $wpdb->get_results( "SELECT meta_key, meta_value FROM $embedding_table", ARRAY_A );
		$embedding_opts = array();
		foreach ( $rows as $row ) {
			$embedding_opts[ CHATGPT_ASSISTANT_OPTIONS_PREFIX . $row['meta_key'] ] = $row['meta_value'];
		}

		$pinecone_key   = isset( $embedding_opts[ CHATGPT_ASSISTANT_OPTIONS_PREFIX . 'pinecone_api_key' ] ) ? $embedding_opts[ CHATGPT_ASSISTANT_OPTIONS_PREFIX . 'pinecone_api_key' ] : '';
		$pinecone_index = isset( $embedding_opts[ CHATGPT_ASSISTANT_OPTIONS_PREFIX . 'pinecone_index' ] ) ? $embedding_opts[ CHATGPT_ASSISTANT_OPTIONS_PREFIX . 'pinecone_index' ] : '';

		if ( empty( $pinecone_key ) || empty( $pinecone_index ) ) {
			wp_send_json_error( array( 'message' => 'Pinecone not configured' ) );
			wp_die();
		}

		// Build Pinecone query URL
		$pinecone_url = ( strpos( $pinecone_index, 'https://' ) === false ) ? 'https://' . $pinecone_index : $pinecone_index;
		$pinecone_query_url = rtrim( $pinecone_url, '/' ) . '/query';

		// Validate Pinecone URL
		if ( !$this->is_allowed_pinecone_url( $pinecone_query_url ) ) {
			wp_send_json_error( array( 'message' => 'Invalid Pinecone URL' ) );
			wp_die();
		}

		// --- Step 4: Query Pinecone ---
		$query_body = json_encode( array(
			'topK'           => 3,
			'includeMetadata' => true,
			'includeValues'  => false,
			'namespace'      => '',
			'vector'         => $vector,
		) );

		$pinecone_response = wp_safe_remote_post( $pinecone_query_url, array(
			'headers' => array(
				'Content-Type' => 'application/json',
				'Api-Key'      => $pinecone_key,
			),
			'body'    => $query_body,
			'timeout' => 20,
		) );

		if ( is_wp_error( $pinecone_response ) ) {
			wp_send_json_error( array( 'message' => $pinecone_response->get_error_message() ) );
			wp_die();
		}

		$pinecone_data = json_decode( wp_remote_retrieve_body( $pinecone_response ), true );

		if ( isset( $pinecone_data['code'] ) && $pinecone_data['code'] === 3 ) {
			wp_send_json_error( array( 'message' => $pinecone_data['message'] ) );
			wp_die();
		}

		// Decode text metadata
		if ( isset( $pinecone_data['matches'] ) ) {
			foreach ( $pinecone_data['matches'] as &$match ) {
				if ( isset( $match['metadata']['text'] ) ) {
					$match['metadata']['text'] = stripcslashes( json_decode( '"' . $match['metadata']['text'] . '"' ) );
				}
			}
		}

		wp_send_json_success( array(
			'status'   => true,
			'response' => $pinecone_data,
		) );
		wp_die();
	}

    
    public function ays_chatgpt_save_embedding_text_to_db() {
        
        if (isset($_POST['text']) && isset($_POST['length'])) {
   
            $text = sanitize_text_field($_POST['text']);
            $word_count = intval($_POST['length']);      
            $encoded_text = base64_encode($text);
            $postId = sanitize_text_field($_POST['id']);
            $meta_data = array(
                array('meta_key' => 'embedding_text', 'meta_value' => $encoded_text),
                array('meta_key' => 'embedding_text_length', 'meta_value' => $word_count),
                array('meta_key' => 'embedding_text_id', 'meta_value' => $postId) 
            );
            global $wpdb;
            $embedding_settings = $wpdb->prefix . CHATGPT_ASSISTANT_DB_PREFIX . 'embedding_settings';
    
            foreach ($meta_data as $data) {  
                $meta_key = $data['meta_key'];
                $meta_value = $data['meta_value'];
    
                $existing_record = $wpdb->get_var(
                    $wpdb->prepare("SELECT COUNT(*) FROM $embedding_settings WHERE meta_key = %s", $meta_key)
                );
                
                if ($existing_record > 0) {
                    $wpdb->update(
                        $embedding_settings,
                        ['meta_value' => $meta_value], 
                        ['meta_key' => $meta_key]
                    );
                } else {
                    $wpdb->insert(
                        $embedding_settings,
                        [
                            'meta_key' => $meta_key,
                            'meta_value' => $meta_value,
                        ]
                    );
                }
            }
            wp_send_json_success();  
        } else {
            wp_send_json_error('Invalid data');  
        }
    }
    public function ays_chatgpt_pinecone_upsert(){
        if ( !isset( $_REQUEST['nonce'] ) || !wp_verify_nonce(sanitize_text_field ( wp_unslash( $_REQUEST['nonce'] ) ), 'ajax-nonce' ) || !current_user_can('manage_options') ) {
            wp_send_json_error( [ 'message' => 'Request failed', 'error' => [] ] );
        }

		$pinecone_key = isset($_REQUEST['pinecone_key']) && $_REQUEST['pinecone_key'] != '' ? esc_attr($_REQUEST['pinecone_key']) : '';
		$pinecone_url = isset($_REQUEST['pinecone_url']) && $_REQUEST['pinecone_url'] != '' ? esc_url_raw($_REQUEST['pinecone_url']) : '';
		$upsert_data = isset($_REQUEST['upsert_data']) && $_REQUEST['upsert_data'] != '' ? str_replace("\\", '', stripslashes($_REQUEST['upsert_data'])) : '';
		
		$headers = array(
			"Content-Type"  => "application/json",
			"Api-Key" => $pinecone_key
		);

		$request_data = array(
			"headers" => $headers,
			"body" => $upsert_data
		);
		
		$response = wp_safe_remote_post($pinecone_url , $request_data);
		
		if (is_wp_error($response)) {
			return $response->get_error_message();
		}

		$data = json_decode(wp_remote_retrieve_body($response), true);
		if (isset($data['code']) && $data['code'] === 3) {
			return $data['message'];
		}

		return true;
	}

	public function ays_chatgpt_disconnect(){
        if (! isset( $_REQUEST['nonce'] ) || !wp_verify_nonce(sanitize_text_field ( wp_unslash( $_REQUEST['nonce'] ) ), 'ajax-nonce') || !current_user_can('manage_options')) {
            wp_send_json_error(['message' => 'Request failed', 'error' => []]);
        }

        $id = isset($_REQUEST[CHATGPT_ASSISTANT_NAME_PREFIX.'_id']) && $_REQUEST[CHATGPT_ASSISTANT_NAME_PREFIX.'_id'] != '' ? esc_attr(sanitize_text_field(wp_unslash($_REQUEST[CHATGPT_ASSISTANT_NAME_PREFIX.'_id']))) : '';

		$status = $this->db_obj->update_setting($id , "" , 'api_key' , 'id');		

		return $status;
	}

    public function ays_chatgpt_save_feedback(){
		global $wpdb;
		$rates_table = $wpdb->prefix . CHATGPT_ASSISTANT_DB_PREFIX . 'rates';

		$data = isset($_REQUEST['feedback_data']) && $_REQUEST['feedback_data'] != '' ? array_map('sanitize_text_field', json_decode(wp_unslash($_REQUEST['feedback_data']), true)) : array();// phpcs:ignore WordPress.Security.NonceVerification.Recommended

		global $current_user;
		$user_name = isset($data['user_name']) && $data['user_name'] != '' ? sanitize_text_field($data['user_name']) : (isset($current_user->user_login) && $current_user->user_login != '' ? sanitize_text_field($current_user->user_login) : '');
		$user_email = isset($data['user_email']) && $data['user_email'] != '' ? sanitize_text_field($data['user_email']) : (isset($current_user->user_email) && $current_user->user_email != '' ? sanitize_text_field($current_user->user_email) : '');
		
		$user_id = get_current_user_id();
		$date = current_time('mysql');

		$post_id = isset($data['post_id']) && $data['post_id'] != '' ? intval($data['post_id']) : 0;
		
		$source = isset($data['source']) && $data['source'] != '' ? sanitize_text_field($data['source']) : '';
		$type = isset($data['type']) && $data['type'] != '' ? sanitize_text_field($data['type']) : '';
		$feedback_action = isset($data['feedback_action']) && $data['feedback_action'] != '' ? sanitize_text_field($data['feedback_action']) : '';
		$feedback = isset($data['feedback']) && $data['feedback'] != '' ? esc_attr(stripslashes(sanitize_text_field($data['feedback']))) : '';

		if (trim($feedback) == '') {
			return false;
		}

		$result = $wpdb->insert(
			$rates_table,
			array(
                'post_id'      => $post_id,
                'user_id'      => $user_id,
                'user_name'    => $user_name,
                'user_email'   => $user_email,
                'date'         => $date,
                'chat_source'  => $source,
                'chat_type'    => $type,
                'feedback'     => $feedback,
                'action'       => $feedback_action,
			),
			array( '%d', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )
		);

		if ($result && $result > 0) {
			return true;
		}

		return false;
	}

    public function get_chatgpt_api_key() {
        
        if ( !isset( $_REQUEST['nonce'] ) || !wp_verify_nonce(sanitize_text_field ( wp_unslash( $_REQUEST['nonce'] ) ), 'ajax-nonce' ) ) {
            wp_send_json_error( [ 'message' => 'Request failed', 'error' => [] ] );
        }
        
        // Security: Only admins can retrieve the actual API key
        // Guests/non-admins only get confirmation that API is configured
        $is_admin = current_user_can( 'manage_options' );
        
		$data = $this->db_obj->get_data();
		if (!$data || empty($data['api_key'])) {
			wp_send_json_error(['message' => __('API key not found', 'ays-chatgpt-assistant')]);
		}
		
		if ( $is_admin ) {
			// Admins get the actual API key
			$api_key = esc_attr( $data['api_key'] );
			wp_send_json_success(['api_key' => $api_key]);
		} else {
			// Guests only get confirmation API is configured (without exposing the key)
			// The actual key is used server-side in ays_chatgpt_make_request
			wp_send_json_success(['api_key' => 'configured']);
		}

		$image_url = isset($_REQUEST['image_url']) ? esc_url_raw(sanitize_text_field(wp_unslash($_REQUEST['image_url']))) : '';// phpcs:ignore WordPress.Security.NonceVerification.Recommended
	
		require_once(ABSPATH . 'wp-admin/includes/media.php');
		require_once(ABSPATH . 'wp-admin/includes/file.php');
		require_once(ABSPATH . 'wp-admin/includes/image.php');
	
		if (!filter_var($image_url, FILTER_VALIDATE_URL)) {
			wp_send_json(['status' => false, 'message' => __('Invalid image URL provided', 'ays-chatgpt-assistant')]);
			return;
		}
	
		$tmp = download_url($image_url);
	
		if (is_wp_error($tmp)) {
			wp_send_json(['status' => false, 'message' => __('Error downloading the image:', 'ays-chatgpt-assistant') . $tmp->get_error_message()]);
			return;
		}
	
		$file_name = sanitize_file_name(basename(wp_parse_url($image_url, PHP_URL_PATH)));
		$file_array = array(
			'name' => $file_name,
			'tmp_name' => $tmp
		);
	
		$media_id = media_handle_sideload($file_array, 0);
	
		if (is_wp_error($media_id)) {
			wp_send_json(['status' => false, 'message' => __('Error saving the image:', 'ays-chatgpt-assistant') . $media_id->get_error_message()]);
			return;
		}
	
		$image_url = wp_get_attachment_url($media_id);
		wp_send_json(['status' => true, 'message' => __('Image saved to WordPress media library. URL: ', 'ays-chatgpt-assistant') . $image_url]);
	}

    /**
     * Security: Validate that the request URL is allowed
     * Prevents Server-Side Request Forgery (SSRF) attacks
     * Only allows requests to OpenAI API endpoints
     */
    private function is_allowed_request_url( $url ) {
        if ( empty( $url ) ) {
            return false;
        }
        
        // Whitelist of allowed API endpoints
        $allowed_domains = array(
            'api.openai.com',
            'api.openaicom-user-facing.com',
        );
        
        $parsed_url = wp_parse_url( $url );
        if ( !isset( $parsed_url['host'] ) ) {
            return false;
        }
        
        // Check if host is in whitelist
        $host = $parsed_url['host'];
        foreach ( $allowed_domains as $domain ) {
            if ( $host === $domain || substr( $host, -strlen( $domain ) - 1 ) === '.' . $domain ) {
                return true;
            }
        }
        
        return false;
    }

    /**
     * Security: Validate that Pinecone URL is allowed
     * Prevents Server-Side Request Forgery (SSRF) attacks
     * Only allows requests to Pinecone API endpoints
     */
    private function is_allowed_pinecone_url( $url ) {
        if ( empty( $url ) ) {
            return false;
        }
        
        // Whitelist of allowed Pinecone endpoints domains
        $allowed_domains = array(
            'pinecone.io',
        );
        
        $parsed_url = wp_parse_url( $url );
        if ( !isset( $parsed_url['host'] ) ) {
            return false;
        }
        
        // Check if host is in whitelist
        $host = $parsed_url['host'];
        foreach ( $allowed_domains as $domain ) {
            if ( $host === $domain || substr( $host, -strlen( $domain ) - 1 ) === '.' . $domain ) {
                return true;
            }
        }
        
        return false;
    }

    /**
     * Server-side proxy for OpenAI text embeddings.
     * Allows guests to get embeddings without exposing the API key client-side.
     */
    public function ays_chatgpt_get_embedding() {

        if ( !isset( $_REQUEST['nonce'] ) || !wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['nonce'] ) ), 'ajax-nonce' ) ) {
            wp_send_json_error( [ 'message' => 'Request failed', 'error' => [ 'message' => 'Request failed' ] ] );
        }

        $data   = $this->db_obj->get_data();
        $apiKey = isset( $data['api_key'] ) && $data['api_key'] !== '' ? esc_attr( $data['api_key'] ) : '';

        if ( $apiKey === '' ) {
            wp_send_json_error( [ 'message' => 'API key not found', 'error' => [ 'message' => 'API key not found' ] ] );
        }

        $input = isset( $_REQUEST['input'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['input'] ) ) : '';
        $model = isset( $_REQUEST['model'] )  ? sanitize_text_field( wp_unslash( $_REQUEST['model'] ) )  : 'text-embedding-ada-002';

        if ( $input === '' ) {
            wp_send_json_error( [ 'message' => 'Missing input', 'error' => [ 'message' => 'Missing input' ] ] );
        }

        $response = wp_safe_remote_post( 'https://api.openai.com/v1/embeddings', array(
            'method'  => 'POST',
            'headers' => array(
                'Content-Type'  => 'application/json',
                'Authorization' => 'Bearer ' . $apiKey,
            ),
            'body'    => json_encode( array(
                'model' => $model,
                'input' => $input,
            ) ),
            'timeout' => 20,
        ) );

        if ( is_wp_error( $response ) ) {
            wp_send_json_error( [ 'message' => 'Request failed', 'error' => $response->get_error_message() ] );
        }

        $response_body = wp_remote_retrieve_body( $response );
        wp_send_json_success( json_decode( $response_body ) );
        wp_die();
    }

    public function ays_chatgpt_make_request() {

        if ( !isset( $_REQUEST['nonce'] ) || !wp_verify_nonce(sanitize_text_field ( wp_unslash( $_REQUEST['nonce'] ) ), 'ajax-nonce' ) ) {
            wp_send_json_error( [ 'message' => 'Request failed', 'error' => ['message' => 'Request failed']]);
        }
        
        if ( !isset($_REQUEST['dataObj']) || !isset($_REQUEST['dbOptions']) ) {
            wp_send_json_error(['message' => 'Missing required parameters', 'error' => ['message' => 'Missing required parameters']]);
        }
    
        $data = $this->db_obj->get_data();
		$apiKey = isset( $data['api_key'] ) && $data['api_key'] != '' ? esc_attr( $data['api_key'] ) : '';

        if ( !isset($apiKey) || $apiKey === "" ) {
            wp_send_json_error(['message' => 'API key not found', 'error' => ['message' => 'API key not found']]);
        }
    

        if(function_exists('mb_convert_encoding')){
            $dataObj = json_decode(mb_convert_encoding(base64_decode($_REQUEST['dataObj']), 'UTF-8'), true);
            $dbOptions = json_decode(mb_convert_encoding(base64_decode($_REQUEST['dbOptions']), 'UTF-8'), true);
        } else {
            $dataObj = json_decode(iconv('ISO-8859-1', 'UTF-8', base64_decode($_REQUEST['dataObj'])), true);
            $dbOptions = json_decode(iconv('ISO-8859-1', 'UTF-8', base64_decode($_REQUEST['dbOptions'])), true);
        }
        
        // Security: Validate requestUrl to prevent SSRF attacks
        // If URL is not provided, use default OpenAI endpoint based on model
        $request_url = isset($dataObj['requestUrl']) ? esc_url_raw($dataObj['requestUrl']) : '';
        if ( !empty($request_url) && !$this->is_allowed_request_url($request_url) ) {
            wp_send_json_error(['message' => 'Invalid request URL', 'error' => ['message' => 'Invalid request URL']]);
        } else if ( empty($request_url) ) {
            // Use default OpenAI URL based on model
            $model = isset($dbOptions['chatModel']) ? $dbOptions['chatModel'] : 'gpt-3.5-turbo';
            switch ($model) {
                case 'gpt-3.5-turbo':
                case 'gpt-3.5-turbo-16k':
                case 'gpt-4':
                case 'gpt-4o-mini':
                case 'gpt-4.1-mini':
                case 'gpt-4.1-nano':
                case 'gpt-5-mini':
                case 'gpt-5-nano':
                    $request_url = 'https://api.openai.com/v1/chat/completions';
                    break;
                default:
                    $request_url = 'https://api.openai.com/v1/completions';
                    break;
            }
            $dataObj['requestUrl'] = $request_url;
        }
            
        $modelRequiresMaxCompletionTokens = in_array($dbOptions['chatModel'] ?? "", ['gpt-5-mini', 'gpt-5-nano']);
        
        $chatRequestBody = array(
            'temperature'        => +$dbOptions['chatTemperature'] ?? 0.7,
            'top_p'              => +$dbOptions['chatTopP'] ?? 1,
            'model'              => $dbOptions['chatModel'] ?? ""
        );
        
        if ($modelRequiresMaxCompletionTokens) {
            $chatRequestBody['max_completion_tokens'] = +$dbOptions['chatMaxTokents'] ?? 1500;
        } else {
            $chatRequestBody['max_tokens'] = +$dbOptions['chatMaxTokents'] ?? 1500;
            $chatRequestBody['frequency_penalty'] = +$dbOptions['chatFrequencyPenalty'] ?? 0.01;
            $chatRequestBody['presence_penalty'] = +$dbOptions['chatPresencePenalty'] ?? 0.01;
        }
    
        switch ($dbOptions['chatModel']) {
            case 'gpt-3.5-turbo':
            case 'gpt-3.5-turbo-16k':
            case 'gpt-4':
            case 'gpt-4o-mini':
            case 'gpt-4.1-mini':
            case 'gpt-4.1-nano':
            case 'gpt-5-mini':
            case 'gpt-5-nano':
                $dataObj['chatConversation'][] = array('role' => 'user', 'content' => $dataObj['prompt']);
                $chatRequestBody['messages'] = $dataObj['chatConversation'];
                break;
            default:
                $dataObj['chatConversation'][] = "Human: " . $dataObj['prompt'] . '.';
                $chatRequestBody['best_of'] = +$dbOptions['chatBestOf'] ?? 1;
                $chatRequestBody['prompt'] = implode("", $dataObj['chatConversation']);
                break;
        }
    
        $response = wp_safe_remote_post($dataObj['requestUrl'], array(
            'method'    => 'POST',
            'headers'   => array(
                'Content-Type'  => 'application/json',
                'Authorization' => 'Bearer ' . $apiKey,
            ),
            'body'      => json_encode($chatRequestBody),
            'timeout'   => 20,
        ));
    
        if ( is_wp_error( $response ) ) {
            wp_send_json_error(['message' => 'Request failed', 'error' => $response->get_error_message()]);
            wp_die();
        }
    
        $response_body = wp_remote_retrieve_body( $response );
        wp_send_json_success(json_decode($response_body));
        
        wp_die();
    }

    public function ays_chatgpt_disable_all_notice_from_plugin() {
        if (!function_exists('get_current_screen')) {
            return;
        }

        $screen = get_current_screen();

        if (empty($screen) || strpos($screen->id, $this->plugin_name) === false) {
            return;
        }

        global $wp_filter;

        if (!isset($wp_filter['admin_notices']) || !is_a($wp_filter['admin_notices'], 'WP_Hook')) {
            return;
        }

        $exclude_functions = [
            'chatgpt_assistant_general_admin_notice',
        ];

        foreach ($wp_filter['admin_notices']->callbacks as $priority => $callbacks) {
            foreach ($callbacks as $key => $callback) {
                $remove = true;

                // Allow this plugin's class methods to remain
                if (
                    is_array($callback['function']) &&
                    is_object($callback['function'][0]) &&
                    get_class($callback['function'][0]) === __CLASS__
                ) {
                    $remove = false;
                }

                // Allow specific standalone functions
                if (
                    is_string($callback['function']) &&
                    in_array($callback['function'], $exclude_functions, true)
                ) {
                    $remove = false;
                }

                if ($remove) {
                    remove_action('admin_notices', $callback['function'], $priority);
                }
            }
        }
    }
}
