"use strict";
exports.__esModule = true;
exports.ContentBuilderTemplate = void 0;
var tslib_1 = require("tslib");
// @ts-nocheck
require("./ContentBuilderTemplate.css");
var react_1 = (0, tslib_1.__importDefault)(require("react"));
var react_router_dom_1 = require("react-router-dom");
var PropsWithAsAttributes_1 = require("../../../utils/types/PropsWithAsAttributes");
var usePropsHandler_1 = require("../../EventInterceptor/usePropsHandler");
var index_1 = require("./index");
var Typography_1 = require("../../Typography/Typography");
var Article_1 = require("../../Article/Article");
var Slider_1 = require("../../Slider/Slider");
var EssenceCard_1 = require("../../EssenceCard/EssenceCard");
var Button_1 = require("../../Button/Button");
var IconOpenInNew_1 = require("../../../icons/IconOpenInNew/IconOpenInNew");
exports.ContentBuilderTemplate = (0, PropsWithAsAttributes_1.forwardRefWithAs)(function (props, ref) {
    var _a = (0, usePropsHandler_1.usePropsHandler)((0, index_1.cnContentBuilderTemplate)(), props), type = _a.type, title = _a.title, text = _a.text, items = _a.items, aliases = _a.aliases, button = _a.button, linkTitleType0 = _a.linkTitleType0, linkTitleType1 = _a.linkTitleType1;
    var typeNumber = type.toString();
    var options = {
        navigation: true,
        breakpoints: {
            767: {
                spaceBetween: 16,
                slidesPerView: 2
            },
            1200: {
                spaceBetween: 24,
                slidesPerView: 3
            }
        },
        spaceBetween: 8,
        slidesPerView: 1,
        watchOverflow: true
    };
    var generateParams = function (options) {
        if (options.contentType === 4) {
            return (0, tslib_1.__assign)((0, tslib_1.__assign)({}, options), { contentType: options.contentType, picture: options.picture, routePath: options.link, targetBlank: options.targetBlank, title: options.title, view: 'filled', size: 'm', linkIcon: IconOpenInNew_1.IconOpenInNew, linkTitle: options.linkTitle, redirectTo: options.link });
        }
        if (options.contentType === 3) {
            return (0, tslib_1.__assign)((0, tslib_1.__assign)({}, options), { routePath: (0, react_router_dom_1.generatePath)(aliases.EVENTS_PAGE, {
                    slug: options.slug
                }) });
        }
        if (options.contentType === 0) {
            return (0, tslib_1.__assign)((0, tslib_1.__assign)({}, options), { contentType: options.contentType, picture: options.picture, title: options.title, view: 'filled', size: 'm', path: (0, react_router_dom_1.generatePath)(aliases.BLOG_SINGLE, {
                    slug: options.slug
                }), linkTitle: linkTitleType0, linkTitleType1: linkTitleType1, url: options.url, videoUrl: options.videoUrl, video: options.video, postDate: null });
        }
        if (options.contentType === 2) {
            return (0, tslib_1.__assign)((0, tslib_1.__assign)({}, options), { contentType: options.contentType, picture: options.picture, title: options.title, view: 'filled', size: 'm', linkTitle: linkTitleType1 || 'watch on youtube', url: options.url, videoUrl: options.videoUrl, video: options.video, postDate: null });
        }
        if (options.contentType === 6) {
            return (0, tslib_1.__assign)((0, tslib_1.__assign)({}, options), { view: 'filled', size: 'm', linkTitle: 'learn more', linkIcon: IconOpenInNew_1.IconOpenInNew, path: (0, react_router_dom_1.generatePath)(aliases.INDUSTRIES_PAGE_INNER, {
                    slug: options.industrySlug,
                    inner_page: options.slug
                }) });
        }
        if (options.contentType === 5) {
            return (0, tslib_1.__assign)((0, tslib_1.__assign)({}, options), { view: 'filled', size: 'm', linkTitle: 'learn more', path: (0, react_router_dom_1.generatePath)(aliases.NEWSROOM_PAGE, {
                    slug: options.slug,
                    parentSlug: options.parentSlug
                }) });
        }
        return (0, tslib_1.__assign)({}, options);
    };
    return (react_1["default"].createElement("div", { className: (0, index_1.cnContentBuilderTemplate)({ type: typeNumber }) },
        title && (react_1["default"].createElement(Typography_1.Typography.Text, { size: "xs", weight: "bold", transform: "uppercase", className: (0, index_1.cnContentBuilderTemplate)('Title') }, title)),
        text && react_1["default"].createElement(Article_1.Article, { content: text, className: (0, index_1.cnContentBuilderTemplate)('SubTitle') }),
        items && (react_1["default"].createElement(Slider_1.Slider, (0, tslib_1.__assign)({}, options), items.map(function (post, index) { return (react_1["default"].createElement(Slider_1.SliderItem, { key: post.id },
            react_1["default"].createElement(EssenceCard_1.EssenceCard, (0, tslib_1.__assign)({}, generateParams(post))))); }))),
        button && (react_1["default"].createElement("div", { className: (0, index_1.cnContentBuilderTemplate)('Button') },
            react_1["default"].createElement(Button_1.Button, (0, tslib_1.__assign)({}, button))))));
});
exports["default"] = exports.ContentBuilderTemplate;
