<?php
/**
 * PPE Login Form.
 *
 * @package PPE
 */

namespace PowerpackElements\Modules\LoginForm\Widgets;

use PowerpackElements\Base\Powerpack_Widget;
use PowerpackElements\Classes\PP_Helper;
use PowerpackElements\Classes\PP_Config;
use PowerpackElements\Classes\PP_Admin_Settings;

use Elementor\Controls_Manager;
use Elementor\Icons_Manager;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Typography;
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
use Elementor\Core\Kits\Documents\Tabs\Global_Colors;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

/**
 * Login Form Widget
 */
class Login_Form extends Powerpack_Widget {

	/**
	 * Retrieve login form widget name.
	 *
	 * @access public
	 *
	 * @return string Widget name.
	 */
	public function get_name() {
		return parent::get_widget_name( 'Login_Form' );
	}

	/**
	 * Retrieve login form widget title.
	 *
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title() {
		return parent::get_widget_title( 'Login_Form' );
	}

	/**
	 * Retrieve login form widget icon.
	 *
	 * @access public
	 *
	 * @return string Widget icon.
	 */
	public function get_icon() {
		return parent::get_widget_icon( 'Login_Form' );
	}

	/**
	 * Retrieve login form widget keywords.
	 *
	 * @return array List of keywords
	 */
	public function get_keywords() {
		return parent::get_widget_keywords( 'Login_Form' );
	}

	protected function is_dynamic_content(): bool {
		return false;
	}

	/**
	 * Retrieve the list of scripts the login form widget depended on.
	 *
	 * Used to set scripts dependencies required to run the widget.
	 *
	 * @access public
	 *
	 * @return array Widget scripts dependencies.
	 */
	public function get_script_depends() {
		return array(
			//'pp-google-login',
			'pp-google-recaptcha',
			'pp-login-form',
		);
	}

	/**
	 * Get style dependencies.
	 *
	 * Retrieve the list of style dependencies the widget requires.
	 *
	 * @since 2.11.0
	 * @access public
	 *
	 * @return array Widget style dependencies.
	 */
	public function get_style_depends(): array {
		return [ 'widget-pp-login-form' ];
	}

	public function has_widget_inner_wrapper(): bool {
		return ! PP_Helper::is_feature_active( 'e_optimized_markup' );
	}

	/**
	 * Register login form widget controls.
	 *
	 * Adds different input fields to allow the user to change and customize the widget settings.
	 *
	 * @since 2.0.3
	 * @access protected
	 */
	protected function register_controls() {
		/**
		 * Content Tab: Form Fields
\		 */
		$this->start_controls_section(
			'section_fields_content',
			array(
				'label' => esc_html__( 'Form Fields', 'powerpack' ),
			)
		);

		$this->add_control(
			'show_labels',
			array(
				'label'   => esc_html__( 'Labels', 'powerpack' ),
				'type'    => Controls_Manager::SELECT,
				'options' => array(
					'default' => esc_html__( 'Default', 'powerpack' ),
					'custom'  => esc_html__( 'Custom', 'powerpack' ),
					''        => esc_html__( 'None', 'powerpack' ),
				),
				'default' => 'default',
			)
		);

		$this->add_control(
			'user_label',
			array(
				'label'       => esc_html__( 'Username Label', 'powerpack' ),
				'label_block' => true,
				'type'        => Controls_Manager::TEXT,
				'default'     => esc_html__( ' Username or Email Address', 'powerpack' ),
				'condition'   => array(
					'show_labels' => 'custom',
				),
			)
		);

		$this->add_control(
			'user_placeholder',
			array(
				'label'       => esc_html__( 'Username Placeholder', 'powerpack' ),
				'label_block' => true,
				'type'        => Controls_Manager::TEXT,
				'default'     => esc_html__( ' Username or Email Address', 'powerpack' ),
				'condition'   => array(
					'show_labels' => 'custom',
				),
			)
		);

		$this->add_control(
			'password_label',
			array(
				'label'       => esc_html__( 'Password Label', 'powerpack' ),
				'label_block' => true,
				'type'        => Controls_Manager::TEXT,
				'default'     => esc_html__( 'Password', 'powerpack' ),
				'condition'   => array(
					'show_labels' => 'custom',
				),
			)
		);

		$this->add_control(
			'password_placeholder',
			array(
				'label'       => esc_html__( 'Password Placeholder', 'powerpack' ),
				'label_block' => true,
				'type'        => Controls_Manager::TEXT,
				'default'     => esc_html__( 'Password', 'powerpack' ),
				'condition'   => array(
					'show_labels' => 'custom',
				),
			)
		);

		$this->add_control(
			'input_size',
			array(
				'label'   => esc_html__( 'Input Size', 'powerpack' ),
				'type'    => Controls_Manager::SELECT,
				'options' => array(
					'xs' => esc_html__( 'Extra Small', 'powerpack' ),
					'sm' => esc_html__( 'Small', 'powerpack' ),
					'md' => esc_html__( 'Medium', 'powerpack' ),
					'lg' => esc_html__( 'Large', 'powerpack' ),
					'xl' => esc_html__( 'Extra Large', 'powerpack' ),
				),
				'default' => 'sm',
			)
		);

		$this->add_control(
			'show_remember_me',
			array(
				'label'     => esc_html__( 'Remember Me', 'powerpack' ),
				'type'      => Controls_Manager::SWITCHER,
				'default'   => 'yes',
				'label_off' => esc_html__( 'Hide', 'powerpack' ),
				'label_on'  => esc_html__( 'Show', 'powerpack' ),
			)
		);

		$this->add_control(
			'remember_me_text',
			array(
				'label'     => esc_html__( 'Remember Me Text', 'powerpack' ),
				'type'      => Controls_Manager::TEXT,
				'default'   => esc_html__( 'Remember Me', 'powerpack' ),
				'condition' => array(
					'show_remember_me' => 'yes',
				),
			)
		);

		$this->add_control(
			'enable_ajax',
			array(
				'label'              => esc_html__( 'Enable AJAX Login', 'powerpack' ),
				'type'               => Controls_Manager::SWITCHER,
				'default'            => 'yes',
				'label_on'           => esc_html__( 'Yes', 'powerpack' ),
				'label_off'          => esc_html__( 'No', 'powerpack' ),
				'frontend_available' => true,
			)
		);

		$this->end_controls_section();

		/**
		 * Content Tab: Button
\		 */
		$this->start_controls_section(
			'section_button_content',
			array(
				'label' => esc_html__( 'Button', 'powerpack' ),
			)
		);

		$this->add_control(
			'button_text',
			array(
				'label'   => esc_html__( 'Text', 'powerpack' ),
				'type'    => Controls_Manager::TEXT,
				'default' => esc_html__( 'Log In', 'powerpack' ),
			)
		);

		$this->add_control(
			'button_size',
			array(
				'label'   => esc_html__( 'Size', 'powerpack' ),
				'type'    => Controls_Manager::SELECT,
				'options' => array(
					'xs' => esc_html__( 'Extra Small', 'powerpack' ),
					'sm' => esc_html__( 'Small', 'powerpack' ),
					'md' => esc_html__( 'Medium', 'powerpack' ),
					'lg' => esc_html__( 'Large', 'powerpack' ),
					'xl' => esc_html__( 'Extra Large', 'powerpack' ),
				),
				'default' => 'sm',
			)
		);

		$this->add_responsive_control(
			'align',
			array(
				'label'        => esc_html__( 'Alignment', 'powerpack' ),
				'type'         => Controls_Manager::CHOOSE,
				'options'      => array(
					'start'   => array(
						'title' => esc_html__( 'Left', 'powerpack' ),
						'icon'  => 'eicon-text-align-left',
					),
					'center'  => array(
						'title' => esc_html__( 'Center', 'powerpack' ),
						'icon'  => 'eicon-text-align-center',
					),
					'end'     => array(
						'title' => esc_html__( 'Right', 'powerpack' ),
						'icon'  => 'eicon-text-align-right',
					),
					'stretch' => array(
						'title' => esc_html__( 'Justified', 'powerpack' ),
						'icon'  => 'eicon-text-align-justify',
					),
				),
				'prefix_class' => 'elementor%s-button-align-',
				'default'      => '',
			)
		);

		$this->end_controls_section();

		/**
		 * Content Tab: reCAPTCHA
		 */
		$this->start_controls_section(
			'section_recaptcha',
			array(
				'label' => esc_html__( 'reCAPTCHA', 'powerpack' ),
			)
		);

		$this->add_control(
			'enable_recaptcha',
			array(
				'label'              => esc_html__( 'Enable reCAPTCHA', 'powerpack' ),
				'type'               => Controls_Manager::SWITCHER,
				'default'            => 'no',
				'label_off'          => esc_html__( 'No', 'powerpack' ),
				'label_on'           => esc_html__( 'Yes', 'powerpack' ),
				'frontend_available' => true,
			)
		);

		if ( ! $this->is_recaptcha() ) {
			$this->add_control(
				'google_clientid_setting',
				array(
					'type'            => Controls_Manager::RAW_HTML,
					'raw'             => PP_Helper::get_recaptcha_desc(),
					'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
					'condition'       => array(
						'enable_recaptcha' => 'yes',
					),
				)
			);
		}

		if ( $this->is_recaptcha() ) {
			$this->add_control(
				'recaptcha_validate_type',
				array(
					'label'       => esc_html__( 'Validate Type', 'powerpack' ),
					'description' => esc_html__( 'Validate users with checkbox or in the background.<br />Note: Checkbox and Invisible types use seperate API keys.', 'powerpack' ),
					'type'        => Controls_Manager::SELECT,
					'multiple'    => true,
					'label_block' => true,
					'default'     => 'normal',
					'options'     => array(
						'normal'       => esc_html__( '"I\'m not a robot" checkbox (V2)', 'powerpack' ),
						'invisible'    => esc_html__( 'Invisible (V2)', 'powerpack' ),
						'invisible_v3' => esc_html__( 'Invisible (V3)', 'powerpack' ),
					),
					'condition'   => array(
						'enable_recaptcha' => 'yes',
					),
				)
			);

			$this->add_control(
				'recaptcha_theme',
				array(
					'label'     => esc_html__( 'Theme', 'powerpack' ),
					'type'      => Controls_Manager::SELECT,
					'default'   => 'light',
					'options'   => array(
						'light' => esc_html__( 'Light', 'powerpack' ),
						'dark'  => esc_html__( 'Dark', 'powerpack' ),
					),
					'condition' => array(
						'enable_recaptcha' => 'yes',
					),
				)
			);
		}

		$this->end_controls_section();

		/**
		 * Content Tab: Social Login
		 */
		$this->start_controls_section(
			'section_social_login_content',
			array(
				'label' => esc_html__( 'Social Login', 'powerpack' ),
			)
		);

		$this->add_control(
			'facebook_login',
			array(
				'label'              => esc_html__( 'Enable Facebook Login', 'powerpack' ),
				'type'               => Controls_Manager::SWITCHER,
				'default'            => 'no',
				'label_off'          => esc_html__( 'No', 'powerpack' ),
				'label_on'           => esc_html__( 'Yes', 'powerpack' ),
				'frontend_available' => true,
			)
		);

		if ( ! $this->is_fb_data() ) {
			$this->add_control(
				'facebook_app_secret_setting',
				array(
					'type'            => Controls_Manager::RAW_HTML,
					'raw'             => sprintf(
						/* translators: 1: Link opening tag, 2: Link closing tag. */
						esc_html__( 'To use Facebook Login, you need to configure App ID and App Secret under %1$sIntegration Settings%2$s', 'powerpack' ),
						sprintf( '<a href="%s" target="_blank">', PP_Admin_Settings::get_form_action( '&tab=integration' ) ),
						'</a>'
					),
					'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
					'condition'       => array(
						'facebook_login' => 'yes',
					),
				)
			);
		}

		if ( $this->is_fb_data() ) {
			$this->add_control(
				'facebook_login_label',
				array(
					'label'       => esc_html__( 'Facebook Button Text', 'powerpack' ),
					'label_block' => false,
					'type'        => Controls_Manager::TEXT,
					'dynamic'     => array(
						'active' => true,
					),
					'default'     => esc_html__( 'Facebook', 'powerpack' ),
					'condition'   => array(
						'facebook_login' => 'yes',
					),
				)
			);
		}

		$this->add_control(
			'google_login',
			array(
				'label'     => esc_html__( 'Enable Google Login', 'powerpack' ),
				'type'      => Controls_Manager::SWITCHER,
				'default'   => 'no',
				'label_off' => esc_html__( 'No', 'powerpack' ),
				'label_on'  => esc_html__( 'Yes', 'powerpack' ),
			)
		);

		if ( ! $this->is_google_data() ) {
			$this->add_control(
				'google_client_id_setting',
				array(
					'type'            => Controls_Manager::RAW_HTML,
					'raw'             => sprintf(
						/* translators: 1: Link opening tag, 2: Link closing tag. */
						esc_html__( 'To use Google Login, you need to configure Google Client ID under %1$sIntegration Settings%2$s', 'powerpack' ),
						sprintf( '<a href="%s" target="_blank">', PP_Admin_Settings::get_form_action( '&tab=integration' ) ),
						'</a>'
					),
					'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
					'condition'       => array(
						'google_login' => 'yes',
					),
				)
			);
		}

		if ( $this->is_google_data() ) {
			$this->add_control(
				'google_onetap_login',
				[
					'label'       => esc_html__( 'Google One Tap Login', 'powerpack' ),
					'type'        => Controls_Manager::SWITCHER,
					'description' => esc_html__( 'Enable this option to use Google\'s One Tap Login feature to make google login easier for users.', 'powerpack' ),
					'default'     => '',
					'condition'   => [
						'google_login' => 'yes',
					],
				]
			);

			$this->add_control(
				'google_login_button_type',
				[
					'label'     => esc_html__( 'Type', 'powerpack' ),
					'type'      => Controls_Manager::SELECT,
					'default'   => 'standard',
					'options'   => [
						'standard' => esc_html__( 'Standard', 'powerpack' ),
						'icon'     => esc_html__( 'Icon', 'powerpack' ),
					],
					'condition' => [
						'google_login' => 'yes',
						'google_onetap_login!' => 'yes'
					],
				]
			);

			$this->add_control(
				'google_login_button_theme',
				[
					'label'     => esc_html__( 'Theme', 'powerpack' ),
					'type'      => Controls_Manager::SELECT,
					'default'   => 'outline',
					'options'   => [
						'outline'      => esc_html__( 'Light', 'powerpack' ),
						'filled_blue'  => esc_html__( 'Dark Blue', 'powerpack' ),					
						'filled_black' => esc_html__( 'Dark Black', 'powerpack' ),
					],
					'condition' => [
						'google_login' => 'yes',
						'google_onetap_login!' => 'yes',
					],
				]
			);

			$this->add_control(
				'google_login_button_shape',
				[
					'label'     => esc_html__( 'Shape', 'powerpack' ),
					'type'      => Controls_Manager::SELECT,
					'default'   => 'rectangular',
					'options'   => [
						'rectangular' => esc_html__( 'Rectangular', 'powerpack' ),
						'pill'        => esc_html__( 'Pill', 'powerpack' ),
					],
					'condition' => [
						'google_login' => 'yes',
						'google_onetap_login!' => 'yes',
					],
				]
			);

			$this->add_control(
				'google_login_button_text',
				array(
					'label'     => esc_html__( 'Button Text', 'powerpack' ),
					'type'      => Controls_Manager::SELECT,
					'default'   => 'signin_with',
					'options'   => [
						'signin_with'   => esc_html__( 'Sign in with Google', 'powerpack' ),
						'signup_with'   => esc_html__( 'Sign up with Google', 'powerpack' ),
						'continue_with' => esc_html__( 'Continue with Google', 'powerpack' ),
						'signin'        => esc_html__( 'Sign in', 'powerpack' ),
					],
					'condition' => [
						'google_login' => 'yes',
						'google_login_button_type' => 'standard',
						'google_onetap_login!' => 'yes',
					],
				)
			);

			$this->add_control(
				'google_login_button_size',
				[
					'label'     => esc_html__( 'Size', 'powerpack' ),
					'type'      => Controls_Manager::SELECT,
					'default'   => 'large',
					'options'   => [
						'large'  => esc_html__( 'Large', 'powerpack' ),
						'medium' => esc_html__( 'Medium', 'powerpack' ),
						'small'  => esc_html__( 'Small', 'powerpack' ),
						'custom' => esc_html__( 'Custom', 'powerpack' ),
					],
					'condition' => [
						'google_login' => 'yes',
						'google_onetap_login!' => 'yes'
					],
				]
			);

			$this->add_control(
				'google_login_button_width',
				[
					'label'     => esc_html__( 'Width', 'powerpack' ),
					'type'      => \Elementor\Controls_Manager::NUMBER,
					'min'       => 1,
					'max'       => 400,
					'step'      => 1,
					'condition' => [
						'google_login' => 'yes',
						'google_login_button_size' => 'custom',
						'google_onetap_login!' => 'yes',
					],
				]
			);
		}

		$this->add_control(
			'google_login_button_logo_alignment',
			array(
				'label'     => esc_html__( 'Logo Alignment', 'powerpack' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'left',
				'options'   => array(
					'left'   => esc_html__( 'Left', 'powerpack' ),
					'center' => esc_html__( 'Center', 'powerpack' ),
				),
				'condition' => [
					'google_login' => 'yes',
					'google_login_button_type' => 'standard',
					'google_onetap_login!' => 'yes',
				],
			)
		);

		$this->add_control(
			'social_login_button_layout',
			array(
				'label'      => esc_html__( 'Layout', 'powerpack' ),
				'type'       => Controls_Manager::SELECT,
				'default'    => 'inline',
				'options'    => array(
					'inline'  => esc_html__( 'Inline', 'powerpack' ),
					'stacked' => esc_html__( 'Stacked', 'powerpack' ),
				),
				'conditions' => array(
					'relation' => 'or',
					'terms'    => array(
						array(
							'name'     => 'facebook_login',
							'operator' => '==',
							'value'    => 'yes',
						),
						array(
							'name'     => 'google_login',
							'operator' => '==',
							'value'    => 'yes',
						),
					),
				),
			)
		);

		$this->add_control(
			'social_login_separator',
			array(
				'label'      => esc_html__( 'Use Separator', 'powerpack' ),
				'type'       => Controls_Manager::SWITCHER,
				'default'    => 'no',
				'label_off'  => esc_html__( 'No', 'powerpack' ),
				'label_on'   => esc_html__( 'Yes', 'powerpack' ),
				'conditions' => array(
					'relation' => 'or',
					'terms'    => array(
						array(
							'name'     => 'facebook_login',
							'operator' => '==',
							'value'    => 'yes',
						),
						array(
							'name'     => 'google_login',
							'operator' => '==',
							'value'    => 'yes',
						),
					),
				),
			)
		);

		$this->add_control(
			'social_login_separator_text',
			array(
				'label'       => esc_html__( 'Separator Text', 'powerpack' ),
				'label_block' => true,
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => array(
					'active' => true,
				),
				'default'     => esc_html__( 'Continue with', 'powerpack' ),
				'conditions'  => array(
					'relation' => 'and',
					'terms'    => array(
						array(
							'name'     => 'social_login_separator',
							'operator' => '==',
							'value'    => 'yes',
						),
						array(
							'relation' => 'or',
							'terms'    => array(
								array(
									'name'     => 'facebook_login',
									'operator' => '==',
									'value'    => 'yes',
								),
								array(
									'name'     => 'google_login',
									'operator' => '==',
									'value'    => 'yes',
								),
							),
						),
					),
				),
			)
		);

		$this->add_control(
			'social_login_redirect_url',
			[
				'label'       => esc_html__( 'Redirect URL', 'powerpack' ),
				'type'        => Controls_Manager::URL,
				'dynamic'     => [
					'active' => true,
				],
				'placeholder' => 'http://your-link.com/',
				'options'     => false,
				'condition'   => [
					'google_login' => 'yes',
				],
			]
		);	

		$this->end_controls_section();

		/**
		 * Content Tab: Additional Options
		 */
		$this->start_controls_section(
			'section_login_content',
			array(
				'label' => esc_html__( 'Additional Options', 'powerpack' ),
			)
		);

		$this->add_control(
			'password_toggle',
			array(
				'label'        => esc_html__( 'Password Visibility Toggle', 'powerpack' ),
				'type'         => Controls_Manager::SWITCHER,
				'return_value' => 'yes',
				'default'      => '',
			)
		);

		$this->add_control(
			'redirect_after_login',
			array(
				'label'     => esc_html__( 'Redirect After Login', 'powerpack' ),
				'type'      => Controls_Manager::SWITCHER,
				'default'   => '',
				'label_off' => esc_html__( 'Off', 'powerpack' ),
				'label_on'  => esc_html__( 'On', 'powerpack' ),
			)
		);

		$this->add_control(
			'redirect_url',
			array(
				'type'          => Controls_Manager::URL,
				'dynamic'       => [
					'active'  => true,
				],
				'show_label'    => false,
				'show_external' => false,
				'separator'     => false,
				'placeholder'   => esc_html__( 'https://your-link.com', 'powerpack' ),
				'description'   => esc_html__( 'Note: Because of security reasons, you can ONLY use your current domain here.', 'powerpack' ),
				'condition'     => array(
					'redirect_after_login' => 'yes',
				),
			)
		);

		$this->add_control(
			'redirect_after_logout',
			array(
				'label'     => esc_html__( 'Redirect After Logout', 'powerpack' ),
				'type'      => Controls_Manager::SWITCHER,
				'default'   => '',
				'label_off' => esc_html__( 'Off', 'powerpack' ),
				'label_on'  => esc_html__( 'On', 'powerpack' ),
			)
		);

		$this->add_control(
			'redirect_logout_url',
			array(
				'type'          => Controls_Manager::URL,
				'dynamic'       => [
					'active'  => true,
				],
				'show_label'    => false,
				'show_external' => false,
				'separator'     => false,
				'placeholder'   => esc_html__( 'https://your-link.com', 'powerpack' ),
				'description'   => esc_html__( 'Note: Because of security reasons, you can ONLY use your current domain here.', 'powerpack' ),
				'condition'     => array(
					'redirect_after_logout' => 'yes',
				),
			)
		);

		$this->add_control(
			'show_lost_password',
			array(
				'label'     => esc_html__( 'Password Reset Link', 'powerpack' ),
				'type'      => Controls_Manager::SWITCHER,
				'default'   => 'yes',
				'label_off' => esc_html__( 'Hide', 'powerpack' ),
				'label_on'  => esc_html__( 'Show', 'powerpack' ),
			)
		);

		$this->add_control(
			'lost_password_text',
			array(
				'label'       => esc_html__( 'Lost Password Text', 'powerpack' ),
				'label_block' => false,
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => array(
					'active' => true,
				),
				'default'     => esc_html__( 'Lost your password?', 'powerpack' ),
				'condition'   => array(
					'show_lost_password' => 'yes',
				),
			)
		);

		$this->add_control(
			'lost_password_link',
			array(
				'label'     => esc_html__( 'Link to', 'powerpack' ),
				'type'      => Controls_Manager::SELECT,
				'options'   => array(
					'default'  => esc_html__( 'Default', 'powerpack' ),
					'wp-login' => esc_html__( 'WordPress Login Page', 'powerpack' ),
					'custom'   => esc_html__( 'Custom URL', 'powerpack' ),
				),
				'default'   => 'default',
				'condition' => array(
					'show_lost_password' => 'yes',
				),
			)
		);

		$this->add_control(
			'lost_password_url',
			array(
				'label'     => esc_html__( 'Enter Custom URL', 'powerpack' ),
				'type'      => Controls_Manager::URL,
				'dynamic'   => array(
					'active' => true,
				),
				'condition' => array(
					'show_lost_password' => 'yes',
					'lost_password_link' => 'custom',
				),
			)
		);

		if ( get_option( 'users_can_register' ) ) {
			$this->add_control(
				'show_register',
				array(
					'label'        => esc_html__( 'Register Link', 'powerpack' ),
					'descriptuion' => esc_html__( 'This option will only be available if the registration is enabled in WP admin general settings.', 'powerpack' ),
					'type'         => Controls_Manager::SWITCHER,
					'default'      => 'yes',
					'label_off'    => esc_html__( 'Hide', 'powerpack' ),
					'label_on'     => esc_html__( 'Show', 'powerpack' ),
				)
			);

			$this->add_control(
				'register_text',
				array(
					'label'       => esc_html__( 'Register Link Text', 'powerpack' ),
					'label_block' => false,
					'type'        => Controls_Manager::TEXT,
					'dynamic'     => array(
						'active' => true,
					),
					'default'     => esc_html__( 'Register', 'powerpack' ),
					'condition'   => array(
						'show_register' => 'yes',
					),
				)
			);

			$this->add_control(
				'register_link',
				array(
					'label'     => esc_html__( 'Link to', 'powerpack' ),
					'type'      => Controls_Manager::SELECT,
					'options'   => array(
						'wp-register' => esc_html__( 'WordPress Register Page', 'powerpack' ),
						'custom'      => esc_html__( 'Custom URL', 'powerpack' ),
					),
					'default'   => 'wp-register',
					'condition' => array(
						'show_register' => 'yes',
					),
				)
			);
	
			$this->add_control(
				'register_url',
				array(
					'label'     => esc_html__( 'Enter Custom URL', 'powerpack' ),
					'type'      => Controls_Manager::URL,
					'dynamic'   => array(
						'active' => true,
					),
					'condition' => array(
						'show_register' => 'yes',
						'register_link' => 'custom',
					),
				)
			);
		}

		$this->add_control(
			'show_logged_in_message',
			array(
				'label'       => esc_html__( 'Logged in Message', 'powerpack' ),
				'description' => esc_html__( 'Message is visible only after the page is published and when the user is logged into the site.', 'powerpack' ),
				'type'        => Controls_Manager::SWITCHER,
				'default'     => 'yes',
				'label_off'   => esc_html__( 'Hide', 'powerpack' ),
				'label_on'    => esc_html__( 'Show', 'powerpack' ),
			)
		);

		$this->add_control(
			'lost_password_form_heading',
			array(
				'label'       => esc_html__( 'Lost Password Form', 'powerpack' ),
				'type'        => Controls_Manager::HEADING,
				'separator'   => 'before',
				'condition'   => array(
					'show_lost_password' => 'yes',
				),
			)
		);

		$this->add_control(
			'redirect_after_lost_password',
			array(
				'label'     => esc_html__( 'Redirect After Password Reset', 'powerpack' ),
				'type'      => Controls_Manager::SWITCHER,
				'default'   => '',
				'label_off' => esc_html__( 'Off', 'powerpack' ),
				'label_on'  => esc_html__( 'On', 'powerpack' ),
				'condition'   => array(
					'show_lost_password' => 'yes',
				),
			)
		);

		$this->add_control(
			'redirect_lost_password',
			array(
				'type'          => Controls_Manager::URL,
				'dynamic'       => [
					'active'  => true,
				],
				'show_label'    => false,
				'show_external' => false,
				'separator'     => false,
				'placeholder'   => esc_html__( 'https://your-link.com', 'powerpack' ),
				'description'   => esc_html__( 'Note: Because of security reasons, you can ONLY use your current domain here.', 'powerpack' ),
				'condition'   => array(
					'redirect_after_lost_password' => 'yes',
				),
			)
		);

		$this->add_control(
			'lost_password_form_message',
			array(
				'label'       => esc_html__( 'Lost Password Form Message', 'powerpack' ),
				'label_block' => true,
				'type'        => Controls_Manager::TEXTAREA,
				'rows'        => 3,
				'dynamic'     => array(
					'active' => true,
				),
				'default'     => esc_html__( 'Lost your password? Please enter your username or email address. You will receive a link to create a new password via email.', 'powerpack' ),
				'condition'   => array(
					'show_lost_password'            => 'yes',
					'redirect_after_lost_password!' => 'yes',
				),
			)
		);

		$this->add_control(
			'reset_password_button_text',
			array(
				'label'       => esc_html__( 'Reset Password Button Text', 'powerpack' ),
				'label_block' => true,
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => array(
					'active' => true,
				),
				'default'     => esc_html__( 'Reset password', 'powerpack' ),
				'condition'   => array(
					'show_lost_password' => 'yes',
				),
			)
		);

		$this->end_controls_section();

		$help_docs = PP_Config::get_widget_help_links( 'Login_Form' );
		if ( ! empty( $help_docs ) ) {
			/**
			 * Content Tab: Docs Links
			 *
			 * @since 1.4.8
			 * @access protected
			 */
			$this->start_controls_section(
				'section_help_docs',
				array(
					'label' => esc_html__( 'Help Docs', 'powerpack' ),
				)
			);

			$hd_counter = 1;
			foreach ( $help_docs as $hd_title => $hd_link ) {
				$this->add_control(
					'help_doc_' . $hd_counter,
					array(
						'type'            => Controls_Manager::RAW_HTML,
						'raw'             => sprintf( '%1$s ' . $hd_title . ' %2$s', '<a href="' . $hd_link . '" target="_blank" rel="noopener">', '</a>' ),
						'content_classes' => 'pp-editor-doc-links',
					)
				);

				$hd_counter++;
			}

			$this->end_controls_section();
		}

		/**
		 * Style Tab: Form
\		 */
		$this->start_controls_section(
			'section_style',
			array(
				'label' => esc_html__( 'Form', 'powerpack' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_responsive_control(
			'row_gap',
			array(
				'label'      => esc_html__( 'Rows Gap', 'powerpack' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', 'em', 'rem', 'custom' ),
				'default'    => array(
					'size' => 20,
				),
				'range'      => array(
					'px' => array(
						'min' => 0,
						'max' => 60,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .elementor-field-group' => 'margin-bottom: {{SIZE}}{{UNIT}};',
					'{{WRAPPER}} .elementor-form-fields-wrapper' => 'margin-bottom: -{{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_control(
			'links_heading_style',
			array(
				'label'     => esc_html__( 'Links', 'powerpack' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
			)
		);

		$this->add_responsive_control(
			'links_align',
			array(
				'label'      => esc_html__( 'Alignment', 'powerpack' ),
				'type'       => Controls_Manager::CHOOSE,
				'options'    => array(
					'flex-start' => array(
						'title' => esc_html__( 'Left', 'powerpack' ),
						'icon'  => 'eicon-text-align-left',
					),
					'center'     => array(
						'title' => esc_html__( 'Center', 'powerpack' ),
						'icon'  => 'eicon-text-align-center',
					),
					'flex-end'   => array(
						'title' => esc_html__( 'Right', 'powerpack' ),
						'icon'  => 'eicon-text-align-right',
					),
				),
				'default'    => 'flex-start',
				'selectors'  => array(
					'{{WRAPPER}} .pp-login-form-links' => 'justify-content: {{VALUE}};',
				),
				'conditions' => array(
					'relation' => 'or',
					'terms'    => array(
						array(
							'name'     => 'show_lost_password',
							'operator' => '==',
							'value'    => 'yes',
						),
						array(
							'name'     => 'show_register',
							'operator' => '==',
							'value'    => 'yes',
						),
					),
				),
			)
		);

		$this->add_control(
			'links_color',
			array(
				'label'     => esc_html__( 'Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .elementor-field-group > a' => 'color: {{VALUE}};',
				),
				'global'                => [
					'default' => Global_Colors::COLOR_TEXT,
				],
			)
		);

		$this->add_control(
			'links_hover_color',
			array(
				'label'     => esc_html__( 'Hover Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .elementor-field-group > a:hover' => 'color: {{VALUE}};',
				),
				'global'                => [
					'default' => Global_Colors::COLOR_ACCENT,
				],
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'links_typography',
				'selector' => '{{WRAPPER}} .elementor-field-group > a',
			)
		);

		$this->end_controls_section();

		/**
		 * Style Tab: Label
\		 */
		$this->start_controls_section(
			'section_style_labels',
			array(
				'label'     => esc_html__( 'Label', 'powerpack' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'show_labels!' => '',
				),
			)
		);

		$this->add_responsive_control(
			'label_spacing',
			array(
				'label'      => esc_html__( 'Spacing', 'powerpack' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', 'em', 'rem', 'custom' ),
				'default'    => array(
					'size' => '0',
				),
				'range'      => array(
					'px' => array(
						'min' => 0,
						'max' => 60,
					),
				),
				'selectors'  => array(
					'body {{WRAPPER}} .elementor-field-group > label' => 'padding-bottom: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_control(
			'label_color',
			array(
				'label'     => esc_html__( 'Text Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .elementor-form-fields-wrapper label' => 'color: {{VALUE}};',
				),
				'global'                => [
					'default' => Global_Colors::COLOR_TEXT,
				],
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'label_typography',
				'selector' => '{{WRAPPER}} .elementor-form-fields-wrapper label',
				'global'                => [
					'default' => Global_Typography::TYPOGRAPHY_TEXT,
				],
			)
		);

		$this->end_controls_section();

		/**
		 * Style Tab: Fields
\		 */
		$this->start_controls_section(
			'section_field_style',
			array(
				'label' => esc_html__( 'Fields', 'powerpack' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'field_typography',
				'selector' => '{{WRAPPER}} .elementor-field-group .elementor-field, {{WRAPPER}} .elementor-field-subgroup label',
				'global'                => [
					'default' => Global_Typography::TYPOGRAPHY_TEXT,
				],
			)
		);

		$this->start_controls_tabs( 'tabs_fields_style' );

		$this->start_controls_tab(
			'tab_fields_normal',
			array(
				'label' => esc_html__( 'Normal', 'powerpack' ),
			)
		);

		$this->add_control(
			'field_text_color',
			array(
				'label'     => esc_html__( 'Text Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .elementor-field-group .elementor-field' => 'color: {{VALUE}};',
				),
				'global'                => [
					'default' => Global_Colors::COLOR_TEXT,
				],
			)
		);

		$this->add_control(
			'field_background_color',
			array(
				'label'     => esc_html__( 'Background Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#ffffff',
				'selectors' => array(
					'{{WRAPPER}} .elementor-field-group .elementor-field' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'field_border_style',
			array(
				'label'     => esc_html__( 'Border Style', 'powerpack' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'solid',
				'options'   => array(
					'none'   => esc_html__( 'None', 'powerpack' ),
					'solid'  => esc_html__( 'Solid', 'powerpack' ),
					'double' => esc_html__( 'Double', 'powerpack' ),
					'dotted' => esc_html__( 'Dotted', 'powerpack' ),
					'dashed' => esc_html__( 'Dashed', 'powerpack' ),
					'groove' => esc_html__( 'Groove', 'powerpack' ),
				),
				'selectors' => array(
					'{{WRAPPER}} .elementor-field-group .elementor-field' => 'border-style: {{VALUE}}',
				),
			)
		);

		$this->add_control(
			'field_border_color',
			array(
				'label'     => esc_html__( 'Border Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .elementor-field-group .elementor-field' => 'border-color: {{VALUE}};',
					'{{WRAPPER}} .elementor-field-group .elementor-select-wrapper::before' => 'color: {{VALUE}};',
				),
				'condition' => array(
					'field_border_style!' => 'none',
				),
			)
		);

		$this->add_responsive_control(
			'field_border_width',
			array(
				'label'       => esc_html__( 'Border Width', 'powerpack' ),
				'type'        => Controls_Manager::DIMENSIONS,
				'size_units'  => array( 'px', '%', 'em', 'rem', 'vw', 'custom' ),
				'placeholder' => '1',
				'selectors'   => array(
					'{{WRAPPER}} .elementor-field-group .elementor-field' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
				'condition'   => array(
					'field_border_style!' => 'none',
				),
			)
		);

		$this->add_responsive_control(
			'field_border_radius',
			array(
				'label'      => esc_html__( 'Border Radius', 'powerpack' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em', 'rem', 'custom' ),
				'selectors'  => array(
					'{{WRAPPER}} .elementor-field-group .elementor-field' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'field_box_shadow',
				'selector' => '{{WRAPPER}} .elementor-field-group .elementor-field',
			)
		);

		$this->add_responsive_control(
			'field_padding',
			array(
				'label'      => esc_html__( 'Padding', 'powerpack' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em', 'rem', 'vw', 'custom' ),
				'selectors'  => array(
					'{{WRAPPER}} .elementor-field-group .elementor-field' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'tab_fields_focus',
			array(
				'label' => esc_html__( 'Focus', 'powerpack' ),
			)
		);

		$this->add_control(
			'field_text_color_focus',
			array(
				'label'     => esc_html__( 'Text Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .elementor-field-group .elementor-field:focus' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'field_background_color_focus',
			array(
				'label'     => esc_html__( 'Background Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '',
				'selectors' => array(
					'{{WRAPPER}} .elementor-field-group .elementor-field:focus' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'field_border_color_focus',
			array(
				'label'     => esc_html__( 'Border Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '',
				'selectors' => array(
					'{{WRAPPER}} .elementor-field-group .elementor-field:focus' => 'border-color: {{VALUE}};',
				),
				'condition' => array(
					'field_border_style!' => 'none',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'field_box_shadow_focus',
				'selector' => '{{WRAPPER}} .elementor-field-group .elementor-field:focus',
			)
		);

		$this->end_controls_tab();

		$this->end_controls_tabs();

		$this->end_controls_section();

		/**
		 * Style Tab: Button
\		 */
		$this->start_controls_section(
			'section_button_style',
			array(
				'label' => esc_html__( 'Button', 'powerpack' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'button_typography',
				'global'                => [
					'default' => Global_Typography::TYPOGRAPHY_ACCENT,
				],
				'selector' => '{{WRAPPER}} .elementor-button',
			)
		);

		$this->start_controls_tabs( 'tabs_button_style' );

		$this->start_controls_tab(
			'tab_button_normal',
			array(
				'label' => esc_html__( 'Normal', 'powerpack' ),
			)
		);

		$this->add_control(
			'button_text_color',
			array(
				'label'     => esc_html__( 'Text Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '',
				'selectors' => array(
					'{{WRAPPER}} .elementor-button' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'button_background_color',
			array(
				'label'     => esc_html__( 'Background Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'global'                => [
					'default' => Global_Colors::COLOR_ACCENT,
				],
				'selectors' => array(
					'{{WRAPPER}} .elementor-button' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'button_border',
				'selector' => '{{WRAPPER}} .elementor-button',
			)
		);

		$this->add_responsive_control(
			'button_border_radius',
			array(
				'label'      => esc_html__( 'Border Radius', 'powerpack' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em', 'rem', 'custom' ),
				'selectors'  => array(
					'{{WRAPPER}} .elementor-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'button_box_shadow',
				'selector' => '{{WRAPPER}} .elementor-button',
			)
		);

		$this->add_responsive_control(
			'button_text_padding',
			array(
				'label'      => esc_html__( 'Padding', 'powerpack' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em', 'rem', 'vw', 'custom' ),
				'selectors'  => array(
					'{{WRAPPER}} .elementor-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'tab_button_hover',
			array(
				'label' => esc_html__( 'Hover', 'powerpack' ),
			)
		);

		$this->add_control(
			'button_hover_color',
			array(
				'label'     => esc_html__( 'Text Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .elementor-button:hover' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'button_background_hover_color',
			array(
				'label'     => esc_html__( 'Background Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .elementor-button:hover' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'button_hover_border_color',
			array(
				'label'     => esc_html__( 'Border Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .elementor-button:hover' => 'border-color: {{VALUE}};',
				),
				'condition' => array(
					'button_border_border!' => '',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'button_hover_box_shadow',
				'selector' => '{{WRAPPER}} .elementor-button:hover',
			)
		);

		$this->add_control(
			'button_hover_animation',
			array(
				'label' => esc_html__( 'Animation', 'powerpack' ),
				'type'  => Controls_Manager::HOVER_ANIMATION,
			)
		);

		$this->end_controls_tab();

		$this->end_controls_tabs();

		$this->end_controls_section();

		/**
		 * Style Tab: Social Login
\		 */
		$this->start_controls_section(
			'section_style_social',
			array(
				'label'      => esc_html__( 'Social Login', 'powerpack' ),
				'tab'        => Controls_Manager::TAB_STYLE,
				'conditions' => array(
					'relation' => 'or',
					'terms'    => array(
						array(
							'name'     => 'facebook_login',
							'operator' => '==',
							'value'    => 'yes',
						),
						array(
							'name'     => 'google_login',
							'operator' => '==',
							'value'    => 'yes',
						),
					),
				),
			)
		);

		$this->add_responsive_control(
			'social_buttons_align',
			array(
				'label'      => esc_html__( 'Alignment', 'powerpack' ),
				'type'       => Controls_Manager::CHOOSE,
				'options'    => array(
					'flex-start' => array(
						'title' => esc_html__( 'Left', 'powerpack' ),
						'icon'  => 'eicon-text-align-left',
					),
					'center'     => array(
						'title' => esc_html__( 'Center', 'powerpack' ),
						'icon'  => 'eicon-text-align-center',
					),
					'flex-end'   => array(
						'title' => esc_html__( 'Right', 'powerpack' ),
						'icon'  => 'eicon-text-align-right',
					),
				),
				'default'    => 'center',
				'selectors'  => array(
					'{{WRAPPER}} .pp-social-login-wrap' => 'justify-content: {{VALUE}};',
				),
				'conditions' => array(
					'relation' => 'or',
					'terms'    => array(
						array(
							'name'     => 'facebook_login',
							'operator' => '==',
							'value'    => 'yes',
						),
						array(
							'name'     => 'google_login',
							'operator' => '==',
							'value'    => 'yes',
						),
					),
				),
			)
		);

		$this->add_control(
			'social_button_type',
			array(
				'label'      => esc_html__( 'Button Type', 'powerpack' ),
				'type'       => Controls_Manager::SELECT,
				'options'    => array(
					'solid'       => esc_html__( 'Solid', 'powerpack' ),
					'transparent' => esc_html__( 'Transparent', 'powerpack' ),
					'custom'      => esc_html__( 'Custom', 'powerpack' ),
				),
				'default'    => 'solid',
				'conditions' => array(
					'relation' => 'or',
					'terms'    => array(
						array(
							'name'     => 'facebook_login',
							'operator' => '==',
							'value'    => 'yes',
						),
					),
				),
			)
		);

		$this->add_responsive_control(
			'social_buttons_width',
			array(
				'label'      => esc_html__( 'Button Width', 'powerpack' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%', 'em', 'rem', 'vw', 'custom' ),
				'range'      => array(
					'px' => array(
						'min' => 20,
						'max' => 300,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .pp-login-form .pp-social-login-button' => 'width: {{SIZE}}{{UNIT}};',
				),
				'conditions' => array(
					'relation' => 'or',
					'terms'    => array(
						array(
							'name'     => 'facebook_login',
							'operator' => '==',
							'value'    => 'yes',
						),
					),
				),
			)
		);

		$this->add_responsive_control(
			'social_buttons_spacing',
			array(
				'label'      => esc_html__( 'Button Spacing', 'powerpack' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', 'em', 'rem', 'custom' ),
				'range'      => array(
					'px' => array(
						'min' => 0,
						'max' => 100,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .pp-login-form .pp-social-login-button:not(:last-of-type)' => 'margin-right: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_control(
			'social_fb_button_heading_style',
			array(
				'label'     => esc_html__( 'Facebook', 'powerpack' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
				'condition' => array(
					'facebook_login'     => 'yes',
					'social_button_type' => 'custom',
				),
			)
		);

		$this->start_controls_tabs(
			'tabs_social_fb_button_style',
			array(
				'condition' => array(
					'facebook_login'     => 'yes',
					'social_button_type' => 'custom',
				),
			)
		);

		$this->start_controls_tab(
			'tab_social_fb_button_normal',
			array(
				'label'     => esc_html__( 'Normal', 'powerpack' ),
				'condition' => array(
					'facebook_login'     => 'yes',
					'social_button_type' => 'custom',
				),
			)
		);

		$this->add_control(
			'social_fb_button_color',
			array(
				'label'     => esc_html__( 'Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .pp-login-form .pp-social-login-button.pp-fb-login-button' => 'color: {{VALUE}};',
					'{{WRAPPER}} .pp-login-form .pp-social-login-button.pp-fb-login-button svg path' => 'fill: {{VALUE}};',
				),
				'condition' => array(
					'facebook_login'     => 'yes',
					'social_button_type' => 'custom',
				),
			)
		);

		$this->add_control(
			'social_fb_button_bg_color',
			array(
				'label'     => esc_html__( 'Background Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .pp-login-form .pp-social-login-button.pp-fb-login-button' => 'background-color: {{VALUE}};',
				),
				'condition' => array(
					'facebook_login'     => 'yes',
					'social_button_type' => 'custom',
				),
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'tab_social_fb_button_hover',
			array(
				'label'     => esc_html__( 'Hover', 'powerpack' ),
				'condition' => array(
					'facebook_login'     => 'yes',
					'social_button_type' => 'custom',
				),
			)
		);

		$this->add_control(
			'social_fb_button_color_hover',
			array(
				'label'     => esc_html__( 'Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .pp-login-form .pp-social-login-button.pp-fb-login-button:hover' => 'color: {{VALUE}};',
					'{{WRAPPER}} .pp-login-form .pp-social-login-button.pp-fb-login-button:hover svg path' => 'fill: {{VALUE}};',
				),
				'condition' => array(
					'facebook_login'     => 'yes',
					'social_button_type' => 'custom',
				),
			)
		);

		$this->add_control(
			'social_fb_button_bg_color_hover',
			array(
				'label'     => esc_html__( 'Background Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .pp-login-form .pp-social-login-button.pp-fb-login-button:hover' => 'background-color: {{VALUE}};',
				),
				'condition' => array(
					'facebook_login'     => 'yes',
					'social_button_type' => 'custom',
				),
			)
		);

		$this->end_controls_tab();
		$this->end_controls_tabs();

		$this->add_control(
			'social_google_button_heading_style',
			array(
				'label'     => esc_html__( 'Google', 'powerpack' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
				'condition' => array(
					'google_login'       => 'yes',
					'social_button_type' => 'custom',
				),
			)
		);

		$this->start_controls_tabs(
			'tabs_social_google_button_style',
			array(
				'condition' => array(
					'google_login'       => 'yes',
					'social_button_type' => 'custom',
				),
			)
		);

		$this->add_control(
			'social_google_button_bg_color',
			array(
				'label'     => esc_html__( 'Background Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .pp-login-form .pp-social-login-button.pp-google-login-button' => 'background-color: {{VALUE}};',
				),
				'condition' => array(
					'google_login'       => 'yes',
					'social_button_type' => 'custom',
				),
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'tab_social_google_button_hover',
			array(
				'label'     => esc_html__( 'Hover', 'powerpack' ),
				'condition' => array(
					'google_login'       => 'yes',
					'social_button_type' => 'custom',
				),
			)
		);

		$this->add_control(
			'social_google_button_color_hover',
			array(
				'label'     => esc_html__( 'Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .pp-login-form .pp-social-login-button.pp-google-login-button:hover' => 'color: {{VALUE}};',
				),
				'condition' => array(
					'google_login'       => 'yes',
					'social_button_type' => 'custom',
				),
			)
		);

		$this->add_control(
			'social_google_button_bg_color_hover',
			array(
				'label'     => esc_html__( 'Background Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .pp-login-form .pp-social-login-button.pp-google-login-button:hover' => 'background-color: {{VALUE}};',
				),
				'condition' => array(
					'google_login'       => 'yes',
					'social_button_type' => 'custom',
				),
			)
		);

		$this->end_controls_tab();
		$this->end_controls_tabs();

		$this->add_control(
			'separator_heading_style',
			array(
				'label'      => esc_html__( 'Separator', 'powerpack' ),
				'type'       => Controls_Manager::HEADING,
				'separator'  => 'before',
				'conditions' => array(
					'relation' => 'and',
					'terms'    => array(
						array(
							'name'     => 'social_login_separator',
							'operator' => '==',
							'value'    => 'yes',
						),
						array(
							'relation' => 'or',
							'terms'    => array(
								array(
									'name'     => 'facebook_login',
									'operator' => '==',
									'value'    => 'yes',
								),
								array(
									'name'     => 'google_login',
									'operator' => '==',
									'value'    => 'yes',
								),
							),
						),
					),
				),
			)
		);

		$this->add_control(
			'separator_color',
			array(
				'label'      => esc_html__( 'Separator Color', 'powerpack' ),
				'type'       => Controls_Manager::COLOR,
				'selectors'  => array(
					'{{WRAPPER}} .pp-login-form .pp-login-form-sep-text:after, {{WRAPPER}} .pp-login-form .pp-login-form-sep-text:before' => 'border-bottom-color: {{VALUE}};',
				),
				'conditions' => array(
					'relation' => 'and',
					'terms'    => array(
						array(
							'name'     => 'social_login_separator',
							'operator' => '==',
							'value'    => 'yes',
						),
						array(
							'relation' => 'or',
							'terms'    => array(
								array(
									'name'     => 'facebook_login',
									'operator' => '==',
									'value'    => 'yes',
								),
								array(
									'name'     => 'google_login',
									'operator' => '==',
									'value'    => 'yes',
								),
							),
						),
					),
				),
			)
		);

		$this->add_control(
			'social_login_separator_text_color',
			array(
				'label'      => esc_html__( 'Separator Text Color', 'powerpack' ),
				'type'       => Controls_Manager::COLOR,
				'selectors'  => array(
					'{{WRAPPER}} .pp-login-form .pp-login-form-sep-text' => 'color: {{VALUE}};',
				),
				'conditions' => array(
					'relation' => 'and',
					'terms'    => array(
						array(
							'name'     => 'social_login_separator',
							'operator' => '==',
							'value'    => 'yes',
						),
						array(
							'relation' => 'or',
							'terms'    => array(
								array(
									'name'     => 'facebook_login',
									'operator' => '==',
									'value'    => 'yes',
								),
								array(
									'name'     => 'google_login',
									'operator' => '==',
									'value'    => 'yes',
								),
							),
						),
					),
				),
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'       => 'social_login_separator_text_typography',
				'selector'   => '{{WRAPPER}} .pp-login-form .pp-login-form-sep-text',
				'conditions' => array(
					'relation' => 'and',
					'terms'    => array(
						array(
							'name'     => 'social_login_separator',
							'operator' => '==',
							'value'    => 'yes',
						),
						array(
							'relation' => 'or',
							'terms'    => array(
								array(
									'name'     => 'facebook_login',
									'operator' => '==',
									'value'    => 'yes',
								),
								array(
									'name'     => 'google_login',
									'operator' => '==',
									'value'    => 'yes',
								),
							),
						),
					),
				),
			)
		);

		$this->add_responsive_control(
			'separator_width',
			array(
				'label'      => esc_html__( 'Separator Width', 'powerpack' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', 'em', 'rem', 'custom' ),
				'range'      => array(
					'px' => array(
						'min' => 0,
						'max' => 500,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .pp-login-form .pp-login-form-sep-text:after, {{WRAPPER}} .pp-login-form .pp-login-form-sep-text:before' => 'width: {{SIZE}}{{UNIT}};',
				),
				'conditions' => array(
					'relation' => 'and',
					'terms'    => array(
						array(
							'name'     => 'social_login_separator',
							'operator' => '==',
							'value'    => 'yes',
						),
						array(
							'relation' => 'or',
							'terms'    => array(
								array(
									'name'     => 'facebook_login',
									'operator' => '==',
									'value'    => 'yes',
								),
								array(
									'name'     => 'google_login',
									'operator' => '==',
									'value'    => 'yes',
								),
							),
						),
					),
				),
			)
		);

		$this->end_controls_section();

		/**
		 * Style Tab: Logged in Message
\		 */
		$this->start_controls_section(
			'section_style_message',
			array(
				'label'     => esc_html__( 'Logged in Message', 'powerpack' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'show_logged_in_message' => 'yes',
				),
			)
		);

		$this->add_control(
			'message_color',
			array(
				'label'     => esc_html__( 'Text Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .elementor-login__logged-in-message' => 'color: {{VALUE}};',
				),
				'global'                => [
					'default' => Global_Colors::COLOR_TEXT,
				],
				'condition' => array(
					'show_logged_in_message' => 'yes',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'      => 'message_typography',
				'selector'  => '{{WRAPPER}} .elementor-login__logged-in-message',
				'global'                => [
					'default' => Global_Typography::TYPOGRAPHY_TEXT,
				],
				'condition' => array(
					'show_logged_in_message' => 'yes',
				),
			)
		);

		$this->end_controls_section();

		/**
		 * Style Tab: Lost Password Form
\		 */
		$this->start_controls_section(
			'section_style_lost_password_form',
			array(
				'label'     => esc_html__( 'Lost Password Form', 'powerpack' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'show_lost_password' => 'yes',
				),
			)
		);

		$this->add_control(
			'lost_password_form_message_style',
			array(
				'label'     => esc_html__( 'Lost Password Form Message', 'powerpack' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
				'condition' => array(
					'show_lost_password' => 'yes',
				),
			)
		);

		$this->add_control(
			'lost_password_form_message_color',
			array(
				'label'     => esc_html__( 'Text Color', 'powerpack' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .pp-login-form .pp-login-form--lost-pass-message' => 'color: {{VALUE}};',
				),
				'condition' => array(
					'show_lost_password' => 'yes',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'      => 'lost_password_form_message_typography',
				'selector'  => '{{WRAPPER}} .pp-login-form .pp-login-form--lost-pass-message',
				'condition' => array(
					'show_lost_password' => 'yes',
				),
			)
		);

		$this->end_controls_section();
	}

	/**
	 * Get registration url
	 *
	 * @return string registration link
	 */
	public function get_registration_url() {
		$page_id = PP_Admin_Settings::get_option( 'pp_register_page', true );

		if ( empty( $page_id ) ) {
			return wp_registration_url();
		}

		return get_permalink( $page_id );
	}

	/**
	 * Check if reCaptcha is enabled
	 *
	 * @return bool
	 */
	public function is_recaptcha() {
		$recaptcha_v2_site_key = PP_Admin_Settings::get_option( 'pp_recaptcha_site_key' );
		// Get reCAPTCHA Secret Key from PP admin settings.
		$recaptcha_v2_secret_key = PP_Admin_Settings::get_option( 'pp_recaptcha_secret_key' );
		// Get reCAPTCHA V3 Site Key from PP admin settings.
		$recaptcha_v3_site_key = PP_Admin_Settings::get_option( 'pp_recaptcha_v3_site_key' );
		// Get reCAPTCHA V3 Secret Key from PP admin settings.
		$recaptcha_v3_secret_key = PP_Admin_Settings::get_option( 'pp_recaptcha_v3_secret_key' );

		if ( ( $recaptcha_v2_site_key && $recaptcha_v2_secret_key ) || ( $recaptcha_v3_site_key && $recaptcha_v3_secret_key ) ) {
			return true;
		}

		return false;
	}

	/**
	 * Check if Facebook login data is entered
	 *
	 * @return bool
	 */
	public function is_fb_data() {
		// Get Facebook App ID from PP admin settings.
		$fb_app_id = PP_Admin_Settings::get_option( 'pp_fb_app_id' );
		// Get Facebook App Secret Key from PP admin settings.
		$fb_app_secret = PP_Admin_Settings::get_option( 'pp_fb_app_secret' );

		if ( $fb_app_id && $fb_app_secret ) {
			return true;
		}

		return false;
	}

	/**
	 * Check if Google login data is entered
	 *
	 * @return bool
	 */
	public function is_google_data() {
		// Get Google Client ID from PP admin settings.
		$google_client_id = PP_Admin_Settings::get_option( 'pp_google_client_id' );

		if ( $google_client_id ) {
			return true;
		}

		return false;
	}

	/**
	 * Renders reCAPTCHA field.
	 *
	 * @since 1.5.0
	 *
	 * @param string $instance_id   Unique module ID.
	 * @return void
	 */
	public function render_recaptcha_field( $instance_id ) {
		$settings  = $this->get_settings();
		$is_editor = \Elementor\Plugin::$instance->editor->is_edit_mode();

		// Get reCAPTCHA Site Key from PP admin settings.
		$recaptcha_v2_site_key = PP_Admin_Settings::get_option( 'pp_recaptcha_site_key' );
		// Get reCAPTCHA V3 Site Key from PP admin settings.
		$recaptcha_v3_site_key = PP_Admin_Settings::get_option( 'pp_recaptcha_v3_site_key' );
		?>
		<div class="pp-login-form-field pp-field-group pp-field-type-recaptcha">
			<?php
			$id                      = $instance_id;
			$recaptcha_site_key      = 'invisible_v3' === $settings['recaptcha_validate_type'] ? $recaptcha_v3_site_key : $recaptcha_v2_site_key;
			$recaptcha_validate      = ( 'invisible_v3' === $settings['recaptcha_validate_type'] || 'invisible' === $settings['recaptcha_validate_type'] ) ? 'invisible' : $settings['recaptcha_validate_type'];
			$recaptcha_validate_type = ( 'invisible_v3' === $settings['recaptcha_validate_type'] ) ? 'invisible_v3' : $settings['recaptcha_validate_type'];
			$recaptcha_theme         = $settings['recaptcha_theme'];

			if ( $recaptcha_site_key ) {
				?>
				<div id="<?php echo esc_attr( $id ); ?>-pp-grecaptcha" class="pp-grecaptcha" data-sitekey="<?php echo wp_kses_post( $recaptcha_site_key ); ?>" data-validate="<?php echo wp_kses_post( $recaptcha_validate ); ?>"data-validate-type="<?php echo wp_kses_post( $recaptcha_validate_type ); ?>" data-theme="<?php echo wp_kses_post( $recaptcha_theme ); ?>"></div>
			<?php } else { ?>
				<?php if ( $is_editor ) { ?>
					<div class="pp-editor-placeholder"><?php echo wp_kses_post( PP_Helper::get_recaptcha_desc() ); ?></div>
				<?php } ?>
			<?php } ?>
		</div>
		<?php
	}

	/**
	 * Render Social Media icons on the frontend.
	 *
	 * Written in PHP and used to generate the final HTML.
	 *
	 * @since 1.5.0
	 * @access protected
	 */
	private function render_social_login() {
		$settings         = $this->get_settings_for_display();
		$fb_app_id        = PP_Admin_Settings::get_option( 'pp_fb_app_id' );
		$google_client_id = PP_Admin_Settings::get_option( 'pp_google_client_id' );
		?>
		<?php if ( $this->is_fb_data() || $this->is_google_data() ) { ?>
			<?php if ( 'yes' === $settings['facebook_login'] || 'yes' === $settings['google_login'] ) { ?>
				<?php if ( 'yes' === $settings['social_login_separator'] ) { ?>
					<div class="pp-login-form-sep">
						<span class="pp-login-form-sep-text"><?php echo wp_kses_post( $settings['social_login_separator_text'] ); ?></span>
					</div>
					<?php } ?>
					<div class="pp-social-login-wrap pp-social-login--<?php echo ( $settings['social_button_type'] ) ? wp_kses_post( $settings['social_button_type'] ) : 'solid'; ?> pp-social-login--layout-<?php echo wp_kses_post( $settings['social_login_button_layout'] ); ?>">
						<?php if ( $this->is_fb_data() && 'yes' === $settings['facebook_login'] ) { ?>
							<div class="pp-fb-login-button pp-social-login-button" id="pp-fb-login-button" tabindex="0" role="button" data-appid="<?php echo esc_attr( $fb_app_id ); ?>">
								<span class="pp-social-login-icon">
									<svg xmlns="http://www.w3.org/2000/svg">
										<path d="M22.688 0H1.323C.589 0 0 .589 0 1.322v21.356C0 23.41.59 24 1.323 24h11.505v-9.289H9.693V11.09h3.124V8.422c0-3.1 1.89-4.789 4.658-4.789 1.322 0 2.467.1 2.8.145v3.244h-1.922c-1.5 0-1.801.711-1.801 1.767V11.1h3.59l-.466 3.622h-3.113V24h6.114c.734 0 1.323-.589 1.323-1.322V1.322A1.302 1.302 0 0 0 22.688 0z"></path>
									</svg>
								</span>
								<?php if ( $settings['facebook_login_label'] ) { ?>
									<span class="pp-social-login-label"><?php echo wp_kses_post( $settings['facebook_login_label'] ); ?></span>
								<?php } ?>
							</div>
						<?php } ?>
						<?php if ( $this->is_google_data() && 'yes' === $settings['google_login'] ) {
							$google_login_button_type  = ! empty( $settings['google_login_button_type'] ) ? $settings['google_login_button_type'] : 'standard';
							$google_login_button_theme = ! empty( $settings['google_login_button_theme'] ) ? $settings['google_login_button_theme'] : 'outline';
							$google_login_button_shape = ! empty( $settings['google_login_button_shape'] ) ? $settings['google_login_button_shape'] : 'rectangular';
							if ( 'icon' === $google_login_button_type ) {
								$google_login_button_shape = ( 'pill' === $google_login_button_shape ) ? 'circle' : 'square';
							}
							$google_login_button_text  = ! empty( $settings['google_login_button_text'] ) ? $settings['google_login_button_text'] : 'signin_with';
							$google_login_button_size  = ! empty( $settings['google_login_button_size'] ) ? $settings['google_login_button_size'] : 'large';
							$google_login_button_width = ! empty( $settings['google_login_button_width'] ) ? $settings['google_login_button_width'] : '100';
							$google_login_button_logo_align = ! empty( $settings['google_login_button_logo_alignment'] ) ? $settings['google_login_button_logo_alignment'] : 'left';
							$google_onetap_login       = ! empty( $settings['google_onetap_login'] ) ? $settings['google_onetap_login'] : '';
							$social_login_redirect_url = ! empty( $settings['social_login_redirect_url']['url'] ) ? $settings['social_login_redirect_url']['url'] : '';
							?>
							<script src="https://accounts.google.com/gsi/client"></script>
							<div class="pp-google-login-button pp-social-login-button" id="pp-google-login-button" tabindex="0" role="button" data-clientid="<?php echo esc_attr( $google_client_id ); ?>" > </div>
							<script>
								var getGoogleLoginButtton = document.querySelector('.pp-google-login-button'),
									googleLoginOneTap = '<?php echo $google_onetap_login?>',
									getSocialRedirectUrl = '<?php echo $social_login_redirect_url; ?>',
									nonce = '<?php echo wp_create_nonce( 'pp_login_nonce' )?>';
	
								if ( googleLoginOneTap ) {
									getGoogleLoginButtton.innerHTML = '<div id="g_id_onload" data-cancel_on_tap_outside="false" data-client_id="<?php echo esc_attr( $google_client_id ); ?>" data-context="signin"  data-callback="ppGoogleLoginEndpoint" data-nonce="pp_login_nonce"> </div>';
								} else {
									window.onload = function () {
										google.accounts.id.initialize({
											client_id: '<?php echo esc_attr( $google_client_id ); ?>',
											callback: function(response) {
												ppGoogleLoginEndpoint(response , '<?php echo esc_attr( $google_client_id ); ?>' )
											}
										});
										google.accounts.id.renderButton(getGoogleLoginButtton , {
											type: '<?php echo esc_attr( $google_login_button_type ); ?>',
											theme: '<?php echo esc_attr( $google_login_button_theme ); ?>',
											shape: '<?php echo esc_attr( $google_login_button_shape ); ?>',
											text: '<?php echo esc_attr( $google_login_button_text ); ?>',
											size: '<?php echo esc_attr( $google_login_button_size ); ?>',
											logo_alignment: '<?php echo esc_attr( $google_login_button_logo_align ); ?>',
											width: '<?php echo esc_attr( $google_login_button_width ); ?>'
										} );
									}
								}

								function ppGoogleLoginEndpoint(googleUser , clientId){
									let gclientId = '';

									if (clientId) {
										gclientId = clientId;
									} else {
										if (googleUser.clientId) {
											gclientId = googleUser.clientId
										}
									}

									jQuery.ajax({
										url: '<?php echo admin_url( 'admin-ajax.php' ); ?>',
										method: 'post',
										data: {
											action: 'pp_lf_process_social_login',
											googleCre: googleUser.credential,
											clientId: gclientId,
											nonce: nonce,
											provider: 'google',
										},
										dataType: 'json',
										success: function(data) {
											if (getSocialRedirectUrl) {
												window.location = getSocialRedirectUrl;
											} else {
												location.reload();
											}
										},
										complete: function(){

										}
									});
								}
							</script>
						<?php } ?>
					</div>
				<?php } ?>
			<?php } ?>
		<?php
	}

	/**
	 * Render form fields attributes
	 *
	 * @access private
	 */
	private function form_fields_render_attributes() {
		$settings = $this->get_settings();

		if ( ! empty( $settings['button_size'] ) ) {
			$this->add_render_attribute( 'button', 'class', 'elementor-size-' . $settings['button_size'] );
			$this->add_render_attribute( 'lost_password_button', 'class', 'elementor-size-' . $settings['button_size'] );
			$this->add_render_attribute( 'reset_password_button', 'class', 'elementor-size-' . $settings['button_size'] );
		}

		if ( $settings['button_hover_animation'] ) {
			$this->add_render_attribute( 'button', 'class', 'elementor-animation-' . $settings['button_hover_animation'] );
			$this->add_render_attribute( 'lost_password_button', 'class', 'elementor-animation-' . $settings['button_hover_animation'] );
			$this->add_render_attribute( 'reset_password_button', 'class', 'elementor-animation-' . $settings['button_hover_animation'] );
		}

		$this->add_render_attribute(
			array(
				'wrapper'               => array(
					'class' => array(
						'elementor-form-fields-wrapper',
					),
				),
				'field-group'           => array(
					'class' => array(
						'elementor-field-type-text',
						'elementor-field-group',
						'elementor-column',
						'elementor-col-100',
					),
				),
				'password-field-group'  => array(
					'class' => array(
						'elementor-field-type-text',
						'elementor-field-group',
						'elementor-column',
						'elementor-col-100',
						'form-field-password',
					),
				),
				'submit-group'          => array(
					'class' => array(
						'elementor-field-group',
						'elementor-column',
						'elementor-field-type-submit',
						'elementor-col-100',
					),
				),
				'button'                => array(
					'class' => array(
						'elementor-button',
						'pp-submit-button',
					),
					'name'  => 'wp-submit',
				),
				'user_input'            => array(
					'type'        => 'text',
					'name'        => 'log',
					'id'          => 'user',
					'placeholder' => $settings['user_placeholder'],
					'class'       => array(
						'elementor-field',
						'elementor-field-textual',
						'elementor-size-' . $settings['input_size'],
					),
				),
				'password_input'        => array(
					'type'        => 'password',
					'name'        => 'pwd',
					'id'          => 'password',
					'placeholder' => $settings['password_placeholder'],
					'class'       => array(
						'elementor-field',
						'elementor-field-textual',
						'elementor-size-' . $settings['input_size'],
					),
				),
				'label_user'            => array(
					'for'   => 'user',
					'class' => 'elementor-field-label',
				),
				'label_password'        => array(
					'for'   => 'password',
					'class' => 'elementor-field-label',
				),
				'lost_password_button'  => array(
					'class' => array(
						'elementor-button',
						'pp-submit-button',
						'pp-lost-password-button',
					),
					'name'  => 'pp-login-form-lost-pw',
					'type'  => 'submit',
				),
				'lost_password_label'   => array(
					'for'   => 'user_login',
					'class' => 'elementor-field-label',
				),
				'lost_password_input'   => array(
					'type'         => 'text',
					'name'         => 'user_login',
					'id'           => 'user_login',
					'placeholder'  => $settings['user_placeholder'],
					'class'        => array(
						'elementor-field',
						'elementor-field-textual',
						'elementor-size-' . $settings['input_size'],
					),
					'size'         => '1',
					'autocomplete' => 'username',
				),
				'reset_password_1'      => array(
					'type'         => 'password',
					'name'         => 'password_1',
					'id'           => 'password_1',
					'placeholder'  => esc_html__( 'Enter New Password', 'powerpack' ),
					'class'        => array(
						'elementor-field',
						'elementor-field-textual',
						'elementor-size-' . $settings['input_size'],
					),
					'size'         => '1',
					'autocomplete' => 'new-password',
				),
				'reset_password_2'      => array(
					'type'         => 'password',
					'name'         => 'password_2',
					'id'           => 'password_2',
					'placeholder'  => esc_html__( 'Re-enter New Password', 'powerpack' ),
					'class'        => array(
						'elementor-field',
						'elementor-field-textual',
						'elementor-size-' . $settings['input_size'],
					),
					'size'         => '1',
					'autocomplete' => 'new-password',
				),
				'reset_password_button' => array(
					'class' => array(
						'elementor-button',
						'pp-submit-button',
						'pp-lost-password-button',
						'pp-login-form--lost-pass',
					),
					'name'  => 'pp-login-form-reset-pw',
					'type'  => 'submit',
				),
			)
		);

		if ( ! $settings['show_labels'] ) {
			$this->add_render_attribute( 'label', 'class', 'elementor-screen-only' );
		}

		if ( isset( $settings['password_toggle'] ) && 'yes' === $settings['password_toggle'] ) {
			$this->add_render_attribute( 'password-field-group', 'class', 'pp-lf-field-pw-toggle' );
		}

		$this->add_render_attribute( 'field-group', 'class', 'elementor-field-required' )
			->add_render_attribute( 'input', 'required', true )
			->add_render_attribute( 'input', 'aria-required', 'true' );

	}

	/**
	 * Get Lost Password Form
	 *
	 * Form asks for users email or username to send a password reset email to
	 * their registered email account.
	 *
	 * @since 2.1.0
	 * @access private
	 */
	private function get_lost_password_form( $settings, $id ) {
		do_action( 'pp_login_form_before_lost_password_form', $settings, $id );
		?>
		<form method="post" class="pp-login-form pp-login-form--lost-pass elementor-form">
			<div class="pp-login-form--lost-pass-message">
				<p>
					<?php
					$lost_password_form_message = ( $settings['lost_password_form_message'] ) ? $settings['lost_password_form_message'] : esc_html__( 'Lost your password? Please enter your username or email address. You will receive a link to create a new password via email.', 'powerpack' );
					$lost_password_form_message = apply_filters( 'pp_login_form_lost_password_message', $lost_password_form_message );
					echo wp_kses_post( $lost_password_form_message );
					?>
				</p><?php // @codingStandardsIgnoreLine ?>
			</div>
			<div <?php $this->print_render_attribute_string( 'wrapper' ); ?>>
				<div class="elementor-field-group elementor-column elementor-col-100">
					<?php
					if ( 'custom' === $settings['show_labels'] ) {
						echo '<label ' . wp_kses_post( $this->get_render_attribute_string( 'lost_password_label' ) ) . '>' . wp_kses_post( $settings['user_label'] ) . '</label>';
					} elseif ( 'default' === $settings['show_labels'] ) {
						echo '<label ' . wp_kses_post( $this->get_render_attribute_string( 'lost_password_label' ) ) . '>';
						echo esc_attr__( 'Username or Email Address', 'powerpack' );
						echo '</label>';
					}

					$current_url     = remove_query_arg( 'fake_arg' );
					$redirect_url    = $current_url;

					if ( 'yes' === $settings['redirect_after_lost_password'] && ! empty( $settings['redirect_lost_password']['url'] ) ) {
						$redirect_url = $settings['redirect_lost_password']['url'];
					}
					$is_redirect = ( 'yes' === $settings['redirect_after_lost_password'] ) ? 1 : 0;
					?>
					<input <?php $this->print_render_attribute_string( 'lost_password_input' ); ?> />
					<input type="hidden" name="lost_redirect_to" value="<?php echo esc_attr( $redirect_url ); ?>">
					<input type="hidden" name="is_lost_redirect" value="<?php echo esc_attr( $is_redirect ); ?>">
				</div>
				<div <?php $this->print_render_attribute_string( 'submit-group' ); ?>>
					<button <?php $this->print_render_attribute_string( 'lost_password_button' ); ?>>
						<span class="pp-login-form--button-text">
							<?php
							if ( $settings['reset_password_button_text'] ) {
								echo wp_kses_post( $settings['reset_password_button_text'] );
							} else {
								esc_html_e( 'Reset Password', 'powerpack' );
							}
							?>
						</span>
					</button>
				</div>
			</div>

			<?php wp_nonce_field( 'lost_password', 'pp-lf-lost-password-nonce' ); ?>
		</form>
		<?php
		do_action( 'pp_login_form_after_lost_password_form', $settings, $id );
	}

	/**
	 * Get Password Reset Form
	 *
	 * Form allows user to add new password. It appears after user has clicked password
	 * reset link from their email account.
	 *
	 * @since 2.1.0
	 * @access private
	 */

	private function get_reset_password_form( $settings, $id ) {
		defined( 'ABSPATH' ) || exit;

		$key        = esc_attr( wp_unslash( $_GET['key'] ) );
		$user_id    = esc_attr( wp_unslash( $_GET['id'] ) );
		$userdata   = get_userdata( absint( $user_id ) );
		$user_login = $userdata ? $userdata->user_login : '';

		$validate_reset_key = check_password_reset_key( $key, $user_login );
		if ( is_wp_error( $validate_reset_key ) ) {
			echo '<span class="pp-lf-error">' . esc_attr__( 'This key is invalid or has already been used. Please reset your password again if needed.', 'powerpack' ) . '</span>';
			return;
		}

		do_action( 'pp_login_form_before_reset_password_form', $settings, $id );
		?>
		<form method="post" class="pp-login-form pp-login-form--reset-pass">
			<p><?php echo apply_filters( 'pp_login_form_reset_password_message', esc_html__( 'Enter a password below.', 'powerpack' ) ); ?></p><?php // @codingStandardsIgnoreLine ?>
			<div <?php $this->print_render_attribute_string( 'wrapper' ); ?>>
				<div <?php $this->print_render_attribute_string( 'field-group' ); ?>>
					<label for="password_1"><?php esc_html_e( 'New Password', 'powerpack' ); ?></label>
					<input <?php $this->print_render_attribute_string( 'reset_password_1' ); ?> />
				</div>
				<div <?php $this->print_render_attribute_string( 'field-group' ); ?>>
					<label for="password_2"><?php esc_html_e( 'Re-enter New Password', 'powerpack' ); ?></label>
					<input <?php $this->print_render_attribute_string( 'reset_password_2' ); ?> />
				</div>
				<div <?php $this->print_render_attribute_string( 'submit-group' ); ?>>
					<button <?php $this->print_render_attribute_string( 'reset_password_button' ); ?>>
						<span class="pp-login-form--button-text"><?php esc_html_e( 'Save', 'powerpack' ); ?></span>
					</button>
				</div>
			</div>

			<input type="hidden" name="reset_key" value="<?php echo esc_attr( $key ); ?>" />
			<input type="hidden" name="reset_login" value="<?php echo esc_attr( $user_login ); ?>" />

			<?php wp_nonce_field( 'reset_password', 'pp-lf-reset-password-nonce' ); ?>
		</form>
		<?php
		do_action( 'pp_login_form_after_reset_password_form', $settings, $id );
	}

	private function render_password_toggle_icon( $icon, $attributes = [] ) {
		// When the experiment is active and the search icon renders as SVG, it needs additional container for the icon box border.
		if ( PP_Helper::is_feature_active( 'e_font_icon_svg' ) ) {
			$icon_html = Icons_Manager::render_font_icon( $icon, $attributes );

			\Elementor\Utils::print_unescaped_internal_string( sprintf( '<div class="e-font-icon-svg-container">%s</div>', $icon_html ) );
		} else {
			$migration_allowed = Icons_Manager::is_migration_allowed();

			if ( ! $migration_allowed || ! Icons_Manager::render_icon( $icon, [ 'aria-hidden' => 'true' ] ) ) {
				\Elementor\Utils::print_unescaped_internal_string( sprintf( '<i %s aria-hidden="true"></i>', $this->get_render_attribute_string( 'icon' ) ) );
			}
		}
	}

	/**
	 * Render Login-Form output on the frontend.
	 *
	 * Written in PHP and used to generate the final HTML.
	 *
	 * @since 1.5.0
	 * @access protected
	 */
	protected function render() {
		$settings        = $this->get_settings_for_display();
		$id              = $this->get_id();
		$current_url     = remove_query_arg( 'fake_arg' );
		$redirect_url    = $current_url;
		$logout_redirect = $current_url;

		$action            = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'login';
		$is_lost_password  = 'lost_pass' === $action || isset( $_GET['lost_pass'] );
		$is_reset_password = 'reset_pass' === $action || isset( $_GET['reset_pass'] );

		if ( 'yes' === $settings['redirect_after_login'] && ! empty( $settings['redirect_url']['url'] ) ) {
			$redirect_url = $settings['redirect_url']['url'];
		}

		if ( 'yes' === $settings['redirect_after_logout'] && ! empty( $settings['redirect_logout_url']['url'] ) ) {
			$logout_redirect = $settings['redirect_logout_url']['url'];
		}

		if ( is_user_logged_in() && ! \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
			if ( 'yes' === $settings['show_logged_in_message'] ) {
				$current_user = wp_get_current_user();

				echo '<div class="elementor-login elementor-login__logged-in-message">';
				$a_tag       = '<a href="' . esc_url( wp_logout_url( $logout_redirect ) ) . '">';
				$close_a_tag = '</a>';
				/* translators: 1: Current user's display name 2: Link opening tag, 3: Link closing tag. */
				$msg = sprintf( esc_html__( 'You are Logged in as %1$s (%2$sLogout%3$s)', 'powerpack' ), wp_kses_post( $current_user->display_name ), wp_kses_post( $a_tag ), wp_kses_post( $close_a_tag ) );
				echo apply_filters( 'pp_login_form_logged_in_message', $msg, $current_user->display_name, wp_logout_url( $logout_redirect ) );
				echo '</div>';
			}

			return;
		}

		$this->form_fields_render_attributes();
		?>
		<div class="pp-login-form-wrap" data-page-url="<?php echo esc_url( get_permalink() ); ?>">

		<?php if ( ! $is_lost_password && ! $is_reset_password ) { ?>

			<form class="pp-form pp-login-form elementor-form" id="pp-form-<?php echo esc_attr( $this->get_id() ); ?>" method="post" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>">
				<?php
				/**
				 * Hook to add custom content just after form opening tag.
				 *
				 * @since 2.2.2
				 *
				 * @param array $settings  Module settings.
				 */
				do_action( 'pp_login_form_start', $settings );
				?>
				<?php wp_nonce_field( 'pp_login_nonce', 'ppe-lf-login-nonce' ); ?>
				<input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_url ); ?>">
				<div <?php $this->print_render_attribute_string( 'wrapper' ); ?>>
					<div <?php $this->print_render_attribute_string( 'field-group' ); ?>>
						<?php
						if ( 'custom' === $settings['show_labels'] ) {
							echo '<label ' . wp_kses_post( $this->get_render_attribute_string( 'label_user' ) ) . '>' . wp_kses_post( $settings['user_label'] ) . '</label>';
						} elseif ( 'default' === $settings['show_labels'] ) {
							echo '<label ' . wp_kses_post( $this->get_render_attribute_string( 'label_user' ) ) . '>';
							echo esc_attr__( 'Username or Email Address', 'powerpack' );
							echo '</label>';
						}

						echo '<input size="1" ' . wp_kses_post( $this->get_render_attribute_string( 'user_input' ) ) . '>';
						?>
					</div>
					<div <?php $this->print_render_attribute_string( 'password-field-group' ); ?>>
						<?php
						if ( 'custom' === $settings['show_labels'] ) {
							echo '<label ' . wp_kses_post( $this->get_render_attribute_string( 'label_password' ) ) . '>' . wp_kses_post( $settings['password_label'] ) . '</label>';
						} elseif ( 'default' === $settings['show_labels'] ) {
							echo '<label ' . wp_kses_post( $this->get_render_attribute_string( 'label_password' ) ) . '>';
							echo esc_attr__( 'Password', 'powerpack' );
							echo '</label>';
						}

						?>
						<div class="pp-lf-field-inner">
							<input size="1" <?php $this->print_render_attribute_string( 'password_input' ); ?> >
							<?php if ( 'yes' === $settings['password_toggle'] ) { ?>
								<?php
								$icon_class = 'eye';

								$this->add_render_attribute( 'icon', 'class', 'fa fa-' . $icon_class );

								$icon = [
									'value' => 'far fa-' . $icon_class,
									'library' => 'fa-regular',
								];
								?>
								<button type="button" class="pp-lf-toggle-pw hide-if-no-js" aria-label="<?php esc_attr_e( 'Show password', 'powerpack' ); ?>">
									<?php $this->render_password_toggle_icon( $icon, [ 'aria-hidden' => 'true' ] ); ?>
								</button>
							<?php } ?>
						</div>
					</div>

					<?php if ( 'yes' === $settings['show_remember_me'] ) : ?>
						<?php
						$remember_me_text = ( $settings['remember_me_text'] ) ? $settings['remember_me_text'] : esc_html__( 'Remember Me', 'powerpack' );
						?>
						<div class="elementor-field-type-checkbox elementor-field-group elementor-column elementor-col-100 elementor-remember-me">
							<label for="pp-login-remember-me">
								<input type="checkbox" id="elementor-login-remember-me" name="rememberme" value="forever">
								<span class="pp-login-remember-text"><?php echo esc_attr( $remember_me_text ); ?></span>
							</label>
						</div>
					<?php endif; ?>

					<?php
					// Render reCAPTCHA field.
					if ( 'yes' === $settings['enable_recaptcha'] ) {
						$this->render_recaptcha_field( $id );
					}
					?>

					<div <?php $this->print_render_attribute_string( 'submit-group' ); ?>>
						<button type="submit" <?php $this->print_render_attribute_string( 'button' ); ?>>
							<?php if ( ! empty( $settings['button_text'] ) ) : ?>
								<span class="elementor-button-text"><?php echo wp_kses_post( $settings['button_text'] ); ?></span>
							<?php endif; ?>
						</button>
					</div>

					<?php
					$show_lost_password = 'yes' === $settings['show_lost_password'];
					$show_register      = get_option( 'users_can_register' ) && 'yes' === $settings['show_register'];

					if ( $show_lost_password || $show_register ) :
						$this->add_render_attribute( 'lost_pass_link', 'class', 'elementor-lost-password' );

						if ( 'wp-login' === $settings['lost_password_link'] ) {

							$this->add_render_attribute( 'lost_pass_link', 'href', wp_lostpassword_url() );

						} elseif ( 'custom' === $settings['lost_password_link'] && ! empty( $settings['lost_password_url']['url'] ) ) {

							$this->add_link_attributes( 'lost_pass_link', $settings['lost_password_url'] );

						} else {
							$this->add_render_attribute( 'lost_pass_link', 'href', esc_url( add_query_arg( 'lost_pass', '1' ) ) );
						}

						$this->add_render_attribute( 'register_link', 'class', 'elementor-register' );

						if ( isset( $settings['register_link'] ) && 'custom' === $settings['register_link'] && ! empty( $settings['register_url']['url'] ) ) {

							$this->add_link_attributes( 'register_link', $settings['register_url'] );

						} else {
							$this->add_render_attribute( 'register_link', 'href', esc_url( $this->get_registration_url() ) );
						}
						?>
						<div class="elementor-field-group elementor-column elementor-col-100 pp-login-form-links">
							<?php if ( $show_lost_password ) : ?>
								<a <?php $this->print_render_attribute_string( 'lost_pass_link' ); ?>>
									<?php echo ! empty( $settings['lost_password_text'] ) ? wp_kses_post( $settings['lost_password_text'] ) : esc_attr__( 'Lost your password?', 'powerpack' ); ?>
								</a>
							<?php endif; ?>

							<?php if ( $show_register ) : ?>
								<a <?php $this->print_render_attribute_string( 'register_link' ); ?>>
									<?php echo wp_kses_post( $settings['register_text'] ); ?>
								</a>
							<?php endif; ?>
						</div>
					<?php endif; ?>
				</div>
				<?php
					$this->render_social_login();
				?>

				<?php
				/**
				 * Hook to add custom content just before form closing tag.
				 *
				 * @since 2.2.2
				 *
				 * @param array $settings  Module settings.
				 */
				do_action( 'pp_login_form_end', $settings );
				?>
			</form>
			<?php
		} elseif ( $is_lost_password ) {
			$this->get_lost_password_form( $settings, $id );
		} elseif ( $is_reset_password ) {
			$this->get_reset_password_form( $settings, $id );
		}
		?>

		</div>
		<?php
	}
}
