// Synced from packages/transport-http/src/reconnect.ts
// Extracted from legacy source: src/runtime/transports/stream-reconnect.ts
import { computeBackoffDelay, normalizeBackoffPolicy } from './backoff.js';
export const DEFAULT_STREAM_RECONNECT_POLICY = {
    enabled: false,
    maxAttempts: Number.POSITIVE_INFINITY,
    baseDelayMs: 500,
    maxDelayMs: 5_000,
    backoffFactor: 2,
};
export function normalizeStreamReconnectPolicy(policy) {
    const normalized = normalizeBackoffPolicy(policy, DEFAULT_STREAM_RECONNECT_POLICY);
    return {
        ...normalized,
        enabled: policy?.enabled ?? DEFAULT_STREAM_RECONNECT_POLICY.enabled,
    };
}
export function getStreamReconnectDelay(attempt, policy) {
    return computeBackoffDelay(attempt, policy);
}
