"use client";
import { useCallback, useState } from "react";
import { useStigmer } from "../hooks";
import { toError } from "../internal/toError";
/**
 * Mutation hook that wraps `platformclient.delete()` with loading
 * and error state.
 *
 * Deletes a platform client by its resource ID. Returns the deleted
 * {@link PlatformClient} on success so callers can confirm which
 * resource was removed.
 *
 * @example
 * ```tsx
 * const { deletePlatformClient, isDeleting, error } = useDeletePlatformClient();
 *
 * await deletePlatformClient({ resourceId: "pc-abc123" });
 * refetch(); // refresh the list after deletion
 * ```
 */
export function useDeletePlatformClient() {
    const stigmer = useStigmer();
    const [isDeleting, setIsDeleting] = useState(false);
    const [error, setError] = useState(null);
    const clearError = useCallback(() => setError(null), []);
    const deletePlatformClient = useCallback(async (input) => {
        setIsDeleting(true);
        setError(null);
        try {
            return await stigmer.platformclient.delete(input);
        }
        catch (err) {
            setError(toError(err));
            throw err;
        }
        finally {
            setIsDeleting(false);
        }
    }, [stigmer]);
    return { deletePlatformClient, isDeleting, error, clearError };
}
//# sourceMappingURL=useDeletePlatformClient.js.map