// Synced from packages/transport-http/src/sse.ts
import { openServerSentEventStream as openServerSentEventStreamCore } from './sse-stream.js';
import { normalizeTransportError } from './http.js';
export async function openServerSentEventStream(transport, pathOrUrl, handlers, options = {}) {
    const url = pathOrUrl.startsWith('http://') || pathOrUrl.startsWith('https://')
        ? pathOrUrl
        : transport.buildUrl(pathOrUrl);
    try {
        return await openServerSentEventStreamCore(transport.fetchImpl, url, handlers, {
            ...options,
            authToken: transport.authToken,
            getAuthToken: transport.getAuthToken.bind(transport),
        });
    }
    catch (error) {
        throw normalizeTransportError(error);
    }
}
