# 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.LayoutRegion do
  @moduledoc """
  A detected layout region on a page.

  When layout detection is enabled, each page may have layout regions
  identifying different content types (text, pictures, tables, etc.)
  with confidence scores and spatial positions.
  """

  @typedoc "A detected layout region on a page."
  @type t :: %__MODULE__{
          class_name: String.t() | nil,
          confidence: float(),
          bounding_box: map(),
          area_fraction: float()
        }

  defstruct class_name: nil,
            confidence: 0.0,
            bounding_box: nil,
            area_fraction: 0.0

  defimpl Jason.Encoder do
    @doc false
    def encode(value, opts) do
      value
      |> Map.from_struct()
      |> Enum.reject(fn {_k, v} -> v == nil end)
      |> Enum.into(%{})
      |> Jason.Encoder.encode(opts)
    end
  end
end
