<?php
    $html_id = pxl_get_element_id($settings);

    $is_items = isset($settings['items']) && !empty($settings['items']) && count($settings['items']) || false;
    
    // Grid
    $col_xs = $widget->get_setting('col_xs', '');
    $col_sm = $widget->get_setting('col_sm', '');
    $col_md = $widget->get_setting('col_md', '');
    $col_lg = $widget->get_setting('col_lg', '');
    $col_xl = $widget->get_setting('col_xl', '');
    $col_xxl = $widget->get_setting('col_xxl', '');
    
    // Animation
    $animate = $widget->get_setting('pxl_animate');
    $animate_delay = (int)$widget->get_setting('pxl_animate_delay', 0);
    
    $img_size = $settings['img_size'] ?? 'full';

    $pause_on_hover = !empty($settings['pause_on_hover']) || false;
    $autoplay = !empty($settings['autoplay']) || false;
    $autoplay_speed = !empty($settings['autoplay_speed']) ? $settings['autoplay_speed'] : 5000;
    $infinite = !empty($settings['infinite']) || false;
    $speed = !empty($settings['speed']) ? $settings['speed'] : 500;
    $arrows = !empty($settings['arrows']) || false;
    $pagination = !empty($settings['pagination']) || false;
    $pagination_type = $settings['pagination_carousel_type'];

    $opts = [
        'slide_direction'               => 'horizontal',
        'slide_percolumn'               => 1, 
        'slide_mode'                    => 'slide', 
        'slides_to_show'                => 1,
        'slides_to_show_xxl'            => $col_xxl,
        'slides_to_show_xl'             => $col_xl,
        'slides_to_show_lg'             => $col_lg,
        'slides_to_show_md'             => $col_md,
        'slides_to_show_sm'             => $col_sm,
        'slides_to_show_xs'             => $col_xs,
        'slides_to_scroll'              => 1,
        'arrow'                         => $arrows,
        'pagination'                    => $pagination,
        'pagination_type'               => $pagination_type,
        'autoplay'                      => $autoplay,
        'pause_on_hover'                => $pause_on_hover,
        'pause_on_interaction'          => true,
        'delay'                         => $autoplay_speed,
        'loop'                          => $infinite,
        'speed'                         => $speed
    ];
    $widget->add_render_attribute( 'carousel', [
        'class'         => 'pxl-swiper-container',
        'dir'           => is_rtl() ? 'rtl' : 'ltr',
        'data-settings' => wp_json_encode($opts)
    ]);

?>

<?php if ($is_items): ?>
    <div class="pxl-swiper-slider pxl-workflow-steps pxl-workflow-steps2">
        <div class="pxl-carousel-inner">
            <div <?php pxl_print_html($widget->get_render_attribute_string( 'carousel' )); ?>>
                <div class="pxl-item--curve wow svg-grow-width" data-wow-duration="<?php echo esc_attr('3000ms'); ?>">
                    <svg class="pxl-svg--curve" xmlns="http://www.w3.org/2000/svg" width="924" height="98" viewBox="0 0 924 98" fill="none">
                        <path d="M1 35.9999C59 71.3332 196.6 128.8 283 75.9999C391 9.99987 463 -32.0001 619 35.9999C775 104 865 81.9999 923 35.9999" stroke="#565969" stroke-dasharray="4 4"/>
                    </svg>
                </div>
                <div class="pxl-swiper-wrapper">
                    <?php foreach ($settings['items'] as $key => $item): ?>
                        <?php  
                            $image = solarva_get_thumbnail($item['image']['id'], $img_size); 
                            $title = $item['title'] ?? '';    
                            $desc = $item['desc'] ?? '';  
                            $index = '0'.(string)($key + 1);
                            $wow_delay = $key * $animate_delay;
                        ?>
                        <div class="pxl-swiper-slide <?php  echo esc_attr($animate); ?>" data-wow-delay="<?php echo esc_attr($wow_delay.'ms'); ?>">
                            <div class="pxl-slide--container <?php echo esc_attr('pxl-item-step'.$index.' '.'elementor-repeater-item-'.$item['_id']); ?>">
                                <div class="pxl-slide-inner">
                                    <?php if(!empty($image)) : ?>
                                        <div class="pxl-item--image ">
                                            <div class="pxl-item--group">
                                                <?php pxl_print_html($image); ?>
                                                <span class="pxl-item--index">
                                                    <?php echo esc_attr($index); ?>
                                                </span>
                                            </div>
                                        </div>
                                    <?php endif; ?>
                                    <div class="pxl-item--content">
                                        <h3 class="pxl-item--title el-empty">
                                            <?php echo esc_attr($title); ?>
                                        </h3>
                                        <div class="pxl-item--desc el-empty">
                                            <?php echo esc_attr($desc); ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    <?php endforeach; ?>
                </div>
            </div>
        </div>
        <?php solarva_swiper_controls($pagination, $arrows); ?>
    </div>
<?php endif; ?>


