"use strict";
/* eslint-disable react/jsx-no-target-blank */
/* eslint-disable jsx-a11y/anchor-has-content */
/* eslint-disable jsx-a11y/control-has-associated-label */
// @ts-nocheck
exports.__esModule = true;
exports.EventCard = exports.cnEventCard = void 0;
var tslib_1 = require("tslib");
require("./EventCard.css");
var react_1 = (0, tslib_1.__importDefault)(require("react"));
var react_router_dom_1 = require("react-router-dom");
var IconPlay_1 = require("../../icons/IconPlay/IconPlay");
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 TagGroup_1 = require("../TagGroup/TagGroup");
var Typography_1 = require("../Typography/Typography");
var User_1 = require("../User/User");
exports.cnEventCard = (0, bem_1.cn)('EventCard');
var sizeMapTitle = {
    m: 'sm',
    l: 'lg'
};
exports.EventCard = (0, PropsWithAsAttributes_1.forwardRefWithAs)(function (props, ref) {
    var _a, _b, _c;
    var _d = (0, usePropsHandler_1.usePropsHandler)((0, exports.cnEventCard)(), props), routePath = _d.routePath, view = _d.view, picture = _d.picture, date = _d.date, tags = _d.tags, isOnline = _d.isOnline, languages = _d.languages, title = _d.title, _e = _d.size, size = _e === void 0 ? 'm' : _e, invertedStyle = _d.invertedStyle, locations = _d.locations, speakers = _d.speakers, slug = _d.slug, registrationStatus = _d.registrationStatus, redirectTo = _d.redirectTo, eventType = _d.eventType, fullUrl = _d.fullUrl, eventTypeText = _d.eventTypeText, location = _d.location, eventWithoutPage = _d.eventWithoutPage, onlineTitle = _d.onlineTitle, video = _d.video, cardDictionary = _d.cardDictionary;
    var eventCard = (cardDictionary || {}).eventCard;
    var redirectToPage = redirectTo;
    if (Number(process.env.REACT_APP_EVENT_TYPE) !== Number(eventType) &&
        !redirectToPage &&
        fullUrl) {
        redirectToPage = fullUrl;
    }
    return (react_1["default"].createElement("div", { className: (0, exports.cnEventCard)({
            view: view,
            size: size,
            invertedStyle: invertedStyle,
            noHover: eventWithoutPage
        }) },
        !eventWithoutPage && (react_1["default"].createElement(react_1["default"].Fragment, null,
            redirectToPage && (react_1["default"].createElement("a", { className: (0, exports.cnEventCard)('Link'), href: redirectToPage, target: "_blank", rel: "noreferrer" })),
            !redirectToPage && routePath && (react_1["default"].createElement(react_router_dom_1.NavLink, { className: (0, exports.cnEventCard)('Link'), to: routePath })))),
        picture && (react_1["default"].createElement("div", { className: (0, exports.cnEventCard)('Picture') },
            react_1["default"].createElement(Picture_1.Picture, (0, tslib_1.__assign)({}, picture)))),
        react_1["default"].createElement("div", { className: (0, exports.cnEventCard)('Inner') },
            react_1["default"].createElement("div", { className: (0, exports.cnEventCard)('Date') },
                react_1["default"].createElement(Typography_1.Typography.Text, { size: "xs", weight: "bold", transform: "uppercase" }, date),
                locations && (react_1["default"].createElement(Typography_1.Typography.Text, { size: "xs", weight: "bold", transform: "uppercase" },
                    "|",
                    ' ',
                    isOnline
                        ? (_a = eventCard === null || eventCard === void 0 ? void 0 : eventCard.eventCardOnline) !== null && _a !== void 0 ? _a : onlineTitle
                        : locations.map(function (location) { return "".concat(location.country, ", ").concat(location.location); }))),
                location && (react_1["default"].createElement(Typography_1.Typography.Text, { size: "xs", weight: "bold", transform: "uppercase" },
                    "|",
                    ' ',
                    isOnline
                        ? (_b = eventCard === null || eventCard === void 0 ? void 0 : eventCard.eventCardOnline) !== null && _b !== void 0 ? _b : onlineTitle
                        : "".concat(location.country, ", ").concat(location.location))),
                !location && !locations && isOnline && (react_1["default"].createElement(Typography_1.Typography.Text, { size: "xs", weight: "bold", transform: "uppercase" },
                    "|\u00A0",
                    isOnline ? (_c = eventCard === null || eventCard === void 0 ? void 0 : eventCard.eventCardOnline) !== null && _c !== void 0 ? _c : onlineTitle : null))),
            react_1["default"].createElement("div", { className: (0, exports.cnEventCard)('Title') },
                react_1["default"].createElement(Typography_1.Typography.Title, { size: (0, getSizeByMap_1.getSizeByMap)(sizeMapTitle, size), weight: "bold" }, title)),
            eventTypeText && (react_1["default"].createElement("div", { className: (0, exports.cnEventCard)('SubTitle') },
                react_1["default"].createElement(Typography_1.Typography.Text, { size: "s" }, eventTypeText))),
            react_1["default"].createElement("div", { className: (0, exports.cnEventCard)('Tags') }, tags && react_1["default"].createElement(TagGroup_1.TagGroup, { items: tags })),
            react_1["default"].createElement("div", { className: (0, exports.cnEventCard)('Speakers') },
                video && (react_1["default"].createElement("div", { className: (0, exports.cnEventCard)('VideoCircle'), style: { zIndex: (speakers === null || speakers === void 0 ? void 0 : speakers.length) > 0 ? speakers.length + 1 : 1 } },
                    react_1["default"].createElement(Button_1.Button, { view: "primary", form: "circle", iconRight: IconPlay_1.IconPlay, size: "4xl", iconSize: "s", onlyIcon: true }))),
                speakers &&
                    speakers.map(function (speaker, index) {
                        var _a;
                        return (react_1["default"].createElement(react_1["default"].Fragment, { key: index + slug + title }, speaker.photo && (react_1["default"].createElement(User_1.User, { size: "m", avatarUrl: (_a = speaker.photo) === null || _a === void 0 ? void 0 : _a.url, style: { zIndex: speakers.length - index } }))));
                    })),
            languages && (react_1["default"].createElement("div", { className: (0, exports.cnEventCard)('Bottom') },
                react_1["default"].createElement(TagGroup_1.TagGroup, { items: languages, mode: "label", gap: "xs" }))),
            registrationStatus && (react_1["default"].createElement("div", { className: (0, exports.cnEventCard)('Bottom') },
                react_1["default"].createElement(Tag_1.Tag, { mode: "label", label: registrationStatus.title, colorBorder: registrationStatus.color, gap: "xs" }))))));
});
