/**
 * Shortcut credit balance fetcher.
 *
 * Fetches the user's remaining credits from the Shortcut API
 * and exposes them for display in the footer.
 */
import { SHORTCUT_API_URL as API_BASE_URL } from '../constants.js';
import { SHORTCUT_API_ENDPOINTS } from '../endpoints.js';
/**
 * Fetch the current credit balance for a Shortcut-authenticated user.
 * Returns null on any failure (network, auth, etc.) — never throws.
 */
export async function fetchCreditBalance(accessToken) {
    try {
        const response = await fetch(`${API_BASE_URL}${SHORTCUT_API_ENDPOINTS.creditsBalance}`, {
            headers: { Authorization: `Bearer ${accessToken}` }
        });
        if (!response.ok)
            return null;
        const data = await response.json();
        return {
            creditsRemaining: data.creditsRemaining ?? 0,
            isUnlimited: data.isUnlimited ?? false,
            hasTeamBilling: data.billingAdminCredits != null
        };
    }
    catch {
        return null;
    }
}
//# sourceMappingURL=shortcut-credits.js.map