/**
 * @remix-run/router v1.14.0
 *
 * Copyright (c) Remix Software Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 *
 * @license MIT
 */
function u() {
  return u = Object.assign ? Object.assign.bind() : function(e) {
    for (var t = 1; t < arguments.length; t++) {
      var n = arguments[t];
      for (var r in n)
        Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
    }
    return e;
  }, u.apply(this, arguments);
}
var d;
(function(e) {
  e.Pop = "POP", e.Push = "PUSH", e.Replace = "REPLACE";
})(d || (d = {}));
function p(e, t) {
  if (e === !1 || e === null || typeof e > "u")
    throw new Error(t);
}
function O(e, t) {
  if (!e) {
    typeof console < "u" && console.warn(t);
    try {
      throw new Error(t);
    } catch {
    }
  }
}
function m(e) {
  let t = {};
  if (e) {
    let n = e.indexOf("#");
    n >= 0 && (t.hash = e.substr(n), e = e.substr(0, n));
    let r = e.indexOf("?");
    r >= 0 && (t.search = e.substr(r), e = e.substr(0, r)), e && (t.pathname = e);
  }
  return t;
}
var g;
(function(e) {
  e.data = "data", e.deferred = "deferred", e.redirect = "redirect", e.error = "error";
})(g || (g = {}));
function y(e, t) {
  t === void 0 && (t = "/");
  let {
    pathname: n,
    search: r = "",
    hash: a = ""
  } = typeof e == "string" ? m(e) : e;
  return {
    pathname: n ? n.startsWith("/") ? n : E(n, t) : t,
    search: j(r),
    hash: P(a)
  };
}
function E(e, t) {
  let n = t.replace(/\/+$/, "").split("/");
  return e.split("/").forEach((a) => {
    a === ".." ? n.length > 1 && n.pop() : a !== "." && n.push(a);
  }), n.length > 1 ? n.join("/") : "/";
}
function c(e, t, n, r) {
  return "Cannot include a '" + e + "' character in a manually specified " + ("`to." + t + "` field [" + JSON.stringify(r) + "].  Please separate it out to the ") + ("`to." + n + "` field. Alternatively you may provide the full path as ") + 'a string in <Link to="..."> and the router will parse it for you.';
}
function b(e) {
  return e.filter((t, n) => n === 0 || t.route.path && t.route.path.length > 0);
}
function W(e, t) {
  let n = b(e);
  return t ? n.map((r, a) => a === e.length - 1 ? r.pathname : r.pathnameBase) : n.map((r) => r.pathnameBase);
}
function M(e, t, n, r) {
  r === void 0 && (r = !1);
  let a;
  typeof e == "string" ? a = m(e) : (a = u({}, e), p(!a.pathname || !a.pathname.includes("?"), c("?", "pathname", "search", a)), p(!a.pathname || !a.pathname.includes("#"), c("#", "pathname", "hash", a)), p(!a.search || !a.search.includes("#"), c("#", "search", "hash", a)));
  let h = e === "" || a.pathname === "", i = h ? "/" : a.pathname, o;
  if (i == null)
    o = n;
  else if (r) {
    let l = t.length === 0 ? [] : t[t.length - 1].replace(/^\//, "").split("/");
    if (i.startsWith("..")) {
      let s = i.split("/");
      for (; s[0] === ".."; )
        s.shift(), l.pop();
      a.pathname = s.join("/");
    }
    o = "/" + l.join("/");
  } else {
    let l = t.length - 1;
    if (i.startsWith("..")) {
      let s = i.split("/");
      for (; s[0] === ".."; )
        s.shift(), l -= 1;
      a.pathname = s.join("/");
    }
    o = l >= 0 ? t[l] : "/";
  }
  let f = y(a, o), S = i && i !== "/" && i.endsWith("/"), w = (h || i === ".") && n.endsWith("/");
  return !f.pathname.endsWith("/") && (S || w) && (f.pathname += "/"), f;
}
const C = (e) => e.join("/").replace(/\/\/+/g, "/"), j = (e) => !e || e === "?" ? "" : e.startsWith("?") ? e : "?" + e, P = (e) => !e || e === "#" ? "" : e.startsWith("#") ? e : "#" + e, v = ["post", "put", "patch", "delete"];
new Set(v);
const x = ["get", ...v];
new Set(x);
export {
  d as Action,
  W as UNSAFE_getResolveToMatches,
  p as UNSAFE_invariant,
  O as UNSAFE_warning,
  C as joinPaths,
  m as parsePath,
  y as resolvePath,
  M as resolveTo
};
