{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://makeasciiart.com/agent/scene-schema-v2.json",
  "title": "MakeASCIIArt typed recursive scene v2",
  "description": "Finite local scene graph. CLI is the authoritative validator for node count and data limits.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "version",
    "title",
    "canvas",
    "background",
    "camera",
    "root"
  ],
  "properties": {
    "version": {
      "const": 2
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 72
    },
    "canvas": {
      "type": "object",
      "required": [
        "width",
        "height"
      ],
      "properties": {
        "width": {
          "const": 1000
        },
        "height": {
          "const": 1000
        }
      }
    },
    "background": {
      "$ref": "#/$defs/color"
    },
    "camera": {
      "type": "array",
      "minItems": 2,
      "maxItems": 5,
      "items": {
        "type": "object",
        "required": [
          "name",
          "x",
          "y",
          "zoom"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 50
          },
          "x": {
            "type": "number",
            "minimum": -3000,
            "maximum": 3000
          },
          "y": {
            "type": "number",
            "minimum": -3000,
            "maximum": 3000
          },
          "zoom": {
            "type": "number",
            "minimum": 0.6,
            "maximum": 200
          }
        }
      }
    },
    "root": {
      "$ref": "#/$defs/node"
    },
    "sources": {
      "type": "array",
      "maxItems": 8,
      "items": {
        "type": "object",
        "required": [
          "label",
          "url"
        ],
        "properties": {
          "label": {
            "type": "string",
            "maxLength": 100
          },
          "url": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://"
          },
          "license": {
            "type": "string",
            "maxLength": 60
          },
          "role": {
            "type": "string",
            "maxLength": 32
          }
        }
      }
    }
  },
  "$defs": {
    "color": {
      "type": "string",
      "pattern": "^#[0-9a-fA-F]{6}$"
    },
    "node": {
      "type": "object",
      "required": [
        "id",
        "type",
        "x",
        "y"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 42
        },
        "type": {
          "enum": [
            "group",
            "text",
            "shape",
            "image",
            "data",
            "glyphField"
          ]
        },
        "x": {
          "type": "number",
          "minimum": -3000,
          "maximum": 3000
        },
        "y": {
          "type": "number",
          "minimum": -3000,
          "maximum": 3000
        },
        "scale": {
          "type": "number",
          "minimum": 0.01,
          "maximum": 50
        },
        "rotate": {
          "type": "number",
          "minimum": -360,
          "maximum": 360
        },
        "opacity": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "color": {
          "$ref": "#/$defs/color"
        },
        "text": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "size": {
          "type": "number",
          "minimum": 1,
          "maximum": 1000
        },
        "shape": {
          "enum": [
            "rect",
            "circle",
            "ellipse"
          ]
        },
        "width": {
          "type": "number",
          "minimum": 1,
          "maximum": 2000
        },
        "height": {
          "type": "number",
          "minimum": 1,
          "maximum": 2000
        },
        "src": {
          "type": "string",
          "pattern": "^data:image/(png|jpeg|webp);base64,[A-Za-z0-9+/]+=*$"
        },
        "label": {
          "type": "string",
          "minLength": 1,
          "maxLength": 48
        },
        "value": {
          "type": "number",
          "minimum": 0,
          "maximum": 100
        },
        "children": {
          "type": "array",
          "maxItems": 30,
          "items": {
            "$ref": "#/$defs/node"
          }
        },
        "revealZoom": {
          "type": "number",
          "minimum": 1,
          "maximum": 180
        },
        "luma": {
          "type": "string",
          "maxLength": 9000
        },
        "columns": {
          "type": "integer",
          "minimum": 8,
          "maximum": 80
        },
        "rows": {
          "type": "integer",
          "minimum": 8,
          "maximum": 80
        },
        "invert": {
          "type": "boolean"
        },
        "mode": {
          "enum": [
            "characters",
            "words"
          ]
        },
        "words": {
          "type": "array",
          "minItems": 1,
          "maxItems": 18,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 22
          }
        },
        "hideZoom": {
          "type": "number",
          "minimum": 1,
          "maximum": 180
        }
      }
    }
  }
}
