{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:folio:1:settings",
  "title": "settings.json",
  "description": "Targets, meal slots and preferences. Only in full exports. Never holds an API key.",
  "type": "object",
  "required": [],
  "properties": {
    "targets": {
      "type": "object",
      "required": [
        "kcal",
        "protein",
        "carbs",
        "fat"
      ],
      "properties": {
        "kcal": {
          "type": "integer",
          "minimum": 1000,
          "maximum": 6000
        },
        "protein": {
          "type": "integer",
          "minimum": 0
        },
        "carbs": {
          "type": "integer",
          "minimum": 0
        },
        "fat": {
          "type": "integer",
          "minimum": 0
        },
        "trainingDays": {
          "type": "array",
          "items": {
            "type": "integer",
            "minimum": 1,
            "maximum": 7,
            "description": "1 = Monday … 7 = Sunday."
          },
          "uniqueItems": true
        },
        "trainingExtraKcal": {
          "type": "integer",
          "minimum": 0
        },
        "trainingEnabled": {
          "type": "boolean",
          "description": "Absent: on when there are training days."
        }
      },
      "description": "Daily targets: kcal, and protein, carbs and fat in grams."
    },
    "mealSlots": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "name",
          "time",
          "weekdays"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "name": {
            "type": "string",
            "minLength": 1
          },
          "time": {
            "type": "string",
            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$",
            "description": "HH:MM, 24-hour."
          },
          "weekdays": {
            "type": "array",
            "items": {
              "type": "integer",
              "minimum": 1,
              "maximum": 7,
              "description": "1 = Monday … 7 = Sunday."
            },
            "uniqueItems": true
          },
          "share": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "description": "Whole % of the day. Missing: split equally."
          }
        }
      }
    },
    "displayMode": {
      "enum": [
        "asWritten",
        "metric",
        "us"
      ]
    },
    "appearance": {
      "enum": [
        "system",
        "light",
        "dark"
      ]
    },
    "aiProvider": {
      "anyOf": [
        {
          "enum": [
            "anthropic",
            "openai",
            "google"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "aiModels": {
      "type": "object",
      "propertyNames": {
        "enum": [
          "anthropic",
          "openai",
          "google"
        ]
      },
      "additionalProperties": {
        "type": "string"
      },
      "description": "The model picked for each provider."
    },
    "energyUnit": {
      "enum": [
        "kcal",
        "kJ"
      ],
      "description": "Missing: kcal."
    },
    "ovenUnit": {
      "enum": [
        "celsius",
        "fahrenheit"
      ],
      "description": "Temperatures in method steps. Missing: the device region's default."
    },
    "planning": {
      "type": "object",
      "required": [],
      "properties": {
        "leftoverDays": {
          "type": "integer",
          "minimum": 0
        },
        "maxRepeats": {
          "type": "integer",
          "minimum": 1
        },
        "planSeed": {
          "type": "integer"
        }
      },
      "description": "Week planner settings; each missing field keeps its default (2, 2, 0)."
    }
  },
  "not": {
    "anyOf": [
      {
        "required": [
          "apiKey"
        ]
      },
      {
        "required": [
          "api_key"
        ]
      },
      {
        "required": [
          "accessKey"
        ]
      },
      {
        "required": [
          "key"
        ]
      },
      {
        "required": [
          "unsplashAccessKey"
        ]
      },
      {
        "required": [
          "anthropicKey"
        ]
      },
      {
        "required": [
          "openaiKey"
        ]
      },
      {
        "required": [
          "googleKey"
        ]
      }
    ]
  }
}
