import u from "../../_virtual/isEqual.js";
const r = ":", d = () => (i, e) => {
  const n = typeof window < "u" ? window.location.hash.substring(1) : "";
  if (!n)
    return !1;
  const t = n.split(r);
  return t.length > e.length ? u(e, t.slice(0, e.length)) && t[e.length] === i : !1;
}, c = () => {
  const i = (n) => {
    const t = new URL(window.location.href);
    return t.hash = n, t.toString();
  }, e = (n) => {
    if (typeof window > "u" || typeof document > "u" || !document.hasFocus())
      return;
    const t = n.join(r), o = i(t);
    window.history.replaceState(
      { ...window.history.state, as: o, url: o },
      "",
      o
    );
  };
  return (n, t, o) => {
    if (n)
      t && e([...o, t]);
    else if (o.length > 0)
      e(o);
    else {
      if (typeof window > "u" || typeof document > "u" || !document.hasFocus())
        return;
      const s = i("");
      window.history.replaceState(
        { ...window.history.state, as: s, url: s },
        "",
        s
      );
    }
  };
};
export {
  r as CONNECTING_CHARACTER,
  d as getInitialOpenState,
  c as updateAndCopyUrl
};
