<?php
namespace EcafeAddons\Widgets;

use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Utils;
use Elementor\Group_Control_Typography;
use Elementor\Core\Schemes\Typography;
use Elementor\Scheme_Color;
use Elementor\Group_Control_Background;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Text_Shadow;

use EcafeAddons\EcafeElementLoad;

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

class Ecafe_Marketing_Link extends Widget_Base {

	public function get_name() {
		return 'ecafe-marketing-link';
	}

	public function get_title() {
		return esc_html__( 'Marketing Link', 'essential-classy-addons-for-elementor' );
	}

	public function get_icon() {
		return 'ecafe-ele-back-icon ecafe-button-icon';
	}

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


	public function get_keywords() {
		return array( 'marketing link', 'affiliate', 'button', 'creative button', 'cool button', 'advanced button', 'link', 'marketing', 'promo link', 'promo bridge' );
	}

	public function get_script_depends() {
		return array( 'ecafe-marketing-link' );
	}
	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(
			'contentSection',
			array(
				'label' => esc_html__( 'Marketing Link', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);
		$this->add_control(
			'mlStyle',
			array(
				'label'   => esc_html__( 'Style', 'essential-classy-addons-for-elementor' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'style1',
				'options' => array(
					'style1' => esc_html__( 'Style 1', 'essential-classy-addons-for-elementor' ),
					'style2' => esc_html__( 'Style 2', 'essential-classy-addons-for-elementor' ),
					'style3' => esc_html__( 'Style 3', 'essential-classy-addons-for-elementor' ),
					'style4' => esc_html__( 'Style 4', 'essential-classy-addons-for-elementor' ),
					'style5' => esc_html__( 'Style 5', 'essential-classy-addons-for-elementor' ),
					'style6' => esc_html__( 'Style 6', 'essential-classy-addons-for-elementor' ),
				),
			)
		);
		$this->add_control(
			'mLMainText',
			array(
				'label'       => esc_html__( 'Label', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => array( 'active' => true ),
				'default'     => esc_html__( 'Label', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Enter Label', 'essential-classy-addons-for-elementor' ),
				'selectors'   => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper.style6 .ec-marketing-link::before,
					{{WRAPPER}} .ec-marketing-link-wrapper.style6 .ec-marketing-link::after' => 'content: "{{VALUE}}";',
				),
			)
		);
		$this->add_control(
			'mLLinkLabel',
			array(
				'label'       => esc_html__( 'Link Label', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => array( 'active' => true ),
				'default'     => esc_html__( 'wordpress', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Enter Label', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'mLMainLink',
			array(
				'label'         => esc_html__( 'URL', 'essential-classy-addons-for-elementor' ),
				'type'          => Controls_Manager::URL,
				'placeholder'   => esc_html__( 'https://your-link.com', 'essential-classy-addons-for-elementor' ),
				'show_external' => true,
				'default'       => array( 'url' => 'http://elementor.com/' ),
				'dynamic'       => array( 'active' => true ),
			)
		);
		$this->add_control(
			'mLMainIcon',
			array(
				'label'   => esc_html__( 'Icon', 'essential-classy-addons-for-elementor' ),
				'type'    => Controls_Manager::ICONS,
				'default' => array(
					'value'   => 'fab fa-microblog',
					'library' => 'brands',
				),
			)
		);
		$this->add_control(
			'mlType',
			array(
				'label'   => esc_html__( 'Type', 'essential-classy-addons-for-elementor' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'default',
				'options' => array(
					'default' => esc_html__( 'Default', 'essential-classy-addons-for-elementor' ),
					'mbp'     => esc_html__( 'Multiple Browser Popup', 'essential-classy-addons-for-elementor' ),
				),
			)
		);
		$this->add_control(
			'mlTypeD',
			array(
				'label'         => esc_html__( 'URL', 'essential-classy-addons-for-elementor' ),
				'type'          => Controls_Manager::URL,
				'placeholder'   => esc_html__( 'https://your-link.com', 'essential-classy-addons-for-elementor' ),
				'show_external' => true,
				'default'       => array( 'url' => 'http://elementor.com/' ),
				'dynamic'       => array( 'active' => true ),
				'condition'     => array(
					'mlType' => 'default',
				),
			)
		);
		$repeater = new \Elementor\Repeater();
		$repeater->add_control(
			'mLLinkLabel',
			array(
				'label'       => esc_html__( 'Label', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => array( 'active' => true ),
				'default'     => esc_html__( 'Label', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Enter Label', 'essential-classy-addons-for-elementor' ),
			)
		);
		$repeater->add_control(
			'mLLink',
			array(
				'label'         => esc_html__( 'Link', 'essential-classy-addons-for-elementor' ),
				'type'          => Controls_Manager::URL,
				'placeholder'   => esc_html__( 'https://your-link.com', 'essential-classy-addons-for-elementor' ),
				'show_external' => true,
				'default'       => array( 'url' => '#' ),
				'dynamic'       => array( 'active' => true ),
			)
		);
		$this->add_control(
			'mLLinkList',
			array(
				'label'       => esc_html__( 'List', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::REPEATER,
				'fields'      => $repeater->get_controls(),
				'default'     => array(
					array(
						'mLLinkLabel' => 'Wordpress',
					),
					array(
						'mLLinkLabel' => 'Google',
					),
					array(
						'mLLinkLabel' => 'Wordpress Plugins',
					),
				),
				'condition'   => array(
					'mlType' => 'mbp',
				),
				'title_field' => '{{{ mLLinkLabel }}}',
			)
		);
		$this->end_controls_section();

		/*Tilt Effect Options*/
		include ECAFE_PATH . 'element/widgets/ecafe-tilt-options.php';

		/*Tippy Tooltip Options*/
		include ECAFE_PATH . 'element/widgets/ecafe-tippy-options.php';

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

		/*style start*/
		$this->start_controls_section(
			'mlStyling',
			array(
				'label'     => esc_html__( 'Marketing Link', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'mlStyle' => 'style1',
				),
			)
		);
		$this->add_responsive_control(
			'mlPadding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'mlAlign',
			array(
				'label'     => esc_html__( 'Alignment', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::CHOOSE,
				'options'   => array(
					'flex-start' => 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',
					),
					'flex-end'   => array(
						'title' => esc_html__( 'Right', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-right',
					),
				),
				'separator' => 'before',
				'selectors' => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper' => 'justify-content:{{VALUE}};',
				),
			)
		);
		$this->add_responsive_control(
			'mlIconSize',
			array(
				'label'      => esc_html__( 'Icon Size', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 500,
					),
					'%'  => array(
						'min'  => 1,
						'max'  => 100,
						'step' => 1,
					),
				),
				'default'    => array(
					'unit' => 'px',
					'size' => 20,
				),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link i'   => 'font-size:{{SIZE}}{{UNIT}};',
					'{{WRAPPER}} .ec-marketing-link svg' => 'width:{{SIZE}}{{UNIT}};height:{{SIZE}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'mlIconSpace',
			array(
				'label'      => esc_html__( 'Icon Space', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 500,
					),
					'%'  => array(
						'min'  => 1,
						'max'  => 100,
						'step' => 1,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link i,{{WRAPPER}} .ec-marketing-link svg' => 'margin-right:{{SIZE}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'mlTextTypography',
				'selector' => '{{WRAPPER}} .ec-marketing-link',
			)
		);
		$this->start_controls_tabs( 'tabsMltyle' );
		$this->start_controls_tab(
			'tabMlNorm',
			array(
				'label' => esc_html__( 'Normal', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'mlColorNorm',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-marketing-link'     => 'color: {{VALUE}};',
					'{{WRAPPER}} .ec-marketing-link svg' => 'fill: {{VALUE}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'     => 'mlBgNorm',
				'types'    => array( 'classic', 'gradient' ),
				'selector' => '{{WRAPPER}} .ec-marketing-link',
			)
		);
		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'mlBorderNorm',
				'label'    => esc_html__( 'Border', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .ec-marketing-link',
			)
		);
		$this->add_responsive_control(
			'mlBrNorm',
			array(
				'label'      => esc_html__( 'Border Radius', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'mlShadowNorm',
				'selector' => '{{WRAPPER}} .ec-marketing-link',
			)
		);
		$this->add_group_control(
			Group_Control_Text_Shadow::get_type(),
			array(
				'name'     => 'mlTextShadowN',
				'label'    => esc_html__( 'Text Shadow', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .ec-marketing-link',
			)
		);
		$this->add_control(
			'mlTransition',
			array(
				'label'       => esc_html__( 'Transition css', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'placeholder' => esc_html__( 'all .3s linear', 'essential-classy-addons-for-elementor' ),
				'selectors'   => array(
					'{{WRAPPER}} .ec-marketing-link' => 'transition:{{VALUE}};',
				),
			)
		);
		$this->add_control(
			'mlTransform',
			array(
				'label'       => esc_html__( 'Transform css', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'placeholder' => esc_html__( 'skew(-20deg)', 'essential-classy-addons-for-elementor' ),
				'selectors'   => array(
					'{{WRAPPER}} .ec-marketing-link' => 'transform: {{VALUE}};-ms-transform: {{VALUE}};-moz-transform: {{VALUE}};-webkit-transform: {{VALUE}};',
				),
			)
		);
		$this->end_controls_tab();
		$this->start_controls_tab(
			'tabMlHover',
			array(
				'label' => esc_html__( 'Hover', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'mlColorHover',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-marketing-link:hover' => 'color: {{VALUE}};',
					'{{WRAPPER}} .ec-marketing-link:hover svg' => 'fill: {{VALUE}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'     => 'mlBgHover',
				'types'    => array( 'classic', 'gradient' ),
				'selector' => '{{WRAPPER}} .ec-marketing-link:hover',
			)
		);
		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'mlBorderHover',
				'label'    => esc_html__( 'Border', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .ec-marketing-link:hover',
			)
		);
		$this->add_responsive_control(
			'mlBrHover',
			array(
				'label'      => esc_html__( 'Border Radius', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'mlShadowHover',
				'selector' => '{{WRAPPER}} .ec-marketing-link:hover',
			)
		);
		$this->add_group_control(
			Group_Control_Text_Shadow::get_type(),
			array(
				'name'     => 'mlTextShadowH',
				'label'    => esc_html__( 'Text Shadow', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .ec-marketing-link:hover',
			)
		);
		$this->add_control(
			'mlTransitionH',
			array(
				'label'       => esc_html__( 'Transition css', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'placeholder' => esc_html__( 'all .3s linear', 'essential-classy-addons-for-elementor' ),
				'selectors'   => array(
					'{{WRAPPER}} .ec-marketing-link:hover' => 'transition:{{VALUE}};',
				),
			)
		);
		$this->add_control(
			'mlTransformH',
			array(
				'label'       => esc_html__( 'Transform css', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'placeholder' => esc_html__( 'skew(-20deg)', 'essential-classy-addons-for-elementor' ),
				'selectors'   => array(
					'{{WRAPPER}} .ec-marketing-link:hover' => 'transform: {{VALUE}};-ms-transform: {{VALUE}};-moz-transform: {{VALUE}};-webkit-transform: {{VALUE}};',
				),
			)
		);
		$this->end_controls_tab();
		$this->end_controls_tabs();
		$this->end_controls_section();

		$this->start_controls_section(
			'ml2Styling',
			array(
				'label'     => esc_html__( 'Marketing Link', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'mlStyle' => 'style2',
				),
			)
		);
		$this->add_responsive_control(
			'ml2Padding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper .ec-marketing-link span' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'ml2Align',
			array(
				'label'     => esc_html__( 'Alignment', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::CHOOSE,
				'options'   => array(
					'flex-start' => 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',
					),
					'flex-end'   => array(
						'title' => esc_html__( 'Right', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-right',
					),
				),
				'separator' => 'before',
				'selectors' => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper' => 'justify-content:{{VALUE}};',
				),
			)
		);
		$this->add_responsive_control(
			'ml2IconSize',
			array(
				'label'      => esc_html__( 'Icon Size', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 500,
					),
					'%'  => array(
						'min'  => 1,
						'max'  => 100,
						'step' => 1,
					),
				),
				'default'    => array(
					'unit' => 'px',
					'size' => 20,
				),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link i'   => 'font-size:{{SIZE}}{{UNIT}};',
					'{{WRAPPER}} .ec-marketing-link svg' => 'width:{{SIZE}}{{UNIT}};height:{{SIZE}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'ml2IconSpace',
			array(
				'label'      => esc_html__( 'Icon Space', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 500,
					),
					'%'  => array(
						'min'  => 1,
						'max'  => 100,
						'step' => 1,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link i,{{WRAPPER}} .ec-marketing-link svg' => 'margin-right:{{SIZE}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'ml2TextTypography',
				'selector' => '{{WRAPPER}} .ec-marketing-link',
			)
		);
		$this->add_control(
			'ml2Color1',
			array(
				'label'     => esc_html__( 'Color 1', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper.style2 .ec-marketing-link' => 'color: {{VALUE}};',
					'{{WRAPPER}} .ec-marketing-link-wrapper.style2 .ec-marketing-link svg' => 'fill: {{VALUE}};',
				),
			)
		);
		$this->add_control(
			'ml2Color2',
			array(
				'label'     => esc_html__( 'Color 2', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper.style2 .ec-marketing-link,
					{{WRAPPER}} .ec-marketing-link-wrapper.style2 .ec-marketing-link:before,
					{{WRAPPER}} .ec-marketing-link-wrapper.style2 .ec-marketing-link:after,
					{{WRAPPER}} .ec-marketing-link-wrapper.style2 .ec-marketing-link span:before,
					{{WRAPPER}} .ec-marketing-link-wrapper.style2 .ec-marketing-link span:after' => 'background: {{VALUE}};',
					'{{WRAPPER}} .ec-marketing-link-wrapper.style2 .ec-marketing-link:hover,
					{{WRAPPER}} .ec-marketing-link-wrapper.style2 .ec-marketing-link span:hover' => 'color: {{VALUE}};',
					'{{WRAPPER}} .ec-marketing-link-wrapper.style2 .ec-marketing-link span:hover svg' => 'fill: {{VALUE}};',
				),
			)
		);
		$this->end_controls_section();

		$this->start_controls_section(
			'ml3Styling',
			array(
				'label'     => esc_html__( 'Marketing Link', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'mlStyle' => 'style3',
				),
			)
		);
		$this->add_responsive_control(
			'ml3Padding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper .ec-marketing-link span' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'ml3Align',
			array(
				'label'     => esc_html__( 'Alignment', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::CHOOSE,
				'options'   => array(
					'flex-start' => 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',
					),
					'flex-end'   => array(
						'title' => esc_html__( 'Right', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-right',
					),
				),
				'separator' => 'before',
				'selectors' => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper' => 'justify-content:{{VALUE}};',
				),
			)
		);
		$this->add_responsive_control(
			'ml3IconSize',
			array(
				'label'      => esc_html__( 'Icon Size', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 500,
					),
					'%'  => array(
						'min'  => 1,
						'max'  => 100,
						'step' => 1,
					),
				),
				'default'    => array(
					'unit' => 'px',
					'size' => 20,
				),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link i'   => 'font-size:{{SIZE}}{{UNIT}};',
					'{{WRAPPER}} .ec-marketing-link svg' => 'width:{{SIZE}}{{UNIT}};height:{{SIZE}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'ml3IconSpace',
			array(
				'label'      => esc_html__( 'Icon Space', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 500,
					),
					'%'  => array(
						'min'  => 1,
						'max'  => 100,
						'step' => 1,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link i,{{WRAPPER}} .ec-marketing-link svg' => 'margin-right:{{SIZE}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'ml3TextTypography',
				'selector' => '{{WRAPPER}} .ec-marketing-link',
			)
		);
		$this->add_control(
			'ml3Color1',
			array(
				'label'     => esc_html__( 'Color 1', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper.style3 .ec-marketing-link' => 'color: {{VALUE}};',
					'{{WRAPPER}} .ec-marketing-link-wrapper.style3 .ec-marketing-link svg' => 'fill: {{VALUE}};',
				),
			)
		);
		$this->add_control(
			'ml3Color2',
			array(
				'label'     => esc_html__( 'Color 2', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper.style3 .ec-marketing-link,
					{{WRAPPER}} .ec-marketing-link-wrapper.style3 .ec-marketing-link:before,
					{{WRAPPER}} .ec-marketing-link-wrapper.style3 .ec-marketing-link:after' => 'background: {{VALUE}};',
					'{{WRAPPER}} .ec-marketing-link-wrapper.style3 .ec-marketing-link:hover' => 'color: {{VALUE}};',
					'{{WRAPPER}} .ec-marketing-link-wrapper.style3 .ec-marketing-link:hover svg' => 'fill: {{VALUE}};',
				),
			)
		);
		$this->end_controls_section();

		$this->start_controls_section(
			'ml4Styling',
			array(
				'label'     => esc_html__( 'Marketing Link', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'mlStyle' => 'style4',
				),
			)
		);
		$this->add_responsive_control(
			'ml4Padding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper .ec-marketing-link span' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'ml4Align',
			array(
				'label'     => esc_html__( 'Alignment', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::CHOOSE,
				'options'   => array(
					'flex-start' => 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',
					),
					'flex-end'   => array(
						'title' => esc_html__( 'Right', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-right',
					),
				),
				'separator' => 'before',
				'selectors' => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper' => 'justify-content:{{VALUE}};',
				),
			)
		);
		$this->add_responsive_control(
			'ml4IconSize',
			array(
				'label'      => esc_html__( 'Icon Size', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 500,
					),
					'%'  => array(
						'min'  => 1,
						'max'  => 100,
						'step' => 1,
					),
				),
				'default'    => array(
					'unit' => 'px',
					'size' => 20,
				),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link i'   => 'font-size:{{SIZE}}{{UNIT}};',
					'{{WRAPPER}} .ec-marketing-link svg' => 'width:{{SIZE}}{{UNIT}};height:{{SIZE}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'ml4IconSpace',
			array(
				'label'      => esc_html__( 'Icon Space', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 500,
					),
					'%'  => array(
						'min'  => 1,
						'max'  => 100,
						'step' => 1,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link i,{{WRAPPER}} .ec-marketing-link svg' => 'margin-right:{{SIZE}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'ml4TextTypography',
				'selector' => '{{WRAPPER}} .ec-marketing-link',
			)
		);
		$this->add_control(
			'ml4Color1',
			array(
				'label'     => esc_html__( 'Color 1', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper.style4 .ec-marketing-link' => 'color: {{VALUE}};',
					'{{WRAPPER}} .ec-marketing-link-wrapper.style4 .ec-marketing-link svg' => 'fill: {{VALUE}};',
				),
			)
		);
		$this->add_control(
			'ml4Color2',
			array(
				'label'     => esc_html__( 'Color 2', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper.style4 .ec-marketing-link' => 'background: {{VALUE}};',
					'{{WRAPPER}} .ec-marketing-link-wrapper.style4 .ec-marketing-link:hover' => 'color: {{VALUE}};',
					'{{WRAPPER}} .ec-marketing-link-wrapper.style4 .ec-marketing-link:hover svg' => 'fill: {{VALUE}};',
					'{{WRAPPER}} .ec-marketing-link-wrapper.style4 .ec-marketing-link span:before,
					{{WRAPPER}} .ec-marketing-link-wrapper.style4 .ec-marketing-link span:after,
					{{WRAPPER}} .ec-marketing-link-wrapper.style4 .ec-marketing-link:hover:before,
					{{WRAPPER}} .ec-marketing-link-wrapper.style4 .ec-marketing-link:hover:after' => 'box-shadow: 0 0 20px 0px {{VALUE}}, 0 0 5px 0px {{VALUE}}, 0 0 20px 0px {{VALUE}}, 0 0 5px 0px {{VALUE}};',
				),
			)
		);
		$this->end_controls_section();

		$this->start_controls_section(
			'ml5Styling',
			array(
				'label'     => esc_html__( 'Marketing Link', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'mlStyle' => 'style5',
				),
			)
		);
		$this->add_responsive_control(
			'ml5Padding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper .ec-marketing-link span' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'ml5Align',
			array(
				'label'     => esc_html__( 'Alignment', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::CHOOSE,
				'options'   => array(
					'flex-start' => 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',
					),
					'flex-end'   => array(
						'title' => esc_html__( 'Right', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-right',
					),
				),
				'separator' => 'before',
				'selectors' => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper' => 'justify-content:{{VALUE}};',
				),
			)
		);
		$this->add_responsive_control(
			'ml5IconSize',
			array(
				'label'      => esc_html__( 'Icon Size', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 500,
					),
					'%'  => array(
						'min'  => 1,
						'max'  => 100,
						'step' => 1,
					),
				),
				'default'    => array(
					'unit' => 'px',
					'size' => 20,
				),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link i'   => 'font-size:{{SIZE}}{{UNIT}};',
					'{{WRAPPER}} .ec-marketing-link svg' => 'width:{{SIZE}}{{UNIT}};height:{{SIZE}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'ml5IconSpace',
			array(
				'label'      => esc_html__( 'Icon Space', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 500,
					),
					'%'  => array(
						'min'  => 1,
						'max'  => 100,
						'step' => 1,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link i,{{WRAPPER}} .ec-marketing-link svg' => 'margin-right:{{SIZE}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'ml5TextTypography',
				'selector' => '{{WRAPPER}} .ec-marketing-link',
			)
		);
		$this->add_control(
			'ml5Color1',
			array(
				'label'     => esc_html__( 'Color 1', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper.style5 .ec-marketing-link:hover' => 'color: {{VALUE}};',
					'{{WRAPPER}} .ec-marketing-link-wrapper.style5 .ec-marketing-link:hover svg' => 'fill: {{VALUE}};',
				),
			)
		);
		$this->add_control(
			'ml5Color2',
			array(
				'label'     => esc_html__( 'Color 2', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper.style5 .ec-marketing-link' => 'color: {{VALUE}};',
					'{{WRAPPER}} .ec-marketing-link-wrapper.style5 .ec-marketing-link svg' => 'fill: {{VALUE}};',
					'{{WRAPPER}} .ec-marketing-link-wrapper.style5 .ec-marketing-link::before,
					{{WRAPPER}} .ec-marketing-link-wrapper.style5 .ec-marketing-link:hover::before' => 'background:{{VALUE}};',
					'{{WRAPPER}} .ec-marketing-link-wrapper.style5 .ec-marketing-link,
					{{WRAPPER}} .ec-marketing-link-wrapper.style5 .ec-marketing-link:hover' => 'border-color:{{VALUE}};',
				),
			)
		);
		$this->add_responsive_control(
			'ml5BrNorm',
			array(
				'label'      => esc_html__( 'Border Radius', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->end_controls_section();

		$this->start_controls_section(
			'ml6Styling',
			array(
				'label'     => esc_html__( 'Marketing Link', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'mlStyle' => 'style6',
				),
			)
		);
		$this->add_responsive_control(
			'ml6Padding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper .ec-marketing-link span' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'ml6Align',
			array(
				'label'     => esc_html__( 'Alignment', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::CHOOSE,
				'options'   => array(
					'flex-start' => 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',
					),
					'flex-end'   => array(
						'title' => esc_html__( 'Right', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-right',
					),
				),
				'separator' => 'before',
				'selectors' => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper' => 'justify-content:{{VALUE}};',
				),
			)
		);
		$this->add_responsive_control(
			'ml6IconSize',
			array(
				'label'      => esc_html__( 'Icon Size', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 500,
					),
					'%'  => array(
						'min'  => 1,
						'max'  => 100,
						'step' => 1,
					),
				),
				'default'    => array(
					'unit' => 'px',
					'size' => 20,
				),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link i'   => 'font-size:{{SIZE}}{{UNIT}};',
					'{{WRAPPER}} .ec-marketing-link svg' => 'width:{{SIZE}}{{UNIT}};height:{{SIZE}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'ml6IconSpace',
			array(
				'label'      => esc_html__( 'Icon Space', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 500,
					),
					'%'  => array(
						'min'  => 1,
						'max'  => 100,
						'step' => 1,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link i,{{WRAPPER}} .ec-marketing-link svg' => 'margin-right:{{SIZE}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'ml6TextTypography',
				'selector' => '{{WRAPPER}} .ec-marketing-link',
			)
		);
		$this->add_responsive_control(
			'ml6TxtAdj',
			array(
				'label'      => esc_html__( 'Text Adjust', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 250,
					),
					'%'  => array(
						'min'  => 1,
						'max'  => 100,
						'step' => 1,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper.style6 .ec-marketing-link::before' => 'padding-top:{{SIZE}}{{UNIT}};',
				),
			)
		);
		$this->add_control(
			'ml6Color1',
			array(
				'label'     => esc_html__( 'Color 1', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper.style6 .ec-marketing-link::before,
					{{WRAPPER}} .ec-marketing-link-wrapper.style6 .ec-marketing-link::after' => 'color: {{VALUE}};',
				),
			)
		);
		$this->add_control(
			'ml6Color2',
			array(
				'label'     => esc_html__( 'Color 2', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-marketing-link-wrapper.style6 .ec-marketing-link' => 'color: {{VALUE}};',
					'{{WRAPPER}} .ec-marketing-link-wrapper.style6 .ec-marketing-link svg' => 'fill: {{VALUE}};',
					'{{WRAPPER}} .ec-marketing-link-wrapper.style6 .ec-marketing-link::before,
					{{WRAPPER}} .ec-marketing-link-wrapper.style6 .ec-marketing-link::after' => 'background: {{VALUE}};',
				),
			)
		);
		$this->add_responsive_control(
			'ml6BrNorm',
			array(
				'label'      => esc_html__( 'Border Radius', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-marketing-link' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->end_controls_section();
		/*style end*/
	}

	protected function render() {

		$settings    = $this->get_settings_for_display();
		$mLMainLink  = ! empty( $settings['mLMainLink']['url'] ) ? $settings['mLMainLink']['url'] : '';
		$mLMainText  = ! empty( $settings['mLMainText'] ) ? $settings['mLMainText'] : '';
		$mLLinkLabel = ! empty( $settings['mLLinkLabel'] ) ? $settings['mLLinkLabel'] : '#';
		$mlType      = ! empty( $settings['mlType'] ) ? $settings['mlType'] : 'default';
		$mlTypeD     = ! empty( $settings['mlTypeD']['url'] ) ? $settings['mlTypeD']['url'] : '';

		$mLMainIcon = '';
		if ( ! empty( $settings['mLMainIcon'] ) ) {
			ob_start();
			\Elementor\Icons_Manager::render_icon( $settings['mLMainIcon'], array( 'aria-hidden' => 'true' ) );
			$mLMainIcon = ob_get_contents();
			ob_end_clean();
		}

		$data_attr = array();
		$class     = '';
		if ( $mlType == 'default' ) {
			$data_attr[] = esc_url( $mlTypeD );
			$class       = ' ml-default';
		} elseif ( $mlType == 'mbp' ) {
			foreach ( $settings['mLLinkList'] as $item ) {
				$mLLinkIn    = ! empty( $item['mLLink']['url'] ) ? $item['mLLink']['url'] : '';
				$data_attr[] = esc_url( $mLLinkIn );
				$class       = ' ml-mbp';
			}
		}

		$mLLinkMain = ! empty( $settings['mLMainLink']['url'] ) ? $settings['mLMainLink']['url'] : '';

		$data_attr[] = esc_url( $mLLinkMain );

		$data_attr = json_encode( $data_attr );

		$mlStyle = ! empty( $settings['mlStyle'] ) ? $settings['mlStyle'] : 'style1';

		$tiltclass  = '';
		$tiltrender = '';
		if ( isset( $settings['tiltEffect'] ) && $settings['tiltEffect'] === 'yes' ) {
			/*Tilt Effect Render*/
			include ECAFE_PATH . 'element/widgets/ecafe-tilt-render.php';
		}
		$tippyclass  = '';
		$tippyrender = '';
		if ( isset( $settings['tippyTooltip'] ) && $settings['tippyTooltip'] === 'yes' ) {
			/*Tippy Tooltip Render*/
			include ECAFE_PATH . 'element/widgets/ecafe-tippy-render.php';
		}
		$output      = '<div class="ec-marketing-link-wrapper ' . esc_attr( $mlStyle ) . ' ' . esc_attr( $tiltclass ) . ' ' . esc_attr( $tippyclass ) . '" ' . $tiltrender . ' ' . $tippyrender . '>';
			$output .= '<a class="ec-marketing-link ' . esc_attr( $class ) . '" href="' . esc_attr( $mLLinkLabel ) . '" data-settings=\'' . $data_attr . '\'>';
		if ( ! empty( $mlStyle ) && ( $mlStyle == 'style2' || $mlStyle == 'style3' || $mlStyle == 'style4' || $mlStyle == 'style6' ) ) {
			$output .= '<span>';
		}

				$output .= $mLMainIcon . esc_attr( $mLMainText );

		if ( ! empty( $mlStyle ) && ( $mlStyle == 'style2' || $mlStyle == 'style3' || $mlStyle == 'style4' || $mlStyle == 'style6' ) ) {
			$output .= '</span>';
		}
			$output .= '</a>';
			$output .= '</div>';

			echo wp_kses_normalize_entities( $output );
	}
}
