import React from 'react';
import { LocalLabelsProvider, ListingPageProvider, useListingInjectedContent, RenderInjectedContent, BasicListingSEO } from '@sentecacommerce-theme/lib';
import { ListingPageComponent } from './Components';
import { useRouter } from 'next/router';
var listingContentUnderTitleKey = 'afterTitle';
export var ListingPage = (_ref) => {
  var {
    seoAggregates,
    aggregates,
    sortOptions,
    defaultSortKey,
    categoryTreeConfig,
    labels,
    productsPerPage
  } = _ref;
  var router = useRouter();
  var content = useListingInjectedContent({
    path: router.asPath,
    currentPage: router.query.page || '1'
  });
  return /*#__PURE__*/React.createElement(ListingPageProvider, {
    config: {
      seoAggregates,
      aggregates,
      categoryTreeConfig,
      sortOptions,
      defaultSortKey,
      productsPerPage
    }
  }, /*#__PURE__*/React.createElement(LocalLabelsProvider, {
    labels: labels
  }, /*#__PURE__*/React.createElement(RenderInjectedContent, {
    componentList: content.before.filter(c => {
      var _c$positionMetadata;

      return !((_c$positionMetadata = c.positionMetadata) != null && _c$positionMetadata.includes(listingContentUnderTitleKey));
    })
  }), /*#__PURE__*/React.createElement(BasicListingSEO, null), /*#__PURE__*/React.createElement(ListingPageComponent, {
    contentInside: content.inside,
    contentUnderTitle: content.before.filter(c => {
      var _c$positionMetadata2;

      return (_c$positionMetadata2 = c.positionMetadata) == null ? void 0 : _c$positionMetadata2.includes(listingContentUnderTitleKey);
    })
  }), /*#__PURE__*/React.createElement(RenderInjectedContent, {
    componentList: content.after
  })));
};
//# sourceMappingURL=listingPage.component.js.map