"use strict";
/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConversationEvents$inboundSchema = exports.ConversationEventsData$inboundSchema = void 0;
exports.conversationEventsDataFromJSON = conversationEventsDataFromJSON;
exports.conversationEventsFromJSON = conversationEventsFromJSON;
const z = __importStar(require("zod/v3"));
const schemas_js_1 = require("../../lib/schemas.js");
const agenthandoffdoneevent_js_1 = require("./agenthandoffdoneevent.js");
const agenthandoffstartedevent_js_1 = require("./agenthandoffstartedevent.js");
const functioncallevent_js_1 = require("./functioncallevent.js");
const messageoutputevent_js_1 = require("./messageoutputevent.js");
const responsedoneevent_js_1 = require("./responsedoneevent.js");
const responseerrorevent_js_1 = require("./responseerrorevent.js");
const responsestartedevent_js_1 = require("./responsestartedevent.js");
const ssetypes_js_1 = require("./ssetypes.js");
const toolexecutiondeltaevent_js_1 = require("./toolexecutiondeltaevent.js");
const toolexecutiondoneevent_js_1 = require("./toolexecutiondoneevent.js");
const toolexecutionstartedevent_js_1 = require("./toolexecutionstartedevent.js");
/** @internal */
exports.ConversationEventsData$inboundSchema = z.union([
    agenthandoffdoneevent_js_1.AgentHandoffDoneEvent$inboundSchema.and(z.object({ type: z.literal("agent.handoff.done") })),
    agenthandoffstartedevent_js_1.AgentHandoffStartedEvent$inboundSchema.and(z.object({ type: z.literal("agent.handoff.started") })),
    responsedoneevent_js_1.ResponseDoneEvent$inboundSchema.and(z.object({ type: z.literal("conversation.response.done") })),
    responseerrorevent_js_1.ResponseErrorEvent$inboundSchema.and(z.object({ type: z.literal("conversation.response.error") })),
    responsestartedevent_js_1.ResponseStartedEvent$inboundSchema.and(z.object({ type: z.literal("conversation.response.started") })),
    functioncallevent_js_1.FunctionCallEvent$inboundSchema.and(z.object({ type: z.literal("function.call.delta") })),
    messageoutputevent_js_1.MessageOutputEvent$inboundSchema.and(z.object({ type: z.literal("message.output.delta") })),
    toolexecutiondeltaevent_js_1.ToolExecutionDeltaEvent$inboundSchema.and(z.object({ type: z.literal("tool.execution.delta") })),
    toolexecutiondoneevent_js_1.ToolExecutionDoneEvent$inboundSchema.and(z.object({ type: z.literal("tool.execution.done") })),
    toolexecutionstartedevent_js_1.ToolExecutionStartedEvent$inboundSchema.and(z.object({ type: z.literal("tool.execution.started") })),
]);
function conversationEventsDataFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.ConversationEventsData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ConversationEventsData' from JSON`);
}
/** @internal */
exports.ConversationEvents$inboundSchema = z.object({
    event: ssetypes_js_1.SSETypes$inboundSchema,
    data: z.string().transform((v, ctx) => {
        try {
            return JSON.parse(v);
        }
        catch (err) {
            ctx.addIssue({ code: "custom", message: `malformed json: ${err}` });
            return z.NEVER;
        }
    }).pipe(z.union([
        agenthandoffdoneevent_js_1.AgentHandoffDoneEvent$inboundSchema.and(z.object({ type: z.literal("agent.handoff.done") })),
        agenthandoffstartedevent_js_1.AgentHandoffStartedEvent$inboundSchema.and(z.object({ type: z.literal("agent.handoff.started") })),
        responsedoneevent_js_1.ResponseDoneEvent$inboundSchema.and(z.object({ type: z.literal("conversation.response.done") })),
        responseerrorevent_js_1.ResponseErrorEvent$inboundSchema.and(z.object({ type: z.literal("conversation.response.error") })),
        responsestartedevent_js_1.ResponseStartedEvent$inboundSchema.and(z.object({ type: z.literal("conversation.response.started") })),
        functioncallevent_js_1.FunctionCallEvent$inboundSchema.and(z.object({ type: z.literal("function.call.delta") })),
        messageoutputevent_js_1.MessageOutputEvent$inboundSchema.and(z.object({ type: z.literal("message.output.delta") })),
        toolexecutiondeltaevent_js_1.ToolExecutionDeltaEvent$inboundSchema.and(z.object({ type: z.literal("tool.execution.delta") })),
        toolexecutiondoneevent_js_1.ToolExecutionDoneEvent$inboundSchema.and(z.object({ type: z.literal("tool.execution.done") })),
        toolexecutionstartedevent_js_1.ToolExecutionStartedEvent$inboundSchema.and(z.object({ type: z.literal("tool.execution.started") })),
    ])),
});
function conversationEventsFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.ConversationEvents$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ConversationEvents' from JSON`);
}
//# sourceMappingURL=conversationevents.js.map