var s, H;
function k() {
  if (H) return s;
  H = 1;
  const N = /^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu, q = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
  function h(e) {
    return typeof e.secure == "boolean" ? e.secure : String(e.scheme).toLowerCase() === "wss";
  }
  function f(e) {
    return e.host || (e.error = e.error || "HTTP URIs must have a host."), e;
  }
  function l(e) {
    const r = String(e.scheme).toLowerCase() === "https";
    return (e.port === (r ? 443 : 80) || e.port === "") && (e.port = void 0), e.path || (e.path = "/"), e;
  }
  function U(e) {
    return e.secure = h(e), e.resourceName = (e.path || "/") + (e.query ? "?" + e.query : ""), e.path = void 0, e.query = void 0, e;
  }
  function $(e) {
    if ((e.port === (h(e) ? 443 : 80) || e.port === "") && (e.port = void 0), typeof e.secure == "boolean" && (e.scheme = e.secure ? "wss" : "ws", e.secure = void 0), e.resourceName) {
      const [r, i] = e.resourceName.split("?");
      e.path = r && r !== "/" ? r : void 0, e.query = i, e.resourceName = void 0;
    }
    return e.fragment = void 0, e;
  }
  function y(e, r) {
    if (!e.path)
      return e.error = "URN can not be parsed", e;
    const i = e.path.match(q);
    if (i) {
      const c = r.scheme || e.scheme || "urn";
      e.nid = i[1].toLowerCase(), e.nss = i[2];
      const t = `${c}:${r.nid || e.nid}`, a = d[t];
      e.path = void 0, a && (e = a.parse(e, r));
    } else
      e.error = e.error || "URN can not be parsed.";
    return e;
  }
  function R(e, r) {
    const i = r.scheme || e.scheme || "urn", c = e.nid.toLowerCase(), t = `${i}:${r.nid || c}`, a = d[t];
    a && (e = a.serialize(e, r));
    const S = e, v = e.nss;
    return S.path = `${c || r.nid}:${v}`, r.skipEscape = !0, S;
  }
  function E(e, r) {
    const i = e;
    return i.uuid = i.nss, i.nss = void 0, !r.tolerant && (!i.uuid || !N.test(i.uuid)) && (i.error = i.error || "UUID is not valid."), i;
  }
  function L(e) {
    const r = e;
    return r.nss = (e.uuid || "").toLowerCase(), r;
  }
  const z = {
    scheme: "http",
    domainHost: !0,
    parse: f,
    serialize: l
  }, P = {
    scheme: "https",
    domainHost: z.domainHost,
    parse: f,
    serialize: l
  }, u = {
    scheme: "ws",
    domainHost: !0,
    parse: U,
    serialize: $
  }, b = {
    scheme: "wss",
    domainHost: u.domainHost,
    parse: u.parse,
    serialize: u.serialize
  }, d = {
    http: z,
    https: P,
    ws: u,
    wss: b,
    urn: {
      scheme: "urn",
      parse: y,
      serialize: R,
      skipNormalize: !0
    },
    "urn:uuid": {
      scheme: "urn:uuid",
      parse: E,
      serialize: L,
      skipNormalize: !0
    }
  };
  return s = d, s;
}
export {
  k as __require
};
//# sourceMappingURL=schemes.js.map
