// 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
package dev.kreuzberg;

import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import org.jspecify.annotations.Nullable;

/**
 * Unified page structure for documents.
 *
 * Supports different page types (PDF pages, PPTX slides, Excel sheets)
 * with character offset boundaries for chunk-to-page mapping.
 */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = PageStructure.Builder.class)
public record PageStructure(
    /**
     * Total number of pages/slides/sheets
     */
    @JsonProperty("total_count") int totalCount,
    /**
     * Type of paginated unit
     */
    @JsonProperty("unit_type") PageUnitType unitType,
    /**
     * Character offset boundaries for each page
     *
     * Maps character ranges in the extracted content to page numbers.
     * Used for chunk page range calculation.
     */
    @Nullable @JsonProperty("boundaries") List<PageBoundary> boundaries,
    /**
     * Detailed per-page metadata (optional, only when needed)
     */
    @Nullable @JsonProperty("pages") List<PageInfo> pages
) {
    public static Builder builder() {
        return new Builder();
    }

    // CPD-OFF
    @JsonPOJOBuilder(withPrefix = "with", buildMethodName = "build")
    public static final class Builder {

        @JsonProperty("total_count")
private int totalCount = 0;
        @JsonProperty("unit_type")
private PageUnitType unitType = null;
private List<PageBoundary> boundaries = null;
private List<PageInfo> pages = null;

        /** Sets the totalCount field. */
        @JsonProperty("total_count")
        public Builder withTotalCount(final int value) {
            this.totalCount = value;
            return this;
        }

        /** Sets the unitType field. */
        @JsonProperty("unit_type")
        public Builder withUnitType(final PageUnitType value) {
            this.unitType = value;
            return this;
        }

        /** Sets the boundaries field. */
        @JsonProperty("boundaries")
        public Builder withBoundaries(final @Nullable List<PageBoundary> value) {
            this.boundaries = value;
            return this;
        }

        /** Sets the pages field. */
        @JsonProperty("pages")
        public Builder withPages(final @Nullable List<PageInfo> value) {
            this.pages = value;
            return this;
        }

        /** Builds the PageStructure instance. */
        public PageStructure build() {
            return new PageStructure(
                totalCount,
                unitType,
                boundaries,
                pages
            );
        }
    }
    // CPD-ON
}
