{
  "title": "Resource",
  "description": "An OpenStreetMap community resource",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "type",
    "locationSet",
    "strings"
  ],

  "properties": {

    "id": {
      "description": "(required) A unique identifier for the resource",
      "type": "string",
      "pattern": "^[-_.A-Za-z0-9]+$"
    },

    "type": {
      "description": "(required) Type of community resource",
      "type": "string",
      "enum": [
        "aparat",
        "bluesky",
        "discord",
        "discourse",
        "facebook",
        "fediverse",
        "forum",
        "github",
        "gitlab",
        "group",
        "instagram",
        "irc",
        "linkedin",
        "mailinglist",
        "mastodon",
        "matrix",
        "meetup",
        "newsletter",
        "osm",
        "osm-lc",
        "reddit",
        "signal",
        "slack",
        "telegram",
        "threads",
        "tiktok",
        "twitter",
        "url",
        "wiki",
        "x",
        "xmpp",
        "youthmappers",
        "youtube",
        "zulip"
      ]
    },

    "account": {
      "description": "(optional) Resource account string, required for some resource types",
      "examples": ["talk-af"],
      "type": "string"
    },

    "locationSet": {
      "$comment": "See location-conflation documentation for compatible values: https://github.com/rapideditor/location-conflation#readme",
      "description": "(required) included and excluded locations for this item",
      "$ref": "#/definitions/locationSet"
    },

    "languageCodes": {
      "description": "(optional) Array of ISO-639-1 (2 letter) or ISO-639-3 (3 letter) codes in lowercase",
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "string",
        "pattern": "^[a-z]{2,3}(-[a-zA-Z]{2})?$"
      }
    },

    "strings": {
      "description": "(required) Source text strings related to this community resource",
      "$comment": "All strings should be provided in English, and will be sent to Transifex for translation",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "community": {
          "description": "(optional) Community Name",
          "examples": ["OpenStreetMap Afghanistan"],
          "type": "string"
        },
        "communityID": {
          "description": "(generated) A unique identifier generated automatically from the Community Name string",
          "$comment": "Only generated if community is present . See https://github.com/osmlab/osm-community-index/issues/616",
          "examples": ["openstreetmapafghanistan"],
          "type": "string",
          "pattern": "^[-_.A-Za-z0-9]+$"
        },
        "name": {
          "description": "(optional) Display name for this community resource",
          "examples": ["Talk-af Mailing List"],
          "type": "string"
        },
        "description": {
          "description": "(optional) One line description of the community resource",
          "type": "string"
        },
        "extendedDescription": {
          "description": "(optional) Longer description of the community resource",
          "type": "string"
        },
        "signupUrl": {
          "description": "(optional) A url link to sign up for the community resource",
          "type": "string"
        },
        "url": {
          "description": "(optional) A url link to visit the community resource",
          "type": "string"
        }
      }
    },

    "contacts": {
      "description": "(optional) People to contact about this community resource",
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "object",
        "required": ["name", "email"],
        "properties": {
          "name": {
            "description": "The contact person's name",
            "type": "string"
          },
          "email": {
            "description": "The contact person's email address",
            "type": "string",
            "format": "email"
          }
        }
      }
    },

    "order": {
      "$comment": "When several resources with same geography are present, this controls the display order.",
      "description": "(optional) Suggested sort order for this resource (default = 0, higher numbers display more prominently)",
      "type": "number"
    },

    "events": {
      "description": "(optional) Featured events for this resource",
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "object",
        "required": [
          "name",
          "description",
          "when",
          "where"
        ],
        "dependencies": {
          "i18n": { "required": ["id"] }
        },
        "properties": {
          "i18n": {
            "enum": [ true ],
            "description": "(optional) if true, `name`, `description` and `where` will be translated",
            "type": "boolean"
          },
          "id": {
            "description": "(required if i18n=true) A unique identifier for the event",
            "type": "string",
            "pattern": "^[-_.A-Za-z0-9]+$"
          },
          "name": {
            "$comment": "In local language by default, in English if `i18n=true`",
            "description": "(required) Name of the event",
            "type": "string"
          },
          "description": {
            "$comment": "In local language by default, in English if `i18n=true`",
            "description": "(required) One line description of the event",
            "type": "string"
          },
          "where": {
            "$comment": "In local language by default, in English if `i18n=true`",
            "description": "(required) Where the event is",
            "type": "string"
          },
          "when": {
            "description": "(required) When the event is (Should be a string parseable by Date.parse, and assumed to be local time zone for the event)",
            "type": "string"
          },
          "url": {
            "description": "(optional) A url link for the event",
            "type": "string",
            "pattern": "(https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*))|(mailto:.+)"
          }
        }
      }
    }
  },

  "definitions": {

    "countryCoder": {
      "$comment": "See country-coder documentation for compatible values: https://github.com/rapideditor/country-coder#readme",
      "description": "A country code (ISO 3166-1, United Nations M49, or anything recognized by country-coder)",
      "type": "string"
    },

    "circularArea": {
      "description": "A circular area defined as [longitude, latitude, radius?]. If not specified, radius will default to 25km.",
      "type": "array",
      "minItems": 2,
      "maxItems": 3,
      "items": {
        "type": "number"
      }
    },

    "geojsonFilename": {
      "description": "A filename for one of the custom geojson features in this project",
      "type": "string",
      "pattern": "^.*\\.geojson$"
    },

    "locationSet": {
      "$comment": "See location-conflation documentation for compatible values: https://github.com/rapideditor/location-conflation#readme",
      "type": "object",
      "additionalProperties": false,
      "required": ["include"],
      "properties": {
        "include": {
          "description": "(required) locations included",
          "type": "array",
          "uniqueItems": true,
          "items": {
            "anyOf": [
              { "$ref": "#/definitions/countryCoder" },
              { "$ref": "#/definitions/circularArea" },
              { "$ref": "#/definitions/geojsonFilename" }
            ]
          }
        },
        "exclude": {
          "description": "(optional) locations excluded",
          "type": "array",
          "uniqueItems": true,
          "items": {
            "anyOf": [
              { "$ref": "#/definitions/countryCoder" },
              { "$ref": "#/definitions/circularArea" },
              { "$ref": "#/definitions/geojsonFilename" }
            ]
          }
        }
      }
    }

  }
}
