{
  "$defs": {
    "unit_options": {
      "additionalProperties": false,
      "description": "Options for the specific time unit.",
      "minProperties": 1,
      "properties": {
        "display": {
          "default": true,
          "description": "Whether the unit input should be displayed to the user.",
          "type": "boolean"
        },
        "return": {
          "default": true,
          "description": "Whether this unit should be returned as a separate value.",
          "type": "boolean"
        },
        "step": {
          "description": "The time segment size of the respective duration input.",
          "minimum": 1,
          "type": "integer"
        }
      },
      "type": "object"
    }
  },
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "A list of questions to choose from.",
  "items": {
    "additionalProperties": false,
    "description": "A question entry is defined of three main parts:\n- A basic question phrase later displayed to the user\n- An input type, which defines the UI element in the frontend as well as the written OSM tags\n-A set of conditions that define under which circumstances the question should be asked",
    "properties": {
      "$comment": {
        "description": "For documentation purpose only. Used to note hints, explanations, reasoning or exceptions for other programmers and your future self. Do not underestimate the power and fun of documentation C_C",
        "type": "string"
      },
      "answer": {
        "additionalProperties": false,
        "anyOf": [
          {
            "description": "Describes a text input field that allows any character.",
            "properties": {
              "input": {
                "additionalProperties": false,
                "properties": {
                  "max": {
                    "default": 255,
                    "description": "Restricts the maximum number of characters allowed by this input field.",
                    "maximum": 255,
                    "minimum": 0,
                    "type": "integer"
                  },
                  "min": {
                    "default": 0,
                    "description": "Restricts the minimum number of characters allowed by this input field.",
                    "maximum": 255,
                    "minimum": 0,
                    "type": "integer"
                  },
                  "placeholder": {
                    "description": "An optional placeholder for the input field.",
                    "type": "string"
                  }
                },
                "type": "object"
              },
              "type": {
                "const": "String"
              }
            },
            "required": [
              "constructor"
            ],
            "type": "object"
          },
          {
            "description": "Describes a number input field that allows numbers only.",
            "properties": {
              "input": {
                "additionalProperties": false,
                "properties": {
                  "decimals": {
                    "description": "Restricts the number of allowed decimals by this input field.",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "max": {
                    "description": "Limits the input value to a maximum value.",
                    "type": "integer"
                  },
                  "min": {
                    "description": "Limits the input value to a minimum value.",
                    "type": "integer"
                  },
                  "placeholder": {
                    "description": "An optional placeholder for the input field.",
                    "type": "string"
                  },
                  "unit": {
                    "description": "The unit of the input value that will be displayed at the end of the input field.",
                    "type": "string"
                  }
                },
                "type": "object"
              },
              "type": {
                "const": "Number"
              }
            },
            "required": [
              "constructor"
            ],
            "type": "object"
          },
          {
            "description": "Describes a time input field that allows entering a duration in different time units.",
            "properties": {
              "input": {
                "additionalProperties": false,
                "anyOf": [
                  {
                    "required": [
                      "days"
                    ]
                  },
                  {
                    "required": [
                      "hours"
                    ]
                  },
                  {
                    "required": [
                      "minutes"
                    ]
                  },
                  {
                    "required": [
                      "seconds"
                    ]
                  }
                ],
                "properties": {
                  "days": {
                    "$ref": "#/$defs/unit_options"
                  },
                  "hours": {
                    "$ref": "#/$defs/unit_options"
                  },
                  "max": {
                    "description": "The maximum allowed value for the biggest unit.",
                    "minimum": 1,
                    "type": "integer"
                  },
                  "minutes": {
                    "$ref": "#/$defs/unit_options"
                  },
                  "seconds": {
                    "$ref": "#/$defs/unit_options"
                  }
                },
                "type": "object"
              },
              "type": {
                "const": "Duration"
              }
            },
            "required": [
              "constructor"
            ],
            "type": "object"
          },
          {
            "description": "Describes an input with exactly two possible answers that allows the selection of one answer.",
            "properties": {
              "input": {
                "items": {
                  "additionalProperties": false,
                  "properties": {
                    "name": {
                      "description": "A short term describing this answer. If omitted the first entry will fallback to \"Yes\" and the second to \"No\".",
                      "type": "string"
                    },
                    "osm_tags": {
                      "additionalProperties": {
                        "type": "string"
                      },
                      "description": "All OSM tags that should apply when this entry is selected.",
                      "type": "object"
                    }
                  },
                  "required": [
                    "osm_tags"
                  ],
                  "type": "object"
                },
                "maxItems": 2,
                "minItems": 2,
                "type": "array"
              },
              "type": {
                "const": "Bool"
              }
            },
            "type": "object"
          },
          {
            "description": "Describes an input with multiple possible answers. List allows the selection of exactly one answer, while MultiList allows the selection of multiple answers.",
            "properties": {
              "input": {
                "items": {
                  "additionalProperties": false,
                  "properties": {
                    "description": {
                      "description": "Additional details and hints clarifying this answer.",
                      "type": "string"
                    },
                    "image": {
                      "description": "A single image describing this answer.",
                      "format": "uri-reference",
                      "type": "string"
                    },
                    "name": {
                      "description": "A short term describing this answer.",
                      "type": "string"
                    },
                    "osm_tags": {
                      "additionalProperties": {
                        "type": "string"
                      },
                      "description": "All OSM tags that should apply when this entry is selected.",
                      "type": "object"
                    }
                  },
                  "required": [
                    "osm_tags",
                    "name"
                  ],
                  "type": "object"
                },
                "minItems": 2,
                "type": "array"
              },
              "type": {
                "enum": [
                  "List",
                  "MultiList"
                ]
              }
            },
            "type": "object"
          }
        ],
        "description": "Holds properties to specify the UI input element and its constraints by which the question can be answered.",
        "properties": {
          "constructor": {
            "additionalProperties": {
              "$ref": "file:schemas/expression_schema.json"
            },
            "description": "The constructor ultimately creates the OSM tags to be written based on the given input value(s). Input types without predefined values like `String`, `Number` and `Duration` require a constructor, while all other types with predefined values have a default constructor that coalesces the selected values.\n The OSM tags to be written are defined by a key of type String and an expression that evaluates to a String. Expressions are defined by an array [] containing the expression identifier as the first element followed by a number of Strings as arguments. The input values can be accessed using the `$input` variable. If the expression starts with the `$input` variable the coalesce expression is assumed.",
            "minProperties": 1,
            "type": "object"
          },
          "input": {
            "description": "Holds any properties to configure the UI input element and its constraints. The contents of this property **vary in its structure and properties** depending on the input `type`.",
            "items": {
              "type": "object"
            },
            "minItems": 2,
            "type": [
              "array",
              "object"
            ]
          },
          "type": {
            "description": "Defines the UI input element used to answer the question.",
            "enum": [
              "String",
              "Number",
              "Duration",
              "Bool",
              "List",
              "MultiList"
            ]
          }
        },
        "required": [
          "type",
          "input"
        ],
        "type": "object"
      },
      "conditions": {
        "$ref": "file:schemas/osm_condition_schema.json"
      },
      "question": {
        "additionalProperties": false,
        "description": "This holds any to the question related information including the question itself.",
        "properties": {
          "description": {
            "description": "Details or further information describing this question.",
            "type": "string"
          },
          "image": {
            "description": "A list of image urls that may help to clarify this question.",
            "items": {
              "format": "uri-reference",
              "type": "string"
            },
            "minItems": 1,
            "type": "array"
          },
          "name": {
            "description": "A short term describing the content of the answer.",
            "type": "string"
          },
          "text": {
            "description": "The actual question. It should be kept as short as possible while still being comprehensible and independent of the context in which it is asked.",
            "type": "string"
          }
        },
        "required": [
          "name",
          "text"
        ],
        "type": "object"
      }
    },
    "required": [
      "question",
      "answer",
      "conditions"
    ],
    "type": "object"
  },
  "title": "Question Catalog",
  "type": "array"
}