"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNextEntityName = exports.validateEmail = exports.EmailRegexString = exports.jsonPrettyPrint = exports.snakeCaseToDisplay = exports.camelCaseToDisplay = void 0;
const camelCaseToDisplay = (camelCaseString) => {
    return (camelCaseString.charAt(0).toUpperCase() + camelCaseString.slice(1)).replace(/([A-Z])/g, ' $1').trim();
};
exports.camelCaseToDisplay = camelCaseToDisplay;
const snakeCaseToDisplay = (snakeCaseString) => {
    return snakeCaseString.charAt(0).toUpperCase() + snakeCaseString.slice(1).replace('_', ' ').trim();
};
exports.snakeCaseToDisplay = snakeCaseToDisplay;
const jsonPrettyPrint = (obj) => {
    return JSON.stringify(obj, null, 2);
};
exports.jsonPrettyPrint = jsonPrettyPrint;
exports.EmailRegexString = '(([^<>()[\\].,;:\\s@\\"]+(\\.[^<>()[\\]\\.,;:\\s@\\"]+)*)|(\\".+\\"))@(([^<>()[\\]\\.,;:\\s@\\"]+\\.)+[^<>()[\\]\\.,;:\\s@\\"]{2,})';
const EmailRegexComplete = new RegExp(`^${exports.EmailRegexString}$`);
const validateEmail = (email) => {
    return EmailRegexComplete.test(email);
};
exports.validateEmail = validateEmail;
const getNextEntityName = (prefix, existingNames, separator = '_') => {
    const cleanName = (name) => {
        return (name
            // eslint-disable-next-line no-useless-escape
            .replace(/[\[\]\(\)\s]/g, separator)
            .replace(/^a-zA-Z0-9+/g, '')
            .replace(new RegExp(`${separator}+`, 'g'), separator));
    };
    const formattedPrefix = cleanName(prefix);
    const cleanedNames = existingNames.map((name) => cleanName(name.trim()));
    const regex = new RegExp(`^${formattedPrefix}(\\d+)$`);
    const usedIndices = cleanedNames.map((name) => {
        if (name && regex.test(name)) {
            const matches = name.match(regex);
            const ind = matches && Array.isArray(matches) ? parseInt(matches[1], 10) : 0;
            return Number.isNaN(ind) ? 0 : ind;
        }
        return 0;
    });
    const lastIndex = Math.max(...usedIndices, ...[0]);
    return `${formattedPrefix}${lastIndex + 1}`;
};
exports.getNextEntityName = getNextEntityName;
//# sourceMappingURL=string.js.map