// ---------------------------------------------------------------------------
// Category map: category → known packages in that category
// ---------------------------------------------------------------------------
const CATEGORY_MAP = {
    'http-client': [
        'axios',
        'got',
        'node-fetch',
        'ky',
        'superagent',
        'request',
        'undici',
        'cross-fetch',
    ],
    'date-library': ['moment', 'dayjs', 'date-fns', 'luxon', 'fecha'],
    'test-runner': ['jest', 'mocha', 'vitest', 'jasmine', 'ava', 'tap', 'tape'],
    'assertion-library': ['chai', 'expect', 'assert', 'should', '@testing-library/jest-dom'],
    logger: ['winston', 'pino', 'bunyan', 'log4js', 'morgan', 'signale', 'consola'],
    validation: ['joi', 'yup', 'zod', 'ajv', 'valibot', 'superstruct', 'io-ts'],
    orm: ['sequelize', 'typeorm', 'prisma', 'drizzle', 'knex', 'mongoose', 'mikro-orm'],
    'state-management': ['redux', 'mobx', 'zustand', 'recoil', 'jotai', 'valtio', 'xstate', 'pinia'],
    'css-in-js': [
        'styled-components',
        'emotion',
        '@emotion/react',
        'stitches',
        'linaria',
        'vanilla-extract',
    ],
    bundler: ['webpack', 'vite', 'rollup', 'esbuild', 'parcel', 'turbopack'],
    uuid: ['uuid', 'nanoid', 'cuid', 'cuid2', 'ulid', 'ksuid'],
    'env-loading': ['dotenv', 'dotenv-expand', 'envalid', '@t3-oss/env-core', 'env-var'],
    'graphql-client': ['apollo-client', '@apollo/client', 'urql', 'graphql-request'],
    auth: ['passport', 'next-auth', '@auth/core', 'better-auth', 'lucia'],
    'task-queue': ['bull', 'bullmq', 'bee-queue', 'agenda', 'kue'],
};
// Preferred recommendation per category (first = preferred)
const CATEGORY_PREFERRED = {
    'http-client': 'axios or node native fetch',
    'date-library': 'date-fns (tree-shakable) or dayjs (lightweight)',
    'test-runner': 'vitest (fast, ESM-native)',
    'assertion-library': 'vitest built-in expect',
    logger: 'pino (high performance)',
    validation: 'zod (type-safe, TS-first)',
    orm: 'prisma (type-safe) or drizzle (lightweight)',
    'state-management': 'zustand (minimal) or redux (complex apps)',
    'css-in-js': 'emotion or vanilla-extract (zero-runtime)',
    bundler: 'vite (fast DX)',
    uuid: 'nanoid (small) or crypto.randomUUID() (native)',
    'env-loading': 'dotenv (simple) or @t3-oss/env-core (type-safe)',
    'graphql-client': '@apollo/client or urql (lightweight)',
    auth: 'next-auth or lucia (framework-specific)',
    'task-queue': 'bullmq (Redis-backed)',
};
// ---------------------------------------------------------------------------
// Public API
// ---------------------------------------------------------------------------
/**
 * Detect duplicate dependencies with similar purpose.
 * Returns a list of duplicate groups found in the provided dep names.
 */
export function detectDuplicates(depNames) {
    const depSet = new Set(depNames.map((d) => d.toLowerCase()));
    const duplicates = [];
    for (const [category, members] of Object.entries(CATEGORY_MAP)) {
        const found = members.filter((m) => depSet.has(m.toLowerCase()));
        if (found.length >= 2) {
            /* v8 ignore next 1 */
            const preferred = CATEGORY_PREFERRED[category] ?? found[0] ?? members[0] ?? category;
            duplicates.push({
                category,
                packages: found,
                recommendation: `Keep only one ${category} library. Recommended: ${preferred}. Remove: ${found.slice(1).join(', ')}.`,
            });
        }
    }
    return duplicates;
}
/** Expose the category map for testing and extension. */
export { CATEGORY_MAP };
//# sourceMappingURL=dep-duplicates-detector.js.map