"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 internal_exports = {};
__export(internal_exports, {
  CHAR_BACKWARD_SLASH: () => CHAR_BACKWARD_SLASH,
  CHAR_COLON: () => CHAR_COLON,
  CHAR_FORWARD_SLASH: () => CHAR_FORWARD_SLASH,
  CHAR_LOWERCASE_A: () => CHAR_LOWERCASE_A,
  CHAR_LOWERCASE_Z: () => CHAR_LOWERCASE_Z,
  CHAR_UPPERCASE_A: () => CHAR_UPPERCASE_A,
  CHAR_UPPERCASE_Z: () => CHAR_UPPERCASE_Z,
  getUrl: () => getUrl,
  msysDriveRegExp: () => msysDriveRegExp,
  nodeModulesPathRegExp: () => nodeModulesPathRegExp,
  pathLikeToString: () => pathLikeToString,
  slashRegExp: () => slashRegExp
});
module.exports = __toCommonJS(internal_exports);
var import_platform = require("../constants/platform");
var import_buffer = require("../primordials/buffer");
var import_string = require("../primordials/string");
const CHAR_BACKWARD_SLASH = 92;
const CHAR_COLON = 58;
const CHAR_FORWARD_SLASH = 47;
const CHAR_LOWERCASE_A = 97;
const CHAR_LOWERCASE_Z = 122;
const CHAR_UPPERCASE_A = 65;
const CHAR_UPPERCASE_Z = 90;
const msysDriveRegExp = /^\/([a-zA-Z])(\/|$)/;
const nodeModulesPathRegExp = /(?:^|[/\\])node_modules(?:[/\\]|$)/;
const slashRegExp = /[/\\]/;
let _url;
// @__NO_SIDE_EFFECTS__
function getUrl() {
  if (_url === void 0) {
    _url = require("node:url");
  }
  return _url;
}
// @__NO_SIDE_EFFECTS__
function pathLikeToString(pathLike) {
  if (pathLike === null || pathLike === void 0) {
    return "";
  }
  if (typeof pathLike === "string") {
    return pathLike;
  }
  if ((0, import_buffer.BufferIsBuffer)(pathLike)) {
    return pathLike.toString("utf8");
  }
  const url = /* @__PURE__ */ getUrl();
  if (pathLike instanceof URL) {
    try {
      return url.fileURLToPath(pathLike);
    } catch {
      const pathname = pathLike.pathname;
      const decodedPathname = decodeURIComponent(pathname);
      if (import_platform.WIN32 && (0, import_string.StringPrototypeStartsWith)(decodedPathname, "/")) {
        const letter = (0, import_string.StringPrototypeCharCodeAt)(decodedPathname, 1) | 32;
        const hasValidDriveLetter = decodedPathname.length >= 3 && letter >= 97 && letter <= 122 && (0, import_string.StringPrototypeCharAt)(decodedPathname, 2) === ":";
        if (!hasValidDriveLetter) {
          return decodedPathname;
        }
      }
      return decodedPathname;
    }
  }
  return String(pathLike);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  CHAR_BACKWARD_SLASH,
  CHAR_COLON,
  CHAR_FORWARD_SLASH,
  CHAR_LOWERCASE_A,
  CHAR_LOWERCASE_Z,
  CHAR_UPPERCASE_A,
  CHAR_UPPERCASE_Z,
  getUrl,
  msysDriveRegExp,
  nodeModulesPathRegExp,
  pathLikeToString,
  slashRegExp
});
