{
  "format": "flow-studio-project-export/v1",
  "metadata": {
    "title": "设备连接",
    "description": "从权限授权到设备配对的完整体验。"
  },
  "manifest": {
    "format": "flow-studio-project/v1",
    "title": "设备连接",
    "description": "从权限授权到设备配对的完整体验。",
    "source": "device-flow.json",
    "adapter": "generic",
    "defaultGroup": "pairing",
    "defaultScenario": "start",
    "links": [
      {
        "title": "使用与边界",
        "href": "ux-studio/README.md"
      }
    ],
    "previewValues": {}
  },
  "flow": {
    "schemaVersion": 2,
    "version": "DEMO-01",
    "status": "通用适配样例，不代表真实设备协议",
    "entry": "intro",
    "defaults": {
      "state": {
        "permission": false,
        "connected": false
      }
    },
    "rules": [
      "仅演示状态与页面关系"
    ],
    "uncovered": [
      "真实蓝牙授权、扫描、连接及后台恢复"
    ],
    "deferred": [],
    "fixed": {},
    "conditions": {
      "hasPermission": "已允许蓝牙",
      "isConnected": "设备已连接"
    },
    "effects": {
      "allow": "允许蓝牙访问",
      "connect": "连接成功",
      "disconnect": "断开连接"
    },
    "effectValues": {
      "allow": {
        "permission": true
      },
      "connect": {
        "connected": true
      },
      "disconnect": {
        "connected": false
      }
    },
    "conditionValues": {
      "hasPermission": {
        "key": "permission",
        "equals": true
      },
      "isConnected": {
        "key": "connected",
        "equals": true
      }
    },
    "actions": {
      "allow": {
        "to": "devices",
        "effect": "allow"
      },
      "connect": {
        "to": "connected",
        "effect": "connect",
        "guard": "hasPermission"
      },
      "disconnect": {
        "to": "devices",
        "effect": "disconnect"
      }
    },
    "groups": [
      {
        "id": "pairing",
        "title": "发现与连接",
        "description": "发现附近设备，完成授权与连接。",
        "main": [
          "intro",
          "permission",
          "devices",
          "connected"
        ],
        "screens": [
          "intro",
          "permission",
          "devices",
          "connected",
          "retry"
        ]
      }
    ],
    "scenarios": [
      {
        "id": "start",
        "title": "首次连接",
        "description": "从零开始",
        "entry": "intro",
        "state": {
          "permission": false,
          "connected": false
        }
      },
      {
        "id": "allowed",
        "title": "已有授权",
        "description": "可直接连接",
        "entry": "devices",
        "state": {
          "permission": true,
          "connected": false
        }
      },
      {
        "id": "connected",
        "title": "连接成功",
        "description": "检查断开与返回",
        "entry": "connected",
        "state": {
          "permission": true,
          "connected": true
        }
      }
    ],
    "screens": {
      "intro": {
        "title": "连接你的设备",
        "hideBack": true,
        "blocks": [
          {
            "id": "intro-title",
            "type": "heading",
            "text": "让设备，\n准备就绪。"
          },
          {
            "id": "intro-copy",
            "type": "text",
            "text": "简单几步，开始连接体验。"
          },
          {
            "id": "intro-next",
            "type": "action",
            "text": "开始连接",
            "action": "permission"
          },
          {
            "id": "intro-note",
            "type": "note",
            "text": "这是工作台的通用模型示例，不会调用系统蓝牙。"
          }
        ]
      },
      "permission": {
        "title": "允许蓝牙访问",
        "back": {
          "to": "intro"
        },
        "blocks": [
          {
            "id": "permission-copy",
            "type": "text",
            "text": "使用蓝牙发现并连接附近的设备。"
          },
          {
            "id": "permission-allow",
            "type": "action",
            "text": "允许并继续",
            "action": "allow"
          },
          {
            "id": "permission-skip",
            "type": "action",
            "text": "稍后再说",
            "action": "intro"
          }
        ]
      },
      "devices": {
        "title": "选择设备",
        "back": {
          "to": "permission"
        },
        "outcomes": {
          "没有找到设备": "retry"
        },
        "blocks": [
          {
            "id": "devices-photo",
            "type": "placeholder",
            "text": "附近设备列表"
          },
          {
            "id": "devices-connect",
            "type": "action",
            "text": "连接示例设备",
            "action": "connect",
            "enabled": "hasPermission"
          },
          {
            "id": "devices-note",
            "type": "note",
            "text": "没有授权时，连接按钮保持禁用。成功与失败均为模拟。"
          }
        ]
      },
      "connected": {
        "title": "已连接",
        "back": {
          "to": "devices"
        },
        "blocks": [
          {
            "id": "connected-copy",
            "type": "heading",
            "text": "一切就绪。"
          },
          {
            "id": "connected-status",
            "type": "text",
            "text": "你的示例设备已连接。"
          },
          {
            "id": "connected-disconnect",
            "type": "action",
            "text": "断开连接",
            "action": "disconnect",
            "enabled": "isConnected"
          }
        ]
      },
      "retry": {
        "title": "暂未发现设备",
        "back": {
          "to": "devices"
        },
        "blocks": [
          {
            "id": "retry-copy",
            "type": "text",
            "text": "请检查设备是否已开启，或稍后重试。"
          },
          {
            "id": "retry-action",
            "type": "action",
            "text": "重新查找",
            "action": "devices"
          }
        ]
      }
    }
  }
}
