import { __assign } from "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
import './MaterialCard.css';
import React, { useMemo } from 'react';
import { NavLink } from 'react-router-dom';
import { IconArrowRight } from '../../icons/IconArrowRight/IconArrowRight';
import { cn } from '../../utils/bem';
import { getSizeByMap } from '../../utils/getSizeByMap';
import { forwardRefWithAs } from '../../utils/types/PropsWithAsAttributes';
import { Button } from '../Button/Button';
import { usePropsHandler } from '../EventInterceptor/usePropsHandler';
import { Picture } from '../Picture/Picture';
import { Typography } from '../Typography/Typography';
export var materialCardPropSize = ['m', 'l'];
export var materialCardPropSizeDefault = materialCardPropSize[0];
var sizeTitle = {
    m: 'tiny',
    l: 'lg'
};
var sizeSubTitle = {
    m: 'tiny',
    l: 'tiny'
};
export var cnMaterialCard = cn('MaterialCard');
export var MaterialCard = forwardRefWithAs(function (props, ref) {
    var _a = usePropsHandler(cnMaterialCard(), props), _b = _a.size, size = _b === void 0 ? 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 : _c, decorImg = _a.decorImg, bgColor = _a.bgColor, inverted = _a.inverted, link = _a.link, linkImage = _a.linkImage, buttonAttrs = _a.buttonAttrs, targetBlank = _a.targetBlank;
    var LinkImageComponent = useMemo(function () { return React.createElement(React.Fragment, null, linkImage && React.createElement("img", { src: linkImage.url, alt: "alt" })); }, [linkImage]);
    return (React.createElement("div", { className: cnMaterialCard({ size: size, inverted: inverted }), style: { backgroundColor: bgColor } },
        targetBlank ? (React.createElement("a", { href: path !== null && path !== void 0 ? path : link, target: "_blank", rel: "noopener", className: cnMaterialCard('Link') })) : (React.createElement(NavLink, { className: cnMaterialCard('Link'), to: path !== null && path !== void 0 ? path : link })),
        React.createElement("div", { className: cnMaterialCard('Inner') },
            React.createElement(Typography.Title, { size: getSizeByMap(sizeTitle, size), className: cnMaterialCard('Title') }, title),
            size !== 'm' && (React.createElement(Typography.Title, { size: getSizeByMap(sizeSubTitle, size), className: cnMaterialCard('SubTitle') }, subtitle)),
            React.createElement("div", { className: cnMaterialCard('Decor') }, decorImg && React.createElement(Picture, { desktop: decorImg.url, desktopWebp: decorImg.urlWebp })),
            React.createElement("div", { className: cnMaterialCard('Button') },
                React.createElement(Button, __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))))));
});
