const allowedVideoExtensions = ['mp4', 'mov', 'avi'];
export const isValidTelephoneNumber = (value) => {
    if (!value) {
        return false;
    }
    const cleanValue = value.replace(/\s+/g, '');
    if (cleanValue.startsWith('+')) {
        if (cleanValue.length < 4 || cleanValue.length > 15) {
            return false;
        }
        const numberPart = cleanValue.substring(1);
        return /^\d+$/.test(numberPart);
    }
    if (cleanValue.length >= 3 && cleanValue.length <= 4) {
        return /^\d+$/.test(cleanValue);
    }
    if (cleanValue.length >= 8 && cleanValue.length <= 10) {
        return /^\d+$/.test(cleanValue);
    }
    return false;
};
export const isValidEmail = (value) => {
    if (!value) {
        return false;
    }
    return /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(value);
};
export const isValidUrl = (value) => {
    if (!value) {
        return false;
    }
    const cleanValue = value.trim();
    try {
        const parsed = new URL(cleanValue);
        const scheme = parsed.protocol.replace(':', '').toLowerCase();
        if (scheme !== 'http' && scheme !== 'https') {
            return false;
        }
        const host = parsed.hostname;
        if (!host || !host.includes('.')) {
            return false;
        }
        if (host.startsWith('.') || host.endsWith('.')) {
            return false;
        }
        if (!/^[a-zA-Z0-9.-]+$/.test(host)) {
            return false;
        }
        return true;
    }
    catch (e) {
        return false;
    }
};
export const isValidVideoUrl = (value) => {
    if (!value || !isValidUrl(value)) {
        return false;
    }
    try {
        const parsed = new URL(value.trim());
        const pathname = parsed.pathname.toLowerCase();
        return allowedVideoExtensions.some(extension => pathname.endsWith(`.${extension}`));
    }
    catch (e) {
        return false;
    }
};
