import { wrapMinimal } from '../utils.js';
import { parseComCss } from './css.js';
export function parseComScss(codigo) {
    try {
        const variables = [...new Set(Array.from(codigo.matchAll(/\$([A-Za-z_][\w-]*)\s*:/g)).map(m => m[1]))];
        const mixins = Array.from(codigo.matchAll(/@mixin\s+([A-Za-z_][\w-]*)/g)).map(m => m[1]);
        const includes = Array.from(codigo.matchAll(/@include\s+([A-Za-z_][\w-]*)/g)).map(m => m[1]);
        const extends_ = Array.from(codigo.matchAll(/@extend\s+([%A-Za-z_][\w%-]*)/g)).map(m => m[1]);
        const functions_ = Array.from(codigo.matchAll(/@function\s+([A-Za-z_][\w-]*)/g)).map(m => m[1]);
        const nests = (codigo.match(/&/g) || []).length;
        const imports = Array.from(codigo.matchAll(/@(?:use|import|forward)\s+['"]([^'"]+)['"]/g)).map(m => m[1]);
        const placeholderSelectors = [...new Set(Array.from(codigo.matchAll(/%([A-Za-z_][\w-]*)/g)).map(m => m[1]))];
        if (variables.length === 0 && mixins.length === 0 && includes.length === 0 && extends_.length === 0) {
            return parseComCss(codigo);
        }
        return wrapMinimal('scss', {
            variables,
            mixins,
            includes,
            extends: extends_,
            functions: functions_,
            imports,
            placeholderSelectors,
            ifElse: (codigo.match(/@if\s|@else\s|@else\s+if/g) || []).length,
            eachLoops: (codigo.match(/@each\s/g) || []).length,
            forLoops: (codigo.match(/@for\s/g) || []).length,
            whileLoops: (codigo.match(/@while\s/g) || []).length,
            hasNesting: nests > 0,
            hasMixins: mixins.length > 0,
            hasVariables: variables.length > 0
        });
    }
    catch {
        return parseComCss(codigo);
    }
}
//# sourceMappingURL=scss.js.map