/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 3b81da54d1b2
 */

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  ToolConfiguration,
  ToolConfiguration$inboundSchema,
  ToolConfiguration$Outbound,
  ToolConfiguration$outboundSchema,
} from "./toolconfiguration.js";

export type WebSearchTool = {
  toolConfiguration?: ToolConfiguration | null | undefined;
  type: "web_search";
};

/** @internal */
export const WebSearchTool$inboundSchema: z.ZodType<WebSearchTool, unknown> = z
  .object({
    tool_configuration: z.nullable(ToolConfiguration$inboundSchema).optional(),
    type: z.literal("web_search"),
  }).transform((v) => {
    return remap$(v, {
      "tool_configuration": "toolConfiguration",
    });
  });
/** @internal */
export type WebSearchTool$Outbound = {
  tool_configuration?: ToolConfiguration$Outbound | null | undefined;
  type: "web_search";
};

/** @internal */
export const WebSearchTool$outboundSchema: z.ZodType<
  WebSearchTool$Outbound,
  WebSearchTool
> = z.object({
  toolConfiguration: z.nullable(ToolConfiguration$outboundSchema).optional(),
  type: z.literal("web_search"),
}).transform((v) => {
  return remap$(v, {
    toolConfiguration: "tool_configuration",
  });
});

export function webSearchToolToJSON(webSearchTool: WebSearchTool): string {
  return JSON.stringify(WebSearchTool$outboundSchema.parse(webSearchTool));
}
export function webSearchToolFromJSON(
  jsonString: string,
): SafeParseResult<WebSearchTool, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => WebSearchTool$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'WebSearchTool' from JSON`,
  );
}
