<?php
use Elementor\Controls_Manager;
use Elementor\Repeater;
use Elementor\Plugin;

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

class Ecafe_Widgets_Extras {

	public function __construct() {
		$extrasListOpt = get_option( 'ecafe_extension' );
		if ( ! empty( $extrasListOpt ) && ( isset( $extrasListOpt['extrasList'] ) && ! empty( $extrasListOpt['extrasList'] ) ) ) {
			$this->extra_add_widgets_actions();

			// if(in_array('ecafe-lax-scroll',$extrasListOpt['extrasList'])){
				// add_action( 'wp_enqueue_scripts', [ $this, 'eca_lax_style' ] );
			// }
		}
	}
	public function get_extra_list() {
		$extrasListOpt = get_option( 'ecafe_extension' );
		if ( ! empty( $extrasListOpt ) && ( isset( $extrasListOpt['extrasList'] ) && ! empty( $extrasListOpt['extrasList'] ) ) ) {
			return $extrasListOpt['extrasList'];
		}
		return array();
	}
	public function get_name() {
		return 'eca-extras-opts';
	}

	public function eca_lax_style() {
		wp_enqueue_script( 'ecafe-lax', ECAFE_ASSETS_PATH . 'js/baharni/lax.min.js', array( 'jquery' ), ECAFE_VERSION, false );
		wp_enqueue_script( 'ecafe-min-js', ECAFE_ASSETS_PATH . 'js/custom/ecafe.min.js', array( 'jquery' ), ECAFE_VERSION, false );
		wp_enqueue_script( 'eca-lax', ECAFE_ASSETS_PATH . 'js/admin/eca-lax.js', array( 'jquery' ), ECAFE_VERSION, true );
	}


	/**
	 * Extra Add Actions
	 */
	protected function extra_add_widgets_actions() {
		$experiments_manager = Plugin::$instance->experiments;
		if ( in_array( 'ecafe-lax-scroll', $this->get_extra_list() ) ) {
			add_action( 'elementor_pro/element/common/_section_style/after_section_end', array( $this, 'add_lax_controls' ), 10, 2 );
			add_action( 'elementor/element/common/_section_style/after_section_end', array( $this, 'add_lax_controls' ), 10, 2 );
			add_action( 'elementor/element/container/section_layout/after_section_end', array( $this, 'add_lax_controls' ), 10, 2 );
		}
		if ( in_array( 'ecafe-widget-link', $this->get_extra_list() ) ) {
			add_action( 'elementor/element/column/_section_responsive/after_section_end', array( $this, 'add_link_controls' ), 10, 2 );
			add_action( 'elementor/element/section/_section_responsive/after_section_end', array( $this, 'add_link_controls' ), 10, 2 );
			add_action( 'elementor/element/common/section_custom_css_pro/after_section_end', array( $this, 'add_link_controls' ), 10, 2 );

			if ( $experiments_manager->is_feature_active( 'container' ) ) {
				add_action( 'elementor/element/container/section_layout/after_section_end', array( $this, 'add_link_controls' ), 10, 2 );
			}
		}

		if ( in_array( 'ecafe-glassmorphism', $this->get_extra_list() ) ) {
			add_action( 'elementor/element/column/_section_responsive/after_section_end', array( $this, 'ec_glassmorphism_controls' ), 10, 2 );
			add_action( 'elementor/element/section/_section_responsive/after_section_end', array( $this, 'ec_glassmorphism_controls' ), 10, 2 );
			add_action( 'elementor/element/common/section_custom_css_pro/after_section_end', array( $this, 'ec_glassmorphism_controls' ), 10, 2 );

			if ( $experiments_manager->is_feature_active( 'container' ) ) {
				add_action( 'elementor/element/container/section_layout/after_section_end', array( $this, 'ec_glassmorphism_controls' ), 10, 2 );
			}
		}

		add_action(
			'elementor/frontend/before_render',
			function ( $element ) {

				$settings = $element->get_settings();
				/*lax animation*/
				if ( ! empty( $settings['ecaExtraLaxScroll'] ) && 'yes' === $settings['ecaExtraLaxScroll'] && in_array( 'ecafe-lax-scroll', $this->get_extra_list() ) ) {

					// Set Data Lax Effect
					if ( empty( $settings['laxScrollOpt'] ) ) {
						return;
					}
					wp_enqueue_script( 'ecafe-lax', ECAFE_ASSETS_PATH . 'js/baharni/lax.min.js', array( 'jquery' ), ECAFE_VERSION, false );
					wp_enqueue_script( 'ecafe-min-js', ECAFE_ASSETS_PATH . 'js/custom/ecafe.min.js', array( 'jquery' ), ECAFE_VERSION, false );
					wp_enqueue_script( 'eca-lax', ECAFE_ASSETS_PATH . 'js/admin/eca-lax.js', array( 'jquery' ), ECAFE_VERSION, true );

					$effectDesk = $effectTab = $effectMob = '';
					foreach ( $settings['laxScrollOpt'] as $index => $rule ) {
						$distanceDk = $distanceTb = $distanceMb = '';
						if ( isset( $rule['scrollDistance']['size'] ) && ! empty( $rule['scrollDistance']['size'] ) ) {
							$distanceDk = $rule['scrollDistance']['size'];
						} else {
							$distanceDk = 0;
						}
						if ( isset( $rule['scrollDistance_tablet']['size'] ) && ! empty( $rule['scrollDistance_tablet']['size'] ) ) {
							$distanceTb = $rule['scrollDistance_tablet']['size'];
						} else {
							$distanceTb = $distanceDk;
						}
						if ( isset( $rule['scrollDistance_mobile']['size'] ) && ! empty( $rule['scrollDistance_mobile']['size'] ) ) {
							$distanceMb = $rule['scrollDistance_mobile']['size'];
						} else {
							$distanceMb = $distanceTb;
						}
						$effect         = ' lax_preset_' . $rule['laxEffects'];
						$effectNameDesk = $effect . ':' . $distanceDk . ':';
						$effectNameTab  = $effect . ':' . $distanceTb . ':';
						$effectNameMob  = $effect . ':' . $distanceMb . ':';

						if ( $rule['laxEffects'] == 'fadeIn' || $rule['laxEffects'] == 'fadeOut' || $rule['laxEffects'] == 'fadeInOut' ) {
							$fadeDk      = ! empty( $rule['fadeOpt']['size'] ) ? $rule['fadeOpt']['size'] : 0;
							$fadeTb      = ! empty( $rule['fadeOpt_tablet']['size'] ) ? $rule['fadeOpt_tablet']['size'] : $fadeDk;
							$fadeMb      = ! empty( $rule['fadeOpt_mobile']['size'] ) ? $rule['fadeOpt_mobile']['size'] : $fadeTb;
							$effectDesk .= $effectNameDesk . $fadeDk;
							$effectTab  .= $effectNameTab . $fadeTb;
							$effectMob  .= $effectNameMob . $fadeMb;
						}
						if ( $rule['laxEffects'] == 'scaleIn' || $rule['laxEffects'] == 'scaleOut' || $rule['laxEffects'] == 'scaleInOut' ) {
							$scaleDk     = ! empty( $rule['scaleOpt']['size'] ) ? $rule['scaleOpt']['size'] : 0;
							$scaleTb     = ! empty( $rule['scaleOpt_tablet']['size'] ) ? $rule['scaleOpt_tablet']['size'] : $scaleDk;
							$scaleMb     = ! empty( $rule['scaleOpt_mobile']['size'] ) ? $rule['scaleOpt_mobile']['size'] : $scaleTb;
							$effectDesk .= $effectNameDesk . $scaleDk;
							$effectTab  .= $effectNameTab . $scaleTb;
							$effectMob  .= $effectNameMob . $scaleMb;
						}
						if ( $rule['laxEffects'] == 'slideX' || $rule['laxEffects'] == 'slideY' ) {
							$slideDk     = ! empty( $rule['slideOpt']['size'] ) ? $rule['slideOpt']['size'] : 0;
							$slideTb     = ! empty( $rule['slideOpt_tablet']['size'] ) ? $rule['slideOpt_tablet']['size'] : $slideDk;
							$slideMb     = ! empty( $rule['slideOpt_mobile']['size'] ) ? $rule['slideOpt_mobile']['size'] : $slideTb;
							$effectDesk .= $effectNameDesk . $slideDk;
							$effectTab  .= $effectNameTab . $slideTb;
							$effectMob  .= $effectNameMob . $slideMb;
						}
						if ( $rule['laxEffects'] == 'jiggle' ) {
							$jiggleDk    = ! empty( $rule['jiggleOpt']['size'] ) ? $rule['jiggleOpt']['size'] : 0;
							$jiggleTb    = ! empty( $rule['jiggleOpt_tablet']['size'] ) ? $rule['jiggleOpt_tablet']['size'] : $jiggleDk;
							$jiggleMb    = ! empty( $rule['jiggleOpt_mobile']['size'] ) ? $rule['jiggleOpt_mobile']['size'] : $jiggleTb;
							$effectDesk .= $effectNameDesk . $jiggleDk;
							$effectTab  .= $effectNameTab . $jiggleTb;
							$effectMob  .= $effectNameMob . $jiggleMb;
						}
						if ( $rule['laxEffects'] == 'seesaw' ) {
							$seesawDk    = ! empty( $rule['seesawOpt']['size'] ) ? $rule['seesawOpt']['size'] : 0;
							$seesawTb    = ! empty( $rule['seesawOpt_tablet']['size'] ) ? $rule['seesawOpt_tablet']['size'] : $seesawDk;
							$seesawMb    = ! empty( $rule['seesawOpt_mobile']['size'] ) ? $rule['seesawOpt_mobile']['size'] : $seesawTb;
							$effectDesk .= $effectNameDesk . $seesawDk;
							$effectTab  .= $effectNameTab . $seesawTb;
							$effectMob  .= $effectNameMob . $seesawMb;
						}
						if ( $rule['laxEffects'] == 'zigzag' ) {
							$zigzagDk    = ! empty( $rule['zigzagOpt']['size'] ) ? $rule['zigzagOpt']['size'] : 0;
							$zigzagTb    = ! empty( $rule['zigzagOpt_tablet']['size'] ) ? $rule['zigzagOpt_tablet']['size'] : $zigzagDk;
							$zigzagMb    = ! empty( $rule['zigzagOpt_mobile']['size'] ) ? $rule['zigzagOpt_mobile']['size'] : $zigzagTb;
							$effectDesk .= $effectNameDesk . $zigzagDk;
							$effectTab  .= $effectNameTab . $zigzagTb;
							$effectMob  .= $effectNameMob . $zigzagMb;
						}
						if ( $rule['laxEffects'] == 'hueRotate' || $rule['laxEffects'] == 'spin' || $rule['laxEffects'] == 'flipX' || $rule['laxEffects'] == 'flipY' ) {
							$hueRotateDk = ! empty( $rule['hueRotateOpt']['size'] ) ? $rule['hueRotateOpt']['size'] : 0;
							$hueRotateTb = ! empty( $rule['hueRotateOpt_tablet']['size'] ) ? $rule['hueRotateOpt_tablet']['size'] : $hueRotateDk;
							$hueRotateMb = ! empty( $rule['hueRotateOpt_mobile']['size'] ) ? $rule['hueRotateOpt_mobile']['size'] : $hueRotateTb;
							$effectDesk .= $effectNameDesk . $hueRotateDk;
							$effectTab  .= $effectNameTab . $hueRotateTb;
							$effectMob  .= $effectNameMob . $hueRotateMb;
						}
						if ( $rule['laxEffects'] == 'blurIn' || $rule['laxEffects'] == 'blurOut' || $rule['laxEffects'] == 'blurInOut' ) {
							$blurDk      = ! empty( $rule['blurOpt']['size'] ) ? $rule['blurOpt']['size'] : 0;
							$blurTb      = ! empty( $rule['blurOpt_tablet']['size'] ) ? $rule['blurOpt_tablet']['size'] : $blurDk;
							$blurMb      = ! empty( $rule['blurOpt_mobile']['size'] ) ? $rule['blurOpt_mobile']['size'] : $blurTb;
							$effectDesk .= $effectNameDesk . $blurDk;
							$effectTab  .= $effectNameTab . $blurTb;
							$effectMob  .= $effectNameMob . $blurMb;
						}
					}

					$element->add_render_attribute( '_wrapper', 'class', 'eca-lax lax' );
					$element->add_render_attribute( '_wrapper', 'data-lax-md', $effectDesk );
					$element->add_render_attribute( '_wrapper', 'data-lax-sm', $effectTab );
					$element->add_render_attribute( '_wrapper', 'data-lax-xs', $effectMob );
				}

				/*section link*/
				if ( ( ! empty( $settings['linkSwitch'] ) && $settings['linkSwitch'] == 'yes' ) && ! empty( $settings['secLink'] ) && ! empty( $settings['secLink']['url'] ) && in_array( 'ecafe-widget-link', $this->get_extra_list() ) ) {
					$url = "window.location.href='" . esc_url( $settings['secLink']['url'] ) . "';";
					if ( $settings['secLink']['is_external'] == 'on' ) {
						$url = "window.open('" . esc_url( $settings['secLink']['url'] ) . "',  '_blank');";
					}
					$element->add_render_attribute(
						'_wrapper',
						array(
							'onclick' => $url,
							'style'   => 'cursor: pointer',
						)
					);
				}

				if ( ! empty( $settings['glassmorphismOpt'] ) && 'yes' === $settings['glassmorphismOpt'] && in_array( 'ecafe-glassmorphism', $this->get_extra_list() ) ) {
					$glassmorphisBlurCustom = isset( $settings['glassmorphisBlur'] ) ? $settings['glassmorphisBlur']['size'] : 10;
					$glassmorphistype       = ! empty( $settings['glassmorphistype'] ) ? $settings['glassmorphistype'] : 'normal';

					$targetCSS = '';
					if ( ! empty( $settings['glassmorphisCustomClass'] ) ) {
						if ( ! empty( $glassmorphistype ) && $glassmorphistype == 'multiple' ) {
							$glassmorphisMBlur       = isset( $settings['glassmorphisMBlur'] ) ? $settings['glassmorphisMBlur']['size'] : 10;
							$glassmorphisMBrightness = isset( $settings['glassmorphisMBrightness'] ) ? $settings['glassmorphisMBrightness']['size'] : 1;
							$glassmorphisMContrast   = isset( $settings['glassmorphisMContrast'] ) ? $settings['glassmorphisMContrast']['size'] : 1;
							$glassmorphisMGrayscale  = isset( $settings['glassmorphisMGrayscale'] ) ? $settings['glassmorphisMGrayscale']['size'] : 0;
							$glassmorphisMInvert     = isset( $settings['glassmorphisMInvert'] ) ? $settings['glassmorphisMInvert']['size'] : 0;
							$glassmorphisMOpacity    = isset( $settings['glassmorphisMOpacity'] ) ? $settings['glassmorphisMOpacity']['size'] : 1;
							$glassmorphisMSepia      = isset( $settings['glassmorphisMSepia'] ) ? $settings['glassmorphisMSepia']['size'] : 0;
							$glassmorphisMSaturate   = isset( $settings['glassmorphisMSaturate'] ) ? $settings['glassmorphisMSaturate']['size'] : 1;
							$glassmorphisMHuerotate  = isset( $settings['glassmorphisMHuerotate'] ) ? $settings['glassmorphisMHuerotate']['size'] : 1;

							$targetCSS = '.elementor-element-' . $element->get_id() . ' .' . esc_attr( $settings['glassmorphisCustomClass'] ) . '{-webkit-backdrop-filter:blur(' . esc_attr( $glassmorphisMBlur ) . 'px) brightness(' . esc_attr( $glassmorphisMBrightness ) . ') contrast(' . esc_attr( $glassmorphisMContrast ) . ') grayscale(' . esc_attr( $glassmorphisMGrayscale ) . ') invert(' . esc_attr( $glassmorphisMInvert ) . ') opacity(' . esc_attr( $glassmorphisMOpacity ) . ') sepia(' . esc_attr( $glassmorphisMSepia ) . ') saturate(' . esc_attr( $glassmorphisMSaturate ) . ') hue-rotate(' . esc_attr( $glassmorphisMHuerotate ) . 'deg) !important;backdrop-filter:blur(' . esc_attr( $glassmorphisMBlur ) . 'px) brightness(' . esc_attr( $glassmorphisMBrightness ) . ') contrast(' . esc_attr( $glassmorphisMContrast ) . ') grayscale(' . esc_attr( $glassmorphisMGrayscale ) . ') invert(' . esc_attr( $glassmorphisMInvert ) . ') opacity(' . esc_attr( $glassmorphisMOpacity ) . ') sepia(' . esc_attr( $glassmorphisMSepia ) . ') saturate(' . esc_attr( $glassmorphisMSaturate ) . ') hue-rotate(' . esc_attr( $glassmorphisMHuerotate ) . 'deg) !important;}';
						} elseif ( ! empty( $glassmorphisBlurCustom ) ) {
								$targetCSS = '.elementor-element-' . $element->get_id() . ' .' . esc_attr( $settings['glassmorphisCustomClass'] ) . '{-webkit-backdrop-filter:  blur(' . $glassmorphisBlurCustom . 'px) !important;backdrop-filter:  blur(' . $glassmorphisBlurCustom . 'px) !important;}';
						}
						$targetCSSUnset = '.elementor-element-' . $element->get_id() . '.e-con,.elementor-element-' . $element->get_id() . '.e-container,.elementor-element-' . $element->get_id() . ' > .elementor-container,.elementor-element-' . $element->get_id() . ' > .elementor-widget-wrap,.elementor-element-' . $element->get_id() . '{-webkit-backdrop-filter:  unset !important;backdrop-filter:  unset !important;}';

						echo '<style>' . $targetCSS . $targetCSSUnset . '</style>';
					}
				}
			},
			10,
			1
		);
	}


	/**
	 * Add Lax Scroll
	 *
	 * @access public
	 */
	public function add_lax_controls( $element, $args ) {
		if ( in_array( 'ecafe-lax-scroll', $this->get_extra_list() ) ) {
			$element->start_controls_section(
				'ecaLaxSection',
				array(
					'label' => esc_html__( 'Lax Scroll', 'essential-classy-addons-for-elementor' ),
					'tab'   => Controls_Manager::TAB_ADVANCED,
				)
			);
			$element->add_control(
				'ecaExtraLaxScroll',
				array(
					'label'              => esc_html__( 'Lax Scroll', 'essential-classy-addons-for-elementor' ),
					'type'               => Controls_Manager::SWITCHER,
					'default'            => '',
					'label_on'           => esc_html__( 'Yes', 'essential-classy-addons-for-elementor' ),
					'label_off'          => esc_html__( 'No', 'essential-classy-addons-for-elementor' ),
					'return_value'       => 'yes',
					'frontend_available' => true,
				)
			);

			$repeater = new Repeater();

			$repeater->add_control(
				'laxEffects',
				array(
					'type'        => Controls_Manager::SELECT,
					'default'     => 'fadeIn',
					'label_block' => true,
					'groups'      => array(
						'fadeIn'     => __( 'FadeIn', 'essential-classy-addons-for-elementor' ),
						'fadeOut'    => __( 'FadeOut', 'essential-classy-addons-for-elementor' ),
						'fadeInOut'  => __( 'FadeInOut', 'essential-classy-addons-for-elementor' ),
						'scaleIn'    => __( 'ScaleIn', 'essential-classy-addons-for-elementor' ),
						'scaleOut'   => __( 'ScaleOut', 'essential-classy-addons-for-elementor' ),
						'scaleInOut' => __( 'ScaleInOut', 'essential-classy-addons-for-elementor' ),
						'slideX'     => __( 'SlideX', 'essential-classy-addons-for-elementor' ),
						'slideY'     => __( 'SlideY', 'essential-classy-addons-for-elementor' ),
						'jiggle'     => __( 'Jiggle', 'essential-classy-addons-for-elementor' ),
						'seesaw'     => __( 'SeeSaw', 'essential-classy-addons-for-elementor' ),
						'zigzag'     => __( 'ZigZag', 'essential-classy-addons-for-elementor' ),
						'hueRotate'  => __( 'Hue Rotate', 'essential-classy-addons-for-elementor' ),
						'spin'       => __( 'Spin', 'essential-classy-addons-for-elementor' ),
						'flipX'      => __( 'FlipX', 'essential-classy-addons-for-elementor' ),
						'flipY'      => __( 'FlipY', 'essential-classy-addons-for-elementor' ),
						'blurIn'     => __( 'blurIn', 'essential-classy-addons-for-elementor' ),
						'blurOut'    => __( 'blurOut', 'essential-classy-addons-for-elementor' ),
						'blurInOut'  => __( 'blurInOut', 'essential-classy-addons-for-elementor' ),
					),
				)
			);
			$repeater->add_responsive_control(
				'fadeOpt',
				array(
					'type'       => Controls_Manager::SLIDER,
					'label'      => esc_html__( 'Opacity', 'essential-classy-addons-for-elementor' ),
					'size_units' => array( 'px' ),
					'range'      => array(
						'px' => array(
							'min'  => 0,
							'max'  => 1,
							'step' => 0.01,
						),
					),
					'default'    => array(
						'unit' => 'px',
						'size' => 0.6,
					),
					'condition'  => array(
						'laxEffects' => array( 'fadeIn', 'fadeOut', 'fadeInOut' ),
					),
				)
			);
			$repeater->add_responsive_control(
				'scaleOpt',
				array(
					'type'       => Controls_Manager::SLIDER,
					'label'      => esc_html__( 'Scale', 'essential-classy-addons-for-elementor' ),
					'size_units' => array( 'px' ),
					'range'      => array(
						'px' => array(
							'min'  => 0,
							'max'  => 50,
							'step' => 0.02,
						),
					),
					'default'    => array(
						'unit' => 'px',
						'size' => 0.8,
					),
					'condition'  => array(
						'laxEffects' => array( 'scaleIn', 'scaleOut', 'scaleInOut' ),
					),
				)
			);
			$repeater->add_responsive_control(
				'slideOpt',
				array(
					'type'       => Controls_Manager::SLIDER,
					'label'      => esc_html__( 'Amount', 'essential-classy-addons-for-elementor' ),
					'size_units' => array( 'px' ),
					'range'      => array(
						'px' => array(
							'min'  => -2000,
							'max'  => 2000,
							'step' => 50,
						),
					),
					'default'    => array(
						'unit' => 'px',
						'size' => 100,
					),
					'condition'  => array(
						'laxEffects' => array( 'slideX', 'slideY' ),
					),
				)
			);
			$repeater->add_responsive_control(
				'jiggleOpt',
				array(
					'type'       => Controls_Manager::SLIDER,
					'label'      => esc_html__( 'Stength', 'essential-classy-addons-for-elementor' ),
					'size_units' => array( 'px' ),
					'range'      => array(
						'px' => array(
							'min'  => 10,
							'max'  => 200,
							'step' => 2,
						),
					),
					'default'    => array(
						'unit' => 'px',
						'size' => 40,
					),
					'condition'  => array(
						'laxEffects' => array( 'jiggle' ),
					),
				)
			);
			$repeater->add_responsive_control(
				'seesawOpt',
				array(
					'type'       => Controls_Manager::SLIDER,
					'label'      => esc_html__( 'Stength', 'essential-classy-addons-for-elementor' ),
					'size_units' => array( 'px' ),
					'range'      => array(
						'px' => array(
							'min'  => 0,
							'max'  => 150,
							'step' => 1,
						),
					),
					'default'    => array(
						'unit' => 'px',
						'size' => 40,
					),
					'condition'  => array(
						'laxEffects' => array( 'seesaw' ),
					),
				)
			);
			$repeater->add_responsive_control(
				'zigzagOpt',
				array(
					'type'       => Controls_Manager::SLIDER,
					'label'      => esc_html__( 'Stength', 'essential-classy-addons-for-elementor' ),
					'size_units' => array( 'px' ),
					'range'      => array(
						'px' => array(
							'min'  => 0,
							'max'  => 1000,
							'step' => 5,
						),
					),
					'default'    => array(
						'unit' => 'px',
						'size' => 40,
					),
					'condition'  => array(
						'laxEffects' => array( 'zigzag' ),
					),
				)
			);
			$repeater->add_responsive_control(
				'hueRotateOpt',
				array(
					'type'       => Controls_Manager::SLIDER,
					'label'      => esc_html__( 'Stength', 'essential-classy-addons-for-elementor' ),
					'size_units' => array( 'px' ),
					'range'      => array(
						'px' => array(
							'min'  => 1,
							'max'  => 360,
							'step' => 1,
						),
					),
					'default'    => array(
						'unit' => 'px',
						'size' => 40,
					),
					'condition'  => array(
						'laxEffects' => array( 'hueRotate', 'spin', 'flipX', 'flipY' ),
					),
				)
			);
			$repeater->add_responsive_control(
				'blurOpt',
				array(
					'type'       => Controls_Manager::SLIDER,
					'label'      => esc_html__( 'Stength', 'essential-classy-addons-for-elementor' ),
					'size_units' => array( 'px' ),
					'range'      => array(
						'px' => array(
							'min'  => 0,
							'max'  => 50,
							'step' => 1,
						),
					),
					'default'    => array(
						'unit' => 'px',
						'size' => 5,
					),
					'condition'  => array(
						'laxEffects' => array( 'blurIn', 'blurOut', 'blurInOut' ),
					),
				)
			);
			$repeater->add_responsive_control(
				'scrollDistance',
				array(
					'type'       => Controls_Manager::SLIDER,
					'label'      => esc_html__( 'Distance', 'essential-classy-addons-for-elementor' ),
					'size_units' => array( 'px' ),
					'range'      => array(
						'px' => array(
							'min'  => 0,
							'max'  => 2000,
							'step' => 10,
						),
					),
					'default'    => array(
						'unit' => 'px',
						'size' => 200,
					),
				)
			);
			$element->add_control(
				'laxScrollOpt',
				array(
					'label'       => esc_html__( 'Rules', 'essential-classy-addons-for-elementor' ),
					'type'        => Controls_Manager::REPEATER,
					'default'     => array(
						array(
							'laxEffects' => '',
						),
					),
					'condition'   => array(
						'ecaExtraLaxScroll' => 'yes',
					),
					'fields'      => $repeater->get_controls(),
					'title_field' => '{{laxEffects}}',
				)
			);
			$element->end_controls_section();
		}
	}

	/**
	 * Add Link
	 *
	 * @access public
	 */
	public function add_link_controls( $element, $args ) {
		if ( in_array( 'ecafe-widget-link', $this->get_extra_list() ) ) {
			$element->start_controls_section(
				'ecaLinkSection',
				array(
					'label' => esc_html__( 'EC Link', 'essential-classy-addons-for-elementor' ),
					'tab'   => Controls_Manager::TAB_ADVANCED,
				)
			);
			$element->add_control(
				'linkSwitch',
				array(
					'label'        => esc_html__( 'Link', 'essential-classy-addons-for-elementor' ),
					'type'         => Controls_Manager::SWITCHER,
					'return_value' => 'yes',
					'default'      => 'no',
					'separator'    => 'before',
				)
			);
			$element->add_control(
				'secLink',
				array(
					'label'       => esc_html__( 'Link', 'essential-classy-addons-for-elementor' ),
					'type'        => Controls_Manager::URL,
					'dynamic'     => array(
						'active' => true,
					),
					'placeholder' => esc_html__( 'https://www.link.com', 'essential-classy-addons-for-elementor' ),
					'condition'   => array(
						'linkSwitch' => 'yes',
					),
				)
			);
			$element->end_controls_section();
		}
	}

	/**
	 * Glassmorphism
	 *
	 * @access public
	 */
	public function ec_glassmorphism_controls( $element, $args ) {
		if ( in_array( 'ecafe-glassmorphism', $this->get_extra_list() ) ) {
			$element->start_controls_section(
				'ecaGlassmorphismSection',
				array(
					'label' => esc_html__( 'EC Glassmorphism', 'essential-classy-addons-for-elementor' ),
					'tab'   => Controls_Manager::TAB_ADVANCED,
				)
			);
			$element->add_control(
				'glassmorphismOpt',
				array(
					'label'     => esc_html__( 'Glass Morphism', 'essential-classy-addons-for-elementor' ),
					'type'      => Controls_Manager::SWITCHER,
					'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
					'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
					'default'   => 'no',
				)
			);
			$element->add_control(
				'glassmorphisCustomClass',
				array(
					'label'       => esc_html__( 'Custom Class', 'essential-classy-addons-for-elementor' ),
					'type'        => Controls_Manager::TEXT,
					'label_block' => true,
					'description' => __( 'Enter Class', 'essential-classy-addons-for-elementor' ),
					'condition'   => array(
						'glassmorphismOpt' => 'yes',
					),
				)
			);
			$element->add_control(
				'glassmorphisCustomClassNote',
				array(
					'label'           => esc_html__( 'Note', 'essential-classy-addons-for-elementor' ),
					'type'            => Controls_Manager::RAW_HTML,
					'raw'             => esc_html__( 'Custom Class effect visible on front end.', 'essential-classy-addons-for-elementor' ),
					'content_classes' => 'ec-description-note',
					'condition'       => array(
						'glassmorphisCustomClass!' => '',
					),
				)
			);
			$element->add_control(
				'glassmorphistype',
				array(
					'label'       => esc_html__( 'Type', 'essential-classy-addons-for-elementor' ),
					'type'        => Controls_Manager::SELECT,
					'default'     => 'normal',
					'label_block' => true,
					'options'     => array(
						'normal'   => esc_html__( 'Normal', 'essential-classy-addons-for-elementor' ),
						'multiple' => esc_html__( 'Multiple', 'essential-classy-addons-for-elementor' ),
					),
					'condition'   => array(
						'glassmorphismOpt' => 'yes',
					),
				)
			);
			$element->add_control(
				'glassmorphisBlur',
				array(
					'label'      => esc_html__( 'Blur', 'essential-classy-addons-for-elementor' ),
					'type'       => Controls_Manager::SLIDER,
					'size_units' => array( 'px' ),
					'range'      => array(
						'px' => array(
							'max'  => 100,
							'min'  => 1,
							'step' => 1,
						),
					),
					'default'    => array(
						'unit' => 'px',
						'size' => 10,
					),
					'selectors'  => array(
						'{{WRAPPER}}.e-con,{{WRAPPER}}.e-container,{{WRAPPER}} > .elementor-container,{{WRAPPER}} > .elementor-widget-wrap,{{WRAPPER}}' => '-webkit-backdrop-filter:  blur({{glassmorphisBlur.SIZE}}{{glassmorphisBlur.UNIT}});backdrop-filter:  blur({{glassmorphisBlur.SIZE}}{{glassmorphisBlur.UNIT}});',
					),
					'condition'  => array(
						'glassmorphismOpt' => 'yes',
						'glassmorphistype' => 'normal',
					),
				)
			);
			// multiple
			$element->add_control(
				'glassmorphisMBlur',
				array(
					'label'      => esc_html__( 'Blur', 'essential-classy-addons-for-elementor' ),
					'type'       => Controls_Manager::SLIDER,
					'size_units' => array( 'px' ),
					'range'      => array(
						'px' => array(
							'max'  => 20,
							'min'  => 0,
							'step' => 0.1,
						),
					),
					'default'    => array(
						'size' => 10,
					),
					'selectors'  => array(
						'{{WRAPPER}}.e-con,{{WRAPPER}}.e-container,{{WRAPPER}} > .elementor-container,{{WRAPPER}} > .elementor-widget-wrap,{{WRAPPER}}' => '-webkit-backdrop-filter:blur({{SIZE}}px) brightness({{glassmorphisMBrightness.SIZE}}) contrast({{glassmorphisMContrast.SIZE}}) grayscale({{glassmorphisMGrayscale.SIZE}}) invert({{glassmorphisMInvert.SIZE}}) opacity({{glassmorphisMOpacity.SIZE}}) sepia({{glassmorphisMSepia.SIZE}}) saturate({{glassmorphisMSaturate.SIZE}}) hue-rotate({{glassmorphisMHuerotate.SIZE}}deg);backdrop-filter:blur({{SIZE}}px) brightness({{glassmorphisMBrightness.SIZE}}) contrast({{glassmorphisMContrast.SIZE}}) grayscale({{glassmorphisMGrayscale.SIZE}}) invert({{glassmorphisMInvert.SIZE}}) opacity({{glassmorphisMOpacity.SIZE}}) sepia({{glassmorphisMSepia.SIZE}}) saturate({{glassmorphisMSaturate.SIZE}}) hue-rotate({{glassmorphisMHuerotate.SIZE}}deg);',
					),
					'condition'  => array(
						'glassmorphismOpt' => 'yes',
						'glassmorphistype' => 'multiple',
					),
				)
			);
			$element->add_control(
				'glassmorphisMBrightness',
				array(
					'label'      => esc_html__( 'Brightness', 'essential-classy-addons-for-elementor' ),
					'type'       => Controls_Manager::SLIDER,
					'size_units' => array( 'px' ),
					'range'      => array(
						'px' => array(
							'max'  => 200,
							'min'  => 0,
							'step' => 10,
						),
					),
					'default'    => array(
						'size' => 1,
					),
					'selectors'  => array(
						'{{WRAPPER}}.e-con,{{WRAPPER}}.e-container,{{WRAPPER}} > .elementor-container,{{WRAPPER}} > .elementor-widget-wrap,{{WRAPPER}}' => '-webkit-backdrop-filter:blur({{glassmorphisMBlur.SIZE}}px) brightness({{SIZE}}) contrast({{glassmorphisMContrast.SIZE}}) grayscale({{glassmorphisMGrayscale.SIZE}}) invert({{glassmorphisMInvert.SIZE}}) opacity({{glassmorphisMOpacity.SIZE}}) sepia({{glassmorphisMSepia.SIZE}}) saturate({{glassmorphisMSaturate.SIZE}}) hue-rotate({{glassmorphisMHuerotate.SIZE}}deg);backdrop-filter:blur({{glassmorphisMBlur.SIZE}}px) brightness({{SIZE}}) contrast({{glassmorphisMContrast.SIZE}}) grayscale({{glassmorphisMGrayscale.SIZE}}) invert({{glassmorphisMInvert.SIZE}}) opacity({{glassmorphisMOpacity.SIZE}}) sepia({{glassmorphisMSepia.SIZE}}) saturate({{glassmorphisMSaturate.SIZE}}) hue-rotate({{glassmorphisMHuerotate.SIZE}}deg);',
					),
					'condition'  => array(
						'glassmorphismOpt' => 'yes',
						'glassmorphistype' => 'multiple',
					),
				)
			);
			$element->add_control(
				'glassmorphisMContrast',
				array(
					'label'      => esc_html__( 'Contrast', 'essential-classy-addons-for-elementor' ),
					'type'       => Controls_Manager::SLIDER,
					'size_units' => array( 'px' ),
					'range'      => array(
						'px' => array(
							'max'  => 3,
							'min'  => 0,
							'step' => 0.1,
						),
					),
					'default'    => array(
						'size' => 1,
					),
					'selectors'  => array(
						'{{WRAPPER}}.e-con,{{WRAPPER}}.e-container,{{WRAPPER}} > .elementor-container,{{WRAPPER}} > .elementor-widget-wrap,{{WRAPPER}}' => '-webkit-backdrop-filter:blur({{glassmorphisMBlur.SIZE}}px) brightness({{glassmorphisMBrightness.SIZE}}) contrast({{SIZE}}) grayscale({{glassmorphisMGrayscale.SIZE}}) invert({{glassmorphisMInvert.SIZE}}) opacity({{glassmorphisMOpacity.SIZE}}) sepia({{glassmorphisMSepia.SIZE}}) saturate({{glassmorphisMSaturate.SIZE}}) hue-rotate({{glassmorphisMHuerotate.SIZE}}deg);backdrop-filter:blur({{glassmorphisMBlur.SIZE}}px) brightness({{glassmorphisMBrightness.SIZE}}) contrast({{SIZE}}) grayscale({{glassmorphisMGrayscale.SIZE}}) invert({{glassmorphisMInvert.SIZE}}) opacity({{glassmorphisMOpacity.SIZE}}) sepia({{glassmorphisMSepia.SIZE}}) saturate({{glassmorphisMSaturate.SIZE}}) hue-rotate({{glassmorphisMHuerotate.SIZE}}deg);',
					),
					'condition'  => array(
						'glassmorphismOpt' => 'yes',
						'glassmorphistype' => 'multiple',
					),
				)
			);
			$element->add_control(
				'glassmorphisMGrayscale',
				array(
					'label'      => esc_html__( 'Grayscale', 'essential-classy-addons-for-elementor' ),
					'type'       => Controls_Manager::SLIDER,
					'size_units' => array( 'px' ),
					'range'      => array(
						'px' => array(
							'max'  => 1,
							'min'  => 0,
							'step' => 0.1,
						),
					),
					'default'    => array(
						'size' => 0,
					),
					'selectors'  => array(
						'{{WRAPPER}}.e-con,{{WRAPPER}}.e-container,{{WRAPPER}} > .elementor-container,{{WRAPPER}} > .elementor-widget-wrap,{{WRAPPER}}' => '-webkit-backdrop-filter:blur({{glassmorphisMBlur.SIZE}}px) brightness({{glassmorphisMBrightness.SIZE}}) contrast({{glassmorphisMContrast.SIZE}}) grayscale({{SIZE}}) invert({{glassmorphisMInvert.SIZE}}) opacity({{glassmorphisMOpacity.SIZE}}) sepia({{glassmorphisMSepia.SIZE}}) saturate({{glassmorphisMSaturate.SIZE}}) hue-rotate({{glassmorphisMHuerotate.SIZE}}deg);backdrop-filter:blur({{glassmorphisMBlur.SIZE}}px) brightness({{glassmorphisMBrightness.SIZE}}) contrast({{glassmorphisMContrast.SIZE}}) grayscale({{SIZE}}) invert({{glassmorphisMInvert.SIZE}}) opacity({{glassmorphisMOpacity.SIZE}}) sepia({{glassmorphisMSepia.SIZE}}) saturate({{glassmorphisMSaturate.SIZE}}) hue-rotate({{glassmorphisMHuerotate.SIZE}}deg);',
					),
					'condition'  => array(
						'glassmorphismOpt' => 'yes',
						'glassmorphistype' => 'multiple',
					),
				)
			);
			$element->add_control(
				'glassmorphisMInvert',
				array(
					'label'      => esc_html__( 'Invert', 'essential-classy-addons-for-elementor' ),
					'type'       => Controls_Manager::SLIDER,
					'size_units' => array( 'px' ),
					'range'      => array(
						'px' => array(
							'max'  => 1,
							'min'  => 0,
							'step' => 0.1,
						),
					),
					'default'    => array(
						'size' => 0,
					),
					'selectors'  => array(
						'{{WRAPPER}}.e-con,{{WRAPPER}}.e-container,{{WRAPPER}} > .elementor-container,{{WRAPPER}} > .elementor-widget-wrap,{{WRAPPER}}' => '-webkit-backdrop-filter:blur({{glassmorphisMBlur.SIZE}}px) brightness({{glassmorphisMBrightness.SIZE}}) contrast({{glassmorphisMContrast.SIZE}}) grayscale({{glassmorphisMGrayscale.SIZE}}) invert({{SIZE}}) opacity({{glassmorphisMOpacity.SIZE}}) sepia({{glassmorphisMSepia.SIZE}}) saturate({{glassmorphisMSaturate.SIZE}}) hue-rotate({{glassmorphisMHuerotate.SIZE}}deg);backdrop-filter:blur({{glassmorphisMBlur.SIZE}}px) brightness({{glassmorphisMBrightness.SIZE}}) contrast({{glassmorphisMContrast.SIZE}}) grayscale({{glassmorphisMGrayscale.SIZE}}) invert({{SIZE}}) opacity({{glassmorphisMOpacity.SIZE}}) sepia({{glassmorphisMSepia.SIZE}}) saturate({{glassmorphisMSaturate.SIZE}}) hue-rotate({{glassmorphisMHuerotate.SIZE}}deg);',
					),
					'condition'  => array(
						'glassmorphismOpt' => 'yes',
						'glassmorphistype' => 'multiple',
					),
				)
			);
			$element->add_control(
				'glassmorphisMOpacity',
				array(
					'label'      => esc_html__( 'Opacity', 'essential-classy-addons-for-elementor' ),
					'type'       => Controls_Manager::SLIDER,
					'size_units' => array( 'px' ),
					'range'      => array(
						'px' => array(
							'max'  => 1,
							'min'  => 0,
							'step' => 0.1,
						),
					),
					'default'    => array(
						'size' => 1,
					),
					'selectors'  => array(
						'{{WRAPPER}}.e-con,{{WRAPPER}}.e-container,{{WRAPPER}} > .elementor-container,{{WRAPPER}} > .elementor-widget-wrap,{{WRAPPER}}' => '-webkit-backdrop-filter:blur({{glassmorphisMBlur.SIZE}}px) brightness({{glassmorphisMBrightness.SIZE}}) contrast({{glassmorphisMContrast.SIZE}}) grayscale({{glassmorphisMGrayscale.SIZE}}) invert({{glassmorphisMInvert.SIZE}}) opacity({{SIZE}}) sepia({{glassmorphisMSepia.SIZE}}) saturate({{glassmorphisMSaturate.SIZE}}) hue-rotate({{glassmorphisMHuerotate.SIZE}}deg);backdrop-filter:blur({{glassmorphisMBlur.SIZE}}px) brightness({{glassmorphisMBrightness.SIZE}}) contrast({{glassmorphisMContrast.SIZE}}) grayscale({{glassmorphisMGrayscale.SIZE}}) invert({{glassmorphisMInvert.SIZE}}) opacity({{SIZE}}) sepia({{glassmorphisMSepia.SIZE}}) saturate({{glassmorphisMSaturate.SIZE}}) hue-rotate({{glassmorphisMHuerotate.SIZE}}deg);',
					),
					'condition'  => array(
						'glassmorphismOpt' => 'yes',
						'glassmorphistype' => 'multiple',
					),
				)
			);
			$element->add_control(
				'glassmorphisMSepia',
				array(
					'label'      => esc_html__( 'Sepia', 'essential-classy-addons-for-elementor' ),
					'type'       => Controls_Manager::SLIDER,
					'size_units' => array( 'px' ),
					'range'      => array(
						'px' => array(
							'max'  => 1,
							'min'  => 0,
							'step' => 0.1,
						),
					),
					'default'    => array(
						'size' => 0,
					),
					'selectors'  => array(
						'{{WRAPPER}}.e-con,{{WRAPPER}}.e-container,{{WRAPPER}} > .elementor-container,{{WRAPPER}} > .elementor-widget-wrap,{{WRAPPER}}' => '-webkit-backdrop-filter:blur({{glassmorphisMBlur.SIZE}}px) brightness({{glassmorphisMBrightness.SIZE}}) contrast({{glassmorphisMContrast.SIZE}}) grayscale({{glassmorphisMGrayscale.SIZE}}) invert({{glassmorphisMInvert.SIZE}}) opacity({{glassmorphisMOpacity.SIZE}}) sepia({{SIZE}}) saturate({{glassmorphisMSaturate.SIZE}}) hue-rotate({{glassmorphisMHuerotate.SIZE}}deg);backdrop-filter:blur({{glassmorphisMBlur.SIZE}}px) brightness({{glassmorphisMBrightness.SIZE}}) contrast({{glassmorphisMContrast.SIZE}}) grayscale({{glassmorphisMGrayscale.SIZE}}) invert({{glassmorphisMInvert.SIZE}}) opacity({{glassmorphisMOpacity.SIZE}}) sepia({{SIZE}}) saturate({{glassmorphisMSaturate.SIZE}}) hue-rotate({{glassmorphisMHuerotate.SIZE}}deg);',
					),
					'condition'  => array(
						'glassmorphismOpt' => 'yes',
						'glassmorphistype' => 'multiple',
					),
				)
			);
			$element->add_control(
				'glassmorphisMSaturate',
				array(
					'label'      => esc_html__( 'Saturate', 'essential-classy-addons-for-elementor' ),
					'type'       => Controls_Manager::SLIDER,
					'size_units' => array( 'px' ),
					'range'      => array(
						'px' => array(
							'max'  => 10,
							'min'  => 0,
							'step' => 0.1,
						),
					),
					'default'    => array(
						'size' => 1,
					),
					'selectors'  => array(
						'{{WRAPPER}}.e-con,{{WRAPPER}}.e-container,{{WRAPPER}} > .elementor-container,{{WRAPPER}} > .elementor-widget-wrap,{{WRAPPER}}' => '-webkit-backdrop-filter:blur({{glassmorphisMBlur.SIZE}}px) brightness({{glassmorphisMBrightness.SIZE}}) contrast({{glassmorphisMContrast.SIZE}}) grayscale({{glassmorphisMGrayscale.SIZE}}) invert({{glassmorphisMInvert.SIZE}}) opacity({{glassmorphisMOpacity.SIZE}}) sepia({{glassmorphisMSepia.SIZE}}) saturate({{SIZE}}) hue-rotate({{glassmorphisMHuerotate.SIZE}}deg);backdrop-filter:blur({{glassmorphisMBlur.SIZE}}px) brightness({{glassmorphisMBrightness.SIZE}}) contrast({{glassmorphisMContrast.SIZE}}) grayscale({{glassmorphisMGrayscale.SIZE}}) invert({{glassmorphisMInvert.SIZE}}) opacity({{glassmorphisMOpacity.SIZE}}) sepia({{glassmorphisMSepia.SIZE}}) saturate({{SIZE}}) hue-rotate({{glassmorphisMHuerotate.SIZE}}deg);',
					),
					'condition'  => array(
						'glassmorphismOpt' => 'yes',
						'glassmorphistype' => 'multiple',
					),
				)
			);
			$element->add_control(
				'glassmorphisMHuerotate',
				array(
					'label'      => esc_html__( 'Hue Rotate', 'essential-classy-addons-for-elementor' ),
					'type'       => Controls_Manager::SLIDER,
					'size_units' => array( 'px' ),
					'range'      => array(
						'px' => array(
							'max' => 360,
							'min' => 0,
						),
					),
					'default'    => array(
						'size' => 0,
					),
					'selectors'  => array(
						'{{WRAPPER}}.e-con,{{WRAPPER}}.e-container,{{WRAPPER}} > .elementor-container,{{WRAPPER}} > .elementor-widget-wrap,{{WRAPPER}}' => '-webkit-backdrop-filter:blur({{glassmorphisMBlur.SIZE}}px) brightness({{glassmorphisMBrightness.SIZE}}) contrast({{glassmorphisMContrast.SIZE}}) grayscale({{glassmorphisMGrayscale.SIZE}}) invert({{glassmorphisMInvert.SIZE}}) opacity({{glassmorphisMOpacity.SIZE}}) sepia({{glassmorphisMSepia.SIZE}}) saturate({{glassmorphisMSaturate.SIZE}}) hue-rotate({{SIZE}}deg);backdrop-filter:blur({{glassmorphisMBlur.SIZE}}px) brightness({{glassmorphisMBrightness.SIZE}}) contrast({{glassmorphisMContrast.SIZE}}) grayscale({{glassmorphisMGrayscale.SIZE}}) invert({{glassmorphisMInvert.SIZE}}) opacity({{glassmorphisMOpacity.SIZE}}) sepia({{glassmorphisMSepia.SIZE}}) saturate({{glassmorphisMSaturate.SIZE}}) hue-rotate({{SIZE}}deg);',
					),
					'condition'  => array(
						'glassmorphismOpt' => 'yes',
						'glassmorphistype' => 'multiple',
					),
				)
			);
			$element->end_controls_section();
		}
	}
}
