<?php
$carousel_settings = kaitex_carousel_header($widget, array());

$img_size = $widget->get_setting('img_size', 'full');

if(isset($settings['list']) && !empty($settings['list']) && count($settings['list'])): ?>
    <div class="pxl-swiper-sliders pxl-pricing-carousel pxl-pricing-carousel1 pxl-parent-cursor pxl-drag-area <?php echo esc_attr($settings['pxl_animate']); ?>" data-wow-delay="<?php echo esc_attr($settings['pxl_animate_delay']); ?>ms" data-wow-duration="<?php echo esc_attr($settings['pxl_animate_duration']); ?>s" data-arrow="<?php echo esc_attr($carousel_settings['arrows']); ?>">
        <div class="pxl-carousel-inner">
            <div <?php pxl_print_html($widget->get_render_attribute_string( 'carousel' )); ?>>
                <div class="pxl-swiper-wrapper">
                    <?php foreach ($settings['list'] as $key => $value):
                        $price = isset($value['price']) ? $value['price'] : '';
                        $prefix = isset($value['prefix']) ? $value['prefix'] : '';
                        $suffix = isset($value['suffix']) ? $value['suffix'] : '';
                        $plan_text = isset($value['plan_text']) ? $value['plan_text'] : '';
                        $lists = isset($value['lists']) ? $value['lists'] : '';
                        $image = isset($value['image']) ? $value['image'] : '';
                        $btn_text = isset($value['btn_text']) ? $value['btn_text'] : '';
                        $btn_link = isset($value['btn_link']) ? $value['btn_link'] : '';
                        $link_key = $widget->get_repeater_setting_key( 'btn_link', 'value', $key );
                        if ( ! empty( $btn_link['url'] ) ) {
                            $widget->add_render_attribute( $link_key, 'href', $btn_link['url'] );

                            if ( $btn_link['is_external'] ) {
                                $widget->add_render_attribute( $link_key, 'target', '_blank' );
                            }

                            if ( $btn_link['nofollow'] ) {
                                $widget->add_render_attribute( $link_key, 'rel', 'nofollow' );
                            }
                        }
                        $link_attributes = $widget->get_render_attribute_string( $link_key );
                        ?>
                        <div class="pxl-swiper-slide">
                            <div class="pxl-item--inner">
                                <?php if (!empty($price)) : ?>
                                    <div class="item--number">
                                        <?php if(!empty($prefix)) : ?>
                                            <span class="text--prefix"><?php echo pxl_print_html($prefix); ?></span>
                                        <?php endif; ?>
                                        <span class="text--price"><?php echo pxl_print_html($price); ?></span>
                                        <?php if(!empty($suffix)) : ?>
                                            <span class="text--suffix"><?php echo pxl_print_html($suffix); ?></span>
                                        <?php endif; ?>
                                    </div>
                                <?php endif; ?>
                                <?php if (!empty($plan_text)) : ?>
                                    <div class="item--plan"><?php echo pxl_print_html($plan_text); ?></div>
                                <?php endif; ?>
                                <?php $price_lists = json_decode($lists, true);
                                if(!empty($price_lists)): ?>
                                    <ul class="item--content">
                                        <?php foreach ($price_lists as $value):
                                            if(!empty($value['content'])) { ?>
                                                <li>
                                                    <?php if (!empty($value['url'])) { ?>
                                                    <a aria-label="<?php echo pxl_print_html($value['content']); ?>" href="<?php echo esc_url($value['url']); ?>" target="_blank"> <?php } ?>
                                                        <?php echo pxl_print_html($value['content']); ?>
                                                    <?php if (!empty($value['url'])) { ?> </a> <?php } ?>
                                                </li>
                                            <?php }
                                        endforeach; ?>
                                    </ul>
                                <?php endif; ?>
                                <?php if ( !empty($image['id']) ) :
                                    $img_icon  = pxl_get_image_by_size( array(
                                        'attach_id'  => $image['id'],
                                        'thumb_size' => $img_size,
                                    ) );
                                    $thumbnail_icon = $img_icon['thumbnail']; ?>
                                    <div class="item--image">
                                        <?php echo pxl_print_html($thumbnail_icon); ?>
                                    </div>
                                <?php endif; ?>
                                <?php if (!empty($btn_text) && !empty($btn_link['url'])) : ?>
                                    <a aria-label="<?php echo pxl_print_html($btn_text); ?>" <?php echo implode( ' ', [ $link_attributes ] ); ?> class="item--button btn-default style2">
                                        <span><?php echo pxl_print_html($btn_text); ?></span>
                                    </a>
                                <?php endif; ?>
                           </div>
                        </div>
                    <?php endforeach; ?>
                </div>
            </div>
            <?php kaitex_carousel_footer($carousel_settings['arrows'], $carousel_settings['arrows_style'], $carousel_settings['pagination'], $carousel_settings['bullets_style']); ?>
        </div>
    </div>
<?php endif; ?>
