<?php
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Repeater;
use Elementor\Scheme_Color;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Background;
Use Elementor\Core\Schemes\Typography;
use Elementor\Group_Control_Border;
use Elementor\Utils;

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

/**
 * magmax Layout
 * =============
 */
class Widgetkit_Pro_Magmax_Newsletter extends Widget_Base
{

    public function get_name()
    {
        return 'magmax-newsletter';
    }

    public function get_title()
    {
        return __('Newsletter', 'widgetkit-pro');
    }

    public function get_icon()
    {
        return 'eicon-mailchimp';
    }

    public function get_categories()
    {
        return ['widgetkit_pro'];
    }

    /**
     * A list of scripts that the widgets is depended in
     *
     * @since 1.3.0
     **/

//    public function get_script_depends() {
//        return [ 'magmax_test' ];
//    }


    protected function register_controls()
    {
        /* slides content title subtitle button and button link */
        $this->start_controls_section(
            'section_tab',
            [
                'label' => __('Layout', 'widgetkit-pro'),
            ]
        );
        $this->add_control(
            'newsletter_image',
            [
                'label' => __( 'Choose Image', 'widgetkit-pro' ),
                'type' => Controls_Manager::MEDIA,
                'default' => [
                    'url' => Utils::get_placeholder_image_src(),
                ],
            ]
        );
        $this->add_control(
            'newsletter_thumb_size',
            [
                'label'       => __( 'Thumbnail Size', 'widgetkit-pro' ),
                'type' => Controls_Manager::SELECT,
                'default' => 'Medium',
                'options' => [
                    'medium'  => __( 'Medium', 'widgetkit-pro' ),
                    'medium_large'  => __( 'Medium Large', 'widgetkit-pro' ),
                    'large'  => __( 'Large', 'widgetkit-pro' ),
                    'full'  => __( 'Full', 'widgetkit-pro' ),
                ],
            ]
        );
        $this->add_control(
            'newsletter_title',
            [
                'label'       => __( 'MailChimp Title', 'widgetkit-pro' ),
                'type'        => Controls_Manager::TEXT,
                'placeholder' => __( 'title here', 'widgetkit-pro' ),
            ]
        );
        $this->add_control(
            'newsletter_subtitle',
            [
                'label'       => __( 'MailChimp Subtitle', 'widgetkit-pro' ),
                'type'        => Controls_Manager::TEXT,
                'placeholder' => __( 'Subtitle here', 'widgetkit-pro' ),
            ]
        );
        $this->add_control(
            'newsletter_shortcode',
            [
                'label'       => __( 'MailChimp Shortcode', 'widgetkit-pro' ),
                'type'        => Controls_Manager::TEXT,
                'placeholder' => __( '[your mailchimp shortcode]', 'widgetkit-pro' ),
            ]
        );
        $this->add_control(
            'newsletter_align',
            [
                'label' => __( 'Alignment', 'widgetkit-pro' ),
                'type' => Controls_Manager::CHOOSE,
                'options' => [
                    'left'    => [
                        'title' => __( 'Left', 'widgetkit-pro' ),
                        'icon' => 'fa fa-align-left',
                    ],
                    'center' => [
                        'title' => __( 'Center', 'widgetkit-pro' ),
                        'icon' => 'fa fa-align-center',
                    ],
                    'right' => [
                        'title' => __( 'Right', 'widgetkit-pro' ),
                        'icon' => 'fa fa-align-right',
                    ],
                ],
                'selectors' => [
                    '{{WRAPPER}} .magmax-newsletter .newsletter-wrapper' => 'text-align: {{VALUE}};',
                ],
            ]
        );
        $this->end_controls_section();

        /**
         * Style tab
         * =============
         */
        $this->start_controls_section(
            'section_style',
            [
                'label' => __( 'Typography', 'widgetkit-pro' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );

        /**
         * title
         */
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'label' => __( 'Title', 'widgetkit-pro' ),
                'name' => 'newsletter_title_typography',
                'selector' => '{{WRAPPER}} .magmax-newsletter .newsletter-title',
            ]
        );
        /**
         * Subtitle
         */
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'label' => __( 'Subtitle', 'widgetkit-pro' ),
                'name' => 'newsletter_subtitle_typography',
                'selector' => '{{WRAPPER}} .magmax-newsletter .newsletter-subtitle',
            ]
        );

        $this->end_controls_section();


        $this->start_controls_section(
            'content_style',
            [
                'label' => __( 'Content', 'widgetkit-pro' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );
        /**
         * Custom Color
         */
        $this->add_control(
            'custom_color',
            [
                'label' => __( 'Custom Color', 'widgetkit-pro' ),
                'type' => Controls_Manager::SWITCHER,
                'default' => '',
                'description' => 'Show custom color for content',
                'label_on' => __( 'Yes', 'widgetkit-pro' ),
                'label_off' => __( 'No', 'widgetkit-pro' ),
                'return_value' => 'yes',
            ]
        );
        $this->add_control(
            'newsletter_title_color',
            [
                'label' => __( 'Newsletter Title Color', 'widgetkit-pro' ),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .magmax-newsletter .newsletter-title' => 'color: {{VALUE}}',
                ],
                'condition' => [
                    'custom_color' => 'yes',
                ],
            ]
        );
        $this->add_control(
            'newsletter_subtitle_color',
            [
                'label' => __( 'Newsletter Subtitle Color', 'widgetkit-pro' ),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .magmax-newsletter .newsletter-subtitle' => 'color: {{VALUE}}',
                ],
                'condition' => [
                    'custom_color' => 'yes',
                ],
            ]
        );
        $this->end_controls_section();
    }

    protected function render()
    {
        $settings = $this->get_settings();
        $newsletter_image = widgetkit_pro_widgetkit_pro_array_get($settings, 'newsletter_image');
        $newsletter_thumb_size = widgetkit_pro_widgetkit_pro_array_get($settings, 'newsletter_thumb_size');
        $newsletter_title = widgetkit_pro_widgetkit_pro_array_get($settings, 'newsletter_title');
        $newsletter_subtitle = widgetkit_pro_widgetkit_pro_array_get($settings, 'newsletter_subtitle');
        $newsletter_shortcode = widgetkit_pro_widgetkit_pro_array_get($settings, 'newsletter_shortcode');
        $newsletter_align = widgetkit_pro_widgetkit_pro_array_get($settings, 'newsletter_align');


        include( plugin_dir_path( __FILE__ ) . '../layout/newsletter.php');
    }
    protected function _content_template()
    {
    }
}
