"use client";
import { create } from "@bufbuild/protobuf";
import { ListOAuthAppsByOrgInputSchema } from "@stigmer/protos/ai/stigmer/iam/oauthapp/v1/io_pb";
import { useStigmer } from "../hooks";
import { useFetch } from "../internal/useFetch";
/**
 * Data hook that fetches all {@link OAuthApp} entries for an organization.
 *
 * Returns every OAuthApp whose `metadata.org` matches the input. In
 * practice these are the BYOA OAuth apps created through the "Bring
 * your own app" flow on MCP server detail pages.
 *
 * Pass `null` for `org` to skip fetching (stable no-op). Useful when
 * the active organization has not been resolved yet.
 *
 * @example
 * ```tsx
 * const { oauthApps, isLoading, error } = useOAuthAppList(org);
 *
 * if (isLoading) return <Spinner />;
 * oauthApps.map((app) => app.spec?.provider);
 * ```
 */
export function useOAuthAppList(org) {
    const stigmer = useStigmer();
    const { data: oauthApps, isLoading, isRefetching, error, refetch } = useFetch(org
        ? () => stigmer.oauthapp
            .listByOrg(create(ListOAuthAppsByOrgInputSchema, { org }))
            .then((r) => [...r.entries])
        : null, [org, stigmer], []);
    return { oauthApps, isLoading, isRefetching, error, refetch };
}
//# sourceMappingURL=useOAuthAppList.js.map