<reponame>vwraposo/netlify-test
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.storage = void 0;
const env_1 = require("../../utils/env");
const SESSION_STORAGE_KEY = 'vtex:session';
const ONE_DAY_MS = 86400000;
exports.storage = {
    get: () => {
        const serialized = env_1.isServer
            ? null
            : localStorage.getItem(SESSION_STORAGE_KEY);
        const payload = serialized ? JSON.parse(serialized) : null;
        if (payload) {
            const elapsedTime = Date.now() - payload.generatedAt;
            if (elapsedTime < ONE_DAY_MS) {
                return payload.value;
            }
        }
        return null;
    },
    set: (data) => {
        const payload = {
            value: data,
            generatedAt: Date.now(),
        };
        localStorage.setItem(SESSION_STORAGE_KEY, JSON.stringify(payload));
    },
};
