"use client" import type { QueryClient } from "@tanstack/react-query" import { AUTH_STORAGE_KEY, LEGACY_AUTH_KEYS, useAuthStore } from "@/lib/api/auth-store" import { flushPersistStorage } from "@/lib/stores/debounced-json-storage" import { useAccountStore } from "@/lib/stores/account-store" /** Drop in-memory auth, cached API data, and persisted profile chrome. */ export function clearClientAuthState(queryClient?: QueryClient) { useAuthStore.getState().logout() queryClient?.clear() useAccountStore.setState({ activeAccountId: null, otherAccountsExpanded: true }) if (typeof window === "undefined") return localStorage.removeItem(AUTH_STORAGE_KEY) for (const legacy of LEGACY_AUTH_KEYS) { localStorage.removeItem(legacy) } flushPersistStorage() }