{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Legends Wall duel import v1",
  "description": "Browser-only historical duels. Target club and active discipline are selected separately. Member text and tags also follow ordinary product semantic rules.",
  "type": "object",
  "additionalProperties": false,
  "required": ["format", "format_version", "participants", "duels"],
  "properties": {
    "format": { "const": "legends-wall-duel-import" },
    "format_version": { "const": 1 },
    "participants": {
      "type": "array",
      "minItems": 1,
      "items": { "$ref": "#/$defs/sourceParticipant" }
    },
    "duels": {
      "type": "array",
      "minItems": 1,
      "items": { "$ref": "#/$defs/duel" }
    }
  },
  "$defs": {
    "sourceId": { "type": "string", "minLength": 1 },
    "sourceParticipant": {
      "type": "object",
      "additionalProperties": false,
      "required": ["source_id", "display_name", "handle"],
      "properties": {
        "source_id": { "$ref": "#/$defs/sourceId" },
        "display_name": { "type": "string" },
        "handle": { "type": ["string", "null"] }
      }
    },
    "duelParticipant": {
      "type": "object",
      "additionalProperties": false,
      "required": ["source_id", "place"],
      "properties": {
        "source_id": { "$ref": "#/$defs/sourceId" },
        "place": { "type": "integer", "minimum": 1 }
      }
    },
    "duel": {
      "type": "object",
      "additionalProperties": false,
      "required": ["index", "played_at", "participants", "tags"],
      "properties": {
        "index": { "type": "integer", "minimum": 0 },
        "played_at": {
          "type": "string",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt][0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+)?([Zz]|[+-][0-9]{2}:[0-9]{2})$"
        },
        "participants": {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": { "$ref": "#/$defs/duelParticipant" }
        },
        "tags": { "type": "array", "items": { "type": "string" } }
      }
    }
  }
}
