"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeDepartmentValue = normalizeDepartmentValue;
const normalize_department_object_1 = require("./normalize-department-object");
/**
 * 标准化部门选择器的值
 */
function normalizeDepartmentValue(value, componentProps) {
    const isMultiple = (componentProps === null || componentProps === void 0 ? void 0 : componentProps.multiple) === true;
    if (isMultiple) {
        // 多选：返回数组
        if (!Array.isArray(value)) {
            return [(0, normalize_department_object_1.normalizeDepartmentObject)(value)];
        }
        return value.map((item) => (0, normalize_department_object_1.normalizeDepartmentObject)(item));
    }
    else {
        // 单选：返回单个值
        if (Array.isArray(value)) {
            return value.length > 0 ? (0, normalize_department_object_1.normalizeDepartmentObject)(value[0]) : undefined;
        }
        return (0, normalize_department_object_1.normalizeDepartmentObject)(value);
    }
}
