import { capitalize } from 'es-toolkit';
import { useMemo } from 'react';
import { useSiteOverrides } from '../hooks/index.js';
import { handleCJKWhitespaces } from '../utils.js';
export const Term = ({ name, textCase }) => {
    const { terms } = useSiteOverrides();
    const text = useMemo(() => {
        const origin = handleCJKWhitespaces(terms?.[name]);
        if (!origin) {
            return origin;
        }
        switch (textCase) {
            case 'lower': {
                return origin.toLowerCase();
            }
            case 'upper': {
                return origin.toUpperCase();
            }
            case 'capitalize': {
                return origin.split(/\b/).map(capitalize).join('');
            }
            default: {
                return origin;
            }
        }
    }, [terms, name, textCase]);
    return text;
};
export default Term;
