{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://digidala.ru/schemas/chat-mandala-template-0.4.json",
  "title": "DigiDala Chat Mandala Template Metadata",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "template_id",
    "status",
    "size",
    "source",
    "canvas",
    "source_path_count",
    "logical_game_unit_count",
    "logical_type_count",
    "logical_types",
    "engine_contract",
    "units"
  ],
  "properties": {
    "schema_version": {
      "type": "string"
    },
    "template_id": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "candidate_for_chat_mandala_mvp",
        "active"
      ]
    },
    "size": {
      "type": "string",
      "enum": [
        "small",
        "medium",
        "large"
      ]
    },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "source_file",
        "license_file",
        "attribution",
        "adaptation"
      ],
      "properties": {
        "source_file": {
          "type": "string"
        },
        "license_file": {
          "type": "string"
        },
        "attribution": {
          "type": "string"
        },
        "adaptation": {
          "type": "string"
        }
      }
    },
    "canvas": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "viewBox",
        "normalization",
        "target_margin_px"
      ],
      "properties": {
        "viewBox": {
          "type": "array",
          "items": {
            "type": "number"
          },
          "minItems": 4,
          "maxItems": 4
        },
        "normalization": {
          "type": "string"
        },
        "artwork_source_render_bbox": {
          "type": "array",
          "items": {
            "type": "number"
          },
          "minItems": 4,
          "maxItems": 4
        },
        "target_margin_px": {
          "type": "number"
        },
        "normalization_scale": {
          "type": "number"
        }
      }
    },
    "source_path_count": {
      "type": "integer",
      "minimum": 1
    },
    "logical_game_unit_count": {
      "type": "integer",
      "minimum": 1
    },
    "logical_type_count": {
      "type": "integer",
      "minimum": 1
    },
    "logical_types": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "weight",
          "recommended_progress_bias",
          "unit_count",
          "channel"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "weight": {
            "type": "number"
          },
          "recommended_progress_bias": {
            "type": "string"
          },
          "unit_count": {
            "type": "integer",
            "minimum": 1
          },
          "channel": {
            "type": "string"
          }
        }
      }
    },
    "engine_contract": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "profiling",
        "progress_model",
        "initial_reveal",
        "completion",
        "channels"
      ],
      "properties": {
        "profiling": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "text_symbols_target",
            "unique_text_symbols_min",
            "soft_checkpoint_minutes"
          ],
          "properties": {
            "text_symbols_target": {
              "type": "integer"
            },
            "unique_text_symbols_min": {
              "type": "integer"
            },
            "soft_checkpoint_minutes": {
              "type": "number"
            }
          }
        },
        "progress_model": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "global_progress_weight",
            "local_channel_weight",
            "energy_affects_structure"
          ],
          "properties": {
            "global_progress_weight": {
              "type": "number"
            },
            "local_channel_weight": {
              "type": "number"
            },
            "energy_affects_structure": {
              "type": "boolean"
            }
          }
        },
        "initial_reveal": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "center": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            },
            "inner_ring": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            },
            "inner_elements": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            },
            "middle_elements": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            },
            "outer_ring": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            },
            "ornaments": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            }
          }
        },
        "completion": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "condition",
            "energy_threshold_status"
          ],
          "properties": {
            "condition": {
              "type": "string"
            },
            "energy_threshold_status": {
              "type": "string"
            }
          }
        },
        "channels": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "text_structure": {
              "type": "string"
            },
            "emoji": {
              "type": "string"
            },
            "punctuation": {
              "type": "string"
            },
            "activity": {
              "type": "string"
            }
          }
        }
      }
    },
    "units": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "type",
          "source_paths",
          "weight",
          "fill_mode",
          "channel"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "sector_index": {
            "type": "integer",
            "minimum": 0
          },
          "source_paths": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 1
          },
          "weight": {
            "type": "number"
          },
          "fill_mode": {
            "type": "string",
            "enum": [
              "progressive_mask",
              "progressive_clip",
              "progressive_gradient"
            ]
          },
          "channel": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          }
        }
      }
    },
    "notes": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  }
}