import { u as useServerEvents } from '../_/useServerEvents.mjs';
import { c as defineEventHandler, f as setHeader, h as setResponseStatus, g as getQuery } from '../_/nitro.mjs';
import 'node:http';
import 'node:https';
import 'node:events';
import 'node:buffer';
import 'node:fs';
import 'node:path';
import 'node:crypto';
import 'node:url';

const eventStream_get = defineEventHandler(async (event) => {
  setHeader(event, "content-type", "text/event-stream");
  setHeader(event, "cache-control", "no-cache");
  setHeader(event, "connection", "keep-alive");
  setResponseStatus(event, 200);
  const { addClient, close } = useServerEvents();
  const { clientId } = getQuery(event);
  addClient({
    id: clientId,
    response: event.node.res
  });
  event._handled = true;
  event.node.req.on("close", () => {
    close(event.node.res);
  });
  return {};
});

export { eventStream_get as default };
//# sourceMappingURL=event-stream.get.mjs.map
