import { AlertCircle } from 'lucide-react' import type { ApiSuccessOf } from '../lib/api-client' import { Button } from './ui/button' type HfAuthStatus = ApiSuccessOf<'getHuggingFaceAuthStatus'>['status'] type ModelAccessMap = ApiSuccessOf<'checkModelAccess'>['access'] interface HfModelAccessGateProps { accessMap: ModelAccessMap allAuthorized: boolean hfAuthStatus: HfAuthStatus hfAuthPolling: boolean startHuggingFaceLogin: () => void /** When the access check itself failed (network/backend), distinct from unauthorized. */ checkError?: string | null onRetryCheck?: () => void className?: string } export function HfModelAccessGate({ accessMap, allAuthorized, hfAuthStatus, hfAuthPolling, startHuggingFaceLogin, checkError = null, onRetryCheck, className, }: HfModelAccessGateProps) { if (allAuthorized) return null if (checkError) { return (
Couldn't verify Hugging Face access: {checkError}
{onRetryCheck && ( )}
) } const unauthorizedRepos = Object.entries(accessMap).filter(([, status]) => status === 'not_authorized') if (unauthorizedRepos.length === 0) return null if (hfAuthStatus !== 'authenticated') { return (
This model is gated on Hugging Face. Sign in, then accept the license to download.
) } return (

Accept the Hugging Face license for this model, then download.

{unauthorizedRepos.map(([repoId]) => (
{repoId}
))}
) }