"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 read_dir_exports = {};
__export(read_dir_exports, {
  innerReadDirNames: () => innerReadDirNames,
  readDirNames: () => readDirNames,
  readDirNamesSync: () => readDirNamesSync
});
module.exports = __toCommonJS(read_dir_exports);
var import_fs = require("../node/fs");
var import_path = require("../node/path");
var import_natural = require("../sorts/natural");
var import_inspect = require("./inspect");
// @__NO_SIDE_EFFECTS__
function innerReadDirNames(dirents, dirname, options) {
  const {
    ignore,
    includeEmpty = true,
    sort = true
  } = { __proto__: null, ...options };
  const path = (0, import_path.getNodePath)();
  const names = dirents.filter(
    (d) => d.isDirectory() && (includeEmpty || !(0, import_inspect.isDirEmptySync)(path.join(dirname || d.parentPath, d.name), {
      ignore
    }))
  ).map((d) => d.name);
  return sort ? names.sort(import_natural.naturalCompare) : names;
}
// @__NO_SIDE_EFFECTS__
async function readDirNames(dirname, options) {
  const fs = (0, import_fs.getNodeFs)();
  try {
    return /* @__PURE__ */ innerReadDirNames(
      await fs.promises.readdir(dirname, {
        __proto__: null,
        encoding: "utf8",
        withFileTypes: true
      }),
      String(dirname),
      options
    );
  } catch {
  }
  return [];
}
// @__NO_SIDE_EFFECTS__
function readDirNamesSync(dirname, options) {
  const fs = (0, import_fs.getNodeFs)();
  try {
    return /* @__PURE__ */ innerReadDirNames(
      fs.readdirSync(dirname, {
        __proto__: null,
        encoding: "utf8",
        withFileTypes: true
      }),
      String(dirname),
      options
    );
  } catch {
  }
  return [];
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  innerReadDirNames,
  readDirNames,
  readDirNamesSync
});
