{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://redbook.fun/specification/1.0/schemas/extension-declaration.schema.json",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "minLength": 1
    },
    "version": {
      "type": "string",
      "minLength": 1
    },
    "kind": {
      "enum": [
        "supplied-core",
        "viewbox-type",
        "theme",
        "plugin"
      ]
    },
    "target": {
      "enum": [
        "redbook",
        "viewbox"
      ]
    },
    "entry": {
      "type": "string",
      "minLength": 1,
      "pattern": "^(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*\\.(?:/|$))[A-Za-z0-9_.-]+(?:/[A-Za-z0-9_.-]+)*(?![\\s\\S])"
    },
    "export": {
      "type": "string",
      "minLength": 1
    },
    "requirements": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "uniqueItems": true
    },
    "configuration": {
      "$ref": "https://redbook.fun/specification/1.0/schemas/value.schema.json#/$defs/map"
    },
    "installationId": {
      "type": "string",
      "minLength": 1
    },
    "targetId": {
      "type": "string",
      "minLength": 1
    },
    "manifestPart": {
      "type": "string",
      "minLength": 1,
      "pattern": "^(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*\\.(?:/|$))[A-Za-z0-9_.-]+(?:/[A-Za-z0-9_.-]+)*(?![\\s\\S])"
    },
    "state": {
      "$ref": "https://redbook.fun/specification/1.0/schemas/value.schema.json"
    },
    "resourceKey": {
      "type": "string",
      "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}(?![\\s\\S])"
    },
    "payloadRoot": {
      "type": "string",
      "pattern": "^redbook/installations/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/(?![\\s\\S])"
    },
    "enabled": {
      "type": "boolean"
    },
    "order": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    }
  },
  "required": [
    "id",
    "version",
    "kind",
    "target",
    "entry",
    "configuration"
  ],
  "additionalProperties": {
    "$ref": "https://redbook.fun/specification/1.0/schemas/value.schema.json"
  },
  "allOf": [
    {
      "if": {
        "required": [
          "installationId"
        ]
      },
      "then": {
        "required": [
          "targetId",
          "manifestPart",
          "resourceKey",
          "payloadRoot",
          "enabled",
          "order"
        ],
        "properties": {
          "kind": {
            "enum": [
              "theme",
              "plugin"
            ]
          }
        }
      }
    }
  ]
}
