import { b as D } from "./Env-92498313.mjs";
import { UrlHelper as b, DesktopChecker as N } from "@accelbyte/sdk";
import { a as q, m as k, g as j } from "./merge-78dc87d6.mjs";
var S = {}, W = {
  get exports() {
    return S;
  },
  set exports(e) {
    S = e;
  }
}, A = {}, z = {
  get exports() {
    return A;
  },
  set exports(e) {
    A = e;
  }
};
(function(e, n) {
  Object.defineProperty(n, "__esModule", {
    value: !0
  }), n.default = v;
  var u = g(q), m = g(k);
  function g(r) {
    return r && r.__esModule ? r : { default: r };
  }
  var o = {
    require_tld: !0,
    allow_underscores: !1,
    allow_trailing_dot: !1,
    allow_numeric_tld: !1,
    allow_wildcard: !1
  };
  function v(r, d) {
    (0, u.default)(r), d = (0, m.default)(d, o), d.allow_trailing_dot && r[r.length - 1] === "." && (r = r.substring(0, r.length - 1)), d.allow_wildcard === !0 && r.indexOf("*.") === 0 && (r = r.substring(2));
    var h = r.split("."), s = h[h.length - 1];
    return d.require_tld && (h.length < 2 || !/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(s) || /\s/.test(s)) || !d.allow_numeric_tld && /^\d+$/.test(s) ? !1 : h.every(function(c) {
      return !(c.length > 63 || !/^[a-z_\u00a1-\uffff0-9-]+$/i.test(c) || /[\uff01-\uff5e]/.test(c) || /^-|-$/.test(c) || !d.allow_underscores && /_/.test(c));
    });
  }
  e.exports = n.default, e.exports.default = n.default;
})(z, A);
var L = {}, Q = {
  get exports() {
    return L;
  },
  set exports(e) {
    L = e;
  }
};
(function(e, n) {
  Object.defineProperty(n, "__esModule", {
    value: !0
  }), n.default = h;
  var u = m(q);
  function m(s) {
    return s && s.__esModule ? s : { default: s };
  }
  var g = "(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])", o = "(".concat(g, "[.]){3}").concat(g), v = new RegExp("^".concat(o, "$")), r = "(?:[0-9a-fA-F]{1,4})", d = new RegExp("^(" + "(?:".concat(r, ":){7}(?:").concat(r, "|:)|") + "(?:".concat(r, ":){6}(?:").concat(o, "|:").concat(r, "|:)|") + "(?:".concat(r, ":){5}(?::").concat(o, "|(:").concat(r, "){1,2}|:)|") + "(?:".concat(r, ":){4}(?:(:").concat(r, "){0,1}:").concat(o, "|(:").concat(r, "){1,3}|:)|") + "(?:".concat(r, ":){3}(?:(:").concat(r, "){0,2}:").concat(o, "|(:").concat(r, "){1,4}|:)|") + "(?:".concat(r, ":){2}(?:(:").concat(r, "){0,3}:").concat(o, "|(:").concat(r, "){1,5}|:)|") + "(?:".concat(r, ":){1}(?:(:").concat(r, "){0,4}:").concat(o, "|(:").concat(r, "){1,6}|:)|") + "(?::((?::".concat(r, "){0,5}:").concat(o, "|(?::").concat(r, "){1,7}|:))") + ")(%[0-9a-zA-Z-.:]{1,})?$");
  function h(s) {
    var c = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
    if ((0, u.default)(s), c = String(c), !c)
      return h(s, 4) || h(s, 6);
    if (c === "4") {
      if (!v.test(s))
        return !1;
      var x = s.split(".").sort(function(F, P) {
        return F - P;
      });
      return x[3] <= 255;
    }
    return c === "6" ? !!d.test(s) : !1;
  }
  e.exports = n.default, e.exports.default = n.default;
})(Q, L);
(function(e, n) {
  Object.defineProperty(n, "__esModule", {
    value: !0
  }), n.default = V;
  var u = v(q), m = v(A), g = v(L), o = v(k);
  function v(t) {
    return t && t.__esModule ? t : { default: t };
  }
  function r(t, a) {
    return x(t) || c(t, a) || h(t, a) || d();
  }
  function d() {
    throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
  }
  function h(t, a) {
    if (t) {
      if (typeof t == "string")
        return s(t, a);
      var i = Object.prototype.toString.call(t).slice(8, -1);
      if (i === "Object" && t.constructor && (i = t.constructor.name), i === "Map" || i === "Set")
        return Array.from(t);
      if (i === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))
        return s(t, a);
    }
  }
  function s(t, a) {
    (a == null || a > t.length) && (a = t.length);
    for (var i = 0, f = new Array(a); i < a; i++)
      f[i] = t[i];
    return f;
  }
  function c(t, a) {
    if (!(typeof Symbol > "u" || !(Symbol.iterator in Object(t)))) {
      var i = [], f = !0, _ = !1, y = void 0;
      try {
        for (var w = t[Symbol.iterator](), p; !(f = (p = w.next()).done) && (i.push(p.value), !(a && i.length === a)); f = !0)
          ;
      } catch (l) {
        _ = !0, y = l;
      } finally {
        try {
          !f && w.return != null && w.return();
        } finally {
          if (_)
            throw y;
        }
      }
      return i;
    }
  }
  function x(t) {
    if (Array.isArray(t))
      return t;
  }
  var F = {
    protocols: ["http", "https", "ftp"],
    require_tld: !0,
    require_protocol: !1,
    require_host: !0,
    require_port: !1,
    require_valid_protocol: !0,
    allow_underscores: !1,
    allow_trailing_dot: !1,
    allow_protocol_relative_urls: !1,
    allow_fragments: !0,
    allow_query_components: !0,
    validate_length: !0
  }, P = /^\[([^\]]+)\](?::([0-9]+))?$/;
  function M(t) {
    return Object.prototype.toString.call(t) === "[object RegExp]";
  }
  function I(t, a) {
    for (var i = 0; i < a.length; i++) {
      var f = a[i];
      if (t === f || M(f) && f.test(t))
        return !0;
    }
    return !1;
  }
  function V(t, a) {
    if ((0, u.default)(t), !t || /[\s<>]/.test(t) || t.indexOf("mailto:") === 0 || (a = (0, o.default)(a, F), a.validate_length && t.length >= 2083) || !a.allow_fragments && t.includes("#") || !a.allow_query_components && (t.includes("?") || t.includes("&")))
      return !1;
    var i, f, _, y, w, p, l, R;
    if (l = t.split("#"), t = l.shift(), l = t.split("?"), t = l.shift(), l = t.split("://"), l.length > 1) {
      if (i = l.shift().toLowerCase(), a.require_valid_protocol && a.protocols.indexOf(i) === -1)
        return !1;
    } else {
      if (a.require_protocol)
        return !1;
      if (t.substr(0, 2) === "//") {
        if (!a.allow_protocol_relative_urls)
          return !1;
        l[0] = t.substr(2);
      }
    }
    if (t = l.join("://"), t === "")
      return !1;
    if (l = t.split("/"), t = l.shift(), t === "" && !a.require_host)
      return !0;
    if (l = t.split("@"), l.length > 1) {
      if (a.disallow_auth || l[0] === "" || (f = l.shift(), f.indexOf(":") >= 0 && f.split(":").length > 2))
        return !1;
      var B = f.split(":"), O = r(B, 2), C = O[0], T = O[1];
      if (C === "" && T === "")
        return !1;
    }
    y = l.join("@"), p = null, R = null;
    var E = y.match(P);
    if (E ? (_ = "", R = E[1], p = E[2] || null) : (l = y.split(":"), _ = l.shift(), l.length && (p = l.join(":"))), p !== null && p.length > 0) {
      if (w = parseInt(p, 10), !/^[0-9]+$/.test(p) || w <= 0 || w > 65535)
        return !1;
    } else if (a.require_port)
      return !1;
    return a.host_whitelist ? I(_, a.host_whitelist) : !(!(0, g.default)(_) && !(0, m.default)(_, a) && (!R || !(0, g.default)(R, 6)) || (_ = _ || R, a.host_blacklist && I(_, a.host_blacklist)));
  }
  e.exports = n.default, e.exports.default = n.default;
})(W, S);
const H = /* @__PURE__ */ j(S), $ = class {
  static silentUrlBuilder(e) {
    try {
      return new URL(e);
    } catch {
      return null;
    }
  }
  static silentSearchParamsBuilder(e) {
    try {
      return new URLSearchParams(e);
    } catch {
      return new URLSearchParams("");
    }
  }
  static makeAbsolutePath(e) {
    return `/${b.trimSlashFromStringStart(e)}`;
  }
  static transformToValidURLOrUndefined(e) {
    try {
      if (e)
        return new URL(e);
    } catch {
    }
  }
  static isValidUrl(e) {
    return typeof e != "string" ? !1 : H(e, {
      protocols: ["http", "https"],
      // TODO(try.ajitiono): we can enable this and remove the `isValidUrl2` above.
      // require_protocol: true,
      require_tld: !1
    }) && e;
  }
  static isImageURL(e) {
    return !!this.isValidUrl(e) && e.match(/\.(jpeg|jpg|gif|png)$/) != null;
  }
  //
  static getCurrentPathWithNoBaseName() {
    return window.location.pathname.slice(D.PLAYER_PORTAL_BASE_URL.length);
  }
  static getRedirectUrl(e, n) {
    return N.isDesktopApp() ? `${e}${b.trimSlashFromStringStart(n)}` : `${b.combineURLPaths(e, n)}`;
  }
  static getRouterRedirection(e, n) {
    const u = new URL(e), m = new URL(n), g = u.origin === window.location.origin, o = u.origin === m.origin;
    return g || D.IS_DEV_MODE && o ? `${u.pathname}${u.search}` : null;
  }
};
let U = $;
U.stripColonFromProtocol = (e) => e[e.length - 1] === ":" ? e.slice(0, e.length - 1) : e;
U.checkUrlValidity = (e, n = !0) => $.isValidUrl2(e, n) ? null : `${e} is not a valid URL.`;
U.isValidUrl2 = (e, n = !0) => {
  try {
    return Boolean(new URL(e));
  } catch (u) {
    return n && console.error(u), !1;
  }
};
U.fixUrl = (e) => $.isValidUrl2(e, !1) ? e : `https://${e}`;
U.buildURLSearchParamsFromObject = (e) => {
  const n = {};
  for (const u in e)
    e[u] && (n[u] = `${e[u]}`);
  return new URLSearchParams(n);
};
export {
  U
};
