{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "annotatedText": {
      "properties": {
        "annotations": {
          "items": {
            "ref": "#annotation",
            "type": "ref"
          },
          "type": "array"
        },
        "text": {
          "maxLength": 20000,
          "type": "string"
        }
      },
      "required": [
        "text"
      ],
      "type": "object"
    },
    "annotation": {
      "description": "Marks up a range of the text. Offsets are zero-indexed counts of UTF-8 bytes; the start is inclusive and the end exclusive.",
      "properties": {
        "byteEnd": {
          "minimum": 0,
          "type": "integer"
        },
        "byteStart": {
          "minimum": 0,
          "type": "integer"
        },
        "type": {
          "knownValues": [
            "em",
            "strong",
            "underline",
            "locale"
          ],
          "maxLength": 100,
          "type": "string"
        },
        "value": {
          "description": "For 'locale' annotations, the language tag of the annotated range.",
          "maxLength": 100,
          "type": "string"
        }
      },
      "required": [
        "type",
        "byteStart",
        "byteEnd"
      ],
      "type": "object"
    },
    "context": {
      "description": "Where this postcard came from, and who is describing it.",
      "properties": {
        "author": {
          "ref": "#person",
          "type": "ref"
        },
        "description": {
          "maxLength": 20000,
          "type": "string"
        }
      },
      "type": "object"
    },
    "date": {
      "description": "A calendar date, with no time of day or timezone.",
      "properties": {
        "day": {
          "maximum": 31,
          "minimum": 1,
          "type": "integer"
        },
        "month": {
          "maximum": 12,
          "minimum": 1,
          "type": "integer"
        },
        "year": {
          "minimum": 1,
          "type": "integer"
        }
      },
      "required": [
        "year",
        "month",
        "day"
      ],
      "type": "object"
    },
    "flipBook": {
      "description": "Flips about a vertical axis, like a book.",
      "type": "token"
    },
    "flipCalendar": {
      "description": "Flips about a horizontal axis, like a calendar.",
      "type": "token"
    },
    "flipLeftHand": {
      "description": "Flips about the up-right diagonal axis, as if flipped with your left hand. The sides have different orientations.",
      "type": "token"
    },
    "flipNone": {
      "description": "The postcard has only one side.",
      "type": "token"
    },
    "flipRightHand": {
      "description": "Flips about the down-right diagonal axis, as if flipped with your right hand. The sides have different orientations.",
      "type": "token"
    },
    "location": {
      "properties": {
        "countryCode": {
          "description": "ISO 3166-1 alpha-3 country code.",
          "maxLength": 3,
          "minLength": 3,
          "type": "string"
        },
        "latitude": {
          "description": "Decimal degrees, as a string (atproto has no floating point numbers).",
          "maxLength": 32,
          "type": "string"
        },
        "longitude": {
          "description": "Decimal degrees, as a string (atproto has no floating point numbers).",
          "maxLength": 32,
          "type": "string"
        },
        "name": {
          "maxLength": 1000,
          "type": "string"
        }
      },
      "type": "object"
    },
    "main": {
      "description": "A postcard. The record key is a TID whose timestamp is the date the postcard was sent (or the date it was uploaded, if that's unknown; 1970-01-01 if it was sent before then), with its remaining bits taken from the image's own hash.",
      "key": "tid",
      "record": {
        "properties": {
          "context": {
            "ref": "#context",
            "type": "ref"
          },
          "flip": {
            "description": "The axis the physical postcard flips about, to keep both sides upright.",
            "knownValues": [
              "org.dotpostcard.postcard#flipBook",
              "org.dotpostcard.postcard#flipLeftHand",
              "org.dotpostcard.postcard#flipCalendar",
              "org.dotpostcard.postcard#flipRightHand",
              "org.dotpostcard.postcard#flipNone"
            ],
            "maxLength": 100,
            "type": "string"
          },
          "image": {
            "accept": [
              "image/*"
            ],
            "description": "A 'web' format postcard image: the front of the postcard above the back (rotated so the specified flip works), with the postcard's XMP metadata embedded.",
            "type": "blob"
          },
          "locale": {
            "description": "The language the descriptions and transcriptions are written in, unless annotated otherwise.",
            "format": "language",
            "type": "string"
          },
          "location": {
            "ref": "#location",
            "type": "ref"
          },
          "physical": {
            "ref": "#physical",
            "type": "ref"
          },
          "recipient": {
            "ref": "#person",
            "type": "ref"
          },
          "sender": {
            "ref": "#person",
            "type": "ref"
          },
          "sentOn": {
            "description": "The date the postcard was sent.",
            "ref": "#date",
            "type": "ref"
          },
          "sides": {
            "description": "The sides of the postcard, front first. One-sided postcards (flipNone) have a single side.",
            "items": {
              "ref": "#side",
              "type": "ref"
            },
            "maxLength": 2,
            "minLength": 1,
            "type": "array"
          },
          "title": {
            "description": "The postcard's human-readable title.",
            "maxGraphemes": 300,
            "maxLength": 3000,
            "type": "string"
          }
        },
        "required": [
          "image",
          "flip",
          "sides",
          "physical"
        ],
        "type": "object"
      },
      "type": "record"
    },
    "person": {
      "properties": {
        "name": {
          "maxLength": 1000,
          "type": "string"
        },
        "uri": {
          "format": "uri",
          "type": "string"
        }
      },
      "type": "object"
    },
    "physical": {
      "description": "The physical attributes of the postcard.",
      "properties": {
        "cardColor": {
          "description": "The colour of the card the postcard is made from.",
          "ref": "#rgbColor",
          "type": "ref"
        },
        "frontSize": {
          "ref": "#size",
          "type": "ref"
        },
        "thicknessUm": {
          "description": "The thickness of the postcard, in micrometres.",
          "minimum": 1,
          "type": "integer"
        }
      },
      "required": [
        "frontSize"
      ],
      "type": "object"
    },
    "point": {
      "description": "A point on one side of the postcard, in ten-thousandths of that side's width (x, from the left) and height (y, from the top).",
      "properties": {
        "x": {
          "maximum": 10000,
          "minimum": 0,
          "type": "integer"
        },
        "y": {
          "maximum": 10000,
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "x",
        "y"
      ],
      "type": "object"
    },
    "rgbColor": {
      "properties": {
        "b": {
          "maximum": 255,
          "minimum": 0,
          "type": "integer"
        },
        "g": {
          "maximum": 255,
          "minimum": 0,
          "type": "integer"
        },
        "r": {
          "maximum": 255,
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "r",
        "g",
        "b"
      ],
      "type": "object"
    },
    "secret": {
      "properties": {
        "points": {
          "description": "The vertices of the polygon bounding the region.",
          "items": {
            "ref": "#point",
            "type": "ref"
          },
          "minLength": 3,
          "type": "array"
        },
        "prehidden": {
          "default": true,
          "description": "False if this region still shows its private information in the image; regions are assumed to be already obscured.",
          "type": "boolean"
        }
      },
      "required": [
        "points"
      ],
      "type": "object"
    },
    "side": {
      "properties": {
        "description": {
          "description": "A description of what this side depicts, suitable for use as alt text.",
          "maxLength": 20000,
          "type": "string"
        },
        "secrets": {
          "description": "Regions of this side which hold private information, and should be obscured.",
          "items": {
            "ref": "#secret",
            "type": "ref"
          },
          "type": "array"
        },
        "transcription": {
          "ref": "#annotatedText",
          "type": "ref"
        }
      },
      "type": "object"
    },
    "size": {
      "description": "The dimensions of the front of the postcard.",
      "properties": {
        "heightMm": {
          "minimum": 1,
          "type": "integer"
        },
        "heightPx": {
          "minimum": 1,
          "type": "integer"
        },
        "widthMm": {
          "minimum": 1,
          "type": "integer"
        },
        "widthPx": {
          "minimum": 1,
          "type": "integer"
        }
      },
      "required": [
        "widthPx",
        "heightPx"
      ],
      "type": "object"
    }
  },
  "description": "A digitised physical postcard: an image of its side(s), and the metadata describing it.",
  "id": "org.dotpostcard.postcard",
  "lexicon": 1
}
