/*! js-cookie v3.0.5 | MIT */
function l(e) {
  for (var t = 1; t < arguments.length; t++) {
    var n = arguments[t];
    for (var g in n)
      e[g] = n[g];
  }
  return e;
}
var k = {
  read: function(e) {
    return e[0] === '"' && (e = e.slice(1, -1)), e.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
  },
  write: function(e) {
    return encodeURIComponent(e).replace(
      /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
      decodeURIComponent
    );
  }
};
function d(e, t) {
  function n(r, i, o) {
    if (!(typeof document > "u")) {
      o = l({}, t, o), typeof o.expires == "number" && (o.expires = new Date(Date.now() + o.expires * 864e5)), o.expires && (o.expires = o.expires.toUTCString()), r = encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
      var c = "";
      for (var s in o)
        o[s] && (c += "; " + s, o[s] !== !0 && (c += "=" + o[s].split(";")[0]));
      return document.cookie = r + "=" + e.write(i, r) + c;
    }
  }
  function g(r) {
    if (!(typeof document > "u" || arguments.length && !r)) {
      for (var i = document.cookie ? document.cookie.split("; ") : [], o = {}, c = 0; c < i.length; c++) {
        var s = i[c].split("="), I = s.slice(1).join("=");
        try {
          var f = decodeURIComponent(s[0]);
          if (o[f] = e.read(I, f), r === f)
            break;
        } catch {
        }
      }
      return r ? o[r] : o;
    }
  }
  return Object.create(
    {
      set: n,
      get: g,
      remove: function(r, i) {
        n(
          r,
          "",
          l({}, i, {
            expires: -1
          })
        );
      },
      withAttributes: function(r) {
        return d(this.converter, l({}, this.attributes, r));
      },
      withConverter: function(r) {
        return d(l({}, this.converter, r), this.attributes);
      }
    },
    {
      attributes: { value: Object.freeze(t) },
      converter: { value: Object.freeze(e) }
    }
  );
}
var p = d(k, { path: "/" });
const a = "accessToken", m = "accessTokenExpiredAt", v = "refreshToken", u = "redirectUri", S = "csrf-token", h = () => localStorage.getItem(a) ?? p.get(a) ?? sessionStorage.getItem(a) ?? "", C = (e) => localStorage.getItem(e) ?? p.get(e) ?? sessionStorage.getItem(e) ?? "", x = (e, t = {}) => {
  var n;
  (n = window.webConfig) != null && n.disableSaveToken || (localStorage.setItem(a, e), localStorage.setItem(m, t.accessTokenExpiredAt ?? "0"), localStorage.setItem(v, t.refreshToken ?? ""), t.redirectUri && localStorage.setItem(u, t.redirectUri));
}, U = () => {
  localStorage.removeItem(a), localStorage.removeItem(m), localStorage.removeItem(v), localStorage.removeItem(u), localStorage.removeItem(S);
};
export {
  h as getAccessToken,
  C as getAccessTokenInfo,
  U as removeAccessToken,
  x as setAccessToken
};
