"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 extract_exports = {};
__export(extract_exports, {
  extractArchive: () => extractArchive
});
module.exports = __toCommonJS(extract_exports);
var import_error = require("../primordials/error");
var import_detect = require("./detect");
var import_internal = require("./_internal");
var import_tar = require("./tar");
var import_zip = require("./zip");
async function extractArchive(archivePath, outputDir, options = {}) {
  const format = (0, import_detect.detectArchiveFormat)(archivePath);
  if (!format) {
    const path = (0, import_internal.getPath)();
    const ext = path.extname(archivePath).toLowerCase();
    throw new import_error.ErrorCtor(
      `Unsupported archive format${ext ? ` (extension: ${ext})` : ""}: ${archivePath}. Supported formats: .zip, .tar, .tar.gz, .tgz`
    );
  }
  switch (format) {
    case "zip":
      return await (0, import_zip.extractZip)(archivePath, outputDir, options);
    case "tar":
      return await (0, import_tar.extractTar)(archivePath, outputDir, options);
    case "tar.gz":
    case "tgz":
      return await (0, import_tar.extractTarGz)(archivePath, outputDir, options);
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  extractArchive
});
