{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "shell-sign-out",
  "title": "Sign out",
  "description": "Ends the session and shows the host's own error if it fails.",
  "dependencies": [
    "@registrystack/app-runtime@~0.43.0-next.0",
    "lucide-react@1.43.0"
  ],
  "registryDependencies": [
    "@registrystack/shell-content",
    "@registrystack/shell-error-panel",
    "@registrystack/ui-button"
  ],
  "files": [
    {
      "path": "shell/sign-out.tsx",
      "content": "import { useState } from \"react\";\nimport { LogOut, UserRoundCog } from \"lucide-react\";\nimport { useEndSession, useSignOut } from \"@registrystack/app-runtime/react\";\nimport { Button } from \"@/components/ui/button\";\nimport { ErrorPanel } from \"@/blocks/shell/error-panel\";\nimport { useShellContent } from \"@/blocks/shell/shell-content\";\n\n/** Ends the session; the runtime's own hook, kept here for pages that import it. */\nexport { useSignOut };\n\nexport function SignOut() {\n  const c = useShellContent();\n  const signOut = useSignOut();\n  const [error, setError] = useState<unknown>(null);\n  return (\n    <>\n      <Button variant=\"ghost\" onClick={() => void signOut().catch(setError)}>\n        <LogOut size={16} />\n        {c.signOut}\n      </Button>\n      {error && <ErrorPanel error={error} />}\n    </>\n  );\n}\n\n/** The host route that signs a person in again and asks the issuer to authenticate them afresh. */\nexport function switchAccountUrl(app: string): string {\n  return `/auth/login?app=${encodeURIComponent(app)}&switch=1`;\n}\n\n/**\n * Ends the session through the host's sign-out route, then starts a fresh\n * sign-in through its sign-in route. Nothing of the first session travels\n * with the second; a refused sign-out stops before the sign-in starts.\n * `signOut` ends only the app session (`useEndSession`): the fresh sign-in\n * asks the issuer to authenticate the person again, and visiting the issuer's\n * logout first would return to the app origin instead of that sign-in.\n */\nexport async function switchAccount(\n  signOut: () => Promise<void>,\n  navigate: (url: string) => void,\n  app: string,\n): Promise<void> {\n  await signOut();\n  navigate(switchAccountUrl(app));\n}\n\nexport function SwitchAccount({ app }: { app: string }) {\n  const c = useShellContent();\n  const endSession = useEndSession();\n  const [error, setError] = useState<unknown>(null);\n  return (\n    <>\n      <Button\n        variant=\"ghost\"\n        onClick={() =>\n          void switchAccount(\n            endSession,\n            (url) => window.location.assign(url),\n            app,\n          ).catch(setError)\n        }\n      >\n        <UserRoundCog size={16} />\n        {c.switchAccount}\n      </Button>\n      {error && <ErrorPanel error={error} />}\n    </>\n  );\n}\n",
      "type": "registry:block",
      "target": "@components/shell/sign-out.tsx"
    }
  ],
  "type": "registry:block"
}