{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://edit.trysometh.ing/schemas/editatlas-project-1.schema.json",
  "title": "editatlas-project/1",
  "description": "A finished short video described as the elements it is made of: footage clips, text, pictures, sounds and music, with the person's notes. project.json in a project folder holds one; versions/v<n>.json files hold one each, under $defs/version. Times are seconds on the timeline unless a field says source time; positions are fractions of the canvas; sizes in pixels are canvas pixels. Readers ignore properties they do not know; properties that start with x- are free for other tools. Reference: https://edit.trysometh.ing/docs/project-format",
  "type": "object",
  "required": ["format", "canvas", "tracks"],
  "properties": {
    "$schema": { "type": "string", "description": "Optional: the address of this schema, for editors that check the file as you type." },
    "format": { "const": "editatlas-project/1", "description": "Format id. A change that old readers would draw wrongly gets a new id (editatlas-project/2)." },
    "title": { "type": "string", "description": "The project's name, shown in the studio's header." },
    "canvas": { "$ref": "#/$defs/canvas" },
    "media": {
      "type": "object",
      "description": "Every file the edit uses, by id.",
      "propertyNames": { "minLength": 1 },
      "additionalProperties": { "$ref": "#/$defs/media" }
    },
    "styles": {
      "type": "object",
      "description": "Shared looks for text items, by name. A property set on an item wins over its style.",
      "propertyNames": { "minLength": 1 },
      "additionalProperties": { "$ref": "#/$defs/textStyle" }
    },
    "tracks": {
      "type": "array",
      "description": "Drawn in order: later tracks are on top. One video track at most.",
      "items": { "$ref": "#/$defs/track" }
    },
    "notes": {
      "type": "array",
      "description": "What the person wants changed, and where. Not elements: they draw nothing and exports ignore them.",
      "items": { "$ref": "#/$defs/note" }
    }
  },
  "patternProperties": { "^x-": true },
  "additionalProperties": false,
  "$defs": {
    "id": { "type": "string", "minLength": 1, "description": "Unique in the project among clips and items. Keep ids stable across versions." },
    "seconds": { "type": "number", "minimum": 0 },
    "duration": { "type": "number", "exclusiveMinimum": 0 },
    "color": { "type": "string", "minLength": 1, "description": "A CSS colour: #rrggbb, #rgb, rgba(...) or a name." },
    "label": { "type": ["string", "null"], "description": "A name the person sees on the timeline and in the panel." },
    "canvas": {
      "type": "object",
      "required": ["width", "height"],
      "properties": {
        "width": { "type": "integer", "minimum": 2, "description": "Pixels. Even, for H.264." },
        "height": { "type": "integer", "minimum": 2, "description": "Pixels. Even, for H.264." },
        "fps": { "type": "number", "exclusiveMinimum": 0, "maximum": 240, "description": "Frame rate of the export. Readers use 30 when it is missing." },
        "background": { "$ref": "#/$defs/color", "description": "Drawn under everything. Default #000000." }
      },
      "patternProperties": { "^x-": true },
      "additionalProperties": false
    },
    "media": {
      "type": "object",
      "required": ["kind", "path"],
      "properties": {
        "kind": { "enum": ["video", "audio", "image", "font"] },
        "path": { "type": "string", "description": "Relative to project.json, with forward slashes (media/clip.mp4)." },
        "title": { "type": ["string", "null"], "description": "A name for the file, shown to the person." },
        "duration": { "type": ["number", "null"], "minimum": 0, "description": "Seconds, measured from the file (video, audio, animated image)." },
        "width": { "type": ["integer", "null"], "minimum": 1, "description": "Pixels, measured from the file (video, image)." },
        "height": { "type": ["integer", "null"], "minimum": 1, "description": "Pixels, measured from the file (video, image)." },
        "fps": { "type": ["number", "null"], "exclusiveMinimum": 0, "description": "Frame rate of the file (video, animated image)." },
        "has_audio": { "type": ["boolean", "null"], "description": "Whether a video file has a sound stream." },
        "family": { "type": "string", "minLength": 1, "description": "Font family name that text properties use in font." },
        "weight": { "type": "number", "minimum": 1, "maximum": 1000, "description": "Font weight of this file. Default 400." },
        "style": { "enum": ["normal", "italic"], "description": "Font style of this file. Default normal." }
      },
      "if": { "properties": { "kind": { "const": "font" } } },
      "then": { "required": ["family"] },
      "patternProperties": { "^x-": true },
      "additionalProperties": false
    },
    "track": {
      "type": "object",
      "required": ["id", "kind"],
      "properties": { "kind": { "enum": ["video", "text", "image", "audio"] } },
      "allOf": [
        { "if": { "properties": { "kind": { "const": "video" } } }, "then": { "$ref": "#/$defs/videoTrack" } },
        { "if": { "properties": { "kind": { "const": "text" } } }, "then": { "$ref": "#/$defs/textTrack" } },
        { "if": { "properties": { "kind": { "const": "image" } } }, "then": { "$ref": "#/$defs/imageTrack" } },
        { "if": { "properties": { "kind": { "const": "audio" } } }, "then": { "$ref": "#/$defs/audioTrack" } }
      ]
    },
    "videoTrack": {
      "description": "The footage: clips back to back, with no gaps.",
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "kind": { "const": "video" },
        "name": { "type": "string" },
        "hidden": { "type": "boolean" },
        "muted": { "type": "boolean" },
        "clips": { "type": "array", "items": { "$ref": "#/$defs/clip" } }
      },
      "patternProperties": { "^x-": true },
      "additionalProperties": false
    },
    "textTrack": {
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "kind": { "const": "text" },
        "name": { "type": "string" },
        "hidden": { "type": "boolean" },
        "items": { "type": "array", "items": { "$ref": "#/$defs/textItem" } }
      },
      "patternProperties": { "^x-": true },
      "additionalProperties": false
    },
    "imageTrack": {
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "kind": { "const": "image" },
        "name": { "type": "string" },
        "hidden": { "type": "boolean" },
        "items": { "type": "array", "items": { "$ref": "#/$defs/imageItem" } }
      },
      "patternProperties": { "^x-": true },
      "additionalProperties": false
    },
    "audioTrack": {
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "kind": { "const": "audio" },
        "name": { "type": "string" },
        "muted": { "type": "boolean" },
        "items": { "type": "array", "items": { "$ref": "#/$defs/audioItem" } }
      },
      "patternProperties": { "^x-": true },
      "additionalProperties": false
    },
    "clip": {
      "type": "object",
      "description": "A part of a video file. It lasts (out - in) / speed on the timeline, right after the clip before it.",
      "required": ["id", "media", "in", "out"],
      "properties": {
        "id": { "$ref": "#/$defs/id" },
        "media": { "type": "string", "minLength": 1, "description": "A media id of kind video." },
        "in": { "$ref": "#/$defs/seconds", "description": "Source time where the part starts." },
        "out": { "type": "number", "exclusiveMinimum": 0, "description": "Source time where the part ends; greater than in." },
        "speed": { "type": "number", "minimum": 0.1, "maximum": 10, "description": "How fast the source plays. Default 1." },
        "volume": { "type": "number", "minimum": 0, "maximum": 2, "description": "The footage's own sound in this clip. Default 1." },
        "fit": { "enum": ["cover", "contain"], "description": "cover fills the canvas and crops; contain shows the whole frame. Default cover." },
        "x": { "type": "number", "description": "Point of the source kept in the centre when cropped, 0 to 1. Default 0.5." },
        "y": { "type": "number", "description": "Point of the source kept in the centre when cropped, 0 to 1. Default 0.5." },
        "scale": { "type": "number", "exclusiveMinimum": 0, "description": "Extra zoom. Default 1." },
        "zoom_to": { "type": ["number", "null"], "exclusiveMinimum": 0, "description": "The zoom moves from scale to this over the clip." },
        "transition": {
          "description": "How the cut into this clip looks, centred on the cut. Null or missing: a plain cut.",
          "oneOf": [
            { "type": "null" },
            {
              "type": "object",
              "required": ["type"],
              "properties": {
                "type": { "enum": ["dissolve", "black", "white", "slide", "wipe"] },
                "dur": { "type": "number", "exclusiveMinimum": 0, "maximum": 5, "description": "Seconds. Default 0.5." }
              },
              "patternProperties": { "^x-": true },
              "additionalProperties": false
            }
          ]
        },
        "label": { "$ref": "#/$defs/label" }
      },
      "patternProperties": { "^x-": true },
      "additionalProperties": false
    },
    "anim": {
      "description": "How an item appears (in) or leaves (out). Null: no animation, also over a style's.",
      "oneOf": [
        { "type": "null" },
        {
          "type": "object",
          "required": ["type"],
          "properties": {
            "type": { "enum": ["fade", "pop", "slide-up"] },
            "dur": { "type": "number", "exclusiveMinimum": 0, "description": "Seconds." }
          },
          "patternProperties": { "^x-": true },
          "additionalProperties": false
        }
      ]
    },
    "keys": {
      "type": "array",
      "minItems": 1,
      "description": "Keyframes of the item's own motion, in time order, on top of in and out.",
      "items": {
        "type": "object",
        "required": ["t"],
        "properties": {
          "t": { "type": "number", "description": "Seconds after the item starts." },
          "dx": { "type": "number", "description": "Move right, canvas pixels." },
          "dy": { "type": "number", "description": "Move down, canvas pixels." },
          "scale": { "type": "number", "description": "Times the item's size." },
          "rotate": { "type": "number", "description": "Degrees, added to rotation." },
          "opacity": { "type": "number", "description": "Times the item's opacity." },
          "ease": { "enum": ["linear", "out", "in", "in-out", "back", "step", null], "description": "How the move into this key runs. Default out." }
        },
        "anyOf": [
          { "required": ["dx"] }, { "required": ["dy"] }, { "required": ["scale"] }, { "required": ["rotate"] }, { "required": ["opacity"] }
        ],
        "additionalProperties": false
      }
    },
    "textLook": {
      "description": "The look of text, in a style or on a text item.",
      "properties": {
        "font": { "type": "string", "minLength": 1, "description": "sans-serif, or the family of a font in media. Default sans-serif." },
        "weight": { "type": "number", "minimum": 1, "maximum": 1000, "description": "Default 700." },
        "italic": { "type": "boolean" },
        "size": { "type": "number", "exclusiveMinimum": 0, "description": "Pixels. Default 64." },
        "color": { "$ref": "#/$defs/color", "description": "Default #ffffff." },
        "x": { "type": "number", "description": "Centre of the block, fraction of the canvas width (inside a card: of the card's box, and the edge align names). Default 0.5." },
        "y": { "type": "number", "description": "Centre of the block, fraction of the canvas height (inside a card: of the card's box). Default 0.75." },
        "max_width": { "type": "number", "exclusiveMinimum": 0, "description": "Wrap width, fraction of the canvas width. Default 0.84." },
        "align": { "enum": ["left", "center", "right"], "description": "Default center." },
        "line_height": { "type": "number", "exclusiveMinimum": 0, "description": "Times size. Default 1.15." },
        "case": { "enum": ["upper", "", null], "description": "upper draws capitals; empty or null draws the text as typed." },
        "letter_spacing": { "type": "number", "description": "Pixels. Default 0." },
        "stroke": {
          "oneOf": [
            { "type": "null" },
            { "type": "object", "properties": { "color": { "$ref": "#/$defs/color" }, "width": { "type": "number", "minimum": 0 } }, "patternProperties": { "^x-": true }, "additionalProperties": false }
          ]
        },
        "shadow": {
          "oneOf": [
            { "type": "null" },
            { "type": "object", "properties": { "color": { "$ref": "#/$defs/color" }, "blur": { "type": "number", "minimum": 0 }, "x": { "type": "number" }, "y": { "type": "number" } }, "patternProperties": { "^x-": true }, "additionalProperties": false }
          ]
        },
        "box": {
          "description": "A filled box behind the text; a text item with a box can be a card.",
          "oneOf": [
            { "type": "null" },
            { "type": "object", "properties": { "color": { "$ref": "#/$defs/color" }, "pad_x": { "type": "number", "minimum": 0 }, "pad_y": { "type": "number", "minimum": 0 }, "radius": { "type": "number", "minimum": 0 }, "opacity": { "type": "number", "minimum": 0, "maximum": 1 } }, "patternProperties": { "^x-": true }, "additionalProperties": false }
          ]
        },
        "highlight": { "oneOf": [{ "type": "null" }, { "$ref": "#/$defs/color" }], "description": "Colour of the word being spoken (needs words)." },
        "reveal": { "enum": ["all", "word"], "description": "word: words appear as they are said. Default all." },
        "in": { "$ref": "#/$defs/anim" },
        "out": { "$ref": "#/$defs/anim" },
        "opacity": { "type": "number", "minimum": 0, "maximum": 1, "description": "Default 1." },
        "rotation": { "type": "number", "description": "Degrees. Default 0." },
        "strike": {
          "description": "A line drawn through the text, line by line, from at seconds after the item starts, over dur seconds.",
          "oneOf": [
            { "type": "null" },
            { "type": "object", "properties": { "color": { "$ref": "#/$defs/color" }, "width": { "type": "number", "minimum": 0 }, "at": { "type": "number", "minimum": 0 }, "dur": { "type": "number", "minimum": 0 } }, "patternProperties": { "^x-": true }, "additionalProperties": false }
          ]
        }
      }
    },
    "textStyle": {
      "type": "object",
      "description": "A shared look for text items.",
      "$ref": "#/$defs/textLook",
      "patternProperties": { "^x-": true },
      "unevaluatedProperties": false
    },
    "textItem": {
      "type": "object",
      "description": "Captions, hooks, titles, and the words on a card. Any text property can be set here; it wins over the style.",
      "required": ["id", "at", "dur"],
      "properties": {
        "id": { "$ref": "#/$defs/id" },
        "text": { "type": "string" },
        "at": { "$ref": "#/$defs/seconds", "description": "When it shows." },
        "dur": { "$ref": "#/$defs/duration", "description": "How long it shows." },
        "style": { "type": "string", "minLength": 1, "description": "A name in styles." },
        "words": {
          "type": "array",
          "description": "One entry per word of text (split on spaces), times relative to at.",
          "items": {
            "type": "object",
            "required": ["at", "dur"],
            "properties": { "at": { "type": "number", "minimum": 0 }, "dur": { "type": "number", "minimum": 0 } },
            "additionalProperties": false
          }
        },
        "parent": { "type": ["string", "null"], "minLength": 1, "description": "The id of a text or image item this one is drawn inside (a card). One level only." },
        "keys": { "$ref": "#/$defs/keys" },
        "label": { "$ref": "#/$defs/label" }
      },
      "$ref": "#/$defs/textLook",
      "patternProperties": { "^x-": true },
      "unevaluatedProperties": false
    },
    "imageItem": {
      "type": "object",
      "description": "Logos, stickers, graphics, and animated WebP, GIF or APNG motion graphics.",
      "required": ["id", "media", "at", "dur"],
      "properties": {
        "id": { "$ref": "#/$defs/id" },
        "media": { "type": "string", "minLength": 1, "description": "A media id of kind image." },
        "at": { "$ref": "#/$defs/seconds" },
        "dur": { "$ref": "#/$defs/duration" },
        "x": { "type": "number", "description": "Centre, fraction of the canvas width (inside a card: of the card's box). Default 0.5." },
        "y": { "type": "number", "description": "Centre, fraction of the canvas height (inside a card: of the card's box). Default 0.5." },
        "width": { "type": "number", "exclusiveMinimum": 0, "description": "Fraction of the canvas width; the height keeps the image's shape." },
        "opacity": { "type": "number", "minimum": 0, "maximum": 1 },
        "rotation": { "type": "number", "description": "Degrees." },
        "in": { "$ref": "#/$defs/anim" },
        "out": { "$ref": "#/$defs/anim" },
        "loop": { "type": "boolean", "description": "Repeat an animated image for dur; otherwise it holds its last frame." },
        "from": { "type": "number", "minimum": 0, "description": "Start this many seconds into an animated image." },
        "parent": { "type": ["string", "null"], "minLength": 1, "description": "The id of a text or image item this one is drawn inside. One level only." },
        "keys": { "$ref": "#/$defs/keys" },
        "label": { "$ref": "#/$defs/label" }
      },
      "patternProperties": { "^x-": true },
      "additionalProperties": false
    },
    "audioItem": {
      "type": "object",
      "description": "A sound effect or music.",
      "required": ["id", "media", "at"],
      "properties": {
        "id": { "$ref": "#/$defs/id" },
        "media": { "type": "string", "minLength": 1, "description": "A media id of kind audio." },
        "at": { "$ref": "#/$defs/seconds", "description": "When the file starts on the timeline." },
        "in": { "type": ["number", "null"], "minimum": 0, "description": "File time where the part used starts. Default 0." },
        "out": { "type": ["number", "null"], "minimum": 0, "description": "File time where it ends; null: to the end of the file." },
        "gain_db": { "type": "number", "description": "Applied to the file as it is; 0 is the file's own level. Nothing is normalised later." },
        "gain_keys": {
          "type": "array",
          "description": "Points on the volume line, in time order: t is file time, db the change from gain_db there.",
          "items": {
            "type": "object",
            "required": ["t", "db"],
            "properties": { "t": { "type": "number" }, "db": { "type": "number" } },
            "additionalProperties": false
          }
        },
        "fade_in": { "type": "number", "minimum": 0, "description": "Seconds." },
        "fade_out": { "type": "number", "minimum": 0, "description": "Seconds." },
        "label": { "$ref": "#/$defs/label" }
      },
      "patternProperties": { "^x-": true },
      "additionalProperties": false
    },
    "note": {
      "type": "object",
      "required": ["id", "at"],
      "properties": {
        "id": { "type": "string", "minLength": 1, "description": "Unique among notes; not an element id." },
        "at": { "$ref": "#/$defs/seconds", "description": "Seconds on the timeline." },
        "text": { "type": "string", "maxLength": 500 }
      },
      "additionalProperties": false
    },
    "version": {
      "title": "editatlas-version/1",
      "description": "One file in a project folder's versions/: versions/v<n>.json, numbered 1, 2, 3 ... with no gaps, never overwritten.",
      "type": "object",
      "required": ["format", "version", "parent", "by", "name", "note", "made", "project"],
      "properties": {
        "format": { "const": "editatlas-version/1" },
        "version": { "type": "integer", "minimum": 1, "description": "The n in its file name." },
        "parent": { "type": ["integer", "null"], "minimum": 1, "description": "The version the writer opened and changed; null for version 1." },
        "by": { "enum": ["agent", "studio"] },
        "name": { "type": "string", "maxLength": 40, "description": "The agent's name; empty for the studio." },
        "note": { "type": "string", "maxLength": 500, "description": "What the writer did, or what the person wants next." },
        "made": { "type": "string", "format": "date-time", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}(:[0-9]{2}([.][0-9]+)?)?(Z|[+-][0-9]{2}:[0-9]{2})$", "description": "ISO 8601 with a time zone, UTC (2026-11-10T12:00:00.000Z)." },
        "project": { "$ref": "#" }
      },
      "patternProperties": { "^x-": true },
      "additionalProperties": false
    }
  }
}
