{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "description": "Project name, must be unique in the workspace"
    },
    "extends": {
      "description": "Extend styles from other config files",
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "minItems": 1,
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      ]
    },
    "title": {
      "description": "A human readable title for the project",
      "type": "string",
      "minLength": 1
    },
    "contactPerson": {
      "description": "A person who has been involved in creating or maintaining this project",
      "type": "string",
      "minLength": 1
    },
    "metadata": {
      "description": "Arbitrary metadata as key-value pairs for custom project information",
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {}
    },
    "styles": {
      "description": "Project styles customization",
      "type": "object",
      "properties": {
        "theme": {
          "description": "Project theme customization",
          "$ref": "#/$defs/ThemeCustomization"
        },
        "defaults": {
          "description": "Override default values for style properties\nThese values will be used if such property is not defined",
          "$ref": "#/$defs/DefaultStyleValues"
        },
        "customCss": {
          "description": "Custom CSS (or list of CSS files) to be included in the generated diagrams",
          "$ref": "#/$defs/CustomStylesheets"
        }
      },
      "additionalProperties": false
    },
    "imageAliases": {
      "$ref": "#/$defs/ImageAliases"
    },
    "include": {
      "$ref": "#/$defs/include-config"
    },
    "exclude": {
      "description": "List of file patterns to exclude from the project, default is [\"**/node_modules/**\"]",
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "manualLayouts": {
      "$ref": "#/$defs/ManualLayoutsConfig"
    },
    "inferTechnologyFromIcon": {
      "description": "Automatically derive element technology from icon name when technology is not set explicitly.\nApplies to aws:, azure:, gcp:, and tech: icons. Bootstrap icons are excluded.\nDefaults to true.",
      "type": "boolean"
    },
    "implicitViews": {
      "description": "Auto-generate scoped views for elements without explicit views. Defaults to false.",
      "type": "boolean"
    },
    "landingPage": {
      "$ref": "#/$defs/LandingPageConfig"
    }
  },
  "required": [
    "name"
  ],
  "description": "LikeC4 Project Configuration",
  "$defs": {
    "ThemeCustomization": {
      "type": "object",
      "properties": {
        "colors": {
          "description": "Override theme colors",
          "type": "object",
          "propertyNames": {
            "$ref": "#/$defs/ColorName"
          },
          "additionalProperties": {
            "$ref": "#/$defs/ThemeColorValues"
          }
        },
        "sizes": {
          "description": "Override theme sizes",
          "type": "object",
          "propertyNames": {
            "$ref": "#/$defs/ElementSize"
          },
          "additionalProperties": {
            "$ref": "#/$defs/Dimensions"
          }
        }
      },
      "additionalProperties": false,
      "description": "Customize theme colors and sizes"
    },
    "ThemeColorName": {
      "type": "string",
      "enum": [
        "amber",
        "blue",
        "gray",
        "slate",
        "green",
        "indigo",
        "muted",
        "primary",
        "red",
        "secondary",
        "sky"
      ]
    },
    "CustomColorName": {},
    "ColorName": {
      "anyOf": [
        {
          "$ref": "#/$defs/ThemeColorName"
        },
        {
          "$ref": "#/$defs/CustomColorName"
        }
      ]
    },
    "ThemeColorValues": {
      "description": "Exact value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color values",
      "anyOf": [
        {
          "$ref": "#/$defs/StrictThemeColorValues"
        },
        {
          "$ref": "#/$defs/ColorLiteral"
        }
      ]
    },
    "StrictThemeColorValues": {
      "description": "Exact color value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color value",
      "type": "object",
      "properties": {
        "elements": {
          "anyOf": [
            {
              "$ref": "#/$defs/ElementColorValues"
            },
            {
              "$ref": "#/$defs/ColorLiteral"
            }
          ],
          "description": "Exact color value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color values"
        },
        "relationships": {
          "anyOf": [
            {
              "$ref": "#/$defs/RelationshipColorValues"
            },
            {
              "$ref": "#/$defs/ColorLiteral"
            }
          ],
          "description": "Exact color value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color values"
        }
      },
      "required": [
        "elements",
        "relationships"
      ],
      "additionalProperties": false
    },
    "ElementColorValues": {
      "type": "object",
      "properties": {
        "fill": {
          "description": "Background color",
          "$ref": "#/$defs/ColorLiteral"
        },
        "stroke": {
          "description": "Stroke color (border, paths above background)",
          "$ref": "#/$defs/ColorLiteral"
        },
        "hiContrast": {
          "description": "High contrast text color (title)",
          "$ref": "#/$defs/ColorLiteral"
        },
        "loContrast": {
          "description": "Low contrast text color (description)",
          "$ref": "#/$defs/ColorLiteral"
        }
      },
      "required": [
        "fill",
        "stroke",
        "hiContrast",
        "loContrast"
      ],
      "additionalProperties": false
    },
    "ColorLiteral": {
      "type": "string",
      "minLength": 1
    },
    "RelationshipColorValues": {
      "type": "object",
      "properties": {
        "line": {
          "description": "Line color",
          "$ref": "#/$defs/ColorLiteral"
        },
        "label": {
          "description": "Label text color",
          "$ref": "#/$defs/ColorLiteral"
        },
        "labelBg": {
          "default": "rgba(0, 0, 0, 0.5)",
          "description": "Label background color",
          "$ref": "#/$defs/ColorLiteral"
        }
      },
      "required": [
        "line",
        "label"
      ],
      "additionalProperties": false
    },
    "ElementSize": {
      "type": "string",
      "enum": [
        "xs",
        "sm",
        "md",
        "lg",
        "xl"
      ]
    },
    "Dimensions": {
      "type": "object",
      "properties": {
        "width": {
          "type": "number",
          "minimum": 50
        },
        "height": {
          "type": "number",
          "minimum": 50
        }
      },
      "required": [
        "width",
        "height"
      ],
      "additionalProperties": false,
      "description": "Defines dimensions for theme size"
    },
    "DefaultStyleValues": {
      "type": "object",
      "properties": {
        "color": {
          "description": "Default color for elements\n(must be a valid color name from the theme)",
          "$ref": "#/$defs/ColorName"
        },
        "opacity": {
          "description": "Default opacity (0-100%) for elements when displayed as a group (like a container)",
          "$ref": "#/$defs/Opacity"
        },
        "border": {
          "description": "Default border style for elements when displayed as a group (like a container)",
          "$ref": "#/$defs/BorderStyle"
        },
        "size": {
          "description": "Default size for elements",
          "$ref": "#/$defs/ElementSize"
        },
        "shape": {
          "description": "Default shape for elements",
          "$ref": "#/$defs/ElementShape"
        },
        "iconPosition": {
          "description": "Default icon position for elements",
          "$ref": "#/$defs/IconPosition"
        },
        "group": {
          "description": "Override default values for group style properties\nThese values will be used if such property is not defined",
          "$ref": "#/$defs/GroupDefaultStyleValues"
        },
        "relationship": {
          "$ref": "#/$defs/RelationshipDefaultStyleValues"
        }
      },
      "additionalProperties": false
    },
    "Opacity": {
      "type": "integer",
      "minimum": 0,
      "maximum": 100,
      "description": "Opacity 0-100%"
    },
    "BorderStyle": {
      "type": "string",
      "enum": [
        "solid",
        "dashed",
        "dotted",
        "none"
      ]
    },
    "ElementShape": {
      "type": "string",
      "enum": [
        "rectangle",
        "person",
        "browser",
        "mobile",
        "cylinder",
        "storage",
        "queue",
        "bucket",
        "document",
        "component"
      ]
    },
    "IconPosition": {
      "type": "string",
      "enum": [
        "left",
        "right",
        "top",
        "bottom"
      ]
    },
    "GroupDefaultStyleValues": {
      "type": "object",
      "properties": {
        "color": {
          "description": "Default color for groups\n(must be a valid color name from the theme)",
          "$ref": "#/$defs/ColorName"
        },
        "opacity": {
          "description": "Default opacity for groups",
          "$ref": "#/$defs/Opacity"
        },
        "border": {
          "description": "Default border for groups",
          "$ref": "#/$defs/BorderStyle"
        }
      },
      "additionalProperties": false
    },
    "RelationshipDefaultStyleValues": {
      "type": "object",
      "properties": {
        "color": {
          "description": "Default color for relationships\n(must be a valid color name from the theme)",
          "$ref": "#/$defs/ColorName"
        },
        "line": {
          "description": "Default line style for relationships",
          "$ref": "#/$defs/LineType"
        },
        "arrow": {
          "description": "Default arrow style for relationships",
          "$ref": "#/$defs/ArrowType"
        }
      },
      "additionalProperties": false,
      "description": "Override default values for relationship style properties\nThese values will be used if such property is not defined"
    },
    "LineType": {
      "type": "string",
      "enum": [
        "dashed",
        "solid",
        "dotted"
      ]
    },
    "ArrowType": {
      "type": "string",
      "enum": [
        "none",
        "normal",
        "onormal",
        "dot",
        "odot",
        "diamond",
        "odiamond",
        "crow",
        "open",
        "vee"
      ]
    },
    "CustomStylesheets": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      ]
    },
    "ImageAliases": {
      "type": "object",
      "propertyNames": {
        "type": "string",
        "minLength": 1,
        "pattern": "^@[A-Za-z0-9_-]*$"
      },
      "additionalProperties": {
        "type": "string",
        "minLength": 1,
        "pattern": "^(?!\\/|[A-Za-z]:[\\\\\\/])(?!.*:\\/\\/).*$"
      },
      "description": "Map of image alias prefixes to relative paths (keys must match /^@\\w+$/; values must be relative paths without protocol or leading slash)."
    },
    "include-config": {
      "type": "object",
      "properties": {
        "paths": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "pattern": "^(?!\\/|[A-Za-z]:[\\\\\\/])(?!.*:\\/\\/).*$"
          },
          "description": "Additional relative directory paths to include LikeC4 source files from, searched recursively.\nPaths are relative to the project folder (the folder containing this config file).\nExample: [\"../shared\", \"../common/specs\"]"
        },
        "maxDepth": {
          "default": 3,
          "description": "Maximum directory depth to scan when searching for .c4 files in include paths.\nPrevents excessive scanning of deeply nested directories.\nDefault: 3",
          "type": "integer",
          "minimum": 1,
          "maximum": 20
        },
        "fileThreshold": {
          "default": 30,
          "description": "Maximum number of files to load from include paths before warning.\nHelps identify performance issues from accidentally including large directories.\nDefault: 30",
          "type": "integer",
          "minimum": 1,
          "maximum": 10000
        }
      },
      "required": [
        "paths"
      ],
      "additionalProperties": false,
      "description": "Configuration for including additional LikeC4 source files from other directories.\nExample: { \"paths\": [\"../shared\", \"../common/specs\"], \"maxDepth\": 5, \"fileThreshold\": 50 }"
    },
    "ManualLayoutsConfig": {
      "type": "object",
      "properties": {
        "outDir": {
          "default": ".likec4",
          "description": "Path to the directory where manual layouts will be stored,\nrelative to the folder containing the project config. \n\nDefaults to '.likec4'.",
          "type": "string"
        }
      },
      "additionalProperties": false,
      "description": "Configuration for manual layouts"
    },
    "LandingPageConfig": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "redirect": {
              "type": "boolean",
              "const": true
            }
          },
          "required": [
            "redirect"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "include": {
              "minItems": 1,
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1
              }
            }
          },
          "required": [
            "include"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "exclude": {
              "minItems": 1,
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1
              }
            }
          },
          "required": [
            "exclude"
          ],
          "additionalProperties": false
        }
      ],
      "description": "Configure the landing page. Use redirect to go to the index view, or include/exclude to filter the view grid."
    }
  }
}