"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const React = tslib_1.__importStar(require("react"));
const components_1 = require("../../components/index.js");
const utils_1 = require("../../components/Media/Image/utils.js");
const theme_1 = require("../../gravity-blocks/context/theme/index.js");
const hooks_1 = require("../../gravity-blocks/hooks/index.js");
const models_1 = require("../../models/index.js");
const utils_2 = require("../../utils/index.js");
const b = (0, utils_2.block)('quote');
const Quote = (props) => {
    const { theme: textTheme = 'light', color, image, border = 'shadow', text, yfmText, logo, author, url, urlTitle, buttonText, quoteType = models_1.QuoteType.Chevron, button, } = props;
    const theme = (0, theme_1.useTheme)();
    const imageThemed = (0, utils_2.getThemedValue)(image, theme);
    const imageData = (0, utils_1.getMediaImage)(imageThemed);
    const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.QuoteButton, url);
    const handleButtonClick = React.useCallback(() => handleAnalytics(), [handleAnalytics]);
    const themedAuthor = author
        ? {
            ...author,
            avatar: (0, utils_2.getThemedValue)(author.avatar, theme),
        }
        : author;
    const renderFooter = Boolean(author || url) && ((0, jsx_runtime_1.jsxs)("div", { className: b('author-wrapper'), children: [themedAuthor && ((0, jsx_runtime_1.jsx)(components_1.Author, { className: b('author', { theme: textTheme }), author: themedAuthor, type: models_1.AuthorType.Line, theme: textTheme })), url && buttonText && !button && ((0, jsx_runtime_1.jsx)(components_1.Button, { theme: "outlined", size: "xl", url: url, className: b('link-button', { theme: textTheme }), onClick: handleButtonClick, urlTitle: urlTitle, text: buttonText })), button && (0, jsx_runtime_1.jsx)(components_1.Button, { size: "xl", ...button })] }));
    const themedLogoProps = (0, utils_2.getThemedValue)(logo, theme);
    const logoProps = (0, utils_1.getMediaImage)(themedLogoProps);
    const textLocal = yfmText || text;
    return ((0, jsx_runtime_1.jsxs)("div", { className: b({ theme: textTheme, border }), style: color ? { backgroundColor: color } : {}, children: [(0, jsx_runtime_1.jsxs)("div", { className: b('content-wrapper'), children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(components_1.Image, { className: b('logo'), ...logoProps }), (0, jsx_runtime_1.jsx)("div", { className: b('content', { 'quote-type': quoteType }), children: textLocal && ((0, jsx_runtime_1.jsx)(components_1.YFMWrapper, { tagName: "span", contentClassName: b('text'), content: textLocal, modifiers: { constructor: true } })) })] }), renderFooter] }, text), (0, jsx_runtime_1.jsx)("div", { className: b('image-wrapper'), children: (0, jsx_runtime_1.jsx)(components_1.Image, { ...imageData, className: b('image') }) })] }));
};
exports.default = Quote;
//# sourceMappingURL=Quote.js.map
