"use strict";
/* Socket Lib - Built with esbuild */
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 specs_exports = {};
__export(specs_exports, {
  getRepoUrlDetails: () => getRepoUrlDetails,
  gitHubTagRefUrl: () => gitHubTagRefUrl,
  gitHubTgzUrl: () => gitHubTgzUrl,
  isGitHubTgzSpec: () => isGitHubTgzSpec,
  isGitHubUrlSpec: () => isGitHubUrlSpec
});
module.exports = __toCommonJS(specs_exports);
var import_npm_package_arg = __toESM(require("../external/npm-package-arg"));
var import_objects = require("../objects");
var import_strings = require("../strings");
// @__NO_SIDE_EFFECTS__
function getRepoUrlDetails(repoUrl = "") {
  const userAndRepo = repoUrl.replace(/^.+github.com\//, "").split("/");
  const user = userAndRepo[0] || "";
  const project = userAndRepo.length > 1 ? userAndRepo[1]?.slice(0, -".git".length) || "" : "";
  return { user, project };
}
// @__NO_SIDE_EFFECTS__
function gitHubTagRefUrl(user, project, tag) {
  return `https://api.github.com/repos/${user}/${project}/git/ref/tags/${tag}`;
}
// @__NO_SIDE_EFFECTS__
function gitHubTgzUrl(user, project, sha) {
  return `https://github.com/${user}/${project}/archive/${sha}.tar.gz`;
}
// @__NO_SIDE_EFFECTS__
function isGitHubTgzSpec(spec, where) {
  let parsedSpec;
  if ((0, import_objects.isObjectObject)(spec)) {
    parsedSpec = spec;
  } else {
    parsedSpec = (0, import_npm_package_arg.default)(spec, where);
  }
  const typedSpec = parsedSpec;
  return typedSpec.type === "remote" && !!typedSpec.saveSpec?.endsWith(".tar.gz");
}
// @__NO_SIDE_EFFECTS__
function isGitHubUrlSpec(spec, where) {
  let parsedSpec;
  if ((0, import_objects.isObjectObject)(spec)) {
    parsedSpec = spec;
  } else {
    parsedSpec = (0, import_npm_package_arg.default)(spec, where);
  }
  const typedSpec = parsedSpec;
  return typedSpec.type === "git" && typedSpec.hosted?.domain === "github.com" && (0, import_strings.isNonEmptyString)(typedSpec.gitCommittish);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  getRepoUrlDetails,
  gitHubTagRefUrl,
  gitHubTgzUrl,
  isGitHubTgzSpec,
  isGitHubUrlSpec
});
