import { v as validateAuth } from './auth-DuunT7Cg.js';
import { s as sosCoordinator } from './coordinator-DMU_ADXf.js';
import { j as json } from './index-lhTMmBNn.js';
import './shared-server-DaWdgxVh.js';
import 'crypto';
import 'better-sqlite3';
import 'fs';
import 'os';
import 'path';

const GET = ({ params, request }) => {
  const authError = validateAuth(request);
  if (authError) {
    return authError;
  }
  const session = sosCoordinator.getSuperSession(params.id ?? "");
  if (!session) {
    return json({ error: "Super-session not found" }, { status: 404 });
  }
  return json(session);
};
const PATCH = async ({ params, request }) => {
  const authError = validateAuth(request);
  if (authError) {
    return authError;
  }
  let body;
  try {
    body = await request.json();
  } catch {
    return json({ error: "Invalid JSON in request body" }, { status: 400 });
  }
  if (typeof body !== "object" || body === null) {
    return json({ error: "Invalid JSON in request body" }, { status: 400 });
  }
  const payload = body;
  if (payload.status !== "active" && payload.status !== "paused" && payload.status !== "archived") {
    return json({ error: "status must be active | paused | archived" }, { status: 400 });
  }
  if (!sosCoordinator.setStatus(params.id ?? "", payload.status)) {
    return json({ error: "Super-session not found" }, { status: 404 });
  }
  return json({ id: params.id, status: payload.status });
};
const DELETE = ({ params, request }) => {
  const authError = validateAuth(request);
  if (authError) {
    return authError;
  }
  if (!sosCoordinator.deleteSuperSession(params.id ?? "")) {
    return json({ error: "Super-session not found" }, { status: 404 });
  }
  return json({ deleted: true });
};

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