/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
import * as z from "zod/v3";
import { remap as remap$ } from "../../lib/primitives.js";
import { collectExtraKeys as collectExtraKeys$, safeParse, } from "../../lib/schemas.js";
import { OpenAIContentItem$inboundSchema, OpenAIContentItem$outboundSchema, } from "./openaicontentitem.js";
import { OpenAIToolCall$inboundSchema, OpenAIToolCall$outboundSchema, } from "./openaitoolcall.js";
export const OpenAIExtendedMessageType = {
    Openai: "openai",
};
export const Role = {
    System: "system",
    User: "user",
    Assistant: "assistant",
};
export const One = {
    Documentation: "documentation",
    Site: "site",
    DiscoursePost: "discourse_post",
    GithubIssue: "github_issue",
    GithubDiscussion: "github_discussion",
    StackoverflowQuestion: "stackoverflow_question",
    DiscordForumPost: "discord_forum_post",
    DiscordMessage: "discord_message",
    CustomQuestionAnswer: "custom_question_answer",
};
/** @internal */
export const OpenAIExtendedMessageType$inboundSchema = z.nativeEnum(OpenAIExtendedMessageType);
/** @internal */
export const OpenAIExtendedMessageType$outboundSchema = OpenAIExtendedMessageType$inboundSchema;
/** @internal */
export const Role$inboundSchema = z.nativeEnum(Role);
/** @internal */
export const Role$outboundSchema = Role$inboundSchema;
/** @internal */
export const Content$inboundSchema = z.union([z.string(), z.array(OpenAIContentItem$inboundSchema)]);
/** @internal */
export const Content$outboundSchema = z.union([z.string(), z.array(OpenAIContentItem$outboundSchema)]);
export function contentToJSON(content) {
    return JSON.stringify(Content$outboundSchema.parse(content));
}
export function contentFromJSON(jsonString) {
    return safeParse(jsonString, (x) => Content$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Content' from JSON`);
}
/** @internal */
export const One$inboundSchema = z.nativeEnum(One);
/** @internal */
export const One$outboundSchema = One$inboundSchema;
/** @internal */
export const OpenAIExtendedMessageLinksType$inboundSchema = z.union([One$inboundSchema, z.string()]);
/** @internal */
export const OpenAIExtendedMessageLinksType$outboundSchema = z.union([One$outboundSchema, z.string()]);
export function openAIExtendedMessageLinksTypeToJSON(openAIExtendedMessageLinksType) {
    return JSON.stringify(OpenAIExtendedMessageLinksType$outboundSchema.parse(openAIExtendedMessageLinksType));
}
export function openAIExtendedMessageLinksTypeFromJSON(jsonString) {
    return safeParse(jsonString, (x) => OpenAIExtendedMessageLinksType$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OpenAIExtendedMessageLinksType' from JSON`);
}
/** @internal */
export const Links$inboundSchema = z
    .object({
    label: z.nullable(z.string()).optional(),
    url: z.string(),
    title: z.nullable(z.string()).optional(),
    description: z.nullable(z.string()).optional(),
    type: z.nullable(z.union([One$inboundSchema, z.string()])).optional(),
    breadcrumbs: z.nullable(z.array(z.string())).optional(),
});
/** @internal */
export const Links$outboundSchema = z.object({
    label: z.nullable(z.string()).optional(),
    url: z.string(),
    title: z.nullable(z.string()).optional(),
    description: z.nullable(z.string()).optional(),
    type: z.nullable(z.union([One$outboundSchema, z.string()])).optional(),
    breadcrumbs: z.nullable(z.array(z.string())).optional(),
});
export function linksToJSON(links) {
    return JSON.stringify(Links$outboundSchema.parse(links));
}
export function linksFromJSON(jsonString) {
    return safeParse(jsonString, (x) => Links$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Links' from JSON`);
}
/** @internal */
export const OpenAIExtendedMessageId$inboundSchema = z.union([z.string(), z.number()]);
/** @internal */
export const OpenAIExtendedMessageId$outboundSchema = z.union([z.string(), z.number()]);
export function openAIExtendedMessageIdToJSON(openAIExtendedMessageId) {
    return JSON.stringify(OpenAIExtendedMessageId$outboundSchema.parse(openAIExtendedMessageId));
}
export function openAIExtendedMessageIdFromJSON(jsonString) {
    return safeParse(jsonString, (x) => OpenAIExtendedMessageId$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OpenAIExtendedMessageId' from JSON`);
}
/** @internal */
export const OpenAIExtendedMessageUserId$inboundSchema = z.union([z.string(), z.number()]);
/** @internal */
export const OpenAIExtendedMessageUserId$outboundSchema = z.union([z.string(), z.number()]);
export function openAIExtendedMessageUserIdToJSON(openAIExtendedMessageUserId) {
    return JSON.stringify(OpenAIExtendedMessageUserId$outboundSchema.parse(openAIExtendedMessageUserId));
}
export function openAIExtendedMessageUserIdFromJSON(jsonString) {
    return safeParse(jsonString, (x) => OpenAIExtendedMessageUserId$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OpenAIExtendedMessageUserId' from JSON`);
}
/** @internal */
export const OpenAIExtendedMessageUserProperties$inboundSchema = collectExtraKeys$(z.object({
    id: z.nullable(z.union([z.string(), z.number()])).optional(),
    identificationType: z.nullable(z.string()).optional(),
    userId: z.nullable(z.union([z.string(), z.number()])).optional(),
    supportAgentName: z.nullable(z.string()).optional(),
    userType: z.nullable(z.string()).optional(),
}).catchall(z.any()), "additionalProperties", true);
/** @internal */
export const OpenAIExtendedMessageUserProperties$outboundSchema = z.object({
    id: z.nullable(z.union([z.string(), z.number()])).optional(),
    identificationType: z.nullable(z.string()).optional(),
    userId: z.nullable(z.union([z.string(), z.number()])).optional(),
    supportAgentName: z.nullable(z.string()).optional(),
    userType: z.nullable(z.string()).optional(),
    additionalProperties: z.record(z.any()).optional(),
}).transform((v) => {
    return {
        ...v.additionalProperties,
        ...remap$(v, {
            additionalProperties: null,
        }),
    };
});
export function openAIExtendedMessageUserPropertiesToJSON(openAIExtendedMessageUserProperties) {
    return JSON.stringify(OpenAIExtendedMessageUserProperties$outboundSchema.parse(openAIExtendedMessageUserProperties));
}
export function openAIExtendedMessageUserPropertiesFromJSON(jsonString) {
    return safeParse(jsonString, (x) => OpenAIExtendedMessageUserProperties$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OpenAIExtendedMessageUserProperties' from JSON`);
}
/** @internal */
export const OpenAIExtendedMessage$inboundSchema = z.object({
    id: z.string(),
    type: OpenAIExtendedMessageType$inboundSchema,
    externalId: z.nullable(z.string()),
    externalUrl: z.nullable(z.string()),
    conversationId: z.string(),
    createdAt: z.string(),
    updatedAt: z.string(),
    role: Role$inboundSchema,
    content: z.union([z.string(), z.array(OpenAIContentItem$inboundSchema)]),
    name: z.nullable(z.string()).optional(),
    links: z.nullable(z.array(z.lazy(() => Links$inboundSchema))).optional(),
    properties: z.nullable(z.record(z.any())).optional(),
    userProperties: z.nullable(z.lazy(() => OpenAIExtendedMessageUserProperties$inboundSchema)).optional(),
    tool_calls: z.nullable(z.array(OpenAIToolCall$inboundSchema)).optional(),
}).transform((v) => {
    return remap$(v, {
        "tool_calls": "toolCalls",
    });
});
/** @internal */
export const OpenAIExtendedMessage$outboundSchema = z.object({
    id: z.string(),
    type: OpenAIExtendedMessageType$outboundSchema,
    externalId: z.nullable(z.string()),
    externalUrl: z.nullable(z.string()),
    conversationId: z.string(),
    createdAt: z.string(),
    updatedAt: z.string(),
    role: Role$outboundSchema,
    content: z.union([z.string(), z.array(OpenAIContentItem$outboundSchema)]),
    name: z.nullable(z.string()).optional(),
    links: z.nullable(z.array(z.lazy(() => Links$outboundSchema))).optional(),
    properties: z.nullable(z.record(z.any())).optional(),
    userProperties: z.nullable(z.lazy(() => OpenAIExtendedMessageUserProperties$outboundSchema)).optional(),
    toolCalls: z.nullable(z.array(OpenAIToolCall$outboundSchema)).optional(),
}).transform((v) => {
    return remap$(v, {
        toolCalls: "tool_calls",
    });
});
export function openAIExtendedMessageToJSON(openAIExtendedMessage) {
    return JSON.stringify(OpenAIExtendedMessage$outboundSchema.parse(openAIExtendedMessage));
}
export function openAIExtendedMessageFromJSON(jsonString) {
    return safeParse(jsonString, (x) => OpenAIExtendedMessage$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OpenAIExtendedMessage' from JSON`);
}
//# sourceMappingURL=openaiextendedmessage.js.map