{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "required": ["mode"],
  "anyOf": [{
    "required": ["version", "payment", "curves"],
    "additionalProperties": false,
    "properties": {
      "mode": {"enum": ["elwig"]},
      "version": {"enum": [1]},
      "consider_delivery_modifiers": {"type": "boolean"},
      "consider_contract_penalties": {"type": "boolean"},
      "consider_total_penalty": {"type": "boolean"},
      "consider_auto_business_shares": {"type": "boolean"},
      "consider_custom_modifiers": {"type": "boolean"},
      "net_weight_modifier": {"type": "number"},
      "gross_weight_modifier": {"type": "number"},
      "payment": {"$ref": "#/definitions/payment_1"},
      "quality": {"$ref": "#/definitions/quality_1"},
      "curves": {
        "type": "array",
        "items": {"$ref": "#/definitions/curve"}
      }
    }
  }, {
    "required": ["AuszahlungSorten", "Kurven"],
    "properties": {
      "mode": {"enum": ["wgmaster"]},
      "Rebelzuschlag": {"type": "number"},
      "AuszahlungSorten": {"$ref": "#/definitions/payment_1"},
      "AuszahlungSortenQualitätsstufe": {"$ref": "#/definitions/quality_1"},
      "Kurven": {
        "type": "array",
        "items": {"$ref": "#/definitions/curve"}
      }
    }
  }],
  "definitions": {
    "payment_1": {
      "type": ["number", "string", "object"],
      "pattern": "^curve:[0-9]+$",
      "additionalProperties": false,
      "properties": {
        "default": {
          "type": ["number", "string"],
          "pattern": "^curve:[0-9]+$"
        }
      },
      "patternProperties": {
        "^([A-Z]{2})?(\/[A-Z]*)?(-[A-Z][A-Z0-9]*)?$": {
          "type": ["number", "string"],
          "pattern": "^curve:[0-9]+$"
        }
      }
    },
    "quality_1": {
      "type": "object",
        "additionalProperties": false,
        "patternProperties": {
          "^[A-Z]{3}$": {
            "type": ["number", "string", "object"],
            "pattern": "^curve:[0-9]+$",
            "additionalProperties": false,
            "properties": {
              "default": {
                "type": ["number", "string"],
                "pattern": "^curve:[0-9]+$"
              }
            },
            "patternProperties": {
              "^([A-Z]{2})?(\/[A-Z]*)?(-[A-Z][A-Z0-9]*)?$": {
                "type": ["number", "string"],
                "pattern": "^curve:[0-9]+$"
              }
            }
          }
        }
    },
    "curve": {
      "type": "object",
      "required": ["id", "mode", "data"],
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "integer",
          "minimum": 0
        },
        "mode": {"enum": ["oe", "kmw"]},
        "data": {
          "anyOf": [
            {"type": "number"},
            {"$ref": "#/definitions/curve_data"}
          ]
        },
        "geb": {
          "anyOf": [
            {"type": "number"},
            {"$ref": "#/definitions/curve_data"}
          ]
        }
      }
    },
    "curve_data": {
      "type": "object",
      "additionalProperties": false,
      "minProperties": 1,
      "patternProperties": {
        "^[<>]?([0-9]+(\\.[0-9]+)?)(oe|kmw)$": {"type": "number"}
      }
    }
  }
}
