const cartSliderHTML = '<div class="custom-slider just-added d-none"></div>';

createPopupSlider({
    type: 'cart',
    sliderSelector: '.custom-slider.just-added',
    onAppendEvent: 'productAddedToCart',
    onAppend: function (event, { showSlider, handleScroll, el }) {
        Wick.MiniBasketSliderFE.isMiniBasketLoaded = false;

        if (event.detail.bulkAddToCartData) {
            return;
        }

        if (!$('.custom-slider.just-added').length) {
            $('body').append(cartSliderHTML);
        }

        const htmlContent = event.detail.html;

        if (htmlContent) {
            $(el.slider).append(htmlContent);
        }

        showSlider();

        if ($(el.sliderWrap).length) {
            $(el.sliderWrap).on(
                'scroll',
                _.debounce(() => handleScroll(el.sliderWrap), 100)
            );
        }
    },
    onClose: function () {
        Wick.MiniBasketSliderFE.cartEntries = [];
    },
});
