"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSettings = getSettings;
const telemetry_1 = require("../lib/telemetry");
const events_1 = require("../lib/events");
const nats_1 = require("../lib/events/nats");
const socketio_1 = require("../lib/events/socketio");
const defaults_1 = require("../modules/defaults");
const llm_1 = require("../services/llm");
/**
 * Return platform settings for the current deployment.
 *
 * Includes telemetry configuration (trace URL), escalation claim duration
 * options, and event transport details (socket.io, NATS, or none).
 *
 * @returns `{ status: 200, data: { telemetry, escalation, events } }`
 */
async function getSettings() {
    try {
        const hasSocketIO = !!events_1.eventRegistry.getAdapter(socketio_1.SocketIOEventAdapter);
        const hasNats = !!events_1.eventRegistry.getAdapter(nats_1.NatsEventAdapter);
        // Dashboard transport: Socket.IO is the default (works in-process, zero config).
        // NATS is only reported when explicitly opted in via EVENT_TRANSPORT=nats,
        // which a multi-container deployment sets when it wants the dashboard to
        // connect via NATS instead of Socket.IO.
        const forceNats = process.env.EVENT_TRANSPORT === 'nats';
        const transport = forceNats && hasNats ? 'nats' : hasSocketIO ? 'socketio' : hasNats ? 'nats' : 'none';
        return {
            status: 200,
            data: {
                telemetry: {
                    traceUrl: telemetry_1.telemetryRegistry.traceUrl ?? null,
                },
                escalation: {
                    claimDurations: defaults_1.CLAIM_DURATION_OPTIONS,
                },
                events: {
                    transport,
                    natsWsUrl: hasNats
                        ? (process.env.VITE_NATS_WS_URL || process.env.NATS_WS_URL || null)
                        : null,
                },
                ai: {
                    enabled: (0, llm_1.hasLLMApiKey)(),
                },
            },
        };
    }
    catch (err) {
        return { status: 500, error: err.message };
    }
}
