{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "anyOf": [
    {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "member": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "reward": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100,
                  "pattern": "^[a-zA-Z0-9_-]+$"
                },
                "title": {
                  "type": "string"
                },
                "tiers": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100,
                        "pattern": "^[a-zA-Z0-9_-]+$"
                      },
                      "title": {
                        "type": "string"
                      }
                    },
                    "required": ["id", "title"],
                    "additionalProperties": {}
                  }
                },
                "inventory": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string"
                    }
                  },
                  "required": ["kind"],
                  "additionalProperties": {}
                },
                "fulfillment": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string"
                    }
                  },
                  "required": ["kind"],
                  "additionalProperties": {}
                }
              },
              "required": ["id", "title", "tiers", "inventory", "fulfillment"],
              "additionalProperties": {}
            },
            "earnedTier": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "tier": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "revision": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "status": {
              "type": "string",
              "const": "available"
            }
          },
          "required": [
            "id",
            "member",
            "reward",
            "earnedTier",
            "tier",
            "revision",
            "status"
          ],
          "additionalProperties": {}
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "member": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "reward": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100,
                  "pattern": "^[a-zA-Z0-9_-]+$"
                },
                "title": {
                  "type": "string"
                },
                "tiers": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100,
                        "pattern": "^[a-zA-Z0-9_-]+$"
                      },
                      "title": {
                        "type": "string"
                      }
                    },
                    "required": ["id", "title"],
                    "additionalProperties": {}
                  }
                },
                "inventory": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string"
                    }
                  },
                  "required": ["kind"],
                  "additionalProperties": {}
                },
                "fulfillment": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string"
                    }
                  },
                  "required": ["kind"],
                  "additionalProperties": {}
                }
              },
              "required": ["id", "title", "tiers", "inventory", "fulfillment"],
              "additionalProperties": {}
            },
            "earnedTier": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "tier": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "revision": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "status": {
              "type": "string",
              "const": "handing-over"
            },
            "handover": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "startedAt": {
              "type": "number"
            },
            "allocation": {
              "type": "object",
              "properties": {
                "item": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100,
                  "pattern": "^[a-zA-Z0-9_-]+$"
                },
                "label": {
                  "type": "string"
                }
              },
              "required": ["item", "label"],
              "additionalProperties": {}
            }
          },
          "required": [
            "id",
            "member",
            "reward",
            "earnedTier",
            "tier",
            "revision",
            "status",
            "handover",
            "startedAt"
          ],
          "additionalProperties": {}
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "member": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "reward": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100,
                  "pattern": "^[a-zA-Z0-9_-]+$"
                },
                "title": {
                  "type": "string"
                },
                "tiers": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100,
                        "pattern": "^[a-zA-Z0-9_-]+$"
                      },
                      "title": {
                        "type": "string"
                      }
                    },
                    "required": ["id", "title"],
                    "additionalProperties": {}
                  }
                },
                "inventory": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string"
                    }
                  },
                  "required": ["kind"],
                  "additionalProperties": {}
                },
                "fulfillment": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string"
                    }
                  },
                  "required": ["kind"],
                  "additionalProperties": {}
                }
              },
              "required": ["id", "title", "tiers", "inventory", "fulfillment"],
              "additionalProperties": {}
            },
            "earnedTier": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "tier": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "revision": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "status": {
              "type": "string",
              "const": "collected"
            },
            "handover": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "startedAt": {
              "type": "number"
            },
            "allocation": {
              "type": "object",
              "properties": {
                "item": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100,
                  "pattern": "^[a-zA-Z0-9_-]+$"
                },
                "label": {
                  "type": "string"
                }
              },
              "required": ["item", "label"],
              "additionalProperties": {}
            },
            "collectedAt": {
              "type": "number"
            },
            "recovery": {
              "type": "object",
              "properties": {
                "completion": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100,
                  "pattern": "^[a-zA-Z0-9_-]+$"
                },
                "reason": {
                  "type": "string"
                },
                "flaggedAt": {
                  "type": "number"
                },
                "remainingTier": {
                  "anyOf": [
                    {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 100,
                      "pattern": "^[a-zA-Z0-9_-]+$"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": ["completion", "reason", "flaggedAt", "remainingTier"]
            }
          },
          "required": [
            "id",
            "member",
            "reward",
            "earnedTier",
            "tier",
            "revision",
            "status",
            "handover",
            "startedAt",
            "collectedAt"
          ],
          "additionalProperties": {}
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "member": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "reward": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100,
                  "pattern": "^[a-zA-Z0-9_-]+$"
                },
                "title": {
                  "type": "string"
                },
                "tiers": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100,
                        "pattern": "^[a-zA-Z0-9_-]+$"
                      },
                      "title": {
                        "type": "string"
                      }
                    },
                    "required": ["id", "title"],
                    "additionalProperties": {}
                  }
                },
                "inventory": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string"
                    }
                  },
                  "required": ["kind"],
                  "additionalProperties": {}
                },
                "fulfillment": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string"
                    }
                  },
                  "required": ["kind"],
                  "additionalProperties": {}
                }
              },
              "required": ["id", "title", "tiers", "inventory", "fulfillment"],
              "additionalProperties": {}
            },
            "earnedTier": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "tier": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "revision": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "status": {
              "type": "string",
              "const": "void"
            },
            "voidedAt": {
              "type": "number"
            }
          },
          "required": [
            "id",
            "member",
            "reward",
            "earnedTier",
            "tier",
            "revision",
            "status",
            "voidedAt"
          ],
          "additionalProperties": {}
        }
      ]
    },
    {}
  ]
}
