import { g as getActiveEndpoint } from './endpoints-UdQGgKsR.js';
import { d as getRequestId, r as requireAdmin, k as jsonResponse } from './helpers-kzwksNq1.js';
import './state-fxN45gBp.js';
import './src-CidJbygh.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';

//#region src/routes/admin/health/+server.ts
var GET = async (event) => {
	const requestId = getRequestId(event);
	const authError = requireAdmin(event, requestId);
	if (authError) return authError;
	const endpoint = getActiveEndpoint();
	let opencode = false;
	try {
		const headers = {};
		if (endpoint.password) {
			const user = endpoint.username || "openpalm";
			headers["authorization"] = `Basic ${btoa(`${user}:${endpoint.password}`)}`;
		}
		opencode = (await fetch(`${endpoint.url}/health`, {
			headers,
			signal: AbortSignal.timeout(2e3)
		})).ok;
	} catch {}
	return jsonResponse(200, {
		ok: true,
		opencode,
		endpoint: {
			id: endpoint.id,
			label: endpoint.label,
			url: endpoint.url,
			isDefault: endpoint.isDefault
		}
	}, requestId);
};

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