{
  "pluginAlias": "CloudflaredTunnel",
  "pluginType": "platform",
  "singular": true,
  "customUi": true,
  "customUiPath": "./dist/homebridge-ui",
  "headerDisplay": "<p align='center'><img width='250px' src='https://raw.githubusercontent.com/homebridge-plugins/homebridge-cloudflared-tunnel/latest/branding/Homebridge_x_CloudflaredTunnel.png'></p>\n\n<p>The Homebridge Cloudflared Tunnel plugin allows you to run a Cloudflare-Tunnel for exposing your Homebridge instance for remote access.",
  "footerDisplay": "Your CloudflaredTunnel has been created. Please raise any issues on our [project page](https://github.com/homebridge-plugins/homebridge-cloudflared-tunnel/issues).\n\nIf you would like to have other features, please open a [feature request](https://github.com/homebridge-plugins/homebridge-cloudflared-tunnel/issues/new/choose).",
  "schema": {
    "type": "object",
    "properties": {
      "name": {
        "type": "string",
        "title": "Name",
        "default": "CloudflaredTunnel"
      },
      "domain": {
        "type": "string",
        "title": "Domain",
        "description": "The domain of the self specified tunnel."
      },
      "token": {
        "type": "string",
        "title": "Token",
        "description": "The token to use for the self specified tunnel.",
        "condition": {
          "functionBody": "return (!model.url || (!model.protocol && !model.hostname && !model.port));"
        }
      },
      "acceptCloudflareNotice": {
        "type": "boolean",
        "title": "Auto Start Tunnel Install",
        "description": "Automatically start the Cloudflared Tunnel install process.",
        "condition": {
          "functionBody": "return (!model.token && !model.domain);"
        }
      },
      "url": {
        "type": "string",
        "title": "URL",
        "placeholder": "http://localhost:8581",
        "pattern": "^https?://",
        "condition": {
          "functionBody": "return ((!model.port && !model.hostname && !model.protocol) || (!model.domain && !model.token));"
        },
        "description": "The URL to tunnel to. If you are using a URL, you do not need to specify the protocol, hostname, or port.",
        "default": "",
        "format": "uri",
        "patternErrorMessage": "URL must start with http:// or https://",
        "validationMessage": "URL must start with http:// or https://",
        "validationKeywords": [
          "pattern"
        ],
        "validation": {
          "pattern": "^https?://"
        }
      },
      "protocol": {
        "type": "string",
        "title": "Protocol",
        "default": "",
        "oneOf": [
          {
            "title": "HTTP",
            "enum": [
              "http"
            ]
          },
          {
            "title": "HTTPS",
            "enum": [
              "https"
            ]
          }
        ],
        "description": "The protocol to use for the tunnel. If you are using a URL, you do not need to specify the protocol, hostname, or port.",
        "condition": {
          "functionBody": "return (!model.url || (!model.domain && !model.token));"
        }
      },
      "hostname": {
        "type": "string",
        "title": "hostname",
        "placeholder": "homebridge.local",
        "description": "The hostname to tunnel to. If you are using a URL, you do not need to specify the protocol, hostname, or port.",
        "validation": {
          "pattern": "^(?!\\s*$).+",
          "functionBody": "return (!model.url);"
        },
        "validationMessage": "Hostname must be specified if not using a URL",
        "pattern": "^(?!\\s*$).+",
        "patternErrorMessage": "Hostname must be specified if not using a URL",
        "validationKeywords": [
          "pattern"
        ],
        "condition": {
          "functionBody": "return (!model.url || (!model.domain && !model.token));"
        }
      },
      "port": {
        "type": "number",
        "title": "Port",
        "placeholder": "8581",
        "description": "The port to tunnel to. If you are using a URL, you do not need to specify the protocol, hostname, or port.",
        "minimum": 1,
        "maximum": 65535,
        "validationMessage": "Port must be between 1 and 65535",
        "validationKeywords": [
          "minimum",
          "maximum"
        ],
        "validation": {
          "minimum": 1,
          "maximum": 65535,
          "functionBody": "return (!model.url || (!model.domain && !model.token));"
        },
        "condition": {
          "functionBody": "return (!model.url || (!model.domain && !model.token));"
        }
      },
      "verifyTLS": {
        "type": "boolean",
        "title": "Verify TLS",
        "default": false,
        "description": "Verify the TLS certificate of the origin server.",
        "condition": {
          "functionBody": "return ((!model.url || (!model.protocol && !model.hostname && !model.port)) || (!model.domain && !model.token));"
        },
        "validation": {
          "functionBody": "return ((!model.url || (!model.protocol && !model.hostname && !model.port)) || (!model.domain && !model.token));"
        }
      },
      "logging": {
        "title": "Plugin Logging Level",
        "description": "None turns off all messages from this plugin. Standard shows normal activity, warnings and errors. Debug adds detailed messages, and is what to use when reporting a problem. Default behaves the same as Standard.",
        "type": "string",
        "default": "",
        "oneOf": [
          {
            "title": "Default (same as Standard)",
            "enum": [
              ""
            ]
          },
          {
            "title": "None",
            "enum": [
              "none"
            ]
          },
          {
            "title": "Standard",
            "enum": [
              "standard"
            ]
          },
          {
            "title": "Debug",
            "enum": [
              "debug"
            ]
          }
        ]
      },
      "enableMatter": {
        "type": "boolean",
        "title": "Enable Matter",
        "default": true,
        "description": "Enable Matter mode for this plugin. In Matter mode, the plugin publishes only the Matter tunnel status accessory endpoint."
      },
      "allowInvalidCharacters": {
        "title": "Allow Invalid Characters",
        "type": "boolean",
        "default": false,
        "description": "Keep accessory names exactly as they are set. Without this, characters HomeKit does not accept are stripped out and the change is reported in the log."
      }
    },
    "dependentRequired": {
      "domain": [
        "token"
      ],
      "token": [
        "domain"
      ],
      "protocol": [
        "hostname",
        "port"
      ],
      "hostname": [
        "protocol",
        "port"
      ],
      "port": [
        "protocol",
        "hostname"
      ]
    },
    "required": [
      "name",
      "logging"
    ]
  },
  "layout": [
    {
      "type": "fieldset",
      "title": "Cloudflared Tunnel Settings",
      "expandable": true,
      "expanded": false,
      "items": [
        "domain",
        "token",
        "acceptCloudflareNotice",
        "url",
        "protocol",
        "hostname",
        "port",
        "verifyTLS"
      ]
    },
    {
      "type": "fieldset",
      "title": "Advanced Settings",
      "expandable": true,
      "expanded": false,
      "items": [
        "logging",
        "allowInvalidCharacters"
      ]
    },
    {
      "type": "fieldset",
      "title": "Matter Settings",
      "expandable": true,
      "expanded": false,
      "items": [
        "enableMatter"
      ]
    }
  ]
}
