{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://compositionfacts.org/schema/1.0.0-rc.1/supplement.schema.json",
  "title": "Composition Facts - SupplementProduct profile (v1.0.0-rc.1)",
  "description": "Validates a Composition Facts JSON-LD document (compacted form) for a dietary supplement. Keys starting with '_' are human annotations and are ignored by JSON-LD processors. Valid values for country-specific code schemes live in the countries data files, not in this schema.",
  "type": "object",
  "properties": {
    "@context": {
      "description": "Canonical form: the dual context [schema.org, compositionfacts.org] - Google's validators only dereference schema.org; full processors load both.",
      "oneOf": [
        {
          "const": [
            "https://schema.org",
            "https://compositionfacts.org/ns/1.0/context.jsonld"
          ]
        },
        {
          "type": "string",
          "const": "https://compositionfacts.org/ns/1.0/context.jsonld"
        },
        {
          "type": "object"
        }
      ]
    },
    "id": {
      "type": "string",
      "format": "uri"
    },
    "type": {
      "const": "DietarySupplement"
    },
    "conformsTo": {
      "type": "string",
      "const": "https://compositionfacts.org/spec/1.0.0-rc.1"
    },
    "version": {
      "type": "string",
      "minLength": 1
    },
    "name": {
      "$ref": "#/$defs/LanguageMap"
    },
    "description": {
      "$ref": "#/$defs/LanguageMap"
    },
    "brand": {
      "type": "string",
      "minLength": 1
    },
    "gtin13": {
      "type": "string",
      "pattern": "^[0-9]{13}$"
    },
    "sku": {
      "type": "string"
    },
    "sameAs": {
      "type": "string",
      "format": "uri"
    },
    "hasPart": {
      "type": "array"
    },
    "classification": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Classification"
      }
    },
    "dosageForm": {
      "type": "string"
    },
    "modifiedRelease": {
      "type": "boolean"
    },
    "galenicNote": {
      "$ref": "#/$defs/LanguageMap"
    },
    "flavor": {
      "$ref": "#/$defs/LanguageMap"
    },
    "pharmacyOnly": {
      "type": "boolean"
    },
    "distributionChannel": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "lifecycleStatus": {
      "type": "string"
    },
    "manufacturer": {
      "$ref": "#/$defs/Organization"
    },
    "seller": {
      "$ref": "#/$defs/Organization"
    },
    "regulatoryStatus": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/RegulatoryStatus"
      }
    },
    "dietaryProfile": {
      "$ref": "#/$defs/DietaryProfile"
    },
    "recommendedIntake": {
      "$ref": "#/$defs/DoseSchedule"
    },
    "maximumIntake": {
      "$ref": "#/$defs/DoseSchedule"
    },
    "composition": {
      "$ref": "#/$defs/SupplementComposition"
    },
    "ingredientStatement": {
      "$ref": "#/$defs/LanguageMap"
    },
    "healthClaim": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/HealthClaim"
      }
    },
    "nationalCode": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/NationalProductCode"
      }
    },
    "responsiblePerson": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ResponsiblePerson"
      }
    },
    "warning": {
      "$ref": "#/$defs/LanguageMap"
    },
    "foodWarning": {
      "$ref": "#/$defs/LanguageMap"
    },
    "interaction": {
      "type": "array"
    },
    "validation": {
      "$ref": "#/$defs/Validation"
    }
  },
  "required": [
    "@context",
    "id",
    "type",
    "conformsTo",
    "version",
    "name",
    "brand",
    "regulatoryStatus",
    "composition"
  ],
  "patternProperties": {
    "^_": {}
  },
  "additionalProperties": false,
  "$defs": {
    "LanguageMap": {
      "description": "Text per BCP-47 language tag, e.g. {\"de\": \"...\", \"en\": \"...\"}. Numbers are never translated; legally binding wordings are never guessed.",
      "type": "object",
      "minProperties": 1,
      "patternProperties": {
        "^[a-z]{2}(-[A-Z]{2})?$": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false
    },
    "QuantitativeValue": {
      "type": "object",
      "properties": {
        "type": {
          "const": "QuantitativeValue"
        },
        "value": {
          "type": "number",
          "minimum": 0
        },
        "unitCode": {
          "type": "string",
          "description": "UN/ECE Recommendation 20 code, e.g. MGM, MC, GRM"
        },
        "unitText": {
          "type": "string",
          "minLength": 1,
          "description": "Human- and LLM-readable unit, e.g. mg, µg (S-13)"
        }
      },
      "required": [
        "type",
        "value",
        "unitText"
      ],
      "patternProperties": {
        "^_": {}
      },
      "additionalProperties": false
    },
    "Identifier": {
      "description": "Substance anchor. Three open registries (S-18): wikidata, pubchem, foodex2.",
      "type": "object",
      "properties": {
        "scheme": {
          "enum": [
            "wikidata",
            "pubchem",
            "foodex2"
          ]
        },
        "code": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "scheme",
        "code"
      ],
      "additionalProperties": false
    },
    "SourceCompound": {
      "description": "The source relationship: which compound delivers the nutrient, optionally with the compound's own weight (e.g. 300 mg magnesium FROM 694 mg magnesium malate).",
      "type": "object",
      "properties": {
        "type": {
          "const": "SourceCompound"
        },
        "name": {
          "$ref": "#/$defs/LanguageMap"
        },
        "identifier": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Identifier"
          }
        },
        "amount": {
          "$ref": "#/$defs/QuantitativeValue"
        }
      },
      "required": [
        "type",
        "name"
      ],
      "patternProperties": {
        "^_": {}
      },
      "additionalProperties": false
    },
    "NutrientDeclaration": {
      "type": "object",
      "properties": {
        "type": {
          "const": "NutrientDeclaration"
        },
        "substance": {
          "$ref": "#/$defs/LanguageMap"
        },
        "identifier": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/Identifier"
          }
        },
        "amount": {
          "$ref": "#/$defs/QuantitativeValue"
        },
        "referenceIntake": {
          "type": "number",
          "minimum": 0,
          "description": "Percent as number (S-12), e.g. 80 for 80 %"
        },
        "referenceBasis": {
          "type": "string",
          "description": "e.g. EU_NRV_1169_2011"
        },
        "sourceCompound": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/SourceCompound"
          }
        }
      },
      "required": [
        "type",
        "substance",
        "amount"
      ],
      "dependentRequired": {
        "referenceIntake": [
          "referenceBasis"
        ]
      },
      "patternProperties": {
        "^_": {}
      },
      "additionalProperties": false
    },
    "SupplementComposition": {
      "description": "The declaration table (D1): one shared basis for all entries (S-11), entries as an OPEN list - any substance, not a fixed column set.",
      "type": "object",
      "properties": {
        "type": {
          "const": "SupplementComposition"
        },
        "basis": {
          "$ref": "#/$defs/QuantitativeValue"
        },
        "basisDescription": {
          "$ref": "#/$defs/LanguageMap"
        },
        "entry": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/NutrientDeclaration"
          }
        }
      },
      "required": [
        "type",
        "basis",
        "entry"
      ],
      "patternProperties": {
        "^_": {}
      },
      "additionalProperties": false
    },
    "DoseSchedule": {
      "type": "object",
      "properties": {
        "type": {
          "enum": [
            "RecommendedDoseSchedule",
            "MaximumDoseSchedule"
          ]
        },
        "doseValue": {
          "type": "number",
          "minimum": 0
        },
        "doseUnit": {
          "type": "string"
        },
        "frequency": {
          "type": "string"
        },
        "targetPopulation": {
          "type": "string"
        },
        "description": {
          "$ref": "#/$defs/LanguageMap"
        }
      },
      "required": [
        "type"
      ],
      "patternProperties": {
        "^_": {}
      },
      "additionalProperties": false
    },
    "HealthClaim": {
      "type": "object",
      "properties": {
        "type": {
          "const": "HealthClaim"
        },
        "relatedNutrient": {
          "type": "string"
        },
        "claimText": {
          "$ref": "#/$defs/LanguageMap"
        },
        "legalBasis": {
          "type": "string"
        },
        "claimStatus": {
          "enum": [
            "authorized",
            "non-authorized",
            "on-hold"
          ],
          "description": "Status in the EU claims register (VO (EU) 432/2012 and successors)"
        }
      },
      "required": [
        "type",
        "claimText",
        "legalBasis",
        "claimStatus"
      ],
      "patternProperties": {
        "^_": {}
      },
      "additionalProperties": false
    },
    "NationalProductCode": {
      "type": "object",
      "properties": {
        "type": {
          "const": "NationalProductCode"
        },
        "scheme": {
          "type": "string",
          "minLength": 1,
          "description": "Controlled list lives in the countries data files (S-08/S-31), e.g. PZN-DE"
        },
        "code": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "type",
        "scheme",
        "code"
      ],
      "additionalProperties": false
    },
    "ResponsiblePerson": {
      "type": "object",
      "properties": {
        "type": {
          "const": "ResponsiblePerson"
        },
        "role": {
          "enum": [
            "lmiv",
            "gpsr",
            "cosmetic"
          ]
        },
        "name": {
          "$ref": "#/$defs/LanguageMap"
        },
        "address": {
          "type": "string"
        }
      },
      "required": [
        "type",
        "role",
        "name"
      ],
      "patternProperties": {
        "^_": {}
      },
      "additionalProperties": false
    },
    "RegulatoryStatus": {
      "type": "object",
      "properties": {
        "type": {
          "const": "RegulatoryStatus"
        },
        "market": {
          "type": "string",
          "pattern": "^[A-Z]{2}$"
        },
        "productClass": {
          "type": "string"
        },
        "intendedPurpose": {
          "$ref": "#/$defs/LanguageMap"
        },
        "legalFramework": {
          "type": "string"
        },
        "notification": {
          "$ref": "#/$defs/Notification"
        }
      },
      "required": [
        "type",
        "market",
        "productClass"
      ],
      "patternProperties": {
        "^_": {}
      },
      "additionalProperties": false
    },
    "Notification": {
      "type": "object",
      "properties": {
        "type": {
          "const": "Notification"
        },
        "authority": {
          "type": "string"
        },
        "notificationId": {
          "type": "string"
        },
        "notifiedOn": {
          "type": "string"
        }
      },
      "required": [
        "type",
        "authority"
      ],
      "patternProperties": {
        "^_": {}
      },
      "additionalProperties": false
    },
    "Classification": {
      "type": "object",
      "properties": {
        "type": {
          "const": "Classification"
        },
        "axis": {
          "enum": [
            "category",
            "substance",
            "anatomical",
            "targetGroup"
          ]
        },
        "scheme": {
          "type": "string",
          "description": "e.g. shopify-2026-08, gpc"
        },
        "code": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "type",
        "axis",
        "code"
      ],
      "additionalProperties": false
    },
    "DietaryProfile": {
      "type": "object",
      "properties": {
        "type": {
          "const": "DietaryProfile"
        },
        "freeFrom": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "suitableForDiet": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "type"
      ],
      "patternProperties": {
        "^_": {}
      },
      "additionalProperties": false
    },
    "Organization": {
      "type": "object",
      "properties": {
        "type": {
          "const": "Organization"
        },
        "name": {
          "$ref": "#/$defs/LanguageMap"
        },
        "address": {
          "type": "string"
        }
      },
      "required": [
        "type",
        "name"
      ],
      "patternProperties": {
        "^_": {}
      },
      "additionalProperties": false
    },
    "Validation": {
      "type": "object",
      "properties": {
        "type": {
          "const": "Validation"
        },
        "validatedBy": {
          "type": "string"
        },
        "validatedOn": {
          "type": "string"
        }
      },
      "required": [
        "type"
      ],
      "patternProperties": {
        "^_": {}
      },
      "additionalProperties": false
    }
  }
}
