# This file was auto-generated by Fern from our API Definition.

from __future__ import annotations

import typing

import typing_extensions
from ..core.serialization import FieldMetadata
from ..types.edit_json_extend_edit_field_type import EditJsonExtendEditFieldType
from .edit_bounding_box import EditBoundingBoxParams
from .edit_text_options import EditTextOptionsParams

if typing.TYPE_CHECKING:
    from .edit_object_json import EditObjectJsonParams


class EditJsonParams(typing_extensions.TypedDict):
    """
    Schema definition for a field to edit in a PDF. This is a union type that supports:
    * `EditStringJSONSchema` - type: ["string", "null"], field_type: "text" | "signature"
    * `EditNumberJSONSchema` - type: ["number", "null"], field_type: "text"
    * `EditIntegerJSONSchema` - type: ["integer", "null"], field_type: "text"
    * `EditBooleanJSONSchema` - type: ["boolean", "null"], field_type: "checkbox" | "radio"
    * `EditArrayJSONSchema` - type: "array", field_type: "text" | "table"
    * `EditEnumJSONSchema` - has enum property (no type field), field_type: "radio" | "optionList" | "dropdown"
    * `EditObjectJSON` - type: "object", field_type: "signature"

    All variants share common `extend_edit:*` properties for positioning and styling.
    """

    type: typing_extensions.NotRequired[typing.Any]
    """
    The JSON schema type of the field. Can be:
    * A string: "array" or "object"
    * A nullable tuple array: ["string", "null"], ["number", "null"], ["integer", "null"], ["boolean", "null"]
    * Omitted for enum fields (use enum property instead)
    """

    description: typing_extensions.NotRequired[str]
    """
    Description of the field
    """

    extend_edit_field_type: typing_extensions.NotRequired[
        typing_extensions.Annotated[EditJsonExtendEditFieldType, FieldMetadata(alias="extend_edit:field_type")]
    ]
    """
    The PDF field type to edit. Allowed values depend on the schema type:
    * `["string", "null"]` → `text`, `signature`
    * `["number", "null"]` → `text`
    * `["integer", "null"]` → `text`
    * `["boolean", "null"]` → `checkbox`, `radio`
    * `"array"` → `text`, `table`
    * `"object"` → `signature`
    * enum fields (no type) → `radio`, `optionList`, `dropdown`
    """

    extend_edit_bbox: typing_extensions.NotRequired[
        typing_extensions.Annotated[EditBoundingBoxParams, FieldMetadata(alias="extend_edit:bbox")]
    ]
    extend_edit_page_index: typing_extensions.NotRequired[
        typing_extensions.Annotated[int, FieldMetadata(alias="extend_edit:page_index")]
    ]
    """
    Zero-based page index where the field should be placed
    """

    extend_edit_text_edit_options: typing_extensions.NotRequired[
        typing_extensions.Annotated[EditTextOptionsParams, FieldMetadata(alias="extend_edit:text_edit_options")]
    ]
    extend_edit_column_width: typing_extensions.NotRequired[
        typing_extensions.Annotated[float, FieldMetadata(alias="extend_edit:column_width")]
    ]
    """
    Width of the column as a percentage (for table fields)
    """

    extend_edit_value: typing_extensions.NotRequired[
        typing_extensions.Annotated[typing.Any, FieldMetadata(alias="extend_edit:value")]
    ]
    """
    The value to fill into this field. Can be any type. This will force the value at this field to be filled with this value. If a value is not provided, we will attempt to generate or infer one based on the instructions.
    """

    extend_edit_row_heights: typing_extensions.NotRequired[
        typing_extensions.Annotated[typing.Sequence[float], FieldMetadata(alias="extend_edit:row_heights")]
    ]
    """
    Array of row height percentages for array/table fields (e.g. [0.25, 0.50, 0.25])
    """

    items: typing_extensions.NotRequired["EditObjectJsonParams"]
    """
    Schema for array items (when type is "array"). Must be an EditObjectJSON.
    """

    properties: typing_extensions.NotRequired[typing.Dict[str, "EditJsonParams"]]
    """
    Nested properties for object types. Each property follows the EditJSON structure.
    """

    enum: typing_extensions.NotRequired[typing.Sequence[str]]
    """
    Allowed values for enum/dropdown/radio fields
    """

    max_items: typing_extensions.NotRequired[typing_extensions.Annotated[int, FieldMetadata(alias="maxItems")]]
    """
    Maximum number of rows for array/table fields
    """

    required: typing_extensions.NotRequired[typing.Sequence[str]]
    """
    List of required property names (for object types)
    """

    additional_properties: typing_extensions.NotRequired[
        typing_extensions.Annotated[bool, FieldMetadata(alias="additionalProperties")]
    ]
    """
    Whether additional properties are allowed (for object types)
    """
