;
{
  try {
    let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
    n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "d6fe1583-4e23-4fab-9202-7861204ba69b", e._sentryDebugIdIdentifier = "sentry-dbid-d6fe1583-4e23-4fab-9202-7861204ba69b");
  } catch (e) {
  }
}
;
import { jsx, jsxs } from "preact/jsx-runtime";
import { lazy } from "preact/compat";
import { useState } from "preact/hooks";
import { u as useTranslation, z as Typography, V as Button, o as LegalEntityTypes } from "./StoreProvider-CqQrndhS.js";
import { F as Field } from "./Field-BL3Mh7gm.js";
import { I as Image } from "./Image-C0SMWMbc.js";
import { R as RadioGroupCard } from "./RadioGroupCard-lHRSs1iT.js";
import { u as useForm } from "./useForm-BFLyeF0c.js";
const setupAccountMethods = ["singpass", "manual"];
const setupAccountMethodFields = ["setupAccountMethod"];
const singpassLogo = lazy(() => import("./singpass-logo-wY4xsmTX.js"));
const instantVerificationImage = lazy(
  () => import("./singpass-verification-instant-JCqTr7Mv.js")
);
const manualVerificationImage = lazy(
  () => import("./singpass-verification-manual-DQ7XW6R3.js")
);
const getSingpassSelectionDisabled = (legalEntityType) => {
  switch (legalEntityType) {
    case LegalEntityTypes.INDIVIDUAL:
    case LegalEntityTypes.ORGANIZATION:
      return false;
    default:
      return true;
  }
};
const legalEntityTypeToSelectionTranslationKeyMap = {
  [LegalEntityTypes.INDIVIDUAL]: "retrieveMyInfo",
  [LegalEntityTypes.ORGANIZATION]: "retrieveMyInfoBusiness"
};
const legalEntityTypeToSelectionDescriptionTranslationKeyMap = {
  [LegalEntityTypes.INDIVIDUAL]: "getYourVerifiedDetailsInstantly",
  [LegalEntityTypes.ORGANIZATION]: "getYourBusinessVerifiedDetails"
};
const getSetupAccountMethodMetadata = (legalEntityType, commonT) => {
  const translationSingpassNameKey = legalEntityTypeToSelectionTranslationKeyMap[legalEntityType] ?? "retrieveMyInfoBusiness";
  const translationSingpassDescriptionKey = legalEntityTypeToSelectionDescriptionTranslationKeyMap[legalEntityType] ?? "getYourBusinessVerifiedDetails";
  const isSingpassSelectionDisabled = getSingpassSelectionDisabled(legalEntityType);
  return {
    singpass: {
      name: commonT(($) => $[translationSingpassNameKey]),
      description: commonT(($) => $[translationSingpassDescriptionKey]),
      icon: /* @__PURE__ */ jsx(
        Image,
        {
          lazyLoadedImage: instantVerificationImage,
          className: "adyen-kyc-setup-singpass-container"
        }
      ),
      provider: {
        name: "singpass",
        icon: /* @__PURE__ */ jsx(Image, { lazyLoadedImage: singpassLogo, className: "adyen-kyc-singpass-logo-container" })
      },
      isOptionDisabled: isSingpassSelectionDisabled
    },
    manual: {
      name: commonT(($) => $["enterTheDetailsYourself"]),
      description: commonT(($) => $["youAlsoHaveToUploadSomeSupportingDocuments"]),
      icon: /* @__PURE__ */ jsx(
        Image,
        {
          lazyLoadedImage: manualVerificationImage,
          className: "adyen-kyc-singpass-logo-container"
        }
      )
    }
  };
};
const SingpassSelection = (props) => {
  const { t } = useTranslation("common");
  const { legalEntityType, handleNextClick } = props;
  const [selectedMethod, setSelectedMethod] = useState();
  const selectSetupAccountMethod = (method) => {
    setSelectedMethod(method);
    handleChangeFor("setupAccountMethod")(method);
  };
  const { handleChangeFor, data } = useForm({
    ...props,
    schema: setupAccountMethodFields,
    defaultData: {}
  });
  const methodsMetadata = getSetupAccountMethodMetadata(legalEntityType, t);
  return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-singpass-selection", children: [
    /* @__PURE__ */ jsx("header", { className: "adyen-kyc-u-margin-bottom-32", children: /* @__PURE__ */ jsx(Typography, { el: "h2", variant: "title-m", children: t(($) => $["howWouldYouLikeToSetUpYourAccount"]) }) }),
    /* @__PURE__ */ jsx("form", { children: /* @__PURE__ */ jsx(Field, { el: "fieldset", name: "setupAccountMethod", children: (childProps) => /* @__PURE__ */ jsx(
      RadioGroupCard,
      {
        ...childProps,
        name: "setupAccountMethod",
        options: setupAccountMethods,
        onSelect: selectSetupAccountMethod,
        selected: data.setupAccountMethod,
        optionId: (method) => method,
        optionName: (method) => methodsMetadata[method].name,
        optionDescription: (method) => methodsMetadata[method].description,
        className: "adyen-kyc-field-verification-methods",
        optionClassNames: () => ({
          icon: "adyen-kyc-radio-group-card__illustration",
          label: "adyen-kyc-field-verification-methods__card",
          footer: "adyen-kyc-field-verification-methods__footer"
        }),
        renderOptionIcon: (method) => methodsMetadata[method].icon,
        renderOptionFooter: (method) => methodsMetadata[method].provider?.icon,
        floatingRadio: true
      }
    ) }) }),
    /* @__PURE__ */ jsx(
      Button,
      {
        disabled: !selectedMethod,
        onClick: () => {
          if (!selectedMethod) return;
          handleNextClick(selectedMethod);
        },
        fullWidth: true,
        children: t(($) => $["continue"])
      }
    )
  ] }) });
};
export {
  SingpassSelection
};
