import { TOKEN_VALUE_TYPES } from "./constants.js";
export default function geComponentTokenSchema(enabledRules = {}) {
    const hasStructure = enabledRules.structure == true;
    const hasMetadata = enabledRules.metadata == true;
    return {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "type": "object",
        "minProperties": 1,
        "maxProperties": 1,
        "patternProperties": {
            "^[a-zA-Z0-9_-]+$": {
                "type": "object",
                ...(hasStructure ? { required: ["mapping"] } : {}),
                "additionalProperties": false,
                "properties": {
                    "meta": {
                        "type": "object",
                        "additionalProperties": true
                    },
                    "mapping": {
                        "type": "object",
                        "properties": {
                            "states": {
                                "type": "object",
                                "patternProperties": {
                                    "^[a-zA-Z0-9_-]+$": {
                                        "type": "object",
                                        "additionalProperties": { "$ref": "#/definitions/overrideToken" }
                                    }
                                },
                                "additionalProperties": false
                            }
                        },
                        "additionalProperties": { "$ref": "#/definitions/mappingToken" }
                    },
                    "appearances": { "$ref": "#/definitions/appearanceNode" }
                }
            }
        },
        "definitions": {
            "mappingToken": {
                "type": "object",
                "leafMustHaveValue": true,
                "tokenValueContent": true,
                "properties": {
                    "value": { "type": "string", "minLength": 1, "refExists": true },
                    "type": {
                        "type": "string",
                        "enum": TOKEN_VALUE_TYPES
                    },
                    "attributes": {
                        "type": "object",
                        "properties": {
                            "subtype": { "type": "string" },
                            "description": { "type": "string" }
                        },
                        ...(hasMetadata ? { required: ["subtype", "description"] } : {}),
                        "additionalProperties": false
                    }
                },
                ...(hasMetadata
                    ? {
                        if: { required: ["value"] },
                        then: { required: ["type", "attributes"] }
                    }
                    : {}),
                "additionalProperties": { "$ref": "#/definitions/mappingToken" }
            },
            "appearanceNode": {
                "type": "object",
                "additionalProperties": {
                    "type": "object",
                    "properties": {
                        "mapping": {
                            "type": "object",
                            "overrideContext": true,
                            "additionalProperties": { "$ref": "#/definitions/overrideToken" }
                        },
                        "states": {
                            "type": "object",
                            "patternProperties": {
                                "^[a-zA-Z0-9_-]+$": {
                                    "type": "object",
                                    "overrideContext": true,
                                    "additionalProperties": { "$ref": "#/definitions/overrideToken" }
                                }
                            },
                            "additionalProperties": false
                        },
                        "variantGroups": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "object",
                                "additionalProperties": {
                                    "type": "object",
                                    "overrideContext": true,
                                    "properties": {
                                        "states": {
                                            "type": "object",
                                            "patternProperties": {
                                                "^[a-zA-Z0-9_-]+$": {
                                                    "type": "object",
                                                    "overrideContext": true,
                                                    "additionalProperties": {
                                                        "$ref": "#/definitions/overrideToken"
                                                    }
                                                }
                                            },
                                            "additionalProperties": false
                                        }
                                    },
                                    "additionalProperties": {
                                        "$ref": "#/definitions/overrideToken"
                                    }
                                }
                            }
                        }
                    },
                    "additionalProperties": false
                }
            },
            "overrideToken": {
                "type": "object",
                "leafMustHaveValue": true,
                "tokenValueContent": true,
                "properties": {
                    "value": { "type": "string", "minLength": 1, "refExists": true },
                    "type": {
                        "type": "string",
                        "enum": TOKEN_VALUE_TYPES
                    },
                    "attributes": {
                        "type": "object",
                        "properties": {
                            "subtype": { "type": "string" },
                            "description": { "type": "string" }
                        },
                        "additionalProperties": true
                    }
                },
                "additionalProperties": { "$ref": "#/definitions/overrideToken" }
            }
        },
        "additionalProperties": false
    };
}
;
//# sourceMappingURL=component-token-schema.js.map