import { wrapMinimal } from '../utils.js';
export function parseComCss(codigo) {
    try {
        if (!codigo || !codigo.trim())
            return null;
        const classes = [...new Set(Array.from(codigo.matchAll(/\.([A-Za-z_][\w-]*)/g)).map(m => m[1]))];
        const ids = [...new Set(Array.from(codigo.matchAll(/#([A-Za-z_][\w-]*)/g)).map(m => m[1]))];
        const tags = [...new Set(Array.from(codigo.matchAll(/(?:\s|^|,|\{)([A-Za-z][\w-]*)(?=\s*[#.:\s\[{])/g)).map(m => m[1]).filter(t => !['px', 'em', 'rem', 'vh', 'vw', 'important'].includes(t)))];
        const blockRegex = /([^{]+)\{([^}]*)\}/g;
        let blockMatch;
        let rules = 0;
        const ruleDetails = [];
        while ((blockMatch = blockRegex.exec(codigo)) !== null) {
            const selectors = blockMatch[1].split(',').map(s => s.trim()).filter(Boolean);
            const declarations = blockMatch[2].split(';').filter(d => d.trim()).length;
            if (selectors.length > 0) {
                rules++;
                ruleDetails.push({ selectors, declarations });
            }
        }
        return wrapMinimal('css', {
            classes,
            ids,
            tags,
            rules,
            ruleDetails,
            customProperties: [...new Set(Array.from(codigo.matchAll(/--([A-Za-z_][\w-]*)\s*:/g)).map(m => m[1]))],
            hasKeyframes: /@keyframes\s/i.test(codigo) || /@-webkit-keyframes\s/i.test(codigo),
            hasMedia: /@media\s/i.test(codigo),
            hasSupports: /@supports\s/i.test(codigo),
            hasContainer: /@container\s/i.test(codigo),
            imports: Array.from(codigo.matchAll(/@import\s+['"]([^'"]+)['"]/g)).map(m => m[1]),
            fontFaces: (codigo.match(/@font-face\s*\{/gi) || []).length,
            totalSelectors: classes.length + ids.length + tags.length
        });
    }
    catch {
        return null;
    }
}
//# sourceMappingURL=css.js.map