"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MediaBlock = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const React = tslib_1.__importStar(require("react"));
const Media_1 = tslib_1.__importDefault(require("../../components/Media/Media.js"));
const MediaBase_1 = tslib_1.__importDefault(require("../../components/MediaBase/MediaBase.js"));
const theme_1 = require("../../gravity-blocks/context/theme/index.js");
const utils_1 = require("../../utils/index.js");
const borderSelector_1 = require("../../utils/borderSelector.js");
const microdata_1 = require("../../utils/microdata.js");
const b = (0, utils_1.block)('media-block');
const MediaBlock = (props) => {
    const { media, border, disableShadow, title, description } = props;
    const borderSelected = (0, borderSelector_1.getMediaBorder)({
        border,
        disableShadow,
    });
    const [play, setPlay] = React.useState(false);
    const theme = (0, theme_1.useTheme)();
    const mediaThemed = (0, utils_1.getThemedValue)(media, theme);
    const mediaWithMicrodata = (0, microdata_1.mergeVideoMicrodata)(mediaThemed, {
        name: typeof title === 'object' && 'text' in title ? title.text : title,
        description,
    });
    return ((0, jsx_runtime_1.jsx)(MediaBase_1.default, { ...props, onScroll: () => setPlay(true), children: (0, jsx_runtime_1.jsx)(MediaBase_1.default.Card, { children: (0, jsx_runtime_1.jsx)(Media_1.default, { imageClassName: b('image'), ...mediaWithMicrodata, playVideo: play, className: b({ border: borderSelected }) }) }) }));
};
exports.MediaBlock = MediaBlock;
exports.default = exports.MediaBlock;
//# sourceMappingURL=Media.js.map
