{
  "version": "1.1.0",
  "source": {"tool": "figma", "fileId": "sample-ai-native-interactions"},
  "tokens": {
    "space.3": {"type": "dimension", "value": 12, "unit": "px"},
    "color.brand.primary": {"type": "color", "value": "#2F6BFF"},
    "typography.label.md": {
      "type": "typography",
      "value": {"fontFamily": "Inter", "fontSize": 14, "fontWeight": 600, "lineHeight": 20}
    }
  },
  "nodes": [
    {
      "id": "scr_login",
      "type": "screen",
      "name": "Login",
      "role": "container",
      "children": ["cnt_form"]
    },
    {
      "id": "cnt_form",
      "type": "container",
      "name": "Form",
      "parentId": "scr_login",
      "children": ["cmp_email", "cmp_password", "cmp_submit"],
      "layout": {"type": "stack", "direction": "column", "gap": "{space.3}"}
    },
    {"id": "cmp_email", "type": "component", "name": "Input/Email", "role": "input", "parentId": "cnt_form"},
    {"id": "cmp_password", "type": "component", "name": "Input/Password", "role": "input", "parentId": "cnt_form"},
    {
      "id": "cmp_submit",
      "type": "component",
      "name": "Button/LogIn",
      "role": "button",
      "parentId": "cnt_form",
      "style": {"background": "{color.brand.primary}", "text": "{typography.label.md}"}
    }
  ],
  "extensions": {
    "ai_native": {
      "version": "1.1.0",
      "contractDialect": "jsonschema-2020-12",
      "intent": {
        "cmp_submit": "authenticate user",
        "cmp_email": "collect email",
        "cmp_password": "collect password"
      },
      "flows": {
        "login": {"steps": ["cmp_email", "cmp_password", "cmp_submit", "@showResult"]}
      },
      "state": {
        "form": {
          "description": "Login form model",
          "initial": {"email": "test@example.com", "password": "password123"}
        },
        "session": {
          "description": "Session and auth results",
          "initial": {"auth": null, "authError": null}
        }
      },
      "dataBindings": [
        {
          "component": "cmp_email",
          "property": "value",
          "direction": "inout",
          "source": {"kind": "state", "store": "form", "pointer": "/email"}
        },
        {
          "component": "cmp_password",
          "property": "value",
          "direction": "inout",
          "source": {"kind": "state", "store": "form", "pointer": "/password"}
        }
      ],
      "dataClassification": {
        "cmp_password": {
          "categories": ["credentials"],
          "sensitivity": "high",
          "redactInTrace": true,
          "requiresUserConfirmation": false
        }
      },
      "capabilities": {
        "auth.validateCredentials": {
          "description": "Validate credentials before submit",
          "input": {
            "type": "object",
            "required": ["email", "password"],
            "properties": {"email": {"type": "string", "format": "email"}, "password": {"type": "string"}}
          },
          "output": {"type": "object", "required": ["ok"], "properties": {"ok": {"type": "boolean"}, "reason": {"type": "string"}}},
          "fixtures": [
            {
              "id": "ok",
              "args": {"email": "test@example.com", "password": "password123"},
              "result": {"ok": true, "reason": ""}
            },
            {
              "id": "bad",
              "args": {"email": "test@example.com", "password": "wrong"},
              "result": {"ok": false, "reason": "invalid_credentials"}
            }
          ]
        }
      },
      "events": {
        "form.submitted": {
          "description": "Login form submitted",
          "payload": {"type": "object", "properties": {"scope": {"type": "string"}, "status": {"type": "string"}}}
        },
        "auth.validationFailed": {
          "description": "Credential validation failed",
          "payload": {"type": "object", "properties": {"scope": {"type": "string"}, "reason": {"type": "string"}}}
        }
      },
      "actions": {
        "act_validate": {
          "type": "invoke",
          "target": "auth.validateCredentials",
          "payload": {
            "fixtureId": "ok",
            "argsFromState": {"store": "form", "pointer": ""},
            "timeoutMs": 2000,
            "retry": {"maxAttempts": 0, "backoffMs": 0},
            "bindResultTo": {"store": "session", "pointer": "/auth"},
            "bindErrorTo": {"store": "session", "pointer": "/authError"}
          },
          "then": ["act_emit_submitted", "act_submit", "act_nav_success"],
          "catch": ["act_emit_failed"],
          "finally": ["act_clear_password"]
        },
        "act_clear_password": {"type": "setState", "target": "scr_login", "payload": {"store": "form", "mode": "merge", "patch": {"password": ""}}},
        "act_submit": {"type": "submit", "target": "scr_login", "payload": {"method": "POST", "endpoint": "/login", "bodyFromState": {"store": "form", "pointer": ""}}},
        "act_emit_submitted": {"type": "emit", "target": "scr_login", "payload": {"event": "form.submitted", "detail": {"scope": "scr_login", "status": "attempt"}}},
        "act_emit_failed": {"type": "emit", "target": "scr_login", "payload": {"event": "auth.validationFailed", "detail": {"scope": "scr_login", "reason": "invalid"}}},
        "act_nav_success": {"type": "navigate", "target": "@showResult", "payload": {"mode": "push", "query": {"status": "success"}}},
        "act_nav_error": {"type": "navigate", "target": "@showResult", "payload": {"mode": "push", "query": {"status": "error"}}}
      },
      "eventHandlers": [
        {"id": "eh_login_submit", "on": "click", "scope": "cmp_submit", "preventDefault": true, "stopPropagation": true, "do": ["act_validate"]},
        {"id": "eh_auth_failed", "on": "event", "scope": "scr_login", "event": "auth.validationFailed", "do": ["act_nav_error"]}
      ],
      "a11y": {
        "cmp_email": {"label": "Email", "required": true},
        "cmp_password": {"label": "Password", "required": true},
        "cmp_submit": {"label": "Log in"}
      },
      "validation": {
        "cmp_email": {"required": true, "type": "string", "format": "email"},
        "cmp_password": {"required": true, "type": "string", "minLength": 8}
      }
    }
  }
}
