import { p as checkDocker, aa as getDockerEvents } from './src-CidJbygh.js';
import { d as getRequestId, r as requireAdmin, e as errorResponse, k as jsonResponse } from './helpers-kzwksNq1.js';
import './chunk-CLZ62Ad-.js';
import 'node:module';
import './provider-constants-DPrj3yBX.js';
import './dist-DOFcG0Zp.js';
import 'node:fs';
import 'node:path';
import 'buffer';
import 'fs';
import 'path';
import 'node:child_process';
import 'node:url';
import 'node:crypto';
import 'events';
import 'node:events';
import 'node:stream';
import 'node:string_decoder';
import 'assert';
import 'zlib';
import 'node:assert';
import 'node:fs/promises';
import 'node:os';
import './endpoints-UdQGgKsR.js';
import './state-fxN45gBp.js';

//#region src/routes/admin/containers/events/+server.ts
var GET = async (event) => {
	const requestId = getRequestId(event);
	const authError = requireAdmin(event, requestId);
	if (authError) return authError;
	const since = event.url.searchParams.get("since") || "1h";
	if (!(await checkDocker()).ok) return errorResponse(503, "docker_unavailable", "Docker is not available", {}, requestId);
	const result = await getDockerEvents("openpalm", since);
	if (!result.ok) return errorResponse(500, "docker_error", `Failed to get Docker events: ${result.stderr}`, {}, requestId);
	let events = [];
	if (result.stdout.trim()) try {
		events = result.stdout.trim().split("\n").filter((l) => l.startsWith("{")).map((l) => JSON.parse(l));
	} catch (e) {
		console.warn("[containers.events] Failed to parse Docker events output", e);
		return errorResponse(500, "parse_error", "Failed to parse Docker events output", {}, requestId);
	}
	return jsonResponse(200, { events }, requestId);
};

export { GET };
//# sourceMappingURL=_server.ts-D2qIIqBN.js.map
