{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.designfoundry.app/0.5/foundry-designsystem.schema.json",
  "type": "object",
  "properties": {
    "schemaVersion": {
      "const": "foundry-designsystem/0.5"
    },
    "system": {
      "type": "object",
      "properties": {
        "identifier": {
          "type": "string"
        },
        "displayName": {
          "type": [
            "string",
            "null"
          ]
        },
        "description": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "modes": {
      "type": "array",
      "items": {
        "type": [
          "object",
          "null"
        ],
        "properties": {
          "identifier": {
            "type": "string"
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "isDefault": {
            "type": "boolean"
          }
        }
      }
    },
    "tokens": {
      "type": "object",
      "properties": {
        "color": {
          "type": "array",
          "items": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "value": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "l": {
                    "type": [
                      "string",
                      "number"
                    ],
                    "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$"
                  },
                  "c": {
                    "type": [
                      "string",
                      "number"
                    ],
                    "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$"
                  },
                  "h": {
                    "type": [
                      "string",
                      "number"
                    ],
                    "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$"
                  },
                  "alpha": {
                    "type": [
                      "string",
                      "number",
                      "null"
                    ],
                    "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$"
                  }
                }
              },
              "source": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "description": "Mode identifier → identifier of the token this one takes its value from in that mode."
              },
              "modifiers": {
                "type": [
                  "array",
                  "null"
                ],
                "items": {
                  "type": [
                    "object",
                    "null"
                  ],
                  "properties": {
                    "channel": {
                      "type": "string"
                    },
                    "kind": {
                      "type": "string"
                    },
                    "value": {
                      "type": [
                        "string",
                        "number"
                      ],
                      "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$"
                    },
                    "token": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              },
              "identifier": {
                "type": "string"
              },
              "displayName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        },
        "dimension": {
          "type": "array",
          "items": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "value": {
                "type": [
                  "string",
                  "number",
                  "null"
                ],
                "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$"
              },
              "unit": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "source": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "modifiers": {
                "type": [
                  "array",
                  "null"
                ],
                "items": {
                  "$ref": "#/properties/tokens/properties/color/items/properties/modifiers/items"
                }
              },
              "identifier": {
                "type": "string"
              },
              "displayName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        },
        "duration": {
          "type": "array",
          "items": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "value": {
                "type": [
                  "string",
                  "number",
                  "null"
                ],
                "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$"
              },
              "unit": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "source": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "modifiers": {
                "type": [
                  "array",
                  "null"
                ],
                "items": {
                  "$ref": "#/properties/tokens/properties/color/items/properties/modifiers/items"
                }
              },
              "identifier": {
                "type": "string"
              },
              "displayName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "description": "A duration token: a value in ms or s, or an alias per mode."
          },
          "description": "Duration tokens, in ms or s."
        },
        "ratio": {
          "type": "array",
          "items": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "value": {
                "type": [
                  "string",
                  "number",
                  "null"
                ],
                "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$"
              },
              "source": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "modifiers": {
                "type": [
                  "array",
                  "null"
                ],
                "items": {
                  "$ref": "#/properties/tokens/properties/color/items/properties/modifiers/items"
                }
              },
              "identifier": {
                "type": "string"
              },
              "displayName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "description": "A ratio token: a unitless value, or an alias per mode."
          },
          "description": "Ratio tokens: unitless magnitudes such as line heights."
        },
        "opacity": {
          "type": "array",
          "items": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "value": {
                "type": [
                  "string",
                  "number",
                  "null"
                ],
                "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$"
              },
              "source": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "modifiers": {
                "type": [
                  "array",
                  "null"
                ],
                "items": {
                  "$ref": "#/properties/tokens/properties/color/items/properties/modifiers/items"
                }
              },
              "identifier": {
                "type": "string"
              },
              "displayName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "description": "An opacity token: a value from 0 to 1, or an alias per mode."
          },
          "description": "Opacity tokens, from 0 to 1."
        },
        "typography": {
          "type": "array",
          "items": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "fontStack": {
                "type": "string",
                "description": "The font role this style targets."
              },
              "fontSize": {
                "type": "string"
              },
              "lineHeight": {
                "type": "string"
              },
              "letterSpacing": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "axes": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": {
                  "type": [
                    "string",
                    "number"
                  ],
                  "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$"
                }
              },
              "features": {
                "type": [
                  "object",
                  "null"
                ],
                "description": "OpenType feature settings, tag → true / false / number, kept as authored."
              },
              "textTransform": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "textDecoration": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "identifier": {
                "type": "string"
              },
              "displayName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        },
        "border": {
          "type": "array",
          "items": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "width": {
                "type": "string"
              },
              "style": {
                "type": "string"
              },
              "color": {
                "type": "string"
              },
              "identifier": {
                "type": "string"
              },
              "displayName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        },
        "shadow": {
          "type": "array",
          "items": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "layers": {
                "type": "array",
                "items": {
                  "type": [
                    "object",
                    "null"
                  ],
                  "properties": {
                    "offsetX": {
                      "type": [
                        "string",
                        "number"
                      ],
                      "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$"
                    },
                    "offsetY": {
                      "type": [
                        "string",
                        "number"
                      ],
                      "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$"
                    },
                    "blur": {
                      "type": [
                        "string",
                        "number"
                      ],
                      "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$"
                    },
                    "spread": {
                      "type": [
                        "string",
                        "number"
                      ],
                      "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$"
                    },
                    "inset": {
                      "type": "boolean"
                    },
                    "color": {
                      "type": "string"
                    },
                    "colorModifiers": {
                      "type": [
                        "array",
                        "null"
                      ],
                      "items": {
                        "$ref": "#/properties/tokens/properties/color/items/properties/modifiers/items"
                      }
                    }
                  }
                }
              },
              "identifier": {
                "type": "string"
              },
              "displayName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        },
        "gradient": {
          "type": "array",
          "items": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "geometry": {
                "type": "string",
                "description": "\"linear\" (default), \"radial\" or \"conic\"."
              },
              "repeating": {
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "angle": {
                "type": [
                  "string",
                  "number",
                  "null"
                ],
                "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
                "description": "Degrees. Linear direction or conic \"from\" angle; absent on radial."
              },
              "shape": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Radial only: \"circle\" or \"ellipse\"."
              },
              "extent": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Radial only: \"closest-side\", \"closest-corner\", \"farthest-side\" or \"farthest-corner\"."
              },
              "center": {
                "type": [
                  "array",
                  "null"
                ],
                "items": {
                  "type": [
                    "string",
                    "number"
                  ],
                  "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$"
                },
                "description": "Radial and conic: x and y in percent of the box."
              },
              "stops": {
                "type": "array",
                "items": {
                  "type": [
                    "object",
                    "null"
                  ],
                  "properties": {
                    "position": {
                      "type": [
                        "string",
                        "number",
                        "null"
                      ],
                      "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
                      "description": "From 0 to 1. Omitted positions are spread evenly between their neighbours."
                    },
                    "color": {
                      "type": "string"
                    },
                    "colorModifiers": {
                      "type": [
                        "array",
                        "null"
                      ],
                      "items": {
                        "$ref": "#/properties/tokens/properties/color/items/properties/modifiers/items"
                      }
                    }
                  }
                }
              },
              "identifier": {
                "type": "string"
              },
              "displayName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "description": "A gradient token: a geometry and ordered colour stops. Fields that do not apply to the geometry must be absent."
          },
          "description": "Gradient tokens."
        },
        "easing": {
          "type": "array",
          "items": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "keyword": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "points": {
                "type": [
                  "array",
                  "null"
                ],
                "items": {
                  "type": [
                    "string",
                    "number"
                  ],
                  "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$"
                }
              },
              "steps": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "count": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "pattern": "^-?(?:0|[1-9]\\d*)$"
                  },
                  "position": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              },
              "identifier": {
                "type": "string"
              },
              "displayName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        }
      }
    },
    "organization": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "scales": {
          "type": "array",
          "items": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "identifier": {
                "type": "string"
              },
              "displayName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "kind": {
                "type": "string"
              },
              "members": {
                "type": "array",
                "items": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "base": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        },
        "collections": {
          "type": "array",
          "items": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "identifier": {
                "type": "string"
              },
              "displayName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "members": {
                "type": "array",
                "items": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "resources": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "fonts": {
          "type": "array",
          "items": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "identifier": {
                "type": "string"
              },
              "displayName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "provider": {
                "type": "string"
              },
              "key": {
                "type": "string"
              },
              "capabilities": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "axes": {
                    "type": "array",
                    "items": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "properties": {
                        "tag": {
                          "type": "string"
                        },
                        "domain": {
                          "type": "object",
                          "properties": {
                            "min": {
                              "type": [
                                "string",
                                "number",
                                "null"
                              ],
                              "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$"
                            },
                            "max": {
                              "type": [
                                "string",
                                "number",
                                "null"
                              ],
                              "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$"
                            },
                            "values": {
                              "type": [
                                "array",
                                "null"
                              ],
                              "items": {
                                "type": [
                                  "string",
                                  "number"
                                ],
                                "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$"
                              }
                            }
                          }
                        },
                        "default": {
                          "type": [
                            "string",
                            "number",
                            "null"
                          ],
                          "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$"
                        }
                      }
                    }
                  },
                  "features": {
                    "type": "array",
                    "items": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "subsets": {
                    "type": "array",
                    "items": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "familyVersion": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The font family's version."
                  },
                  "integrityHash": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "A hash of the font files, so a consumer can verify it received the same bytes."
                  }
                }
              },
              "provenance": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "license": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "attribution": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "sourceUrl": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              }
            }
          }
        },
        "fontStacks": {
          "type": "array",
          "items": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "identifier": {
                "type": "string"
              },
              "displayName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "entries": {
                "type": "array",
                "items": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "genericFallback": {
                "type": "string"
              }
            }
          }
        },
        "iconSets": {
          "type": "array",
          "items": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "identifier": {
                "type": "string"
              },
              "displayName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "provider": {
                "type": "string"
              },
              "key": {
                "type": "string"
              },
              "capabilities": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "setVersion": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "glyphs": {
                    "type": [
                      "array",
                      "null"
                    ],
                    "items": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "properties": {
                        "key": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "axes": {
                    "type": [
                      "array",
                      "null"
                    ],
                    "items": {
                      "$ref": "#/properties/resources/properties/fonts/items/properties/capabilities/properties/axes/items"
                    }
                  }
                }
              }
            }
          }
        },
        "iconAliases": {
          "type": "array",
          "items": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "identifier": {
                "type": "string"
              },
              "displayName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "target": {
                "type": "object",
                "properties": {
                  "set": {
                    "type": "string"
                  },
                  "glyph": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "description": "An authored design-system document: modes, tokens, resources and organization.",
  "required": [
    "schemaVersion"
  ]
}
