import { useState as S, useEffect as g, useCallback as u } from "react";
const a = (e, o, c) => {
  const t = c === "localStorage" ? window.localStorage : window.sessionStorage, [s, r] = S(() => {
    const n = t.getItem(e);
    return n ? JSON.parse(n) : typeof o == "function" ? o() : o;
  });
  g(() => {
    s ? t.setItem(e, JSON.stringify(s)) : t.removeItem(e);
  }, [e, s, t]);
  const i = u(() => {
    r(void 0);
  }, []);
  return [s, r, i];
}, f = (e, o) => a(e, o, "localStorage"), m = (e, o) => a(e, o, "sessionStorage");
export {
  f as useLocalStorage,
  m as useSessionStorage
};
//# sourceMappingURL=useStorage.js.map
