"use client";
import { useStigmer } from "../../hooks";
import { useFetch } from "../../internal/useFetch";
/**
 * Data hook that fetches a single WorkflowInstance by ID.
 *
 * Wraps `stigmer.workflowInstance.get()` with loading and error state.
 * Pass `null` or `undefined` as `instanceId` to skip fetching (stable no-op).
 *
 * @example
 * ```tsx
 * const { instance, isLoading } = useWorkflowInstance(selectedInstanceId);
 * ```
 */
export function useWorkflowInstance(instanceId) {
    const stigmer = useStigmer();
    const fetchFn = instanceId
        ? async () => stigmer.workflowInstance.get(instanceId)
        : null;
    const { data: instance, isLoading, isRefetching, error, refetch, } = useFetch(fetchFn, [instanceId, stigmer], null);
    return { instance, isLoading, isRefetching, error, refetch };
}
//# sourceMappingURL=useWorkflowInstance.js.map