"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.VerifyCodeBody = VerifyCodeBody;
const jsx_runtime_1 = require("react/jsx-runtime");
const components_1 = require("@react-email/components");
// @ts-ignore
const constant_1 = require("@abtnode/constant");
const actions_1 = __importDefault(require("../_components/actions"));
// HACK: 只是短暂为了兼容现有 launcher 转发逻辑
function VerifyCodeBody({ appName, locale = 'en', code, magicLink, children, }) {
    const translations = {
        en: {
            title: `Sign in to ${appName}`,
            followConfirmation: `Please use the confirmation button below to complete your login.`,
            confirmButton: 'Confirm Sign in',
            useConfirmLink: 'If Confirm Button does not work, please use the link below.',
            orEnterCode: `Or enter the following code in the application: `,
            followEnterCode: `Please use the verification code below to complete your login.`,
            codeExpiresIn: `This code expires in ${constant_1.VERIFY_CODE_TTL / 60 / 1000} minutes.`,
            doNotShareCodeTitle: 'Security Check:',
            doNotShareCode: 'Do not share this code with anyone.',
            doNotShareCode2: 'MyVibe employees will never ask for this code.',
        },
        zh: {
            title: `登录 ${appName}`,
            followConfirmation: `请使用下面的确认按钮完成登录。`,
            confirmButton: '确认登录',
            useConfirmLink: '如果确认按钮无法工作，请使用以下链接。',
            orEnterCode: `或者在应用中输入以下代码：`,
            followEnterCode: `请使用下面的验证码完成登录。`,
            codeExpiresIn: `此代码将在${constant_1.VERIFY_CODE_TTL / 60 / 1000}分钟内过期。`,
            doNotShareCodeTitle: '安全提示：',
            doNotShareCode: '请勿将此代码分享给任何人。',
            doNotShareCode2: 'MyVibe 员工绝不会向您索要此代码。',
        },
    };
    const translation = translations[locale] || translations.en;
    const _code = code ? code.toString().trim() : '';
    const code1 = _code.slice(0, 3);
    const code2 = _code.slice(3);
    if (children) {
        return children;
    }
    if (code && magicLink) {
        return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(components_1.Text, { children: translation.followConfirmation }), (0, jsx_runtime_1.jsx)(actions_1.default, { actions: [{ title: translation.confirmButton, link: magicLink }] }), (0, jsx_runtime_1.jsx)(components_1.Hr, {}), (0, jsx_runtime_1.jsxs)(components_1.Text, { children: [translation.orEnterCode, (0, jsx_runtime_1.jsx)("strong", { children: code })] }), (0, jsx_runtime_1.jsx)(components_1.Text, { children: translation.codeExpiresIn }), (0, jsx_runtime_1.jsxs)(components_1.Text, { children: [(0, jsx_runtime_1.jsx)("strong", { children: translation.doNotShareCodeTitle }), " ", translation.doNotShareCode, (0, jsx_runtime_1.jsx)("br", {}), translation.doNotShareCode2] })] }));
    }
    if (magicLink) {
        return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(components_1.Text, { children: translation.followConfirmation }), (0, jsx_runtime_1.jsx)(actions_1.default, { actions: [{ title: translation.confirmButton, link: magicLink }] }), (0, jsx_runtime_1.jsx)(components_1.Text, { children: translation.useConfirmLink }), (0, jsx_runtime_1.jsx)(components_1.Link, { href: magicLink, children: magicLink })] }));
    }
    if (code) {
        return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(components_1.Text, { children: translation.followEnterCode }), (0, jsx_runtime_1.jsxs)(components_1.Heading, { style: {
                        textAlign: 'center',
                        fontSize: '3em',
                        letterSpacing: '2px',
                        fontFamily: 'SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace',
                    }, children: [(0, jsx_runtime_1.jsx)("span", { style: { marginRight: '0.4em' }, children: code1 }), (0, jsx_runtime_1.jsx)("span", { children: code2 })] }), (0, jsx_runtime_1.jsx)(components_1.Text, { style: { textAlign: 'center', marginTop: '-1em' }, children: translation.codeExpiresIn }), (0, jsx_runtime_1.jsxs)(components_1.Text, { children: [(0, jsx_runtime_1.jsx)("strong", { children: translation.doNotShareCodeTitle }), " ", translation.doNotShareCode, (0, jsx_runtime_1.jsx)("br", {}), translation.doNotShareCode2] })] }));
    }
}
exports.default = VerifyCodeBody;
