'use strict';

const index = require('./index-81aa1bcb.js');
const getCache = require('./getCache-c039a6ae.js');

const config = {
  env: "live",
  url: "https://theflood.team",
  dade: {
    apiKey: "668112a786ef9e357d5dbb53993afa62",
    url: "https://lockbox.dadesystems.com/api/billers/670",
  },
  functions: {
    url: "https://us-central1-the-flood-team.cloudfunctions.net",
  },
  firebase: {
    apiKey: "AIzaSyCMZzl6TZViOFx3G3Wz7omxL56e_WnMAzQ",
    authDomain: "the-flood-team.firebaseapp.com",
    projectId: "the-flood-team",
    storageBucket: "the-flood-team.appspot.com",
    messagingSenderId: "1065444417180",
    appId: "1:1065444417180:web:cd5fd2a1a6b15cf2f0d759",
    measurementId: "G-8J4NCLDTBN",
  },
  graphql: {
    url: "https://theflood.team/graphql",
  },
  logrocketKey: "mfh3ua/flood-team-app",
  stripe: {
    key: "pk_live_r5b0hheVLZcWxxyUS0cNkTlC",
    clientId: "ca_DRtszUtwgrKfRt9XkV5ArzRJYKLJV39m",
  },
  dynamicLinkDomain: "floodteam.page.link",
  franchise: {
    stripe: {
      key: "pk_live_B1NjOFNTbjMmRcPd6AeLrnDG00wukem0hk",
      clientId: "ca_H3DErpg90RI5wuL2mZU3AMjp1DumT2k0",
    },
    dade: {
      apiKey: "a4f3f7e624de9fded4af23a40b3f0ba4",
      url: "https://lockbox.dadesystems.com/api/billers/966",
    },
  },
};

function env(key, fallback) {
  const value = !key
    ? config
    : key && key.indexOf(".") >= 0
      ? key.split(".").reduce((p, c) => (p && p[c]) || null, config)
      : key && typeof config[key] !== "undefined"
        ? config[key]
        : null;
  return fallback &&
    ((!value && value !== false && value !== 0) ||
      typeof value === "undefined" ||
      value === null)
    ? fallback
    : value;
}

// import localforage from "localforage";
async function setCache(key, value) {
  // try {
  //   await localforage?.setItem?.(key, value);
  // } catch (error) {
  //   console.log("Error setting data from cache with localforage", error);
  try {
    localStorage.setItem(key, JSON.stringify(value));
  }
  catch (err) {
    console.log("Error setting data from cache with localStorage", err);
  }
  // }
  return value;
}

const { state, onChange } = index.createStore({
  manifest: {},
  config: env(),
  version: "1.1.0",
  locations: getCache.getCache("floodteam:locations", []),
  profile: getCache.getCache("floodteam:profile", {}),
  session: null,
  services: getCache.getCache("floodteam:services", []),
  templates: getCache.getCache("floodteam:templates", []),
  isOnline: false,
  claims: {},
  myJobs: getCache.getCache("floodteam:templates", []),
  job: null,
  site: null,
  pins: getCache.getCache("floodteam:pins", []),
  feed: getCache.getCache("floodteam:feed", []),
  editorSizes: [50, 50],
  isPreviewing: false,
  showingNaviation: false,
  roles: [
    "homeowner",
    "franchisee",
    "mitigation",
    "vision",
    "design",
    "tech",
    "finance",
    "operations",
    "success",
    "marketing",
    "agent",
    "adjuster",
    "referral",
    "vendor",
    "business",
  ],
});
onChange("editorSizes", async (value) => {
  await setCache("floodteam:editorSizes", value);
});
onChange("isPreviewing", async (value) => {
  await setCache("floodteam:isPreviewing", value);
});
onChange("feed", async (value) => {
  await setCache("floodteam:feed", value);
});
onChange("pins", async (value) => {
  await setCache("floodteam:pins", value);
});
onChange("job", async (value) => {
  await setCache("floodteam:job", value);
});
onChange("myJobs", async (value) => {
  await setCache("floodteam:myjobs", value);
});
onChange("claims", async (value) => {
  await setCache("floodteam:claims", value);
});
onChange("profile", async (value) => {
  await setCache("floodteam:profile", value);
});
onChange("site", async (value) => {
  await setCache("floodteam:site", value);
});
onChange("services", async (value) => {
  await setCache("floodteam:services", value);
});
onChange("locations", async (value) => {
  await setCache("floodteam:locations", value);
});
onChange("templates", async (value) => {
  await setCache("floodteam:templates", value);
});

exports.env = env;
exports.state = state;

//# sourceMappingURL=store-f2110833.js.map