"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.NewUserSessionEmail = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const components_1 = require("@react-email/components");
const footer_1 = __importDefault(require("../_components/footer"));
const content_1 = __importDefault(require("../_components/content"));
const layout_1 = __importDefault(require("../_components/layout"));
const header_1 = __importDefault(require("../_components/header"));
const style_1 = require("../_libs/style");
const fontFamily = 'HelveticaNeue,Helvetica,Arial,sans-serif';
const main = {
    fontFamily,
};
const NewUserSessionEmail = ({ userSession, appInfo, locale = 'en', userInfo, poweredBy, signatureConfig, }) => {
    const translations = {
        en: {
            title: 'You are logged in on a new device',
            loginIp: 'Login IP',
            loginAt: 'Login At',
        },
        zh: {
            title: '你在一个新的设备上登录了',
            loginIp: '登录 IP',
            loginAt: '登录时间',
        },
    };
    const translation = translations[locale] || translations.en;
    const subject = `[${appInfo.title}] ${translation.title}`;
    const localeMap = {
        en: 'en-US',
        zh: 'zh-CN',
    };
    const targetLocale = localeMap[locale] || localeMap.en;
    return ((0, jsx_runtime_1.jsxs)(layout_1.default, { mainStyle: main, subject: subject, children: [(0, jsx_runtime_1.jsx)(components_1.Preview, { children: subject }), (0, jsx_runtime_1.jsx)(header_1.default, { appInfo: appInfo }), (0, jsx_runtime_1.jsx)(content_1.default, { style: style_1.contentStyle, locale: locale, title: translation.title, body: (0, jsx_runtime_1.jsxs)(components_1.Text, { children: ["You are logged in on a new device: ", userSession.ua] }), attachments: [
                    {
                        type: 'section',
                        fields: [
                            {
                                type: 'text',
                                data: { type: 'plain', color: '#9397A1', text: translation.loginIp },
                            },
                            {
                                type: 'text',
                                data: { type: 'plain', text: userSession.lastLoginIp },
                            },
                            {
                                type: 'text',
                                data: { type: 'plain', color: '#9397A1', text: translation.loginAt },
                            },
                            {
                                type: 'text',
                                data: { type: 'plain', text: userSession.updatedAt.toLocaleString(targetLocale) },
                            },
                        ],
                    },
                ] }), (0, jsx_runtime_1.jsx)(footer_1.default, { showCopyright: false, poweredBy: poweredBy, showBlocklet: true, appInfo: appInfo, locale: locale, userInfo: userInfo, signatureConfig: signatureConfig })] }));
};
exports.NewUserSessionEmail = NewUserSessionEmail;
exports.default = exports.NewUserSessionEmail;
