{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://scan-quest.com/portal/ai-build-kit/quest.schema.json",
  "title": "Scan Quest AI Quest",
  "type": "object",
  "additionalProperties": false,
  "required": ["title", "date", "hours", "minutes", "instructions", "challenges"],
  "properties": {
    "title": { "type": "string", "minLength": 3, "maxLength": 120 },
    "date": { "type": "string", "format": "date" },
    "hours": { "type": "integer", "minimum": 0, "maximum": 23 },
    "minutes": { "type": "integer", "minimum": 0, "maximum": 59 },
    "instructions": { "type": "string", "minLength": 20, "maxLength": 4000 },
    "challenges": {
      "type": "array",
      "minItems": 1,
      "maxItems": 100,
      "items": { "$ref": "#/$defs/challenge" }
    }
  },
  "$defs": {
    "challenge": {
      "type": "object",
      "additionalProperties": false,
      "required": ["delivery", "type", "title", "description", "points"],
      "properties": {
        "delivery": { "enum": ["app", "qr"] },
        "type": { "enum": ["actpic", "chkin", "draw", "action", "multi", "photo", "points", "prize", "rule", "trivia"] },
        "title": { "type": "string", "maxLength": 240 },
        "description": { "type": "string", "maxLength": 1500 },
        "points": { "type": "integer", "minimum": 0, "maximum": 9999 },
        "answers": { "type": "array", "minItems": 2, "maxItems": 4, "items": { "type": "string", "minLength": 1, "maxLength": 240 } },
        "address": { "type": "array", "minItems": 4, "maxItems": 4, "prefixItems": [{"type":"string"},{"type":"string"},{"type":"string"},{"type":"string"}] }
      },
      "allOf": [
        { "if": { "properties": { "type": { "const": "multi" } } }, "then": { "required": ["answers"] } },
        { "if": { "properties": { "type": { "const": "chkin" } } }, "then": { "required": ["address"] } }
      ]
    }
  }
}
