{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "default_locale": {
      "type": "string",
      "pattern": "^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$"
    },
    "title": {
      "type": "object",
      "propertyNames": {
        "type": "string",
        "pattern": "^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$"
      },
      "additionalProperties": {
        "type": "string",
        "minLength": 1,
        "maxLength": 20000
      }
    },
    "summary": {
      "type": "object",
      "propertyNames": {
        "type": "string",
        "pattern": "^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$"
      },
      "additionalProperties": {
        "type": "string",
        "minLength": 1,
        "maxLength": 20000
      }
    },
    "region": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "themes": {
      "minItems": 1,
      "maxItems": 5,
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "vanlife",
          "patrimoine",
          "nature",
          "art",
          "spiritualité"
        ]
      }
    },
    "constraints": {
      "type": "object",
      "properties": {
        "duration_days": {
          "type": "integer",
          "minimum": 1,
          "maximum": 365
        },
        "seasons": {
          "minItems": 1,
          "maxItems": 12,
          "type": "array",
          "items": {
            "type": "integer",
            "minimum": 1,
            "maximum": 12
          }
        },
        "vehicle": {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "van",
                "camping-car",
                "voiture",
                "vélo",
                "à pied"
              ]
            },
            "max_height_m": {
              "anyOf": [
                {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "maximum": 10
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "type",
            "max_height_m"
          ],
          "additionalProperties": false
        },
        "budget_eur": {
          "type": "object",
          "properties": {
            "min": {
              "type": "number",
              "minimum": 0,
              "maximum": 1000000
            },
            "max": {
              "type": "number",
              "minimum": 0,
              "maximum": 1000000
            }
          },
          "required": [
            "min",
            "max"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "duration_days",
        "seasons",
        "vehicle",
        "budget_eur"
      ],
      "additionalProperties": false
    },
    "steps": {
      "minItems": 1,
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "order": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991
          },
          "day": {
            "type": "integer",
            "minimum": 1,
            "maximum": 365
          },
          "title": {
            "type": "object",
            "propertyNames": {
              "type": "string",
              "pattern": "^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$"
            },
            "additionalProperties": {
              "type": "string",
              "minLength": 1,
              "maxLength": 20000
            }
          },
          "location": {
            "type": "object",
            "properties": {
              "lat": {
                "type": "number",
                "minimum": -90,
                "maximum": 90
              },
              "lon": {
                "type": "number",
                "minimum": -180,
                "maximum": 180
              }
            },
            "required": [
              "lat",
              "lon"
            ],
            "additionalProperties": false
          },
          "narrative": {
            "type": "object",
            "propertyNames": {
              "type": "string",
              "pattern": "^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$"
            },
            "additionalProperties": {
              "type": "string",
              "minLength": 1,
              "maxLength": 20000
            }
          },
          "practical": {
            "type": "object",
            "properties": {
              "night_spot": {
                "type": "boolean"
              },
              "booking_required": {
                "type": "boolean"
              },
              "notes": {
                "type": "string",
                "maxLength": 3000
              }
            },
            "required": [
              "night_spot",
              "booking_required",
              "notes"
            ],
            "additionalProperties": false
          },
          "media": {
            "maxItems": 10,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "url": {
                  "type": "string",
                  "maxLength": 2000,
                  "format": "uri",
                  "pattern": "^https:\\/\\/.*"
                },
                "alt": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                }
              },
              "required": [
                "url",
                "alt"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "id",
          "order",
          "day",
          "title",
          "location",
          "narrative",
          "practical",
          "media"
        ],
        "additionalProperties": false
      }
    },
    "licence": {
      "type": "string",
      "enum": [
        "CC-BY-NC-4.0",
        "CC-BY-4.0",
        "CC-BY-SA-4.0",
        "CC0-1.0"
      ]
    },
    "editorial_status": {
      "type": "string",
      "enum": [
        "example",
        "creator_published"
      ]
    },
    "rihla_version": {
      "type": "string",
      "const": "1.0.0"
    },
    "id": {
      "type": "string",
      "pattern": "^rihla:[a-z0-9-]{3,100}$"
    },
    "version": {
      "type": "string",
      "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$"
    },
    "author": {
      "type": "object",
      "properties": {
        "handle": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9-]{2,39}$"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        }
      },
      "required": [
        "handle",
        "name"
      ],
      "additionalProperties": false
    },
    "lineage": {
      "type": "object",
      "properties": {
        "forked_from": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "pattern": "^rihla:.*"
                },
                "version": {
                  "type": "string",
                  "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$"
                },
                "title": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string",
                    "pattern": "^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$"
                  },
                  "additionalProperties": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 20000
                  }
                },
                "author": {
                  "type": "object",
                  "properties": {
                    "handle": {
                      "type": "string",
                      "pattern": "^[a-z0-9][a-z0-9-]{2,39}$"
                    },
                    "name": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    }
                  },
                  "required": [
                    "handle",
                    "name"
                  ],
                  "additionalProperties": false
                },
                "licence": {
                  "type": "string",
                  "enum": [
                    "CC-BY-NC-4.0",
                    "CC-BY-4.0",
                    "CC-BY-SA-4.0",
                    "CC0-1.0"
                  ]
                }
              },
              "required": [
                "id",
                "version",
                "title",
                "author",
                "licence"
              ],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        },
        "ancestors": {
          "maxItems": 50,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^rihla:.*"
              },
              "version": {
                "type": "string",
                "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$"
              },
              "title": {
                "type": "object",
                "propertyNames": {
                  "type": "string",
                  "pattern": "^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$"
                },
                "additionalProperties": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 20000
                }
              },
              "author": {
                "type": "object",
                "properties": {
                  "handle": {
                    "type": "string",
                    "pattern": "^[a-z0-9][a-z0-9-]{2,39}$"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": [
                  "handle",
                  "name"
                ],
                "additionalProperties": false
              },
              "licence": {
                "type": "string",
                "enum": [
                  "CC-BY-NC-4.0",
                  "CC-BY-4.0",
                  "CC-BY-SA-4.0",
                  "CC0-1.0"
                ]
              }
            },
            "required": [
              "id",
              "version",
              "title",
              "author",
              "licence"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "forked_from",
        "ancestors"
      ],
      "additionalProperties": false
    },
    "pricing": {
      "type": "object",
      "properties": {
        "model": {
          "type": "string",
          "const": "free"
        }
      },
      "required": [
        "model"
      ],
      "additionalProperties": false
    },
    "distribution": {
      "type": "object",
      "properties": {
        "exports": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "rihla",
              "gpx",
              "geojson",
              "kml"
            ]
          }
        },
        "mcp": {
          "type": "boolean",
          "const": false
        },
        "schema_org": {
          "type": "string",
          "const": "TouristTrip"
        }
      },
      "required": [
        "exports",
        "mcp",
        "schema_org"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "default_locale",
    "title",
    "summary",
    "region",
    "themes",
    "constraints",
    "steps",
    "licence",
    "editorial_status",
    "rihla_version",
    "id",
    "version",
    "author",
    "lineage",
    "pricing",
    "distribution"
  ],
  "additionalProperties": false,
  "$id": "https://rihla.example/format/rihla.schema.json",
  "title": "Open Itinerary Format 1.0.0",
  "description": "Proposition v1. Voir docs/FORMAT.md pour les invariants de publication et de lignée, complémentaires au schéma structurel."
}
