"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const styles_1 = require("@mui/material/styles");
const Box_1 = tslib_1.__importDefault(require("@mui/material/Box"));
const FeedObject_1 = tslib_1.__importDefault(require("../../../components/FeedObject"));
const feedObject_1 = require("../../../types/feedObject");
const utils_1 = require("@selfcommunity/utils");
const classnames_1 = tslib_1.__importDefault(require("classnames"));
const filter_1 = tslib_1.__importDefault(require("./filter"));
const constants_1 = require("./constants");
const Media_1 = require("../../../constants/Media");
const event_1 = require("../../../types/event");
const Event_1 = tslib_1.__importDefault(require("../../../components/Event"));
const classes = {
    displayRoot: `${constants_1.PREFIX}-display-root`,
    sharePreview: `${constants_1.PREFIX}-share-preview`,
    sharePlaceholder: `${constants_1.PREFIX}-share-placeholder`
};
const Root = (0, styles_1.styled)(Box_1.default, {
    name: constants_1.PREFIX,
    slot: 'DisplayRoot'
})(({ theme }) => ({}));
exports.default = (_a) => {
    var { className, medias = [], onMediaClick = null } = _a, rest = tslib_1.__rest(_a, ["className", "medias", "onMediaClick"]);
    // MEMO
    const _medias = (0, react_1.useMemo)(() => medias.filter(filter_1.default), [medias]);
    if (_medias.length === 0) {
        return null;
    }
    return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(className, classes.displayRoot) }, rest, { children: _medias.map((media, i) => ((0, jsx_runtime_1.jsx)(Box_1.default, Object.assign({ className: classes.sharePreview, onClick: onMediaClick }, { children: media.type === Media_1.MEDIA_TYPE_EVENT || (media.embed && media.embed.embed_type === Media_1.MEDIA_EMBED_SC_SHARED_EVENT) ? ((0, jsx_runtime_1.jsx)(Event_1.default, { event: media.embed.metadata, template: event_1.SCEventTemplateType.DETAIL, variant: "outlined", square: true, hideEventParticipants: true, hideEventPlanner: true, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}) })) : ((0, jsx_runtime_1.jsx)(FeedObject_1.default, { feedObjectId: media.embed.metadata.id, feedObjectType: media.embed.metadata.type, variant: 'outlined', template: feedObject_1.SCFeedObjectTemplateType.SHARE, cacheStrategy: utils_1.CacheStrategies.CACHE_FIRST })) }), i))) })));
};
