"use strict";
const node_path_1 = require("node:path");
const ENV_1 = require("./ENV");
const WIN32_1 = require("./WIN32");
// PNPM store path - the global package store location.
// By default:
// - macOS: ~/Library/pnpm/store
// - Linux: ~/.local/share/pnpm/store (or $XDG_DATA_HOME/pnpm/store if set)
// - Windows: %LOCALAPPDATA%/pnpm/store
//
// Can be overridden by:
// - PNPM_HOME environment variable
// - pnpm config store-dir setting
// - .npmrc store-dir setting
//
// Documentation: https://pnpm.io/npmrc#store-dir
function getPnpmStorePath() {
    // Check for explicit PNPM_HOME environment variable.
    const pnpmHome = process.env['PNPM_HOME'];
    if (pnpmHome) {
        return node_path_1.join(pnpmHome, 'store');
    }
    if (WIN32_1) {
        // On Windows, use LOCALAPPDATA.
        return ENV_1.LOCALAPPDATA ? node_path_1.join(ENV_1.LOCALAPPDATA, 'pnpm', 'store') : '';
    }
    // On Unix-like systems, follow XDG Base Directory specification.
    if (ENV_1.XDG_DATA_HOME) {
        return node_path_1.join(ENV_1.XDG_DATA_HOME, 'pnpm', 'store');
    }
    // macOS default location.
    if (process.platform === 'darwin' && ENV_1.HOME) {
        return node_path_1.join(ENV_1.HOME, 'Library', 'pnpm', 'store');
    }
    // Linux/Unix default location.
    return ENV_1.HOME ? node_path_1.join(ENV_1.HOME, '.local', 'share', 'pnpm', 'store') : '';
}
module.exports = getPnpmStorePath();
//# sourceMappingURL=pnpm-store-path.js.map