import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useMemo, useEffect, useState } from 'react';
import { Box, Text } from 'ink';
import { theme } from '../semantic-colors.js';
import { UserAccountManager, AuthType, } from '@google/gemini-cli-core';
export const UserIdentity = ({ config }) => {
    const authType = config.getContentGeneratorConfig()?.authType;
    const [email, setEmail] = useState();
    useEffect(() => {
        if (authType) {
            const userAccountManager = new UserAccountManager();
            setEmail(userAccountManager.getCachedGoogleAccount() ?? undefined);
        }
    }, [authType]);
    const tierName = useMemo(() => (authType ? config.getUserTierName() : undefined), [config, authType]);
    if (!authType) {
        return null;
    }
    return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: theme.text.primary, wrap: "truncate-end", children: authType === AuthType.LOGIN_WITH_GOOGLE ? (_jsx(Text, { children: email ?? 'Logged in with Google' })) : (`Authenticated with ${authType}`) }), _jsx(Text, { color: theme.text.secondary, children: " /auth" })] }), tierName && (_jsxs(Box, { children: [_jsx(Text, { color: theme.text.primary, wrap: "truncate-end", children: tierName }), _jsx(Text, { color: theme.text.secondary, children: " /upgrade" })] }))] }));
};
//# sourceMappingURL=UserIdentity.js.map