/**
 * @license
 * Copyright 2025 Vybestack LLC
 * SPDX-License-Identifier: Apache-2.0
 */
import { useCallback } from 'react';
export class TodoPausePreserver {
    preserveNextSubmission = false;
    handleSubmit(onClear) {
        if (this.preserveNextSubmission) {
            this.preserveNextSubmission = false;
            return;
        }
        onClear();
    }
    registerTodoPause() {
        this.preserveNextSubmission = true;
    }
}
export const useTodoPausePreserver = ({ controller, updateTodos, handleFinalSubmit, }) => {
    const handleUserInputSubmit = useCallback((submittedValue) => {
        controller.handleSubmit(() => {
            updateTodos([]);
        });
        handleFinalSubmit(submittedValue);
    }, [controller, updateTodos, handleFinalSubmit]);
    return {
        handleUserInputSubmit,
    };
};
//# sourceMappingURL=useTodoPausePreserver.js.map