import { splitLines } from '../../../shared/helpers/index.js';
export function pontuarSvg(src, _relPath) {
    let score = 0;
    const maxScore = 100;
    const issues = [];
    const strengths = [];
    const _linhas = splitLines(src);
    const srcCompleto = src;
    if (!/<svg\b/i.test(srcCompleto)) {
        return { score: 0, maxScore, percentage: 0, issues: ['SVG inválido'], strengths: [] };
    }
    if (!/<script\b/i.test(srcCompleto)) {
        score += 25;
        strengths.push('Sem scripts inline');
    }
    else {
        issues.push('Script inline detectado');
    }
    const handlers = (srcCompleto.match(/\son\w+\s*=/gi) || []).length;
    if (handlers === 0) {
        score += 20;
        strengths.push('Sem event handlers inline');
    }
    else {
        issues.push(`${handlers} event handler(s) inline`);
    }
    if (!/javascript\s*:/i.test(srcCompleto)) {
        score += 20;
        strengths.push('Sem URLs javascript:');
    }
    else {
        issues.push('URL javascript: detectado');
    }
    if (/\bviewBox\s*=\s*['"][^'"]+['"]/i.test(srcCompleto)) {
        score += 15;
        strengths.push('viewBox definido');
    }
    else {
        issues.push('viewBox ausente');
    }
    if (/\bwidth\s*=\s*['"]\d+['"]/i.test(srcCompleto) && /\bheight\s*=\s*['"]\d+['"]/i.test(srcCompleto)) {
        score += 10;
        strengths.push('Dimensões definidas');
    }
    else {
        issues.push('Dimensões ausentes');
    }
    if (/<title>|aria-label|role=/i.test(srcCompleto)) {
        score += 10;
        strengths.push('Acessibilidade considerada');
    }
    else {
        issues.push('Sem título ou aria-label');
    }
    return {
        score,
        maxScore,
        percentage: Math.round((score / maxScore) * 100),
        issues,
        strengths
    };
}
export const pontuadorSvg = {
    nome: 'pontuador-svg',
    categoria: 'assets',
    descricao: 'Pontua qualidade de SVG',
    pontuar: pontuarSvg
};
//# sourceMappingURL=scorer-svg.js.map