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

/**
 * Block-level element in a Djot document.
 *
 * Represents structural elements like headings, paragraphs, lists, code blocks, etc.
 */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = FormattedBlock.Builder.class)
public record FormattedBlock(
    /**
     * Type of block element
     */
    @JsonProperty("block_type") BlockType blockType,
    /**
     * Heading level (1-6) for headings, or nesting level for lists
     */
    @Nullable @JsonProperty("level") Long level,
    /**
     * Inline content within the block
     */
    @JsonProperty("inline_content") List<InlineElement> inlineContent,
    /**
     * Element attributes (classes, IDs, key-value pairs)
     */
    @Nullable @JsonProperty("attributes") String attributes,
    /**
     * Language identifier for code blocks
     */
    @Nullable @JsonProperty("language") String language,
    /**
     * Raw code content for code blocks
     */
    @Nullable @JsonProperty("code") String code,
    /**
     * Nested blocks for containers (blockquotes, list items, divs)
     */
    @Nullable @JsonProperty("children") List<FormattedBlock> children
) {
    public static Builder builder() {
        return new Builder();
    }

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

        @JsonProperty("block_type")
private BlockType blockType = null;
private Long level = null;
        @JsonProperty("inline_content")
private List<InlineElement> inlineContent = List.of();
private String attributes = null;
private String language = null;
private String code = null;
private List<FormattedBlock> children = null;

        /** Sets the blockType field. */
        @JsonProperty("block_type")
        public Builder withBlockType(final BlockType value) {
            this.blockType = value;
            return this;
        }

        /** Sets the level field. */
        @JsonProperty("level")
        public Builder withLevel(final @Nullable long value) {
            this.level = value;
            return this;
        }

        /** Sets the inlineContent field. */
        @JsonProperty("inline_content")
        public Builder withInlineContent(final List<InlineElement> value) {
            this.inlineContent = value;
            return this;
        }

        /** Sets the attributes field. */
        @JsonProperty("attributes")
        public Builder withAttributes(final @Nullable String value) {
            this.attributes = value;
            return this;
        }

        /** Sets the language field. */
        @JsonProperty("language")
        public Builder withLanguage(final @Nullable String value) {
            this.language = value;
            return this;
        }

        /** Sets the code field. */
        @JsonProperty("code")
        public Builder withCode(final @Nullable String value) {
            this.code = value;
            return this;
        }

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

        /** Builds the FormattedBlock instance. */
        public FormattedBlock build() {
            return new FormattedBlock(
                blockType,
                level,
                inlineContent,
                attributes,
                language,
                code,
                children
            );
        }
    }
    // CPD-ON
}
