'use strict';

const localforage = require('./localforage-af1b8c0e.js');

async function getCache(key, defaultValue) {
  var _a;
  let data = null;
  try {
    data = await ((_a = localforage.localforage === null || localforage.localforage === void 0 ? void 0 : localforage.localforage.getItem) === null || _a === void 0 ? void 0 : _a.call(localforage.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;
}

exports.getCache = getCache;
