{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://radio2.org/schema/v0.2/manifest.schema.json",
  "title": "Radio 2.0 station manifest, version 0.2",
  "description": "One live station: who it is, how to hear it, where its live events and schedule are, how to reach it and how to support it.",
  "type": "object",
  "required": ["specVersion", "guid", "manifestUrl", "name", "homepage", "language", "streams"],
  "additionalProperties": false,
  "properties": {
    "specVersion": { "type": "string", "enum": ["0.2"] },
    "guid": { "$ref": "#/$defs/uuid" },
    "manifestUrl": { "type": "string", "format": "uri", "maxLength": 2000 },
    "locked": { "type": "boolean", "default": false },
    "name": { "type": "string", "minLength": 1, "maxLength": 120 },
    "tagline": { "type": "string", "maxLength": 160 },
    "description": { "type": "string", "maxLength": 4000 },
    "homepage": { "type": "string", "format": "uri", "maxLength": 2000 },
    "language": { "$ref": "#/$defs/language" },
    "country": { "type": "string", "pattern": "^[A-Z]{2}$" },
    "location": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "city": { "type": "string", "maxLength": 80 },
        "region": { "type": "string", "maxLength": 80 }
      }
    },
    "genres": {
      "type": "array",
      "maxItems": 10,
      "uniqueItems": true,
      "items": { "type": "string", "minLength": 1, "maxLength": 40 }
    },
    "branding": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "logo": { "type": "string", "format": "uri", "maxLength": 2000 },
        "icon": { "type": "string", "format": "uri", "maxLength": 2000 },
        "banner": { "type": "string", "format": "uri", "maxLength": 2000 },
        "themeColor": { "type": "string", "pattern": "^#[0-9A-Fa-f]{6}$" }
      }
    },
    "streams": {
      "type": "array",
      "minItems": 1,
      "maxItems": 32,
      "items": { "$ref": "#/$defs/stream" }
    },
    "broadcast": { "$ref": "#/$defs/broadcast" },
    "events": {
      "type": "object",
      "required": ["sse", "poll"],
      "additionalProperties": false,
      "properties": {
        "sse": { "type": "string", "format": "uri", "maxLength": 2000 },
        "poll": { "type": "string", "format": "uri", "maxLength": 2000 },
        "pollInterval": { "type": "integer", "minimum": 5, "maximum": 300, "default": 15 }
      }
    },
    "schedule": {
      "type": "object",
      "required": ["timeZone"],
      "additionalProperties": false,
      "properties": {
        "timeZone": { "type": "string", "minLength": 1, "maxLength": 64 },
        "json": { "type": "string", "format": "uri", "maxLength": 2000 },
        "ical": { "type": "string", "format": "uri", "maxLength": 2000 }
      }
    },
    "contact": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "email": { "type": "string", "maxLength": 254, "pattern": "^[^@\\s]+@[^@\\s]+$" },
        "phone": { "type": "string", "maxLength": 40 },
        "whatsapp": { "type": "string", "maxLength": 40 },
        "requestsUrl": { "type": "string", "format": "uri", "maxLength": 2000 },
        "address": {
          "type": "object",
          "description": "A postal address for display and contact. At least one of street, locality or country.",
          "additionalProperties": false,
          "properties": {
            "label": { "type": "string", "minLength": 1, "maxLength": 60 },
            "street": { "type": "string", "minLength": 1, "maxLength": 300 },
            "locality": { "type": "string", "minLength": 1, "maxLength": 80 },
            "region": { "type": "string", "minLength": 1, "maxLength": 80 },
            "postalCode": { "type": "string", "minLength": 1, "maxLength": 20 },
            "country": { "type": "string", "pattern": "^[A-Z]{2}$" }
          }
        },
        "social": {
          "type": "array",
          "maxItems": 30,
          "items": {
            "type": "object",
            "required": ["url"],
            "additionalProperties": false,
            "properties": {
              "platform": { "type": "string", "pattern": "^[a-z0-9_]{1,30}$" },
              "label": { "type": "string", "maxLength": 60 },
              "url": { "type": "string", "format": "uri", "maxLength": 2000 }
            }
          }
        }
      }
    },
    "value": { "$ref": "#/$defs/value" },
    "videoStreams": {
      "type": "array",
      "maxItems": 16,
      "items": { "$ref": "#/$defs/videoStream" }
    },
    "extensions": {
      "type": "object",
      "description": "Publisher-specific members. Each key SHOULD be a reverse domain name or a URL the publisher controls.",
      "additionalProperties": true
    }
  },
  "$defs": {
    "uuid": {
      "type": "string",
      "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
    },
    "language": {
      "type": "string",
      "maxLength": 35,
      "pattern": "^[A-Za-z]{2,3}(-[A-Za-z0-9]{1,8})*$"
    },
    "stream": {
      "type": "object",
      "required": ["id", "url", "mimeType"],
      "additionalProperties": false,
      "properties": {
        "id": { "type": "string", "pattern": "^[A-Za-z0-9._-]{1,64}$" },
        "url": { "type": "string", "format": "uri", "maxLength": 2000 },
        "mimeType": { "type": "string", "minLength": 3, "maxLength": 100 },
        "protocol": { "type": "string", "enum": ["icecast", "http", "hls", "ll-hls"] },
        "bitrate": { "type": "integer", "minimum": 1, "maximum": 100000 },
        "sampleRate": { "type": "integer", "minimum": 8000, "maximum": 384000 },
        "channels": { "type": "integer", "minimum": 1, "maximum": 8 },
        "typicalDelayMs": { "type": "integer", "minimum": 0, "maximum": 600000 },
        "default": { "type": "boolean", "default": false },
        "carries": {
          "type": "array",
          "description": "Ids of the transmissions this stream is the feed of, or the single value \"web\" for an internet-only stream.",
          "minItems": 1,
          "maxItems": 16,
          "uniqueItems": true,
          "items": { "type": "string", "pattern": "^[A-Za-z0-9._-]{1,64}$" }
        }
      }
    },
    "videoStream": {
      "type": "object",
      "required": ["id", "url", "mimeType", "protocol"],
      "additionalProperties": false,
      "properties": {
        "id": { "type": "string", "pattern": "^[A-Za-z0-9._-]{1,64}$" },
        "url": { "type": "string", "format": "uri", "maxLength": 2000 },
        "mimeType": { "type": "string", "minLength": 3, "maxLength": 100 },
        "protocol": { "type": "string", "enum": ["whep", "ll-hls", "hls"] },
        "kind": { "type": "string", "enum": ["studio_camera", "visualizer", "screen"] },
        "width": { "type": "integer", "minimum": 1, "maximum": 8192 },
        "height": { "type": "integer", "minimum": 1, "maximum": 8192 },
        "frameRate": { "type": "integer", "minimum": 1, "maximum": 240 },
        "syncStreamId": { "type": "string", "pattern": "^[A-Za-z0-9._-]{1,64}$" },
        "typicalDelayMs": { "type": "integer", "minimum": 0, "maximum": 600000 },
        "default": { "type": "boolean", "default": false }
      }
    },
    "value": {
      "type": "object",
      "required": ["type", "method", "recipients"],
      "additionalProperties": false,
      "properties": {
        "type": { "type": "string", "enum": ["lightning"] },
        "method": { "type": "string", "enum": ["keysend", "lnaddress"] },
        "suggested": { "type": "string", "pattern": "^[0-9]+(\\.[0-9]+)?$" },
        "recipients": {
          "type": "array",
          "minItems": 1,
          "maxItems": 50,
          "items": { "$ref": "#/$defs/recipient" }
        }
      }
    },
    "recipient": {
      "type": "object",
      "required": ["type", "address", "split"],
      "additionalProperties": false,
      "properties": {
        "name": { "type": "string", "maxLength": 120 },
        "type": { "type": "string", "enum": ["node", "lnaddress"] },
        "address": { "type": "string", "minLength": 3, "maxLength": 320 },
        "split": { "type": "integer", "minimum": 0, "maximum": 1000000 },
        "fee": { "type": "boolean", "default": false },
        "customKey": { "type": "string", "maxLength": 64 },
        "customValue": { "type": "string", "maxLength": 256 },
        "role": { "type": "string", "enum": ["station", "host", "artist", "producer", "app", "other"] }
      }
    },
    "broadcast": {
      "type": "object",
      "required": ["mode"],
      "additionalProperties": false,
      "properties": {
        "mode": { "type": "string", "enum": ["on_air", "web_only"] },
        "transmissions": {
          "type": "array",
          "maxItems": 32,
          "items": { "$ref": "#/$defs/transmission" }
        },
        "regulatorIds": {
          "type": "array",
          "maxItems": 10,
          "items": { "$ref": "#/$defs/regulatorId" }
        }
      }
    },
    "transmission": {
      "type": "object",
      "required": ["id", "band"],
      "additionalProperties": false,
      "properties": {
        "id": { "type": "string", "pattern": "^[A-Za-z0-9._-]{1,64}$" },
        "band": {
          "type": "string",
          "enum": ["fm", "am", "lw", "sw", "hd_fm", "hd_am", "dab", "dab_plus", "drm", "drm_plus", "satellite", "cable", "dtv"]
        },
        "frequencyKhz": { "type": "integer", "minimum": 148, "maximum": 30000 },
        "frequencyMhz": { "type": "number", "minimum": 47, "maximum": 230 },
        "subchannel": { "type": "integer", "minimum": 1, "maximum": 8 },
        "block": { "type": "string", "pattern": "^(([5-9]|1[0-3])[A-FN]|L[A-W])$" },
        "channel": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9.-]{0,15}$" },
        "provider": { "type": "string", "minLength": 1, "maxLength": 80 },
        "callSign": { "type": "string", "pattern": "^[A-Z0-9]{1,10}(-[A-Z0-9]{1,5})?$" },
        "licensedName": { "type": "string", "minLength": 1, "maxLength": 120 },
        "ecc": { "type": "string", "pattern": "^[0-9A-F]{2}$" },
        "rds": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "pi": { "type": "string", "pattern": "^[0-9A-F]{4}$" },
            "ps": { "type": "string", "minLength": 1, "maxLength": 8 }
          }
        },
        "serviceId": { "type": "string", "pattern": "^[0-9A-F]{4}([0-9A-F]{4})?$" },
        "ensembleId": { "type": "string", "pattern": "^[0-9A-F]{4}$" },
        "area": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "city": { "type": "string", "maxLength": 80 },
            "region": { "type": "string", "maxLength": 80 },
            "country": { "type": "string", "pattern": "^[A-Z]{2}$" }
          }
        },
        "coverage": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "note": { "type": "string", "maxLength": 300 },
            "url": { "type": "string", "format": "uri", "maxLength": 2000 }
          }
        },
        "site": {
          "type": "object",
          "required": ["latitude", "longitude"],
          "additionalProperties": false,
          "properties": {
            "latitude": { "type": "number", "minimum": -90, "maximum": 90 },
            "longitude": { "type": "number", "minimum": -180, "maximum": 180 }
          }
        },
        "regulatorIds": {
          "type": "array",
          "maxItems": 10,
          "items": { "$ref": "#/$defs/regulatorId" }
        }
      }
    },
    "regulatorId": {
      "type": "object",
      "required": ["authority", "id"],
      "additionalProperties": false,
      "properties": {
        "authority": { "type": "string", "pattern": "^[a-z]{2,3}\\.[a-z0-9-]{1,32}$" },
        "kind": { "type": "string", "pattern": "^[a-z0-9_]{1,32}$" },
        "id": { "type": "string", "minLength": 1, "maxLength": 64 }
      }
    }
  }
}
