var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/pro/Login2.0/shared/registerFlow.ts
var registerFlow_exports = {};
__export(registerFlow_exports, {
  REGISTER_FLOW_CONFIGS: () => REGISTER_FLOW_CONFIGS,
  RegisterStep: () => RegisterStep,
  STEP_DEFINITIONS: () => STEP_DEFINITIONS,
  STEP_TRANSITIONS: () => STEP_TRANSITIONS,
  VerificationMethod: () => VerificationMethod,
  determineVerificationMethod: () => determineVerificationMethod,
  getFlowConfig: () => getFlowConfig,
  getStepDefinition: () => getStepDefinition,
  isValidTransition: () => isValidTransition
});
module.exports = __toCommonJS(registerFlow_exports);
var RegisterStep = /* @__PURE__ */ ((RegisterStep2) => {
  RegisterStep2["INITIAL_FORM"] = "INITIAL_FORM";
  RegisterStep2["WAIT_EMAIL_LINK"] = "WAIT_EMAIL_LINK";
  RegisterStep2["INPUT_VERIFICATION_CODE"] = "INPUT_VERIFICATION_CODE";
  RegisterStep2["VERIFICATION_SUCCESS"] = "VERIFICATION_SUCCESS";
  RegisterStep2["SET_PASSWORD"] = "SET_PASSWORD";
  RegisterStep2["EMAIL_ALREADY_REGISTERED"] = "EMAIL_ALREADY_REGISTERED";
  RegisterStep2["COMPLETE"] = "COMPLETE";
  return RegisterStep2;
})(RegisterStep || {});
var VerificationMethod = /* @__PURE__ */ ((VerificationMethod2) => {
  VerificationMethod2["EMAIL_LINK"] = "EMAIL_LINK";
  VerificationMethod2["EMAIL_CODE"] = "EMAIL_CODE";
  VerificationMethod2["PHONE_CODE"] = "PHONE_CODE";
  VerificationMethod2["PASSWORD_ONLY"] = "PASSWORD_ONLY";
  return VerificationMethod2;
})(VerificationMethod || {});
var REGISTER_FLOW_CONFIGS = {
  ["EMAIL_LINK" /* EMAIL_LINK */]: {
    verificationMethod: "EMAIL_LINK" /* EMAIL_LINK */,
    requirePasswordAtStart: true
  },
  ["EMAIL_CODE" /* EMAIL_CODE */]: {
    verificationMethod: "EMAIL_CODE" /* EMAIL_CODE */,
    requirePasswordAtStart: false,
    autoTransition: {
      ["VERIFICATION_SUCCESS" /* VERIFICATION_SUCCESS */]: {
        delay: 1500,
        nextStep: "SET_PASSWORD" /* SET_PASSWORD */
      }
    }
  },
  ["PHONE_CODE" /* PHONE_CODE */]: {
    verificationMethod: "PHONE_CODE" /* PHONE_CODE */,
    requirePasswordAtStart: false,
    autoTransition: {
      ["VERIFICATION_SUCCESS" /* VERIFICATION_SUCCESS */]: {
        delay: 1500,
        nextStep: "SET_PASSWORD" /* SET_PASSWORD */
      }
    }
  },
  ["PASSWORD_ONLY" /* PASSWORD_ONLY */]: {
    verificationMethod: "PASSWORD_ONLY" /* PASSWORD_ONLY */,
    requirePasswordAtStart: true
  }
};
var STEP_TRANSITIONS = {
  // 邮件链接验证流程
  ["EMAIL_LINK" /* EMAIL_LINK */]: {
    ["INITIAL_FORM" /* INITIAL_FORM */]: ["WAIT_EMAIL_LINK" /* WAIT_EMAIL_LINK */, "EMAIL_ALREADY_REGISTERED" /* EMAIL_ALREADY_REGISTERED */],
    ["WAIT_EMAIL_LINK" /* WAIT_EMAIL_LINK */]: ["COMPLETE" /* COMPLETE */, "INITIAL_FORM" /* INITIAL_FORM */],
    ["EMAIL_ALREADY_REGISTERED" /* EMAIL_ALREADY_REGISTERED */]: ["INITIAL_FORM" /* INITIAL_FORM */],
    ["INPUT_VERIFICATION_CODE" /* INPUT_VERIFICATION_CODE */]: [],
    ["VERIFICATION_SUCCESS" /* VERIFICATION_SUCCESS */]: [],
    ["SET_PASSWORD" /* SET_PASSWORD */]: [],
    ["COMPLETE" /* COMPLETE */]: []
  },
  // 邮箱验证码验证流程
  ["EMAIL_CODE" /* EMAIL_CODE */]: {
    ["INITIAL_FORM" /* INITIAL_FORM */]: ["INPUT_VERIFICATION_CODE" /* INPUT_VERIFICATION_CODE */, "EMAIL_ALREADY_REGISTERED" /* EMAIL_ALREADY_REGISTERED */],
    ["INPUT_VERIFICATION_CODE" /* INPUT_VERIFICATION_CODE */]: [
      "VERIFICATION_SUCCESS" /* VERIFICATION_SUCCESS */,
      "INITIAL_FORM" /* INITIAL_FORM */
    ],
    ["VERIFICATION_SUCCESS" /* VERIFICATION_SUCCESS */]: ["SET_PASSWORD" /* SET_PASSWORD */],
    ["SET_PASSWORD" /* SET_PASSWORD */]: ["COMPLETE" /* COMPLETE */],
    ["EMAIL_ALREADY_REGISTERED" /* EMAIL_ALREADY_REGISTERED */]: ["INITIAL_FORM" /* INITIAL_FORM */],
    ["WAIT_EMAIL_LINK" /* WAIT_EMAIL_LINK */]: [],
    ["COMPLETE" /* COMPLETE */]: []
  },
  // 手机验证码验证流程
  ["PHONE_CODE" /* PHONE_CODE */]: {
    ["INITIAL_FORM" /* INITIAL_FORM */]: ["INPUT_VERIFICATION_CODE" /* INPUT_VERIFICATION_CODE */, "EMAIL_ALREADY_REGISTERED" /* EMAIL_ALREADY_REGISTERED */],
    ["INPUT_VERIFICATION_CODE" /* INPUT_VERIFICATION_CODE */]: [
      "VERIFICATION_SUCCESS" /* VERIFICATION_SUCCESS */,
      "INITIAL_FORM" /* INITIAL_FORM */
    ],
    ["VERIFICATION_SUCCESS" /* VERIFICATION_SUCCESS */]: ["SET_PASSWORD" /* SET_PASSWORD */],
    ["SET_PASSWORD" /* SET_PASSWORD */]: ["COMPLETE" /* COMPLETE */],
    ["EMAIL_ALREADY_REGISTERED" /* EMAIL_ALREADY_REGISTERED */]: ["INITIAL_FORM" /* INITIAL_FORM */],
    ["WAIT_EMAIL_LINK" /* WAIT_EMAIL_LINK */]: [],
    ["COMPLETE" /* COMPLETE */]: []
  },
  // 仅密码验证流程（无验证码）
  ["PASSWORD_ONLY" /* PASSWORD_ONLY */]: {
    ["INITIAL_FORM" /* INITIAL_FORM */]: ["COMPLETE" /* COMPLETE */, "EMAIL_ALREADY_REGISTERED" /* EMAIL_ALREADY_REGISTERED */],
    ["EMAIL_ALREADY_REGISTERED" /* EMAIL_ALREADY_REGISTERED */]: ["INITIAL_FORM" /* INITIAL_FORM */],
    ["INPUT_VERIFICATION_CODE" /* INPUT_VERIFICATION_CODE */]: [],
    ["VERIFICATION_SUCCESS" /* VERIFICATION_SUCCESS */]: [],
    ["SET_PASSWORD" /* SET_PASSWORD */]: [],
    ["WAIT_EMAIL_LINK" /* WAIT_EMAIL_LINK */]: [],
    ["COMPLETE" /* COMPLETE */]: []
  }
};
var STEP_DEFINITIONS = {
  ["INITIAL_FORM" /* INITIAL_FORM */]: {
    step: "INITIAL_FORM" /* INITIAL_FORM */,
    component: "form",
    config: {
      showBack: true,
      showClose: true,
      canEditAccount: true,
      showResend: false
    }
  },
  ["WAIT_EMAIL_LINK" /* WAIT_EMAIL_LINK */]: {
    step: "WAIT_EMAIL_LINK" /* WAIT_EMAIL_LINK */,
    component: "waiting",
    config: {
      showBack: true,
      showClose: true,
      canEditAccount: true,
      showResend: true
    }
  },
  ["INPUT_VERIFICATION_CODE" /* INPUT_VERIFICATION_CODE */]: {
    step: "INPUT_VERIFICATION_CODE" /* INPUT_VERIFICATION_CODE */,
    component: "code-input",
    config: {
      showBack: true,
      showClose: true,
      canEditAccount: false,
      showResend: true
    }
  },
  ["VERIFICATION_SUCCESS" /* VERIFICATION_SUCCESS */]: {
    step: "VERIFICATION_SUCCESS" /* VERIFICATION_SUCCESS */,
    component: "success",
    config: {
      showBack: false,
      showClose: false,
      canEditAccount: false,
      showResend: false
    }
  },
  ["SET_PASSWORD" /* SET_PASSWORD */]: {
    step: "SET_PASSWORD" /* SET_PASSWORD */,
    component: "password-set",
    config: {
      showBack: true,
      showClose: true,
      canEditAccount: false,
      showResend: false
    }
  },
  ["EMAIL_ALREADY_REGISTERED" /* EMAIL_ALREADY_REGISTERED */]: {
    step: "EMAIL_ALREADY_REGISTERED" /* EMAIL_ALREADY_REGISTERED */,
    component: "error",
    config: {
      showBack: true,
      showClose: true,
      canEditAccount: true,
      showResend: false
    }
  },
  ["COMPLETE" /* COMPLETE */]: {
    step: "COMPLETE" /* COMPLETE */,
    component: "success",
    config: {
      showBack: false,
      showClose: false,
      canEditAccount: false,
      showResend: false
    }
  }
};
function isValidTransition(verificationMethod, fromStep, toStep) {
  var _a;
  const validNextSteps = ((_a = STEP_TRANSITIONS[verificationMethod]) == null ? void 0 : _a[fromStep]) || [];
  return validNextSteps.includes(toStep);
}
function getStepDefinition(step) {
  return STEP_DEFINITIONS[step];
}
function getFlowConfig(verificationMethod) {
  return REGISTER_FLOW_CONFIGS[verificationMethod];
}
function determineVerificationMethod(accountType, emailConfig, phoneConfig) {
  if (accountType === "email") {
    if ((emailConfig == null ? void 0 : emailConfig.require_email_verification) !== false) {
      return "EMAIL_CODE" /* EMAIL_CODE */;
    }
    return "PASSWORD_ONLY" /* PASSWORD_ONLY */;
  } else {
    if ((phoneConfig == null ? void 0 : phoneConfig.require_phone_verification) !== false) {
      return "PHONE_CODE" /* PHONE_CODE */;
    }
    return "PASSWORD_ONLY" /* PASSWORD_ONLY */;
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  REGISTER_FLOW_CONFIGS,
  RegisterStep,
  STEP_DEFINITIONS,
  STEP_TRANSITIONS,
  VerificationMethod,
  determineVerificationMethod,
  getFlowConfig,
  getStepDefinition,
  isValidTransition
});
