{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "askId": { "type": "string" },
    "allowClosing": { "type": "boolean" },
    "type": {
      "type": "string",
      "enum": ["routine", "critical"]
    },
    "message": { "type": "string" },
    "title": { "type": "string" },
    "optionsType": {
      "type": "string",
      "enum": ["button", "product"]
    },
    "timeout": { "type": "number" },
    "defaultOptionId": { "type": "string" }
  },
  "required": ["message", "title", "optionsType"],
  "if": {
    "properties": { "optionsType": { "const": "button" } }
  },
  "then": {
    "properties": {
      "options": { "$ref": "#/definitions/ButtonOptions" }
    },
    "required": ["options"]
  },
  "else": {
    "properties": {
      "options": { "$ref": "#/definitions/ProductOptions" }
    },
    "required": ["options"]
  },
  "definitions": {
    "ButtonOptions": {
      "type": "array",
      "minItems": 2,
      "items": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "id": { "type": "string" },
          "button": {
            "type": "object",
            "additionalProperties": true,
            "properties": {
              "label": { "type": "string" },
              "type": {
                "type": "string",
                "enum": ["primary", "secondary", "link", "abort"]
              }
            },
            "required": ["type", "label"]
          }
        },
        "required": ["id", "button"]
      }
    },
    "ProductOptions": {
      "type": "array",
      "minItems": 2,
      "items": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "id": { "type": "string" },
          "product": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "required": ["id", "product"]
      }
    }
  }
}
