"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var _chunkPPUM3LLNjs = require('./chunk-PPUM3LLN.js');


var _chunkXEC3A24Jjs = require('./chunk-XEC3A24J.js');


var _chunkJKLLUSG3js = require('./chunk-JKLLUSG3.js');

// tmp-babel/content-feed/web/PostList/index.js
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
var _displays = require('@baseapp-frontend/design-system/components/web/displays');
var _material = require('@mui/material');
var _reactvirtuoso = require('react-virtuoso');
var _jsxruntime = require('react/jsx-runtime');
var Scroller = /* @__PURE__ */ _react2.default.forwardRef(function(_ref, ref) {
  var style = _ref.style, children = _ref.children;
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkPPUM3LLNjs.PostsListContainer, {
    style,
    ref,
    children
  });
});
var PostList = function PostList2(_ref2) {
  var preloadedQuery = _ref2.preloadedQuery;
  var _useContentPosts = _chunkJKLLUSG3js.useContentPosts.call(void 0, preloadedQuery), contentPosts = _useContentPosts.data.contentPosts, loadNext = _useContentPosts.loadNext, isLoadingNext = _useContentPosts.isLoadingNext, hasNext = _useContentPosts.hasNext;
  var renderPostItem = function renderPostItem2(post) {
    if (!(post !== null && post !== void 0 && post.node)) return null;
    return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkXEC3A24Jjs.PostItem_default, {
      postRef: post.node
    });
  };
  var renderLoadingState = function renderLoadingState2() {
    if (!isLoadingNext) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, {
      sx: {
        paddingTop: 3
      }
    });
    return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _displays.LoadingState, {
      sx: {
        paddingTop: 3,
        paddingBottom: 1
      },
      CircularProgressProps: {
        size: 15
      },
      "aria-label": "loading more posts"
    });
  };
  var renderHeader = function renderHeader2() {
    var _contentPosts$edges;
    if ((contentPosts === null || contentPosts === void 0 || (_contentPosts$edges = contentPosts.edges) === null || _contentPosts$edges === void 0 ? void 0 : _contentPosts$edges.length) === 0) return null;
    return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {
      className: "h-2"
    });
  };
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactvirtuoso.Virtuoso, {
    useWindowScroll: true,
    data: contentPosts === null || contentPosts === void 0 ? void 0 : contentPosts.edges,
    overscan: 2e3,
    itemContent: function itemContent(_index, post) {
      return renderPostItem(post);
    },
    components: {
      Header: renderHeader,
      Footer: renderLoadingState,
      List: Scroller
    },
    endReached: function endReached() {
      if (hasNext) {
        loadNext(5);
      }
    }
  });
};
var PostList_default = PostList;



exports.PostList_default = PostList_default;
//# sourceMappingURL=chunk-ALEYL6IK.js.map