// Email regex that doesn't allow consecutive dots
const emailRegex = /^(?!.*\.\.)[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@(?!.*\.\.)[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z]{2,}$/;
export const validateEmailFormat = (value) => {
    return emailRegex.test(value) || 'Please enter a valid email address';
};
export const extractEmailDomain = (email) => {
    const domain = email.split('@')[1]?.toLowerCase();
    return domain || null;
};
export const isDomainAllowed = (domain, allowedDomains) => {
    if (allowedDomains.length === 0)
        return true;
    return allowedDomains.some((allowedDomain) => allowedDomain.toLowerCase() === domain.toLowerCase());
};
/**
 * Validates if an email domain is in the allowed domains list
 * @param value - The email string to validate
 * @param options - Validation options containing allowed domains
 * @returns true if valid, error message if invalid
 */
export const validateEmailDomain = (value, options) => {
    if (options.allowedDomains.length === 0)
        return true;
    const domain = extractEmailDomain(value);
    if (!domain)
        return 'Invalid email format';
    const isAllowed = isDomainAllowed(domain, options.allowedDomains);
    return isAllowed || `Email domain must be one of: ${options.allowedDomains.join(', ')}`;
};
export const escapeIdForSelector = (id) => {
    return id.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g, '\\$&');
};
//# sourceMappingURL=utils.js.map