{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://recit.dev/schema/v1/form.json",
  "x-recit-stability": "preview",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string"
    },
    "kind": {
      "type": "string",
      "const": "story"
    },
    "version": {
      "type": "number",
      "const": 1
    },
    "syntax": {
      "type": "string",
      "enum": [
        "md",
        "mdx"
      ]
    },
    "preamble": {
      "type": "string"
    },
    "meta": {
      "type": "object",
      "properties": {
        "title": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": "string"
              }
            }
          ]
        },
        "subtitle": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": "string"
              }
            }
          ]
        },
        "description": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": "string"
              }
            }
          ]
        },
        "author": {
          "type": "string"
        },
        "date": {
          "type": "string"
        },
        "lang": {
          "type": "string"
        },
        "duration": {
          "anyOf": [
            {
              "type": "number",
              "exclusiveMinimum": 0
            },
            {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {
                    "type": "string"
                  }
                }
              ]
            }
          ],
          "description": "Duration of the story: minutes as a positive number, or a short text (optionally per language)."
        },
        "audience": {
          "description": "Target audience of the story (string or per-language map).",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": "string"
              }
            }
          ]
        },
        "level": {
          "type": "string",
          "enum": [
            "flash",
            "talk",
            "deep-dive"
          ],
          "description": "Format or depth level of the story: flash, talk, or deep-dive."
        }
      },
      "additionalProperties": false
    },
    "data": {
      "type": "object",
      "propertyNames": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9_-]*$"
      },
      "additionalProperties": {
        "anyOf": [
          {
            "type": "string",
            "minLength": 1
          },
          {
            "type": "object",
            "properties": {
              "src": {
                "type": "string",
                "minLength": 1
              },
              "format": {
                "type": "string",
                "enum": [
                  "csv",
                  "json",
                  "yaml"
                ]
              },
              "columns": {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "type": "string",
                  "enum": [
                    "string",
                    "number",
                    "date",
                    "boolean"
                  ]
                }
              }
            },
            "required": [
              "src"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "rows": {
                "type": "array",
                "items": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {
                    "type": [
                      "string",
                      "number",
                      "boolean",
                      "null"
                    ]
                  }
                }
              },
              "columns": {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "type": "string",
                  "enum": [
                    "string",
                    "number",
                    "date",
                    "boolean"
                  ]
                }
              },
              "meta": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "description": "Title of the dataset (DCAT `title`)."
                  },
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "description": "HTTP or HTTPS address of the dataset (`https:` or `http:`)."
                  },
                  "publisher": {
                    "type": "string",
                    "description": "Organisation or author publishing the dataset (DCAT `publisher`)."
                  },
                  "license": {
                    "type": "string",
                    "description": "Name or URL of the dataset's license (DCAT `license`)."
                  },
                  "modified": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
                      },
                      {
                        "type": "string",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d))|(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?)$"
                      }
                    ],
                    "description": "Last modification date (`YYYY-MM-DD`) or ISO 8601 date-time (DCAT `modified`)."
                  }
                },
                "additionalProperties": false,
                "description": "Provenance metadata of a data source (DCAT field names), used by `::chart` when `source=` is omitted."
              }
            },
            "required": [
              "rows"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "chart": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "chart"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "source": {
                "type": "string",
                "pattern": "^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$"
              }
            },
            "required": [
              "source"
            ],
            "additionalProperties": {},
            "x-recit-stability": "stable",
            "description": "A data source of a Récit plugin: its other keys are checked by the plugin."
          }
        ]
      }
    },
    "format": {
      "type": "string",
      "const": "form"
    },
    "settings": {
      "type": "object",
      "properties": {
        "colorMode": {
          "type": "string",
          "enum": [
            "light",
            "dark",
            "system"
          ]
        },
        "theme": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^(?!(?:light|dark|system)$)"
            },
            {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "primary": {
                  "type": "string"
                },
                "accent": {
                  "type": "string"
                },
                "fontSans": {
                  "type": "string",
                  "minLength": 1
                },
                "fontMono": {
                  "type": "string",
                  "minLength": 1
                },
                "customCss": {
                  "type": "string"
                },
                "colors": {
                  "type": "object",
                  "properties": {
                    "primary": {
                      "type": "string"
                    },
                    "primaryForeground": {
                      "type": "string"
                    },
                    "accent": {
                      "type": "string"
                    },
                    "accentForeground": {
                      "type": "string"
                    },
                    "background": {
                      "type": "string"
                    },
                    "foreground": {
                      "type": "string"
                    },
                    "card": {
                      "type": "string"
                    },
                    "cardForeground": {
                      "type": "string"
                    },
                    "border": {
                      "type": "string"
                    },
                    "muted": {
                      "type": "string"
                    },
                    "mutedForeground": {
                      "type": "string"
                    }
                  }
                },
                "dark": {
                  "type": "object",
                  "properties": {
                    "primary": {
                      "type": "string"
                    },
                    "primaryForeground": {
                      "type": "string"
                    },
                    "accent": {
                      "type": "string"
                    },
                    "accentForeground": {
                      "type": "string"
                    },
                    "background": {
                      "type": "string"
                    },
                    "foreground": {
                      "type": "string"
                    },
                    "card": {
                      "type": "string"
                    },
                    "cardForeground": {
                      "type": "string"
                    },
                    "border": {
                      "type": "string"
                    },
                    "muted": {
                      "type": "string"
                    },
                    "mutedForeground": {
                      "type": "string"
                    }
                  }
                },
                "chart": {
                  "type": "object",
                  "properties": {
                    "roles": {
                      "type": "object",
                      "properties": {
                        "reference": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "object",
                              "properties": {
                                "light": {
                                  "type": "string"
                                },
                                "dark": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "light",
                                "dark"
                              ],
                              "additionalProperties": false
                            }
                          ],
                          "description": "A CSS color for both modes, or { light, dark }."
                        },
                        "alert": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "object",
                              "properties": {
                                "light": {
                                  "type": "string"
                                },
                                "dark": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "light",
                                "dark"
                              ],
                              "additionalProperties": false
                            }
                          ],
                          "description": "A CSS color for both modes, or { light, dark }."
                        },
                        "solution": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "object",
                              "properties": {
                                "light": {
                                  "type": "string"
                                },
                                "dark": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "light",
                                "dark"
                              ],
                              "additionalProperties": false
                            }
                          ],
                          "description": "A CSS color for both modes, or { light, dark }."
                        },
                        "context": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "object",
                              "properties": {
                                "light": {
                                  "type": "string"
                                },
                                "dark": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "light",
                                "dark"
                              ],
                              "additionalProperties": false
                            }
                          ],
                          "description": "A CSS color for both modes, or { light, dark }."
                        }
                      },
                      "additionalProperties": false,
                      "description": "Colors of the four semantic chart roles (reference, alert, solution, context), each a color or { light, dark }."
                    },
                    "sequential": {
                      "anyOf": [
                        {
                          "minItems": 5,
                          "maxItems": 5,
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "object",
                          "properties": {
                            "light": {
                              "minItems": 5,
                              "maxItems": 5,
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "dark": {
                              "minItems": 5,
                              "maxItems": 5,
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          },
                          "required": [
                            "light",
                            "dark"
                          ],
                          "additionalProperties": false
                        }
                      ],
                      "description": "5 colors for the sequential scale, one list for both modes or { light, dark }."
                    },
                    "diverging": {
                      "anyOf": [
                        {
                          "minItems": 7,
                          "maxItems": 7,
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "object",
                          "properties": {
                            "light": {
                              "minItems": 7,
                              "maxItems": 7,
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "dark": {
                              "minItems": 7,
                              "maxItems": 7,
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          },
                          "required": [
                            "light",
                            "dark"
                          ],
                          "additionalProperties": false
                        }
                      ],
                      "description": "7 colors for the diverging scale, one list for both modes or { light, dark }."
                    }
                  },
                  "additionalProperties": false,
                  "description": "Chart palette overrides (plan 55 D4, GR10): semantic role colors and sequential (5 steps) or diverging (7 steps) scales, in light and dark modes."
                },
                "radius": {
                  "type": "string"
                },
                "fonts": {
                  "type": "object",
                  "properties": {
                    "sans": {
                      "type": "string",
                      "minLength": 1
                    },
                    "mono": {
                      "type": "string",
                      "minLength": 1
                    },
                    "heading": {
                      "type": "string",
                      "minLength": 1
                    },
                    "lettering": {
                      "type": "string",
                      "minLength": 1,
                      "description": "The lettering of a webtoon (bubbles, captions and sound effects); defaults to the theme's body font."
                    }
                  }
                },
                "mermaid": {
                  "type": "object",
                  "properties": {
                    "fontSize": {
                      "type": "number",
                      "exclusiveMinimum": 0
                    }
                  }
                },
                "defaultMode": {
                  "not": {}
                },
                "tokens": {
                  "not": {}
                }
              }
            }
          ]
        },
        "form": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9-]*$"
            },
            "endpoint": {
              "type": "string",
              "minLength": 1
            },
            "contract": {
              "type": "string",
              "enum": [
                "recit",
                "openapi",
                "formspree"
              ]
            },
            "submit": {
              "type": "string",
              "enum": [
                "fetch",
                "native",
                "mock"
              ]
            },
            "encoding": {
              "type": "string",
              "enum": [
                "form",
                "json"
              ]
            },
            "antispam": {
              "type": "string",
              "enum": [
                "honeypot",
                "turnstile",
                "none"
              ]
            },
            "auth": {
              "type": "string",
              "enum": [
                "none",
                "publishable-key",
                "bearer"
              ]
            },
            "publishableKey": {
              "type": "string",
              "minLength": 1
            },
            "turnstileSiteKey": {
              "type": "string",
              "minLength": 1
            },
            "privacy": {
              "type": "string",
              "minLength": 1
            },
            "retention": {
              "type": "integer",
              "minimum": 1,
              "maximum": 3650
            },
            "upload": {
              "type": "string",
              "enum": [
                "multipart",
                "presigned"
              ]
            },
            "progress": {
              "type": "string",
              "enum": [
                "steps",
                "bar",
                "none"
              ]
            },
            "review": {
              "type": "boolean"
            }
          },
          "required": [
            "id"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "form"
      ],
      "additionalProperties": false
    },
    "scenes": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "attrs": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            }
          },
          "body": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "type": "string"
                }
              }
            ]
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "type": "string"
                }
              }
            ]
          },
          "when": {
            "type": "string",
            "pattern": "^(!?[A-Za-z][A-Za-z0-9_.-]*|[A-Za-z][A-Za-z0-9_.-]*!?=[^=]*)$"
          },
          "end": {
            "type": "boolean",
            "const": true
          }
        },
        "required": [
          "id"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "kind",
    "version",
    "meta",
    "format",
    "settings",
    "scenes"
  ],
  "additionalProperties": false
}
