export const MAX_PENDING_REFRESHES = 20;
export function formatPendingRefreshLimitMessage(surface) {
    return `refresh_context exceeded ${MAX_PENDING_REFRESHES} continuations in ${surface}.`;
}
export async function drainPendingRefreshes(options) {
    let count = 0;
    let refresh;
    while ((refresh = options.consumePendingRefresh()) !== null) {
        count++;
        if (count > MAX_PENDING_REFRESHES) {
            return {
                count: count - 1,
                limitExceeded: true,
                message: formatPendingRefreshLimitMessage(options.surface)
            };
        }
        await options.beforeRefresh?.(refresh);
        await options.preparePendingRefresh(refresh);
        await options.prompt(refresh.prompt);
    }
    return { count, limitExceeded: false };
}
//# sourceMappingURL=pending-refresh-runner.js.map