{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://nodedc.ru/schemas/design-profile-v0.1.schema.json",
  "title": "NODE.DC Design Profile v0.1",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "id", "name", "version", "status", "layout", "timestamps"],
  "properties": {
    "schemaVersion": { "const": "0.1.0" },
    "id": { "type": "string", "anyOf": [{ "const": "default" }, { "format": "uuid" }] },
    "name": { "type": "string", "minLength": 1, "maxLength": 120 },
    "version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
    "status": { "enum": ["draft", "published"] },
    "layout": {
      "type": "object",
      "additionalProperties": false,
      "required": ["theme", "accentHex", "materialByTheme", "environment", "media", "glass", "toolbar"],
      "properties": {
        "theme": { "enum": ["dark", "light"] },
        "accentHex": { "$ref": "#/$defs/hex" },
        "materialByTheme": {
          "type": "object",
          "additionalProperties": false,
          "required": ["dark", "light"],
          "properties": {
            "dark": { "$ref": "#/$defs/material" },
            "light": { "$ref": "#/$defs/material" }
          }
        },
        "environment": {
          "type": "object",
          "additionalProperties": false,
          "required": ["lightColor", "brightness", "glowDistance", "connectionType", "connectionColor", "usePortColors", "fillColor", "fillOpacity", "strokeColor", "strokeOpacity"],
          "properties": {
            "lightColor": { "$ref": "#/$defs/hex" },
            "brightness": { "$ref": "#/$defs/percent" },
            "glowDistance": { "type": "number", "minimum": 0, "maximum": 500 },
            "connectionType": { "type": "string", "minLength": 1, "maxLength": 64 },
            "connectionColor": { "$ref": "#/$defs/hex" },
            "usePortColors": { "type": "boolean" },
            "fillColor": { "$ref": "#/$defs/hex" },
            "fillOpacity": { "$ref": "#/$defs/percent" },
            "strokeColor": { "$ref": "#/$defs/hex" },
            "strokeOpacity": { "$ref": "#/$defs/percent" }
          }
        },
        "media": {
          "type": "object",
          "additionalProperties": false,
          "required": ["source", "url", "fileName", "fileSrc", "visible", "logoSource", "logoUrl", "logoFileName", "logoFileSrc", "faviconFileName", "faviconAssets"],
          "properties": {
            "source": { "enum": ["file", "url"] },
            "url": { "type": "string" },
            "fileName": { "type": "string" },
            "fileSrc": { "type": "string" },
            "visible": { "type": "boolean" },
            "logoSource": { "enum": ["file", "url"] },
            "logoUrl": { "type": "string" },
            "logoFileName": { "type": "string" },
            "logoFileSrc": { "type": "string" },
            "faviconFileName": { "type": "string" },
            "faviconAssets": {
              "type": "object",
              "additionalProperties": false,
              "required": ["ico", "apple", "icon192", "icon512"],
              "properties": {
                "ico": { "type": "string", "minLength": 1 },
                "apple": { "type": "string", "minLength": 1 },
                "icon192": { "type": "string", "minLength": 1 },
                "icon512": { "type": "string", "minLength": 1 }
              }
            }
          }
        },
        "glass": {
          "type": "object",
          "additionalProperties": false,
          "required": ["version", "tintHex", "tintOpacity", "blur", "saturation", "brightness", "outlineOpacity", "shadowOpacity"],
          "properties": {
            "version": { "const": 4 },
            "tintHex": { "$ref": "#/$defs/hex" },
            "tintOpacity": { "$ref": "#/$defs/percent" },
            "blur": { "type": "number", "minimum": 0, "maximum": 120 },
            "saturation": { "type": "number", "minimum": 0, "maximum": 300 },
            "brightness": { "type": "number", "minimum": 0, "maximum": 200 },
            "outlineOpacity": { "$ref": "#/$defs/percent" },
            "shadowOpacity": { "$ref": "#/$defs/percent" }
          }
        },
        "toolbar": {
          "type": "object",
          "additionalProperties": false,
          "required": ["placement", "background", "border", "outline", "minSize", "maxSize", "lensCount", "autoHide"],
          "properties": {
            "placement": { "enum": ["left", "right", "bottom"] },
            "background": { "$ref": "#/$defs/hex" },
            "border": { "$ref": "#/$defs/hex" },
            "outline": { "$ref": "#/$defs/hex" },
            "minSize": { "type": "number", "minimum": 16, "maximum": 64 },
            "maxSize": { "type": "number", "minimum": 32, "maximum": 160 },
            "lensCount": { "type": "integer", "minimum": 1, "maximum": 12 },
            "autoHide": { "type": "boolean" }
          }
        }
      }
    },
    "timestamps": {
      "type": "object",
      "additionalProperties": false,
      "required": ["createdAt", "updatedAt"],
      "properties": {
        "createdAt": { "type": "string", "format": "date-time" },
        "updatedAt": { "type": "string", "format": "date-time" },
        "publishedAt": { "type": "string", "format": "date-time" }
      }
    }
  },
  "$defs": {
    "hex": { "type": "string", "pattern": "^#[0-9a-fA-F]{6}$" },
    "percent": { "type": "number", "minimum": 0, "maximum": 100 },
    "material": {
      "type": "object",
      "additionalProperties": false,
      "required": ["panelHex", "panelOpacity", "fieldHex", "fieldOpacity", "nestedHex"],
      "properties": {
        "panelHex": { "$ref": "#/$defs/hex" },
        "panelOpacity": { "$ref": "#/$defs/percent" },
        "fieldHex": { "$ref": "#/$defs/hex" },
        "fieldOpacity": { "$ref": "#/$defs/percent" },
        "nestedHex": { "$ref": "#/$defs/hex" }
      }
    }
  }
}
