{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "mpmedia/step-processor/parts-mapping/v1",
  "title": "PartsMapping",
  "description": "Mapping file that classifies parts from a STEP assembly tree. Used by the external diagram generator to determine geometry scope and labels. Supports Chinese-to-English normalization. One file per product model, stored alongside the STEP file or in a shared product data directory.",

  "type": "object",
  "required": ["model_number", "parts"],

  "properties": {
    "model_number": {
      "type": "string",
      "description": "Product model number this mapping applies to. e.g. 'MR28UW'"
    },
    "parts": {
      "type": "object",
      "description": "Keyed by original part name from STEP file (may be Chinese). Value is a classification object.",
      "additionalProperties": {
        "type": "object",
        "required": ["english_name", "category"],
        "properties": {
          "english_name": {
            "type": "string",
            "description": "Translated/normalized English name. Used in diagrams and BOM."
          },
          "category": {
            "type": "string",
            "enum": ["enclosure", "mounting", "internal", "fastener", "display_panel", "cable", "other"],
            "description": "Classification drives inclusion/exclusion logic per diagram mode."
          },
          "include_in_diagram": {
            "type": "boolean",
            "default": true,
            "description": "Override flag. False = always exclude from diagrams regardless of mode."
          },
          "diagram_label": {
            "type": ["string", "null"],
            "description": "Optional custom label shown on the diagram for this part. If null, english_name is used."
          },
          "mounting_variant": {
            "type": ["string", "null"],
            "description": "If this part belongs to a specific mounting variant, name it here. e.g. 'Wall Mount VESA 200x200'. Parts with the same variant_name are shown/hidden together."
          },
          "notes": {
            "type": "string",
            "description": "Free-text notes for documentation or translator flags."
          }
        }
      }
    },
    "mounting_variants": {
      "type": ["array", "null"],
      "description": "Named mounting configurations available in this STEP file. Each variant is a named group of mounting parts that should be shown together.",
      "items": {
        "type": "object",
        "required": ["name"],
        "properties": {
          "name":        { "type": "string" },
          "description": { "type": "string" },
          "default":     { "type": "boolean", "description": "True = use this variant when mode is enclosure_plus_mounting and no variant is specified." }
        }
      }
    }
  },

  "examples": [
    {
      "model_number": "MR28UW",
      "parts": {
        "前面板": {
          "english_name": "Front Panel",
          "category": "enclosure",
          "include_in_diagram": true,
          "diagram_label": null,
          "mounting_variant": null
        },
        "安装支架": {
          "english_name": "Mounting Bracket",
          "category": "mounting",
          "include_in_diagram": true,
          "diagram_label": "Wall Mount Bracket",
          "mounting_variant": "Wall Mount"
        },
        "VESA板": {
          "english_name": "VESA Plate 200x200",
          "category": "mounting",
          "include_in_diagram": true,
          "diagram_label": "VESA 200x200 Plate",
          "mounting_variant": "VESA Mount"
        },
        "螺钉M4": {
          "english_name": "M4 Screw",
          "category": "fastener",
          "include_in_diagram": false,
          "notes": "Internal fastener - exclude from all diagrams"
        },
        "主板": {
          "english_name": "Main Board",
          "category": "internal",
          "include_in_diagram": false
        }
      },
      "mounting_variants": [
        { "name": "Wall Mount",      "description": "Standard wall mount bracket",    "default": true },
        { "name": "VESA Mount",      "description": "VESA 200x200 compatible plate",  "default": false }
      ]
    }
  ]
}
