{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "title": { "type": "string" },
    "items": { "$ref": "#/$defs/items" },
    "required": ["title", "items"],
    "additionalProperties": false
  },
  "$defs": {
    "toggle": {
      "type": "object",
      "properties": {
        "entity": { "$ref": "#/$defs/entity" },
        "name": { "type": "string" },
        "type": { "const": "toggle" }
      },
      "required": ["entity", "name", "type"],
      "additionalProperties": false
    },
    "tap": {
      "type": "object",
      "properties": {
        "entity": { "$ref": "#/$defs/entity" },
        "name": { "type": "string" },
        "type": { "const": "tap" },
        "service": { "$ref": "#/$defs/entity" }
      },
      "required": ["entity", "name", "type"],
      "additionalProperties": false
    },
    "menu": {
      "type": "object",
      "properties": {
        "entity": { "$ref": "#/$defs/entity" },
        "name": { "type": "string" },
        "title": { "type": "string" },
        "type": { "const": "group" },
        "items": { "$ref": "#/$defs/items" }
      },
      "required": ["entity", "name", "title", "type", "items"],
      "additionalProperties": false
    },
    "items": {
      "type": "array",
      "items": {
        "oneOf": [
          { "$ref": "#/$defs/toggle" },
          { "$ref": "#/$defs/tap" },
          { "$ref": "#/$defs/menu" }
        ]
      }
    },
    "entity": {
      "type": "string",
      "pattern": "^[^.]+\\.[^.]+$"
    }
  }
}
