"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 sort_exports = {};
__export(sort_exports, {
  entryKeyComparator: () => entryKeyComparator,
  objectEntries: () => objectEntries,
  toSortedObject: () => toSortedObject,
  toSortedObjectFromEntries: () => toSortedObjectFromEntries
});
module.exports = __toCommonJS(sort_exports);
var import_object = require("../primordials/object");
var import_reflect = require("../primordials/reflect");
var import_natural = require("../sorts/natural");
// @__NO_SIDE_EFFECTS__
function entryKeyComparator(a, b) {
  const keyA = a[0];
  const keyB = b[0];
  const strKeyA = typeof keyA === "string" ? keyA : String(keyA);
  const strKeyB = typeof keyB === "string" ? keyB : String(keyB);
  return (0, import_natural.localeCompare)(strKeyA, strKeyB);
}
// @__NO_SIDE_EFFECTS__
function objectEntries(obj) {
  if (obj === null || obj === void 0) {
    return [];
  }
  const keys = (0, import_reflect.ReflectOwnKeys)(obj);
  const { length } = keys;
  const entries = Array(length);
  const record = obj;
  for (let i = 0; i < length; i += 1) {
    const key = keys[i];
    entries[i] = [key, record[key]];
  }
  return entries;
}
// @__NO_SIDE_EFFECTS__
function toSortedObject(obj) {
  return /* @__PURE__ */ toSortedObjectFromEntries(/* @__PURE__ */ objectEntries(obj));
}
// @__NO_SIDE_EFFECTS__
function toSortedObjectFromEntries(entries) {
  const otherEntries = [];
  const symbolEntries = [];
  for (const entry of entries) {
    if (typeof entry[0] === "symbol") {
      symbolEntries.push(entry);
    } else {
      otherEntries.push(entry);
    }
  }
  if (!otherEntries.length && !symbolEntries.length) {
    return {};
  }
  return (0, import_object.ObjectFromEntries)([
    // The String constructor is safe to use with symbols.
    ...symbolEntries.sort(entryKeyComparator),
    ...otherEntries.sort(entryKeyComparator)
  ]);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  entryKeyComparator,
  objectEntries,
  toSortedObject,
  toSortedObjectFromEntries
});
