{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://cheap-thrills-trinidad.flat18.app/schemas/find.schema.json",
  "title": "Cheap Thrills Trinidad find",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion", "id", "slug", "kind", "title", "summary", "description",
    "status", "confidence", "createdAt", "updatedAt", "publishedAt", "checkedAt",
    "places", "price", "validity", "categories", "sources"
  ],
  "properties": {
    "schemaVersion": { "const": 2 },
    "id": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]+$" },
    "slug": { "type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" },
    "kind": { "enum": ["food", "event"] },
    "title": { "type": "string", "minLength": 3, "maxLength": 120 },
    "summary": { "type": "string", "minLength": 10, "maxLength": 300 },
    "description": { "type": "string", "minLength": 10, "maxLength": 4000 },
    "status": { "enum": ["candidate", "published", "expired", "withdrawn"] },
    "confidence": { "enum": ["high", "medium", "low"] },
    "createdAt": { "type": "string", "format": "date-time" },
    "updatedAt": { "type": "string", "format": "date-time" },
    "publishedAt": { "type": ["string", "null"], "format": "date-time" },
    "checkedAt": { "type": "string", "format": "date-time" },
    "places": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["name", "area", "region", "address"],
        "properties": {
          "name": { "type": "string", "minLength": 1 },
          "area": { "type": "string", "minLength": 1 },
          "region": { "type": "string", "minLength": 1 },
          "address": { "type": ["string", "null"] },
          "mapUrl": { "type": ["string", "null"], "format": "uri" },
          "geolocation": {
            "type": "object",
            "additionalProperties": false,
            "required": ["latitude", "longitude", "crs", "precision", "source", "verifiedAt"],
            "properties": {
              "latitude": { "type": "number", "minimum": -90, "maximum": 90 },
              "longitude": { "type": "number", "minimum": -180, "maximum": 180 },
              "crs": { "const": "EPSG:4326" },
              "precision": { "enum": ["venue", "area"] },
              "source": {
                "type": "object",
                "additionalProperties": false,
                "required": ["provider", "url"],
                "properties": {
                  "provider": { "type": "string", "minLength": 1, "maxLength": 80 },
                  "url": { "type": "string", "format": "uri" }
                }
              },
              "verifiedAt": { "type": "string", "format": "date-time" }
            }
          }
        }
      }
    },
    "price": {
      "type": "object",
      "additionalProperties": false,
      "required": ["currency", "amount", "fromAmount", "label", "terms"],
      "properties": {
        "currency": { "const": "TTD" },
        "amount": { "type": ["number", "null"], "minimum": 0 },
        "fromAmount": { "type": ["number", "null"], "minimum": 0 },
        "label": { "type": "string", "maxLength": 120 },
        "terms": { "type": ["string", "null"], "maxLength": 800 }
      }
    },
    "validity": {
      "type": "object",
      "additionalProperties": false,
      "required": ["startsAt", "endsAt", "recurrence", "timezone"],
      "properties": {
        "startsAt": { "type": ["string", "null"], "format": "date-time" },
        "endsAt": { "type": ["string", "null"], "format": "date-time" },
        "recurrence": { "type": ["string", "null"], "maxLength": 400 },
        "timezone": { "const": "America/Port_of_Spain" }
      }
    },
    "categories": { "type": "array", "items": { "type": "string", "pattern": "^[a-z0-9-]+$" }, "uniqueItems": true },
    "research": {
      "type": "object",
      "additionalProperties": false,
      "required": ["service", "model"],
      "properties": {
        "service": { "type": "string", "minLength": 1, "maxLength": 120 },
        "model": { "type": "string", "minLength": 1, "maxLength": 160 }
      }
    },
    "food": {
      "type": "object",
      "additionalProperties": false,
      "required": ["items", "dietFit", "dietNotes"],
      "properties": {
        "items": { "type": "array", "items": { "type": "string" } },
        "dietFit": {
          "type": "object",
          "additionalProperties": false,
          "required": ["pescatarian", "dairyFree", "vegan"],
          "properties": {
            "pescatarian": { "enum": ["yes", "no", "unknown"] },
            "dairyFree": { "enum": ["yes", "no", "unknown"] },
            "vegan": { "enum": ["yes", "no", "unknown"] }
          }
        },
        "dietNotes": { "type": "string", "maxLength": 1200 }
      }
    },
    "event": {
      "type": "object",
      "additionalProperties": false,
      "required": ["format", "admission"],
      "properties": {
        "format": { "type": "string", "minLength": 1, "maxLength": 120 },
        "admission": { "type": "string", "minLength": 1, "maxLength": 500 }
      }
    },
    "sources": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["url", "publisher", "type", "checkedAt", "supports"],
        "properties": {
          "url": { "type": "string", "format": "uri" },
          "publisher": { "type": "string", "minLength": 1, "maxLength": 160 },
          "type": { "enum": ["official", "ticketing", "institutional", "social", "press", "other"] },
          "checkedAt": { "type": "string", "format": "date-time" },
          "supports": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1, "maxLength": 120 } }
        }
      }
    },
    "editorialNote": { "type": "string", "maxLength": 1200 }
  },
  "allOf": [
    { "if": { "properties": { "kind": { "const": "food" } } }, "then": { "required": ["food"], "not": { "required": ["event"] } } },
    { "if": { "properties": { "kind": { "const": "event" } } }, "then": { "required": ["event"], "not": { "required": ["food"] } } }
  ]
}
