/**
 * ============================================================
 * AirScript: 判定部署类型
 * ============================================================
 *
 * 自动化流程入参:
 *   - isDeployFlyControl:  单选项 (是 / 否) — 是否部署飞服平台
 *   - isDeploySupervisor:  单选项 (是 / 否) — 是否部署监管平台
 *
 * 返回值 (JSON):
 *   { "code": "<类型>" }
 *
 * 判定规则:
 *   两个都为「是」  → "both"
 *   仅飞服为「是」  → "fly-center"
 *   仅监管为「是」  → "supervisor"
 *   两个都为「否」  → "error"
 *
 * ============================================================
 */

function main() {
  // 获取入参
  let isDeployFlyControl = "";
  let isDeploySupervisor = "";

  if (typeof Context !== "undefined" && Context.argv) {
    isDeployFlyControl = String(Context.argv.isDeployFlyControl || "").trim();
    isDeploySupervisor = String(Context.argv.isDeploySupervisor || "").trim();
  }

  console.log("入参 isDeployFlyControl: " + isDeployFlyControl);
  console.log("入参 isDeploySupervisor: " + isDeploySupervisor);

  // 判定类型
  let flyYes = (isDeployFlyControl === "是");
  let supYes = (isDeploySupervisor === "是");

  let type = "error";

  if (flyYes && supYes) {
    type = "both";
  } else if (flyYes) {
    type = "fly-center";
  } else if (supYes) {
    type = "supervisor";
  }

  // 输出结果
  let result = { code: type };
  console.log(JSON.stringify(result));

  return result;
}

main();
