{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://autype.com/llm-resources/region-block.schema.json",
  "title": "Autype Region Block",
  "description": "One text, image, field, variable, rule, spacer, QR-code, or shape block.",
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_-]{0,63}$",
          "maxLength": 64
        },
        "width": {
          "anyOf": [
            {
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 2000
            },
            {
              "type": "string",
              "enum": [
                "auto",
                "fill"
              ]
            }
          ]
        },
        "height": {
          "anyOf": [
            {
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 2000
            },
            {
              "type": "string",
              "const": "auto"
            }
          ]
        },
        "alignSelf": {
          "type": "string",
          "enum": [
            "start",
            "center",
            "end",
            "stretch"
          ]
        },
        "visible": {
          "type": "boolean"
        },
        "opacity": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "alt": {
          "type": "string",
          "maxLength": 500
        },
        "fontFamily": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        },
        "fontSize": {
          "type": "number",
          "minimum": 1,
          "maximum": 500
        },
        "fontWeight": {
          "type": "string",
          "enum": [
            "normal",
            "medium",
            "semibold",
            "bold"
          ]
        },
        "fontStyle": {
          "type": "string",
          "enum": [
            "normal",
            "italic"
          ]
        },
        "color": {
          "type": "string"
        },
        "align": {
          "type": "string",
          "enum": [
            "left",
            "center",
            "right",
            "justify"
          ]
        },
        "lineHeight": {
          "type": "number",
          "minimum": 0.5,
          "maximum": 5
        },
        "type": {
          "type": "string",
          "const": "text"
        },
        "text": {
          "type": "string",
          "minLength": 1,
          "maxLength": 5000
        },
        "format": {
          "type": "string",
          "enum": [
            "plain",
            "markdown"
          ]
        },
        "link": {
          "type": "string",
          "format": "uri",
          "maxLength": 2000
        }
      },
      "required": [
        "id",
        "type",
        "text"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "#/anyOf/0/properties/id"
        },
        "width": {
          "$ref": "#/anyOf/0/properties/width"
        },
        "height": {
          "$ref": "#/anyOf/0/properties/height"
        },
        "alignSelf": {
          "$ref": "#/anyOf/0/properties/alignSelf"
        },
        "visible": {
          "$ref": "#/anyOf/0/properties/visible"
        },
        "opacity": {
          "$ref": "#/anyOf/0/properties/opacity"
        },
        "alt": {
          "$ref": "#/anyOf/0/properties/alt"
        },
        "type": {
          "type": "string",
          "const": "image"
        },
        "src": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2000
        },
        "fit": {
          "type": "string",
          "enum": [
            "contain",
            "cover",
            "fill",
            "none"
          ]
        },
        "focalPoint": {
          "type": "object",
          "properties": {
            "x": {
              "type": "number",
              "minimum": 0,
              "maximum": 100
            },
            "y": {
              "type": "number",
              "minimum": 0,
              "maximum": 100
            }
          },
          "required": [
            "x",
            "y"
          ],
          "additionalProperties": false
        },
        "link": {
          "type": "string",
          "format": "uri",
          "maxLength": 2000
        }
      },
      "required": [
        "id",
        "type",
        "src"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "#/anyOf/0/properties/id"
        },
        "width": {
          "$ref": "#/anyOf/0/properties/width"
        },
        "height": {
          "$ref": "#/anyOf/0/properties/height"
        },
        "alignSelf": {
          "$ref": "#/anyOf/0/properties/alignSelf"
        },
        "visible": {
          "$ref": "#/anyOf/0/properties/visible"
        },
        "opacity": {
          "$ref": "#/anyOf/0/properties/opacity"
        },
        "alt": {
          "$ref": "#/anyOf/0/properties/alt"
        },
        "fontFamily": {
          "$ref": "#/anyOf/0/properties/fontFamily"
        },
        "fontSize": {
          "$ref": "#/anyOf/0/properties/fontSize"
        },
        "fontWeight": {
          "$ref": "#/anyOf/0/properties/fontWeight"
        },
        "fontStyle": {
          "$ref": "#/anyOf/0/properties/fontStyle"
        },
        "color": {
          "$ref": "#/anyOf/0/properties/color"
        },
        "align": {
          "$ref": "#/anyOf/0/properties/align"
        },
        "lineHeight": {
          "$ref": "#/anyOf/0/properties/lineHeight"
        },
        "type": {
          "type": "string",
          "const": "field"
        },
        "field": {
          "type": "string",
          "enum": [
            "pageNumber",
            "totalPages",
            "documentTitle",
            "documentAuthor",
            "documentSubject",
            "sectionTitle",
            "chapterTitle",
            "currentDate",
            "createdDate",
            "modifiedDate"
          ]
        },
        "prefix": {
          "type": "string",
          "maxLength": 200
        },
        "suffix": {
          "type": "string",
          "maxLength": 200
        },
        "format": {
          "type": "string",
          "maxLength": 100
        },
        "locale": {
          "type": "string",
          "maxLength": 35
        },
        "fallback": {
          "type": "string",
          "maxLength": 500
        }
      },
      "required": [
        "id",
        "type",
        "field"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "#/anyOf/0/properties/id"
        },
        "width": {
          "$ref": "#/anyOf/0/properties/width"
        },
        "height": {
          "$ref": "#/anyOf/0/properties/height"
        },
        "alignSelf": {
          "$ref": "#/anyOf/0/properties/alignSelf"
        },
        "visible": {
          "$ref": "#/anyOf/0/properties/visible"
        },
        "opacity": {
          "$ref": "#/anyOf/0/properties/opacity"
        },
        "alt": {
          "$ref": "#/anyOf/0/properties/alt"
        },
        "fontFamily": {
          "$ref": "#/anyOf/0/properties/fontFamily"
        },
        "fontSize": {
          "$ref": "#/anyOf/0/properties/fontSize"
        },
        "fontWeight": {
          "$ref": "#/anyOf/0/properties/fontWeight"
        },
        "fontStyle": {
          "$ref": "#/anyOf/0/properties/fontStyle"
        },
        "color": {
          "$ref": "#/anyOf/0/properties/color"
        },
        "align": {
          "$ref": "#/anyOf/0/properties/align"
        },
        "lineHeight": {
          "$ref": "#/anyOf/0/properties/lineHeight"
        },
        "type": {
          "type": "string",
          "const": "variable"
        },
        "name": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9_]*$",
          "maxLength": 50
        },
        "prefix": {
          "type": "string",
          "maxLength": 200
        },
        "suffix": {
          "type": "string",
          "maxLength": 200
        },
        "format": {
          "type": "string",
          "maxLength": 100
        },
        "fallback": {
          "type": "string",
          "maxLength": 500
        }
      },
      "required": [
        "id",
        "type",
        "name"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "#/anyOf/0/properties/id"
        },
        "width": {
          "$ref": "#/anyOf/0/properties/width"
        },
        "height": {
          "$ref": "#/anyOf/0/properties/height"
        },
        "alignSelf": {
          "$ref": "#/anyOf/0/properties/alignSelf"
        },
        "visible": {
          "$ref": "#/anyOf/0/properties/visible"
        },
        "opacity": {
          "$ref": "#/anyOf/0/properties/opacity"
        },
        "alt": {
          "$ref": "#/anyOf/0/properties/alt"
        },
        "type": {
          "type": "string",
          "const": "rule"
        },
        "direction": {
          "type": "string",
          "enum": [
            "horizontal",
            "vertical"
          ]
        },
        "length": {
          "anyOf": [
            {
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 2000
            },
            {
              "type": "string",
              "const": "fill"
            }
          ]
        },
        "line": {
          "type": "object",
          "properties": {
            "width": {
              "type": "number",
              "minimum": 0,
              "maximum": 50
            },
            "style": {
              "type": "string",
              "enum": [
                "solid",
                "dashed",
                "dotted",
                "double"
              ]
            },
            "color": {
              "$ref": "#/anyOf/0/properties/color"
            },
            "opacity": {
              "$ref": "#/anyOf/0/properties/opacity"
            }
          },
          "required": [
            "width",
            "style",
            "color"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "id",
        "type",
        "direction",
        "line"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "#/anyOf/0/properties/id"
        },
        "width": {
          "$ref": "#/anyOf/0/properties/width"
        },
        "height": {
          "$ref": "#/anyOf/0/properties/height"
        },
        "alignSelf": {
          "$ref": "#/anyOf/0/properties/alignSelf"
        },
        "visible": {
          "$ref": "#/anyOf/0/properties/visible"
        },
        "opacity": {
          "$ref": "#/anyOf/0/properties/opacity"
        },
        "alt": {
          "$ref": "#/anyOf/0/properties/alt"
        },
        "type": {
          "type": "string",
          "const": "spacer"
        }
      },
      "required": [
        "id",
        "type"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "#/anyOf/0/properties/id"
        },
        "width": {
          "$ref": "#/anyOf/0/properties/width"
        },
        "height": {
          "$ref": "#/anyOf/0/properties/height"
        },
        "alignSelf": {
          "$ref": "#/anyOf/0/properties/alignSelf"
        },
        "visible": {
          "$ref": "#/anyOf/0/properties/visible"
        },
        "opacity": {
          "$ref": "#/anyOf/0/properties/opacity"
        },
        "alt": {
          "$ref": "#/anyOf/0/properties/alt"
        },
        "type": {
          "type": "string",
          "const": "qrcode"
        },
        "data": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2000
        },
        "errorCorrection": {
          "type": "string",
          "enum": [
            "L",
            "M",
            "Q",
            "H"
          ]
        },
        "foregroundColor": {
          "$ref": "#/anyOf/0/properties/color"
        },
        "backgroundColor": {
          "$ref": "#/anyOf/0/properties/color"
        }
      },
      "required": [
        "id",
        "type",
        "data"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "#/anyOf/0/properties/id"
        },
        "width": {
          "$ref": "#/anyOf/0/properties/width"
        },
        "height": {
          "$ref": "#/anyOf/0/properties/height"
        },
        "alignSelf": {
          "$ref": "#/anyOf/0/properties/alignSelf"
        },
        "visible": {
          "$ref": "#/anyOf/0/properties/visible"
        },
        "opacity": {
          "$ref": "#/anyOf/0/properties/opacity"
        },
        "alt": {
          "$ref": "#/anyOf/0/properties/alt"
        },
        "type": {
          "type": "string",
          "const": "shape"
        },
        "shape": {
          "type": "string",
          "enum": [
            "rectangle",
            "roundedRectangle",
            "ellipse",
            "triangle",
            "diamond"
          ]
        },
        "fill": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "const": "none"
                }
              },
              "required": [
                "type"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "const": "color"
                },
                "color": {
                  "$ref": "#/anyOf/0/properties/color"
                },
                "opacity": {
                  "$ref": "#/anyOf/0/properties/opacity"
                }
              },
              "required": [
                "type",
                "color"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "const": "image"
                },
                "src": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 2000
                },
                "backgroundColor": {
                  "$ref": "#/anyOf/0/properties/color"
                },
                "fit": {
                  "type": "string",
                  "enum": [
                    "contain",
                    "cover",
                    "fill",
                    "none"
                  ]
                },
                "positionX": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100
                },
                "positionY": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100
                },
                "opacity": {
                  "$ref": "#/anyOf/0/properties/opacity"
                }
              },
              "required": [
                "type",
                "src"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "const": "linearGradient"
                },
                "angle": {
                  "type": "number",
                  "minimum": -360,
                  "maximum": 360
                },
                "stops": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "offset": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 100
                      },
                      "color": {
                        "$ref": "#/anyOf/0/properties/color"
                      },
                      "opacity": {
                        "$ref": "#/anyOf/0/properties/opacity"
                      }
                    },
                    "required": [
                      "offset",
                      "color"
                    ],
                    "additionalProperties": false
                  },
                  "minItems": 2,
                  "maxItems": 20
                },
                "opacity": {
                  "$ref": "#/anyOf/0/properties/opacity"
                }
              },
              "required": [
                "type",
                "angle",
                "stops"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "const": "radialGradient"
                },
                "centerX": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100
                },
                "centerY": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100
                },
                "stops": {
                  "type": "array",
                  "items": {
                    "$ref": "#/anyOf/7/properties/fill/anyOf/3/properties/stops/items"
                  },
                  "minItems": 2,
                  "maxItems": 20
                },
                "opacity": {
                  "$ref": "#/anyOf/0/properties/opacity"
                }
              },
              "required": [
                "type",
                "stops"
              ],
              "additionalProperties": false
            }
          ]
        },
        "borders": {
          "type": "object",
          "properties": {
            "top": {
              "anyOf": [
                {
                  "$ref": "#/anyOf/4/properties/line"
                },
                {
                  "type": "null"
                }
              ]
            },
            "right": {
              "anyOf": [
                {
                  "$ref": "#/anyOf/4/properties/line"
                },
                {
                  "type": "null"
                }
              ]
            },
            "bottom": {
              "anyOf": [
                {
                  "$ref": "#/anyOf/4/properties/line"
                },
                {
                  "type": "null"
                }
              ]
            },
            "left": {
              "anyOf": [
                {
                  "$ref": "#/anyOf/4/properties/line"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "additionalProperties": false
        },
        "radius": {
          "type": "number",
          "minimum": 0,
          "maximum": 2000
        }
      },
      "required": [
        "id",
        "type",
        "shape"
      ],
      "additionalProperties": false
    }
  ]
}