"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useAutoDismissPostOnboardingEntryPoint = void 0;
const react_redux_1 = require("react-redux");
const reducer_1 = require("../reducer");
const react_1 = require("react");
const actions_1 = require("../actions");
const usePostOnboardingEntryPointVisibleOnWallet_1 = require("./usePostOnboardingEntryPointVisibleOnWallet");
const millisecondsInADay = 1000 * 60 * 60 * 24;
const isMoreThanSevenDaysAgo = (date) => {
    if (!date)
        return false;
    const datePlusSevenDays = new Date(date).getTime() + 7 * millisecondsInADay;
    const today = new Date().getTime();
    return datePlusSevenDays < today;
};
function useAutoDismissPostOnboardingEntryPoint() {
    const dispatch = (0, react_redux_1.useDispatch)();
    const entryPointFirstDisplayedDate = (0, react_redux_1.useSelector)(reducer_1.entryPointFirstDisplayedDateSelector);
    const isPostOnboardingEntryPointVisible = (0, usePostOnboardingEntryPointVisibleOnWallet_1.usePostOnboardingEntryPointVisibleOnWallet)();
    (0, react_1.useEffect)(() => {
        if (isPostOnboardingEntryPointVisible && isMoreThanSevenDaysAgo(entryPointFirstDisplayedDate)) {
            dispatch((0, actions_1.hidePostOnboardingWalletEntryPoint)());
        }
        // eslint-disable-next-line react-hooks/exhaustive-deps
    }, []);
    return null;
}
exports.useAutoDismissPostOnboardingEntryPoint = useAutoDismissPostOnboardingEntryPoint;
//# sourceMappingURL=useAutoDismissPostOnboardingEntryPoint.js.map