{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://libraries.horizon36596.org/zenith/schema/v1/path.json",
  "title": "Zenith interchange path file, formatVersion 1",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string",
      "const": "https://libraries.horizon36596.org/zenith/schema/v1/path.json"
    },
    "formatVersion": {
      "type": "number",
      "const": 1
    },
    "kind": {
      "type": "string",
      "const": "path"
    },
    "season": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "alliance": {
      "type": "string",
      "enum": [
        "RED",
        "BLUE"
      ]
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "source": {
      "type": "object",
      "properties": {
        "planner": {
          "type": "string",
          "maxLength": 200
        },
        "exporter": {
          "type": "string",
          "maxLength": 200
        }
      },
      "additionalProperties": false
    },
    "frame": {
      "type": "object",
      "properties": {
        "preset": {
          "type": "string",
          "enum": [
            "zenith",
            "pedro",
            "roadrunner"
          ]
        },
        "originIn": {
          "type": "object",
          "properties": {
            "xIn": {
              "type": "number"
            },
            "yIn": {
              "type": "number"
            }
          },
          "required": [
            "xIn",
            "yIn"
          ],
          "additionalProperties": false
        },
        "xAxis": {
          "type": "string",
          "enum": [
            "+x",
            "-x",
            "+y",
            "-y"
          ]
        },
        "yAxis": {
          "type": "string",
          "enum": [
            "+x",
            "-x",
            "+y",
            "-y"
          ]
        },
        "units": {
          "type": "string",
          "enum": [
            "in",
            "mm",
            "cm",
            "m"
          ]
        },
        "headingUnit": {
          "type": "string",
          "enum": [
            "rad",
            "deg"
          ]
        },
        "headingZero": {
          "type": "string",
          "enum": [
            "+x",
            "+y"
          ]
        },
        "headingPositive": {
          "type": "string",
          "enum": [
            "ccw",
            "cw"
          ]
        }
      },
      "additionalProperties": false,
      "description": "The planner's frame: a preset (zenith, pedro or roadrunner), optionally with some of its keys overridden, or every key given explicitly. Axis directions are field-frame directions."
    },
    "startPose": {
      "type": "object",
      "properties": {
        "x": {
          "type": "number"
        },
        "y": {
          "type": "number"
        },
        "heading": {
          "type": "number"
        }
      },
      "required": [
        "x",
        "y",
        "heading"
      ],
      "additionalProperties": false
    },
    "steps": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "kind": {
                "type": "string",
                "const": "path"
              },
              "timeoutS": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "segments": {
                "type": "array",
                "items": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "const": "line"
                        },
                        "from": {
                          "type": "object",
                          "properties": {
                            "x": {
                              "type": "number"
                            },
                            "y": {
                              "type": "number"
                            },
                            "heading": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "x",
                            "y"
                          ],
                          "additionalProperties": false
                        },
                        "to": {
                          "$ref": "#/properties/steps/items/anyOf/0/properties/segments/items/anyOf/0/properties/from"
                        }
                      },
                      "required": [
                        "kind",
                        "from",
                        "to"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "const": "bezier"
                        },
                        "from": {
                          "$ref": "#/properties/steps/items/anyOf/0/properties/segments/items/anyOf/0/properties/from"
                        },
                        "control": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "x": {
                                "type": "number"
                              },
                              "y": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "x",
                              "y"
                            ],
                            "additionalProperties": false
                          },
                          "minItems": 1,
                          "maxItems": 3
                        },
                        "to": {
                          "$ref": "#/properties/steps/items/anyOf/0/properties/segments/items/anyOf/0/properties/from"
                        }
                      },
                      "required": [
                        "kind",
                        "from",
                        "control",
                        "to"
                      ],
                      "additionalProperties": false
                    }
                  ]
                },
                "minItems": 1,
                "maxItems": 200
              },
              "heading": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "mode": {
                        "type": "string",
                        "const": "tangent"
                      }
                    },
                    "required": [
                      "mode"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "mode": {
                        "type": "string",
                        "const": "tangentReversed"
                      }
                    },
                    "required": [
                      "mode"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "mode": {
                        "type": "string",
                        "const": "constant"
                      },
                      "heading": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "mode",
                      "heading"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "mode": {
                        "type": "string",
                        "const": "linear"
                      },
                      "from": {
                        "type": "number"
                      },
                      "to": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "mode",
                      "from",
                      "to"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "mode": {
                        "type": "string",
                        "const": "facePoint"
                      },
                      "x": {
                        "type": "number"
                      },
                      "y": {
                        "type": "number"
                      },
                      "offset": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "mode",
                      "x",
                      "y"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "mode": {
                        "type": "string",
                        "const": "piecewise"
                      },
                      "ranges": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "startT": {
                              "type": "number",
                              "minimum": 0,
                              "maximum": 1
                            },
                            "endT": {
                              "type": "number",
                              "minimum": 0,
                              "maximum": 1
                            },
                            "heading": {
                              "anyOf": [
                                {
                                  "$ref": "#/properties/steps/items/anyOf/0/properties/heading/anyOf/0"
                                },
                                {
                                  "$ref": "#/properties/steps/items/anyOf/0/properties/heading/anyOf/1"
                                },
                                {
                                  "$ref": "#/properties/steps/items/anyOf/0/properties/heading/anyOf/2"
                                },
                                {
                                  "$ref": "#/properties/steps/items/anyOf/0/properties/heading/anyOf/3"
                                },
                                {
                                  "$ref": "#/properties/steps/items/anyOf/0/properties/heading/anyOf/4"
                                }
                              ]
                            }
                          },
                          "required": [
                            "startT",
                            "endT",
                            "heading"
                          ],
                          "additionalProperties": false
                        },
                        "minItems": 1,
                        "maxItems": 200
                      }
                    },
                    "required": [
                      "mode",
                      "ranges"
                    ],
                    "additionalProperties": false
                  }
                ]
              },
              "speedFraction": {
                "type": "number",
                "exclusiveMinimum": 0,
                "maximum": 1
              }
            },
            "required": [
              "kind",
              "segments"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "kind": {
                "type": "string",
                "const": "wait"
              },
              "seconds": {
                "type": "number",
                "minimum": 0
              }
            },
            "required": [
              "kind",
              "seconds"
            ],
            "additionalProperties": false
          }
        ]
      },
      "minItems": 1,
      "maxItems": 200
    }
  },
  "required": [
    "formatVersion",
    "kind",
    "season",
    "alliance",
    "frame",
    "startPose",
    "steps"
  ],
  "additionalProperties": false
}
