<?php



use Elementor\Widget_Base;
use Elementor\Controls_Manager;

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


class Imageboxcarouselfirststkaveh extends Widget_Base{

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

  public function get_title(){
    return esc_html__( 'Image Box Carousel One', 'kavehTheme' );
  }

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

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

  protected function register_controls(){
    
    $this->start_controls_section(
        'contentimageboxcarouselfirststkaveh',
        [
          'label' => esc_html__( 'Element Content', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );
      $repeater = new \Elementor\Repeater();
      $repeater->add_control(
        'imgboxcarousl',
        [
          'label' => esc_html__( 'Background Image', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::MEDIA,
        ]
      );
  
      $repeater->add_control(
      'titleimgboxCarousel',
      [
        'label' => esc_html__( 'Title', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => esc_html__( 'Microsoft', 'kavehTheme' ),

      ]
    );
    $repeater->add_control(
      'tagheading1imageboxcarouselfirststkaveh',
      [
        '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(
      'linkimageboxcarouselfirststkaveh',
      [
        'label' => esc_html__( 'Link', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => '#',
      ]
    );
    $this->add_control(
      'listimageboxcarouselfirststkaveh',
      [
        'label' => esc_html__( 'Categories', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::REPEATER,
        'fields' => $repeater->get_controls(),
        'default' => [
          [
            'title1imageboxcarouselfirststkaveh' => esc_html__( 'Title', 'kavehTheme' ),
            'title2imageboxcarouselfirststkaveh' => esc_html__( 'Subtitle', 'kavehTheme' ),
            'linkimageboxcarouselfirststkaveh' => esc_html__( '#', 'kavehTheme' ),
          ],
      ]
      ]
    
    );
       $this->end_controls_section();


       $this->start_controls_section(
        'content3imageboxcarouselfirststkaveh',
        [
          'label' => esc_html__( 'Carousel Settings', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );
      $this->add_control(
        'productcolumnimageboxcarouselfirststkaveh',
        [
          '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(
        'productcolumn2imageboxcarouselfirststkaveh',
        [
          '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(
        'productcolumn3imageboxcarouselfirststkaveh',
        [
          '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(
        'stylet_iconboxthreethstkaveh',
        [
          'label' => esc_html__( 'Box Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );


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



      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'ftitletyt_imageboxcarouselfirststkaveh',
          'label' => esc_html__( 'Main Title Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .title',
        ]
      );


      $this->add_control(
        'catimg1height2imageboxcarouselfirststkaveh',
        [
          'label' => esc_html__( 'Box Image Height', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 1000,
              'step' => 1,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .shopping-guide-box .image img' => 'height: {{SIZE}}{{UNIT}};',
          ],
        ]
      );

      $this->add_control(
        'BackgroundColorbox',
        [
            'label' => esc_html__( 'Box Background Change', 'kavehTheme' ),
            'type' => \Elementor\Controls_Manager::COLOR,
            'selectors' => [
                '{{WRAPPER}} .shopping-guide-box::before' => 'background-color: {{VALUE}}',
            ],
        ]
    );

    $this->add_control(
      'BackgroundborderColorbox',
      [
          'label' => esc_html__( 'Border Background Change', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
              '{{WRAPPER}} .shopping-guide-box::after' => 'background-color: {{VALUE}}',
          ],
      ]
  );


  $this->add_control(
    'borderradiusboxCarouslone',
    [
      'label' => esc_html__( 'Border Radius', 'kavehTheme' ),
      'type' => \Elementor\Controls_Manager::DIMENSIONS,
      'size_units' => [ 'px' ],
      'selectors' => [ 
        '{{WRAPPER}} .shopping-guide-box::before' => 'border-radius: {{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();
          ?>
          <div class="container">
              <div class="swiper swiper-shopping-guide 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-<?php echo esc_attr($clsid); ?>" aria-live="polite" style="height: 187px; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;">
                      <?php foreach ($settings['listimageboxcarouselfirststkaveh'] as $item): ?>
                          <div class="swiper-slide swiper-slide-active swiper-slide-visible" role="group" aria-label="1 / 5" style="width: 195.2px; margin-left: 80px;">
                              <a href="<?php echo esc_url($item['linkimageboxcarouselfirststkaveh']); ?>" class="shopping-guide-box d-flex align-items-center justify-content-center flex-column h-100 position-relative">
                                  <span class="image position-relative">
                                      <img src="<?php echo esc_url($item['imgboxcarousl']['url']); ?>" alt="shopping guide" width="139" height="103" class="d-block mx-auto">
                                  </span>
                                  <<?php echo  esc_attr($item['tagheading1imageboxcarouselfirststkaveh']);?> class="title text-center">
                  <?php echo  esc_html($item['titleimgboxCarousel']); ?>
                  </<?php echo  esc_attr($item['tagheading1imageboxcarouselfirststkaveh']); ?>>
                                  
                              </a>
                          </div>
                      <?php endforeach; ?>
                  </div>
                  <span class="swiper-notification" aria-live="assertive" aria-atomic="true"></span>
              </div>
          </div>
      
          <style>
              .shopping-guide-box .image img {
                  object-fit: contain !important;
              }
              .categories-products-item .btn::before {
                  background-size: contain !important;
              }
          </style>
          
          <?php
      }
    }
