{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://recit.dev/schema/v1/webtoon.json",
  "x-recit-stability": "stable",
  "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": "webtoon"
    },
    "settings": {
      "type": "object",
      "properties": {
        "width": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "gutter": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "background": {
          "type": "string",
          "minLength": 1
        },
        "font": {
          "type": "string",
          "minLength": 1
        },
        "direction": {
          "type": "string",
          "enum": [
            "ltr",
            "rtl"
          ]
        },
        "budget": {
          "type": "object",
          "properties": {
            "panelBytes": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            },
            "episodeBytes": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            }
          },
          "additionalProperties": false
        },
        "pacing": {
          "type": "object",
          "properties": {
            "maxPanelBubbles": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            },
            "maxBubbleWords": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            }
          },
          "additionalProperties": false
        },
        "pdf": {
          "type": "object",
          "properties": {
            "outline": {
              "type": "boolean"
            },
            "tagged": {
              "type": "boolean"
            },
            "colorMode": {
              "type": "string",
              "enum": [
                "light",
                "dark"
              ]
            },
            "theme": {
              "not": {}
            },
            "output": {
              "type": "string",
              "minLength": 1
            },
            "pagination": {
              "type": "string",
              "enum": [
                "panels"
              ]
            },
            "pageHeight": {
              "type": "string",
              "pattern": "^(?:0|\\d+(?:\\.\\d+)?(?:mm|cm|in|pt|pc|px))$"
            },
            "maxBytes": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            }
          },
          "additionalProperties": false
        },
        "images": {
          "type": "object",
          "properties": {
            "preset": {
              "type": "string",
              "enum": [
                "webtoon-canvas",
                "tapas"
              ]
            },
            "width": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            },
            "sliceHeight": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            },
            "format": {
              "type": "string",
              "enum": [
                "png",
                "jpeg",
                "webp"
              ]
            },
            "quality": {
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 1
            },
            "maxBytes": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            },
            "avoidLettering": {
              "type": "boolean"
            }
          },
          "additionalProperties": false
        },
        "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": {}
                }
              }
            }
          ]
        }
      },
      "additionalProperties": {}
    },
    "scenes": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "src": {
            "type": "string",
            "minLength": 1
          },
          "alt": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "type": "string"
                }
              }
            ]
          },
          "height": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991
          },
          "gutter": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "background": {
            "type": "string",
            "minLength": 1
          },
          "attrs": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            }
          },
          "lettering": {
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "bubble"
                    },
                    "x": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 100
                    },
                    "y": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 100
                    },
                    "text": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "string"
                          }
                        }
                      ]
                    },
                    "w": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 100
                    },
                    "tail": {
                      "type": "string",
                      "enum": [
                        "bottom-left",
                        "bottom",
                        "bottom-right",
                        "top-left",
                        "top",
                        "top-right",
                        "left",
                        "right",
                        "none"
                      ]
                    },
                    "shape": {
                      "type": "string",
                      "enum": [
                        "speech",
                        "thought",
                        "shout",
                        "whisper"
                      ]
                    },
                    "cast": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "type",
                    "text"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "caption"
                    },
                    "x": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 100
                    },
                    "y": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 100
                    },
                    "text": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "string"
                          }
                        }
                      ]
                    },
                    "w": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 100
                    }
                  },
                  "required": [
                    "type",
                    "text"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "sfx"
                    },
                    "x": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 100
                    },
                    "y": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 100
                    },
                    "text": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "string"
                          }
                        }
                      ]
                    },
                    "rotate": {
                      "type": "number",
                      "minimum": -180,
                      "maximum": 180
                    },
                    "size": {
                      "type": "string",
                      "enum": [
                        "s",
                        "m",
                        "l",
                        "xl"
                      ]
                    },
                    "narrative": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "type",
                    "text"
                  ],
                  "additionalProperties": false
                }
              ]
            }
          },
          "characters": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "character": {
                  "type": "string",
                  "minLength": 1
                },
                "pose": {
                  "type": "string",
                  "pattern": "^[a-z0-9][\\w-]*$"
                },
                "expression": {
                  "type": "string",
                  "pattern": "^[a-z0-9][\\w-]*$"
                },
                "animation": {
                  "type": "string",
                  "pattern": "^[a-z0-9][\\w-]*$"
                },
                "render": {
                  "type": "string",
                  "pattern": "^[a-z0-9][\\w-]*$"
                },
                "variant": {
                  "type": "string",
                  "pattern": "^[a-z0-9][\\w-]*$"
                },
                "x": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100
                },
                "y": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100
                },
                "h": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100
                },
                "alt": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "string"
                      }
                    }
                  ]
                }
              },
              "required": [
                "character"
              ],
              "additionalProperties": false
            },
            "x-recit-stability": "preview"
          },
          "body": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "type": "string"
                }
              }
            ]
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "type": "string"
                }
              }
            ]
          }
        },
        "required": [
          "id"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "kind",
    "version",
    "meta",
    "format",
    "scenes"
  ],
  "additionalProperties": false
}
