"use strict";
/* Socket Lib - Built with esbuild */
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var user_agent_exports = {};
__export(user_agent_exports, {
  buildUserAgent: () => buildUserAgent,
  getSocketCallerUserAgent: () => getSocketCallerUserAgent
});
module.exports = __toCommonJS(user_agent_exports);
var import_node_process = __toESM(require("node:process"));
var import_socket = require("../constants/socket");
var import_rewire = require("../env/rewire");
var import_operations = require("../packages/operations");
// @__NO_SIDE_EFFECTS__
function buildUserAgent(pkg, caller) {
  const base = `${(0, import_operations.pkgNameToSlug)(pkg.name)}/${pkg.version} node/${import_node_process.default.version} ${import_node_process.default.platform}/${import_node_process.default.arch}`;
  return caller ? `${base} ${caller}` : base;
}
let cachedBaseUserAgent;
function getSocketCallerUserAgent() {
  if (cachedBaseUserAgent === void 0) {
    cachedBaseUserAgent = /* @__PURE__ */ buildUserAgent({
      name: import_socket.SOCKET_LIB_NAME,
      version: import_socket.SOCKET_LIB_VERSION
    });
  }
  const caller = (0, import_rewire.getEnvValue)("SOCKET_CALLER_USER_AGENT");
  return caller && caller.trim() ? `${cachedBaseUserAgent} ${caller}` : cachedBaseUserAgent;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  buildUserAgent,
  getSocketCallerUserAgent
});
