function b(t) {
  try {
    JSON.parse(t);
  } catch {
    return !1;
  }
  return !0;
}
function h() {
  return typeof window < "u";
}
function y() {
  return h() && location.hostname.includes("localhost");
}
function g(t) {
  return Object.prototype.toString.call(t) === "[object Object]";
}
function O(t) {
  if (typeof t == "object" && t !== null) {
    if (typeof Object.getPrototypeOf == "function") {
      const e = Object.getPrototypeOf(t);
      return e === Object.prototype || e === null;
    }
    return g(t);
  }
  return !1;
}
function j({
  path: t,
  hash: e,
  baseUrl: s = location.href,
  searchParams: c,
  localeOverride: i,
  clearParams: a,
  clearHash: u
}) {
  const n = new URL(s);
  a && (n.search = ""), u && (n.hash = "");
  let o = n.pathname.split("/").filter(Boolean)[0];
  i && (o = i.country ? `${i.language}_${i.country}` : i.language);
  const f = o && (o.length === 2 || o.includes("_") && o.split("_").length === 2), r = t.startsWith("/") ? t : `/${t}`;
  return n.pathname = f ? `/${o}${r}` : r, n.hash = "", e && (n.hash = e.startsWith("#") ? e : `#${e}`), c && Object.entries(c).forEach(([l, p]) => {
    n.searchParams.set(l, String(p));
  }), n;
}
export {
  h as a,
  y as b,
  g as c,
  O as d,
  j as e,
  b as i
};
//# sourceMappingURL=build-oneweb-url.mjs.map
