import { needFullMonth } from "./dateHelper";
export var getMaskedDateOnInput = function getMaskedDateOnInput(value, format, delimiter, prevValue) {
    if (!value) {
        return '';
    }
    if (!format || !delimiter || needFullMonth(format)) {
        return value;
    }
    var dateRegExp = new RegExp("[^0-9".concat(delimiter, "]"), 'g');
    var formattedValue = value.replace(dateRegExp, '');
    if (formattedValue.length >= format.length) {
        return formattedValue.slice(0, format.length);
    }
    if (prevValue && formattedValue.length < prevValue.length && (prevValue === null || prevValue === void 0 ? void 0 : prevValue[formattedValue.length]) === delimiter) {
        return formattedValue.slice(0, -1);
    }
    if ((format === null || format === void 0 ? void 0 : format[formattedValue.length]) === delimiter) {
        return formattedValue + delimiter;
    }
    return formattedValue;
};
