import { b as private_env } from './shared-server-DaWdgxVh.js';
import { v as validateAuth } from './auth-DuunT7Cg.js';
import { t as toErrorMessage } from './error-DDXB3duW.js';
import { j as json } from './index-CoD1IJuy.js';
import QRCode from 'qrcode';
import 'crypto';

const GET = async ({ request, url }) => {
  const authError = validateAuth(request);
  if (authError) {
    return authError;
  }
  const apiKey = private_env.API_KEY?.trim();
  if (!apiKey) {
    return json({ error: "API_KEY not configured on server" }, { status: 500 });
  }
  const serverUrl = private_env.ORIGIN?.trim() || url.origin;
  const configPayload = JSON.stringify({ apiKey, serverUrl });
  try {
    const dataUrl = await QRCode.toDataURL(configPayload, {
      color: {
        dark: "#ededed",
        light: "#0a0a0a"
      },
      errorCorrectionLevel: "M",
      margin: 2,
      type: "image/png",
      width: 280
    });
    return json({ dataUrl, serverUrl });
  } catch (error) {
    console.error("[qr-config] QR generation failed:", toErrorMessage(error));
    return json({ error: "Failed to generate QR code" }, { status: 500 });
  }
};

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