"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useLogic = void 0;
const react_1 = require("react");
const useInterval_1 = require("../../../../useInterval");
// При достижении указанного значения прогресс-бар остановится
const STOP_VALUE = 80;
const useLogic = ({ progress }) => {
    const [fakeProgress, setFakeProgress] = (0, react_1.useState)(0);
    const isRealProgress = typeof progress === 'number';
    const playFakeProgress = () => {
        setFakeProgress((prevValue) => prevValue + 10);
    };
    (0, useInterval_1.useInterval)(() => {
        if (!isRealProgress) {
            playFakeProgress();
        }
    }, fakeProgress >= STOP_VALUE ? null : 500);
    const valueProgress = isRealProgress ? progress : fakeProgress;
    return { progressBarProps: { value: valueProgress } };
};
exports.useLogic = useLogic;
