import { t as accountKeys } from "./query-keys-QbaHKNsd.mjs";
import { createContext, use } from "react";
import { useQuery } from "@tanstack/react-query";
//#region ../core/src/account-api-context.ts
const AccountApiContext = createContext(null);
const AccountApiProvider = AccountApiContext.Provider;
function useAccountApi() {
	const api = use(AccountApiContext);
	if (!api) throw new Error("useAccountApi must be used within an AccountApiProvider");
	return api;
}
//#endregion
//#region src/hooks/use-account.ts
/**
* Fetches the current user's account from GET /api/account.
* Replaces the old useCurrentUser (which called non-existent /api/me).
*/
function useAccount() {
	const api = useAccountApi();
	return useQuery({
		queryKey: accountKeys.detail(),
		queryFn: async () => {
			return (await api.fetchAccount()).account;
		},
		staleTime: 300 * 1e3
	});
}
//#endregion
export { AccountApiProvider as n, useAccountApi as r, useAccount as t };

//# sourceMappingURL=use-account-DR6HXMw_.mjs.map