<?php
namespace EcafeAddons\Widgets;

use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;

use EcafeAddons\EcafeElementLoad;

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

class Ecafe_GradientUnderlineText extends Widget_Base {

	public function get_name() {
		return 'ecafe-gradient-underline-text';
	}

	public function get_title() {
		return esc_html__( 'Gradient Underline Text', 'essential-classy-addons-for-elementor' );
	}

	public function get_icon() {
		return 'ecafe-ele-back-icon ecafe-gradient-underline-text-icon';
	}

	public function get_categories() {
		return array( 'essential' );
	}

	public function get_keywords() {
		return array( 'Gradient Underline Text' );
	}

	public function get_custom_help_url() {
		return 'https://store.kapasias.com/helpdesk/';
	}

	public function has_widget_inner_wrapper(): bool {
		return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
	}

	protected function register_controls() {

		$this->start_controls_section(
			'content_section',
			array(
				'label' => esc_html__( 'Content', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);
		$this->add_control(
			'gutTag',
			array(
				'label'   => esc_html__( 'Tag', 'essential-classy-addons-for-elementor' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'h1',
				'options' => \EcafeHelper::getHtmlTag( 'a' ),
			)
		);
		$this->add_control(
			'gutLink',
			array(
				'label'       => esc_html__( 'Link', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::URL,
				'dynamic'     => array( 'active' => true ),
				'placeholder' => esc_html__( '#', 'essential-classy-addons-for-elementor' ),
				'default'     => array(
					'url' => '#',
				),
				'condition'   => array(
					'gutTag' => 'a',
				),
			)
		);
		$this->add_responsive_control(
			'contentAlign',
			array(
				'label'       => esc_html__( 'Alignment', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::CHOOSE,
				'options'     => array(
					'left'   => array(
						'title' => esc_html__( 'Left', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-left',
					),
					'center' => array(
						'title' => esc_html__( 'Center', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-center',
					),
					'right'  => array(
						'title' => esc_html__( 'Right', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-right',
					),
				),
				'selectors'   => array(
					'{{WRAPPER}} .ec-gradient-underline-text-wrapper' => 'text-align: {{VALUE}};',
				),
				'label_block' => false,
			)
		);

		$repeater = new \Elementor\Repeater();
		$repeater->add_control(
			'gutType',
			array(
				'label'   => esc_html__( 'Type', 'essential-classy-addons-for-elementor' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'normal',
				'options' => array(
					'normal'    => esc_html__( 'Normal', 'essential-classy-addons-for-elementor' ),
					'highlight' => esc_html__( 'Highlight', 'essential-classy-addons-for-elementor' ),
				),
			)
		);
		$repeater->add_control(
			'gutEffectType',
			array(
				'label'     => esc_html__( 'Effect', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'effect1',
				'options'   => array(
					'effect1'  => esc_html__( 'Effect 1', 'essential-classy-addons-for-elementor' ),
					'effect2'  => esc_html__( 'Effect 2', 'essential-classy-addons-for-elementor' ),
					'effect3'  => esc_html__( 'Effect 3', 'essential-classy-addons-for-elementor' ),
					'effect4'  => esc_html__( 'Effect 4', 'essential-classy-addons-for-elementor' ),
					'effect5'  => esc_html__( 'Effect 5', 'essential-classy-addons-for-elementor' ),
					'effect6'  => esc_html__( 'Effect 6', 'essential-classy-addons-for-elementor' ),
					'effect7'  => esc_html__( 'Effect 7', 'essential-classy-addons-for-elementor' ),
					'effect8'  => esc_html__( 'Effect 8', 'essential-classy-addons-for-elementor' ),
					'effect9'  => esc_html__( 'Effect 9', 'essential-classy-addons-for-elementor' ),
					'effect10' => esc_html__( 'Effect 10', 'essential-classy-addons-for-elementor' ),
					'effect11' => esc_html__( 'Effect 11', 'essential-classy-addons-for-elementor' ),
					'effect12' => esc_html__( 'Effect 12', 'essential-classy-addons-for-elementor' ),
					'effect13' => esc_html__( 'Effect 13', 'essential-classy-addons-for-elementor' ),
					'effect14' => esc_html__( 'Effect 14', 'essential-classy-addons-for-elementor' ),
					'effect15' => esc_html__( 'Effect 15', 'essential-classy-addons-for-elementor' ),
					'effect16' => esc_html__( 'Effect 16', 'essential-classy-addons-for-elementor' ),
					'effect17' => esc_html__( 'Effect 17', 'essential-classy-addons-for-elementor' ),
					'effect18' => esc_html__( 'Effect 18', 'essential-classy-addons-for-elementor' ),
					'effect19' => esc_html__( 'Effect 19', 'essential-classy-addons-for-elementor' ),
					'effect20' => esc_html__( 'Effect 20', 'essential-classy-addons-for-elementor' ),
				),
				'condition' => array(
					'gutType' => 'highlight',
				),
			)
		);
		$repeater->add_control(
			'gutText',
			array(
				'label'       => esc_html__( 'Text', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXTAREA,
				'default'     => esc_html__( 'Gradient Underline Text', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Enter Text', 'essential-classy-addons-for-elementor' ),
				'dynamic'     => array( 'active' => true ),
			)
		);
		$repeater->add_control(
			'gutTextLink',
			array(
				'label'       => esc_html__( 'Link', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::URL,
				'dynamic'     => array( 'active' => true ),
				'placeholder' => esc_html__( 'Enter URL', 'essential-classy-addons-for-elementor' ),
			)
		);
		$repeater->add_control(
			'gutStyling',
			array(
				'label'     => esc_html__( 'Styling', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
			)
		);
		$repeater->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'gutTypo',
				'selector' => '{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}',
			)
		);
		$repeater->add_responsive_control(
			'gut128Start',
			array(
				'label'      => esc_html__( 'Starting Visibility', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 100,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-size: {{SIZE}}% 100%;',
				),
				'condition'  => array(
					'gutType'       => 'highlight',
					'gutEffectType' => array( 'effect1', 'effect2', 'effect8' ),
				),
			)
		);
		$repeater->add_responsive_control(
			'gut34679_14Start',
			array(
				'label'      => esc_html__( 'Starting Visibility', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 100,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-size: 100% {{SIZE}}%;',
				),
				'condition'  => array(
					'gutType'       => 'highlight',
					'gutEffectType' => array( 'effect3', 'effect4', 'effect6', 'effect7', 'effect9', 'effect10', 'effect11', 'effect12', 'effect13', 'effect14' ),
				),
			)
		);
		$repeater->add_responsive_control(
			'gut5CenterStart',
			array(
				'label'      => esc_html__( 'Center Starting Visibility', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 100,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-size: {{SIZE}}% {{SIZE}}%;',
				),
				'condition'  => array(
					'gutType'       => 'highlight',
					'gutEffectType' => 'effect5',
				),
			)
		);
		$repeater->add_responsive_control(
			'gut15_20Start',
			array(
				'label'      => esc_html__( 'Starting Visibility', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 100,
					),
				),
				'default'    => array(
					'unit' => '%',
					'size' => 10,
				),
				'selectors'  => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-size:{{SIZE}}% {{gut15_20Height.SIZE}}px;',
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}:hover' => 'background-size:100% {{gut15_20Height.SIZE}}px !important;',
				),
				'condition'  => array(
					'gutType'       => 'highlight',
					'gutEffectType' => array( 'effect15', 'effect16', 'effect17', 'effect18', 'effect19', 'effect20' ),
				),
			)
		);
		$repeater->add_responsive_control(
			'gut15_20Height',
			array(
				'label'      => esc_html__( 'Height', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 100,
					),
				),
				'default'    => array(
					'unit' => '%',
					'size' => 5,
				),
				'selectors'  => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-size:{{gut15_20Start.SIZE}}% {{SIZE}}px;',
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}:hover' => 'background-size:100% {{SIZE}}px !important;',
				),
				'condition'  => array(
					'gutType'       => 'highlight',
					'gutEffectType' => array( 'effect15', 'effect16', 'effect17', 'effect18', 'effect19', 'effect20' ),
				),
			)
		);
		$repeater->start_controls_tabs( 'tabsGutStyle' );
		$repeater->start_controls_tab(
			'tabGutN',
			array(
				'label' => esc_html__( 'Normal', 'essential-classy-addons-for-elementor' ),
			)
		);
		$repeater->add_control(
			'gutColor',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'color: {{VALUE}};',
				),
			)
		);
		$repeater->add_control(
			'gut1267Deg',
			array(
				'label'     => esc_html__( 'Deg (0 - 360)', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::NUMBER,
				'min'       => 0,
				'max'       => 360,
				'step'      => 1,
				'default'   => 120,
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-image: linear-gradient({{VALUE}}deg,{{gut1267Color1.VALUE}},{{gut1267Color2.VALUE}});',
				),
				'condition' => array(
					'gutType'       => 'highlight',
					'gutEffectType' => array( 'effect1', 'effect2', 'effect6', 'effect7' ),
				),
			)
		);
		$repeater->add_control(
			'gut1267Color1',
			array(
				'label'     => esc_html__( 'Color 1', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#deff1380',
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-image:linear-gradient({{gut1267Deg.VALUE}}deg,{{VALUE}},{{gut1267Color2.VALUE}})',
				),
				'condition' => array(
					'gutType'       => 'highlight',
					'gutEffectType' => array( 'effect1', 'effect2', 'effect6', 'effect7' ),
				),
			)
		);
		$repeater->add_control(
			'gut1267Color2',
			array(
				'label'     => esc_html__( 'Color 2', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#e130e480',
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-image:linear-gradient({{gut1267Deg.VALUE}}deg,{{gut1267Color1.VALUE}},{{VALUE}});',
				),
				'condition' => array(
					'gutType'       => 'highlight',
					'gutEffectType' => array( 'effect1', 'effect2', 'effect6', 'effect7' ),
				),
			)
		);
		$repeater->add_control(
			'gut3Color1',
			array(
				'label'     => esc_html__( 'Color 1', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#deff1380',
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-image:linear-gradient(to top,{{VALUE}},{{gut3Color2.VALUE}})',
				),
				'condition' => array(
					'gutType'       => 'highlight',
					'gutEffectType' => 'effect3',
				),
			)
		);
		$repeater->add_control(
			'gut3Color2',
			array(
				'label'     => esc_html__( 'Color 2', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#e130e480',
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-image:linear-gradient(to top,{{gut3Color1.VALUE}},{{VALUE}})',
				),
				'condition' => array(
					'gutType'       => 'highlight',
					'gutEffectType' => 'effect3',
				),
			)
		);
		$repeater->add_control(
			'gut4Color1',
			array(
				'label'     => esc_html__( 'Color 1', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#deff1380',
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-image:linear-gradient(to bottom,{{VALUE}},{{gut4Color2.VALUE}})',
				),
				'condition' => array(
					'gutType'       => 'highlight',
					'gutEffectType' => 'effect4',
				),
			)
		);
		$repeater->add_control(
			'gut4Color2',
			array(
				'label'     => esc_html__( 'Color 2', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#e130e480',
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-image:linear-gradient(to bottom,{{gut4Color1.VALUE}},{{VALUE}})',
				),
				'condition' => array(
					'gutType'       => 'highlight',
					'gutEffectType' => 'effect4',
				),
			)
		);
		$repeater->add_control(
			'gut5Color1',
			array(
				'label'     => esc_html__( 'Color 1', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#deff1380',
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-image:radial-gradient(circle,{{VALUE}} 0%,{{gut5Color2.VALUE}} 100%)',
				),
				'condition' => array(
					'gutType'       => 'highlight',
					'gutEffectType' => 'effect5',
				),
			)
		);
		$repeater->add_control(
			'gut5Color2',
			array(
				'label'     => esc_html__( 'Color 2', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#e130e480',
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-image:radial-gradient(circle,{{gut5Color1.VALUE}} 0%,{{VALUE}} 100%)',
				),
				'condition' => array(
					'gutType'       => 'highlight',
					'gutEffectType' => 'effect5',
				),
			)
		);
		$repeater->add_control(
			'gut8Deg',
			array(
				'label'     => esc_html__( 'Deg (0 - 360)', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::NUMBER,
				'min'       => 0,
				'max'       => 360,
				'step'      => 1,
				'default'   => 135,
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-image: linear-gradient({{VALUE}}deg,{{gut8Color1.VALUE}},{{gut8Color2.VALUE}},{{gut8Color1.VALUE}},{{gut8Color2.VALUE}});',
				),
				'condition' => array(
					'gutType'       => 'highlight',
					'gutEffectType' => 'effect8',
				),
			)
		);
		$repeater->add_control(
			'gut8Color1',
			array(
				'label'     => esc_html__( 'Color 1', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#deff1380',
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-image:linear-gradient({{gut8Deg.VALUE}}deg,{{VALUE}},{{gut8Color2.VALUE}},{{VALUE}},{{gut8Color2.VALUE}})',
				),
				'condition' => array(
					'gutType'       => 'highlight',
					'gutEffectType' => 'effect8',
				),
			)
		);
		$repeater->add_control(
			'gut8Color2',
			array(
				'label'     => esc_html__( 'Color 2', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#e130e480',
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-image:linear-gradient({{gut8Deg.VALUE}}deg,{{gut8Color1.VALUE}},{{VALUE}},{{gut8Color1.VALUE}},{{VALUE}});',
				),
				'condition' => array(
					'gutType'       => 'highlight',
					'gutEffectType' => 'effect8',
				),
			)
		);
		$repeater->add_control(
			'gut9Color1',
			array(
				'label'     => esc_html__( 'Color 1', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#deff1380',
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-image:linear-gradient(to top,{{VALUE}} 5px,{{gut9Color2.VALUE}} 5px)',
				),
				'condition' => array(
					'gutType'       => 'highlight',
					'gutEffectType' => 'effect9',
				),
			)
		);
		$repeater->add_control(
			'gut9Color2',
			array(
				'label'     => esc_html__( 'Color 2', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#e130e480',
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-image:linear-gradient(to top,{{gut9Color1.VALUE}} 5px,{{VALUE}} 5px)',
				),
				'condition' => array(
					'gutType'       => 'highlight',
					'gutEffectType' => 'effect9',
				),
			)
		);
		$repeater->add_control(
			'gut10Color1',
			array(
				'label'     => esc_html__( 'Color 1', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#deff1380',
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-image:linear-gradient(to bottom,{{VALUE}} 5px,{{gut10Color2.VALUE}} 5px)',
				),
				'condition' => array(
					'gutType'       => 'highlight',
					'gutEffectType' => 'effect10',
				),
			)
		);
		$repeater->add_control(
			'gut10Color2',
			array(
				'label'     => esc_html__( 'Color 2', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#e130e480',
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-image:linear-gradient(to bottom,{{gut10Color1.VALUE}} 5px,{{VALUE}} 5px)',
				),
				'condition' => array(
					'gutType'       => 'highlight',
					'gutEffectType' => 'effect10',
				),
			)
		);
		$repeater->add_control(
			'gut11Color1',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#deff1380',
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-image:linear-gradient(to right,{{VALUE}} 100%,transparent 0)',
				),
				'condition' => array(
					'gutType'       => 'highlight',
					'gutEffectType' => 'effect11',
				),
			)
		);
		$repeater->add_control(
			'gut12Color1',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#deff1380',
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-image:linear-gradient(to left,{{VALUE}} 100%,transparent 0)',
				),
				'condition' => array(
					'gutType'       => 'highlight',
					'gutEffectType' => 'effect12',
				),
			)
		);
		$repeater->add_control(
			'gut1314Color1',
			array(
				'label'     => esc_html__( 'Color 1', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#deff1380',
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-image:linear-gradient(to top,{{VALUE}},{{gut1314Color2.VALUE}})',
				),
				'condition' => array(
					'gutType'       => 'highlight',
					'gutEffectType' => array( 'effect13', 'effect14' ),
				),
			)
		);
		$repeater->add_control(
			'gut1314Color2',
			array(
				'label'     => esc_html__( 'Color 2', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#e130e480',
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-image:linear-gradient(to top,{{gut1314Color1.VALUE}},{{VALUE}})',
				),
				'condition' => array(
					'gutType'       => 'highlight',
					'gutEffectType' => array( 'effect13', 'effect14' ),
				),
			)
		);
		$repeater->add_control(
			'gut15161819Color1',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#deff1380',
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-image:linear-gradient(to right,{{VALUE}} 100%,transparent 0)',
				),
				'condition' => array(
					'gutType'       => 'highlight',
					'gutEffectType' => array( 'effect15', 'effect16', 'effect18', 'effect19' ),
				),
			)
		);
		$repeater->add_control(
			'gut1720Color1',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#deff1380',
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}' => 'background-image:linear-gradient(to left,{{VALUE}} 100%,transparent 0)',
				),
				'condition' => array(
					'gutType'       => 'highlight',
					'gutEffectType' => array( 'effect17', 'effect20' ),
				),
			)
		);
		$repeater->end_controls_tab();
		$repeater->start_controls_tab(
			'tabGutH',
			array(
				'label' => esc_html__( 'Hover', 'essential-classy-addons-for-elementor' ),
			)
		);
		$repeater->add_control(
			'gutColorH',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner{{CURRENT_ITEM}}:hover' => 'color: {{VALUE}};',
				),
			)
		);
		$repeater->end_controls_tab();
		$repeater->end_controls_tabs();
		$this->add_control(
			'gutContents',
			array(
				'label'       => 'Contents',
				'type'        => Controls_Manager::REPEATER,
				'fields'      => $repeater->get_controls(),
				'default'     => array(
					array(
						'gutType' => 'normal',
						'gutText' => esc_html__( 'I am item content.&nbsp;', 'essential-classy-addons-for-elementor' ),
					),
					array(
						'gutType' => 'highlight',
						'gutText' => esc_html__( 'Gradient Underline Text', 'essential-classy-addons-for-elementor' ),
					),
					array(
						'gutType' => 'normal',
						'gutText' => esc_html__( '&nbsp;Click edit button to change this text.', 'essential-classy-addons-for-elementor' ),
					),
				),
				'title_field' => '{{ gutType }} - {{{ gutText }}}',
			)
		);
		$this->end_controls_section();

		/*Notice panel*/
		$ecwidgetdemolink = esc_url( 'https://ecaddons.com/elements/gradient-underline-text/' );
		$ecwidgetdoclink  = esc_url( 'https://ecaddons.com/docs/gradient-underline-text-widget-tutorial/' );
		include ECAFE_PATH . 'element/widgets/ecafe-widgetpanel-help.php';

		$this->start_controls_section(
			'generalStyling',
			array(
				'label' => esc_html__( 'General', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);
		$this->add_responsive_control(
			'generalPadding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-gradient-underline-text-wrapper' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'generalMargin',
			array(
				'label'      => esc_html__( 'Margin', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-gradient-underline-text-wrapper' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'generalTypo',
				'selector' => '{{WRAPPER}} .ec-gut-inner,{{WRAPPER}} .ec-gradient-underline-text-wrapper',
			)
		);
		$this->start_controls_tabs( 'tabsGeneralStyle' );
		$this->start_controls_tab(
			'tabGeneralN',
			array(
				'label' => esc_html__( 'Normal', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'generalColor',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner,{{WRAPPER}} .ec-gradient-underline-text-wrapper' => 'color: {{VALUE}};',
				),
			)
		);
		$this->end_controls_tab();
		$this->start_controls_tab(
			'tabGeneralH',
			array(
				'label' => esc_html__( 'Hover', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'generalColorH',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-gut-inner:hover' => 'color: {{VALUE}};',
				),
			)
		);
		$this->end_controls_tab();
		$this->end_controls_tabs();
		$this->end_controls_section();
	}

	protected function render() {

		$settings = $this->get_settings_for_display();
		$output   = '';
		$gutTag   = ! empty( $settings['gutTag'] ) ? $settings['gutTag'] : 'h1';
		if ( $gutTag == 'a' && ! empty( $settings['gutLink']['url'] ) ) {
			$this->add_link_attributes( 'gutLink', $settings['gutLink'] );
			$this->add_render_attribute( 'gutLink', 'class', 'ec-gradient-underline-text-wrapper' );

			$output .= '<' . \EcafeHelper::check_and_validate_html_tag( $gutTag ) . ' ' . $this->get_render_attribute_string( 'gutLink' ) . '>';
		} else {
			$output .= '<' . \EcafeHelper::check_and_validate_html_tag( $gutTag ) . ' class="ec-gradient-underline-text-wrapper">';
		}

		foreach ( $settings['gutContents'] as $index => $item ) {
			if ( ! empty( $item['gutText'] ) ) {
				if ( ! empty( $item['gutTextLink']['url'] ) ) {
					if ( ! empty( $item['gutType'] ) && $item['gutType'] == 'highlight' && ! empty( $item['gutEffectType'] ) ) {
						$output .= '<a href="' . esc_url( $item['gutTextLink']['url'] ) . '" class="ec-gut-inner ec-gut-highlight ec-gut-' . esc_attr( $item['gutEffectType'] ) . ' elementor-repeater-item-' . esc_attr( $item['_id'] ) . '">' . esc_attr( $item['gutText'] ) . '</a>';
					} else {
						$output .= '<a href="' . esc_url( $item['gutTextLink']['url'] ) . '" class="ec-gut-inner elementor-repeater-item-' . esc_attr( $item['_id'] ) . '">' . esc_attr( $item['gutText'] ) . '</a>';
					}
				} elseif ( ! empty( $item['gutType'] ) && $item['gutType'] == 'highlight' && ! empty( $item['gutEffectType'] ) ) {
						$output .= '<span class="ec-gut-inner ec-gut-highlight ec-gut-' . esc_attr( $item['gutEffectType'] ) . ' elementor-repeater-item-' . esc_attr( $item['_id'] ) . '">' . esc_attr( $item['gutText'] ) . '</span>';
				} else {
					$output .= '<span class="ec-gut-inner elementor-repeater-item-' . esc_attr( $item['_id'] ) . '">' . esc_attr( $item['gutText'] ) . '</span>';
				}
			}

			++$index;
		}

		$output .= '</' . \EcafeHelper::check_and_validate_html_tag( $gutTag ) . '>';

		echo wp_kses_normalize_entities( $output );
	}
}
