import {
  copilotRuntimeNodeHttpEndpoint,
  getCommonConfig,
  getRuntimeInstanceTelemetryInfo,
  telemetry_client_default
} from "./chunk-KEYLBFU2.mjs";
import {
  __name
} from "./chunk-FHD4JECV.mjs";

// src/lib/integrations/nextjs/app-router.ts
import { createCopilotEndpointSingleRoute } from "@copilotkitnext/runtime";
import { handle } from "hono/vercel";
function copilotRuntimeNextJSAppRouterEndpoint(options) {
  var _a;
  const commonConfig = getCommonConfig(options);
  console.log("\u2728 copilotRuntimeNextJSAppRouterEndpoint", JSON.stringify(options, null, 2));
  telemetry_client_default.setGlobalProperties({
    runtime: {
      framework: "nextjs-app-router"
    }
  });
  if ((_a = options.properties) == null ? void 0 : _a._copilotkit) {
    telemetry_client_default.setGlobalProperties({
      _copilotkit: options.properties._copilotkit
    });
  }
  telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options));
  const logger = commonConfig.logging;
  logger.debug("Creating NextJS App Router endpoint");
  const serviceAdapter = options.serviceAdapter;
  options.runtime.handleServiceAdapter(serviceAdapter);
  const copilotRoute = createCopilotEndpointSingleRoute({
    runtime: options.runtime.instance,
    basePath: options.baseUrl ?? options.endpoint
  });
  return {
    handleRequest: handle(copilotRoute)
  };
}
__name(copilotRuntimeNextJSAppRouterEndpoint, "copilotRuntimeNextJSAppRouterEndpoint");

// src/lib/integrations/nextjs/pages-router.ts
var config = {
  api: {
    bodyParser: false
  }
};
function copilotRuntimeNextJSPagesRouterEndpoint(options) {
  var _a;
  const commonConfig = getCommonConfig(options);
  telemetry_client_default.setGlobalProperties({
    runtime: {
      framework: "nextjs-pages-router"
    }
  });
  if ((_a = options.properties) == null ? void 0 : _a._copilotkit) {
    telemetry_client_default.setGlobalProperties({
      _copilotkit: options.properties._copilotkit
    });
  }
  telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options));
  const logger = commonConfig.logging;
  logger.debug("Creating NextJS Pages Router endpoint");
  return copilotRuntimeNodeHttpEndpoint(options);
}
__name(copilotRuntimeNextJSPagesRouterEndpoint, "copilotRuntimeNextJSPagesRouterEndpoint");

export {
  copilotRuntimeNextJSAppRouterEndpoint,
  config,
  copilotRuntimeNextJSPagesRouterEndpoint
};
//# sourceMappingURL=chunk-AF73TFTX.mjs.map