
/**
 *   VERSION: 2.240.0-alpha.1
 *   BUILD_TIMESTAMP: 1780360168537
 *   BUILD_DATE: Tue Jun 02 2026 00:29:28 GMT+0000 (Coordinated Universal Time)
 *   BUILD_COMMIT: 758cedd37e00f49a728d704d9ed36884f0f12d79
 */
import { i as g, j as e, F as o, R as u, w as p, M as E, n as R, l as V, V as w, X as I } from "../sheerid.js";
import { I as k } from "./InputText-D8Ob-kQk.js";
const y = ({
  onChange: i,
  value: s,
  isErrored: t,
  errorId: d,
  intl: c,
  placeholder: n = ""
}) => {
  const m = (r) => {
    switch (r) {
      case "invalidSMSCode":
        return /* @__PURE__ */ e.jsx(
          o,
          {
            id: "step.smsLoop.errors.codeVerification",
            defaultMessage: "Verification code could not be validated."
          }
        );
      case "expiredSMSCode":
        return /* @__PURE__ */ e.jsx(
          o,
          {
            id: "step.smsLoop.errors.codeExpired",
            defaultMessage: "Verification code expired."
          }
        );
      default:
        return /* @__PURE__ */ e.jsx(o, { id: "errorId.unknownError", defaultMessage: "Unknown Error" });
    }
  };
  return /* @__PURE__ */ e.jsxs("div", { className: "sid-field sid-sms-code-id", children: [
    /* @__PURE__ */ e.jsx("div", { className: "sid-l-space-top-md" }),
    t ? /* @__PURE__ */ e.jsx("div", { className: "sid-field-error", children: m(d) }) : null,
    /* @__PURE__ */ e.jsx(
      k,
      {
        id: "sms-code",
        isErrored: t,
        required: !0,
        placeholder: n || c.formatHTMLMessage({ id: "smsCodePlaceholder", defaultMessage: "SMS Code" }),
        value: s,
        onChange: (r) => i(r.target.value)
      }
    )
  ] });
}, v = g(y), T = ({ intl: i, verificationService: s }) => {
  const t = s.viewModel, d = s.verificationResponse, c = !!s.fieldValidationErrors.smsCode, n = s.previousViewModel || void 0, [m, r] = u.useState(""), [M, f] = u.useState(
    d.errorIds && d.errorIds.includes("incorrectSMSCodeAttemptLimitExceeded")
  ), h = i.formatHTMLMessage({
    id: "step.smsLoop.successResend",
    defaultMessage: "SMS message re-sent successfully"
  }), x = i.formatHTMLMessage({
    id: "step.smsLoop.errors.codeResendLimit",
    defaultMessage: "Maximum number of re-tries has been reached."
  }), S = i.formatHTMLMessage({
    id: "step.smsLoop.errors.codeResendLimit",
    defaultMessage: "Maximum number of re-tries has been reached."
  }), j = i.formatHTMLMessage({
    id: "step.smsLoop.errors.resend",
    defaultMessage: "Error sending the SMS message"
  });
  u.useEffect(() => {
    M && r(S);
  }, []), p(() => d.errorIds.length) && !s.fieldValidationErrors.smsCode && s.updateFieldValidationErrors({
    ...s.fieldValidationErrors,
    smsCode: d.errorIds[0]
  });
  const C = (a) => {
    const l = R(t, (b) => {
      b.smsCode = a, b.phoneNumber = n && n.phoneNumber;
    });
    s.updateViewModel(l);
  }, L = () => {
    V.info("StepSMSLoop submitting form"), s.submitStep(
      w.smsLoop,
      t,
      s.verificationResponse
    );
  }, N = async (a) => {
    const l = await I.getResendNewSmsCode(a);
    l ? (f(!1), r(l.status === 204 ? h : x)) : r(j);
  };
  return /* @__PURE__ */ e.jsxs("div", { id: "sid-step-sms-loop", className: "sid-sms-loop-container sid-l-container", children: [
    /* @__PURE__ */ e.jsx(E, { align: "center", children: /* @__PURE__ */ e.jsx(
      o,
      {
        id: "step.smsLoop.verificationCode",
        defaultMessage: "Verification Code",
        tagName: "h1"
      }
    ) }),
    /* @__PURE__ */ e.jsx("div", { className: "sid-header__subtitle", children: p(() => n.phoneNumber) ? /* @__PURE__ */ e.jsx(
      o,
      {
        id: "step.smsLoop.titleWithNumber",
        defaultMessage: "We've sent an SMS message to the mobile number ending in {number}. Enter your code here.",
        values: {
          number: p(() => n.phoneNumber.slice(-4), "")
        }
      }
    ) : /* @__PURE__ */ e.jsx(
      o,
      {
        id: "step.smsLoop.titleWithoutNumber",
        defaultMessage: "We've sent an SMS to your mobile number. Please enter the code here."
      }
    ) }),
    /* @__PURE__ */ e.jsx("div", { className: "sid-sms-code-id-wrapper sid-l-horz-center", children: /* @__PURE__ */ e.jsx(
      v,
      {
        onChange: C,
        value: t.smsCode,
        isErrored: c,
        errorId: s.fieldValidationErrors.smsCode
      }
    ) }),
    m && /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsx("p", { children: m }) }),
    /* @__PURE__ */ e.jsxs("div", { className: "sid-submit sid-sms-loop-submit sid-l-space-top-md sid-l-horz-center", children: [
      /* @__PURE__ */ e.jsx(
        "button",
        {
          id: "sid-submit-sms-code",
          onClick: L,
          type: "button",
          className: "sid-btn sid-sms-loop-submit-btn sid-btn--dark sid-submit__continue",
          "aria-label": "submit",
          disabled: !!(!t.smsCode || t.smsCode.length <= 0 || M),
          children: /* @__PURE__ */ e.jsx(o, { id: "step.smsLoop.submitButton", defaultMessage: "Submit" })
        }
      ),
      /* @__PURE__ */ e.jsx("div", { className: "sid-l-space-left-sm", children: " " }),
      /* @__PURE__ */ e.jsx(
        "button",
        {
          id: "sid-resend-sms-code",
          onClick: () => N(d.verificationId),
          type: "submit",
          className: "sid-btn sid-resend-sms-code-btn sid-btn--light sid-submit__cancel",
          "aria-label": "re-send",
          children: /* @__PURE__ */ e.jsx(o, { id: "step.smsLoop.resendButton", defaultMessage: "Re-send" })
        }
      )
    ] }),
    /* @__PURE__ */ e.jsxs("div", { className: "sid-incorrect-number sid-l-horz-center", children: [
      /* @__PURE__ */ e.jsx(
        o,
        {
          id: "step.smsLoop.incorrectNumber.incorrectNumber1",
          defaultMessage: "Incorrect number? Click"
        }
      ),
      " ",
      /* @__PURE__ */ e.jsxs(
        "button",
        {
          type: "button",
          onClick: () => window.location.reload(),
          className: "sid-incorrect-number__refresh-link sid-h-btn-link-like",
          children: [
            /* @__PURE__ */ e.jsx(
              o,
              {
                id: "step.smsLoop.incorrectNumber.incorrectNumber2",
                defaultMessage: "here"
              }
            ),
            " "
          ]
        }
      ),
      /* @__PURE__ */ e.jsx(o, { id: "companyName", defaultMessage: "{Company}", children: (a) => /* @__PURE__ */ e.jsx(
        o,
        {
          id: "step.smsLoop.incorrectNumber.incorrectNumber3",
          defaultMessage: "to return to {companyName}",
          values: { companyName: a }
        }
      ) })
    ] })
  ] });
}, A = g(T);
export {
  A as default
};
