const a = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i, d = (t) => {
  if (typeof t != "string")
    throw new TypeError("Invalid argument expected string");
  const r = t.match(a);
  if (!r)
    throw new Error(`Invalid argument not valid semver ('${t}' received)`);
  return r.shift(), r;
}, o = (t) => t === "*" || t === "x" || t === "X", i = (t) => {
  const r = parseInt(t, 10);
  return isNaN(r) ? t : r;
}, c = (t, r) => typeof t != typeof r ? [String(t), String(r)] : [t, r], s = (t, r) => {
  if (o(t) || o(r))
    return 0;
  const [e, n] = c(i(t), i(r));
  return e > n ? 1 : e < n ? -1 : 0;
}, f = (t, r) => {
  for (let e = 0; e < Math.max(t.length, r.length); e++) {
    const n = s(t[e] || "0", r[e] || "0");
    if (n !== 0)
      return n;
  }
  return 0;
};
export {
  f as compareSegments,
  a as semver,
  d as validateAndParse
};
