{
  "$schema": "http://json-schema.org/draft-07/schema",
  "title": "UIFeedbackConfig",
  "description": "General configuration for UI Feedback elements",
  "type": "object",
  "properties": {
    "elements": {
      "type": "array",
      "description": "Elements inside UIFeedbackConfig.",
      "items": {
        "$ref": "#/definitions/element"
      }
    },
    "presetDefinitions": {
      "type": "array",
      "description": "Preset definitions inside UIFeedbackConfig.",
      "items": {
        "$ref": "#/definitions/presetDefinition"
      }
    },
    "presets": {
      "type": "array",
      "description": "Allows to use presets.",
      "items": {
        "$ref": "#/definitions/preset"
      }
    }
  },
  "definitions": {
    "overlayScale": {
      "title": "OverlayScaleConfig",
      "description": "Configuration for UI Feedback overlays",
      "type": "object",
      "properties": {
        "scaleValue": {
          "description": "Sets the scale value of the overlay.",
          "type": "number"
        },
        "scaleType": {
          "title": "OverlayScaleTypeConfig",
          "description": "Sets the scale type of the overlay.",
          "type": "string",
          "enum": [
            "none",
            "fixed_px",
            "keep_ratio",
            "overlay"
          ]
        }
      }
    },
    "overlayDimension": {
      "title": "OverlayDimensionConfig",
      "description": "Sets the dimension of the overlay.",
      "type": "object",
      "properties": {
        "scaleX": {
          "description": "Sets the scale for x axis of the overlay.",
          "$ref": "#/definitions/overlayScale"
        },
        "scaleY": {
          "description": "Sets the scale for y axis of the overlay.",
          "$ref": "#/definitions/overlayScale"
        }
      }
    },
    "overlayAnchor": {
      "title": "OverlayAnchorConfig",
      "description": "Sets the anchor of the overlay relative to the source defined in the overlaySource.",
      "type": "string",
      "enum": [
        "top_left",
        "top_center",
        "top_right",
        "center_left",
        "center",
        "center_right",
        "bottom_left",
        "bottom_center",
        "bottom_right"
      ]
    },
    "overlaySource": {
      "type": "string",
      "enum": [
        "cutout"
      ],
      "default": "cutout",
      "description": "Sets the source of the overlay. Currently cutout is the only available overlay source."
    },
    "overlay": {
      "title": "OverlayConfig",
      "description": "Configuration for UI Feedback overlays",
      "type": "object",
      "properties": {
        "source": {
          "$ref": "#/definitions/overlaySource",
          "description": "Sets the source of the overlay."
        },
        "anchor": {
          "$ref": "#/definitions/overlayAnchor",
          "description": "Sets the anchor of the overlay."
        },
        "sizeDimension": {
          "$ref": "#/definitions/overlayDimension",
          "description": "Sets the size dimension of the overlay."
        },
        "offsetDimension": {
          "$ref": "#/definitions/overlayDimension",
          "description": "Sets the offset dimension of the overlay."
        },
        "presets": {
          "type": "array",
          "description": "Allows to use overlay presets.",
          "items": {
            "$ref": "#/definitions/preset"
          }
        }
      }
    },
    "content": {
      "title": "UIFeedbackElementContentConfig",
      "description": "Configuration for UI Feedback content",
      "type": "object",
      "properties": {
        "contentValue": {
          "type": "string",
          "default": "",
          "description": "Sets the content of the element."
        },
        "durationMills": {
          "type": "integer",
          "default": 0,
          "minimum": 0,
          "maximum": 1000000,
          "description": "Sets the duration of the element."
        },
        "priorityLevel": {
          "type": "integer",
          "default": 1,
          "minimum": 0,
          "maximum": 100,
          "description": "Sets the priority of the element."
        }
      }
    },
    "triggerScanInfo": {
      "title": "UIFeedbackElementTriggerScanInfoConfig",
      "description": "Configuration for triggering UI Feedback on ScanInfo events",
      "type": "object",
      "properties": {
        "applyDefaultContent": {
          "type": "boolean",
          "default": false,
          "description": "Sets whether the trigger must apply defaultContent."
        },
        "applyContentInstead": {
          "$ref": "#/definitions/content"
        },
        "applyDefaultAttributes": {
          "type": "boolean",
          "default": false,
          "description": "Sets whether the trigger must apply defaultAttributes."
        },
        "applyAttributesInstead": {
          "$ref": "#/definitions/elementAttributes"
        },
        "varNameEquals": {
          "type": "string",
          "default": "",
          "description": "Sets the ScanInfo variable name to be watched."
        },
        "varValueEquals": {
          "type": "string",
          "default": "",
          "description": "Sets the ScanInfo variable value to be watched."
        }
      }
    },
    "triggerRunSkipped": {
      "title": "UIFeedbackElementTriggerRunSkippedConfig",
      "description": "Configuration for triggering UI Feedback on RunSkipped events",
      "type": "object",
      "properties": {
        "applyDefaultContent": {
          "type": "boolean",
          "default": false,
          "description": "Sets whether the trigger must apply defaultContent."
        },
        "applyContentInstead": {
          "$ref": "#/definitions/content"
        },
        "applyDefaultAttributes": {
          "type": "boolean",
          "default": false,
          "description": "Sets whether the trigger must apply defaultAttributes."
        },
        "applyAttributesInstead": {
          "$ref": "#/definitions/elementAttributes"
        },
        "codeEquals": {
          "type": "integer",
          "default": "0",
          "description": "Sets the runSkipped code to be watched."
        }
      }
    },
    "triggerWhenScanInfo": {
      "title": "UIFeedbackElementTriggerWhenScanInfoConfig",
      "description": "Configuration for triggering UI Feedback on ScanInfo events",
      "type": "object",
      "properties": {
        "when": {
          "javaName": "whenElement",
          "type": "object",
          "$ref": "#/definitions/triggerScanInfo"
        }
      }
    },
    "triggerWhenRunSkipped": {
      "title": "UIFeedbackElementTriggerWhenRunSkippedConfig",
      "description": "Configuration for triggering UI Feedback on RunSkipped events",
      "type": "object",
      "properties": {
        "when": {
          "javaName": "whenElement",
          "type": "object",
          "$ref": "#/definitions/triggerRunSkipped"
        }
      }
    },
    "elementTrigger": {
      "title": "UIFeedbackElementTriggerConfig",
      "description": "Trigger configuration for UI Feedback",
      "type": "object",
      "properties": {
        "scanInfo": {
          "type": "array",
          "description": "Allows to watch scanInfo events.",
          "items": {
            "$ref": "#/definitions/triggerWhenScanInfo"
          }
        },
        "runSkipped": {
          "type": "array",
          "description": "Allows to watch runSkipped events.",
          "items": {
            "$ref": "#/definitions/triggerWhenRunSkipped"
          }
        },
        "presets": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/preset"
          }
        }
      }
    },
    "elementType": {
      "type": "string",
      "enum": [
        "image",
        "sound",
        "text"
      ],
      "default": "text",
      "description": "Sets the view type of the element."
    },
    "elementAttributes": {
      "title": "UIFeedbackElementAttributesConfig",
      "description": "Configuration attributes for UI Feedback view elements",
      "type": "object",
      "properties": {
        "textAlignment": {
          "type": "string",
          "enum": [
            "left",
            "right",
            "center"
          ],
          "default": "center",
          "description": "Sets the text alignment."
        },
        "textColor": {
          "type": "string",
          "description": "Sets the text color."
        },
        "backgroundColor": {
          "type": "string",
          "description": "Sets the background color."
        },
        "imageScaleType": {
          "type": "string",
          "enum": [
            "center",
            "center_crop",
            "fit_center",
            "fit_xy"
          ],
          "default": "fit_center",
          "description": "Sets the image scale type."
        }
      }
    },
    "element": {
      "title": "UIFeedbackElementConfig",
      "description": "Configuration for uiFeedback element",
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Sets the id of the element."
        },
        "contentType": {
          "$ref": "#/definitions/elementType"
        },
        "defaultContent": {
          "$ref": "#/definitions/content"
        },
        "clickable": {
          "type": "boolean",
          "default": false,
          "description": "Sets whether the view is clickable."
        },
        "tag": {
          "type": "string",
          "default": "",
          "description": "Sets a tag for the element."
        },
        "defaultAttributes": {
          "$ref": "#/definitions/elementAttributes"
        },
        "trigger": {
          "$ref": "#/definitions/elementTrigger"
        },
        "overlay": {
          "$ref": "#/definitions/overlay"
        },
        "presets": {
          "type": "array",
          "description": "Allows to use element presets.",
          "items": {
            "$ref": "#/definitions/preset"
          }
        }
      }
    },
    "presetDefinitionAttribute": {
      "title": "UIFeedbackPresetDefinitionAttributeConfig",
      "description": "Configuration for uiFeedback preset definition attribute.",
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "Sets the name of the attribute."
        },
        "elementName": {
          "type": "string",
          "description": "Sets the name of the element of the attribute."
        },
        "elementType": {
          "type": "string",
          "enum": [
            "int",
            "long",
            "double",
            "boolean",
            "string",
            "any"
          ],
          "description": "Sets the preset definition attribute element type."
        }
      }
    },
    "presetDefinition": {
      "title": "UIFeedbackPresetDefinitionConfig",
      "description": "Configuration for uiFeedback preset definition.",
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "Sets the name of the preset definition."
        },
        "type": {
          "type": "string",
          "enum": [
            "presetElementOverlay",
            "presetElementTrigger",
            "presetElement",
            "preset"
          ],
          "description": "Sets the preset definition type."
        },
        "attributes": {
          "type": "array",
          "description": "Attributes inside preset definition.",
          "items": {
            "$ref": "#/definitions/presetDefinitionAttribute"
          }
        },
        "presetContent": {
          "title": "UIFeedbackPresetContentConfig",
          "description": "Configuration for uiFeedback preset content definition.",
          "type": "object",
          "properties": {
            "overlay": {
              "$ref": "#/definitions/overlay"
            },
            "trigger": {
              "$ref": "#/definitions/elementTrigger"
            },
            "element": {
              "$ref": "#/definitions/element"
            },
            "elements": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/element"
              }
            },
            "presets": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/preset"
              }
            }
          }
        }
      },
      "required": [
        "name",
        "type"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "type": {
                "const": "presetElementOverlay"
              }
            }
          },
          "then": {
            "properties": {
              "presetContent": {
                "required": [
                  "overlay"
                ]
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "presetElementTrigger"
              }
            }
          },
          "then": {
            "properties": {
              "presetContent": {
                "required": [
                  "trigger"
                ]
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "presetElement"
              }
            }
          },
          "then": {
            "properties": {
              "presetContent": {
                "required": [
                  "element"
                ]
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "preset"
              }
            }
          },
          "then": {
            "properties": {
              "presetContent": {
                "required": [
                  "elements"
                ]
              }
            }
          }
        }
      ]
    },
    "presetAttribute": {
      "title": "UIFeedbackPresetAttributeConfig",
      "description": "Configuration for uiFeedback preset attribute.",
      "type": "object",
      "properties": {
        "attributeName": {
          "type": "string",
          "description": "Name of the attribute declared in the preset definition."
        },
        "attributeValue": {
          "type": "string",
          "description": "Sets the value of the attribute."
        }
      }
    },
    "preset": {
      "title": "UIFeedbackPresetConfig",
      "description": "Configuration for uiFeedback preset.",
      "type": "object",
      "properties": {
        "presetName": {
          "type": "string",
          "description": "Name of the preset."
        },
        "presetAttributes": {
          "type": "array",
          "description": "Attributes inside preset.",
          "items": {
            "$ref": "#/definitions/presetAttribute"
          }
        }
      }
    }
  }
}
