<?php $__env->startSection('content'); ?>
    <style>
        .description-ellipsis {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

    </style>
    <div class="preLoader black">
        <img src="<?php echo e(asset('front/images/logo.png')); ?>" alt="img">
    </div>
    <div class="preLoader white"></div>

    <div class="mouse-cursor cursor-outer"></div>
    <div class="mouse-cursor cursor-inner"></div>

    <section class="mainSlider">
        <div class="swiper-container homeSlider">
            <div class="swiper-wrapper">
                <?php $__currentLoopData = $sliders; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $slider): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="swiper-slide">
                        <div class="slide-inner bg-image" data-background="<?php echo e(asset($slider->image_url)); ?>">
                            <div class="container">
                                <div class="row align-items-center justify-content-center">
                                    <div class="col-md-6">
                                        <div class="slideContent slideOne">
                                            <p><?php echo e($slider->heading); ?></p>
                                            <a href="<?php echo e(route('front.product')); ?>" class="themeBtn">Shop By Category</a>

                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
        </div>
    </section>


    <section class="productMain">
        <div class="container">
            <h2 class="heading">New Products/Merchandise</h2>
            <div class="row">
                <div class="col-md-12">
                    <a href="#" class="allpro">ALL PRODUCTS</a>
                </div>
                <?php $__empty_1 = true; $__currentLoopData = $data['products']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <div class="col-md-3">
                        <div class="proBox">
                            <ul class="iconShow">
                                <li><a href="<?php echo e(route('front.product')); ?>"><i class="far fa-search"></i></a></li>
                                <li><a href="#" class="img-fluid compareProduct" alt="img" data-product-id="<?php echo e($product->id); ?>"><i class="fa fa-random" aria-hidden="true"></i></a></li>

                                <li><a href="<?php echo e(route('wishlist.show')); ?>" class="addToWishlist" data-product-id="<?php echo e($product->id); ?>"><i class="fal fa-heart"></i></a></li>
                            </ul>
                            <a href="<?php echo e(route('front.shop.product' , ['slug' => $product->slug])); ?>">
                                <div class="proImg">
                                    <figure>
                                        <img
                                            src="<?php echo e($product->productImage() ?? asset('front/images/default-product-image.jpg')); ?>"
                                            class="img-fluid" alt="img">
                                        <img
                                            src="<?php echo e($product->productImage() ?? asset('front/images/default-product-image.jpg')); ?>"
                                            class="img-fluid" alt="img">
                                    </figure>
                                </div>
                                <div class="proContent">
                                    <h2><?php echo e($product->name ?? 'Product Name'); ?></h2>
                                    <p class="description-ellipsis"><?php echo e($product->description ?? ''); ?></p>
                                    <form method="post" action="<?php echo e(route('chat.startConversation')); ?>">
                                        <?php echo csrf_field(); ?>
                                        <input type="hidden" name="product_id" value="<?php echo e($product->id); ?>">
                                        <input type="hidden" name="user_id" value="<?php echo e(auth()->user()->id ?? ''); ?>">
                                        <input type="hidden" name="quotation" value="<?php echo e('000'); ?>">
                                        <!-- Assuming $quotation is available in your view -->
                                        <button type="submit" class="offerBtn">Make Offer</button>
                                    </form>
                                    <h6>$<?php echo e($product->price ?? '0.00'); ?></h6>
                                    
                                </div>
                            </a>
                        </div>
                    </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <p>Sorry!! No products found</p>
                <?php endif; ?>

            </div>
        </div>
        <div class="swiper-button-next2"><span data-hover="NEXT"></span></div>


        <div class="col-md-12 text-center mt-4">
            <a href="<?php echo e(route('front.product')); ?>" class="themeBtn">View All</a>
        </div>

    </section>



    <section class="moneyMain">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <ul>
                        <li>
                            <figure><img src="<?php echo e(asset('front/images/moneyreturn.png')); ?>" class="img-fluid" alt="img">
                            </figure>
                            <div>
                                <h4>Money return</h4>
                                <p>Back guarantee under 7 days</p>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </section>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('script'); ?>
    <script>
        $(document).ready(function() {
            var isAddingToWishlist = false;

            $('body').on('click', '.addToWishlist', function(e) {
                e.preventDefault();

                var productId = $(this).data('product-id');

                if (!isAddingToWishlist) {
                    // Single click
                    $.ajax({
                        url: "<?php echo e(route('wishlist.add')); ?>",
                        type: "POST",
                        data: {
                            product_id: productId,
                            _token: "<?php echo e(csrf_token()); ?>",
                        },
                        beforeSend: function() {
                            isAddingToWishlist = true;
                        },
                        success: function(response) {
                            alert(response.success); // Show success message
                        },
                        error: function(xhr, status, error) {
                            if (xhr.status === 401) {
                                alert('You must be logged in to add products to the wishlist');
                            } else if (xhr.status === 400) {
                                alert('Product is already in the wishlist');
                            } else {
                                console.error(xhr.responseText);
                                alert('Failed to add product to wishlist');
                            }
                        },

                        complete: function() {
                            isAddingToWishlist = false;
                        }
                    });
                }
            });

            // Double-click event handler
            $('body').on('dblclick', '.addToWishlist', function(e) {
                e.preventDefault();

                var wishlistUrl = "<?php echo e(route('wishlist.show')); ?>";
                window.location.href = wishlistUrl; // Redirect to wishlist page
            });
        });


    </script>
    <script>
        $(document).ready(function() {
            var isAddingToCompare = false;

            $('body').on('click', '.compareProduct', function(e) {
                e.preventDefault();

                var productId = $(this).data('product-id');
                var compareUrl = "<?php echo e(route('compare.show')); ?>";

                if (!isAddingToCompare) {
                    $.ajax({
                        url: "<?php echo e(route('compare.add')); ?>",
                        type: "POST",
                        data: {
                            product_id: productId,
                            _token: "<?php echo e(csrf_token()); ?>",
                        },
                        beforeSend: function() {
                            isAddingToCompare = true;
                        },
                        success: function(response) {

                            $('.compareProduct[data-product-id="' + productId + '"]').html('<i class="fas fa-check"></i>');
                            alert(response.success);
                        },
                        error: function(xhr, status, error) {
                            if (xhr.status === 400) {
                                alert('Product is already in the comparison');
                            } else if (xhr.status === 500) {
                                alert('Failed to add product to compare');
                            } else {
                                console.error(xhr.responseText);
                                alert('something went wrong');
                            }
                        },
                        complete: function() {
                            isAddingToCompare = false;
                        }
                    });
                }
            });

            $('body').on('dblclick', '.compareProduct', function(e) {
                e.preventDefault();

                var compareUrl = "<?php echo e(route('compare.show')); ?>";
                window.location.href = compareUrl; // Redirect to compare page
            });
        });
    </script>





<?php $__env->stopSection(); ?>





<?php echo $__env->make('front.layout.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/servicedemoweb/public_html/premiere-deals/resources/views/front/pages/index1.blade.php ENDPATH**/ ?>