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

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";

export type TranscriptionSegmentChunk = {
  type?: "transcription_segment" | undefined;
  text: string;
  start: number;
  end: number;
  score?: number | null | undefined;
  speakerId?: string | null | undefined;
  [additionalProperties: string]: unknown;
};

/** @internal */
export const TranscriptionSegmentChunk$inboundSchema: z.ZodType<
  TranscriptionSegmentChunk,
  unknown
> = z.object({
  type: z.literal("transcription_segment").default("transcription_segment"),
  text: z.string(),
  start: z.number(),
  end: z.number(),
  score: z.nullable(z.number()).optional(),
  speaker_id: z.nullable(z.string()).optional(),
}).catchall(z.any()).transform((v) => {
  return remap$(v, {
    "speaker_id": "speakerId",
  });
});
/** @internal */
export type TranscriptionSegmentChunk$Outbound = {
  type: "transcription_segment";
  text: string;
  start: number;
  end: number;
  score?: number | null | undefined;
  speaker_id?: string | null | undefined;
  [additionalProperties: string]: unknown;
};

/** @internal */
export const TranscriptionSegmentChunk$outboundSchema: z.ZodType<
  TranscriptionSegmentChunk$Outbound,
  TranscriptionSegmentChunk
> = z.object({
  type: z.literal("transcription_segment").default(
    "transcription_segment" as const,
  ),
  text: z.string(),
  start: z.number(),
  end: z.number(),
  score: z.nullable(z.number()).optional(),
  speakerId: z.nullable(z.string()).optional(),
}).catchall(z.any()).transform((v) => {
  return {
    ...remap$(v, {
      speakerId: "speaker_id",
    }),
  };
});

export function transcriptionSegmentChunkToJSON(
  transcriptionSegmentChunk: TranscriptionSegmentChunk,
): string {
  return JSON.stringify(
    TranscriptionSegmentChunk$outboundSchema.parse(transcriptionSegmentChunk),
  );
}
export function transcriptionSegmentChunkFromJSON(
  jsonString: string,
): SafeParseResult<TranscriptionSegmentChunk, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => TranscriptionSegmentChunk$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'TranscriptionSegmentChunk' from JSON`,
  );
}
