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

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

/**
 * Confidence score for a token or word in OCR output.
 */
export type OCRConfidenceScore = {
  /**
   * The word or text segment
   */
  text: string;
  /**
   * Confidence score (0-1)
   */
  confidence: number;
  /**
   * Start index of the text in the page markdown string
   */
  startIndex: number;
};

/** @internal */
export const OCRConfidenceScore$inboundSchema: z.ZodType<
  OCRConfidenceScore,
  unknown
> = z.object({
  text: z.string(),
  confidence: z.number(),
  start_index: z.int(),
}).transform((v) => {
  return remap$(v, {
    "start_index": "startIndex",
  });
});

export function ocrConfidenceScoreFromJSON(
  jsonString: string,
): SafeParseResult<OCRConfidenceScore, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => OCRConfidenceScore$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'OCRConfidenceScore' from JSON`,
  );
}
