import { PACKAGE_VERSION, init_package_version } from "../../../package-version.js";
import { serveStaticFile } from "../lib/static-ui.js";
//#region src/gateway/hono/routes/public-gateway.ts
init_package_version();
function registerPublicGatewayRoutes(app, service) {
	app.get("/health", (c) => {
		return c.json(service.getHealth());
	});
	/** Public liveness probe (no auth) — minimal payload for CLI / load balancers. */
	app.get("/api/health", (c) => {
		const health = service.getHealth();
		return c.json({
			status: health.ready ? "ok" : "starting",
			ready: health.ready,
			httpListening: health.httpListening,
			version: health.version,
			uptime: health.uptime,
			startupDurationMs: health.startupDurationMs
		});
	});
	app.get("/api", (c) => {
		return c.json({
			service: "xopc-gateway",
			version: PACKAGE_VERSION,
			transport: "streamable-http",
			endpoints: [
				"GET  /health",
				"GET  /api/health",
				"GET  /status",
				"GET  /api/status",
				"POST /api/agent           (SSE stream / JSON)",
				"POST /api/agent/abort",
				"POST /api/agent/steer",
				"POST /api/send",
				"GET  /api/events          (SSE stream)",
				"GET  /api/channels/status",
				"POST /api/channels/weixin/login/start",
				"GET  /api/channels/weixin/login/:sessionKey",
				"POST /api/channels/feishu/setup/start",
				"GET  /api/channels/feishu/setup/:sessionKey",
				"GET  /api/config",
				"GET  /api/agents",
				"POST /api/agents",
				"PATCH /api/agents/:id",
				"DELETE /api/agents/:id",
				"GET/PUT/DELETE /api/agents/:id/avatar",
				"GET/PUT /api/agents/:id/files/...",
				"DELETE /api/providers/:providerId/key",
				"PATCH /api/config",
				"POST /api/config/reload",
				"POST /api/heartbeat/trigger",
				"...  /api/cron/*",
				"GET/PATCH /api/sessions/:key/agent-config",
				"...  /api/sessions/*",
				"GET  /api/host/fs/meta",
				"GET  /api/host/fs/list"
			]
		});
	});
	app.get("/assets/*", (c) => {
		const response = serveStaticFile(`assets/${c.req.path.replace("/assets/", "")}`, c.req.raw);
		if (response) return response;
		return c.text("Not found", 404);
	});
	/** From `web/public/channel-icons/` (Vite copies to static root). Public: img requests send no Bearer token. */
	app.get("/channel-icons/*", (c) => {
		const response = serveStaticFile(`channel-icons/${c.req.path.replace("/channel-icons/", "")}`, c.req.raw);
		if (response) return response;
		return c.text("Not found", 404);
	});
	app.get("/favicon.ico", (c) => {
		const response = serveStaticFile("favicon.ico", c.req.raw);
		if (response) return response;
		const fallback = serveStaticFile("logo.svg", c.req.raw);
		if (fallback) return fallback;
		return c.text("Not found", 404);
	});
	app.get("/logo.svg", (c) => {
		const response = serveStaticFile("logo.svg", c.req.raw);
		if (response) return response;
		return c.text("Not found", 404);
	});
	app.get("/logo-dark.svg", (c) => {
		const response = serveStaticFile("logo-dark.svg", c.req.raw);
		if (response) return response;
		return c.text("Not found", 404);
	});
	app.get("/", (c) => {
		const response = serveStaticFile("index.html", c.req.raw);
		if (response) return response;
		return c.text("UI not found", 404);
	});
}
//#endregion
export { registerPublicGatewayRoutes };

//# sourceMappingURL=public-gateway.js.map