<?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 nft_sell_create 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 'nft_sell_create';
	}

	/**
	 * Get widget title.
	 *
	 * Retrieve Elementor widget title.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title() {
		return esc_html__( 'NFT Sell Create', '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(
            'nft_slider_options',
            [
                'label' => __( 'NFT Market Options', 'ximsa' ),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );        
        $this->add_control(
			'shape',
			[
				'label' => esc_html__( 'Shape', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'subtitle_shape',
			[
				'label' => esc_html__( 'Sub Title Shape', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'title_main',
			[
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $this->add_control(
			'title_shape',
			[
				'label' => esc_html__( 'Title Shape', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'box_shape',
			[
				'label' => esc_html__( 'Box Shape', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $repeater = new \Elementor\Repeater();
        
        $repeater->add_control(
			'icon_img',
			[
				'label' => esc_html__( 'Icon Image', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'count',
			[
				'label' => esc_html__( 'Count', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'description',
			[
				'label' => esc_html__( 'Description', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'btn_label',
			[
				'label' => esc_html__( 'Button Label', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'link',
			[
				'label' => esc_html__( 'Link', 'ximsa' ),
				'type' => Controls_Manager::URL,
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'features',
			[
				'label' => esc_html__( 'Add Item', 'ximsa' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
				'title_field' => '{{{ title }}}',
			]
		);
		$this->end_controls_section();
        $this->start_controls_section(
            'feature_settings_style',
            [
                'label' => __( 'Content Style Settings', 'ximsa' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );
        
        $this->add_control(
            'slider_title',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        
        $this->add_control(
            'sl_title_color',
            [
                'label'     => esc_html__( 'Description Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-nft-section-title h2' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'sl_title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-nft-section-title h2',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        
        $this->add_control(
            'box_title_desc',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Box Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'sl_title_color',
            [
                'label'     => esc_html__( 'Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-nft-create-sell-inner-item .xis-nft-text h3' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'box_title_desc_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-nft-create-sell-inner-item .xis-nft-text h3
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'box_text_desc',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Description Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'sl_desc_color',
            [
                'label'     => esc_html__( 'Description Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-nft-create-sell-inner-item .xis-nft-text p' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'box_txtl_desc_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-nft-create-sell-inner-item .xis-nft-text p
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'box_more_desc',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Readmore Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'box_readmore_color',
            [
                'label'     => esc_html__( 'Readmore Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-nft-create-sell-inner-item .xis-nft-text .read-more a' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'box_readmore_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-nft-create-sell-inner-item .xis-nft-text .read-more a
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'box_count_desc',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Count Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        
        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'count-background',
				'label' => esc_html__( 'Background', 'ximsa' ),
				'types' => [ 'gradient' ],
				'selector' => '{{WRAPPER}} .xis-nft-create-sell-inner-item .xis-nft-icon-serial span',
			]
		);
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'box_count_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-nft-create-sell-inner-item .xis-nft-icon-serial span
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'box_bg_desc',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Box Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        
        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'box-bg-background',
				'label' => esc_html__( 'Background', 'ximsa' ),
				'types' => [ 'gradient' ],
				'selector' => '{{WRAPPER}} .xis-nft-create-sell-inner-item:before',
			]
		);
        $this->add_control(
            'box_bg_cl',
            [
                'label'     => esc_html__( 'Box Background Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-nft-create-sell-inner-item:after' => 'background-color: {{VALUE}} ',
                ],
            ]
        );
        
		$this->end_controls_section();
        
        $this->start_controls_section(
            'button__content',
            [
                'label' => __( 'Slider Button Style', 'ximsa' ),
                'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name'           => 'btn_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-nft-header-btn a, .xis-nft-btn a
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
			'btnwidth',
			[
				'label' => esc_html__( 'Width', 'ximsa' ),
				'type' => Controls_Manager::SLIDER,
				'size_units' => [ 'px', '%' ],
				'range' => [
					'px' => [
						'min' => 0,
						'max' => 1000,
						'step' => 5,
					],
					'%' => [
						'min' => 0,
						'max' => 100,
					],
				],
				'selectors' => [
					'{{WRAPPER}} .xis-nft-header-btn a, .xis-nft-btn a' => 'width: {{SIZE}}{{UNIT}};',
				],
			]
		);
        $this->add_control(
			'btnheight',
			[
				'label' => esc_html__( 'Height', 'ximsa' ),
				'type' => Controls_Manager::SLIDER,
				'size_units' => [ 'px', '%' ],
				'range' => [
					'px' => [
						'min' => 0,
						'max' => 1000,
						'step' => 5,
					],
					'%' => [
						'min' => 0,
						'max' => 100,
					],
				],
				'selectors' => [
					'{{WRAPPER}} .xis-nft-header-btn a, .xis-nft-btn a' => 'height: {{SIZE}}{{UNIT}};',
				],
			]
		);
        $this->start_controls_tabs( '_banner_button_1' );
        $this->start_controls_tab(
            '_glow-extension_btn__banner_normal',
            [
                'label' => esc_html__( 'Normal', 'ximsa' ),
            ]
        );
        $this->add_control(
            'btn__color',
            [
                'label'     => esc_html__( 'Color', 'ximsa' ),
                'type'      => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-nft-header-btn a, .xis-nft-btn a' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Background::get_type(),
            [
                'name'     => 'btn_bg_color',
                'label'    => __( 'Background', 'ximsa' ),
                'types'    => ['classic', 'gradient'],
                'exclude'  => ['image'],
                'selector' => '
                    {{WRAPPER}} .xis-nft-header-btn a, .xis-nft-btn a
                ',
            ]
        );
        $this->add_responsive_control(
            'btn_border_radious',
            [
                'label'      => esc_html__( 'Border Radius', 'ximsa' ),
                'type'       => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'selectors'  => [
                    '{{WRAPPER}} .xis-nft-header-btn a, .xis-nft-btn a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );
        $this->add_group_control(
			\Elementor\Group_Control_Border::get_type(),
			[
				'name' => 'btn_border',
				'label' => esc_html__( 'Border', 'ximsa' ),
				'selector' => '{{WRAPPER}} .xis-nft-header-btn a, .xis-nft-btn a',
			]
		);
        
        $this->end_controls_tab();
        $this->start_controls_tab(
            '_glow-extension_btn_hover',
            [
                'label' => esc_html__( 'Hover', 'ximsa' ),
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Background::get_type(),
            [
                'name'     => 'btn_hover_bg_color',
                'label'    => __( 'Background', 'ximsa' ),
                'types'    => ['classic', 'gradient'],
                'exclude'  => ['image'],
                'selector' => '
                    {{WRAPPER}} .xis-nft-header-btn a:hover, .xis-nft-btn a:hover
                ',
            ]
        );
        
        $this->end_controls_tab();
        $this->end_controls_tabs();
        $this->end_controls_section();
	}
		


	protected function render() {	
	$settings = $this->get_settings_for_display();?>        
        <!-- Start of Create and sell section
        ============================================= -->
        <section id="xis-nft-create-sell" class="xis-nft-create-sell-section position-relative">
            <span class="xis-nft-side-shape1 position-absolute"><img src="<?php echo esc_url($settings['shape']['url']);?>" alt=""></span>
            <div class="container">
                <div class="xis-nft-section-title xis-nft-headline d-flex align-items-center wow fadeInUp"  data-wow-delay="0ms" data-wow-duration="1000ms">
                    <h2><img src="<?php echo esc_url($settings['subtitle_shape']['url']);?>" alt=""><?php echo esc_html($settings['title_main']);?> <span><img src="<?php echo esc_url($settings['title_shape']['url']);?>" alt=""></span></h2>
                </div>
                <div class="xis-nft-create-sell-content">
                    <div class="row">
                        <?php $i = 0; foreach($settings['features'] as $item): $i++?>
                        <div class="col-lg-3 col-md-6 wow fadeInUp"  data-wow-delay="800ms" data-wow-duration="1000ms">
                            <div class="xis-nft-create-sell-inner-item position-relative">
                                <span class="xis-nft-cs-circle-shape position-absolute"><img src="<?php echo $settings['box_shape']['url']; ?>" alt=""></span>
                                <div class="xis-nft-icon-serial d-flex align-items-center justify-content-between">
                                    <div class="xis-nft-icon">
                                        <img src="<?php echo esc_url($item['icon_img']['url']);?>" alt="">
                                    </div>
                                    <div class="xis-nft-serial">
                                        <span><?php echo esc_html($item['count']);?></span>
                                    </div>
                                </div>
                                <div class="xis-nft-text xis-nft-headline pera-content">
                                    <h3><a href="<?php echo esc_url($item['link']['url']);?>"><?php echo esc_html($item['title']);?></a></h3>
                                    <p><?php echo wp_kses( $item['description'], true ); ?></p>
                                    <div class="read-more position-relative">
                                        <a href="<?php echo esc_url($item['link']['url']);?>"><span><?php echo wp_kses( $item['btn_label'], true ); ?></span><i class="fal fa-long-arrow-right"></i></a>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <?php endforeach;?>
                    </div>
                </div>
            </div>
        </section>		
    <!-- End of Create and sell section
        ============================================= -->
    <?php  
    }
	
}

