"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertValuesToDate = exports.getEditorLabel = void 0;
var ramda_1 = require("ramda");
var mdm_sdk_1 = require("@reltio/mdm-sdk");
var formatValue = function (value, dataTypeDefinition, dateTimeMask) {
    return (0, ramda_1.isNil)(value) ? "".concat(dateTimeMask) : "".concat((0, mdm_sdk_1.formatDataTypeValue)({ dataTypeDefinition: dataTypeDefinition, dateTimeMask: dateTimeMask }, value));
};
var getEditorLabel = function (placeholder, dataTypeDefinition, value, options) {
    return (0, ramda_1.cond)([
        [mdm_sdk_1.isEmptyValue, (0, ramda_1.always)('')],
        [
            (0, ramda_1.is)(Array),
            function (value) { return value.map(function (value) { return formatValue(value, dataTypeDefinition, placeholder); }).join(' \u2014 '); }
        ],
        [(0, ramda_1.is)(String), function (value) { var _a; return (_a = options.find((0, ramda_1.propEq)('value', value))) === null || _a === void 0 ? void 0 : _a.label; }]
    ])(value);
};
exports.getEditorLabel = getEditorLabel;
exports.convertValuesToDate = (0, ramda_1.pipe)(mdm_sdk_1.getDateRangeByValue, (0, ramda_1.defaultTo)([]), (0, ramda_1.map)(function (value) { return value && new Date(value); }));
