"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const styles_1 = require("@mui/material/styles");
const Box_1 = tslib_1.__importDefault(require("@mui/material/Box"));
const react_core_1 = require("@selfcommunity/react-core");
const system_1 = require("@mui/system");
const Media_1 = require("../../shared/Media");
const classnames_1 = tslib_1.__importDefault(require("classnames"));
const PREFIX = 'SCFeedObjectMediaPreview';
const classes = {
    root: `${PREFIX}-root`
};
const Root = (0, styles_1.styled)(Box_1.default, {
    name: PREFIX,
    slot: 'Root'
})(() => ({}));
/**
 * > API documentation for the Community-JS FeedObjectMediaPreview component. Learn about the available props and the CSS API.
 *
 *
 * The FeedObjectMediaPreview component render the list of medias in a feed object thanks to given configurations.

 #### Import
 ```jsx
 import {FeedObjectMediaPreview} from '@selfcommunity/react-ui';
 ```
 #### Component Name
 The name `SCFeedObjectMediaPreview` can be used when providing style overrides in the theme.

 #### CSS

 |Rule Name|Global class|Description|
 |---|---|---|
 |root|.SCFeedObjectMediaPreview-root|Styles applied to the root element.|


 * @param inProps
 */
exports.default = (inProps) => {
    //PROPS
    const props = (0, system_1.useThemeProps)({
        props: inProps,
        name: PREFIX
    });
    const { className, medias, mediaObjectTypes = [Media_1.File, Media_1.Link, Media_1.Share] } = props, rest = tslib_1.__rest(props, ["className", "medias", "mediaObjectTypes"]);
    const { handleMediaClick } = (0, react_core_1.useSCMediaClick)();
    if (!medias.length) {
        /**
         * Feed without any medias:
         * don't render anything
         */
        return null;
    }
    /**
     * Renders list of media preview
     * The adornment prop is used to insert the controls
     * for re-editing the media at the top of the group of elements
     */
    return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(className, classes.root) }, rest, { children: mediaObjectTypes.map((mediaObject) => {
            const { displayProps = {} } = mediaObject;
            return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(mediaObject.displayComponent, Object.assign({ medias: medias }, displayProps, { onMediaClick: handleMediaClick })) }, mediaObject.name));
        }) })));
};
