<?php



use Elementor\Widget_Base;
use Elementor\Controls_Manager;

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


class Categorycarouselthirdstkaveh extends Widget_Base{

  public function get_name(){
    return 'categorycarouselthirdstkaveh';
  }

  public function get_title(){
    return esc_html__( 'Category Carousel Style Three', 'kavehTheme' );
  }

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

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

  protected function register_controls(){
    
    $this->start_controls_section(
        'contentcategorycarouselthirdstkaveh',
        [
          'label' => esc_html__( 'Element Content', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );
      $repeater = new \Elementor\Repeater();
      $repeater->add_control(
      'title1categorycarouselthirdstkaveh',
      [
        'label' => esc_html__( 'Title', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => esc_html__( 'Category', 'kavehTheme' ),

      ]
    );
    $repeater->add_control(
      'tagheadingcategorycarouselthirdstkaveh',
      [
        'label' => esc_html__( 'Subtitle Tag', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'H6',
        'options' => [
          'H1'  => esc_html__( 'H1', 'kavehTheme' ),
          'H2' => esc_html__( 'H2', 'kavehTheme' ),
          'H3' => esc_html__( 'H3', 'kavehTheme' ),
          'H4' => esc_html__( 'H4', 'kavehTheme' ),
          'H5' => esc_html__( 'H5', 'kavehTheme' ),
          'H6' => esc_html__( 'H6', 'kavehTheme' ),
          'p' => esc_html__( 'p', 'kavehTheme' ),
          'div' => esc_html__( 'div', 'kavehTheme' ),
          'span' => esc_html__( 'span', 'kavehTheme' ),
        ],
      ]
    );
    $repeater->add_control(
      'styleboxcategorycarouselthirdstkaveh',
      [
        'label' => esc_html__( 'Display Image or Text?', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'img',
        'options' => [
          'img'  => esc_html__( 'Display Image', 'kavehTheme' ),
          'title'  => esc_html__( 'Display Text', 'kavehTheme' ),
  
        ],
      ]
      ); 
    $repeater->add_control(
      'imgcategorycarouselthirdstkaveh',
      [
        'label' => esc_html__( 'Select Your Image', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::MEDIA,
        'condition' => [
          'styleboxcategorycarouselthirdstkaveh' => 'img',
        ],
      ]
    );
    $repeater->add_control(
      'bigtitlecategorycarouselthirdstkaveh',
      [
        'label' => esc_html__( 'Text', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => '+79',
        'condition' => [
          'styleboxcategorycarouselthirdstkaveh' => 'title',
        ],
      ]
    );
    $repeater->add_control(
      'linkcategorycarouselthirdstkaveh',
      [
        'label' => esc_html__( 'Link', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => '#',
      ]
    );
    $this->add_control(
      'listcategorycarouselthirdstkaveh',
      [
        'label' => esc_html__( 'Categories', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::REPEATER,
        'fields' => $repeater->get_controls(),
        'default' => [
          [
            'title1categorycarouselthirdstkaveh' => esc_html__( 'Title', 'kavehTheme' ),
            'linkcategorycarouselthirdstkaveh' => '#',
          ],
      ]
      ]
    
    ); 
    $this->add_control(
      'colcategorycarouselthirdstkaveh',
      [
        'label' => esc_html__( 'Column Count', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => '2',
        'options' => [
          '1'  => esc_html__( '1', 'kavehTheme' ),
          '2' => esc_html__( '2', 'kavehTheme' ),
          '3' => esc_html__( '3', 'kavehTheme' ),
          '4' => esc_html__( '4', 'kavehTheme' ),
          '6' => esc_html__( '6', 'kavehTheme' ),

        ],
      ]
    );
       $this->end_controls_section();
       $this->start_controls_section(
        'style_categorycarouselthirdstkaveh',
        [
          'label' => esc_html__( 'Title Styles', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'textcolor2categorycarouselthirdstkaveh',
        [
          'label' => esc_html__( 'Title Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}}  .top-category-four-item .cat3t' => 'color: {{VALUE}}',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'title_categorycarouselthirdstkaveh',
          'label' => esc_html__( 'Title Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}}  .top-category-four-item .cat3t',
        ]
      );
      $this->add_control(
        'pcolor3categorycarouselthirdstkaveh',
        [
          'label' => esc_html__( 'Bold Text Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .top-category-four-item span' => 'color: {{VALUE}}',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'p3_categorycarouselthirdstkaveh',
          'label' => esc_html__( 'Bold Text Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .top-category-four-item span',
        ]
      );
      $this->end_controls_section();
      $this->start_controls_section(
        'style2_categorycarouselthirdstkaveh',
        [
          'label' => esc_html__( 'Image Styles', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      
        $this->add_control(
          'widthimgcategorycarouselthirdstkaveh',
          [
            'label' => esc_html__( 'Image Width', 'kavehTheme' ),
            'type' => \Elementor\Controls_Manager::SLIDER,
            'size_units' => [ 'px', '%' ],
            'range' => [
              'px' => [
                'min' => 0,
                'max' => 2000,
                'step' => 5,
              ],
              '%' => [
                'min' => 0,
                'max' => 100,
              ], 
            ],
            'default' => [
              'unit' => 'px',
              'size' => 100,
            ],
            'selectors' => [
              '{{WRAPPER}} .top-category-four img' => 'width: {{SIZE}}{{UNIT}} !important;',
            ],
          ]
        );
        $this->add_control(
          'maxwidthimgcategorycarouselthirdstkaveh',
          [
            'label' => esc_html__( 'Maximum Image Width', 'kavehTheme' ),
            'type' => \Elementor\Controls_Manager::SLIDER,
            'size_units' => [ 'px', '%' ],
            'range' => [
              'px' => [
                'min' => 0,
                'max' => 2000,
                'step' => 5,
              ],
              '%' => [
                'min' => 0,
                'max' => 100,
              ], 
            ],
            'default' => [
              'unit' => 'px',
              'size' => 120,
            ],
            'selectors' => [
              '{{WRAPPER}} .top-category-four-item .image' => 'max-width: {{SIZE}}{{UNIT}} !important;',
            ],
          ]
        );
        
        $this->add_control(
          'heigthimgcategorycarouselthirdstkaveh',
          [
            'label' => esc_html__( 'Image Height', 'kavehTheme' ),
            'type' => \Elementor\Controls_Manager::SLIDER,
            'size_units' => [ 'px', '%' ],
            'range' => [
              'px' => [
                'min' => 0,
                'max' => 2000,
                'step' => 5,
              ],
              '%' => [
                'min' => 0,
                'max' => 100,
              ],
            ],
            'selectors' => [
              '{{WRAPPER}} .top-category-four img' => 'height: {{SIZE}}{{UNIT}} !important;',
            ],
          ]
        );
        $this->add_control(
          'maxheigthimgcategorycarouselthirdstkaveh',
          [
            'label' => esc_html__( 'Maximum Image Height', 'kavehTheme' ),
            'type' => \Elementor\Controls_Manager::SLIDER,
            'size_units' => [ 'px', '%' ],
            'range' => [
              'px' => [
                'min' => 0,
                'max' => 2000,
                'step' => 5,
              ],
              '%' => [
                'min' => 0,
                'max' => 100,
              ],
            ],
            'selectors' => [
              '{{WRAPPER}} .top-category-four-item .image' => 'max-height: {{SIZE}}{{UNIT}} !important;',
            ],
          ]
        );
      $this->end_controls_section();

      $this->start_controls_section(
        'style3_categorycarouselthirdstkaveh',
        [
          'label' => esc_html__( 'Box Styles', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );

      $this->start_controls_tabs(
        'style_tabscategorycarouselthirdstkaveh'
      );

      $this->start_controls_tab(
        'style_normal_tabcategorycarouselthirdstkaveh',
        [
          'label' => esc_html__( 'Normal', 'kavehTheme' ),
        ]
      );

      $this->add_control(
        'buttoncolorcategorycarouselthirdstkaveh',
        [
          'label' => esc_html__( 'Box Background Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .top-category-four-item' => 'background-color: {{VALUE}}',
          ],
        ]
      ); 
      $this->add_control(
        'buttonradiuscategorycarouselthirdstkaveh',
        [
          'label' => esc_html__( 'Box Border Radius', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [
            '{{WRAPPER}} .top-category-four-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Border::get_type(),
        [
          'name' => 'bordercategorycarouselthirdstkaveh',
          'label' => esc_html__( 'Border', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .top-category-four-item',
        ]
      );
      $this->add_control(
        'buttonborderscategorycarouselthirdstkaveh',
        [
          'label' => esc_html__( 'Border Width', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'condition' => [
            'borderbrandscarouselkaveh!' => '',
          ],
          'selectors' => [
            '{{WRAPPER}} .top-category-four-item' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
          ],
        ]
      );
      $this->end_controls_tab();
      $this->start_controls_tab(
        'style_hove_tabcategorycarouselthirdstkaveh',
        [
          'label' => esc_html__( 'Hover', 'kavehTheme' ),
        ]
      );
      $this->add_control(
        'buttoncolorhovercategorycarouselthirdstkaveh',
        [
          'label' => esc_html__( 'Box Background Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .top-category-four-item:hover' => 'background-color: {{VALUE}}',
          ],
        ]
      ); 
      $this->add_control(
        'buttonradiushovercategorycarouselthirdstkaveh',
        [
          'label' => esc_html__( 'Box Border Radius', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [
            '{{WRAPPER}} .top-category-four-item:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Border::get_type(),
        [
          'name' => 'borderhovercategorycarouselthirdstkaveh',
          'label' => esc_html__( 'Border', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .top-category-four-item:hover',
        ]
      );
      $this->add_control(
        'buttonbordershovercategorycarouselthirdstkaveh',
        [
          'label' => esc_html__( 'Border Width', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'condition' => [
            'borderbrandscarouselkaveh!' => '',
          ],
          'selectors' => [
            '{{WRAPPER}} .top-category-four-item:hover' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
          ],
        ]
      );
      $this->end_controls_tab();
      $this->end_controls_tabs();
      $this->add_control(
        'hr1categorycarouselthirdstkaveh',
        [
          'type' => \Elementor\Controls_Manager::DIVIDER,
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Box_Shadow::get_type(),
        [
          'name' => 'box_shadowcategorycarouselthirdstkavehh',
          'label' => esc_html__( 'Box Shadow', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .top-category-four-item',
        ]
      );
      $this->add_control(
        'buttonpaddingcategorycarouselthirdstkaveh',
        [
          'label' => esc_html__( 'Padding', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [
            '{{WRAPPER}} .top-category-four-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
          ],
        ]
      );
      $this->end_controls_section();


        }


  protected function render(){
    $settings = $this->get_settings_for_display();
    $clsid = $this->get_id();
    ?>

<section class="top-category-four position-relative">
      <div class="container">
        <div class="row row-mobile">
        <?php
              if ( $settings['listcategorycarouselthirdstkaveh'] ) {
              foreach (  $settings['listcategorycarouselthirdstkaveh'] as $item ) {
              ?>
          <div class="<?php if('1'===$settings['colcategorycarouselthirdstkaveh']){ ?>col-lg-12<?php }elseif('2'===$settings['colcategorycarouselthirdstkaveh']){?>col-lg-6<?php }elseif('3'===$settings['colcategorycarouselthirdstkaveh']){?>col-lg-4<?php }elseif('4'===$settings['colcategorycarouselthirdstkaveh']){?>col-lg-3<?php }elseif('6'===$settings['colcategorycarouselthirdstkaveh']){?>col-lg-2<?php } ?> col-6">
            <div
              class="top-category-four-item position-relative d-flex align-items-center justify-content-center flex-column">
              <a href="<?php echo  esc_url($item['linkcategorycarouselthirdstkaveh']); ?>" class="stretched-link"></a>
              <?php if('img'===$item['styleboxcategorycarouselthirdstkaveh']){ ?>
              <div class="image mx-auto d-flex align-items-center justify-content-center">
                <img src="<?php echo esc_url($item['imgcategorycarouselthirdstkaveh']['url']); ?>" alt="<?php echo esc_attr(\Elementor\Control_Media::get_image_alt( $item['imgcategorycarouselthirdstkaveh'] )); ?>" />
              </div>
              <?php }elseif('title'===$item['styleboxcategorycarouselthirdstkaveh']){ ?>
                <span> <?php echo  esc_html($item['bigtitlecategorycarouselthirdstkaveh']); ?></span>
                <?php } ?>
              <<?php echo  esc_attr($item['tagheadingcategorycarouselthirdstkaveh']); ?> class="text-center cat3t"> <?php echo  esc_html($item['title1categorycarouselthirdstkaveh']); ?> </<?php echo  esc_attr($item['tagheadingcategorycarouselthirdstkaveh']); ?>>
            </div>
          </div>
          <?php 
            }
              }
            ?>
        </div>
      </div>
    </section>
    <?php
  }


}
