{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://gyrconos.github.io/NMSGalaxyMap/schema/poi-collection.schema.json",
  "title": "NMS POI Collection",
  "description": "Points of interest in the No Man's Sky universe (version 1). Documentation: https://gyrconos.github.io/NMSGalaxyMap/docs/poi-format.html",
  "oneOf": [
    { "$ref": "#/$defs/collection" },
    { "$ref": "#/$defs/points" }
  ],
  "$defs": {
    "collection": {
      "type": "object",
      "required": ["points"],
      "properties": {
        "$schema": { "type": "string" },
        "title": { "type": "string", "description": "Short name of the collection" },
        "description": { "type": "string", "description": "One sentence about what is in the collection" },
        "url": { "$ref": "#/$defs/url", "description": "The collection's web page" },
        "points": { "$ref": "#/$defs/points" }
      }
    },
    "points": {
      "type": "array",
      "items": { "$ref": "#/$defs/point" }
    },
    "point": {
      "type": "object",
      "required": ["type", "galaxy", "region"],
      "properties": {
        "type": {
          "type": "string",
          "description": "region, system, station, planet or base; readers skip types they don't know",
          "examples": ["region", "system", "station", "planet", "base"]
        },
        "galaxy": { "type": "integer", "minimum": 0, "maximum": 255, "description": "Galaxy index, Euclid = 0" },
        "region": { "type": "string", "pattern": "^[0-9a-fA-F]{8}$", "description": "Region address YYZZZXXX (last 8 digits of the portal code)" },
        "system": { "type": "string", "pattern": "^[0-9a-fA-F]{1,3}$", "description": "System index SSS within the region, preferably 3 uppercase digits" },
        "planet": {
          "description": "Planet index 0-15 (the P digit of the portal code)",
          "oneOf": [
            { "type": "integer", "minimum": 0, "maximum": 15 },
            { "type": "string", "pattern": "^([0-9]|1[0-5])$" }
          ]
        },
        "name": { "type": "string", "description": "Name of the place, replacing the generated one; identifies a base" },
        "caption": { "type": "string", "description": "Label for the marker" },
        "color": {
          "description": "Marker color, 0xRRGGBB as an integer or \"#RRGGBB\" / \"RRGGBB\"",
          "oneOf": [
            { "type": "integer", "minimum": 0, "maximum": 16777215 },
            { "type": "string", "pattern": "^#?[0-9a-fA-F]{6}$" }
          ]
        },
        "url": { "$ref": "#/$defs/url", "description": "A web page about the place" },
        "systems": false,
        "planets": false,
        "station": false,
        "bases": false,
        "generatedName": false,
        "generatedNameVersion": false,
        "importIds": false
      },
      "allOf": [
        {
          "if": { "properties": { "type": { "enum": ["system", "station", "planet", "base"] } } },
          "then": { "required": ["system"] }
        },
        {
          "if": { "properties": { "type": { "enum": ["planet", "base"] } } },
          "then": { "required": ["planet"] }
        },
        {
          "if": { "properties": { "type": { "const": "base" } } },
          "then": { "required": ["name"] }
        }
      ]
    },
    "url": {
      "type": "string",
      "description": "Absolute http(s) link to a named host, without user name or password, whitespace, quotes, <>, backticks, backslashes, braces, pipes or carets",
      "maxLength": 2048,
      "pattern": "^https?://[^\\u0000-\\u0020\\u007f-\\u00a0\"'<>`\\\\{}|^/?#@]+\\.[^\\u0000-\\u0020\\u007f-\\u00a0\"'<>`\\\\{}|^]+$"
    }
  }
}
