import { existsSync } from 'node:fs';
import { join, resolve as resolvePath } from 'node:path';
import { pathToFileURL } from 'node:url';
const aliases = {
    "@": "./src/types/index",
    "@analysts/architects": "./src/analysts/architects/index",
    "@analysts/azure-pipelines": "./src/analysts/azure-pipelines/index",
    "@analysts/azure-pipelines/analysts": "./src/analysts/azure-pipelines/analysts/index",
    "@analysts/azure-pipelines/corrections": "./src/analysts/azure-pipelines/corrections/index",
    "@analysts/azure-pipelines/detectors": "./src/analysts/azure-pipelines/detectors/index",
    "@analysts/azure-pipelines/reports": "./src/analysts/azure-pipelines/reports/index",
    "@analysts/azure-pipelines/scorers": "./src/analysts/azure-pipelines/scorers/index",
    "@analysts/circleci": "./src/analysts/circleci/index",
    "@analysts/circleci/analysts": "./src/analysts/circleci/analysts/index",
    "@analysts/circleci/corrections": "./src/analysts/circleci/corrections/index",
    "@analysts/circleci/detectors": "./src/analysts/circleci/detectors/index",
    "@analysts/circleci/reports": "./src/analysts/circleci/reports/index",
    "@analysts/circleci/scorers": "./src/analysts/circleci/scorers/index",
    "@analysts/converters": "./src/analysts/converters/index",
    "@analysts/converters/engines": "./src/analysts/converters/engines/index",
    "@analysts/corrections": "./src/analysts/corrections/index",
    "@analysts/corrections/quick-fixes": "./src/analysts/corrections/quick-fixes/index",
    "@analysts/corrections/type-safety": "./src/analysts/corrections/type-safety/index",
    "@analysts/css": "./src/analysts/css/index",
    "@analysts/css-in-js": "./src/analysts/css-in-js/index",
    "@analysts/css-in-js/analysts": "./src/analysts/css-in-js/analysts/index",
    "@analysts/css-in-js/corrections": "./src/analysts/css-in-js/corrections/index",
    "@analysts/css-in-js/detectors": "./src/analysts/css-in-js/detectors/index",
    "@analysts/css-in-js/scorers": "./src/analysts/css-in-js/scorers/index",
    "@analysts/css/analysts": "./src/analysts/css/analysts/index",
    "@analysts/css/corrections": "./src/analysts/css/corrections/index",
    "@analysts/css/detectors": "./src/analysts/css/detectors/index",
    "@analysts/css/scorers": "./src/analysts/css/scorers/index",
    "@analysts/detectors": "./src/analysts/detectors/index",
    "@analysts/github-actions": "./src/analysts/github-actions/index",
    "@analysts/github-actions/analysts": "./src/analysts/github-actions/analysts/index",
    "@analysts/github-actions/corrections": "./src/analysts/github-actions/corrections/index",
    "@analysts/github-actions/detectors": "./src/analysts/github-actions/detectors/index",
    "@analysts/github-actions/reports": "./src/analysts/github-actions/reports/index",
    "@analysts/github-actions/scorers": "./src/analysts/github-actions/scorers/index",
    "@analysts/gitlab-ci": "./src/analysts/gitlab-ci/index",
    "@analysts/gitlab-ci/analysts": "./src/analysts/gitlab-ci/analysts/index",
    "@analysts/gitlab-ci/corrections": "./src/analysts/gitlab-ci/corrections/index",
    "@analysts/gitlab-ci/detectors": "./src/analysts/gitlab-ci/detectors/index",
    "@analysts/gitlab-ci/reports": "./src/analysts/gitlab-ci/reports/index",
    "@analysts/gitlab-ci/scorers": "./src/analysts/gitlab-ci/scorers/index",
    "@analysts/go": "./src/analysts/go/index",
    "@analysts/go/analysts": "./src/analysts/go/analysts/index",
    "@analysts/go/detectors": "./src/analysts/go/detectors/index",
    "@analysts/html": "./src/analysts/html/index",
    "@analysts/html/analysts": "./src/analysts/html/analysts/index",
    "@analysts/html/corrections": "./src/analysts/html/corrections/index",
    "@analysts/html/detectors": "./src/analysts/html/detectors/index",
    "@analysts/html/scorers": "./src/analysts/html/scorers/index",
    "@analysts/jenkins": "./src/analysts/jenkins/index",
    "@analysts/jenkins/analysts": "./src/analysts/jenkins/analysts/index",
    "@analysts/jenkins/corrections": "./src/analysts/jenkins/corrections/index",
    "@analysts/jenkins/detectors": "./src/analysts/jenkins/detectors/index",
    "@analysts/jenkins/reports": "./src/analysts/jenkins/reports/index",
    "@analysts/jenkins/scorers": "./src/analysts/jenkins/scorers/index",
    "@analysts/js-ts": "./src/analysts/js-ts/index",
    "@analysts/js-ts/analysts": "./src/analysts/js-ts/analysts/index",
    "@analysts/js-ts/detectors": "./src/analysts/js-ts/detectors/index",
    "@analysts/php": "./src/analysts/php/index",
    "@analysts/php/analysts": "./src/analysts/php/analysts/index",
    "@analysts/plugins": "./src/analysts/plugins/index",
    "@analysts/python": "./src/analysts/python/index",
    "@analysts/python/analysts": "./src/analysts/python/analysts/index",
    "@analysts/python/corrections": "./src/analysts/python/corrections/index",
    "@analysts/python/detectors": "./src/analysts/python/detectors/index",
    "@analysts/python/scorers": "./src/analysts/python/scorers/index",
    "@analysts/react": "./src/analysts/react/index",
    "@analysts/react/analysts": "./src/analysts/react/analysts/index",
    "@analysts/react/corrections": "./src/analysts/react/corrections/index",
    "@analysts/react/detectors": "./src/analysts/react/detectors/index",
    "@analysts/react/scorers": "./src/analysts/react/scorers/index",
    "@analysts/registry": "./src/analysts/registry/index",
    "@analysts/rust": "./src/analysts/rust/index",
    "@analysts/rust/analysts": "./src/analysts/rust/analysts/index",
    "@analysts/rust/detectors": "./src/analysts/rust/detectors/index",
    "@analysts/scorers": "./src/analysts/scorers/index",
    "@analysts/shell": "./src/analysts/shell/index",
    "@analysts/shell/analysts": "./src/analysts/shell/analysts/index",
    "@analysts/shell/corrections": "./src/analysts/shell/corrections/index",
    "@analysts/shell/detectors": "./src/analysts/shell/detectors/index",
    "@analysts/shell/scorers": "./src/analysts/shell/scorers/index",
    "@analysts/sql": "./src/analysts/sql/index",
    "@analysts/sql/analysts": "./src/analysts/sql/analysts/index",
    "@analysts/sql/corrections": "./src/analysts/sql/corrections/index",
    "@analysts/sql/detectors": "./src/analysts/sql/detectors/index",
    "@analysts/sql/scorers": "./src/analysts/sql/scorers/index",
    "@analysts/strategists": "./src/analysts/strategists/index",
    "@analysts/svg": "./src/analysts/svg/index",
    "@analysts/svg/analysts": "./src/analysts/svg/analysts/index",
    "@analysts/svg/corrections": "./src/analysts/svg/corrections/index",
    "@analysts/svg/detectors": "./src/analysts/svg/detectors/index",
    "@analysts/svg/scorers": "./src/analysts/svg/scorers/index",
    "@analysts/tailwind": "./src/analysts/tailwind/index",
    "@analysts/tailwind/analysts": "./src/analysts/tailwind/analysts/index",
    "@analysts/tailwind/corrections": "./src/analysts/tailwind/corrections/index",
    "@analysts/tailwind/detectors": "./src/analysts/tailwind/detectors/index",
    "@analysts/tailwind/scorers": "./src/analysts/tailwind/scorers/index",
    "@analysts/xml": "./src/analysts/xml/index",
    "@analysts/xml/analysts": "./src/analysts/xml/analysts/index",
    "@analysts/xml/corrections": "./src/analysts/xml/corrections/index",
    "@analysts/xml/detectors": "./src/analysts/xml/detectors/index",
    "@analysts/xml/scorers": "./src/analysts/xml/scorers/index",
    "@api": "./src/api/index",
    "@api/middleware": "./src/api/middleware/index",
    "@api/routes": "./src/api/routes/index",
    "@api/server": "./src/api/server",
    "@api/services": "./src/api/services/index",
    "@app": "./src/app/index",
    "@app/changelog": "./src/app/changelog/index",
    "@app/github": "./src/app/github/app/index",
    "@app/github/app": "./src/app/github/app/index",
    "@app/github/dashboard": "./src/app/github/dashboard/index",
    "@app/github/jobs": "./src/app/github/jobs/index",
    "@app/github/push-analysis": "./src/app/github/push-analysis/index",
    "@app/privacy-policy": "./src/app/privacy-policy/index",
    "@app/terms-of-use": "./src/app/terms-of-use/index",
    "@caretakers": "./src/caretakers/index",
    "@cli": "./src/cli/index",
    "@cli/commands": "./src/cli/commands/index",
    "@cli/diagnostic": "./src/cli/diagnostic/index",
    "@cli/diagnostic/exporters": "./src/cli/diagnostic/exporters/index",
    "@cli/diagnostic/handlers": "./src/cli/diagnostic/handlers/index",
    "@cli/handlers": "./src/cli/handlers/index",
    "@cli/helpers": "./src/cli/helpers/index",
    "@cli/options": "./src/cli/options/index",
    "@cli/processing": "./src/cli/processing/index",
    "@core/config": "./src/core/config/index",
    "@core/config/auto": "./src/core/config/auto/index",
    "@core/execution": "./src/core/execution/index",
    "@core/formatters": "./src/core/formatters/index",
    "@core/messages": "./src/core/messages/index",
    "@core/messages/en": "./src/core/messages/en/index",
    "@core/messages/en/analysts": "./src/core/messages/en/analysts/index",
    "@core/messages/en/api": "./src/core/messages/en/api/index",
    "@core/messages/en/caretakers": "./src/core/messages/en/caretakers/index",
    "@core/messages/en/cli": "./src/core/messages/en/cli/index",
    "@core/messages/en/core": "./src/core/messages/en/core/index",
    "@core/messages/en/github": "./src/core/messages/en/github/index",
    "@core/messages/en/guardian": "./src/core/messages/en/guardian/index",
    "@core/messages/en/licenses": "./src/core/messages/en/licenses/index",
    "@core/messages/en/log": "./src/core/messages/en/log/index",
    "@core/messages/en/reports": "./src/core/messages/en/reports/index",
    "@core/messages/en/shared": "./src/core/messages/en/shared/index",
    "@core/messages/en/ui": "./src/core/messages/en/ui/index",
    "@core/messages/ja": "./src/core/messages/ja/index",
    "@core/messages/ja/analysts": "./src/core/messages/ja/analysts/index",
    "@core/messages/ja/api": "./src/core/messages/ja/api/index",
    "@core/messages/ja/caretakers": "./src/core/messages/ja/caretakers/index",
    "@core/messages/ja/cli": "./src/core/messages/ja/cli/index",
    "@core/messages/ja/core": "./src/core/messages/ja/core/index",
    "@core/messages/ja/github": "./src/core/messages/ja/github/index",
    "@core/messages/ja/guardian": "./src/core/messages/ja/guardian/index",
    "@core/messages/ja/licenses": "./src/core/messages/ja/licenses/index",
    "@core/messages/ja/log": "./src/core/messages/ja/log/index",
    "@core/messages/ja/reports": "./src/core/messages/ja/reports/index",
    "@core/messages/ja/shared": "./src/core/messages/ja/shared/index",
    "@core/messages/ja/ui": "./src/core/messages/ja/ui/index",
    "@core/messages/pt": "./src/core/messages/pt/index",
    "@core/messages/pt/analysts": "./src/core/messages/pt/analysts/index",
    "@core/messages/pt/api": "./src/core/messages/pt/api/index",
    "@core/messages/pt/caretakers": "./src/core/messages/pt/caretakers/index",
    "@core/messages/pt/cli": "./src/core/messages/pt/cli/index",
    "@core/messages/pt/core": "./src/core/messages/pt/core/index",
    "@core/messages/pt/github": "./src/core/messages/pt/github/index",
    "@core/messages/pt/guardian": "./src/core/messages/pt/guardian/index",
    "@core/messages/pt/licenses": "./src/core/messages/pt/licenses/index",
    "@core/messages/pt/log": "./src/core/messages/pt/log/index",
    "@core/messages/pt/reports": "./src/core/messages/pt/reports/index",
    "@core/messages/pt/shared": "./src/core/messages/pt/shared/index",
    "@core/messages/pt/ui": "./src/core/messages/pt/ui/index",
    "@core/messages/shared": "./src/core/messages/shared/index",
    "@core/messages/zh": "./src/core/messages/zh/index",
    "@core/messages/zh/analysts": "./src/core/messages/zh/analysts/index",
    "@core/messages/zh/api": "./src/core/messages/zh/api/index",
    "@core/messages/zh/caretakers": "./src/core/messages/zh/caretakers/index",
    "@core/messages/zh/cli": "./src/core/messages/zh/cli/index",
    "@core/messages/zh/core": "./src/core/messages/zh/core/index",
    "@core/messages/zh/github": "./src/core/messages/zh/github/index",
    "@core/messages/zh/guardian": "./src/core/messages/zh/guardian/index",
    "@core/messages/zh/licenses": "./src/core/messages/zh/licenses/index",
    "@core/messages/zh/log": "./src/core/messages/zh/log/index",
    "@core/messages/zh/reports": "./src/core/messages/zh/reports/index",
    "@core/messages/zh/shared": "./src/core/messages/zh/shared/index",
    "@core/messages/zh/ui": "./src/core/messages/zh/ui/index",
    "@core/parsing": "./src/core/parsing/index",
    "@core/parsing/langs": "./src/core/parsing/langs/index",
    "@core/registry": "./src/core/registry/index",
    "@core/reporting": "./src/core/reporting/index",
    "@core/runtime": "./src/core/runtime/index",
    "@core/schema": "./src/core/schema/index",
    "@core/utils": "./src/core/utils/index",
    "@core/workers": "./src/core/workers/index",
    "@guardian": "./src/guardian/index",
    "@lib": "./src/lib/index",
    "@licenses": "./src/licenses/index",
    "@lsp": "./src/lsp/index",
    "@reports": "./src/reports/index",
    "@reports/compliance": "./src/reports/compliance/index",
    "@sdk": "./src/sdk/index",
    "@shared": "./src/shared/index",
    "@shared/data-processing": "./src/shared/data-processing/index",
    "@shared/formatters": "./src/shared/formatters/index",
    "@shared/formatters/core": "./src/shared/formatters/core/index",
    "@shared/formatters/engines": "./src/shared/formatters/engines/index",
    "@shared/formatters/formatters": "./src/shared/formatters/formatters/index",
    "@shared/helpers": "./src/shared/helpers/index",
    "@shared/marketplace": "./src/shared/marketplace/index",
    "@shared/persistence": "./src/shared/persistence/index",
    "@shared/plugins": "./src/shared/plugins/index",
    "@shared/validation": "./src/shared/validation/index",
    "@types": "./src/types/index",
    "@types/analysts": "./src/types/analysts/index",
    "@types/analysts/corrections": "./src/types/analysts/corrections/index",
    "@types/analysts/html": "./src/types/analysts/html",
    "@types/caretakers": "./src/types/caretakers/index",
    "@types/cli": "./src/types/cli/index",
    "@types/common": "./src/types/common/index",
    "@types/core": "./src/types/core/index",
    "@types/core/config": "./src/types/core/config/index",
    "@types/core/corrections": "./src/types/core/corrections/index",
    "@types/core/execution": "./src/types/core/execution/index",
    "@types/core/parsing": "./src/types/core/parsing/index",
    "@types/core/utils": "./src/types/core/utils/index",
    "@types/github": "./src/types/github/index",
    "@types/guardian": "./src/types/guardian/index",
    "@types/licenses": "./src/types/licenses/index",
    "@types/project": "./src/types/project/index",
    "@types/reports": "./src/types/reports/index",
    "@types/scripts": "./src/types/scripts/index",
    "@types/sdk": "./src/types/sdk/index",
    "@types/shared": "./src/types/shared/index",
    "@types/structure": "./src/types/structure/index",
    "@types/types": "./src/types/index",
    "@types/vulnerabilities": "./src/types/vulnerabilities/index",
    "@vulnerabilities": "./src/vulnerabilities/index",
};
export async function resolve(specifier, context, nextResolve) {
    if (!specifier.startsWith('@')) {
        return nextResolve(specifier, context);
    }
    let resolved = null;
    const sortedAliases = Object.entries(aliases).sort((arquivo, base) => base[0].length - arquivo[0].length);
    for (const [prefix, replacement] of sortedAliases) {
        const isExactMatch = specifier === prefix;
        const isPrefixMatch = prefix.endsWith('/') && specifier.startsWith(prefix);
        if (isExactMatch || isPrefixMatch) {
            const remaining = isExactMatch ? '' : specifier.slice(prefix.length);
            const newPath = replacement + remaining;
            const parentURL = context.parentURL;
            let basePath = '';
            if (parentURL) {
                const parentPath = new URL(parentURL).pathname;
                if (parentPath.includes('/dist/')) {
                    basePath = resolvePath(parentPath.split('/dist/')[0], 'dist');
                }
                else if (parentPath.includes('/src/')) {
                    basePath = resolvePath(parentPath.split('/src/')[0], 'src');
                }
                else {
                    basePath = resolvePath(process.cwd(), 'src');
                }
            }
            else {
                basePath = resolvePath(process.cwd(), 'src');
            }
            let fullPath = join(basePath, newPath);
            if (basePath.endsWith('/src') && fullPath.endsWith('.js')) {
                const tsPath = `${fullPath.slice(0, -3)}`;
                const tsxPath = `${fullPath.slice(0, -3)}x`;
                if (existsSync(tsPath)) {
                    fullPath = tsPath;
                }
                else if (existsSync(tsxPath)) {
                    fullPath = tsxPath;
                }
            }
            const extensions = ['.js', '.ts', '.tsx', '.mjs', '.cjs'];
            let finalPath = fullPath;
            if (!existsSync(fullPath)) {
                let found = false;
                const currentExt = extensions?.find(ext => fullPath.endsWith(ext));
                const pathSemExt = currentExt ? fullPath.slice(0, -currentExt.length) : fullPath;
                for (const ext of extensions) {
                    const testPath = pathSemExt + ext;
                    if (existsSync(testPath)) {
                        finalPath = testPath;
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    for (const ext of extensions) {
                        const testPath = join(pathSemExt, `index${ext}`);
                        if (existsSync(testPath)) {
                            finalPath = testPath;
                            break;
                        }
                    }
                }
            }
            resolved = pathToFileURL(finalPath).href;
            break;
        }
    }
    if (resolved) {
        return {
            url: resolved,
            shortCircuit: true
        };
    }
    return nextResolve(specifier, context);
}
//# sourceMappingURL=node.loader.js.map