"use client";
import { useCallback, useMemo, useState } from "react";
/**
 * State management hook for confirmation dialogs.
 *
 * Provides an imperative `confirm()` function that returns a promise,
 * paired with `confirmState` for rendering a `ConfirmDialog`.
 *
 * Separates the state logic (this hook) from the visual presentation
 * (ConfirmDialog component) following the headless-first architecture
 * (DD-003).
 */
export function useConfirmAction() {
    const [confirmState, setConfirmState] = useState(null);
    const confirm = useCallback((options) => {
        return new Promise((resolve) => {
            setConfirmState({ ...options, resolve });
        });
    }, []);
    const handleConfirm = useCallback(() => {
        confirmState?.resolve(true);
        setConfirmState(null);
    }, [confirmState]);
    const handleCancel = useCallback(() => {
        confirmState?.resolve(false);
        setConfirmState(null);
    }, [confirmState]);
    return useMemo(() => ({ confirmState, confirm, handleConfirm, handleCancel }), [confirmState, confirm, handleConfirm, handleCancel]);
}
//# sourceMappingURL=useConfirmAction.js.map