# This file is auto-generated by alef — DO NOT EDIT.
# alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
# To regenerate: alef generate
# To verify freshness: alef verify --exit-code
# Issues & docs: https://github.com/kreuzberg-dev/alef
defmodule Kreuzberg do
  @moduledoc "High-level API for kreuzberg"

  @doc "Extract content from a byte array."
  @spec extract_bytes_async(binary(), String.t()) :: {:ok, map()} | {:error, atom, String.t()}
  def extract_bytes_async(content, mime_type) do
    Kreuzberg.Native.extract_bytes_async(content, mime_type, nil)
  end

  @doc "Extract content from a byte array."
  @spec extract_bytes_async(binary(), String.t(), String.t() | nil) ::
          {:ok, map()} | {:error, atom, String.t()}
  def extract_bytes_async(content, mime_type, config) do
    Kreuzberg.Native.extract_bytes_async(content, mime_type, config)
  end

  @doc "Extract content from a file."
  @spec extract_file_async(String.t(), keyword()) :: {:ok, map()} | {:error, atom, String.t()}
  def extract_file_async(path, opts \\ []) do
    Kreuzberg.Native.extract_file_async(
      path,
      Keyword.get(opts, :mime_type),
      Keyword.get(opts, :config)
    )
  end

  @doc "Synchronous wrapper for `extract_file`."
  @spec extract_file_sync(String.t(), keyword()) :: {:ok, map()} | {:error, atom, String.t()}
  def extract_file_sync(path, opts \\ []) do
    Kreuzberg.Native.extract_file_sync(
      path,
      Keyword.get(opts, :mime_type),
      Keyword.get(opts, :config)
    )
  end

  @doc "Synchronous wrapper for `extract_bytes`."
  @spec extract_bytes_sync(binary(), String.t()) :: {:ok, map()} | {:error, atom, String.t()}
  def extract_bytes_sync(content, mime_type) do
    Kreuzberg.Native.extract_bytes_sync(content, mime_type, nil)
  end

  @doc "Synchronous wrapper for `extract_bytes`."
  @spec extract_bytes_sync(binary(), String.t(), String.t() | nil) ::
          {:ok, map()} | {:error, atom, String.t()}
  def extract_bytes_sync(content, mime_type, config) do
    Kreuzberg.Native.extract_bytes_sync(content, mime_type, config)
  end

  @doc "Detect MIME type from raw file bytes."
  @spec detect_mime_type_from_bytes(binary()) :: {:ok, String.t()} | {:error, atom, String.t()}
  def detect_mime_type_from_bytes(content) do
    Kreuzberg.Native.detect_mime_type_from_bytes(content)
  end

  @doc "Get file extensions for a given MIME type."
  @spec get_extensions_for_mime(String.t()) :: {:ok, [String.t()]} | {:error, atom, String.t()}
  def get_extensions_for_mime(mime_type) do
    Kreuzberg.Native.get_extensions_for_mime(mime_type)
  end

  @doc "Clear all embedding backends from the global registry."
  @spec clear_embedding_backends() :: {:ok, nil} | {:error, atom, String.t()}
  def clear_embedding_backends do
    Kreuzberg.Native.clear_embedding_backends()
  end

  @doc "List the names of all registered embedding backends."
  @spec list_embedding_backends() :: {:ok, [String.t()]} | {:error, atom, String.t()}
  def list_embedding_backends do
    Kreuzberg.Native.list_embedding_backends()
  end

  @doc "List names of all registered document extractors."
  @spec list_document_extractors() :: {:ok, [String.t()]} | {:error, atom, String.t()}
  def list_document_extractors do
    Kreuzberg.Native.list_document_extractors()
  end

  @doc "Clear all document extractors from the global registry."
  @spec clear_document_extractors() :: {:ok, nil} | {:error, atom, String.t()}
  def clear_document_extractors do
    Kreuzberg.Native.clear_document_extractors()
  end

  @doc "List all registered OCR backends."
  @spec list_ocr_backends() :: {:ok, [String.t()]} | {:error, atom, String.t()}
  def list_ocr_backends do
    Kreuzberg.Native.list_ocr_backends()
  end

  @doc "Clear all OCR backends from the global registry."
  @spec clear_ocr_backends() :: {:ok, nil} | {:error, atom, String.t()}
  def clear_ocr_backends do
    Kreuzberg.Native.clear_ocr_backends()
  end

  @doc "List all registered post-processor names."
  @spec list_post_processors() :: {:ok, [String.t()]} | {:error, atom, String.t()}
  def list_post_processors do
    Kreuzberg.Native.list_post_processors()
  end

  @doc "Remove all registered post-processors."
  @spec clear_post_processors() :: {:ok, nil} | {:error, atom, String.t()}
  def clear_post_processors do
    Kreuzberg.Native.clear_post_processors()
  end

  @doc "List names of all registered renderers."
  @spec list_renderers() :: {:ok, [String.t()]} | {:error, atom, String.t()}
  def list_renderers do
    Kreuzberg.Native.list_renderers()
  end

  @doc "Clear all renderers from the global registry."
  @spec clear_renderers() :: {:ok, nil} | {:error, atom, String.t()}
  def clear_renderers do
    Kreuzberg.Native.clear_renderers()
  end

  @doc "List names of all registered validators."
  @spec list_validators() :: {:ok, [String.t()]} | {:error, atom, String.t()}
  def list_validators do
    Kreuzberg.Native.list_validators()
  end

  @doc "Remove all registered validators."
  @spec clear_validators() :: {:ok, nil} | {:error, atom, String.t()}
  def clear_validators do
    Kreuzberg.Native.clear_validators()
  end

  @doc "Compare two extraction results and return a structured diff."
  @spec compare(keyword()) :: map()
  def compare(opts \\ []) do
    Kreuzberg.Native.compare(
      Keyword.get(opts, :a),
      Keyword.get(opts, :b),
      Keyword.get(opts, :opts)
    )
  end

  @doc "Generate embeddings asynchronously for a list of text strings."
  @spec embed_texts_async([String.t()]) :: {:ok, [[float()]]} | {:error, atom, String.t()}
  def embed_texts_async(texts) do
    Kreuzberg.Native.embed_texts_async(texts, nil)
  end

  @doc "Generate embeddings asynchronously for a list of text strings."
  @spec embed_texts_async([String.t()], String.t() | nil) ::
          {:ok, [[float()]]} | {:error, atom, String.t()}
  def embed_texts_async(texts, config) do
    Kreuzberg.Native.embed_texts_async(texts, config)
  end

  @doc "Render a single PDF page to PNG bytes."
  @spec render_pdf_page_to_png(binary(), non_neg_integer(), keyword()) ::
          {:ok, binary()} | {:error, atom, String.t()}
  def render_pdf_page_to_png(pdf_bytes, page_index, opts \\ []) do
    Kreuzberg.Native.render_pdf_page_to_png(
      pdf_bytes,
      page_index,
      Keyword.get(opts, :dpi),
      Keyword.get(opts, :password)
    )
  end

  @doc "Detect the MIME type of a file at the given path."
  @spec detect_mime_type(String.t(), boolean()) :: {:ok, String.t()} | {:error, atom, String.t()}
  def detect_mime_type(path, check_exists) do
    Kreuzberg.Native.detect_mime_type(path, check_exists)
  end

  @doc "Embed a list of texts using the configured embedding model."
  @spec embed_texts([String.t()]) :: {:ok, [[float()]]} | {:error, atom, String.t()}
  def embed_texts(texts) do
    Kreuzberg.Native.embed_texts(texts, nil)
  end

  @doc "Embed a list of texts using the configured embedding model."
  @spec embed_texts([String.t()], String.t() | nil) ::
          {:ok, [[float()]]} | {:error, atom, String.t()}
  def embed_texts(texts, config) do
    Kreuzberg.Native.embed_texts(texts, config)
  end

  @doc "Get an embedding preset by name."
  @spec get_embedding_preset(String.t()) :: map() | nil
  def get_embedding_preset(name) do
    Kreuzberg.Native.get_embedding_preset(name)
  end

  @doc "List the names of all available embedding presets."
  @spec list_embedding_presets() :: [String.t()]
  def list_embedding_presets do
    Kreuzberg.Native.list_embedding_presets()
  end

  @doc "Register a OcrBackend plugin with a GenServer PID and name."
  @spec register_ocr_backend(pid(), String.t()) :: :ok | :error
  def register_ocr_backend(genserver_pid, plugin_name) do
    Kreuzberg.Native.register_ocr_backend(genserver_pid, plugin_name)
  end

  @doc "Unregister a previously registered OcrBackend plugin by name."
  @spec unregister_ocr_backend(String.t()) :: :ok | :error
  def unregister_ocr_backend(name) do
    Kreuzberg.Native.unregister_ocr_backend(name)
  end

  @doc "Register a PostProcessor plugin with a GenServer PID and name."
  @spec register_post_processor(pid(), String.t()) :: :ok | :error
  def register_post_processor(genserver_pid, plugin_name) do
    Kreuzberg.Native.register_post_processor(genserver_pid, plugin_name)
  end

  @doc "Unregister a previously registered PostProcessor plugin by name."
  @spec unregister_post_processor(String.t()) :: :ok | :error
  def unregister_post_processor(name) do
    Kreuzberg.Native.unregister_post_processor(name)
  end

  @doc "Register a Validator plugin with a GenServer PID and name."
  @spec register_validator(pid(), String.t()) :: :ok | :error
  def register_validator(genserver_pid, plugin_name) do
    Kreuzberg.Native.register_validator(genserver_pid, plugin_name)
  end

  @doc "Unregister a previously registered Validator plugin by name."
  @spec unregister_validator(String.t()) :: :ok | :error
  def unregister_validator(name) do
    Kreuzberg.Native.unregister_validator(name)
  end

  @doc "Register a EmbeddingBackend plugin with a GenServer PID and name."
  @spec register_embedding_backend(pid(), String.t()) :: :ok | :error
  def register_embedding_backend(genserver_pid, plugin_name) do
    Kreuzberg.Native.register_embedding_backend(genserver_pid, plugin_name)
  end

  @doc "Unregister a previously registered EmbeddingBackend plugin by name."
  @spec unregister_embedding_backend(String.t()) :: :ok | :error
  def unregister_embedding_backend(name) do
    Kreuzberg.Native.unregister_embedding_backend(name)
  end

  @doc "Register a DocumentExtractor plugin with a GenServer PID and name."
  @spec register_document_extractor(pid(), String.t()) :: :ok | :error
  def register_document_extractor(genserver_pid, plugin_name) do
    Kreuzberg.Native.register_document_extractor(genserver_pid, plugin_name)
  end

  @doc "Unregister a previously registered DocumentExtractor plugin by name."
  @spec unregister_document_extractor(String.t()) :: :ok | :error
  def unregister_document_extractor(name) do
    Kreuzberg.Native.unregister_document_extractor(name)
  end

  @doc "Register a Renderer plugin with a GenServer PID and name."
  @spec register_renderer(pid(), String.t()) :: :ok | :error
  def register_renderer(genserver_pid, plugin_name) do
    Kreuzberg.Native.register_renderer(genserver_pid, plugin_name)
  end

  @doc "Unregister a previously registered Renderer plugin by name."
  @spec unregister_renderer(String.t()) :: :ok | :error
  def unregister_renderer(name) do
    Kreuzberg.Native.unregister_renderer(name)
  end
end
