/**
 * Web Server Service
 *
 * Manages the Next.js programmatic server lifecycle.
 * Starts the web UI in the same Node.js process as the CLI,
 * sharing the DI container and application layer.
 *
 * Supports both development (dev: true) and production (dev: false) modes.
 * In production mode, Next.js serves the pre-built .next output.
 */
import next from 'next';
import http from 'node:http';
import type { IWebServerService } from '../../application/ports/output/services/web-server-service.interface.js';
export interface WebServerDeps {
    createNextApp: typeof next;
    createHttpServer: typeof http.createServer;
}
/**
 * Resolve the web UI directory path.
 * Works in both development (src/) and production (dist/) contexts.
 *
 * Priority order matters — when the same workspace has BOTH a dev
 * source tree AND a built `web/` bundle alongside `dist/`, we must
 * prefer the production bundle when it is reached from `dist/` so that
 * `node dist/src/presentation/cli/index.js ui` actually runs in prod
 * mode (no HMR, no compile badge, pre-built routes). Otherwise the
 * workspace-dev fallback would silently downgrade prod launches to
 * dev mode because `<root>/src/presentation/web/next.config.ts`
 * always exists in a dev checkout.
 *
 * Layouts this function handles:
 *
 *   Source (`pnpm dev:cli`): import.meta.dirname =
 *     <root>/packages/core/src/infrastructure/services/
 *     → 5 `..` + `src/presentation/web/` = <root>/src/presentation/web/
 *
 *   Built CLI in workspace (`node dist/.../ui`), prod `web/` NOT built:
 *     <root>/dist/packages/core/src/infrastructure/services/
 *     → 6 `..` + `src/presentation/web/` = <root>/src/presentation/web/
 *     (dev source fallback, kept for the "only built the CLI" loop)
 *
 *   Built CLI in workspace, prod `web/` ALREADY built (`pnpm build:release`):
 *     <root>/dist/packages/core/src/infrastructure/services/
 *     → 6 `..` + `web/` = <root>/web/
 *     (picked BEFORE the workspace-dev fallback)
 *
 *   Published npm install: same 6-up `web/` resolution.
 */
export declare function resolveWebDir(): {
    dir: string;
    dev: boolean;
};
export declare class WebServerService implements IWebServerService {
    private app;
    private server;
    private isShuttingDown;
    private readonly deps;
    constructor(deps?: Partial<WebServerDeps>);
    /**
     * Start the Next.js web server.
     * @param port - Port to listen on
     * @param dir - Path to the Next.js web package directory
     * @param dev - Whether to run in development mode (default: auto-detect)
     */
    start(port: number, dir: string, dev?: boolean): Promise<void>;
    /**
     * Gracefully stop the server.
     * Destroys active connections to avoid hanging on keep-alive sockets.
     */
    stop(): Promise<void>;
}
//# sourceMappingURL=web-server.service.d.ts.map