// Planu — Web Fetcher: Version check orchestration
import { checkPackageVersions } from '../package-registry.js';
export async function resolveVersionStatuses(dependencies, language) {
    try {
        return await checkPackageVersions(dependencies, language);
    }
    catch {
        return Object.entries(dependencies).map(([name, version]) => ({
            name,
            currentVersion: version.replace(/[\^~>=<]/g, ''),
            latestVersion: version.replace(/[\^~>=<]/g, ''),
            updateType: 'up-to-date',
            deprecated: false,
            checkedAt: new Date().toISOString(),
        }));
    }
}
export function buildVersionsResult(depStatuses) {
    const securityAlerts = depStatuses.filter((d) => d.updateType === 'security').length;
    const updatesAvailable = depStatuses.filter((d) => d.updateType !== 'up-to-date').length;
    let recommendation = 'All dependencies are up to date.';
    if (securityAlerts > 0) {
        recommendation = `${String(securityAlerts)} security update(s) found. Update these dependencies immediately.`;
    }
    else if (updatesAvailable > 0) {
        recommendation = `${String(updatesAvailable)} update(s) available. Review changelogs before updating.`;
    }
    return { dependencies: depStatuses, securityAlerts, updatesAvailable, recommendation };
}
//# sourceMappingURL=version-checker.js.map