{
  "$defs": {
    "Message": {
      "additionalProperties": true,
      "dependentRequired": {
        "content": [
          "id",
          "template"
        ],
        "template": [
          "id",
          "content"
        ]
      },
      "properties": {
        "frequency": {
          "description": "An object containing frequency cap information for a message.",
          "properties": {
            "custom": {
              "description": "An array of custom frequency cap definitions.",
              "items": {
                "description": "A frequency cap definition containing time and max impression information",
                "properties": {
                  "cap": {
                    "description": "The maximum impressions for the message within the defined period.",
                    "maximum": 100,
                    "minimum": 1,
                    "type": "integer"
                  },
                  "period": {
                    "description": "Period of time in milliseconds (e.g. 86400000 for one day)",
                    "type": "integer"
                  }
                },
                "required": [
                  "period",
                  "cap"
                ],
                "type": "object"
              },
              "type": "array"
            },
            "lifetime": {
              "description": "The maximum lifetime impressions for a message.",
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          },
          "type": "object"
        },
        "groups": {
          "description": "Array of preferences used to control `enabled` status of the group. If any is `false` the group is disabled.",
          "items": {
            "description": "Preference name",
            "type": "string"
          },
          "type": "array"
        },
        "id": {
          "description": "The message identifier",
          "type": "string"
        },
        "order": {
          "description": "The order in which messages should be shown. Messages will be shown in increasing order.",
          "type": "integer"
        },
        "priority": {
          "description": "The priority of the message. If there are two competing messages to show, the one with the highest priority will be shown",
          "type": "integer"
        },
        "provider": {
          "description": "An identifier for the provider of this message, such as \"cfr\" or \"preview\".",
          "type": "string"
        },
        "targeting": {
          "description": "A JEXL expression representing targeting information",
          "type": "string"
        },
        "template": {
          "description": "Which messaging template this message is using.",
          "enum": [
            "toast_notification"
          ],
          "type": "string"
        },
        "trigger": {
          "description": "An action to trigger potentially showing the message",
          "properties": {
            "id": {
              "description": "A string identifying the trigger action",
              "type": "string"
            },
            "params": {
              "description": "An optional array of string parameters for the trigger action",
              "items": {
                "anyOf": [
                  {
                    "type": "integer"
                  },
                  {
                    "type": "string"
                  }
                ]
              },
              "type": "array"
            }
          },
          "required": [
            "id"
          ],
          "type": "object"
        }
      },
      "type": "object"
    },
    "MultiMessage": {
      "description": "An object containing an array of messages.",
      "properties": {
        "messages": {
          "description": "An array of messages.",
          "items": {
            "$ref": "resource://activity-stream/schemas/BackgroundTaskMessagingExperiment.schema.json#/$defs/TemplatedMessage"
          },
          "type": "array"
        },
        "template": {
          "const": "multi",
          "type": "string"
        }
      },
      "required": [
        "template",
        "messages"
      ],
      "type": "object"
    },
    "TemplatedMessage": {
      "allOf": [
        {
          "$ref": "resource://activity-stream/schemas/BackgroundTaskMessagingExperiment.schema.json#/$defs/Message"
        },
        {
          "if": {
            "properties": {
              "template": {
                "enum": [
                  "toast_notification"
                ],
                "type": "string"
              }
            },
            "required": [
              "template"
            ],
            "type": "object"
          },
          "then": {
            "$ref": "resource://activity-stream/schemas/BackgroundTaskMessagingExperiment.schema.json#/$defs/ToastNotification"
          }
        }
      ],
      "description": "An FxMS message of one of a variety of types.",
      "type": "object"
    },
    "ToastNotification": {
      "$id": "file:///ToastNotification.schema.json",
      "$schema": "https://json-schema.org/draft/2019-09/schema",
      "additionalProperties": true,
      "allOf": [
        {
          "$ref": "resource://activity-stream/schemas/BackgroundTaskMessagingExperiment.schema.json#/$defs/Message"
        }
      ],
      "description": "A template for toast notifications displayed by the Alert service.",
      "properties": {
        "content": {
          "additionalProperties": true,
          "properties": {
            "actions": {
              "items": {
                "additionalProperties": true,
                "properties": {
                  "action": {
                    "description": "Opaque identifer that identifies action.",
                    "type": "string"
                  },
                  "iconURL": {
                    "description": "URL of an icon to display with the action.",
                    "format": "uri",
                    "type": "string"
                  },
                  "title": {
                    "$ref": "resource://activity-stream/schemas/BackgroundTaskMessagingExperiment.schema.json#/$defs/localizableText",
                    "description": "The action text to be shown to the user."
                  },
                  "windowsSystemActivationType": {
                    "description": "Whether to have Windows process the given `action`.",
                    "type": "boolean"
                  }
                },
                "required": [
                  "action",
                  "title"
                ],
                "type": "object"
              },
              "type": "array"
            },
            "body": {
              "$ref": "resource://activity-stream/schemas/BackgroundTaskMessagingExperiment.schema.json#/$defs/localizableText",
              "description": "Id of localized string or message override of toast notification body"
            },
            "data": {
              "description": "Arbitrary data associated with the toast notification.",
              "type": "object"
            },
            "icon_url": {
              "description": "The URL of the image used as an icon of the toast notification.",
              "format": "moz-url-format",
              "type": "string"
            },
            "image_url": {
              "description": "The URL of an image to be displayed as part of the notification.",
              "format": "moz-url-format",
              "type": "string"
            },
            "launch_url": {
              "description": "The URL to launch when the notification or an action button is clicked.",
              "format": "moz-url-format",
              "type": "string"
            },
            "requireInteraction": {
              "description": "Whether the toast notification should remain active until the user clicks or dismisses it, rather than closing automatically.",
              "type": "boolean"
            },
            "tag": {
              "description": "An identifying tag for the toast notification.",
              "type": "string"
            },
            "title": {
              "$ref": "resource://activity-stream/schemas/BackgroundTaskMessagingExperiment.schema.json#/$defs/localizableText",
              "description": "Id of localized string or message override of toast notification title"
            }
          },
          "required": [
            "title",
            "body"
          ],
          "type": "object"
        },
        "template": {
          "const": "toast_notification",
          "type": "string"
        }
      },
      "required": [
        "content",
        "targeting",
        "template",
        "trigger"
      ],
      "title": "ToastNotification",
      "type": "object"
    },
    "localizableText": {
      "description": "Either a raw string or an object containing the string_id of the localized text",
      "oneOf": [
        {
          "description": "The string to be rendered.",
          "type": "string"
        },
        {
          "$ref": "resource://activity-stream/schemas/BackgroundTaskMessagingExperiment.schema.json#/$defs/localizedText"
        }
      ]
    },
    "localizedText": {
      "properties": {
        "string_id": {
          "description": "Id of localized string to be rendered.",
          "type": "string"
        }
      },
      "required": [
        "string_id"
      ],
      "type": "object"
    }
  },
  "$id": "resource://activity-stream/schemas/BackgroundTaskMessagingExperiment.schema.json",
  "$schema": "https://json-schema.org/draft/2019-09/schema",
  "description": "A Firefox Messaging System message.",
  "else": {
    "$ref": "resource://activity-stream/schemas/BackgroundTaskMessagingExperiment.schema.json#/$defs/TemplatedMessage"
  },
  "if": {
    "properties": {
      "template": {
        "const": "multi"
      }
    },
    "required": [
      "template"
    ],
    "type": "object"
  },
  "then": {
    "$ref": "resource://activity-stream/schemas/BackgroundTaskMessagingExperiment.schema.json#/$defs/MultiMessage"
  },
  "title": "Messaging Experiment"
}