<?php
if ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly

$post_item_cls = 'post-item';
if( $settings['layout'] == 'carousel' ) {
    $post_item_cls .= ' swiper-slide';
}

?>
<div class="<?php echo esc_attr($post_item_cls); ?>">
    <article class="post-wrapper">
	    <?php if($settings['terms_position'] == 'top' || $settings['title_position'] == 'top' || $settings['meta_position'] == 'top'): ?>
        <div class="content-wrapper-top">
	        <?php if($settings['terms_position'] == 'top') { $this->render_terms(); } ?>
	        <?php if($settings['title_position'] == 'top') { $this->render_title(); } ?>
	        <?php if($settings['meta_position'] == 'top'): ?>
                <div class="meta-wrapper">
	                <?php if($settings['author_position'] == 'inline') { $this->render_author(); }; ?>
			        <?php $this->render_date(); ?>
			        <?php $this->render_comments(); ?>
			        <?php $this->render_views_count(); ?>
			        <?php $this->render_reading_time(); ?>
                </div>
	        <?php endif; ?>
        </div>
	    <?php endif; ?>
        <?php if(has_post_thumbnail()): ?>
        <div class="image-outer-wrapper">
            <div class="image-wrapper">
                <?php
                $thumb_args = [ 'title' => get_the_title() ];
                if(0 <= $current_post_num && $current_post_num < intval($settings['skip_lazy_loading']) ) {
                    $thumb_args ['loading'] = 'eager'; // Defaults is 'lazy'
                }
                the_post_thumbnail($settings['thumbnail_size'], $thumb_args);
                ?>
		        <?php
		        if($settings['image_link']) {
			        echo '<a class="image-link rivax-position-cover" aria-label="Item Link" href="' . get_permalink() . '"></a>';
		        }
		        ?>
                <?php if($settings['meta_date_position'] == 'inside-image'): ?>
                    <div class="date-in-out-image date-inside-image rivax-position-<?php echo esc_attr($settings['date_inside_image_position']); ?>">
                        <span class="day"><?php echo get_the_date('d') ?></span>
                        <span class="month"><?php echo get_the_date('M') ?></span>
                    </div>
                <?php endif; ?>
		        <?php $this->render_top_content(); ?>
		        <?php $this->render_post_format_icon(); ?>

		        <?php if($settings['author_position'] == 'inside-top' || $settings['terms_position'] == 'inside-top'): ?>
                    <div class="content-wrapper-inside rivax-position-top">
				        <?php if($settings['terms_position'] == 'inside-top') { $this->render_terms(); }; ?>
				        <?php if($settings['author_position'] == 'inside-top') { $this->render_author(); }; ?>
                    </div>
		        <?php endif; ?>

		        <?php if($settings['terms_position'] == 'inside' || $settings['title_position'] == 'inside'): ?>
                    <div class="content-wrapper-inside rivax-position-bottom">
				        <?php if($settings['terms_position'] == 'inside') { $this->render_terms(); } ?>
				        <?php if($settings['title_position'] == 'inside') { $this->render_title(); } ?>
                    </div>
		        <?php endif; ?>

                <?php
                if($settings['show_image_svg_cover']) {
                    rivax_svg_cover ($settings['image_svg_cover']);
                }
                ?>

            </div>
            
	        <?php if($settings['counter_position'] == 'inside-image'): ?>
                <div class="post-counter-wrap counter-inside-image rivax-position-<?php echo esc_attr($settings['counter_inside_position']); ?>">
                    <span class="post-counter"></span>
                </div>
	        <?php endif; ?>

        </div>
        <?php endif; ?>
        <div class="content-wrapper">
	        <?php if($settings['counter_position'] == 'outside-image'): ?>
                <div class="post-counter-wrap counter-outside-image rivax-position-<?php echo esc_attr($settings['counter_inside_position']); ?>">
                    <span class="post-counter"></span>
                </div>
	        <?php endif; ?>
            <?php if($settings['terms_position'] == 'outside') { $this->render_terms(); } ?>
            <?php if($settings['title_position'] == 'outside') { $this->render_title(); } ?>
            <?php if($settings['meta_position'] == 'outside'): ?>
            <div class="meta-wrapper">
	            <?php if($settings['author_position'] == 'inline') { $this->render_author(); }; ?>
                <?php $this->render_date(); ?>
                <?php $this->render_comments(); ?>
                <?php $this->render_views_count(); ?>
                <?php $this->render_reading_time(); ?>
            </div>
            <?php endif; ?>
            <?php $this->render_excerpt(); ?>
            <?php $this->render_read_more(); ?>
        </div>
    </article>
</div>