"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasName = hasName;
exports.findName = findName;
exports.garnishPersonWithName = garnishPersonWithName;
const models = require("../../icc-api/model/models");
function hasName(person, nameUse) {
    var _a;
    return (_a = person.names) === null || _a === void 0 ? void 0 : _a.some((n) => n.use === nameUse);
}
function findName(person, nameUse) {
    var _a;
    return (_a = person.names) === null || _a === void 0 ? void 0 : _a.find((n) => n.use === nameUse);
}
function garnishPersonWithName(person, nameUse, lastName, firstName, fullName = `${lastName} ${firstName !== null && firstName !== void 0 ? firstName : ''}`) {
    var _a;
    return Object.assign(Object.assign({}, person), { names: ((_a = person.names) !== null && _a !== void 0 ? _a : []).concat([
            new models.PersonName({
                lastName: lastName,
                firstNames: firstName ? [firstName] : [],
                text: fullName,
                use: nameUse,
            }),
        ]) });
}
//# sourceMappingURL=person-util.js.map