import { l as localforage } from './localforage-9daa31d6.js';

async function getCache(key, defaultValue) {
  var _a;
  let data = null;
  try {
    data = await ((_a = localforage === null || localforage === void 0 ? void 0 : localforage.getItem) === null || _a === void 0 ? void 0 : _a.call(localforage, key));
  }
  catch (error) {
    console.log("Error fetching data from cache with localforage", error);
    try {
      data = localStorage.getItem(key)
        ? JSON.parse(localStorage.getItem(key))
        : null;
    }
    catch (err) {
      console.log("Error fetching data from cache with LocalStorage", err);
    }
  }
  return data === null && typeof defaultValue !== "undefined"
    ? defaultValue
    : data;
}

export { getCache as g };
