{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://jabbertoon.com/schemas/pack.schema.json",
 "title": "Jabbertoon pack manifest",
 "description": "Every move, character, scene and cartoon file Jabbertoon ships (https://jabbertoon.com/docs/packs/). Shipped packs are CC0; a pack a user makes is licensed \"own\": the maker keeps it.",
 "type": "object",
 "required": [
  "pack",
  "id",
  "type",
  "version",
  "name",
  "author",
  "license",
  "remixable",
  "derived_from",
  "content_hash",
  "content"
 ],
 "properties": {
  "pack": {
   "const": 1
  },
  "id": {
   "type": "string",
   "pattern": "^[a-z0-9]+(:[a-z0-9_.-]+)+$",
   "description": "namespace:type:slug, e.g. c4c:beh:wave_hello."
  },
  "type": {
   "enum": [
    "character",
    "behaviour",
    "scene",
    "background",
    "prop",
    "cartoon"
   ]
  },
  "version": {
   "type": "string",
   "pattern": "^\\d+\\.\\d+\\.\\d+$"
  },
  "name": {
   "type": "string",
   "minLength": 1
  },
  "description": {
   "type": "string"
  },
  "author": {
   "type": "object",
   "required": [
    "id"
   ],
   "properties": {
    "id": {
     "type": "string"
    },
    "name": {
     "type": "string"
    }
   }
  },
  "license": {
   "enum": [
    "cc0",
    "cc-by",
    "c4c-free",
    "c4c-paid",
    "own"
   ]
  },
  "remixable": {
   "type": "boolean"
  },
  "derived_from": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "id"
    ],
    "properties": {
     "id": {
      "type": "string"
     },
     "version": {
      "type": "string"
     },
     "note": {
      "type": "string"
     }
    }
   }
  },
  "preview": {
   "type": "object",
   "properties": {
    "moves": {
     "type": "array",
     "items": {
      "type": "string"
     }
    },
    "seconds": {
     "type": "number",
     "exclusiveMinimum": 0
    }
   }
  },
  "content_hash": {
   "type": "string",
   "pattern": "^sha256:[0-9a-f]{64}$",
   "description": "sha256 of the content as canonical JSON (keys sorted, no spaces)."
  },
  "content": {
   "type": "object"
  }
 },
 "allOf": [
  {
   "if": {
    "properties": {
     "type": {
      "const": "behaviour"
     }
    }
   },
   "then": {
    "properties": {
     "content": {
      "allOf": [
       {
        "$ref": "program.schema.json"
       },
       {
        "properties": {
         "kind": {
          "const": "behaviour"
         }
        }
       }
      ]
     }
    }
   }
  },
  {
   "if": {
    "properties": {
     "type": {
      "const": "scene"
     }
    }
   },
   "then": {
    "properties": {
     "content": {
      "allOf": [
       {
        "$ref": "program.schema.json"
       },
       {
        "properties": {
         "kind": {
          "const": "scene"
         }
        }
       }
      ]
     }
    }
   }
  },
  {
   "if": {
    "properties": {
     "type": {
      "const": "cartoon"
     }
    }
   },
   "then": {
    "properties": {
     "content": {
      "$ref": "cartoon.schema.json"
     }
    }
   }
  }
 ]
}
