/* eslint-disable jsx-a11y/control-has-associated-label */
// @ts-nocheck
/* eslint-disable jsx-a11y/anchor-has-content */
/* eslint-disable jsx-a11y/img-redundant-alt */
import './ProjectCard.css';
import React, { useMemo } from 'react';
import { IconOpenInNew } from '../../icons/IconOpenInNew/IconOpenInNew';
import { cn } from '../../utils/bem';
import { forwardRefWithAs } from '../../utils/types/PropsWithAsAttributes';
import { Button } from '../Button/Button';
import { Picture } from '../Picture/Picture';
import { Typography } from '../Typography';
export var projectCardPropView = ['default'];
export var projectCardPropViewDefault = projectCardPropView[0];
var cnProjectCard = cn('ProjectCard');
export var ProjectCard = forwardRefWithAs(function (props) {
    var _a = props.view, view = _a === void 0 ? projectCardPropViewDefault : _a, title = props.title, link = props.link, picture = props.picture, additionalLinks = props.additionalLinks;
    var LinkImageComponent = useMemo(function () { var _a; return React.createElement(React.Fragment, null, (link === null || link === void 0 ? void 0 : link.icon) && React.createElement("img", { src: (_a = link === null || link === void 0 ? void 0 : link.icon) === null || _a === void 0 ? void 0 : _a.url, alt: "photo" })); }, [link === null || link === void 0 ? void 0 : link.icon]);
    return (React.createElement("div", { className: cnProjectCard({ view: view }) },
        React.createElement("a", { className: cnProjectCard('OverlayLink'), target: link.targetBlank ? '_blank' : null, href: link.link, rel: link.targetBlank ? 'noreferrer noopener' : null }),
        picture && (React.createElement("div", { className: cnProjectCard('Picture') },
            React.createElement(Picture, { desktop: picture.url, desktopWebp: picture.urlWebp }))),
        React.createElement("div", { className: cnProjectCard('Inner') },
            React.createElement(Typography.Text, { className: cnProjectCard('Title') }, title),
            (additionalLinks === null || additionalLinks === void 0 ? void 0 : additionalLinks.length) > 0 && (React.createElement("div", { className: cnProjectCard('Links') }, additionalLinks.map(function (additionalLink) { return (React.createElement("div", { className: cnProjectCard('Links-Item') },
                React.createElement(Button, { label: additionalLink.title, as: "a", target: additionalLink.targetBlank ? '_blank' : null, href: additionalLink.link, view: "link-secondary", badge: {
                        text: additionalLink.labelText,
                        inverted: additionalLink.labelInverted,
                        color: additionalLink.labelColor
                    } }))); }))),
            link && (React.createElement("div", { className: cnProjectCard('Button') },
                React.createElement(Button, { label: link === null || link === void 0 ? void 0 : link.title, view: "link-secondary", icon: !!(link === null || link === void 0 ? void 0 : link.icon) && LinkImageComponent, iconRight: !(link === null || link === void 0 ? void 0 : link.icon) && IconOpenInNew, iconSize: "xs", target: link.targetBlank ? '_blank' : null, as: "a", href: link.link }))))));
});
