import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  resolveNpmDependencies,
  resolvePackageManager
} from "./chunk-NWTPCDEK.js";
import {
  createLogger
} from "./chunk-YKAYM32Q.js";
import "./chunk-KB3GWH37.js";
import "./chunk-HTRGINHM.js";
import {
  createI18nT
} from "./chunk-PPRKUU25.js";
import "./chunk-HEANTKSX.js";
import "./chunk-MYWHJYA3.js";
import "./chunk-4BLGYECY.js";
import {
  authenticate
} from "./chunk-II4C4GML.js";
import "./chunk-O6HC4AYN.js";
import "./chunk-3QMRQKKR.js";
import "./chunk-RF4NA2OH.js";
import "./chunk-NMCF7XG5.js";
import "./chunk-MHV22UIU.js";
import "./chunk-VC5Q2AI5.js";
import "./chunk-HWT3LUJJ.js";
import "./chunk-TOBTRYZF.js";
import "./chunk-7WVNO7VU.js";
import "./chunk-RPTAJN5Y.js";
import "./chunk-YL4347CI.js";
import "./chunk-TODKQSCF.js";
import "./chunk-AFPDHQYI.js";
import "./chunk-HYKBBZLS.js";
import "./chunk-C5RTKQVL.js";
import "./chunk-SVUXJRFD.js";
import "./chunk-YT5BPQDJ.js";
import "./chunk-LU3R3EBR.js";
import "./chunk-XZUGLEBK.js";
import "./chunk-VASURI4S.js";
import "./chunk-SDLCFZRL.js";
import {
  CliError,
  CliErrorCode
} from "./chunk-MTT3QXBC.js";
import {
  init_esm_shims
} from "./chunk-EXLZF52D.js";

// ../cli-site-old/src/uninstall/index.ts
init_esm_shims();

// ../cli-site-old/src/uninstall/uninstall.ts
init_esm_shims();
async function uninstall(model, services, options, initialPackageName) {
  const t = createI18nT();
  const logger = createLogger({ t });
  const authState = await authenticate({
    metaSiteId: model.metaSiteId,
    biLogger: services.biLogger,
    errorReporter: services.errorReporter
  });
  const packageName = initialPackageName.trim();
  if (!packageName) {
    throw new CliError({
      code: CliErrorCode.WixUninstallMissingPackageName(),
      cause: null
    });
  }
  const logDependencyUninstalled = logger.logDependencyUninstalling(packageName);
  try {
    const packageManager = await resolvePackageManager(
      model.projectFolder,
      options
    );
    await packageManager.runUninstallPackage(model.projectFolder, packageName);
    await resolveNpmDependencies(model.projectFolder, { authState });
    logDependencyUninstalled.success();
  } catch (error) {
    logDependencyUninstalled.fail();
    throw error;
  }
}
export {
  uninstall
};
//# sourceMappingURL=uninstall-G2LMM2OJ.js.map