"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
const components_1 = require("@react-email/components");
const token_1 = __importDefault(require("./token"));
const asset_1 = __importDefault(require("./asset"));
const compose_1 = __importDefault(require("./compose"));
const transaction_1 = __importDefault(require("./transaction"));
const dapp_1 = __importDefault(require("./dapp"));
const article_1 = __importDefault(require("./article"));
const style_1 = require("../_libs/style");
function Attachments({ locale, severity = 'normal', attachments = [], }) {
    const attachmentList = attachments
        .map((item, index) => {
        switch (item.type) {
            case 'text':
                return item.data.type === 'plain' ? ((0, jsx_runtime_1.jsx)(components_1.Text, { style: {
                        color: item.data.color || 'initial',
                        fontSize: { small: '12px', normal: '14px', large: '16px' }[item.data.size || 'normal'],
                        whiteSpace: 'pre-line!important',
                    }, children: item.data.text }, `${item.type}-${index}`)) : null;
            case 'image':
                return ((0, jsx_runtime_1.jsx)(components_1.Img, { src: item.data.url, alt: item.data.alt, style: {
                        width: '100%',
                        height: '150px',
                        objectFit: 'contain',
                        objectPosition: 'left center',
                    } }, `${item.type}-${index}`));
            case 'token':
                return (0, jsx_runtime_1.jsx)(token_1.default, { data: item.data, locale: locale }, `${item.type}-${index}`);
            case 'transaction':
                return (0, jsx_runtime_1.jsx)(transaction_1.default, { data: item.data, locale: locale }, `${item.type}-${index}`);
            case 'dapp':
                return (0, jsx_runtime_1.jsx)(dapp_1.default, { data: item.data }, `${item.type}-${index}`);
            case 'link':
                return (0, jsx_runtime_1.jsx)(article_1.default, { data: item.data }, `${item.type}-${index}`);
            case 'divider':
                return (0, jsx_runtime_1.jsx)(components_1.Hr, {}, `${item.type}-${index}`);
            case 'vc':
            case 'asset':
                return (0, jsx_runtime_1.jsx)(asset_1.default, { type: item.type, data: item.data, locale: locale }, `${item.type}-${index}`);
            case 'section':
                return (0, jsx_runtime_1.jsx)(compose_1.default, { data: item.fields }, `${item.type}-${index}`);
            default:
                return null;
        }
    })
        .filter(Boolean);
    return attachmentList.length > 0 ? ((0, jsx_runtime_1.jsx)(components_1.Section, { style: Object.assign(Object.assign({}, style_1.attachmentsStyle), { borderColor: style_1.severityColorMap[severity] || style_1.severityColorMap.normal }), children: attachmentList })) : null;
}
exports.default = Attachments;
