"use strict";
/* Socket Lib - Built with esbuild */
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var exec_exports = {};
__export(exec_exports, {
  execPnpm: () => execPnpm
});
module.exports = __toCommonJS(exec_exports);
var import_exec = require("../../../bin/exec");
var import_namespace = require("../../../debug/namespace");
var import_ci = require("../../../env/ci");
var import_array = require("../../../primordials/array");
var import_flags = require("../npm/flags");
var import_flags2 = require("./flags");
function execPnpm(args, options) {
  const { allowLockfileUpdate, ...extBinOpts } = {
    __proto__: null,
    ...options
  };
  const useDebug = (0, import_namespace.isDebug)();
  const terminatorPos = (0, import_array.ArrayPrototypeIndexOf)(args, "--");
  const pnpmArgs = (terminatorPos === -1 ? args : (0, import_array.ArrayPrototypeSlice)(args, 0, terminatorPos)).filter((a) => !(0, import_flags.isNpmProgressFlag)(a));
  const otherArgs = terminatorPos === -1 ? [] : (0, import_array.ArrayPrototypeSlice)(args, terminatorPos);
  const firstArg = pnpmArgs[0];
  const supportsIgnoreScripts = firstArg ? import_flags2.PNPM_INSTALL_LIKE_COMMANDS.has(firstArg) : false;
  const logLevelArgs = useDebug || pnpmArgs.some(import_flags2.isPnpmLoglevelFlag) ? [] : ["--loglevel", "warn"];
  const hasIgnoreScriptsFlag = pnpmArgs.some(import_flags2.isPnpmIgnoreScriptsFlag);
  const ignoreScriptsArgs = !supportsIgnoreScripts || hasIgnoreScriptsFlag ? [] : ["--ignore-scripts"];
  const frozenLockfileArgs = [];
  if ((0, import_ci.getCI)() && allowLockfileUpdate && firstArg && (0, import_flags2.isPnpmInstallCommand)(firstArg) && !pnpmArgs.some(import_flags2.isPnpmFrozenLockfileFlag)) {
    frozenLockfileArgs.push("--no-frozen-lockfile");
  }
  return (0, import_exec.execBin)(
    "pnpm",
    [
      ...logLevelArgs,
      ...ignoreScriptsArgs,
      ...frozenLockfileArgs,
      ...pnpmArgs,
      ...otherArgs
    ],
    extBinOpts
  );
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  execPnpm
});
