"use client";
import { useStigmer } from "../hooks";
import { useFetch } from "../internal/useFetch";
/**
 * Data hook that fetches a single IdentityProvider by ID.
 *
 * Pass `null` to skip fetching (stable no-op). When the `id` changes,
 * the previous in-flight request is discarded and a fresh fetch begins.
 *
 * Returns the full proto {@link IdentityProvider} resource so consumers
 * have access to metadata, spec (JWKS URI, issuers, SSO config), and
 * status without additional calls.
 *
 * @example
 * ```tsx
 * function IdpDetail({ idpId }: { idpId: string }) {
 *   const { identityProvider, isLoading, error } = useIdentityProvider(idpId);
 *
 *   if (isLoading) return <Skeleton />;
 *   if (error) return <ErrorMessage error={error} />;
 *   if (!identityProvider) return <NotFound />;
 *
 *   return <h1>{identityProvider.spec?.displayName}</h1>;
 * }
 * ```
 */
export function useIdentityProvider(id) {
    const stigmer = useStigmer();
    const { data: identityProvider, isLoading, isRefetching, error, refetch } = useFetch(id ? () => stigmer.identityProvider.get(id) : null, [id, stigmer], null);
    return { identityProvider, isLoading, isRefetching, error, refetch };
}
//# sourceMappingURL=useIdentityProvider.js.map