"use strict";
exports.__esModule = true;
exports.BlogCard = exports.cnBlogCard = exports.cardPropSizeDirection = exports.cardPropDirection = exports.cardPropViewDefault = exports.cardPropView = exports.cardPropSizeDefault = exports.cardPropSize = void 0;
var tslib_1 = require("tslib");
/* eslint-disable jsx-a11y/control-has-associated-label */
// @ts-nocheck
/* eslint-disable jsx-a11y/anchor-has-content */
require("./BlogCard.css");
var react_1 = (0, tslib_1.__importStar)(require("react"));
var react_router_dom_1 = require("react-router-dom");
var IconArrowRight_1 = require("../../icons/IconArrowRight/IconArrowRight");
var bem_1 = require("../../utils/bem");
var getSizeByMap_1 = require("../../utils/getSizeByMap");
var PropsWithAsAttributes_1 = require("../../utils/types/PropsWithAsAttributes");
var Button_1 = require("../Button/Button");
var usePropsHandler_1 = require("../EventInterceptor/usePropsHandler");
var Picture_1 = require("../Picture/Picture");
var Tag_1 = require("../Tag/Tag");
var Typography = (0, tslib_1.__importStar)(require("../Typography/Typography"));
exports.cardPropSize = ['s', 'm', 'l'];
exports.cardPropSizeDefault = exports.cardPropSize[0];
exports.cardPropView = ['feed', 'filled', 'text', 'text2', 'text3'];
exports.cardPropViewDefault = exports.cardPropView[0];
exports.cardPropDirection = ['column', 'row'];
exports.cardPropSizeDirection = exports.cardPropDirection[0];
var sizeMap = {
    s: 'tiny',
    m: 'sm',
    l: 'md'
};
exports.cnBlogCard = (0, bem_1.cn)('BlogCard');
exports.BlogCard = (0, PropsWithAsAttributes_1.forwardRefWithAs)(function (props, ref) {
    var _a = (0, usePropsHandler_1.usePropsHandler)((0, exports.cnBlogCard)(), props), _b = _a.view, view = _b === void 0 ? exports.cardPropViewDefault : _b, _c = _a.direction, direction = _c === void 0 ? exports.cardPropSizeDirection : _c, _d = _a.size, size = _d === void 0 ? exports.cardPropSizeDefault : _d, data = (0, tslib_1.__rest)(_a, ["view", "direction", "size"]);
    var _e = data || {}, postDate = _e.postDate, hrvTags = _e.hrvTags, tagsList = _e.tags, title = _e.title, picture = _e.picture, _f = _e.linkIcon, linkIcon = _f === void 0 ? IconArrowRight_1.IconArrowRight : _f, onClickButton = _e.onClickButton, url = _e.url, path = _e.path, descriptionSmall = _e.descriptionSmall, _g = _e.iconSize, iconSize = _g === void 0 ? 'm' : _g, style = _e.style, linkTitle = _e.linkTitle, detailLinkTitle = _e.detailLinkTitle;
    var currentIcon = linkIcon;
    var tags = (0, react_1.useMemo)(function () { return (react_1["default"].createElement(react_1["default"].Fragment, null,
        react_1["default"].createElement("div", { className: (0, exports.cnBlogCard)('Tags') },
            hrvTags && (react_1["default"].createElement(react_1["default"].Fragment, null, hrvTags.map(function (tag) { return (react_1["default"].createElement("div", { key: tag.id, className: (0, exports.cnBlogCard)('Tag') },
                react_1["default"].createElement(Tag_1.Tag, { mode: "link", label: tag.title, size: "s" }))); }))),
            tagsList && (react_1["default"].createElement(react_1["default"].Fragment, null, tagsList.map(function (tag) { return (react_1["default"].createElement("div", { key: tag.id, className: (0, exports.cnBlogCard)('Tag') },
                react_1["default"].createElement(Tag_1.Tag, { mode: "link", label: tag.title, size: "s" }))); })))))); }, [hrvTags, tagsList]);
    var onClickButtonHandler = function () {
        if (url) {
            window.open(url, '_blank');
        }
    };
    return (react_1["default"].createElement("div", { className: (0, exports.cnBlogCard)({
            view: view,
            size: size,
            direction: direction
        }), style: style },
        path && react_1["default"].createElement(react_router_dom_1.NavLink, { className: (0, exports.cnBlogCard)('Link'), to: path }),
        view !== 'text' && view !== 'text2' && view !== 'text3' && picture && (react_1["default"].createElement("div", { className: (0, exports.cnBlogCard)('Photo') },
            react_1["default"].createElement(Picture_1.Picture, (0, tslib_1.__assign)({}, picture)))),
        react_1["default"].createElement("div", { className: (0, exports.cnBlogCard)('Body') },
            view !== 'text' && view !== 'text3' && postDate && (react_1["default"].createElement("div", { className: (0, exports.cnBlogCard)('Date') },
                react_1["default"].createElement(Typography.Typography.Text, { weight: "semibold", size: "xs" }, postDate))),
            descriptionSmall && (react_1["default"].createElement("div", { className: (0, exports.cnBlogCard)('DescriptionSmall') },
                react_1["default"].createElement(Typography.Typography.Text, { weight: "semibold", size: "xs", transform: "uppercase" }, descriptionSmall))),
            view === 'text3' && tags,
            react_1["default"].createElement("div", { className: (0, exports.cnBlogCard)('Title') },
                react_1["default"].createElement(Typography.Typography.Title, { weight: "bold", size: (0, getSizeByMap_1.getSizeByMap)(sizeMap, size) }, title)),
            view !== 'text' && view !== 'filled' && view !== 'text3' && tags,
            view !== 'text' && view !== 'text2' && linkTitle && (react_1["default"].createElement("div", { style: {
                    pointerEvents: 'none'
                }, className: (0, exports.cnBlogCard)('Button') },
                react_1["default"].createElement(Button_1.Button, { view: "link-secondary", iconRight: currentIcon, iconSize: iconSize, label: detailLinkTitle !== null && detailLinkTitle !== void 0 ? detailLinkTitle : linkTitle, onClick: onClickButton || onClickButtonHandler }))))));
});
