﻿{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "urn:dayu:plugin:1.1.0:core",
  "title": "DAYU 公共插件声明结构 1.0.0 / 1.1.0；还需宿主执行语义校验",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "plugin_id",
    "version",
    "title",
    "fields",
    "commands",
    "panels"
  ],
  "properties": {
    "schema_version": {
      "enum": [
        "1.0.0",
        "1.1.0"
      ]
    },
    "plugin_id": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_.-]{0,127}$"
    },
    "version": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"
    },
    "title": {
      "$ref": "#/definitions/text"
    },
    "localization": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "default_culture",
        "resources"
      ],
      "properties": {
        "default_culture": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "resources": {
          "type": "object",
          "maxProperties": 32,
          "additionalProperties": {
            "type": "object",
            "maxProperties": 2048,
            "propertyNames": {
              "$ref": "#/definitions/id"
            },
            "additionalProperties": {
              "type": "string",
              "maxLength": 4096
            }
          }
        }
      }
    },
    "required_capabilities": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9_.-]*@[1-9][0-9]*$"
      }
    },
    "optional_capabilities": {
      "type": "array",
      "maxItems": 32,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "fallback"
        ],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 128,
            "pattern": "^[a-z][a-z0-9_.-]*@[1-9][0-9]*$"
          },
          "fallback": {
            "const": "module_handles_absence"
          }
        }
      }
    },
    "host_targets": {
      "type": "array",
      "minItems": 1,
      "maxItems": 16,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "product",
          "minimum_release",
          "maximum_release",
          "runtimes",
          "architecture"
        ],
        "properties": {
          "product": {
            "const": "3dsmax"
          },
          "minimum_release": {
            "type": "integer",
            "minimum": 2020,
            "maximum": 2100
          },
          "maximum_release": {
            "type": "integer",
            "minimum": 2020,
            "maximum": 2100
          },
          "runtimes": {
            "type": "array",
            "minItems": 1,
            "maxItems": 3,
            "uniqueItems": true,
            "items": {
              "enum": [
                "net48",
                "net8",
                "net10"
              ]
            }
          },
          "architecture": {
            "const": "x64"
          }
        }
      }
    },
    "modules": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/definitions/module"
      }
    },
    "libraries": {
      "type": "array",
      "maxItems": 64,
      "items": {
        "$ref": "#/definitions/library"
      }
    },
    "state_version": {
      "type": "integer",
      "minimum": 1,
      "maximum": 1000000
    },
    "state_migrations": {
      "type": "array",
      "maxItems": 128,
      "items": {
        "$ref": "#/definitions/state_migration"
      }
    },
    "data_sources": {
      "type": "array",
      "maxItems": 64,
      "items": {
        "$ref": "#/definitions/data_source"
      }
    },
    "fields": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/field"
      },
      "maxItems": 512
    },
    "commands": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/command"
      },
      "maxItems": 512
    },
    "panels": {
      "type": "array",
      "minItems": 1,
      "maxItems": 64,
      "items": {
        "$ref": "#/definitions/panel"
      }
    },
    "panel_templates": {
      "type": "array",
      "maxItems": 16,
      "items": {
        "$ref": "#/definitions/panel_template"
      }
    },
    "directories": {
      "type": "array",
      "maxItems": 64,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "title",
          "group",
          "field",
          "default_subdirectory",
          "kind"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "group": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "field": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "default_subdirectory": {
            "type": "string",
            "minLength": 1,
            "maxLength": 240
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512
          },
          "kind": {
            "enum": [
              "library",
              "cache"
            ]
          }
        }
      }
    },
    "argument_sets": {
      "$ref": "#/definitions/argument_sets"
    }
  },
  "definitions": {
    "state_migration": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "from",
        "to",
        "operations"
      ],
      "properties": {
        "from": {
          "type": "integer",
          "minimum": 1,
          "maximum": 999999
        },
        "to": {
          "type": "integer",
          "minimum": 2,
          "maximum": 1000000
        },
        "operations": {
          "type": "array",
          "maxItems": 256,
          "items": {
            "oneOf": [
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "op",
                  "from",
                  "to"
                ],
                "properties": {
                  "op": {
                    "const": "rename"
                  },
                  "from": {
                    "$ref": "#/definitions/id"
                  },
                  "to": {
                    "$ref": "#/definitions/id"
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "op",
                  "field"
                ],
                "properties": {
                  "op": {
                    "const": "drop"
                  },
                  "field": {
                    "$ref": "#/definitions/id"
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "op",
                  "field",
                  "value"
                ],
                "properties": {
                  "op": {
                    "const": "default"
                  },
                  "field": {
                    "$ref": "#/definitions/id"
                  },
                  "value": {}
                }
              },
              {
                "type": "object",
                "required": [
                  "op",
                  "from",
                  "to",
                  "cases"
                ],
                "properties": {
                  "cases": {
                    "minItems": 1,
                    "type": "array",
                    "maxItems": 128,
                    "items": {
                      "type": "object",
                      "required": [
                        "from",
                        "to"
                      ],
                      "properties": {
                        "to": {},
                        "from": {
                          "oneOf": [
                            {
                              "type": "boolean"
                            },
                            {
                              "type": "string"
                            },
                            {
                              "type": "number"
                            }
                          ]
                        }
                      },
                      "additionalProperties": false
                    }
                  },
                  "from": {
                    "$ref": "#/definitions/id"
                  },
                  "to": {
                    "$ref": "#/definitions/id"
                  },
                  "op": {
                    "const": "map"
                  }
                },
                "additionalProperties": false
              }
            ]
          }
        }
      }
    },
    "id": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_.-]{0,63}$"
    },
    "text": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256
    },
    "path": {
      "type": "string",
      "minLength": 1,
      "maxLength": 240,
      "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))[^\\\\:<>|?*]+$"
    },
    "tutorial": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "text"
          ],
          "properties": {
            "kind": {
              "const": "inline"
            },
            "text": {
              "type": "string",
              "minLength": 1,
              "maxLength": 16384
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "url"
          ],
          "properties": {
            "kind": {
              "const": "url"
            },
            "url": {
              "type": "string",
              "minLength": 9,
              "maxLength": 2048,
              "pattern": "^https://[^\\s]+$"
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "path"
          ],
          "properties": {
            "kind": {
              "const": "resource"
            },
            "path": {
              "allOf": [
                {
                  "$ref": "#/definitions/path"
                },
                {
                  "pattern": "\\.md$"
                }
              ]
            }
          }
        }
      ]
    },
    "module": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "runtime",
        "entry"
      ],
      "properties": {
        "id": {
          "$ref": "#/definitions/id"
        },
        "runtime": {
          "enum": [
            "maxscript",
            "dotnet"
          ]
        },
        "entry": {
          "$ref": "#/definitions/path"
        },
        "factory": {
          "$ref": "#/definitions/text"
        },
        "dependencies": {
          "type": "array",
          "maxItems": 64,
          "uniqueItems": true,
          "items": {
            "$ref": "#/definitions/id"
          }
        },
        "libraries": {
          "type": "array",
          "maxItems": 64,
          "uniqueItems": true,
          "items": {
            "$ref": "#/definitions/id"
          }
        }
      },
      "if": {
        "properties": {
          "runtime": {
            "const": "dotnet"
          }
        }
      },
      "then": {
        "required": [
          "factory"
        ]
      }
    },
    "library": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "runtime",
        "entry",
        "sha256"
      ],
      "properties": {
        "id": {
          "$ref": "#/definitions/id"
        },
        "runtime": {
          "enum": [
            "maxscript",
            "dotnet"
          ]
        },
        "entry": {
          "$ref": "#/definitions/path"
        },
        "sha256": {
          "type": "string",
          "pattern": "^[0-9a-fA-F]{64}$"
        },
        "dependencies": {
          "type": "array",
          "maxItems": 64,
          "uniqueItems": true,
          "items": {
            "$ref": "#/definitions/id"
          }
        }
      }
    },
    "field": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "type",
        "default"
      ],
      "properties": {
        "id": {
          "$ref": "#/definitions/id"
        },
        "type": {
          "enum": [
            "number",
            "boolean",
            "check_state",
            "enum",
            "text",
            "color",
            "string_list",
            "curve",
            "resource",
            "color4"
          ]
        },
        "default": {},
        "persistence": {
          "enum": [
            "view",
            "user",
            "scene",
            "transient"
          ]
        },
        "change_command": {
          "$ref": "#/definitions/id"
        },
        "minimum": {
          "type": "number"
        },
        "maximum": {
          "type": "number"
        },
        "step": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "precision": {
          "type": "integer",
          "minimum": 0,
          "maximum": 6
        },
        "value_kind": {
          "enum": [
            "real",
            "integer"
          ]
        },
        "allow_empty": {
          "type": "boolean"
        },
        "dimension": {
          "enum": [
            "scalar",
            "length",
            "angle",
            "time"
          ]
        },
        "canonical_unit": {
          "enum": [
            "none",
            "mm",
            "cm",
            "m",
            "degree",
            "radian",
            "second"
          ]
        },
        "display_unit": {
          "enum": [
            "none",
            "mm",
            "cm",
            "m",
            "degree",
            "radian",
            "second"
          ]
        },
        "max_length": {
          "type": "integer",
          "minimum": 1,
          "maximum": 4096
        },
        "multiline": {
          "type": "boolean"
        },
        "options_source": {
          "$ref": "#/definitions/id"
        },
        "details_of": {
          "$ref": "#/definitions/id"
        },
        "options": {
          "type": "array",
          "minItems": 0,
          "maxItems": 128,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "label"
            ],
            "properties": {
              "id": {
                "$ref": "#/definitions/id"
              },
              "label": {
                "$ref": "#/definitions/text"
              }
            }
          }
        },
        "edit_command": {
          "$ref": "#/definitions/id"
        },
        "xmin": {
          "type": "number"
        },
        "xmax": {
          "type": "number"
        },
        "ymin": {
          "type": "number"
        },
        "ymax": {
          "type": "number"
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "type": {
                "const": "number"
              }
            }
          },
          "then": {
            "required": [
              "minimum",
              "maximum",
              "step",
              "precision",
              "dimension",
              "canonical_unit",
              "display_unit"
            ],
            "properties": {
              "default": {
                "type": "number"
              },
              "options": false
            }
          }
        },
        {
          "if": {
            "required": [
              "value_kind"
            ],
            "properties": {
              "value_kind": {
                "const": "integer"
              }
            }
          },
          "then": {
            "properties": {
              "type": {
                "const": "number"
              },
              "default": {
                "type": "integer",
                "minimum": -9007199254740991,
                "maximum": 9007199254740991
              },
              "minimum": {
                "type": "integer",
                "minimum": -9007199254740991,
                "maximum": 9007199254740991
              },
              "maximum": {
                "type": "integer",
                "minimum": -9007199254740991,
                "maximum": 9007199254740991
              },
              "step": {
                "type": "integer",
                "minimum": 1,
                "maximum": 9007199254740991
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "check_state"
              }
            }
          },
          "then": {
            "properties": {
              "default": {
                "enum": [
                  "unchecked",
                  "checked",
                  "mixed"
                ]
              },
              "minimum": false,
              "maximum": false,
              "step": false,
              "precision": false,
              "dimension": false,
              "canonical_unit": false,
              "display_unit": false,
              "options": false,
              "options_source": false,
              "details_of": false,
              "max_length": false,
              "multiline": false
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "enum": [
                  "boolean",
                  "check_state",
                  "enum",
                  "text",
                  "color",
                  "string_list"
                ]
              }
            }
          },
          "then": {
            "properties": {
              "value_kind": false
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "enum": [
                  "number",
                  "boolean",
                  "check_state",
                  "text",
                  "color",
                  "string_list"
                ]
              }
            }
          },
          "then": {
            "properties": {
              "allow_empty": false
            }
          }
        },
        {
          "if": {
            "required": [
              "options_source"
            ],
            "properties": {
              "type": {
                "const": "enum"
              }
            }
          },
          "then": {
            "properties": {
              "allow_empty": {
                "const": true
              }
            }
          }
        },
        {
          "if": {
            "required": [
              "options"
            ],
            "properties": {
              "type": {
                "const": "enum"
              }
            },
            "not": {
              "required": [
                "allow_empty"
              ],
              "properties": {
                "allow_empty": {
                  "const": true
                }
              }
            }
          },
          "then": {
            "properties": {
              "default": {
                "minLength": 1,
                "maxLength": 64
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "boolean"
              }
            }
          },
          "then": {
            "properties": {
              "default": {
                "type": "boolean"
              },
              "minimum": false,
              "maximum": false,
              "step": false,
              "precision": false,
              "dimension": false,
              "canonical_unit": false,
              "display_unit": false,
              "options": false
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "enum"
              }
            }
          },
          "then": {
            "oneOf": [
              {
                "required": [
                  "options"
                ],
                "properties": {
                  "options_source": false,
                  "options": {
                    "minItems": 1
                  }
                }
              },
              {
                "required": [
                  "options_source"
                ],
                "properties": {
                  "options": false,
                  "default": {
                    "const": ""
                  }
                }
              }
            ],
            "properties": {
              "default": {
                "type": "string"
              },
              "minimum": false,
              "maximum": false,
              "step": false,
              "precision": false,
              "dimension": false,
              "canonical_unit": false,
              "display_unit": false
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "text"
              }
            }
          },
          "then": {
            "properties": {
              "default": {
                "type": "string",
                "maxLength": 4096
              },
              "options": false
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "color"
              }
            }
          },
          "then": {
            "properties": {
              "default": {
                "type": "string",
                "pattern": "^#[0-9A-Fa-f]{6}$"
              },
              "options": false
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "string_list"
              }
            }
          },
          "then": {
            "oneOf": [
              {
                "required": [
                  "options"
                ],
                "properties": {
                  "options_source": false
                }
              },
              {
                "required": [
                  "options_source"
                ],
                "properties": {
                  "options": false,
                  "default": {
                    "maxItems": 0
                  }
                }
              }
            ],
            "properties": {
              "default": {
                "type": "array",
                "maxItems": 128,
                "uniqueItems": true,
                "items": {
                  "$ref": "#/definitions/id"
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "enum": [
                  "number",
                  "boolean",
                  "text",
                  "color"
                ]
              }
            }
          },
          "then": {
            "properties": {
              "options_source": false
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "enum": [
                  "number",
                  "boolean",
                  "enum",
                  "color",
                  "string_list"
                ]
              }
            }
          },
          "then": {
            "properties": {
              "details_of": false
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "enum": [
                  "text",
                  "color",
                  "string_list"
                ]
              }
            }
          },
          "then": {
            "properties": {
              "minimum": false,
              "maximum": false,
              "step": false,
              "precision": false,
              "dimension": false,
              "canonical_unit": false,
              "display_unit": false
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "enum": [
                  "number",
                  "boolean",
                  "enum",
                  "color",
                  "string_list"
                ]
              }
            }
          },
          "then": {
            "properties": {
              "max_length": false,
              "multiline": false
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "curve"
              }
            }
          },
          "then": {
            "properties": {
              "default": {
                "type": "array",
                "minItems": 2,
                "maxItems": 128,
                "items": {
                  "$ref": "#/definitions/curve_point"
                }
              }
            }
          },
          "else": {
            "properties": {
              "xmin": false,
              "xmax": false,
              "ymin": false,
              "ymax": false
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "resource"
              }
            }
          },
          "then": {
            "properties": {
              "default": {
                "type": "string",
                "maxLength": 512,
                "pattern": "^(?:|package://[^\\u0000-\\u001f]+|user://[^\\u0000-\\u001f]+)$"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "enum": [
                  "curve",
                  "resource",
                  "color4"
                ]
              }
            }
          },
          "then": {
            "properties": {
              "minimum": false,
              "maximum": false,
              "step": false,
              "precision": false,
              "dimension": false,
              "canonical_unit": false,
              "display_unit": false,
              "options": false,
              "max_length": false,
              "multiline": false,
              "options_source": false,
              "details_of": false,
              "value_kind": false,
              "allow_empty": false
            }
          }
        },
        {
          "if": {
            "required": [
              "edit_command"
            ]
          },
          "then": {
            "properties": {
              "type": {
                "enum": [
                  "number",
                  "curve",
                  "color4"
                ]
              },
              "change_command": false
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "color4"
              }
            }
          },
          "then": {
            "properties": {
              "default": {
                "type": "array",
                "minItems": 4,
                "maxItems": 4,
                "items": [
                  {
                    "type": "number",
                    "minimum": -1000000,
                    "maximum": 1000000
                  },
                  {
                    "type": "number",
                    "minimum": -1000000,
                    "maximum": 1000000
                  },
                  {
                    "type": "number",
                    "minimum": -1000000,
                    "maximum": 1000000
                  },
                  {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  }
                ],
                "additionalItems": false
              }
            }
          }
        }
      ]
    },
    "data_source": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "module"
      ],
      "properties": {
        "id": {
          "$ref": "#/definitions/id"
        },
        "module": {
          "$ref": "#/definitions/id"
        },
        "page_size": {
          "type": "integer",
          "minimum": 1,
          "maximum": 128
        },
        "selection_policy": {
          "enum": [
            "retain",
            "page"
          ]
        },
        "filter_field": {
          "$ref": "#/definitions/id"
        },
        "sort_field": {
          "$ref": "#/definitions/id"
        },
        "preserve_order": {
          "type": "boolean",
          "default": false
        }
      }
    },
    "command": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "export",
        "effect"
      ],
      "properties": {
        "id": {
          "$ref": "#/definitions/id"
        },
        "module": {
          "$ref": "#/definitions/id"
        },
        "export": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9_]{0,63}$"
        },
        "effect": {
          "enum": [
            "query",
            "viewport",
            "scene",
            "filesystem"
          ]
        },
        "concurrency": {
          "enum": [
            "reject",
            "replace",
            "queue"
          ]
        },
        "undo": {
          "enum": [
            "none",
            "single",
            "module"
          ]
        },
        "queue_limit": {
          "type": "integer",
          "minimum": 1,
          "maximum": 32
        },
        "async": {
          "type": "boolean"
        },
        "args": {
          "$ref": "#/definitions/arguments"
        },
        "args_ref": {
          "$ref": "#/definitions/id"
        }
      },
      "if": {
        "required": [
          "concurrency"
        ],
        "properties": {
          "concurrency": {
            "const": "queue"
          }
        }
      },
      "then": {
        "required": [
          "queue_limit"
        ]
      },
      "else": {
        "properties": {
          "queue_limit": false
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "effect": {
                "const": "scene"
              }
            }
          },
          "then": {
            "required": [
              "undo"
            ],
            "properties": {
              "undo": {
                "enum": [
                  "single",
                  "module"
                ]
              }
            }
          },
          "else": {
            "properties": {
              "undo": {
                "const": "none"
              }
            }
          }
        },
        {
          "if": {
            "required": [
              "undo"
            ],
            "properties": {
              "undo": {
                "const": "module"
              }
            }
          },
          "then": {
            "properties": {
              "effect": {
                "const": "scene"
              },
              "async": {
                "const": false
              }
            }
          }
        }
      ],
      "oneOf": [
        {
          "required": [
            "args"
          ],
          "properties": {
            "args_ref": false
          }
        },
        {
          "required": [
            "args_ref"
          ],
          "properties": {
            "args": false
          }
        }
      ]
    },
    "panel": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "title",
        "layout",
        "controls"
      ],
      "properties": {
        "id": {
          "$ref": "#/definitions/id"
        },
        "title": {
          "$ref": "#/definitions/text"
        },
        "tutorial": {
          "$ref": "#/definitions/tutorial"
        },
        "prepare_command": {
          "$ref": "#/definitions/id"
        },
        "layout": {
          "oneOf": [
            {
              "enum": [
                "form",
                "stack"
              ]
            },
            {
              "type": "array",
              "maxItems": 512,
              "items": {
                "$ref": "#/definitions/layout_node"
              }
            }
          ]
        },
        "activation": {
          "enum": [
            "on_expand",
            "on_command"
          ]
        },
        "expanded": {
          "type": "boolean"
        },
        "modules": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "$ref": "#/definitions/id"
          }
        },
        "controls": {
          "type": "array",
          "maxItems": 512,
          "items": {
            "$ref": "#/definitions/control"
          }
        },
        "visible_when": {
          "$ref": "#/definitions/id"
        },
        "title_bind": {
          "$ref": "#/definitions/id"
        }
      }
    },
    "control": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "type",
        "label"
      ],
      "properties": {
        "id": {
          "$ref": "#/definitions/id"
        },
        "type": {
          "enum": [
            "button",
            "number",
            "checkbox",
            "choice",
            "label",
            "text",
            "color",
            "slider",
            "list",
            "gallery",
            "radio",
            "progress",
            "table",
            "segmented-choice",
            "toggle-button",
            "angle",
            "combobox",
            "hyperlink",
            "image",
            "image-action",
            "tree",
            "curve",
            "menu",
            "color4"
          ]
        },
        "label": {
          "type": "string",
          "maxLength": 4096
        },
        "bind": {
          "$ref": "#/definitions/id"
        },
        "command": {
          "$ref": "#/definitions/id"
        },
        "secondary_command": {
          "$ref": "#/definitions/id"
        },
        "gallery_columns": {
          "enum": [
            2,
            3
          ]
        },
        "preview_shape": {
          "enum": [
            "square",
            "circle"
          ]
        },
        "multiline": {
          "type": "boolean"
        },
        "role": {
          "enum": [
            "standard",
            "primary",
            "help"
          ]
        },
        "help": {
          "$ref": "#/definitions/text"
        },
        "read_only": {
          "type": "boolean"
        },
        "rows": {
          "type": "integer",
          "minimum": 2,
          "maximum": 12
        },
        "multiple": {
          "type": "boolean"
        },
        "activate_command": {
          "$ref": "#/definitions/id"
        },
        "source": {
          "$ref": "#/definitions/id"
        },
        "source_action": {
          "enum": [
            "previous",
            "next"
          ]
        },
        "enabled_when": {
          "$ref": "#/definitions/id"
        },
        "visible_when": {
          "$ref": "#/definitions/id"
        },
        "text_bind": {
          "$ref": "#/definitions/id"
        },
        "columns": {
          "type": "array",
          "minItems": 1,
          "maxItems": 8,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "title",
              "value"
            ],
            "properties": {
              "id": {
                "$ref": "#/definitions/id"
              },
              "title": {
                "$ref": "#/definitions/text"
              },
              "value": {
                "$ref": "#/definitions/id"
              },
              "type": {
                "enum": [
                  "text",
                  "number",
                  "boolean",
                  "choice"
                ]
              },
              "editable": {
                "type": "boolean"
              },
              "minimum": {
                "type": "number"
              },
              "maximum": {
                "type": "number"
              },
              "items": {
                "type": "array",
                "minItems": 1,
                "maxItems": 128,
                "items": {
                  "$ref": "#/definitions/option"
                }
              }
            },
            "allOf": [
              {
                "if": {
                  "properties": {
                    "value": {
                      "enum": [
                        "id",
                        "label",
                        "details"
                      ]
                    }
                  }
                },
                "then": {
                  "properties": {
                    "type": {
                      "const": "text"
                    },
                    "editable": {
                      "const": false
                    }
                  }
                }
              },
              {
                "if": {
                  "required": [
                    "type"
                  ],
                  "properties": {
                    "type": {
                      "const": "number"
                    }
                  }
                },
                "else": {
                  "properties": {
                    "minimum": false,
                    "maximum": false
                  }
                }
              }
            ]
          }
        },
        "help_bind": {
          "$ref": "#/definitions/id"
        },
        "minimum_bind": {
          "$ref": "#/definitions/id"
        },
        "maximum_bind": {
          "$ref": "#/definitions/id"
        },
        "step_bind": {
          "$ref": "#/definitions/id"
        },
        "mixed_when": {
          "$ref": "#/definitions/id"
        },
        "cell_edit_command": {
          "$ref": "#/definitions/id"
        },
        "image_event_command": {
          "$ref": "#/definitions/id"
        },
        "drop_command": {
          "$ref": "#/definitions/id"
        },
        "reorder_command": {
          "$ref": "#/definitions/id"
        },
        "fit": {
          "enum": [
            "contain",
            "cover"
          ]
        },
        "interactive": {
          "type": "boolean"
        },
        "orientation": {
          "enum": [
            "horizontal",
            "vertical"
          ]
        },
        "items": {
          "type": "array",
          "maxItems": 128
        },
        "hotspots": {
          "type": "array",
          "maxItems": 32,
          "items": {
            "$ref": "#/definitions/hotspot"
          }
        },
        "pointer_command": {
          "$ref": "#/definitions/id"
        },
        "rename_bind": {
          "$ref": "#/definitions/id"
        },
        "icon": {
          "enum": [
            "lock-ratio",
            "flip-horizontal",
            "flip-vertical"
          ]
        },
        "selected_when": {
          "$ref": "#/definitions/id"
        },
        "badge": {
          "type": "string",
          "minLength": 1,
          "maxLength": 8,
          "pattern": "\\S"
        },
        "continuous": {
          "type": "boolean",
          "description": "List-only complete filtered source (up to 4096 items); negotiates list.continuous. Selection remains capped at 128."
        },
        "context_menu": {
          "type": "array",
          "minItems": 1,
          "maxItems": 64,
          "items": {
            "anyOf": [
              {
                "$ref": "#/definitions/menu_item"
              },
              {
                "$ref": "#/definitions/gallery_menu_item"
              }
            ]
          },
          "description": "List or gallery context menu. Gallery negotiates gallery.context-menu; target:item (default) validates clicked current-page resource, target:gallery has no item and works when empty. Image-action uses image.context-menu; right click opens menu, secondary_command remains double-click."
        },
        "color_scale": {
          "enum": [
            "hue",
            "saturation",
            "brightness",
            "contrast",
            "temperature"
          ]
        }
      },
      "allOf": [
        {
          "if": {
            "required": [
              "rename_bind"
            ]
          },
          "then": {
            "required": [
              "text_bind"
            ],
            "properties": {
              "type": {
                "const": "button"
              },
              "secondary_command": false,
              "pointer_command": false
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "button"
              }
            }
          },
          "then": {
            "properties": {
              "bind": false,
              "gallery_columns": false,
              "preview_shape": false,
              "multiline": false,
              "read_only": false,
              "rows": false,
              "multiple": false,
              "activate_command": false,
              "columns": false,
              "minimum_bind": false,
              "maximum_bind": false,
              "step_bind": false,
              "mixed_when": false,
              "cell_edit_command": false,
              "image_event_command": false,
              "drop_command": false,
              "reorder_command": false,
              "fit": false,
              "interactive": false,
              "orientation": false,
              "items": false,
              "hotspots": false,
              "role": {
                "enum": [
                  "standard",
                  "primary"
                ]
              }
            },
            "oneOf": [
              {
                "required": [
                  "command"
                ],
                "properties": {
                  "source": false,
                  "source_action": false
                }
              },
              {
                "required": [
                  "source",
                  "source_action"
                ],
                "properties": {
                  "command": false,
                  "secondary_command": false
                }
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "label"
              }
            }
          },
          "then": {
            "properties": {
              "bind": false,
              "command": false,
              "secondary_command": false,
              "gallery_columns": false,
              "preview_shape": false,
              "read_only": false,
              "multiple": false,
              "activate_command": false,
              "source": false,
              "source_action": false,
              "columns": false,
              "minimum_bind": false,
              "maximum_bind": false,
              "step_bind": false,
              "mixed_when": false,
              "cell_edit_command": false,
              "image_event_command": false,
              "drop_command": false,
              "reorder_command": false,
              "fit": false,
              "interactive": false,
              "orientation": false,
              "items": false,
              "hotspots": false,
              "role": {
                "enum": [
                  "standard",
                  "help"
                ]
              },
              "rows": {
                "maximum": 8
              },
              "pointer_command": false
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "number"
              }
            }
          },
          "then": {
            "properties": {
              "command": false,
              "secondary_command": false,
              "gallery_columns": false,
              "preview_shape": false,
              "multiline": false,
              "role": false,
              "read_only": false,
              "rows": false,
              "multiple": false,
              "activate_command": false,
              "source": false,
              "source_action": false,
              "text_bind": false,
              "columns": false,
              "cell_edit_command": false,
              "image_event_command": false,
              "drop_command": false,
              "reorder_command": false,
              "fit": false,
              "interactive": false,
              "orientation": false,
              "items": false,
              "hotspots": false,
              "pointer_command": false
            },
            "required": [
              "bind"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "angle"
              }
            }
          },
          "then": {
            "properties": {
              "command": false,
              "secondary_command": false,
              "gallery_columns": false,
              "preview_shape": false,
              "multiline": false,
              "role": false,
              "read_only": false,
              "rows": false,
              "multiple": false,
              "activate_command": false,
              "source": false,
              "source_action": false,
              "text_bind": false,
              "columns": false,
              "cell_edit_command": false,
              "image_event_command": false,
              "drop_command": false,
              "reorder_command": false,
              "fit": false,
              "interactive": false,
              "orientation": false,
              "items": false,
              "hotspots": false,
              "pointer_command": false
            },
            "required": [
              "bind"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "slider"
              }
            }
          },
          "then": {
            "properties": {
              "command": false,
              "secondary_command": false,
              "gallery_columns": false,
              "preview_shape": false,
              "multiline": false,
              "role": false,
              "read_only": false,
              "multiple": false,
              "activate_command": false,
              "source": false,
              "source_action": false,
              "text_bind": false,
              "columns": false,
              "cell_edit_command": false,
              "image_event_command": false,
              "drop_command": false,
              "reorder_command": false,
              "fit": false,
              "interactive": false,
              "items": false,
              "hotspots": false,
              "pointer_command": false
            },
            "required": [
              "bind"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "checkbox"
              }
            }
          },
          "then": {
            "properties": {
              "command": false,
              "gallery_columns": false,
              "preview_shape": false,
              "multiline": false,
              "role": false,
              "read_only": false,
              "rows": false,
              "multiple": false,
              "activate_command": false,
              "source": false,
              "source_action": false,
              "text_bind": false,
              "columns": false,
              "minimum_bind": false,
              "maximum_bind": false,
              "step_bind": false,
              "mixed_when": false,
              "cell_edit_command": false,
              "image_event_command": false,
              "drop_command": false,
              "reorder_command": false,
              "fit": false,
              "interactive": false,
              "orientation": false,
              "items": false,
              "hotspots": false
            },
            "required": [
              "bind"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "choice"
              }
            }
          },
          "then": {
            "properties": {
              "command": false,
              "secondary_command": false,
              "gallery_columns": false,
              "preview_shape": false,
              "multiline": false,
              "role": false,
              "read_only": false,
              "rows": false,
              "multiple": false,
              "activate_command": false,
              "source": false,
              "source_action": false,
              "text_bind": false,
              "columns": false,
              "minimum_bind": false,
              "maximum_bind": false,
              "step_bind": false,
              "mixed_when": false,
              "cell_edit_command": false,
              "image_event_command": false,
              "drop_command": false,
              "reorder_command": false,
              "fit": false,
              "interactive": false,
              "orientation": false,
              "items": false,
              "hotspots": false,
              "pointer_command": false
            },
            "required": [
              "bind"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "radio"
              }
            }
          },
          "then": {
            "properties": {
              "command": false,
              "gallery_columns": false,
              "preview_shape": false,
              "multiline": false,
              "role": false,
              "read_only": false,
              "rows": false,
              "multiple": false,
              "activate_command": false,
              "source": false,
              "source_action": false,
              "text_bind": false,
              "columns": false,
              "minimum_bind": false,
              "maximum_bind": false,
              "step_bind": false,
              "mixed_when": false,
              "cell_edit_command": false,
              "image_event_command": false,
              "drop_command": false,
              "reorder_command": false,
              "fit": false,
              "interactive": false,
              "orientation": false,
              "items": false,
              "hotspots": false
            },
            "required": [
              "bind"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "segmented-choice"
              }
            }
          },
          "then": {
            "properties": {
              "command": false,
              "gallery_columns": false,
              "preview_shape": false,
              "multiline": false,
              "role": false,
              "read_only": false,
              "rows": false,
              "multiple": false,
              "activate_command": false,
              "source": false,
              "source_action": false,
              "text_bind": false,
              "columns": false,
              "minimum_bind": false,
              "maximum_bind": false,
              "step_bind": false,
              "mixed_when": false,
              "cell_edit_command": false,
              "image_event_command": false,
              "drop_command": false,
              "reorder_command": false,
              "fit": false,
              "interactive": false,
              "orientation": false,
              "items": false,
              "hotspots": false
            },
            "required": [
              "bind"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "toggle-button"
              }
            }
          },
          "then": {
            "properties": {
              "command": false,
              "gallery_columns": false,
              "preview_shape": false,
              "multiline": false,
              "role": false,
              "read_only": false,
              "rows": false,
              "multiple": false,
              "activate_command": false,
              "source": false,
              "source_action": false,
              "text_bind": false,
              "columns": false,
              "minimum_bind": false,
              "maximum_bind": false,
              "step_bind": false,
              "mixed_when": false,
              "cell_edit_command": false,
              "image_event_command": false,
              "drop_command": false,
              "reorder_command": false,
              "fit": false,
              "interactive": false,
              "orientation": false,
              "items": false,
              "hotspots": false
            },
            "required": [
              "bind"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "color"
              }
            }
          },
          "then": {
            "properties": {
              "command": false,
              "secondary_command": false,
              "gallery_columns": false,
              "preview_shape": false,
              "multiline": false,
              "role": false,
              "read_only": false,
              "rows": false,
              "multiple": false,
              "activate_command": false,
              "source": false,
              "source_action": false,
              "text_bind": false,
              "columns": false,
              "minimum_bind": false,
              "maximum_bind": false,
              "step_bind": false,
              "mixed_when": false,
              "cell_edit_command": false,
              "image_event_command": false,
              "drop_command": false,
              "reorder_command": false,
              "fit": false,
              "interactive": false,
              "orientation": false,
              "items": false,
              "hotspots": false,
              "pointer_command": false
            },
            "required": [
              "bind"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "text"
              }
            }
          },
          "then": {
            "properties": {
              "command": false,
              "secondary_command": false,
              "gallery_columns": false,
              "preview_shape": false,
              "multiline": false,
              "role": false,
              "multiple": false,
              "activate_command": false,
              "source": false,
              "source_action": false,
              "text_bind": false,
              "columns": false,
              "minimum_bind": false,
              "maximum_bind": false,
              "step_bind": false,
              "mixed_when": false,
              "cell_edit_command": false,
              "image_event_command": false,
              "drop_command": false,
              "reorder_command": false,
              "fit": false,
              "interactive": false,
              "orientation": false,
              "items": false,
              "hotspots": false,
              "rows": {
                "maximum": 12
              },
              "pointer_command": false
            },
            "required": [
              "bind"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "combobox"
              }
            }
          },
          "then": {
            "properties": {
              "command": false,
              "secondary_command": false,
              "gallery_columns": false,
              "preview_shape": false,
              "multiline": false,
              "role": false,
              "rows": false,
              "multiple": false,
              "activate_command": false,
              "source": false,
              "source_action": false,
              "text_bind": false,
              "columns": false,
              "minimum_bind": false,
              "maximum_bind": false,
              "step_bind": false,
              "mixed_when": false,
              "cell_edit_command": false,
              "image_event_command": false,
              "drop_command": false,
              "reorder_command": false,
              "fit": false,
              "interactive": false,
              "orientation": false,
              "hotspots": false,
              "items": {
                "items": {
                  "$ref": "#/definitions/option"
                }
              },
              "pointer_command": false
            },
            "required": [
              "bind"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "list"
              }
            }
          },
          "then": {
            "properties": {
              "command": false,
              "gallery_columns": false,
              "preview_shape": false,
              "multiline": false,
              "role": false,
              "source": false,
              "source_action": false,
              "text_bind": false,
              "columns": false,
              "minimum_bind": false,
              "maximum_bind": false,
              "step_bind": false,
              "mixed_when": false,
              "cell_edit_command": false,
              "image_event_command": false,
              "fit": false,
              "interactive": false,
              "orientation": false,
              "items": false,
              "hotspots": false,
              "pointer_command": false
            },
            "required": [
              "bind"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "gallery"
              }
            }
          },
          "then": {
            "properties": {
              "command": false,
              "multiline": false,
              "role": false,
              "read_only": false,
              "rows": false,
              "multiple": false,
              "source": false,
              "source_action": false,
              "text_bind": false,
              "columns": false,
              "minimum_bind": false,
              "maximum_bind": false,
              "step_bind": false,
              "mixed_when": false,
              "cell_edit_command": false,
              "image_event_command": false,
              "drop_command": false,
              "reorder_command": false,
              "fit": false,
              "interactive": false,
              "orientation": false,
              "items": false,
              "hotspots": false,
              "pointer_command": false
            },
            "required": [
              "bind"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "progress"
              }
            }
          },
          "then": {
            "properties": {
              "command": false,
              "gallery_columns": false,
              "preview_shape": false,
              "multiline": false,
              "role": false,
              "read_only": false,
              "rows": false,
              "multiple": false,
              "activate_command": false,
              "source": false,
              "source_action": false,
              "text_bind": false,
              "columns": false,
              "cell_edit_command": false,
              "image_event_command": false,
              "drop_command": false,
              "reorder_command": false,
              "fit": false,
              "items": false,
              "hotspots": false
            },
            "required": [
              "bind"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "table"
              }
            }
          },
          "then": {
            "properties": {
              "command": false,
              "gallery_columns": false,
              "preview_shape": false,
              "multiline": false,
              "role": false,
              "source": false,
              "source_action": false,
              "text_bind": false,
              "minimum_bind": false,
              "maximum_bind": false,
              "step_bind": false,
              "mixed_when": false,
              "image_event_command": false,
              "fit": false,
              "interactive": false,
              "orientation": false,
              "items": false,
              "hotspots": false,
              "pointer_command": false
            },
            "required": [
              "bind",
              "columns"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "image"
              }
            }
          },
          "then": {
            "properties": {
              "command": false,
              "secondary_command": false,
              "gallery_columns": false,
              "preview_shape": false,
              "multiline": false,
              "role": false,
              "multiple": false,
              "activate_command": false,
              "source": false,
              "source_action": false,
              "columns": false,
              "minimum_bind": false,
              "maximum_bind": false,
              "step_bind": false,
              "mixed_when": false,
              "cell_edit_command": false,
              "reorder_command": false,
              "interactive": false,
              "orientation": false,
              "items": false,
              "hotspots": false,
              "pointer_command": false,
              "rows": {
                "minimum": 2,
                "maximum": 8
              },
              "text_bind": false
            },
            "required": [
              "bind"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "image-action"
              }
            }
          },
          "then": {
            "properties": {
              "gallery_columns": false,
              "multiline": false,
              "role": false,
              "multiple": false,
              "activate_command": false,
              "source": false,
              "source_action": false,
              "columns": false,
              "minimum_bind": false,
              "maximum_bind": false,
              "step_bind": false,
              "mixed_when": false,
              "cell_edit_command": false,
              "reorder_command": false,
              "interactive": false,
              "orientation": false,
              "items": false,
              "pointer_command": false,
              "rows": {
                "minimum": 2,
                "maximum": 8
              },
              "text_bind": false,
              "read_only": false
            },
            "required": [
              "bind",
              "command"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "curve"
              }
            }
          },
          "then": {
            "properties": {
              "command": false,
              "secondary_command": false,
              "gallery_columns": false,
              "preview_shape": false,
              "multiline": false,
              "role": false,
              "multiple": false,
              "activate_command": false,
              "source": false,
              "source_action": false,
              "columns": false,
              "minimum_bind": false,
              "maximum_bind": false,
              "step_bind": false,
              "mixed_when": false,
              "cell_edit_command": false,
              "image_event_command": false,
              "drop_command": false,
              "reorder_command": false,
              "fit": false,
              "interactive": false,
              "orientation": false,
              "items": false,
              "hotspots": false,
              "pointer_command": false,
              "rows": {
                "minimum": 4,
                "maximum": 12
              },
              "text_bind": false
            },
            "required": [
              "bind"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "menu"
              }
            }
          },
          "then": {
            "properties": {
              "bind": false,
              "command": false,
              "secondary_command": false,
              "gallery_columns": false,
              "preview_shape": false,
              "multiline": false,
              "role": false,
              "read_only": false,
              "rows": false,
              "multiple": false,
              "activate_command": false,
              "source": false,
              "source_action": false,
              "columns": false,
              "minimum_bind": false,
              "maximum_bind": false,
              "step_bind": false,
              "mixed_when": false,
              "cell_edit_command": false,
              "image_event_command": false,
              "drop_command": false,
              "reorder_command": false,
              "fit": false,
              "interactive": false,
              "orientation": false,
              "hotspots": false,
              "items": {
                "minItems": 1,
                "maxItems": 64,
                "items": {
                  "$ref": "#/definitions/menu_item"
                }
              },
              "pointer_command": false
            },
            "required": [
              "items"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "tree"
              }
            }
          },
          "then": {
            "properties": {
              "command": false,
              "gallery_columns": false,
              "preview_shape": false,
              "multiline": false,
              "role": false,
              "source": false,
              "source_action": false,
              "text_bind": false,
              "columns": false,
              "minimum_bind": false,
              "maximum_bind": false,
              "step_bind": false,
              "mixed_when": false,
              "cell_edit_command": false,
              "image_event_command": false,
              "fit": false,
              "interactive": false,
              "orientation": false,
              "items": false,
              "hotspots": false,
              "pointer_command": false
            },
            "required": [
              "bind"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "hyperlink"
              }
            }
          },
          "then": {
            "properties": {
              "bind": false,
              "gallery_columns": false,
              "preview_shape": false,
              "multiline": false,
              "read_only": false,
              "rows": false,
              "multiple": false,
              "activate_command": false,
              "columns": false,
              "minimum_bind": false,
              "maximum_bind": false,
              "step_bind": false,
              "mixed_when": false,
              "cell_edit_command": false,
              "image_event_command": false,
              "drop_command": false,
              "reorder_command": false,
              "fit": false,
              "interactive": false,
              "orientation": false,
              "items": false,
              "hotspots": false,
              "role": {
                "enum": [
                  "standard",
                  "primary"
                ]
              }
            },
            "oneOf": [
              {
                "required": [
                  "command"
                ],
                "properties": {
                  "source": false,
                  "source_action": false
                }
              },
              {
                "required": [
                  "source",
                  "source_action"
                ],
                "properties": {
                  "command": false,
                  "secondary_command": false
                }
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "label"
              }
            }
          },
          "then": {
            "if": {
              "required": [
                "multiline"
              ],
              "properties": {
                "multiline": {
                  "const": true
                }
              }
            },
            "then": {
              "properties": {
                "label": {
                  "pattern": "^[^\\u0000-\\u0008\\u000b\\u000c\\u000e-\\u001f\\u007f-\\u009f]*$"
                }
              }
            },
            "else": {
              "properties": {
                "rows": false,
                "label": {
                  "maxLength": 256,
                  "pattern": "^[^\\u0000-\\u001f\\u007f-\\u009f]*$"
                }
              }
            }
          },
          "else": {
            "if": {
              "properties": {
                "type": {
                  "enum": [
                    "choice",
                    "text",
                    "color",
                    "combobox"
                  ]
                }
              }
            },
            "then": {
              "properties": {
                "label": {
                  "maxLength": 256,
                  "pattern": "^[^\\u0000-\\u001f\\u007f-\\u009f]*$"
                }
              }
            },
            "else": {
              "properties": {
                "label": {
                  "minLength": 1,
                  "maxLength": 256,
                  "pattern": "^[^\\u0000-\\u001f\\u007f-\\u009f]+$"
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "image"
              }
            }
          },
          "then": {
            "properties": {
              "read_only": {
                "const": true
              },
              "text_bind": false
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "color4"
              }
            }
          },
          "then": {
            "required": [
              "bind"
            ],
            "properties": {
              "command": false,
              "secondary_command": false,
              "gallery_columns": false,
              "preview_shape": false,
              "multiline": false,
              "role": false,
              "multiple": false,
              "activate_command": false,
              "source": false,
              "source_action": false,
              "columns": false,
              "minimum_bind": false,
              "maximum_bind": false,
              "step_bind": false,
              "mixed_when": false,
              "cell_edit_command": false,
              "image_event_command": false,
              "drop_command": false,
              "reorder_command": false,
              "fit": false,
              "interactive": false,
              "orientation": false,
              "items": false,
              "hotspots": false,
              "pointer_command": false,
              "rows": false,
              "text_bind": false
            }
          }
        },
        {
          "if": {
            "required": [
              "icon"
            ]
          },
          "then": {
            "properties": {
              "type": {
                "enum": [
                  "button",
                  "toggle-button"
                ]
              }
            }
          }
        },
        {
          "if": {
            "required": [
              "selected_when"
            ]
          },
          "then": {
            "properties": {
              "type": {
                "enum": [
                  "button",
                  "image-action"
                ]
              }
            }
          }
        },
        {
          "if": {
            "required": [
              "badge"
            ]
          },
          "then": {
            "properties": {
              "type": {
                "const": "image-action"
              }
            }
          }
        },
        {
          "if": {
            "required": [
              "continuous"
            ]
          },
          "then": {
            "properties": {
              "type": {
                "const": "list"
              }
            }
          }
        },
        {
          "if": {
            "required": [
              "context_menu"
            ]
          },
          "then": {
            "properties": {
              "type": {
                "enum": [
                  "list",
                  "gallery",
                  "image-action"
                ]
              },
              "read_only": {
                "const": false
              }
            },
            "allOf": [
              {
                "if": {
                  "properties": {
                    "type": {
                      "enum": [
                        "list",
                        "gallery"
                      ]
                    }
                  }
                },
                "then": {
                  "properties": {
                    "secondary_command": false
                  }
                }
              }
            ]
          }
        },
        {
          "then": {
            "properties": {
              "type": {
                "const": "slider"
              },
              "orientation": {
                "const": "horizontal"
              }
            }
          },
          "if": {
            "required": [
              "color_scale"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "enum": [
                  "list",
                  "image-action"
                ]
              }
            },
            "required": [
              "type",
              "context_menu"
            ]
          },
          "then": {
            "properties": {
              "context_menu": {
                "items": {
                  "$ref": "#/definitions/menu_item"
                }
              }
            }
          }
        }
      ]
    },
    "layout_node": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "type",
            "id",
            "title",
            "items",
            "optional",
            "templates"
          ],
          "properties": {
            "type": {
              "const": "editable"
            },
            "id": {
              "$ref": "#/definitions/id"
            },
            "title": {
              "$ref": "#/definitions/text"
            },
            "items": {
              "type": "array",
              "minItems": 1,
              "maxItems": 64,
              "uniqueItems": true,
              "items": {
                "$ref": "#/definitions/id"
              }
            },
            "optional": {
              "type": "array",
              "maxItems": 64,
              "uniqueItems": true,
              "items": {
                "$ref": "#/definitions/id"
              }
            },
            "templates": {
              "type": "array",
              "minItems": 1,
              "maxItems": 3,
              "uniqueItems": true,
              "items": {
                "type": "integer",
                "minimum": 1,
                "maximum": 3
              }
            }
          }
        },
        {
          "$ref": "#/definitions/id"
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "type",
            "items"
          ],
          "properties": {
            "type": {
              "const": "row"
            },
            "items": {
              "type": "array",
              "minItems": 1,
              "maxItems": 5,
              "items": {
                "$ref": "#/definitions/id"
              }
            },
            "template": {
              "enum": [
                "diagnostic",
                "input_action",
                "alignment",
                "split_action"
              ]
            }
          },
          "allOf": [
            {
              "if": {
                "required": [
                  "template"
                ],
                "properties": {
                  "template": {
                    "const": "split_action"
                  }
                }
              },
              "then": {
                "properties": {
                  "items": {
                    "minItems": 3,
                    "maxItems": 3
                  }
                }
              }
            },
            {
              "if": {
                "required": [
                  "template"
                ],
                "properties": {
                  "template": {
                    "const": "alignment"
                  }
                }
              },
              "then": {
                "properties": {
                  "items": {
                    "minItems": 4,
                    "maxItems": 5
                  }
                }
              }
            }
          ]
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "type",
            "title",
            "items"
          ],
          "properties": {
            "type": {
              "enum": [
                "group",
                "disclosure"
              ]
            },
            "title": {
              "$ref": "#/definitions/text"
            },
            "items": {
              "type": "array",
              "maxItems": 512,
              "items": {
                "$ref": "#/definitions/layout_node"
              }
            },
            "title_control": {
              "$ref": "#/definitions/id"
            }
          },
          "allOf": [
            {
              "if": {
                "required": [
                  "title_control"
                ]
              },
              "then": {
                "properties": {
                  "type": {
                    "const": "group"
                  }
                }
              }
            }
          ]
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "type",
            "items"
          ],
          "properties": {
            "type": {
              "enum": [
                "vector",
                "file",
                "object_picker"
              ]
            },
            "items": {
              "type": "array",
              "minItems": 2,
              "maxItems": 3,
              "items": {
                "$ref": "#/definitions/id"
              }
            }
          },
          "allOf": [
            {
              "if": {
                "properties": {
                  "type": {
                    "enum": [
                      "file",
                      "object_picker"
                    ]
                  }
                }
              },
              "then": {
                "properties": {
                  "items": {
                    "maxItems": 2
                  }
                }
              }
            }
          ]
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "type",
            "id",
            "pages"
          ],
          "properties": {
            "type": {
              "const": "tabs"
            },
            "id": {
              "$ref": "#/definitions/id"
            },
            "selected": {
              "$ref": "#/definitions/id"
            },
            "pages": {
              "type": "array",
              "minItems": 1,
              "maxItems": 8,
              "items": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "id",
                  "title",
                  "items"
                ],
                "properties": {
                  "id": {
                    "$ref": "#/definitions/id"
                  },
                  "title": {
                    "$ref": "#/definitions/text"
                  },
                  "items": {
                    "type": "array",
                    "maxItems": 512,
                    "items": {
                      "$ref": "#/definitions/layout_node"
                    }
                  }
                }
              }
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "type"
          ],
          "properties": {
            "type": {
              "const": "separator"
            }
          }
        }
      ]
    },
    "panel_template": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "capacity",
        "fields",
        "commands",
        "panels"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_.-]{0,19}$"
        },
        "capacity": {
          "type": "integer",
          "minimum": 1,
          "maximum": 16
        },
        "fields": {
          "type": "array",
          "maxItems": 128,
          "items": {
            "$ref": "#/definitions/field"
          }
        },
        "commands": {
          "type": "array",
          "maxItems": 128,
          "items": {
            "$ref": "#/definitions/command"
          }
        },
        "panels": {
          "type": "array",
          "minItems": 1,
          "maxItems": 128,
          "items": {
            "$ref": "#/definitions/panel"
          }
        },
        "data_sources": {
          "type": "array",
          "maxItems": 64,
          "items": {
            "$ref": "#/definitions/data_source"
          }
        },
        "argument_sets": {
          "$ref": "#/definitions/argument_sets"
        }
      }
    },
    "curve_point": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "x",
        "y"
      ],
      "properties": {
        "id": {
          "$ref": "#/definitions/id"
        },
        "x": {
          "type": "number"
        },
        "y": {
          "type": "number"
        },
        "in_x": {
          "type": "number"
        },
        "in_y": {
          "type": "number"
        },
        "out_x": {
          "type": "number"
        },
        "out_y": {
          "type": "number"
        }
      },
      "allOf": [
        {
          "if": {
            "required": [
              "in_x"
            ]
          },
          "then": {
            "required": [
              "in_y"
            ]
          }
        },
        {
          "if": {
            "required": [
              "in_y"
            ]
          },
          "then": {
            "required": [
              "in_x"
            ]
          }
        },
        {
          "if": {
            "required": [
              "out_x"
            ]
          },
          "then": {
            "required": [
              "out_y"
            ]
          }
        },
        {
          "if": {
            "required": [
              "out_y"
            ]
          },
          "then": {
            "required": [
              "out_x"
            ]
          }
        }
      ]
    },
    "option": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "label"
      ],
      "properties": {
        "id": {
          "$ref": "#/definitions/id"
        },
        "label": {
          "$ref": "#/definitions/text"
        }
      }
    },
    "hotspot": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "x",
        "y",
        "width",
        "height"
      ],
      "properties": {
        "id": {
          "$ref": "#/definitions/id"
        },
        "x": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "y": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "width": {
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 1
        },
        "height": {
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 1
        },
        "help": {
          "$ref": "#/definitions/text"
        }
      }
    },
    "menu_item": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "label"
      ],
      "properties": {
        "id": {
          "$ref": "#/definitions/id"
        },
        "label": {
          "$ref": "#/definitions/text"
        },
        "command": {
          "$ref": "#/definitions/id"
        },
        "checked": {
          "type": "boolean"
        },
        "enabled": {
          "type": "boolean"
        },
        "items": {
          "type": "array",
          "minItems": 1,
          "maxItems": 64,
          "items": {
            "$ref": "#/definitions/menu_item"
          }
        }
      },
      "oneOf": [
        {
          "required": [
            "command"
          ],
          "properties": {
            "items": false
          }
        },
        {
          "required": [
            "items"
          ],
          "properties": {
            "command": false
          }
        }
      ]
    },
    "arguments": {
      "type": "object",
      "maxProperties": 128,
      "propertyNames": {
        "$ref": "#/definitions/id"
      },
      "additionalProperties": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "field"
        ],
        "properties": {
          "field": {
            "$ref": "#/definitions/id"
          }
        }
      }
    },
    "argument_sets": {
      "type": "object",
      "maxProperties": 128,
      "propertyNames": {
        "$ref": "#/definitions/id"
      },
      "additionalProperties": {
        "$ref": "#/definitions/arguments"
      }
    },
    "gallery_menu_item": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "label"
      ],
      "properties": {
        "id": {
          "$ref": "#/definitions/id"
        },
        "label": {
          "$ref": "#/definitions/text"
        },
        "command": {
          "$ref": "#/definitions/id"
        },
        "checked": {
          "type": "boolean"
        },
        "enabled": {
          "type": "boolean"
        },
        "items": {
          "type": "array",
          "minItems": 1,
          "maxItems": 64,
          "items": {
            "$ref": "#/definitions/gallery_menu_item"
          }
        },
        "gesture": {
          "enum": [
            "badge",
            "back",
            "forward",
            "ctrl_wheel_up",
            "ctrl_wheel_down",
            "shift_click"
          ]
        },
        "input": {
          "enum": [
            "text",
            "files",
            "confirm"
          ]
        },
        "target": {
          "enum": [
            "item",
            "gallery"
          ],
          "default": "item"
        }
      },
      "oneOf": [
        {
          "required": [
            "command"
          ],
          "properties": {
            "items": false
          }
        },
        {
          "required": [
            "items"
          ],
          "properties": {
            "command": false,
            "target": false,
            "gesture": false,
            "input": false,
            "checked": false
          }
        }
      ]
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "commands": {
            "contains": {
              "required": [
                "undo"
              ],
              "properties": {
                "undo": {
                  "const": "module"
                }
              }
            }
          }
        }
      },
      "then": {
        "required": [
          "required_capabilities"
        ],
        "properties": {
          "required_capabilities": {
            "contains": {
              "const": "scene.module-undo@1"
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "schema_version": {
            "const": "1.0.0"
          }
        }
      },
      "then": {
        "properties": {
          "argument_sets": false,
          "commands": {
            "items": {
              "properties": {
                "args_ref": false
              },
              "required": [
                "args"
              ]
            }
          },
          "panel_templates": {
            "items": {
              "properties": {
                "argument_sets": false,
                "commands": {
                  "items": {
                    "properties": {
                      "args_ref": false
                    },
                    "required": [
                      "args"
                    ]
                  }
                }
              }
            }
          }
        }
      }
    }
  ]
}