{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "admin",
  "title": "Admin",
  "description": "Admin plugin integration that adds a stop-impersonating action to the user button while an administrator is impersonating another user.",
  "dependencies": [
    "@better-auth-ui/react@latest",
    "@better-auth-ui/core@latest",
    "better-auth",
    "lucide-react"
  ],
  "registryDependencies": [
    "dropdown-menu",
    "spinner",
    "https://better-auth-ui.com/r/radix-nova/user-button.json"
  ],
  "files": [
    {
      "path": "src/lib/auth/auth-plugin.ts",
      "content": "import type {\n  AuthPluginComponents,\n  AuthPlugin as AuthPluginPrimitive\n} from \"@better-auth-ui/react\"\n\ndeclare module \"@better-auth-ui/core\" {\n  /** Widens `useAuth().plugins` to the shadcn-typed `AuthPlugin`. */\n  interface AuthPluginRegister {\n    shadcn: AuthPlugin\n  }\n}\n\n/** Props the shadcn `<Auth>` router spreads onto plugin-contributed auth views. */\nexport type AuthViewProps = {\n  className?: string\n  socialLayout?: \"auto\" | \"horizontal\" | \"vertical\" | \"grid\"\n  socialPosition?: \"top\" | \"bottom\"\n}\n\n/** Props the shadcn `<Settings>` router spreads onto plugin-contributed settings views. */\nexport type SettingsViewProps = {\n  className?: string\n}\n\n/** Shadcn plugin type. Plugin authors import this from `@/lib/auth/auth-plugin`. */\nexport type AuthPlugin = AuthPluginPrimitive<\n  AuthPluginComponents,\n  AuthViewProps,\n  SettingsViewProps\n>\n",
      "type": "registry:lib",
      "target": "@lib/auth/auth-plugin.ts"
    },
    {
      "path": "src/lib/auth/admin-plugin.ts",
      "content": "import { createAuthPlugin } from \"@better-auth-ui/core\"\nimport {\n  type AdminPluginOptions,\n  adminPlugin as coreAdminPlugin\n} from \"@better-auth-ui/core/plugins\"\n\nimport { StopImpersonating } from \"@/components/auth/admin/stop-impersonating\"\n\nexport const adminPlugin = createAuthPlugin(\n  coreAdminPlugin.id,\n  (options: AdminPluginOptions = {}) => ({\n    ...coreAdminPlugin(options),\n    userMenuItems: [StopImpersonating]\n  })\n)\n",
      "type": "registry:lib",
      "target": "@lib/auth/admin-plugin.ts"
    },
    {
      "path": "src/components/auth/admin/stop-impersonating.tsx",
      "content": "\"use client\"\n\nimport { isImpersonatingSession } from \"@better-auth-ui/core/plugins\"\nimport {\n  type AdminAuthClient,\n  useAuth,\n  useAuthPlugin,\n  useSession,\n  useStopImpersonating\n} from \"@better-auth-ui/react\"\nimport { UserRoundCheck } from \"lucide-react\"\n\nimport { DropdownMenuItem } from \"@/components/ui/dropdown-menu\"\nimport { Spinner } from \"@/components/ui/spinner\"\nimport { adminPlugin } from \"@/lib/auth/admin-plugin\"\n\nexport type StopImpersonatingProps = {\n  className?: string\n}\n\n/**\n * Restore the administrator's session when the current session is\n * impersonating another user.\n */\nexport function StopImpersonating({ className }: StopImpersonatingProps) {\n  const { authClient } = useAuth()\n  const { localization } = useAuthPlugin(adminPlugin)\n  const { data: session } = useSession(authClient)\n  const stopImpersonating = useStopImpersonating(authClient as AdminAuthClient)\n\n  if (!isImpersonatingSession(session)) {\n    return null\n  }\n\n  return (\n    <DropdownMenuItem\n      className={className}\n      disabled={stopImpersonating.isPending}\n      onClick={() => stopImpersonating.mutate(undefined)}\n    >\n      {stopImpersonating.isPending ? (\n        <Spinner />\n      ) : (\n        <UserRoundCheck className=\"text-muted-foreground\" />\n      )}\n\n      {localization.stopImpersonating}\n    </DropdownMenuItem>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/auth/admin/stop-impersonating.tsx"
    }
  ],
  "type": "registry:component"
}