const i = (n, s) => {
  let e = window.location.search || "";
  if (n && n !== location.href) {
    const t = n.indexOf("?");
    t !== -1 ? e = n.slice(t) : e = "";
  }
  const r = new URLSearchParams(e);
  if (s)
    return r.get(s);
  {
    let t = {};
    for (let [o, l] of r.entries())
      t[o] = l;
    return t;
  }
}, f = (n, s = {}) => {
  let e = "", r = "";
  const t = Object.keys(s);
  return t && t.length && t.forEach((o, l) => {
    l === t.length - 1 ? r += `${o}=${s[o]}` : r += `${o}=${s[o]}&`;
  }), r ? e = location.origin + n + `?${r}` : e = location.origin + n, e;
}, h = (n, s) => {
  const e = s || location.href, r = i(e), t = Object.keys(r) || [];
  if (!t || !t.length) return e.includes("?") ? e.split("?")[0] : e.split("&")[0];
  let o = t.filter((a) => !n.includes(a));
  if (!o || !o.length) return e.includes("?") ? e.split("?")[0] : e.split("&")[0];
  let l = "";
  return o.forEach((a, c) => {
    c === t.length - 1 ? l += `${a}=${r[a]}` : l += `${a}=${r[a]}&`;
  }), e.includes("?") ? e.split("?")[0] + `?${l}` : e.split("&")[0] + `?${l}`;
}, u = (n) => {
  const s = new URLSearchParams(n.split("?")[1]), e = {};
  for (const [r, t] of s)
    e.hasOwnProperty(r) ? Array.isArray(e[r]) ? e[r].push(t) : e[r] = [e[r], t] : e[r] = t;
  return e;
}, g = (n) => {
  let s = "";
  const e = Object.keys(n);
  return e && e.length && e.forEach((r, t) => {
    t === e.length - 1 ? s += `${r}=${n[r]}` : s += `${r}=${n[r]}&`;
  }), s;
}, p = (n, s) => {
  const e = new URL(n, location.origin);
  let { origin: r, pathname: t } = e;
  t === "/" && (t = ""), s.map((l) => t += `/${l}`);
  const o = new URL(`${r}${t}`);
  return e.searchParams.forEach((l, a) => {
    o.searchParams.append(a, l);
  }), o.toString();
};
function $(n) {
  const s = /^(https?:\/\/[^/]+)/, e = n.match(s);
  return e && e.length > 1 ? e[1] : null;
}
export {
  p as addPathParamsToUrl,
  h as funcUrlDel,
  f as getFullPath,
  $ as getOriginFromUrl,
  i as getUrlParams,
  g as objectToUrlparams,
  u as urlParamsToObject
};
