{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/craftingeventfinder-com/json-schema/craftingeventfinder-com-preferences-state-schema.json",
  "title": "PreferencesState",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/craftingeventfinder-com-preferences-api-openapi.yml#/components/schemas/PreferencesState",
  "type": "object",
  "properties": {
    "preferences": {
      "$ref": "#/$defs/Preferences"
    },
    "source": {
      "type": "string",
      "enum": [
        "account",
        "cookie",
        "default"
      ]
    }
  },
  "required": [
    "preferences",
    "source"
  ],
  "$defs": {
    "Preferences": {
      "type": "object",
      "properties": {
        "crafts": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9-]{2,40}$"
          },
          "maxItems": 20
        },
        "formats": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "in_person",
              "online"
            ]
          },
          "minItems": 1,
          "maxItems": 2
        },
        "freeOnly": {
          "type": "boolean"
        },
        "when": {
          "type": "string",
          "enum": [
            "weekend",
            "next30",
            "next90"
          ]
        },
        "place": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "label": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[^\\x00-\\x1F\\x7F]*$"
            }
          },
          "required": [
            "label"
          ]
        },
        "radius": {
          "anyOf": [
            {
              "type": "number",
              "enum": [
                25
              ]
            },
            {
              "type": "number",
              "enum": [
                50
              ]
            },
            {
              "type": "number",
              "enum": [
                100
              ]
            },
            {
              "type": "number",
              "enum": [
                250
              ]
            }
          ]
        },
        "sort": {
          "type": "string",
          "enum": [
            "date",
            "distance"
          ],
          "description": "The results' order: date (soonest first, the default when missing) or distance (nearest first, used only with a place)."
        },
        "showOnline": {
          "type": "boolean",
          "description": "The 'Show online events' switch: the Online events band under local results (true, the default when missing) or one quiet line instead (false)."
        }
      },
      "required": [
        "crafts",
        "formats",
        "freeOnly",
        "when",
        "place",
        "radius"
      ]
    }
  }
}