{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Coach Video Marker: line changes export, version 1",
  "type": "object",
  "required": [
    "schema",
    "version",
    "exportedAt",
    "generator",
    "timeBase",
    "video",
    "lines",
    "shifts",
    "summary"
  ],
  "properties": {
    "schema": {
      "const": "coach-video-marker/line-changes"
    },
    "version": {
      "const": 1
    },
    "exportedAt": {
      "type": "string",
      "format": "date-time"
    },
    "generator": {
      "type": "string"
    },
    "timeBase": {
      "const": "video"
    },
    "video": {
      "$ref": "#/$defs/video"
    },
    "lines": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        }
      }
    },
    "shifts": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "index",
          "lineId",
          "lineName",
          "period",
          "startSeconds",
          "endSeconds",
          "durationSeconds",
          "startUrl"
        ],
        "properties": {
          "index": {
            "type": "integer",
            "minimum": 1
          },
          "lineId": {
            "type": "string"
          },
          "lineName": {
            "type": "string"
          },
          "period": {
            "type": "integer",
            "minimum": 1,
            "maximum": 4
          },
          "startSeconds": {
            "type": "number",
            "minimum": 0
          },
          "endSeconds": {
            "type": "number",
            "minimum": 0
          },
          "durationSeconds": {
            "type": "number",
            "minimum": 0
          },
          "startUrl": {
            "type": "string",
            "format": "uri"
          }
        }
      }
    },
    "summary": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "lineId",
          "lineName",
          "shiftCount",
          "totalSeconds",
          "averageSeconds",
          "longestSeconds",
          "shortestSeconds"
        ],
        "properties": {
          "lineId": {
            "type": "string"
          },
          "lineName": {
            "type": "string"
          },
          "shiftCount": {
            "type": "integer",
            "minimum": 0
          },
          "totalSeconds": {
            "type": "number",
            "minimum": 0
          },
          "averageSeconds": {
            "type": "number",
            "minimum": 0
          },
          "longestSeconds": {
            "type": "number",
            "minimum": 0
          },
          "shortestSeconds": {
            "type": "number",
            "minimum": 0
          }
        }
      }
    }
  },
  "$defs": {
    "video": {
      "type": "object",
      "required": [
        "provider",
        "id",
        "url",
        "title",
        "durationSeconds"
      ],
      "properties": {
        "provider": {
          "const": "youtube"
        },
        "id": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{11}$"
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "title": {
          "type": "string"
        },
        "durationSeconds": {
          "type": [
            "number",
            "null"
          ],
          "minimum": 0
        }
      }
    }
  }
}