import { U as disableHostAkmSharing, ab as getHostAkmSharingStatus, W as enableHostAkmSharing } from './src-CidJbygh.js';
import { g as getState } from './state-fxN45gBp.js';
import { d as getRequestId, r as requireAdmin, k as jsonResponse, p as parseJsonBody, j as jsonBodyError, e as errorResponse } 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';

//#region src/routes/admin/akm/host-sharing/+server.ts
var GET = async (event) => {
	const requestId = getRequestId(event);
	const authError = requireAdmin(event, requestId);
	if (authError) return authError;
	return jsonResponse(200, { sharing: getHostAkmSharingStatus(getState()) }, requestId);
};
var PUT = async (event) => {
	const requestId = getRequestId(event);
	const authError = requireAdmin(event, requestId);
	if (authError) return authError;
	const result = await parseJsonBody(event.request);
	if ("error" in result) return jsonBodyError(result, requestId);
	const opts = result.data;
	const writable = opts.writable === void 0 ? true : opts.writable === true;
	const importProfiles = opts.importProfiles === true;
	const state = getState();
	try {
		const { profilesImported } = enableHostAkmSharing(state, {
			writable,
			importProfiles
		});
		return jsonResponse(200, {
			sharing: getHostAkmSharingStatus(state),
			profilesImported
		}, requestId);
	} catch (err) {
		return errorResponse(409, "conflict", err.message, {}, requestId);
	}
};
var DELETE = async (event) => {
	const requestId = getRequestId(event);
	const authError = requireAdmin(event, requestId);
	if (authError) return authError;
	const state = getState();
	disableHostAkmSharing(state);
	return jsonResponse(200, { sharing: getHostAkmSharingStatus(state) }, requestId);
};

export { DELETE, GET, PUT };
//# sourceMappingURL=_server.ts-D264FNyX.js.map
