{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://cooobird.github.io/datatip/datatip.schema.json",
  "title": "DataTip Resource File",
  "description": "Schema for DataTip JSON files under assets/<namespace>/datatip/.",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string",
      "description": "Optional editor-side schema reference. DataTip ignores this field when loading."
    }
  },
  "patternProperties": {
    "^_": true,
    "^(#)?[a-z0-9_.-]+:[a-z0-9_./*?-]+$": {
      "$ref": "#/$defs/entry"
    }
  },
  "additionalProperties": false,
  "$defs": {
    "color": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        }
      ]
    },
    "styledText": {
      "type": "object",
      "properties": {
        "text": {
          "type": "string"
        },
        "color": {
          "$ref": "#/$defs/color"
        },
        "align": {
          "enum": [
            "left",
            "center",
            "right"
          ]
        },
        "bold": {
          "type": "boolean"
        },
        "italic": {
          "type": "boolean"
        },
        "underlined": {
          "type": "boolean"
        },
        "strikethrough": {
          "type": "boolean"
        },
        "shift": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "localizedText": {
      "description": "Language-code map. Each value may be plain text or a styled text object.",
      "type": "object",
      "minProperties": 1,
      "additionalProperties": {
        "oneOf": [
          {
            "type": "string"
          },
          {
            "$ref": "#/$defs/styledText"
          }
        ]
      }
    },
    "translatableText": {
      "description": "Minecraft or mod translation key.",
      "type": "object",
      "properties": {
          "translate": {
          "type": "string"
        }
      },
      "required": [
          "translate"
      ],
      "additionalProperties": false
    },
    "localizedValue": {
        "description": "Visible text. Accepts a literal string, a language-code map, or {\"translate\": \"translation.key\"}.",
      "anyOf": [
        {
          "type": "string"
        },
        {
          "$ref": "#/$defs/translatableText"
        },
        {
          "$ref": "#/$defs/localizedText"
        }
      ]
    },
    "localizedLines": {
      "type": "object",
      "additionalProperties": {
        "type": "array",
        "items": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/$defs/styledText"
            }
          ]
        }
      }
    },
    "conditions": {
      "type": "object",
      "properties": {
        "dimension": {
          "type": "string"
        },
        "biome": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "holding": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "sneaking": {
          "type": "boolean"
        },
        "creative": {
          "type": "boolean"
        },
        "survival": {
          "type": "boolean"
        },
        "health": {
          "oneOf": [
            {
              "type": "number"
            },
            {
              "type": "string"
            }
          ]
        },
        "hunger": {
          "oneOf": [
            {
              "type": "number"
            },
            {
              "type": "string"
            }
          ]
        },
        "experience": {
          "oneOf": [
            {
              "type": "number"
            },
            {
              "type": "string"
            }
          ]
        },
        "level": {
          "oneOf": [
            {
              "type": "number"
            },
            {
              "type": "string"
            }
          ]
        },
        "time": {
          "oneOf": [
            {
              "type": "number"
            },
            {
              "enum": [
                "day",
                "night",
                "noon",
                "midnight"
              ]
            }
          ]
        },
        "weather": {
          "enum": [
            "clear",
            "rain",
            "thunder"
          ]
        },
        "light": {
          "oneOf": [
            {
              "type": "number"
            },
            {
              "enum": [
                "dark",
                "dim",
                "bright",
                "full"
              ]
            }
          ]
        },
        "altitude": {
          "oneOf": [
            {
              "type": "number"
            },
            {
              "type": "string"
            }
          ]
        },
        "enchanted": {
          "type": "boolean"
        },
        "damage": {
          "type": "number"
        },
        "count": {
          "type": "number"
        },
        "component": {
          "type": "string"
        },
        "custom_data": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "additionalProperties": {
                "type": [
                  "string",
                  "number",
                  "boolean",
                  "null"
                ]
              }
            }
          ]
        },
        "item_tag": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "chartEntry": {
      "type": "object",
      "properties": {
        "label": {
          "$ref": "#/$defs/localizedValue"
        },
        "value": {
          "oneOf": [
            {
              "type": "number"
            },
            {
              "type": "string"
            }
          ]
        },
        "valueExpr": {
          "type": "string"
        },
        "color": {
          "$ref": "#/$defs/color"
        }
      },
      "additionalProperties": false
    },
    "content": {
      "type": "object",
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "type": "string",
          "minLength": 1,
          "examples": [
            "text",
            "cycle_text",
            "spacer",
            "divider",
            "item",
            "atlas",
            "block",
            "entity",
            "progress",
            "vbox",
            "hbox",
            "carousel",
            "typewriter",
            "image",
              "chart",
              "stack"
          ]
        },
        "conditions": {
          "$ref": "#/$defs/conditions"
        },
          "constraints": {
              "type": "object",
              "properties": {
                  "width": {
                      "type": "integer",
                      "minimum": 0
                  },
                  "height": {
                      "type": "integer",
                      "minimum": 0
                  },
                  "minWidth": {
                      "type": "integer",
                      "minimum": 0
                  },
                  "minHeight": {
                      "type": "integer",
                      "minimum": 0
                  },
                  "maxWidth": {
                      "type": "integer",
                      "minimum": 0
                  },
                  "maxHeight": {
                      "type": "integer",
                      "minimum": 0
                  }
              },
              "additionalProperties": false
          },
        "shift": {
          "type": "boolean"
        },
        "prepend": {
          "type": "boolean"
        },
        "shiftHint": {
          "description": "Custom content replacing the merged Shift hint.",
          "oneOf": [
            {
              "$ref": "#/$defs/content"
            },
            {
              "type": "array",
              "items": {
                "$ref": "#/$defs/content"
              }
            }
          ]
        },
        "scrollHint": {
          "description": "Custom content shown when the physical tooltip viewport overflows.",
          "oneOf": [
            {
              "$ref": "#/$defs/content"
            },
            {
              "type": "array",
              "items": {
                "$ref": "#/$defs/content"
              }
            }
          ]
        },
        "text": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/$defs/localizedText"
            }
          ]
        },
        "translate": {
          "type": "string"
        },
        "keybind": {
          "type": "string"
        },
        "with": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": [
                  "string",
                  "number",
                  "boolean"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string"
                  },
                  "translate": {
                    "type": "string"
                  },
                  "keybind": {
                    "type": "string"
                  },
                  "with": {
                    "type": "array"
                  }
                },
                "additionalProperties": false
              }
            ]
          }
        },
          "trans": false,
          "offsetZ": {
              "type": "integer",
              "minimum": -9223372036854775808,
              "maximum": 9223372036854775807
          },
          "selfAlignX": {
              "enum": [
                  "inherit",
                  "left",
                  "center",
                  "right"
              ]
          },
          "selfAlignY": {
              "enum": [
                  "inherit",
                  "top",
                  "center",
                  "bottom"
              ]
          },
          "selfAlign": {
              "enum": [
                  "inherit",
                  "left",
                  "center",
                  "right"
              ]
          },
        "lines": {
          "oneOf": [
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            {
              "$ref": "#/$defs/localizedLines"
            }
          ]
        },
        "children": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/content"
          }
        },
        "frames": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/content"
          }
        },
        "color": {
          "$ref": "#/$defs/color"
        },
        "colors": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/color"
          }
        },
        "cycleSeconds": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "phase": {
          "type": "number"
        },
        "font": {
          "type": "string"
        },
        "align": {
          "enum": [
            "left",
            "center",
            "right",
            "top",
            "bottom"
          ]
        },
          "horizontalAlign": {
              "enum": [
                  "left",
                  "center",
                  "right"
              ]
          },
          "verticalAlign": {
              "enum": [
                  "top",
                  "center",
                  "bottom"
          ]
        },
        "bold": {
          "type": "boolean"
        },
        "italic": {
          "type": "boolean"
        },
        "underlined": {
          "type": "boolean"
        },
        "strikethrough": {
          "type": "boolean"
        },
        "shadow": {
          "type": "boolean"
        },
        "lineHeight": {
          "type": "integer",
            "minimum": 1
        },
        "maxWidth": {
          "type": "integer",
            "minimum": 0
        },
          "minWidth": {
              "type": "integer",
              "minimum": 0
          },
          "minHeight": {
              "type": "integer",
              "minimum": 0
          },
          "maxHeight": {
              "type": "integer",
              "minimum": 0
        },
        "gap": {
          "type": "integer",
            "minimum": 0
        },
        "padding": {
          "type": "integer",
            "minimum": 0
        },
        "width": {
          "type": "integer",
            "minimum": 0
        },
        "height": {
          "type": "integer",
            "minimum": 0
        },
        "size": {
          "type": "integer",
            "minimum": 1
        },
        "offsetX": {
          "type": "integer",
            "minimum": -9223372036854775808,
            "maximum": 9223372036854775807
        },
        "offsetY": {
          "type": "integer",
            "minimum": -9223372036854775808,
            "maximum": 9223372036854775807
        },
        "item": {
          "type": "string"
        },
        "block": {
          "type": "string"
        },
        "entity": {
          "type": "string"
        },
        "texture": {
          "type": "string"
        },
        "count": {
          "type": "integer",
          "minimum": 1
        },
        "showCount": {
          "type": "boolean"
        },
        "showDurability": {
          "type": "boolean"
        },
        "showLabel": {
          "type": "boolean"
        },
        "label": {
          "$ref": "#/$defs/localizedValue"
        },
        "labelColor": {
          "$ref": "#/$defs/color"
        },
        "rotationSpeed": {
          "type": "number"
        },
        "autoRotate": {
          "type": "boolean"
        },
        "progress": {
          "type": "number"
        },
        "colorFg": {
          "$ref": "#/$defs/color"
        },
        "colorBg": {
          "$ref": "#/$defs/color"
        },
        "colorFgLight": {
          "$ref": "#/$defs/color"
        },
        "colorBgDark": {
          "$ref": "#/$defs/color"
        },
        "style": {
          "enum": [
            "solid",
            "dashed",
            "dotted",
            "flat",
            "gradient",
            "segmented",
            "animated"
          ]
        },
        "thickness": {
          "type": "integer",
            "minimum": 1
        },
        "marginTop": {
            "type": "integer"
        },
          "marginRight": {
              "type": "integer"
        },
        "marginBottom": {
            "type": "integer"
        },
          "marginLeft": {
              "type": "integer"
          },
          "margin": {
              "type": "integer"
        },
        "widthMode": {
          "enum": [
            "fixed",
            "fill",
            "centered"
          ]
        },
        "labelAlign": {
          "enum": [
            "left",
            "center",
            "right"
          ]
        },
        "animated": {
          "type": "boolean"
        },
        "animSpeed": {
          "type": "integer",
            "minimum": 1
        },
        "intervalSeconds": {
          "type": "integer",
            "minimum": 1
        },
        "transition": {
          "enum": [
            "none",
            "fade",
            "slide",
            "smooth",
            "step"
          ]
        },
        "charsPerSecond": {
          "type": "integer",
          "minimum": 1
        },
        "pauseSeconds": {
          "type": "integer",
          "minimum": 0
        },
        "loop": {
          "type": "boolean"
        },
        "u": {
          "type": "integer",
          "minimum": 0
        },
        "v": {
          "type": "integer",
          "minimum": 0
        },
        "textureWidth": {
          "type": "integer",
            "minimum": 1
        },
        "textureHeight": {
          "type": "integer",
            "minimum": 1
        },
        "scale": {
          "type": "number",
          "exclusiveMinimum": 0
        },
          "scaleX": {
              "type": "number",
              "exclusiveMinimum": 0
          },
          "scaleY": {
              "type": "number",
              "exclusiveMinimum": 0
          },
          "rotation": {
              "type": "number"
          },
          "pivotX": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
          },
          "pivotY": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
          },
          "opacity": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
          },
          "visible": {
              "type": "boolean"
          },
          "overflow": {
              "enum": [
                  "none",
                  "wrap",
                  "scale_down",
                  "scale-down",
                  "clip"
              ]
          },
        "chartType": {
          "enum": [
            "bar",
            "pie",
            "line"
          ]
        },
        "title": {
          "$ref": "#/$defs/localizedValue"
        },
        "titleColor": {
          "$ref": "#/$defs/color"
        },
        "valueColor": {
          "$ref": "#/$defs/color"
        },
        "zeroLineColor": {
          "$ref": "#/$defs/color"
        },
        "showLabels": {
          "type": "boolean"
        },
        "showValues": {
          "type": "boolean"
        },
        "entries": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/chartEntry"
          }
        }
      },
      "additionalProperties": true
    },
    "legacyObject": {
      "type": "object",
      "not": {
        "required": [
          "type"
        ]
      },
      "required": [
        "text"
      ],
      "properties": {
        "text": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array"
            },
            {
              "type": "object"
            }
          ]
        },
        "color": {
          "$ref": "#/$defs/color"
        },
        "shift": {
          "type": "boolean"
        },
        "prepend": {
          "type": "boolean"
        },
        "conditions": {
          "$ref": "#/$defs/conditions"
        }
      },
      "additionalProperties": true
    },
    "entry": {
      "description": "Modern content or a legacy-compatible string, string array, or text object.",
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        {
          "$ref": "#/$defs/content"
        },
        {
          "$ref": "#/$defs/legacyObject"
        }
      ]
    }
  }
}
