{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://www.anguskit.com/schema/angusmeter/plugins/angus-playwright.json",
  "type": "object",
  "properties": {
    "action": {
      "type": "string",
      "enum": [
        "NAVIGATE",
        "GO_BACK",
        "GO_FORWARD",
        "RELOAD",
        "CLICK",
        "DOUBLE_CLICK",
        "RIGHT_CLICK",
        "TAP",
        "FILL",
        "SELECT",
        "HOVER",
        "CHECK",
        "UNCHECK",
        "UPLOAD",
        "SCREENSHOT",
        "EVALUATE",
        "WAIT",
        "WAIT_FOR_URL",
        "ASSERT",
        "DRAG",
        "KEYBOARD",
        "SCROLL",
        "SWIPE",
        "SWITCH_FRAME",
        "EXIT_FRAME",
        "GET_COOKIE",
        "SET_COOKIE",
        "DELETE_COOKIE",
        "ALERT"
      ],
      "description": "The web action to perform (supports ${var} interpolation)"
    },
    "selector": {
      "type": "string",
      "description": "CSS or Playwright selector for the target element (supports ${var} interpolation)"
    },
    "value": {
      "type": "string",
      "description": "Value to fill, select, or evaluate (supports ${var} interpolation)"
    },
    "url": {
      "type": "string",
      "format": "uri",
      "description": "URL to navigate to (supports ${var} interpolation)"
    },
    "browser": {
      "type": "string",
      "enum": [
        "chromium",
        "firefox",
        "webkit"
      ],
      "default": "chromium",
      "description": "Browser engine to use"
    },
    "headless": {
      "type": "boolean",
      "default": true,
      "description": "Run the browser in headless mode"
    },
    "timeout": {
      "type": "integer",
      "minimum": 1,
      "default": 30000,
      "description": "Action timeout in milliseconds"
    },
    "condition": {
      "type": "string",
      "enum": [
        "attached",
        "visible",
        "hidden",
        "detached"
      ],
      "default": "attached",
      "description": "Wait condition for WAIT action when a selector is provided"
    },
    "script": {
      "type": "string",
      "description": "JavaScript to execute for EVALUATE action (supports ${var} interpolation)"
    },
    "allowScripting": {
      "type": "boolean",
      "default": false,
      "description": "Must be true to allow EVALUATE (arbitrary JS execution) — security gate"
    },
    "filePath": {
      "type": "string",
      "description": "File path to upload for UPLOAD action (supports ${var} interpolation)"
    },
    "assertType": {
      "type": "string",
      "enum": [
        "URL",
        "ELEMENT_VISIBLE",
        "ELEMENT_TEXT",
        "ELEMENT_ATTRIBUTE",
        "PAGE_TITLE",
        "ELEMENT_COUNT",
        "ELEMENT_ENABLED",
        "ELEMENT_CHECKED",
        "CONSOLE_LOG",
        "ELEMENT_CSS"
      ],
      "description": "Type of assertion to evaluate for ASSERT action"
    },
    "expected": {
      "type": "string",
      "description": "Expected value for ASSERT action (supports ${var} interpolation)"
    },
    "attribute": {
      "type": "string",
      "description": "Attribute or CSS property name for ELEMENT_ATTRIBUTE / ELEMENT_CSS assertion"
    },
    "sourceSelector": {
      "type": "string",
      "description": "Source element selector for DRAG action (supports ${var} interpolation)"
    },
    "targetSelector": {
      "type": "string",
      "description": "Target element selector for DRAG action (supports ${var} interpolation)"
    },
    "keyboardAction": {
      "type": "string",
      "enum": [
        "press",
        "type"
      ],
      "default": "press",
      "description": "Keyboard action type: press a key or type text"
    },
    "key": {
      "type": "string",
      "description": "Key to press for KEYBOARD action (e.g. Enter, Tab, Escape)"
    },
    "text": {
      "type": "string",
      "description": "Text to type for KEYBOARD action (supports ${var} interpolation)"
    },
    "frameSelector": {
      "type": "string",
      "description": "Frame selector for SWITCH_FRAME action (supports ${var} interpolation)"
    },
    "cookieName": {
      "type": "string",
      "description": "Cookie name for GET_COOKIE / SET_COOKIE actions"
    },
    "cookieValue": {
      "type": "string",
      "description": "Cookie value for SET_COOKIE action (supports ${var} interpolation)"
    },
    "cookieUrl": {
      "type": "string",
      "description": "Cookie URL for SET_COOKIE action (defaults to current page URL)"
    },
    "cookieDomain": {
      "type": "string",
      "description": "Cookie domain for SET_COOKIE (requires cookiePath)"
    },
    "cookiePath": {
      "type": "string",
      "default": "/",
      "description": "Cookie path for SET_COOKIE when cookieDomain is set"
    },
    "cookieSecure": {
      "type": "boolean",
      "description": "Cookie Secure flag"
    },
    "cookieHttpOnly": {
      "type": "boolean",
      "description": "Cookie HttpOnly flag"
    },
    "cookieSameSite": {
      "type": "string",
      "enum": [
        "Strict",
        "Lax",
        "None"
      ],
      "description": "Cookie SameSite attribute"
    },
    "cookieExpires": {
      "type": "integer",
      "description": "Cookie expiration as Unix epoch seconds"
    },
    "alertAction": {
      "type": "string",
      "enum": [
        "accept",
        "dismiss"
      ],
      "default": "accept",
      "description": "Action to perform on a JavaScript dialog"
    },
    "alertText": {
      "type": "string",
      "description": "Text to enter for prompt dialogs when alertAction is accept"
    },
    "screenshot": {
      "type": "object",
      "properties": {
        "path": {
          "type": "string",
          "description": "File path to save the screenshot (supports ${var} interpolation)"
        },
        "fullPage": {
          "type": "boolean",
          "default": false,
          "description": "Capture the full scrollable page"
        },
        "type": {
          "type": "string",
          "enum": [
            "png",
            "jpeg"
          ],
          "default": "png",
          "description": "Screenshot image format"
        }
      },
      "description": "Screenshot capture options for SCREENSHOT action"
    },
    "viewport": {
      "type": "object",
      "properties": {
        "width": {
          "type": "integer",
          "minimum": 1,
          "description": "Viewport width in pixels"
        },
        "height": {
          "type": "integer",
          "minimum": 1,
          "description": "Viewport height in pixels"
        }
      },
      "description": "Browser viewport dimensions"
    },
    "device": {
      "type": "string",
      "description": "Device preset name (e.g. 'iPhone 13', 'Pixel 5'); individual fields override preset"
    },
    "userAgent": {
      "type": "string",
      "description": "Custom User-Agent header"
    },
    "locale": {
      "type": "string",
      "description": "Browser locale, e.g. 'en-US', 'zh-CN'"
    },
    "timezoneId": {
      "type": "string",
      "description": "IANA timezone, e.g. 'Asia/Shanghai'"
    },
    "isMobile": {
      "type": "boolean",
      "description": "Emulate mobile browser (meta viewport on)"
    },
    "hasTouch": {
      "type": "boolean",
      "description": "Emulate touch input device"
    },
    "deviceScaleFactor": {
      "type": "number",
      "minimum": 0,
      "description": "Device pixel ratio"
    },
    "scrollX": {
      "type": "integer",
      "description": "Absolute X scroll for SCROLL action"
    },
    "scrollY": {
      "type": "integer",
      "description": "Absolute Y scroll for SCROLL action"
    },
    "startX": {
      "type": "integer",
      "description": "Swipe/drag start X (px)"
    },
    "startY": {
      "type": "integer",
      "description": "Swipe/drag start Y (px)"
    },
    "endX": {
      "type": "integer",
      "description": "Swipe/drag end X (px)"
    },
    "endY": {
      "type": "integer",
      "description": "Swipe/drag end Y (px)"
    },
    "steps": {
      "type": "integer",
      "minimum": 1,
      "default": 10,
      "description": "Interpolation steps for SWIPE (higher = smoother)"
    },
    "geolocation": {
      "type": "object",
      "properties": {
        "latitude": {
          "type": "number",
          "minimum": -90,
          "maximum": 90,
          "description": "Latitude in degrees"
        },
        "longitude": {
          "type": "number",
          "minimum": -180,
          "maximum": 180,
          "description": "Longitude in degrees"
        },
        "accuracy": {
          "type": "number",
          "minimum": 0,
          "description": "Optional accuracy in meters"
        }
      },
      "required": [
        "latitude",
        "longitude"
      ],
      "description": "Mock geolocation; auto-grants 'geolocation' permission when set"
    },
    "permissions": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Browser permissions to grant (e.g. 'geolocation','notifications','camera','microphone')"
    },
    "offline": {
      "type": "boolean",
      "description": "Emulate offline network at context creation"
    },
    "colorScheme": {
      "type": "string",
      "enum": [
        "light",
        "dark",
        "no-preference"
      ],
      "description": "Emulated CSS prefers-color-scheme"
    },
    "reducedMotion": {
      "type": "string",
      "enum": [
        "reduce",
        "no-preference"
      ],
      "description": "Emulated CSS prefers-reduced-motion"
    },
    "newContext": {
      "type": "boolean",
      "default": false,
      "description": "Force a fresh BrowserContext (closes any existing one) for scenario-level cookie/storage isolation"
    }
  },
  "required": [
    "action"
  ]
}
