"use strict";
exports.__esModule = true;
exports.MaterialCard = exports.cnMaterialCard = exports.materialCardPropSizeDefault = exports.materialCardPropSize = void 0;
var tslib_1 = require("tslib");
/* eslint-disable react/jsx-no-target-blank */
/* eslint-disable jsx-a11y/anchor-is-valid */
/* eslint-disable jsx-a11y/anchor-has-content */
/* eslint-disable jsx-a11y/control-has-associated-label */
// @ts-nocheck
require("./MaterialCard.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 Typography_1 = require("../Typography/Typography");
exports.materialCardPropSize = ['m', 'l'];
exports.materialCardPropSizeDefault = exports.materialCardPropSize[0];
var sizeTitle = {
    m: 'tiny',
    l: 'lg'
};
var sizeSubTitle = {
    m: 'tiny',
    l: 'tiny'
};
exports.cnMaterialCard = (0, bem_1.cn)('MaterialCard');
exports.MaterialCard = (0, PropsWithAsAttributes_1.forwardRefWithAs)(function (props, ref) {
    var _a = (0, usePropsHandler_1.usePropsHandler)((0, exports.cnMaterialCard)(), props), _b = _a.size, size = _b === void 0 ? exports.materialCardPropSizeDefault : _b, path = _a.path, title = _a.title, subtitle = _a.subtitle, linkLabel = _a.linkLabel, linkTitle = _a.linkTitle, _c = _a.linkIcon, linkIcon = _c === void 0 ? IconArrowRight_1.IconArrowRight : _c, decorImg = _a.decorImg, bgColor = _a.bgColor, inverted = _a.inverted, link = _a.link, linkImage = _a.linkImage, buttonAttrs = _a.buttonAttrs, targetBlank = _a.targetBlank;
    var LinkImageComponent = (0, react_1.useMemo)(function () { return react_1["default"].createElement(react_1["default"].Fragment, null, linkImage && react_1["default"].createElement("img", { src: linkImage.url, alt: "alt" })); }, [linkImage]);
    return (react_1["default"].createElement("div", { className: (0, exports.cnMaterialCard)({ size: size, inverted: inverted }), style: { backgroundColor: bgColor } },
        targetBlank ? (react_1["default"].createElement("a", { href: path !== null && path !== void 0 ? path : link, target: "_blank", rel: "noopener", className: (0, exports.cnMaterialCard)('Link') })) : (react_1["default"].createElement(react_router_dom_1.NavLink, { className: (0, exports.cnMaterialCard)('Link'), to: path !== null && path !== void 0 ? path : link })),
        react_1["default"].createElement("div", { className: (0, exports.cnMaterialCard)('Inner') },
            react_1["default"].createElement(Typography_1.Typography.Title, { size: (0, getSizeByMap_1.getSizeByMap)(sizeTitle, size), className: (0, exports.cnMaterialCard)('Title') }, title),
            size !== 'm' && (react_1["default"].createElement(Typography_1.Typography.Title, { size: (0, getSizeByMap_1.getSizeByMap)(sizeSubTitle, size), className: (0, exports.cnMaterialCard)('SubTitle') }, subtitle)),
            react_1["default"].createElement("div", { className: (0, exports.cnMaterialCard)('Decor') }, decorImg && react_1["default"].createElement(Picture_1.Picture, { desktop: decorImg.url, desktopWebp: decorImg.urlWebp })),
            react_1["default"].createElement("div", { className: (0, exports.cnMaterialCard)('Button') },
                react_1["default"].createElement(Button_1.Button, (0, tslib_1.__assign)({ color: "inherit", view: "link-secondary", iconRight: !linkImage && linkIcon, icon: LinkImageComponent, as: "a", iconSize: "m", label: linkLabel !== null && linkLabel !== void 0 ? linkLabel : linkTitle, href: link }, buttonAttrs))))));
});
