"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 inspect_exports = {};
__export(inspect_exports, {
  isDir: () => isDir,
  isDirEmptySync: () => isDirEmptySync,
  isDirSync: () => isDirSync,
  isSymlinkSync: () => isSymlinkSync,
  safeStat: () => safeStat,
  safeStatSync: () => safeStatSync
});
module.exports = __toCommonJS(inspect_exports);
var import_defaults = require("../globs/defaults");
var import_matcher = require("../globs/matcher");
var import_fs = require("../node/fs");
var import_normalize = require("../paths/normalize");
// @__NO_SIDE_EFFECTS__
async function isDir(filepath) {
  return !!(await /* @__PURE__ */ safeStat(filepath))?.isDirectory();
}
// @__NO_SIDE_EFFECTS__
function isDirEmptySync(dirname, options) {
  const { ignore = import_defaults.defaultIgnore } = {
    __proto__: null,
    ...options
  };
  const fs = (0, import_fs.getNodeFs)();
  try {
    const files = fs.readdirSync(dirname);
    const { length } = files;
    if (length === 0) {
      return true;
    }
    const matcher = (0, import_matcher.getGlobMatcher)(
      ignore,
      {
        cwd: (0, import_normalize.pathLikeToString)(dirname)
      }
    );
    let ignoredCount = 0;
    for (let i = 0; i < length; i += 1) {
      const file = files[i];
      if (file && matcher(file)) {
        ignoredCount += 1;
      }
    }
    return ignoredCount === length;
  } catch {
    return false;
  }
}
// @__NO_SIDE_EFFECTS__
function isDirSync(filepath) {
  return !!(/* @__PURE__ */ safeStatSync(filepath))?.isDirectory();
}
// @__NO_SIDE_EFFECTS__
function isSymlinkSync(filepath) {
  const fs = (0, import_fs.getNodeFs)();
  try {
    return fs.lstatSync(filepath).isSymbolicLink();
  } catch {
  }
  return false;
}
// @__NO_SIDE_EFFECTS__
async function safeStat(filepath) {
  const fs = (0, import_fs.getNodeFs)();
  try {
    return await fs.promises.stat(filepath);
  } catch {
  }
  return void 0;
}
// @__NO_SIDE_EFFECTS__
function safeStatSync(filepath) {
  const fs = (0, import_fs.getNodeFs)();
  try {
    return fs.statSync(filepath, {
      __proto__: null,
      throwIfNoEntry: false
    });
  } catch {
  }
  return void 0;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  isDir,
  isDirEmptySync,
  isDirSync,
  isSymlinkSync,
  safeStat,
  safeStatSync
});
