{
    "type": "object",
    "definitions": {
        "string_limit": {
            "maxLength": 1000
        },
        "id": {
            "maxLength": 1000,
            "pattern": "^[a-z0-9+]+(_[a-z0-9+]+)*$"
        },
        "specific_slicer_settings": {
            "type": "object",
            "properties": {
                "profile_name": {
                    "type": "string",
                    "description": "The name of the profile for this filament. If there is a profile specifically for this filament, that is what should be specified, even if it is printer specific. For slic3r variants, data after the '@' does not need to be included and will be removed when loading into python.",
                    "$ref": "#/definitions/string_limit"
                },
                "overrides": {
                    "type": "object",
                    "description": "Key-value pairs for settings that should be overridden for this filament"
                },
                "id": {
                    "type": "string",
                    "description": "The slicer-native identifier for this filament profile (e.g. GFB00, FFF02)",
                    "$ref": "#/definitions/slicer_id"
                },
                "generic_id": {
                    "type": "string",
                    "description": "Fallback generic slicer profile ID for this material type (e.g. GFL99 for Generic PLA). Used when no brand-specific profile exists.",
                    "$ref": "#/definitions/slicer_id"
                }
            },
            "required": [
                "profile_name"
            ]
        },
        "slicer_settings": {
            "type": "object",
            "properties": {
                "prusaslicer": {
                    "$ref": "#/definitions/specific_slicer_settings",
                    "x-label": "PrusaSlicer",
                    "x-description": "Settings for PrusaSlicer and derivatives. Profile name references built-in or custom profiles."
                },
                "bambustudio": {
                    "$ref": "#/definitions/specific_slicer_settings",
                    "x-label": "Bambu Studio",
                    "x-description": "Settings for Bambu Studio. Compatible with Bambu Lab printers and X1/P1 series."
                },
                "orcaslicer": {
                    "$ref": "#/definitions/specific_slicer_settings",
                    "x-label": "Orca Slicer",
                    "x-description": "Settings for Orca Slicer. Fork of Bambu Studio with extended features."
                },
                "cura": {
                    "$ref": "#/definitions/specific_slicer_settings",
                    "x-label": "Cura",
                    "x-description": "Settings for Ultimaker Cura. Uses Cura profile naming conventions."
                },
                "superslicer": {
                    "$ref": "#/definitions/specific_slicer_settings",
                    "x-label": "SuperSlicer",
                    "x-description": "Settings for SuperSlicer. Fork of PrusaSlicer with additional features."
                },
                "elegooslicer": {
                    "$ref": "#/definitions/specific_slicer_settings",
                    "x-label": "Elegoo Slicer",
                    "x-description": "Settings for Elegoo Slicer. Compatible with Elegoo FDM printers."
                },
                "crealityprint": {
                    "$ref": "#/definitions/specific_slicer_settings",
                    "x-label": "Creality Print",
                    "x-description": "Settings for Creality Print. Compatible with Creality FDM printers."
                },
                "anycubicslicer": {
                    "$ref": "#/definitions/specific_slicer_settings",
                    "x-label": "AnyCubic Slicer",
                    "x-description": "Settings for AnyCubic Slicer. Compatible with AnyCubic FDM printers."
                },
                "kirimoto": {
                    "$ref": "#/definitions/specific_slicer_settings",
                    "x-label": "Kirimoto",
                    "x-description": "Settings for Kirimoto. Compatible with Kirimoto FDM printers."
                },
                "generic": {
                    "type": "object",
                    "x-label": "Generic",
                    "x-description": "Generic temperature settings that apply across all slicers without profile references.",
                    "description": "Generic options that will automatically be mapped to the correct config definition for each slicer. Slicer specific settings are applied first, then these are applied on top.",
                    "properties": {
                        "first_layer_bed_temp": {
                            "type": "integer",
                            "description": "The target bed temperature for the first layer in the generated profile. Should ideally be within [min_bed_temperature, max_bed_temperature]."
                        },
                        "first_layer_nozzle_temp": {
                            "type": "integer",
                            "description": "The target nozzle temperature for the first layer in the generated profile. Should ideally be within [min_print_temperature, max_print_temperature]."
                        },
                        "bed_temp": {
                            "type": "integer",
                            "description": "The target bed temperature for the generated profile. Should ideally be within [min_bed_temperature, max_bed_temperature]."
                        },
                        "nozzle_temp": {
                            "type": "integer",
                            "description": "The target nozzle temperature for the generated profile. Should ideally be within [min_print_temperature, max_print_temperature]."
                        }
                    }
                }
            },
            "additionalProperties": false
        },
        "slicer_id": {
            "type": "string",
            "$ref": "#/definitions/string_limit"
        }
    },
    "properties": {
        "uuid": {
            "type": "string",
            "title": "UUID",
            "description": "Canonical UUID (UUIDv4), assigned automatically by CI on merge. Leave empty when creating.",
            "readOnly": true,
            "pattern": "^$|^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        },
        "moved_from": {
            "type": "array",
            "title": "Moved From",
            "description": "Former canonical UUIDv4(s) this entity previously had (before a merge or move). Lets old UUID references resolve here. Managed by tooling/CI — leave empty when creating.",
            "readOnly": true,
            "items": {
                "type": "string",
                "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
            }
        },
        "id": {
            "type": "string",
            "title": "ID",
            "description": "The unique identifier for this filament",
            "$ref": "#/definitions/id"
        },
        "name": {
            "type": "string",
            "title": "Name",
            "description": "The manufacturer's name for this filament",
            "$ref": "#/definitions/string_limit"
        },
        "diameter_tolerance": {
            "type": "number",
            "title": "Diameter Tolerance (mm)",
            "description": "The diameter tolerance of the filament in mm (e.g., ±0.02)",
            "default": 0.02
        },
        "density": {
            "type": "number",
            "title": "Density (g/cm³)",
            "description": "The density of the filament in g/cm³. Used for weight calculations.",
            "default": 1.24
        },
        "shore_hardness_a": {
            "type": "integer",
            "title": "Shore Hardness A",
            "description": "Hardness on Shore A scale (for flexible materials, typically 20-95)",
            "x-placeholder": "e.g., 95"
        },
        "shore_hardness_d": {
            "type": "integer",
            "title": "Shore Hardness D",
            "description": "Hardness on Shore D scale (for rigid materials, typically 20-90)",
            "x-placeholder": "e.g., 55"
        },
        "certifications": {
            "type": "array",
            "title": "Certifications",
            "items": {
                "type": "string"
            },
            "description": "Certifications the material has (e.g., food-safe, medical-grade)",
            "x-placeholder": "Add certification..."
        },
        "max_dry_temperature": {
            "type": "integer",
            "title": "Max Dry Temp (°C)",
            "description": "Maximum temperature (°C) for drying without degradation",
            "x-placeholder": "e.g., 55"
        },
        "min_print_temperature": {
            "type": "integer",
            "title": "Min Print Temp (°C)",
            "description": "Minimum recommended nozzle temperature for printing (°C)",
            "x-placeholder": "e.g., 190"
        },
        "max_print_temperature": {
            "type": "integer",
            "title": "Max Print Temp (°C)",
            "description": "Maximum recommended nozzle temperature for printing (°C)",
            "x-placeholder": "e.g., 220"
        },
        "preheat_temperature": {
            "type": "integer",
            "title": "Preheat Temp (°C)",
            "description": "Recommended nozzle temperature for preheating/load cell bed leveling (°C)",
            "x-placeholder": "e.g., 170"
        },
        "min_bed_temperature": {
            "type": "integer",
            "title": "Min Bed Temp (°C)",
            "description": "Minimum recommended bed temperature (°C)",
            "x-placeholder": "e.g., 50"
        },
        "max_bed_temperature": {
            "type": "integer",
            "title": "Max Bed Temp (°C)",
            "description": "Maximum recommended bed temperature (°C)",
            "x-placeholder": "e.g., 70"
        },
        "min_chamber_temperature": {
            "type": "integer",
            "title": "Min Chamber Temp (°C)",
            "description": "Minimum recommended chamber temperature (°C)",
            "x-placeholder": "e.g., 40"
        },
        "max_chamber_temperature": {
            "type": "integer",
            "title": "Max Chamber Temp (°C)",
            "description": "Maximum recommended chamber temperature (°C)",
            "x-placeholder": "e.g., 60"
        },
        "chamber_temperature": {
            "type": "integer",
            "title": "Chamber Temp (°C)",
            "description": "Ideal chamber temperature for printing (°C)",
            "x-placeholder": "e.g., 50"
        },
        "min_nozzle_diameter": {
            "type": "number",
            "title": "Min Nozzle Diameter (mm)",
            "description": "Minimum nozzle diameter recommended for this material (mm)",
            "x-placeholder": "e.g., 0.4"
        },
        "data_sheet_url": {
            "type": "string",
            "title": "Data Sheet URL",
            "description": "URL to the manufacturer's technical data sheet",
            "x-placeholder": "https://example.com/...",
            "$ref": "#/definitions/string_limit"
        },
        "safety_sheet_url": {
            "type": "string",
            "title": "Safety Sheet URL",
            "description": "URL to the safety data sheet (SDS/MSDS)",
            "x-placeholder": "https://example.com/...",
            "$ref": "#/definitions/string_limit"
        },
        "discontinued": {
            "type": "boolean",
            "title": "Discontinued",
            "description": "Mark if this filament has been discontinued by the manufacturer"
        },
        "slicer_ids": {
            "type": "object",
            "title": "Slicer IDs",
            "properties": {
                "prusaslicer": {
                    "$ref": "#/definitions/slicer_id"
                },
                "bambustudio": {
                    "$ref": "#/definitions/slicer_id"
                },
                "orcaslicer": {
                    "$ref": "#/definitions/slicer_id"
                },
                "cura": {
                    "$ref": "#/definitions/slicer_id"
                }
            }
        },
        "slicer_settings": {
            "$ref": "#/definitions/slicer_settings",
            "title": "Slicer Settings",
            "description": "Configure slicer profiles and temperature overrides for different slicing software"
        }
    },
    "additionalProperties": false,
    "required": [
        "id",
        "name",
        "density",
        "diameter_tolerance"
    ]
}