// engine/detectors/advanced-framework-detector/index.ts
// Public API: detectAdvancedFrameworks + re-export of hint builder.
import { readPackageJson, getAllDeps } from './helpers.js';
import { detectModernFramework } from './modern-detector.js';
import { detectLegacyFrameworks, checkLegacyFromConfig } from './legacy-detector.js';
import { detectMicroFrontend } from './micro-frontend-detector.js';
import { detectEnterpriseDesignSystem } from './enterprise-ds-detector.js';
import { detectCSSInJS, detectStateManagement, buildSignalSources } from './css-state-detector.js';
export { buildAdvancedFrameworkHints } from '../advanced-framework-hints.js';
function detectAntDesignVersion(deps, pkg) {
    if (!deps.has('antd')) {
        return null;
    }
    const version = pkg.dependencies?.antd ?? pkg.devDependencies?.antd ?? '';
    const major = version.replace(/[^0-9]/, '').charAt(0);
    if (major === '4') {
        return '4';
    }
    /* v8 ignore next 1 */
    return '5';
}
function buildDetectionSignals(modernFramework, legacyFrameworks, microFrontend, enterpriseDS, cssInJS, stateManagement, signalSources) {
    const signals = [];
    if (modernFramework) {
        signals.push(`modern-framework: ${modernFramework}`);
    }
    for (const lf of legacyFrameworks) {
        signals.push(`legacy: ${lf}`);
    }
    if (microFrontend) {
        signals.push(`micro-frontend: ${microFrontend}`);
    }
    if (enterpriseDS) {
        signals.push(`design-system: ${enterpriseDS}`);
    }
    if (cssInJS) {
        signals.push(`css-in-js: ${cssInJS}`);
    }
    for (const sm of stateManagement) {
        signals.push(`state-mgmt: ${sm}`);
    }
    if (signalSources.length > 0) {
        signals.push(...signalSources);
    }
    return signals;
}
/**
 * Detects advanced frontend frameworks, legacy frameworks, micro-frontends,
 * enterprise design systems, CSS-in-JS approaches, and state management libraries.
 */
export async function detectAdvancedFrameworks(projectPath) {
    const pkg = await readPackageJson(projectPath);
    const deps = getAllDeps(pkg);
    const [modernResult, microFrontend, enterpriseDS, cssInJS] = await Promise.all([
        detectModernFramework(projectPath, deps, pkg),
        detectMicroFrontend(projectPath, deps),
        detectEnterpriseDesignSystem(projectPath, deps),
        detectCSSInJS(projectPath, deps),
    ]);
    const antDesignVersion = detectAntDesignVersion(deps, pkg);
    const legacyFromDeps = detectLegacyFrameworks(deps);
    const legacyFromConfig = await checkLegacyFromConfig(projectPath);
    const legacyFrameworks = [...new Set([...legacyFromDeps, ...legacyFromConfig])];
    const stateManagement = detectStateManagement(deps);
    const signalSources = buildSignalSources(deps);
    const detectionSignals = buildDetectionSignals(modernResult.framework, legacyFrameworks, microFrontend, enterpriseDS, cssInJS, stateManagement, signalSources);
    return {
        modernFramework: modernResult.framework,
        architecture: modernResult.architecture,
        legacyFrameworks,
        microFrontend,
        enterpriseDesignSystem: enterpriseDS,
        cssInJS,
        stateManagement,
        antDesignVersion,
        signals: detectionSignals,
    };
}
//# sourceMappingURL=index.js.map