import { useState, useEffect } from 'react';
import { parse } from 'date-fns';
export default function useConfirmStatus(_a) {
    var disabledTimeOption = _a.disabledTimeOption, selected = _a.selected, format = _a.format;
    var _b = useState(false), confirmStatus = _b[0], setConfirmStatus = _b[1];
    useEffect(function () {
        var date = parse(selected, format, new Date());
        var hour = date.getHours();
        var minute = date.getMinutes();
        var disabledHour = function () { var _a, _b; return (_b = (_a = disabledTimeOption === null || disabledTimeOption === void 0 ? void 0 : disabledTimeOption.disabledHours) === null || _a === void 0 ? void 0 : _a.call(disabledTimeOption)) === null || _b === void 0 ? void 0 : _b.includes(hour); };
        var disabledMinute = function () { var _a, _b; return (_b = (_a = disabledTimeOption === null || disabledTimeOption === void 0 ? void 0 : disabledTimeOption.disabledMinutes) === null || _a === void 0 ? void 0 : _a.call(disabledTimeOption, hour)) === null || _b === void 0 ? void 0 : _b.includes(minute); };
        var disabledSecond = function () {
            var _a, _b;
            return (_b = (_a = disabledTimeOption === null || disabledTimeOption === void 0 ? void 0 : disabledTimeOption.disabledSeconds) === null || _a === void 0 ? void 0 : _a.call(disabledTimeOption, hour, minute)) === null || _b === void 0 ? void 0 : _b.includes(date.getSeconds());
        };
        setConfirmStatus(!selected || disabledHour() || disabledMinute() || disabledSecond());
    }, [selected, format, disabledTimeOption]);
    return confirmStatus;
}
