{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.greda.design/components.schema.json",
  "title": "Greda component registry",
  "type": "object",
  "required": [
    "$schema",
    "name",
    "version",
    "generatedFrom",
    "documentation",
    "stylesheet",
    "validator",
    "components"
  ],
  "properties": {
    "$schema": { "const": "./components.schema.json" },
    "name": { "type": "string" },
    "version": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+$" },
    "generatedFrom": { "const": "index.html" },
    "documentation": { "type": "string", "format": "uri" },
    "stylesheet": { "type": "string", "format": "uri" },
    "validator": { "type": "string" },
    "components": {
      "type": "array",
      "minItems": 1,
      "items": { "$ref": "#/$defs/component" }
    }
  },
  "additionalProperties": false,
  "$defs": {
    "stringList": {
      "type": "array",
      "items": { "type": "string" },
      "uniqueItems": true
    },
    "component": {
      "type": "object",
      "required": [
        "id",
        "name",
        "category",
        "description",
        "docs",
        "search",
        "classes",
        "tokens",
        "icons",
        "states",
        "requires",
        "accessibility",
        "implementation"
      ],
      "properties": {
        "id": { "type": "string", "pattern": "^[a-z0-9-]+$" },
        "name": { "type": "string" },
        "category": { "type": "string" },
        "description": { "type": "string" },
        "docs": { "type": "string", "format": "uri" },
        "search": { "$ref": "#/$defs/stringList" },
        "classes": { "$ref": "#/$defs/stringList" },
        "tokens": { "$ref": "#/$defs/stringList" },
        "icons": { "$ref": "#/$defs/stringList" },
        "states": { "$ref": "#/$defs/stringList" },
        "requires": { "$ref": "#/$defs/stringList" },
        "accessibility": { "$ref": "#/$defs/stringList" },
        "implementation": {
          "type": "object",
          "required": ["html", "javascript", "aiPrompt"],
          "properties": {
            "html": { "type": "string" },
            "javascript": { "type": "string" },
            "aiPrompt": { "type": "string" }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    }
  }
}
