<?php



use Elementor\Widget_Base;
use Elementor\Controls_Manager;

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


class Categorycarouseltwentyseventhstkaveh extends Widget_Base{

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

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

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

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

  protected function register_controls(){
    
    $this->start_controls_section(
        'contentcategorycarouseltwentyseventhstkaveh',
        [
          'label' => esc_html__( 'Element Content', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );
      $this->add_control(
        'tagti1categorycarouseltwentyseventhstkaveh',
        [
          'label' => esc_html__( 'Title Tag', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SELECT,
          'default' => 'H3',
          'condition' => [
            'showticategorycarouseltwentyseventhstkaveh' => 'yes',
          ],
          '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' ),
          ],
        ]
      );

      $this->add_control(
        'wigti2categorycarouseltwentyseventhstkaveh',
        [
          'label' => esc_html__( 'Main Title', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::TEXT,
          'default' => 'Product Categories',
        ]
      );

      $repeater = new \Elementor\Repeater();
      $repeater->add_control(
        'img1categorycarouselsevenkaveh',
        [
          'label' => esc_html__( 'Background Image', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::MEDIA,
        ]
      ); 
      $repeater->add_control(
      'title1categorycarouseltwentyseventhstkaveh',
      [
        'label' => esc_html__( 'Title', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => 'Table and Chair',

      ]
    );
    $repeater->add_control(
      'tagheading1categorycarouseltwentyseventhstkaveh',
      [
        'label' => esc_html__( 'Title Tag', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'div',
        '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(
      'linkcategorycarouseltwentyseventhstkaveh',
      [
        'label' => esc_html__( 'Link', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => '#',
      ]
    );



    $this->add_control(
      'listcategorycarouseltwentyseventhstkaveh',
      [
        'label' => esc_html__( 'Product Categories', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::REPEATER,
        'fields' => $repeater->get_controls(),
        'default' => [
          [
            'title1categorycarouseltwentyseventhstkaveh' => esc_html__( 'Title', 'kavehTheme' ),
            'tagheading1categorycarouseltwentyseventhstkaveh' => esc_html__( 'Title Tag', 'kavehTheme' ),
            'linkcategorycarouseltwentyseventhstkaveh' => esc_html__( '#', 'kavehTheme' ),
          ],
      ]
      ]
    
    );

    
       $this->end_controls_section();
       $this->start_controls_section(
        'content3categorycarouseltwentyseventhstkaveh',
        [
          'label' => esc_html__( 'Carousel Settings', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );
      $this->add_control(
        'productcolumncategorycarouseltwentyseventhstkaveh',
        [
          'label' => esc_html__( 'Number of Category Columns on Desktop', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::NUMBER,
          'min' => 0,
          'max' => 8,
          'step' => 1,
          'default' => 3,
      
        ]
      );
      $this->add_control(
        'productcolumn2categorycarouseltwentyseventhstkaveh',
        [
          'label' => esc_html__( 'Number of Category Columns on Tablet', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::NUMBER,
          'min' => 0,
          'max' => 5,
          'step' => 1,
          'default' => 2,
      
        ]
      );
      $this->add_control(
        'productcolumn3categorycarouseltwentyseventhstkaveh',
        [
          'label' => esc_html__( 'Number of Category Columns on Mobile', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::NUMBER,
          'min' => 0,
          'max' => 5,
          'step' => .1,
          'default' => 1.4,
      
        ]
      );
       $this->end_controls_section();


       $this->start_controls_section(
          'styletitlecategorycarouseltwentyseventhstkaveh',
          [
            'label' => esc_html__( 'Category Title Style', 'kavehTheme' ),
            'tab' => \Elementor\Controls_Manager::TAB_STYLE,
          ]
        );

         $this->add_control(
            'titlecolorcategorycarouseltwentyseventhstkaveh',
            [
              'label' => esc_html__( 'Main Title Color', 'kavehTheme' ),
              'type' => \Elementor\Controls_Manager::COLOR,
              'selectors' => [
                '{{WRAPPER}} .categories-travel-equipment-title' => 'color: {{VALUE}}!important',
              ],
            ]
          );


           $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'titletypogrphicategorycarouseltwentyseventhstkaveh',
          'label' => esc_html__( 'Pre-title Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .categories-travel-equipment-title',
        ]
      );
      $this->end_controls_section();

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

      $this->add_control(
        'boxallradiustcustomerreviewlkaveh',
        [
          'label' => esc_html__( 'Image Rounded Corners', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [
            '{{WRAPPER}}  .categories-travel-equipment-item img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
          ]
        ]
      );


      $this->add_control(
        'catimg1height2categorycarouseltwentyeighthstkaveh',
        [
          'label' => esc_html__( 'Category Image Height', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 1000,
              'step' => 1,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .categories-travel-equipment-item img' => 'height: {{SIZE}}{{UNIT}};',
          ],
        ]
      );


      $this->add_control(
        'title2colorcategorycarouseltwentyseventhstkaveh',
        [
          'label' => esc_html__( 'Category Title Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .categories-travel-equipment-item .title' => 'color: {{VALUE}}!important',
          ],
        ]
      );

      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'title3typogrphicategorycarouseltwentyseventhstkaveh',
          'label' => esc_html__( 'Category Title Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .categories-travel-equipment-item .title',
        ]
      );

      $this->add_control(
        'boxcolorcategorycarouseltwentyseventhstkaveh',
        [
          'label' => esc_html__( 'Box Color Change', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .categories-travel-equipment-item' => 'background-color: {{VALUE}}!important',
          ],
        ]
      );

      $this->add_control(
        'boxallradiustcustomerreviewlkaveh',
        [
          'label' => esc_html__( 'Box Rounded Corners', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [
            '{{WRAPPER}}  .categories-travel-equipment-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
          ]
        ]
      );
      $this->add_control(
        'boxmarginatemarginComment',
        [
            'label' => esc_html__('Box Margin', 'kavehTheme'),
            'type' => \Elementor\Controls_Manager::DIMENSIONS,
            'size_units' => ['px', '%', 'em'],
            'selectors' => [
                '{{WRAPPER}} .categories-travel-equipment-item' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
            ],
        ]
    );
    
    $this->add_control(
        'boxpaddingatepaddingComment',
        [
            'label' => esc_html__('Box Padding', 'kavehTheme'),
            'type' => \Elementor\Controls_Manager::DIMENSIONS,
            'size_units' => ['px', '%', 'em'],
            'selectors' => [
                '{{WRAPPER}} .categories-travel-equipment-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
            ],
        ]
    );

    $this->add_control(
      'arrowbootonolorcategorycarouseltwentyseventhstkaveh',
      [
        'label' => esc_html__( 'Slider Top Icon Color Change', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
          '{{WRAPPER}} .categories-travel-equipment-wrapper .scroll-to' => 'color: {{VALUE}}',
        ],
      ]
    );
    $this->end_controls_section();

    $this->start_controls_section(
      'Controlercategorycarouseltwentyseventhstkaveh',
      [
        'label' => esc_html__( 'Controllers Style', 'kavehTheme' ),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
      ]
    );

    $this->add_control(
      'arrowsliderlcolorcategorycarouseltwentyseventhstkaveh',
      [
        'label' => esc_html__( 'Controllers Background Color Change', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
          '{{WRAPPER}} .swiper-buttons-travel-equipment .swiper-button-next::before' => 'background-color: {{VALUE}}',
        ],
      ]
    );

      $this->end_controls_section();
        }


 

        protected function render(){
          $settings = $this->get_settings_for_display();
          $clsid = $this->get_id();
          ?>
          <div class="categories-travel-equipment">
            <div class="container">
              <div class="categories-travel-equipment-wrapper position-relative mx-auto w-100">
                <button type="button" class="scroll-to position-absolute start-50 translate-middle-x p-0">
                  <svg xmlns="http://www.w3.org/2000/svg" width="41" height="37" fill="none" viewBox="0 0 41 37">
                    <path stroke="currentColor" stroke-linecap="round" stroke-opacity=".5" stroke-width="2.387" d="m30.436 11.935-8.95 6.318c-.66.466-1.731.466-2.391 0l-8.95-6.318"></path>
                    <path stroke="currentColor" stroke-linecap="round" stroke-width="2.387" d="m30.436 20.29-8.95 6.318c-.66.466-1.731.466-2.391 0l-8.95-6.318"></path>
                  </svg>            
                </button>
                <div class="bg position-absolute top-0 end-0 w-100">
                  <span></span>
                </div>
                <div class="shape shape-1 position-absolute"></div>
                <div class="shape shape-2 position-absolute"></div>
                <div class="categories-travel-equipment-title text-center fw-bold mb-3 text-white">
                  <?php echo esc_html($settings['wigti2categorycarouseltwentyseventhstkaveh']); ?>
                </div>
                <!-- Start Carousel -->
                <div class="swiper swiper-categories-travel-equipment swiper-visible swiper-visibled-mobile swiper-initialized swiper-horizontal swiper-pointer-events swiper-autoheight swiper-rtl swiper-watch-progress swiper-backface-hidden">
                  <div class="swiper-wrapper" id="swiper-wrapper-dcb115869431c340" aria-live="polite" style="height: 185px; transform: translate3d(0px, 0px, 0px);">
                  <?php
                    if (!empty($settings['listcategorycarouseltwentyseventhstkaveh'])) {
                        foreach ($settings['listcategorycarouseltwentyseventhstkaveh'] as $item) {
                    ?>
                    <!-- Start Slide -->
                    <div class="swiper-slide swiper-slide-visible swiper-slide-active" role="group" aria-label="1 / 8" style="width: 198.75px; margin-left: 24px;">
                      <a href="<?php echo esc_url($item['linkcategorycarouseltwentyseventhstkaveh']); ?>" class="categories-travel-equipment-item d-flex flex-column bg-white h-100">
                        <img src="<?php echo esc_url($item['img1categorycarouselsevenkaveh']['url']); ?>" alt="category" width="115" height="115" class="w-auto m-auto">
                        
                        <<?php echo $item['tagheading1categorycarouseltwentyseventhstkaveh']; ?> class="title text-center">
                          <?php echo esc_html($item['title1categorycarouseltwentyseventhstkaveh']); ?>
                        </<?php echo $item['tagheading1categorycarouseltwentyseventhstkaveh']; ?>>
      
                      </a>
                    </div>
                    <!-- End Slide -->
                    <?php
                       }
                    }
                    ?>
                  </div>
                  <!-- Start Buttons -->
                  <div class="swiper-buttons swiper-buttons-travel-equipment d-flex align-items-center justify-content-center">
                    <div class="swiper-button-prev position-relative top-0 start-0 bottom-0 end-0 w-auto h-auto m-0 swiper-button-disabled" tabindex="-1" role="button" aria-label="Previous slide" aria-controls="swiper-wrapper-dcb115869431c340" aria-disabled="true">
                      <i class="icon-arrow-right-8 lh-1"></i>
                    </div>
                    <div class="swiper-button-next position-relative top-0 start-0 bottom-0 end-0 w-auto h-auto m-0" tabindex="0" role="button" aria-label="Next slide" aria-controls="swiper-wrapper-dcb115869431c340" aria-disabled="false">
                      <i class="icon-arrow-left-8 lh-1"></i>
                    </div>
                  </div>
                  <!-- End Buttons -->
                <span class="swiper-notification" aria-live="assertive" aria-atomic="true"></span></div>
                <!-- End Carousel -->
              </div>
            </div>
          </div>
      
      <style>
        .categories-travel-equipment-item img {
          object-fit: contain !important;
        }
        .categories-travel-equipment-item img {
          background-size: contain !important;
        }
      </style>
      
      
      <?php
      }
    }
