import $i18n from '../../../../../../../../locales/i18n.js';
/**
 * 用户格式文本提取器
 */
import isPlainObject from 'lodash/isPlainObject';
import isNil from 'lodash/isNil';
/**
 * 从单个用户对象提取文本
 */
function extractSingleUserText(user, showDepartTag) {
    if (!isPlainObject(user))
        return '';
    const { name, nickName, workStatus } = user;
    let text = name || '';
    if (nickName) {
        text += `(${nickName})`;
    }
    if (showDepartTag && workStatus === false) {
        text += $i18n.get({ id: 'Resigned', dm: '已离职' });
    }
    return text;
}
/**
 * 用户文本提取器
 */
export function extractUserText(value, column) {
    var _a;
    // 处理空值
    if (isNil(value) || value === '') {
        return '';
    }
    const showDepartTag = (_a = column === null || column === void 0 ? void 0 : column.showDepartTag) !== null && _a !== void 0 ? _a : false;
    // 处理数组
    if (Array.isArray(value)) {
        if (value.length === 0) {
            return '';
        }
        return value
            .map((user) => extractSingleUserText(user, showDepartTag))
            .filter(Boolean)
            .join(' ');
    }
    // 处理单个对象
    if (isPlainObject(value)) {
        const text = extractSingleUserText(value, showDepartTag);
        return text || '';
    }
    return '';
}
