<?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\Plugin;

/**
 * Elementor button widget.
 * Elementor widget that displays a button with the ability to control every
 * aspect of the button design.
 *
 * @since 1.0.0
 */
class helpdesk_banner extends Widget_Base {

    /**
     * Get widget name.
     * Retrieve button widget name.
     *
     * @since  1.0.0
     * @access public
     * @return string Widget name.
     */
    public function get_name() {
        return 'helpdesk_banner';
    }

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

    /**
     * Get widget icon.
     * Retrieve button widget icon.
     *
     * @since  1.0.0
     * @access public
     * @return string Widget icon.
     */
    public function get_icon() {
        return 'eicon-library-open';
    }

    /**
     * Get widget categories.
     * Retrieve the list of categories the button widget belongs to.
     * Used to determine where to display the widget in the editor.
     *
     * @since  2.0.0
     * @access public
     * @return array Widget categories.
     */
    public function get_categories() {
        return [ 'ximsa' ];
    }

    /**
     * Register button 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(
            'helpdesk_banner',
            [
                'label' => esc_html__( 'Helpdesk Banner', 'ximsa' ),
            ]
        );
		$this->add_control(
			'banner_bg',
			[
				'label'       => __( 'Banner BG', 'ximsa' ),
				'label_block' => true,
				'type'        => Controls_Manager::MEDIA,
				'dynamic'     => [
					'active' => true,
				],
			]
		);


		$this->add_control(
			'subtitle',
			[
				'label'       => __( 'Sub Title', 'ximsa' ),
				'label_block' => true,
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => [
					'active' => true,
				],
				'placeholder' => __( 'Enter Form Title', 'ximsa' ),
			]
		);

		$this->add_control(
			'title',
			[
				'label'       => __( 'Title', 'ximsa' ),
				'label_block' => true,
				'type'        => Controls_Manager::TEXTAREA,
				'dynamic'     => [
					'active' => true,
				],
				'placeholder' => __( 'Enter Form Title', 'ximsa' ),
			]
		);

		$this->add_control(
			'description',
			[
				'label'       => __( 'Description', 'ximsa' ),
				'type'        => Controls_Manager::TEXTAREA,
				'dynamic'     => [
					'active' => true,
				],
				'placeholder' => __( 'Enter Description Here', 'ximsa' ),
			]
		);

		$this->add_control(
			'button_label',
			[
				'label'       => __( 'Button Label', 'ximsa' ),
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => [
					'active' => true,
				],
			]
		);
		$this->add_control(
			'button_link',
			[
				'label'       => __( 'Button Link', 'ximsa' ),
				'type'        => Controls_Manager::URL,
				'dynamic'     => [
					'active' => true,
				],
			]
		);
		$this->add_control(
			'video_text',
			[
				'label'       => __( 'Video Label', 'ximsa' ),
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => [
					'active' => true,
				],
			]
		);
		$this->add_control(
			'video_link',
			[
				'label'       => __( 'Video Link', 'ximsa' ),
				'type'        => Controls_Manager::URL,
				'dynamic'     => [
					'active' => true,
				],
			]
		);
		$this->add_control(
			'shape1',
			[
				'label'       => __( 'Shape1', 'ximsa' ),
				'label_block' => true,
				'type'        => Controls_Manager::MEDIA,
				'dynamic'     => [
					'active' => true,
				],
			]
		);
		$this->add_control(
			'shape2',
			[
				'label'       => __( 'Shape2', 'ximsa' ),
				'label_block' => true,
				'type'        => Controls_Manager::MEDIA,
				'dynamic'     => [
					'active' => true,
				],
			]
		);
		$this->add_control(
			'shape3',
			[
				'label'       => __( 'Shape3', 'ximsa' ),
				'label_block' => true,
				'type'        => Controls_Manager::MEDIA,
				'dynamic'     => [
					'active' => true,
				],
			]
		);
		$this->add_control(
			'shape4',
			[
				'label'       => __( 'Shape4', 'ximsa' ),
				'label_block' => true,
				'type'        => Controls_Manager::MEDIA,
				'dynamic'     => [
					'active' => true,
				],
			]
		);
		$this->add_control(
			'shape5',
			[
				'label'       => __( 'Shape5', 'ximsa' ),
				'label_block' => true,
				'type'        => Controls_Manager::MEDIA,
				'dynamic'     => [
					'active' => true,
				],
			]
		);
		$this->add_control(
			'shape6',
			[
				'label'       => __( 'Shape6', 'ximsa' ),
				'label_block' => true,
				'type'        => Controls_Manager::MEDIA,
				'dynamic'     => [
					'active' => true,
				],
			]
		);
		$this->add_control(
			'shape7',
			[
				'label'       => __( 'Shape8', 'ximsa' ),
				'label_block' => true,
				'type'        => Controls_Manager::MEDIA,
				'dynamic'     => [
					'active' => true,
				],
			]
		);
		$this->add_control(
			'shape8',
			[
				'label'       => __( 'Shape8', 'ximsa' ),
				'label_block' => true,
				'type'        => Controls_Manager::MEDIA,
				'dynamic'     => [
					'active' => true,
				],
			]
		);
		$this->add_control(
			'shape9',
			[
				'label'       => __( 'Shape9', 'ximsa' ),
				'label_block' => true,
				'type'        => Controls_Manager::MEDIA,
				'dynamic'     => [
					'active' => true,
				],
			]
		);

		$this->end_controls_section();

        $this->start_controls_section(
            'section_heading_op',
            [
                'label' => __( 'Section Heading Settings', 'ximsa' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );
        $this->add_control(
			'width',
			[
				'label' => esc_html__( 'Container Width', 'plugin-name' ),
				'type' => \Elementor\Controls_Manager::SLIDER,
				'size_units' => [ 'px', '%' ],
				'range' => [
					'px' => [
						'min' => 0,
						'max' => 2000,
						'step' => 1,
					],
				],
				'default' => [
					'unit' => 'px',
					'size' => 1320,
				],
				'selectors' => [
					'{{WRAPPER}} .container' => 'max-width: {{SIZE}}{{UNIT}};',
				],
			]
		);

        $this->add_control(
            'main_sub_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Sub Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'sub_title_cl',
            [
                'label'     => esc_html__( 'Sub Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-hd-banner-text .banner-tag, .xis-hd-section-title .sub-title' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'sub_th_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-hd-banner-text .banner-tag, .xis-hd-section-title .sub-title',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'main_title_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'title_cl',
            [
                'label'     => esc_html__( 'Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-hd-banner-text h1' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'main_th_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-hd-banner-text h1',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'main_text_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Text Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'text_cl',
            [
                'label'     => esc_html__( 'Text Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-hd-banner-text p' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'main_text_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-hd-banner-text p',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'main_btn_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Button Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'btn_cl',
            [
                'label'     => esc_html__( 'Button Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-hd-banner-text .xis-hd-banner-btn-grp .xis-hd-banner-btn a' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'btn_bg_cl',
            [
                'label'     => esc_html__( 'Button BG Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-hd-banner-text .xis-hd-banner-btn-grp .xis-hd-banner-btn a' => 'background-color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'btn_bg_hover_cl',
            [
                'label'     => esc_html__( 'Button Hover Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-hd-banner-text .xis-hd-banner-btn-grp .xis-hd-banner-btn a:hover' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'btn_bg_hover_bg',
            [
                'label'     => esc_html__( 'Button BG Hover Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-hd-banner-text .xis-hd-banner-btn-grp .xis-hd-banner-btn a:hover' => 'background-color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'main_btn_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-hd-banner-text .xis-hd-banner-btn-grp .xis-hd-banner-btn a',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'video_info_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Video Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'video_txt_cl',
            [
                'label'     => esc_html__( 'Video Text Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-hd-banner-text .xis-hd-banner-btn-grp .xis-banner-video-play a' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'video_text_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-hd-banner-text .xis-hd-banner-btn-grp .xis-banner-video-play a',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
		$this->end_controls_section();
    }

    /**
     * Render button widget output on the frontend.
     * Written in PHP and used to generate the final HTML.
     *
     * @since  1.0.0
     * @access protected
     */
    protected function render() {
        $settings = $this->get_settings_for_display();
        $allowed_tags = wp_kses_allowed_html('post');
    ?>

    <!-- Start of Banner section
	============================================= -->
	<section id="xis-hd-banner" class="xis-hd-banner-section position-relative">
		<span class="xis-hd-bg-shape position-absolute"><img src="<?php echo esc_url($settings['banner_bg']['url']);?>" alt=""></span>
		<div class="container">
			<div class="xis-hd-banner-content position-relative">
				<div class="xis-hd-banner-text xis-hd-headline pera-content">
					<div class="banner-tag  wow fadeInUp" data-wow-delay="200ms" data-wow-duration="1500ms">
						<?php echo wp_kses( $settings['subtitle'], true );?>
					</div>
					<h1 class="wow fadeInUp" data-wow-delay="400ms" data-wow-duration="1500ms">
                        <?php echo wp_kses( $settings['title'], true );?>
					</h1>
					<p class="wow fadeInUp" data-wow-delay="600ms" data-wow-duration="1500ms">
                        <?php echo wp_kses( $settings['description'], true );?>
					</p>
					<div class="xis-hd-banner-btn-grp d-flex align-items-center  wow fadeInUp" data-wow-delay="700ms" data-wow-duration="1500ms">
						<div class="xis-hd-banner-btn">
							<a class="d-flex justify-content-center align-items-center text-uppercase"
                            href="<?php echo esc_url($settings['button_link']['url']);?>"
                            target="<?php echo esc_attr($settings['button_link']['is_external'] ? '_blank' : '_self');?>"
                            rel="<?php echo esc_attr($settings['button_link']['nofollow'] ? 'nofollow' : '');?>"
                            >
                                <?php echo wp_kses( $settings['button_label'], true );?>
                            </a>
						</div>
						<div class="xis-banner-video-play">
							<a class="video_box" href="<?php echo esc_url($settings['video_link']['url']);?>"><i class="fas fa-play"></i> <?php echo wp_kses( $settings['video_text'], true );?></a>
						</div>
					</div>
				</div>
				<div class="xis-hd-banner-img-wrap position-absolute scene">
					<div class="xis-hd-banner-img wow fadeInLeft" data-wow-delay="200ms" data-wow-duration="1500ms">
						<img class="layer" data-depth="0.3" src="<?php echo esc_url($settings['shape1']['url']);?>" alt="">
					</div>
					<span class="xis-hd-banner-shape1 position-absolute scene wow fadeInUp" data-wow-delay="400ms" data-wow-duration="1500ms"><img class="layer" data-depth="0.5" src="<?php echo esc_url($settings['shape2']['url']);?>" alt=""></span>
					<span class="xis-hd-banner-shape2 position-absolute scene wow fadeInRight" data-wow-delay="600ms" data-wow-duration="1500ms"><img class="layer" data-depth="0.6" src="<?php echo esc_url($settings['shape3']['url']);?>" alt=""></span>
					<span class="xis-hd-banner-shape3 position-absolute scene wow fadeInLeft" data-wow-delay="800ms" data-wow-duration="1500ms"><img class="layer" data-depth="0.7" src="<?php echo esc_url($settings['shape4']['url']);?>" alt=""></span>
					<span class="xis-hd-banner-shape4 position-absolute scene wow fadeInUp" data-wow-delay="1000ms" data-wow-duration="1500ms"><img class="layer" data-depth="0.2" src="<?php echo esc_url($settings['shape5']['url']);?>" alt=""></span>
					<span class="xis-hd-banner-shape5 position-absolute scene wow fadeInUp" data-wow-delay="600ms" data-wow-duration="1500ms"><img class="layer" data-depth="0.3" src="<?php echo esc_url($settings['shape6']['url']);?>" alt=""></span>
					<span class="xis-hd-banner-shape6 position-absolute scene wow fadeInLeft" data-wow-delay="600ms" data-wow-duration="1500ms"><img class="layer" data-depth="0.5" src="<?php echo esc_url($settings['shape7']['url']);?>" alt=""></span>
					<span class="xis-hd-banner-shape7 position-absolute scene wow fadeInRight" data-wow-delay="800ms" data-wow-duration="1500ms"><img class="layer" data-depth="0.4" src="<?php echo esc_url($settings['shape8']['url']);?>" alt=""></span>
					<span class="xis-hd-banner-shape8 position-absolute scene wow fadeInUp" data-wow-delay="1000ms" data-wow-duration="1500ms"><img class="layer" data-depth="0.6" src="<?php echo esc_url($settings['shape9']['url']);?>" alt=""></span>
				</div>
			</div>

		</div>
	</section>
<!-- End of Banner section
	============================================= -->

	<?php
    }
}
