import { getMessages } from '../../../core/messages/index.js';
import { splitLines } from '../../../shared/helpers/index.js';
export function pontuarCssInJs(src, _relPath) {
    const m = getMessages().CssInJsPontuacaoMensagens;
    let score = 0;
    const maxScore = 100;
    const issues = [];
    const strengths = [];
    const _linhas = splitLines(src);
    const srcCompleto = src;
    if (!/styled-components|styled-jsx|emotion/i.test(srcCompleto)) {
        return { score: 0, maxScore, percentage: 0, issues: [m.notDetected], strengths: [] };
    }
    strengths.push(m.detected);
    if (!/createGlobalStyle|<style[^>]*global/i.test(srcCompleto)) {
        score += 25;
        strengths.push(m.noGlobalStyles);
    }
    else {
        issues.push(m.globalStylesIssue);
    }
    const importantCount = (srcCompleto.match(/!important/g) || []).length;
    if (importantCount === 0) {
        score += 20;
        strengths.push(m.noImportant);
    }
    else {
        issues.push(m.importantUsageCount(importantCount));
    }
    const httpUrls = (srcCompleto.match(/url\(\s*['"]?http:\/\//gi) || []).length;
    if (httpUrls === 0) {
        score += 15;
        strengths.push(m.noHttpUrls);
    }
    else {
        issues.push(m.httpUrlCount(httpUrls));
    }
    const hasMixed = /className=.*style=\{/.test(srcCompleto);
    if (!hasMixed) {
        score += 20;
        strengths.push(m.consistentStyling);
    }
    else {
        issues.push(m.mixedStylingIssue);
    }
    const hasTheme = /useTheme|theme\.|ThemeProvider/i.test(srcCompleto);
    if (hasTheme) {
        score += 20;
        strengths.push(m.themeUsage);
    }
    else {
        issues.push(m.noThemeSystem);
    }
    return {
        score,
        maxScore,
        percentage: Math.round((score / maxScore) * 100),
        issues,
        strengths
    };
}
export const pontuadorCssInJs = {
    nome: 'pontuador-css-in-js',
    categoria: 'estilo',
    descricao: 'Pontua qualidade de CSS-in-JS',
    pontuar: pontuarCssInJs
};
//# sourceMappingURL=scorer-css-in-js.js.map