import { d as getRequestId, r as requireAdmin, e as errorResponse } from './helpers-kzwksNq1.js';
import { o as opencodeFetch } from './http-D8YVIqJa.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';
import './endpoints-UdQGgKsR.js';
import './state-fxN45gBp.js';

//#region src/routes/admin/providers/oauth/[providerId]/callback/+server.ts
var POST = async (event) => {
	const requestId = getRequestId(event);
	const authError = requireAdmin(event, requestId);
	if (authError) return authError;
	const { providerId } = event.params;
	if (!providerId) return errorResponse(400, "missing_provider", "Provider ID is required.", {}, requestId);
	try {
		const body = await event.request.text();
		await opencodeFetch(`/provider/${encodeURIComponent(providerId)}/oauth/callback`, {
			method: "POST",
			body
		});
		return new Response(JSON.stringify({ ok: true }), {
			status: 200,
			headers: {
				"cache-control": "no-store",
				"content-type": "application/json",
				...requestId ? { "x-request-id": requestId } : {}
			}
		});
	} catch (error) {
		return errorResponse(502, "oauth_callback_failed", error instanceof Error ? error.message : "OAuth callback failed", {}, requestId);
	}
};

export { POST };
//# sourceMappingURL=_server.ts-CV4ZTrHb.js.map
