{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://dadafu.app/model-import.schema.json",
  "title": "Dadafu model proposal, version 1",
  "description": "A proposed custom digital build. UTF-8 JSON must be at most 131072 bytes. Optional #model=base64url links are limited to 16000 characters including the fragment prefix; larger valid models use JSON paste or file import. The runtime additionally checks unique piece IDs, full transformed geometry within x/z ±11.8 and y 0–10, and pairwise overlap. Passing validation is not physical testing. Preview/import uses creative mode to preserve geometry. No account privileges, paid materials, URLs or executable fields are accepted.",
  "type": "object",
  "additionalProperties": false,
  "required": ["format", "version", "name", "pieces"],
  "properties": {
    "format": {"const": "dadafu-model"},
    "version": {"const": 1},
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80,
      "pattern": "^[^\\u0000-\\u001f\\u007f-\\u009f<>&\\u200b-\\u200f\\u2028-\\u202e\\u2060-\\u206f\\ufeff]+$",
      "description": "Plain-text display name, trimmed on import. Must contain a non-whitespace character. The runtime limit is 80 UTF-16 code units for compatibility with saved plans; supplementary characters use two units. Unpaired surrogates and hidden control/direction marks are rejected."
    },
    "pieces": {
      "type": "array",
      "minItems": 1,
      "maxItems": 400,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "type", "color", "position", "rotation"],
        "properties": {
          "id": {"type": "string", "pattern": "^[A-Za-z0-9_-]{1,80}$", "description": "Unique within this model."},
          "type": {"enum": ["square", "triangle", "tallTriangle", "rightTriangle", "door", "doubleDoor", "shortRectangle", "window", "fence", "frame", "corner", "rectangle", "battlement", "car"]},
          "color": {"type": "string", "pattern": "^#(?:[a-fA-F0-9]{3}|[a-fA-F0-9]{6})$"},
          "position": {
            "type": "array",
            "minItems": 3,
            "maxItems": 3,
            "prefixItems": [
              {"type": "number", "minimum": -11.8, "maximum": 11.8},
              {"type": "number", "minimum": 0, "maximum": 10},
              {"type": "number", "minimum": -11.8, "maximum": 11.8}
            ],
            "items": false,
            "description": "Finite [x,y,z] values in native units, where a basic square has unit edge length. For magnetic tiles this is the bottom-center anchor in the unrotated local XY plane; a car uses its centered ground-footprint anchor. The complete rotated geometry must stay within bounds."
          },
          "rotation": {
            "type": "array",
            "minItems": 3,
            "maxItems": 3,
            "items": {"type": "number", "minimum": -100.53096491487338, "maximum": 100.53096491487338},
            "description": "Finite [rx,ry,rz] radians, each within ±32π, applied in the renderer's YXZ Euler order. [0,0,0] is upright; [π/2,0,0] lays a tile flat from its anchor toward positive z."
          }
        }
      }
    }
  }
}
