{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://wstein.github.io/regrip/smartcube-profile.v1.schema.json",
  "type": "object",
  "required": ["id"],
  "properties": {
    "$schema": {
      "const": "https://wstein.github.io/regrip/smartcube-profile.v1.schema.json"
    },
    "id": { "type": "string", "minLength": 1 },
    "extends": { "type": "string" },
    "match": {
      "type": "object",
      "properties": {
        "protocol": { "type": "string" },
        "deviceName": { "type": "string" },
        "deviceMAC": { "type": "string" },
        "hardwareName": { "type": "string" },
        "goCubeType": { "type": "string" }
      },
      "additionalProperties": false
    },
    "battery": {
      "type": "object",
      "properties": { "curve": { "type": "string" } },
      "additionalProperties": false
    },
    "gyro": {
      "type": "object",
      "properties": { "axisMap": { "type": "string" } },
      "additionalProperties": false
    },
    "features": {
      "type": "object",
      "properties": {
        "stabilizer": {
          "type": "object",
          "properties": {
            "enabled": { "type": "boolean" },
            "radiusDeg": { "type": "number" },
            "snapDeg": { "type": "number" },
            "velocityMax": { "type": "number" },
            "hysteresis": {
              "type": "object",
              "properties": {
                "enabled": { "type": "boolean" },
                "marginDeg": { "type": "number" }
              },
              "additionalProperties": false
            },
            "drift": {
              "type": "object",
              "properties": {
                "enabled": { "type": "boolean" },
                "degPerSec": { "type": "number" }
              },
              "additionalProperties": false
            }
          },
          "additionalProperties": false
        },
        "regrip": {
          "type": "object",
          "properties": {
            "enabled": { "type": "boolean" }
          },
          "additionalProperties": false
        },
        "customTrigger": {
          "type": "object",
          "properties": {
            "enabled": { "type": "boolean" },
            "triggers": {
              "type": "array",
              "items": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": ["kind", "windowMs"],
                    "properties": {
                      "kind": { "const": "moveBack" },
                      "windowMs": { "type": "number", "minimum": 0 }
                    },
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "required": ["kind"],
                    "properties": {
                      "kind": { "const": "shake" },
                      "minStepAngleDeg": {
                        "type": "number",
                        "exclusiveMinimum": 0,
                        "maximum": 180
                      },
                      "minSteps": { "type": "integer", "minimum": 1 },
                      "minReversals": { "type": "integer", "minimum": 1 },
                      "maxSampleGapMs": { "type": "number", "minimum": 0 },
                      "burstWindowMs": { "type": "number", "minimum": 0 },
                      "faceGuardMs": { "type": "number", "minimum": 0 },
                      "cooldownMs": { "type": "number", "minimum": 0 }
                    },
                    "additionalProperties": false
                  }
                ]
              }
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "quirks": { "type": "object", "additionalProperties": true }
  },
  "additionalProperties": false
}
