"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const modules_yaml_1 = require("@pnpm/modules-yaml");
const shrinkwrap_file_1 = require("@pnpm/shrinkwrap-file");
const utils_1 = require("@pnpm/utils");
const path = require("path");
exports.default = async (importers, shrinkwrapDirectory, opts) => {
    const virtualStoreDir = await utils_1.realNodeModulesDir(shrinkwrapDirectory);
    const modules = await modules_yaml_1.read(virtualStoreDir);
    return {
        importers: await Promise.all(importers.map(async (importer) => {
            let pkg = await utils_1.safeReadPackageFromDir(importer.prefix) || {};
            const modulesDir = await utils_1.realNodeModulesDir(importer.prefix);
            const importerId = shrinkwrap_file_1.getImporterId(shrinkwrapDirectory, importer.prefix);
            return {
                bin: importer.bin || path.join(importer.prefix, 'node_modules', '.bin'),
                currentShamefullyFlatten: modules && modules.importers[importerId] && modules.importers[importerId].shamefullyFlatten,
                hoistedAliases: modules && modules.importers[importerId] && modules.importers[importerId].hoistedAliases || {},
                id: importerId,
                modulesDir,
                pkg,
                prefix: importer.prefix,
                shamefullyFlatten: Boolean(typeof importer.shamefullyFlatten === 'boolean' ? importer.shamefullyFlatten : opts.shamefullyFlatten),
            };
        })),
        include: modules && modules.included || { dependencies: true, devDependencies: true, optionalDependencies: true },
        modules,
        pendingBuilds: modules && modules.pendingBuilds || [],
        registries: modules && modules.registries && utils_1.normalizeRegistries(modules.registries),
        skipped: new Set(modules && modules.skipped || []),
        virtualStoreDir,
    };
};
//# sourceMappingURL=index.js.map