<?php

namespace XIMSAPLUGIN\Element;

use Elementor\Controls_Manager;
use Elementor\Controls_Stack;
use Elementor\Group_Control_Typography;
use Elementor\Scheme_Typography;
use Elementor\Scheme_Color;
use Elementor\Group_Control_Border;
use Elementor\Repeater;
use Elementor\Widget_Base;
use Elementor\Utils;
use Elementor\Group_Control_Text_Shadow;
use Elementor\Group_Control_Background;
use Elementor\Plugin;

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

class crypto_testimonial_widget extends Widget_Base {

	/**
	 * Get widget name.
	 *
	 * Retrieve Elementor widget name.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget name.
	 */
	public function get_name() {
		return 'crypto-testimonial-section';
	}

	/**
	 * Get widget title.
	 *
	 * Retrieve Elementor widget title.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title() {
		return esc_html__( 'Crypto Testimonial', 'ximsa' );
	}

	/**
	 * Get widget icon.
	 *
	 * Retrieve Elementor widget icon.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget icon.
	 */
	public function get_icon() {
		return 'gl-custom-icon';
	}

	/**
	 * Get widget categories.
	 *
	 * Retrieve the list of categories the Elementor widget belongs to.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return array Widget categories.
	 */
	public function get_categories() {
		return [ 'ximsa' ];
	}

	/**
	 * Register Elementor widget controls.
	 *
	 * Adds different input fields to allow the user to change and customize the widget settings.
	 *
	 * @since 1.0.0
	 * @access protected
	 */
	 
	
	protected function register_controls() {
        $this->start_controls_section(
            'crypto_testimonial_options',
            [
                'label' => __( 'Testimonial Option', 'ximsa' ),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_control(
			'shape1',
			[
				'label' => esc_html__( 'Shape 1', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $repeater = new \Elementor\repeater();
        
        $repeater->add_control(
			'authore_img',
			[
				'label' => esc_html__( 'Authore Image', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'feedback',
			[
				'label' => esc_html__( 'Feedback', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'authore_name',
			[
				'label' => esc_html__( 'Authore Name', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'designation_name',
			[
				'label' => esc_html__( 'Designation Name', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'testimonials',
			[
				'label' => esc_html__( 'Add Item', 'ximsa' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
				'title_field' => '{{{ authore_name }}}',
			]
		);
        $this->end_controls_section();

        $this->start_controls_section(
            'testimonial_right_shape',
            [
                'label' => __( 'Testimonial Right Image', 'ximsa' ),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );
        
        $this->add_control(
			'pattern',
			[
				'label' => esc_html__( 'pattern 1', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'pattern2',
			[
				'label' => esc_html__( 'pattern 2', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'pattern3',
			[
				'label' => esc_html__( 'pattern 3', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'authore_1',
			[
				'label' => esc_html__( 'Authore 1', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'authore_2',
			[
				'label' => esc_html__( 'Authore 2', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'authore_3',
			[
				'label' => esc_html__( 'Authore 3', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'authore_4',
			[
				'label' => esc_html__( 'Authore 4', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'authore_5',
			[
				'label' => esc_html__( 'Authore Large Image', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        
        $this->end_controls_section();
        $this->start_controls_section(
            'testimonial_settings_style',
            [
                'label' => __( 'section Title Settings', 'ximsa' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );

        $this->add_control(
            'fs_title_style',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'testimonial Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'fs_title_cl',
            [
                'label'     => esc_html__( 'testimonial Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .crypto-testimonial-block .inner-box .author-info span' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'fs_title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .crypto-testimonial-block .inner-box .author-info span',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'fs_feedback_style',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Feedback Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'fs_feedback_cl',
            [
                'label'     => esc_html__( 'Feedback Text Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .crypto-testimonial-block .text' => 'color: {{VALUE}} ',
                ],
            ]
        );
        
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'fs_feed_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .crypto-testimonial-block .text',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'fs_desig_style',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Desigantion Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'fs_designation_cl',
            [
                'label'     => esc_html__( 'Designation Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .crypto-testimonial-block .inner-box .author-info' => 'color: {{VALUE}} ',
                ],
            ]
        );
        
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'fs_desig_tp_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .crypto-testimonial-block .inner-box .author-info',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );

        $this->end_controls_section();
	}
		


	protected function render() {
		
		
		$settings = $this->get_settings_for_display(); ?>
            <!-- Crypto Testimonial Section -->
            <section class="crypto-testimonial-section">
                <!-- Shape Layer One -->
                <div class="shape-layer-one" style="background-image: url(<?php echo esc_url($settings['shape1']['url']);?>)"></div>
                <div class="auto-container">
                    <div class="row clearfix">
                    
                        <!-- Carousel Column -->
                        <div class="carousel-column col-lg-6 col-md-12 col-sm-12">
                            <div class="inner-column">
                                <div class="single-item-carousel owl-carousel owl-theme">
                                    <?php foreach($settings['testimonials'] as $item):?>
                                    <!-- Crypto Testimonial Block -->
                                    <div class="crypto-testimonial-block">
                                        <div class="inner-box">
                                            <div class="client-logo">
                                                <img src="<?php echo esc_url($item['authore_img']['url']);?>" alt="" />
                                            </div>
                                            <div class="text"><?php echo esc_html($item['feedback']);?></div>
                                            <div class="author-info"><span><?php echo esc_html($item['authore_name']);?></span> <?php echo esc_html($item['designation_name']);?></div>
                                        </div>
                                    </div>
                                    <?php endforeach;?>
                                </div>
                            </div>
                        </div>
                        
                        <!-- Image Column -->
                        <div class="image-column col-lg-6 col-md-12 col-sm-12">
                            <div class="inner-column">
                                <div class="circle-layer zoominup-animate2" style="background-image: url(<?php echo esc_url($settings['pattern']['url']);?>)"></div>
                                <div class="circle-layer-two zoominup-animate" style="background-image: url(<?php echo esc_url($settings['pattern2']['url']);?>)"></div>
                                <div class="circle-layer-three zoominup-animate" style="background-image: url(<?php echo esc_url($settings['pattern3']['url']);?>)"></div>
                                <div class="authors-outer">
                                    <span class="author-one updown-animate updown-animate-2"><img src="<?php echo esc_url($settings['authore_1']['url']);?>" alt="" /></span>
                                    <span class="author-two updown-animate"><img src="<?php echo esc_url($settings['authore_2']['url']);?>" alt="" /></span>
                                    <span class="author-three updown-animate updown-animate-2"><img src="<?php echo esc_url($settings['authore_3']['url']);?>" alt="" /></span>
                                    <span class="author-four updown-animate"><img src="<?php echo esc_url($settings['authore_4']['url']);?>" alt="" /></span>
                                </div>
                                <div class="image wow fadeInRight" data-wow-delay="0s" data-wow-duration="1500ms">
                                    <img src="<?php echo esc_url($settings['authore_5']['url']);?>" alt="" />
                                </div>
                            </div>
                        </div>
                        
                    </div>
                </div>
            </section>
            <!-- End Crypto Testimonial Section -->
		<?php 
      }
	
	

}
