function getHtmlByCurrentPage({ currentPage }) {
    const pagesData = Wick.VatToggle.isToggleVatAvailable()
        ? Wick.FEMock.productListVatPagesData
        : Wick.FEMock.productListPagesData;
    const matchingData = pagesData.find((item) => item.page === currentPage);

    return matchingData.html;
}

function initPLPLoadMoreFunctionality() {
    $(window).on(
        Wick.PLPLoadMore?.PLP_LOAD_MORE_EVENT,
        function ({ detail: { resolve, payload } }) {
            setTimeout(() => {
                resolve(getHtmlByCurrentPage(payload));
            }, 1500);
        }
    );
}

$(document).ready(function () {
    if (!$('.btn-load-more').length) {
        return;
    }

    initPLPLoadMoreFunctionality();
});
