"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.initiateAdvancedOutboundCallController = void 0;
const logger_1 = __importDefault(require("../../../logger"));
const phone_util_1 = require("../../../providers/phone/phone-util");
const initiateAdvancedOutboundCallController = async (req, res) => {
    try {
        const { to, steps, systemPrompt, overallDelay, totalCallLength, aiSpeaksFirst } = req.body;
        // Validate required fields
        if (!to) {
            res.status(400).json({
                success: false,
                error: 'Missing "to" parameter. Please provide a phone number to call.',
            });
            return;
        }
        if (!steps || !Array.isArray(steps) || steps.length === 0) {
            res.status(400).json({
                success: false,
                error: 'Missing or invalid "steps" parameter. Steps must be a non-empty array.',
            });
            return;
        }
        // Call the initiateAdvancedOutboundCall function
        const result = await (0, phone_util_1.initiateAdvancedOutboundCall)({
            to,
            steps,
            systemPrompt,
            overallDelay,
            totalCallLength,
            aiSpeaksFirst,
        });
        logger_1.default.info(`Advanced outbound call initiated: ${result.callSid} to ${to}`);
        res.status(200).json(result);
    }
    catch (error) {
        logger_1.default.error(`Error initiating advanced outbound call: ${error.message}`);
        res.status(500).json({
            success: false,
            error: error.message || 'Failed to initiate advanced outbound call',
        });
    }
};
exports.initiateAdvancedOutboundCallController = initiateAdvancedOutboundCallController;
//# sourceMappingURL=initiate-advanced-outbound-call.js.map