UNPKG

@adyen/kyc-components

Version:

This guide assumes that you have already an account with Adyen. A legalEntity needs to be created, and you need to have a `legalEntityId` to instatiate a Component.

1,040 lines 113 kB
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] = "3e339332-317b-41e9-873b-9678dee86859", e._sentryDebugIdIdentifier = "sentry-dbid-3e339332-317b-41e9-873b-9678dee86859"); } catch (e) {} import { a as Icon, i as Typography, n as addResourceBundles, o as createLogger, r as useTranslation } from "./translation-BFxyJ1c5.js"; import { a as stylesheets, n as EmbedShell, r as useToggles, t as resolveEnvironment } from "./resolveEnvironment-CguBRdxx.js"; import { n as IconButton, r as Loader, t as Button } from "./Button-oj6H8OrC.js"; import { n as httpGet, r as httpPost, s as useApiContext } from "./http-D1NDkBxF.js"; import { r as useLegalEntity, t as ROOT_LE } from "./useLegalEntity-yxi9XhLi.js"; import { t as LegalEntityTypes } from "./legal-entity-type-VIfNYnJP.js"; import { t as getLegalEntityCountry } from "./getLegalEntityCountry-C6bSV6sB.js"; import { n as useLocalStorage, t as useAccountHolder } from "./useAccountHolder-ClppK4-L.js"; import { t as useSettingsContext } from "./useSettingsContext-DzwVt0W0.js"; import { c as objectsDeepEqual, s as noop, t as useAnalyticsContext } from "./useAnalyticsContext-BVFDMrVE.js"; import { t as useToggleContext } from "./useToggleContext-DaQUBF8O.js"; import { a as translateTranslatable } from "./utils-B807QaDx.js"; import { t as _rolldown_dynamic_import_helper_default } from "./_rolldown_dynamic_import_helper-rq_tsyLP.js"; import { t as StackLayout } from "./StackLayout-Bhbj68nx.js"; import { t as TaskVerificationStatus } from "./TaskVerificationStatus-kCWYhocq.js"; import { n as TASK_STATUS_POLLING_INTERVAL_MS, r as TaskStatuses, t as TASK_STATUS_COMPLETED_POLLING_INTERVAL_MS } from "./taskStatus-C7XU4UIF.js"; import { n as useSetting } from "./useAllowedCountries-x3yZO5Qw.js"; import { t as CountryCodes } from "./country-code-CX5KqMBr.js"; import { n as Skeleton } from "./Accordion-Btxq6sGi.js"; import { t as Alert } from "./Alert-C6gL3JIt.js"; import { a as getLegalRepresentative, c as getOwnSolePropProblems, f as hasSolePropInLegalEntity, p as TaskTypes } from "./entityAssociationUtil-BEzUdPbm.js"; import { c as getOwnUnincorporatedPartnershipProblems, d as isInstantVerifiedAccount, i as useGlobalStore, l as isPartOfUnincorporatedPartnership, o as hasAllCapabilitiesResolved, r as useGetTaskStatus, s as hasRejectedCapabilities, u as getObscuredAccountNumber } from "./globalStore-BjMds47R.js"; import { a as getOwnSignatories, i as getOwnDecisionMakersLegalEntityIds } from "./decisionMakerRoles-CAy-eeNV.js"; import { i as getOwnTrustProblems, o as isPartOfTrustFromLegalEntity } from "./trustUtil-BTHvlo55.js"; import { t as doesLegalEntityRequiresLegalRepresentative } from "./birthDateUtils-C686KOxO.js"; import { t as useBusinessLines } from "./useBusinessLines-CgnQUuie.js"; import { n as usePciQuestionnaireList, t as getPciQuestionnaireList } from "./usePciQuestionnaireList-44gPfAcR.js"; import { n as usePciStatus, t as useSalesChannels } from "./useSalesChannels-pzps3cvY.js"; import { n as getAccountTaskStatus, t as useTaskStatus } from "./useTaskStatus-PqBc0I7k.js"; import { n as useTermsOfServiceAcceptanceInfos, t as useTermsOfServiceStatus } from "./useTermsOfServiceStatus-YBxJYvyS.js"; import { t as Card } from "./Card-vYndix5Y.js"; import { t as SettingNames } from "./types-CNZsK2dZ.js"; import { t as useToastContext } from "./useToastContext-CYgfHjSb.js"; import { t as useCanSeeIntroduction } from "./useCanSeeIntroduction-ClAuT5gj.js"; import { t as CompanyTypesValues } from "./company-types-value-BYTAKfjo.js"; import { n as getDefaultAccountHolderType } from "./accountHolderUtils-BYe8xPFy.js"; import { t as useDataMissingRemediations } from "./useDataMissingRemediations-CARoFWDr.js"; import { t as EndStateLayout } from "./EndStateLayout-ChS-vdMt.js"; import { n as useCapabilityProblems } from "./getProblemsForEntity-BLcIg3x_.js"; import { t as downloadFile } from "./file-6a0FDVyq.js"; import { t as filterProblemsByTaskForms } from "./filterProblemsByTaskForms-DwS9T-_E.js"; import { t as useDeleteTransferInstrument } from "./useDeleteTransferInstrument-BwCQ-6Hm.js"; import { t as Avatar } from "./Avatar-CKmUpMXT.js"; import { t as LoaderWrapper } from "./LoaderWrapper-Dq8TNJCi.js"; import { t as VerificationErrorAlert } from "./VerificationErrorAlert-DR3lTJhB.js"; import { t as Confirm } from "./Confirm-B6TWSuab.js"; import { t as HandlerContext } from "./HandlerContext-CIedIvkP.js"; import { n as FeatureNames } from "./types-8S6KTD2W.js"; import { t as TrustedFieldsProviders } from "./trusted-fields-provider-BHbX2hsp.js"; import { r as getTrustedFieldsProvider } from "./getTrustedFields-UVTLadau.js"; import { t as useAssociatedLegalEntity } from "./useAssociatedLegalEntity-zrU8J6iw.js"; import { t as Image } from "./Image-BEzOZ1tt.js"; import { t as isNewEntity } from "./isNewEntity-4QusRCpP.js"; import { i as idNowPostSubmit, o as showIdNowModal, t as isBafinSignatoryFlow } from "./bafinUtils-kBPs58Au.js"; import { t as useTrustMembers } from "./useTrustMembers-NwUmFfVc.js"; import { t as UnincorporatedPartnershipMemberTypes } from "./unincorporated-partnership-5MvG_ts4.js"; import { A as UnincorporatedPartnershipMembersOverview$1, C as TrustMemberCompanyPage$1, D as UnincorporatedPartnershipIndividualPage$1, E as TrustMembersOverview$1, M as getDefaultTask$1, O as UnincorporatedPartnershipMemberCompanyPage$1, S as TrustDetailsPage$1, T as TrustMemberRoleAndTypePage$1, _ as SignPCIComponent$1, a as BusinessTypeSelectionPage$1, b as SourceOfFundsPage$1, c as DecisionMakers$1, d as PayoutDetailsPage$1, f as ROUTE_PATHS, g as RootIndividualDetailsPage$1, h as RootBusinessLinesPage$1, i as BusinessFinancingPage$1, j as detectBasePath, k as UnincorporatedPartnershipMemberRoleAndTypePage$1, l as Introduction$1, m as RootBusinessDetailsPage$1, n as AcceptTermsOfService$1, o as CustomerSupport$1, p as Review$1, r as AccountSetupRejected$1, s as DecisionMakerDetailsPage$1, t as useNavigate, u as LegalRepresentativeDetailsPage$1, v as SingpassSelection$1, w as TrustMemberIndividualPage$1, x as TaxReportingDropin$1, y as SoleProprietorshipPage$1 } from "./useNavigate-lR8Lcsrq.js"; import register from "preact-custom-element"; import { Suspense, lazy } from "preact/compat"; import { useCallback as useCallback$1, useContext as useContext$1, useEffect as useEffect$1, useMemo as useMemo$1, useReducer, useRef as useRef$1, useState as useState$1 } from "preact/hooks"; import cx from "classnames"; import { Fragment as Fragment$1, jsx, jsxs } from "preact/jsx-runtime"; import { skipToken, useQuery } from "@tanstack/preact-query"; import { createContext as createContext$1 } from "preact"; import { Route, Router, Switch, matchRoute, useLocation, useRouter } from "wouter-preact"; import { memoryLocation } from "wouter-preact/memory-location"; //#region src/api/configurations/useTaskTypes.ts /** * Determines based on legalEntity what tasks need to be shown to users * * @param id legalEntityId * @param options additional options passed to Tanstack Query, eg; refetchInterval for polling */ var getTaskTypes = async (id, baseUrl) => { return httpGet({ baseUrl, path: `legalEntities/${id}/configurations/tasks` }); }; var useTaskTypes = (options) => { const { rootLegalEntityId, baseUrl } = useApiContext(); return useQuery({ queryKey: ["taskTypes"], queryFn: () => getTaskTypes(rootLegalEntityId.value, baseUrl.value), ...options }); }; //#endregion //#region src/api/pci/usePciQuestionnaire.ts /** * Returns the details of a questionnaire, notably the content that * is used to generate the pdf in the frontend (to base64 blob, appending .pdf) */ var getPciQuestionnaire = async (legalEntityId, baseUrl, documentId) => { return httpGet({ baseUrl, path: `legalEntities/${legalEntityId}/pci/questionnaires/${documentId}` }); }; //#endregion //#region src/hooks/useBusinessSetup.ts var BusinessTypes = { INDIVIDUAL: "individual", COMPANY: "company", INCORPORATED_PARTNERSHIP: "partnershipIncorporated", UNINCORPORATED_PARTNERSHIP: "partnershipUnincorporated", INDIVIDUAL_TRUSTEE: "individualTrustee", COMPANY_TRUSTEE: "companyTrustee", SOLE_PROPRIETORSHIP: "soleProprietorship", INCORPORATE_ASSOCIATION: "associationIncorporated" }; var businessTypeMapping = { myName: { [LegalEntityTypes.INDIVIDUAL]: BusinessTypes.INDIVIDUAL }, theCompanyIWorkFor: { [LegalEntityTypes.ORGANIZATION]: BusinessTypes.COMPANY }, mySoleProprietorName: { [LegalEntityTypes.INDIVIDUAL]: BusinessTypes.SOLE_PROPRIETORSHIP }, aTrust: { [LegalEntityTypes.INDIVIDUAL]: BusinessTypes.INDIVIDUAL_TRUSTEE, [LegalEntityTypes.ORGANIZATION]: BusinessTypes.COMPANY_TRUSTEE }, anUnincorporatedPartnership: { [LegalEntityTypes.INDIVIDUAL]: BusinessTypes.UNINCORPORATED_PARTNERSHIP, [LegalEntityTypes.ORGANIZATION]: BusinessTypes.UNINCORPORATED_PARTNERSHIP } }; var companyTypesMapping = { [CompanyTypesValues.INCORPORATED_PARTNERSHIP]: BusinessTypes.INCORPORATED_PARTNERSHIP, [CompanyTypesValues.INCORPORATED_ASSOCIATION]: BusinessTypes.INCORPORATE_ASSOCIATION, [CompanyTypesValues.PUBLIC_COMPANY]: BusinessTypes.COMPANY, [CompanyTypesValues.PRIVATE_COMPANY]: BusinessTypes.COMPANY, [CompanyTypesValues.UNLISTED_PUBLIC_COMPANY]: BusinessTypes.COMPANY, [CompanyTypesValues.GOVERNMENTAL_ORGANIZATION]: BusinessTypes.COMPANY, [CompanyTypesValues.NON_PROFIT_OR_CHARITABLE]: BusinessTypes.COMPANY, [CompanyTypesValues.SOLE_PROPRIETORSHIP]: BusinessTypes.SOLE_PROPRIETORSHIP }; var useBusinessSetup = (legalEntityResponse) => { const { accountHolder } = useAccountHolder(); const accountHolderType = accountHolder || getDefaultAccountHolderType(legalEntityResponse); const organizationType = legalEntityResponse.organization?.type; return accountHolderType === "theCompanyIWorkFor" && organizationType ? companyTypesMapping[organizationType] : businessTypeMapping[accountHolderType]?.[legalEntityResponse.type]; }; //#endregion //#region src/components/Business/forms/BusinessDetails/form-ids.ts var businessFormIds = [ "basicInformation", "businessSelection", "companyStructure", "additionalInformation", "companyRegistrationDocument", "companyTaxDocument", "companyProofOfDirectorDocument", "companyProofOfSignatoryDocument", "companyProofOfOwnershipDocument", "companyFinancialInformation", "companyConstitutionalDocument" ]; //#endregion //#region src/components/Individual/forms/form-ids.ts var individualFormIds = [ "signatoryQuestionnaire", "uboQuestionnaire", "basicDetails", "idVerificationMethod", "inviteDetails", "additionalPersonalDetails", "manualIdUpload", "proofOfResidency", "proofOfNationalId", "proofOfRelationship" ]; //#endregion //#region src/components/Apps/tasks/TaskList/TaskListItem.tsx var TaskListItem = ({ titleKey, title, icon, status, onNavigateToTask, disabled = false, problems, downloadHandler, info, loading = false, showErrorAlerts = "onErrorStatus", warningMessage, deleteEntity, testId, enableTracking = true, fallbackErrorMessage }) => { const { t } = useTranslation("common"); const userEvents = useAnalyticsContext(); const [isConfirmShown, setIsConfirmShown] = useState$1(false); const isDeletable = !!deleteEntity; const isDownloadable = !!downloadHandler && status === TaskStatuses.DOWNLOAD; const shouldShowErrorAlert = showErrorAlerts === "always" || showErrorAlerts === "onErrorStatus" && status === TaskStatuses.ERROR || !!problems?.verificationErrors; const handleNavigateToTask = () => { if (enableTracking) userEvents.addJourneyEvent("Clicked button", { actionType: "open", task: void 0, label: titleKey }); onNavigateToTask?.(); }; const avatarVariant = disabled ? "disabled" : "primary"; const handleRemoveIntent = (event) => { event.stopPropagation(); setIsConfirmShown(true); }; const dismissConfirm = () => { setIsConfirmShown(false); }; const getTaskAccessory = () => { switch (status) { case TaskStatuses.SIGN: return t(($) => $["sign"]); case TaskStatuses.DETAILS_REQUIRED: case TaskStatuses.EMPTY: return t(($) => $["add"]); default: return /* @__PURE__ */ jsx(TaskVerificationStatus, { status }); } }; return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Card, { onClick: handleNavigateToTask, disabled: loading || disabled, children: /* @__PURE__ */ jsxs(LoaderWrapper, { status: loading ? "loading" : "success", formOpacityWhenLoading: .3, loaderSize: "medium", children: [ /* @__PURE__ */ jsxs("div", { className: "adyen-task-item", "data-testid": testId, children: [/* @__PURE__ */ jsxs("div", { className: "adyen-task-item__header", children: [/* @__PURE__ */ jsxs("div", { className: "adyen-task-item__heading", children: [/* @__PURE__ */ jsx(Avatar, { variant: avatarVariant, iconName: icon }), /* @__PURE__ */ jsx("div", { className: "adyen-task-item__body", children: /* @__PURE__ */ jsx("span", { className: "adyen-task-item__title", children: title || t(($) => $[titleKey]) }) })] }), info && /* @__PURE__ */ jsxs("div", { className: "adyen-task-item__info", children: [/* @__PURE__ */ jsx(Icon, { name: "info-circle" }), /* @__PURE__ */ jsx("span", { children: info })] })] }), /* @__PURE__ */ jsxs("aside", { className: "adyen-task-item__status", children: [ getTaskAccessory(), isDownloadable && /* @__PURE__ */ jsx(IconButton, { ariaLabel: t(($) => $["download"]), icon: "download", onClick: downloadHandler, variant: "tertiary" }), isDeletable && /* @__PURE__ */ jsx(IconButton, { ariaLabel: t(($) => $["delete"]), icon: "bin", variant: "tertiary", onClick: handleRemoveIntent, disabled: isConfirmShown }), !isDownloadable && !isDeletable && /* @__PURE__ */ jsx(Icon, { name: "chevron-right" }) ] })] }), warningMessage ? /* @__PURE__ */ jsx(Alert, { variant: "warning", title: warningMessage, className: "adyen-task-item__warning-message" }) : void 0, shouldShowErrorAlert && /* @__PURE__ */ jsx(VerificationErrorAlert, { className: "adyen-task-item-alert", problems, fallbackErrorMessage }) ] }) }), isConfirmShown && isDeletable && /* @__PURE__ */ jsx(Confirm, { title: t(($) => $["deleteItem"], { item: title }), description: t(($) => $["thisActionIsPermanent"]), onConfirm: deleteEntity, confirmText: t(($) => $["delete"]), onCancel: dismissConfirm, critical: true })] }); }; //#endregion //#region src/components/Apps/tasks/TaskList/PayoutAccountTaskListItem.tsx var PayoutAccountTaskListItem = ({ account, capabilityProblems, onNavigateToTask, payinPayoutTaskStatus }) => { const { t } = useTranslation("common"); const { showToast } = useToastContext(); const { isFeatureEnabled } = useToggleContext(); const userEvents = useAnalyticsContext(); const { mutateAsync: deleteTransferInstrument } = useDeleteTransferInstrument(); const isInstantVerificationAccount = isInstantVerifiedAccount(account); const obscuredAccountNumber = getObscuredAccountNumber(account); const getTaskStatus = useGetTaskStatus(); const status = isFeatureEnabled("UseTaskStatusApiForPayout") ? getAccountTaskStatus(account.id, payinPayoutTaskStatus) : getTaskStatus(TaskTypes.PAYOUT, account.id); const handleDeleteTransferInstrument = async () => { try { await deleteTransferInstrument(account.id); userEvents.addTaskEvent("Success", { actionType: "remove", returnType: "transferInstrument", returnValue: "transferInstrumentDeleteSuccess", additionalData: { isInstantVerificationAccount } }); showToast({ label: t(($) => $["transferInstrumentDeleted"]), variant: "success" }); } catch { showToast({ label: t(($) => $["failedToDeletePayoutAccount"]), variant: "error" }); } }; return /* @__PURE__ */ jsx(TaskListItem, { disabled: isInstantVerificationAccount && status === TaskStatuses.PROCESSING, onNavigateToTask: isInstantVerificationAccount ? void 0 : onNavigateToTask, icon: "payout", titleKey: "accountNumber", title: obscuredAccountNumber, status, problems: capabilityProblems?.BankAccount?.[account.id], fallbackErrorMessage: isInstantVerificationAccount ? t(($) => $["verificationErrorMessageTrustedTransferInstrument"]) : void 0, deleteEntity: handleDeleteTransferInstrument }); }; //#endregion //#region src/components/Apps/tasks/TaskList/TaskListGroup.tsx var TaskListGroup = ({ title, children }) => /* @__PURE__ */ jsxs("article", { className: "adyen-task-list-group", children: [title && /* @__PURE__ */ jsx("header", { className: "adyen-task-list-group__header", children: /* @__PURE__ */ jsx(Typography, { el: "h4", variant: "body-stronger", color: "secondary", children: title }) }), /* @__PURE__ */ jsx("div", { className: "adyen-kyc-card__body", children: /* @__PURE__ */ jsx(StackLayout, { gap: "xSmall", children }) })] }); //#endregion //#region src/components/Apps/tasks/TaskList/TaskList.tsx var LEGAL_ENTITY_BASE_TASKS = [ TaskTypes.INDIVIDUAL, TaskTypes.BUSINESS_DETAILS, TaskTypes.DECISION_MAKER_OVERVIEW ]; var CONTRACT_TASKS = [TaskTypes.SERVICE_AGREEMENT, TaskTypes.PCI_DSS]; function TaskList({ onNavigateToTask, singpassComponent }) { const { data: rootLe, isLoading } = useLegalEntity(ROOT_LE); const { t } = useTranslation("common"); const { data: existingBusinessLines, isLoading: isLoadingBl, error: businessLinesError } = useBusinessLines(["paymentProcessing"]); const capabilityProblems = useCapabilityProblems() ?? {}; if (isLoading || !rootLe || isLoadingBl) return /* @__PURE__ */ jsx(Loader, { size: "large" }); if (businessLinesError) return /* @__PURE__ */ jsx(EndStateLayout, { title: t(($) => $["thisPageIsntLoading"]), variant: "error", action: /* @__PURE__ */ jsx(Button, { onClick: () => window.location.reload(), fullWidth: true, children: t(($) => $["reloadPage"]) }) }); return /* @__PURE__ */ jsx(TaskListInner, { onNavigateToTask, singpassComponent, legalEntityResponse: rootLe, capabilityProblems, existingBusinessLines }); } function TaskListInner({ onNavigateToTask, legalEntityResponse, capabilityProblems, singpassComponent, existingBusinessLines }) { const userEvents = useAnalyticsContext(); const { t } = useTranslation("common"); const { showToast } = useToastContext(); const { rootLegalEntityId, baseUrl } = useApiContext(); const { isSettingEnabled } = useSettingsContext(); const { isFeatureEnabled } = useToggleContext(); const { accountHolder } = useAccountHolder(); const tasks = useGlobalStore().tasks.value; const getTaskStatus = useGetTaskStatus(); const businessSetup = useBusinessSetup(legalEntityResponse); const canSeeIntroduction = useCanSeeIntroduction({ legalEntity: legalEntityResponse }); const additionalSalesChannels = useSalesChannels(); const { remediationMessages } = useDataMissingRemediations({ legalEntityId: legalEntityResponse.id, problems: capabilityProblems }); const { data: pciStatus } = usePciStatus({ additionalSalesChannels }); const { data: pciQuestionnaireList } = usePciQuestionnaireList(); const { data: termsOfServiceStatus } = useTermsOfServiceStatus(); const { data: termsOfServiceStatusAcceptanceInfos } = useTermsOfServiceAcceptanceInfos(); const { data: normalizedTasks } = useTaskStatus({ refetchInterval: (query) => { const { data: response } = query.state || {}; const statuses = response?.statuses; return statuses?.length === 0 || statuses?.every((task) => task.status === "FINISHED") ? TASK_STATUS_COMPLETED_POLLING_INTERVAL_MS : TASK_STATUS_POLLING_INTERVAL_MS; } }); const canChangeEntityType = isSettingEnabled(SettingNames.AllowLegalEntityTypeChange); const hidePayoutAccountTaskToggled = isFeatureEnabled("HidePayoutAccountTask"); const showCustomerSupportV4 = isFeatureEnabled("ShowCustomerSupportV4"); const transferInstrumentLimit = useSetting("transferInstrumentLimit"); const payinPayoutTaskStatus = normalizedTasks?.PAYOUT ?? normalizedTasks?.PAYIN; const businessDetailsTaskStatus = normalizedTasks?.BUSINESS_DETAILS?.status ?? TaskStatuses.DETAILS_REQUIRED; const businessLinesTaskStatus = normalizedTasks?.ACQUIRING_BUSINESS_LINE?.status ?? TaskStatuses.DETAILS_REQUIRED; const rootLegalEntityProblems = capabilityProblems?.LegalEntity?.[legalEntityResponse.id]; const isReview = Boolean(rootLegalEntityProblems?.isReviewRequired); const hasTrust = accountHolder === "aTrust" || isPartOfTrustFromLegalEntity(legalEntityResponse); const hasUnincorporatedPartnership = accountHolder === "anUnincorporatedPartnership" || isPartOfUnincorporatedPartnership(legalEntityResponse); const hasSoleProprietorship = accountHolder === "mySoleProprietorName" || hasSolePropInLegalEntity(legalEntityResponse); const isLegalRepresentativeRequired = isFeatureEnabled("EnableAgeVerification") && doesLegalEntityRequiresLegalRepresentative(legalEntityResponse); const legalRepresentative = isLegalRepresentativeRequired && getLegalRepresentative(legalEntityResponse); const transferInstruments = legalEntityResponse?.transferInstruments || []; const canAddPayoutAccount = legalEntityResponse?.organization?.legalName || legalEntityResponse?.individual?.name; const hasPayinTaskNotPayout = tasks.includes(TaskTypes.PAYIN) && !tasks.includes(TaskTypes.PAYOUT); const payoutTaskDescriptionKey = isReview ? "payoutAccountsDescriptionReview" : "payoutAccountsDescription"; const pciHasDocuments = !!pciQuestionnaireList?.data?.length; const canDownloadPci = !pciStatus?.signingRequired && pciHasDocuments; const hasCreatedBusinessLines = !!existingBusinessLines?.length; const hasPciSigners = !!legalEntityResponse?.entityAssociations?.length; const pciIsActionable = pciStatus?.signingRequired || canDownloadPci; const serviceAgreementTypes = termsOfServiceStatus?.termsOfServiceTypes ?? []; const serviceAgreementAcceptanceInfos = termsOfServiceStatusAcceptanceInfos?.data ?? []; const hasServiceAgreementSigners = legalEntityResponse.type === LegalEntityTypes.ORGANIZATION && getOwnSignatories(legalEntityResponse).length || Boolean(legalRepresentative) || legalEntityResponse.type === LegalEntityTypes.INDIVIDUAL && !!legalEntityResponse?.individual; const hasTaskOfGroupAccountDetails = tasks.some((task) => LEGAL_ENTITY_BASE_TASKS.includes(task)); const hasContractTasks = tasks.some((task) => CONTRACT_TASKS.includes(task)); const hasFinancingTasks = tasks.includes(TaskTypes.BUSINESS_FINANCING) || tasks.includes(TaskTypes.SOURCE_OF_FUNDS); const showServiceAgreementTask = tasks.includes(TaskTypes.SERVICE_AGREEMENT) && (serviceAgreementTypes.length > 0 || serviceAgreementAcceptanceInfos.length > 0); const showPciTask = isSettingEnabled("allowBusinessLines") ? tasks.includes("PCI_DSS") : tasks.includes("PCI_DSS") && pciIsActionable; const shouldSignPciFirst = showServiceAgreementTask && showPciTask && !pciHasDocuments; const pciTaskState = (() => { if (!hasPciSigners) return { disabled: true, infoMessage: t(($) => $["requiresDecisionMakers"]) }; if (isSettingEnabled("allowBusinessLines") && !hasCreatedBusinessLines) return { disabled: true, infoMessage: t(($) => $["requiresBusinessLine"]) }; return { disabled: !pciStatus?.signingRequired, infoMessage: void 0 }; })(); const serviceAgreementTaskState = (() => { if (isSettingEnabled("allowBusinessLines") && shouldSignPciFirst) return { disabled: true, infoMessage: t(($) => $["signPciFirst"]) }; if (!hasServiceAgreementSigners) return { disabled: true, infoMessage: t(($) => $["requiresSignatory"]) }; return { disabled: false, infoMessage: void 0 }; })(); const getBusinessTaskListTitleKey = () => { if (hasUnincorporatedPartnership) return "tellUsMoreAboutPrimaryPartner"; else if (tasks.includes(TaskTypes.BUSINESS_DETAILS)) return isReview ? "businessAccountDetailsDescriptionReview" : "businessAccountDetailsDescription"; else if (canChangeEntityType) return "provideFewDetailsAboutYourself"; else return "accountDetailsDescription"; }; const getEmptyBankAccountProblems = () => { const transferInstrumentId = legalEntityResponse?.transferInstruments?.[0]?.id; return transferInstrumentId ? capabilityProblems?.BankAccount?.[transferInstrumentId] : void 0; }; const onEditBusinessSetupClick = () => { userEvents.addTaskEvent("Clicked button", { task: TaskTypes.TASKS_OVERVIEW, actionType: "edit" }); onNavigateToTask(TaskTypes.BUSINESS_TYPE_SELECTION); }; const onPciDownload = async () => { try { const response = await getPciQuestionnaireList(rootLegalEntityId.value, baseUrl.value); if (!response.data) return; await Promise.all(response.data.map(async (pciQuestionnaireInfo) => { const pciQuestionnaire = await getPciQuestionnaire(rootLegalEntityId.value, baseUrl.value, pciQuestionnaireInfo.id); await downloadFile(pciQuestionnaire.content, `${pciQuestionnaire.id}.pdf`); })); } catch { showToast({ label: t(($) => $["failedToDownloadPci"]), variant: "error" }); } finally { userEvents.addTaskEvent("Clicked button", { task: TaskTypes.PCI_DSS, actionType: "download" }); } }; const handleOnNavigateToTaskReview = () => onNavigateToTask(TaskTypes.REVIEW); const handleOnNavigateToTaskIndividual = () => onNavigateToTask(TaskTypes.INDIVIDUAL); const handleOnNavigateToTaskBusinessDetails = () => onNavigateToTask(TaskTypes.BUSINESS_DETAILS); const handleOnNavigateToTaskBusinessLines = () => onNavigateToTask(TaskTypes.ACQUIRING_BUSINESS_LINE); const handleOnNavigateToTaskCustomerSupport = () => onNavigateToTask(TaskTypes.CUSTOMER_SUPPORT); const handleOnNavigateToTaskDecisionMaker = () => onNavigateToTask(TaskTypes.DECISION_MAKER_OVERVIEW); const handleOnNavigateToTaskTrust = () => onNavigateToTask(TaskTypes.TRUST); const handleOnNavigateToTaskTrustMember = () => onNavigateToTask(TaskTypes.TRUST_MEMBER_OVERVIEW); const handleOnNavigateToTaskPayout = (id) => hasPayinTaskNotPayout ? onNavigateToTask(TaskTypes.PAYIN, id) : onNavigateToTask(TaskTypes.PAYOUT, id); const handleOnNavigateToPci = () => !canDownloadPci && onNavigateToTask(TaskTypes.PCI_DSS); const handleOnNavigateToSoleProp = () => onNavigateToTask(TaskTypes.SOLE_PROPRIETOR_COMPANY); const handleOnNavigateToServiceAgreement = () => onNavigateToTask(TaskTypes.SERVICE_AGREEMENT); const handleOnNavigateToTaskLegalRepresentative = () => onNavigateToTask(TaskTypes.LEGAL_REPRESENTATIVE_DETAILS); const handleOnNavigateToSourceOfFunds = () => onNavigateToTask(TaskTypes.SOURCE_OF_FUNDS); const handleOnNavigateToBusinessFinancing = () => onNavigateToTask(TaskTypes.BUSINESS_FINANCING); const handleOnNavigateToTaxReporting = () => onNavigateToTask(TaskTypes.TAX_REPORTING); const fullIndividualFormIds = [...individualFormIds]; const showDecisionMakersWarning = Boolean(getOwnDecisionMakersLegalEntityIds(legalEntityResponse).length && remediationMessages.DECISION_MAKER); useEffect$1(() => { if (showDecisionMakersWarning) userEvents.addTaskEvent("Encountered error", { task: TaskTypes.TASKS_OVERVIEW, actionType: "alert", returnValue: "missingDecisionMaker" }); }, [showDecisionMakersWarning, userEvents]); return /* @__PURE__ */ jsxs("div", { className: "adyen-task-list__container", children: [ canSeeIntroduction && /* @__PURE__ */ jsx("div", { className: "adyen-task-list__nav", children: /* @__PURE__ */ jsx(Button, { variant: "link", onClick: () => onNavigateToTask(TaskTypes.INTRODUCTION), children: t(($) => $["goToIntroduction"]) }) }), canChangeEntityType && /* @__PURE__ */ jsxs("header", { className: "adyen-task-list__heading", children: [/* @__PURE__ */ jsx(Typography, { el: "h1", variant: "title-l", children: t(($) => $["setUpYourAccount"]) }), /* @__PURE__ */ jsxs(Typography, { el: "p", variant: "title", className: "adyen-task-list__description", children: [/* @__PURE__ */ jsx(Typography, { el: "span", variant: "body-strongest", children: t(($) => $["yourBusinessSetup"], { businessSetup: businessSetup ? t(($) => $[businessSetup]) : t(($) => $["unknown"]) }) }), /* @__PURE__ */ jsx(IconButton, { ariaLabel: t(($) => $["editBusinessSetup"]), icon: "edit", variant: "tertiary", onClick: onEditBusinessSetupClick })] })] }), singpassComponent, /* @__PURE__ */ jsxs(StackLayout, { children: [ hasTaskOfGroupAccountDetails && /* @__PURE__ */ jsxs(TaskListGroup, { title: t(($) => $[getBusinessTaskListTitleKey()]), children: [ tasks.includes(TaskTypes.INDIVIDUAL) && /* @__PURE__ */ jsx(TaskListItem, { onNavigateToTask: handleOnNavigateToTaskIndividual, icon: "decision-maker", titleKey: hasTrust ? "trusteePersonalDetails" : hasUnincorporatedPartnership ? "primaryPartnerDetails" : "personalDetails", status: getTaskStatus(TaskTypes.INDIVIDUAL), problems: filterProblemsByTaskForms(rootLegalEntityProblems, fullIndividualFormIds) }), tasks.includes(TaskTypes.BUSINESS_DETAILS) && /* @__PURE__ */ jsx(TaskListItem, { testId: TaskTypes.BUSINESS_DETAILS, onNavigateToTask: handleOnNavigateToTaskBusinessDetails, icon: "company", titleKey: hasTrust ? "businessTrusteeDetails" : hasUnincorporatedPartnership ? "primaryPartnerDetails" : "businessDetails", status: businessDetailsTaskStatus, problems: filterProblemsByTaskForms(rootLegalEntityProblems, businessFormIds) }), hasSoleProprietorship && /* @__PURE__ */ jsx(TaskListItem, { onNavigateToTask: handleOnNavigateToSoleProp, icon: "company", titleKey: canChangeEntityType ? "soleProprietorshipDetails" : "soleProprietorDetails", status: getTaskStatus(TaskTypes.SOLE_PROPRIETOR_COMPANY), problems: getOwnSolePropProblems(legalEntityResponse, capabilityProblems) }), isLegalRepresentativeRequired && /* @__PURE__ */ jsx(TaskListItem, { onNavigateToTask: handleOnNavigateToTaskLegalRepresentative, icon: "decision-maker", titleKey: "legalRepresentative", status: getTaskStatus(TaskTypes.LEGAL_REPRESENTATIVE_DETAILS) }), tasks.includes(TaskTypes.DECISION_MAKER_OVERVIEW) && /* @__PURE__ */ jsx(TaskListItem, { onNavigateToTask: handleOnNavigateToTaskDecisionMaker, icon: "decision-maker", titleKey: hasUnincorporatedPartnership ? "entityDecisionMakers" : "decisionMakers", status: getTaskStatus(TaskTypes.DECISION_MAKER_OVERVIEW), warningMessage: showDecisionMakersWarning ? remediationMessages[TaskTypes.DECISION_MAKER] : void 0 }), tasks.includes(TaskTypes.ACQUIRING_BUSINESS_LINE) && /* @__PURE__ */ jsx(TaskListItem, { testId: TaskTypes.ACQUIRING_BUSINESS_LINE, onNavigateToTask: handleOnNavigateToTaskBusinessLines, icon: "solutionPayments", titleKey: "businessLines", status: businessLinesTaskStatus }), showCustomerSupportV4 && tasks.includes(TaskTypes.CUSTOMER_SUPPORT) && /* @__PURE__ */ jsx(TaskListItem, { onNavigateToTask: handleOnNavigateToTaskCustomerSupport, icon: "webinar", titleKey: "customerSupport", status: normalizedTasks?.CUSTOMER_SUPPORT?.status ?? TaskStatuses.DETAILS_REQUIRED, problems: filterProblemsByTaskForms(rootLegalEntityProblems, ["customerSupport"]) }) ] }), hasTrust && /* @__PURE__ */ jsxs(TaskListGroup, { title: t(($) => $["trustDetailsDescription"]), children: [/* @__PURE__ */ jsx(TaskListItem, { onNavigateToTask: handleOnNavigateToTaskTrust, icon: "trust", titleKey: "trustDetails", status: getTaskStatus(TaskTypes.TRUST), problems: getOwnTrustProblems(legalEntityResponse, capabilityProblems) }), /* @__PURE__ */ jsx(TaskListItem, { onNavigateToTask: handleOnNavigateToTaskTrustMember, icon: "decision-maker", titleKey: "trustMembers", status: getTaskStatus(TaskTypes.TRUST_MEMBER_OVERVIEW) })] }), hasUnincorporatedPartnership && /* @__PURE__ */ jsxs(TaskListGroup, { title: t(($) => $["partnershipUnincorporated"]), children: [/* @__PURE__ */ jsx(TaskListItem, { onNavigateToTask: () => onNavigateToTask(TaskTypes.UNINCORPORATED_PARTNERSHIP), icon: "trust", titleKey: "unincorporatedDetails", status: getTaskStatus(TaskTypes.UNINCORPORATED_PARTNERSHIP), problems: getOwnUnincorporatedPartnershipProblems(legalEntityResponse, capabilityProblems) }), /* @__PURE__ */ jsx(TaskListItem, { onNavigateToTask: () => { if (!isPartOfUnincorporatedPartnership(legalEntityResponse)) onNavigateToTask(TaskTypes.UNINCORPORATED_PARTNERSHIP); else onNavigateToTask(TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_OVERVIEW); }, icon: "decision-maker", titleKey: "unincorporatedPartnershipMembers", status: getTaskStatus(TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_OVERVIEW) })] }), hasFinancingTasks && /* @__PURE__ */ jsxs(TaskListGroup, { children: [tasks.includes(TaskTypes.SOURCE_OF_FUNDS) && /* @__PURE__ */ jsx(TaskListItem, { onNavigateToTask: handleOnNavigateToSourceOfFunds, icon: "cash-stack", titleKey: "fundingSources", status: normalizedTasks?.SOURCE_OF_FUNDS?.status ?? TaskStatuses.DETAILS_REQUIRED }), tasks.includes(TaskTypes.BUSINESS_FINANCING) && /* @__PURE__ */ jsx(TaskListItem, { onNavigateToTask: handleOnNavigateToBusinessFinancing, icon: "capital", titleKey: "businessFinancing", status: normalizedTasks?.BUSINESS_FINANCING?.status ?? TaskStatuses.DETAILS_REQUIRED })] }), tasks.includes(TaskTypes.TAX_REPORTING) && /* @__PURE__ */ jsx(TaskListGroup, { children: /* @__PURE__ */ jsx(TaskListItem, { onNavigateToTask: handleOnNavigateToTaxReporting, icon: "reporting", titleKey: "taxReporting", status: normalizedTasks?.TAX_REPORTING?.status ?? TaskStatuses.DETAILS_REQUIRED }) }), (tasks.includes(TaskTypes.PAYOUT) || tasks.includes(TaskTypes.PAYIN)) && !hidePayoutAccountTaskToggled && /* @__PURE__ */ jsx(TaskListGroup, { title: canChangeEntityType ? t(($) => $["payoutBankAccounts"]) : t(($) => $[hasPayinTaskNotPayout ? "payinAccountsDescription" : payoutTaskDescriptionKey]), children: transferInstruments.length > 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [transferInstruments.map((transferInstrument) => /* @__PURE__ */ jsx(PayoutAccountTaskListItem, { account: transferInstrument, capabilityProblems, onNavigateToTask: () => handleOnNavigateToTaskPayout(transferInstrument.id), payinPayoutTaskStatus }, transferInstrument.id)), !transferInstrumentLimit || transferInstruments.length < transferInstrumentLimit ? /* @__PURE__ */ jsxs(Card, { onClick: () => handleOnNavigateToTaskPayout(), disabled: !canAddPayoutAccount, children: [/* @__PURE__ */ jsx(Icon, { name: "plus", className: "adyen-task-list__card-icon " }), /* @__PURE__ */ jsx("span", { children: canChangeEntityType ? t(($) => $["addExtraBankAccount"]) : t(($) => $[hasPayinTaskNotPayout ? "addExtraPayinAccount" : "addExtraPayoutAccount"]) })] }) : null] }) : /* @__PURE__ */ jsx(TaskListItem, { onNavigateToTask: () => handleOnNavigateToTaskPayout(), icon: "payout", titleKey: canChangeEntityType ? "bankAccountDetails" : hasPayinTaskNotPayout ? "payinDetails" : "payoutDetails", status: TaskStatuses.DETAILS_REQUIRED, disabled: !canAddPayoutAccount, problems: getEmptyBankAccountProblems() }) }), hasContractTasks && /* @__PURE__ */ jsxs(TaskListGroup, { title: t(($) => $["reviewAndSignLegalDisclosures"]), children: [showPciTask && /* @__PURE__ */ jsx(TaskListItem, { onNavigateToTask: handleOnNavigateToPci, icon: "pci", titleKey: "pciDssQuestionnaire", status: canDownloadPci ? TaskStatuses.DOWNLOAD : TaskStatuses.SIGN, info: pciTaskState.infoMessage, downloadHandler: onPciDownload, disabled: pciTaskState.disabled }), showServiceAgreementTask && /* @__PURE__ */ jsx(TaskListItem, { onNavigateToTask: handleOnNavigateToServiceAgreement, icon: "contract", titleKey: "signServiceAgreement", disabled: serviceAgreementTaskState.disabled, status: serviceAgreementTypes.length ? TaskStatuses.SIGN : TaskStatuses.SIGNED, info: serviceAgreementTaskState.infoMessage })] }), isReview && /* @__PURE__ */ jsx(TaskListGroup, { title: t(($) => $["pleaseEnsureTheFollowing"]), children: /* @__PURE__ */ jsx(TaskListItem, { onNavigateToTask: handleOnNavigateToTaskReview, icon: "review", titleKey: "submitReviewOfYourData", status: TaskStatuses.SUBMIT, problems: rootLegalEntityProblems, showErrorAlerts: "always" }) }) ] }) ] }); } //#endregion //#region src/context/handlerContext/HandlerProvider.tsx function HandlerProvider({ children, onNavigateToTask }) { return /* @__PURE__ */ jsx(HandlerContext.Provider, { value: { onNavigateToTask }, children }); } //#endregion //#region src/hooks/introduction/useHasSeenIntroduction.ts var getHasSeenIntroductionStorageKey = (legalEntityId) => `COMPLETED_INTRO-${legalEntityId}`; var useHasSeenIntroduction = ({ legalEntityId }) => { const [hasSeenIntroduction, setHasSeenIntroduction] = useLocalStorage(getHasSeenIntroductionStorageKey(legalEntityId), false); return { hasSeenIntroduction, setHasSeenIntroduction }; }; //#endregion //#region src/hooks/singpass/useHasSeenSingpassSelection.ts var getHasSeenSingpassSelectionStorageKey = (legalEntityId) => `COMPLETED_SINGPASS_SELECTION-${legalEntityId}`; var useHasSeenSingpassSelection = ({ legalEntityId }) => { const [hasSeenSingpassSelection, setHasSeenSingpassSelection] = useLocalStorage(getHasSeenSingpassSelectionStorageKey(legalEntityId), false); return { hasSeenSingpassSelection, setHasSeenSingpassSelection }; }; //#endregion //#region src/api/openId/useOpenIdAuthorizationLink.ts async function convertToSingpassLinkResponse(openIdInitiateResponse) { return { item: { authUrl: (await Promise.resolve(openIdInitiateResponse)).authUrl, success: true } }; } var useOpenIdAuthorizationLink = (options) => { const { rootLegalEntityId, baseUrl } = useApiContext(); return useQuery({ queryKey: ["openIdAuthorizationLink"], queryFn: () => getOpenIdAuthorizationLink(rootLegalEntityId.value, baseUrl.value), ...options }); }; var getOpenIdAuthorizationLink = async (legalEntityId, baseUrl) => { return convertToSingpassLinkResponse(httpPost({ baseUrl, path: `/legalEntities/${legalEntityId}/openid/initiate` })); }; //#endregion //#region src/hooks/singpass/useSingpassMyInfoLogin.ts var SingpassMyInfoLoginActionTypes = { LOADING: "LOADING", SUCCESS: "SUCCESS", FAILURE: "FAILURE", RESET: "RESET" }; var defaultSingpassState = { isLoading: false, isSuccess: false }; var singpassReducer = (state, action) => { switch (action.type) { case SingpassMyInfoLoginActionTypes.LOADING: return { ...state, isLoading: true }; case SingpassMyInfoLoginActionTypes.SUCCESS: return { isLoading: false, isSuccess: true }; case SingpassMyInfoLoginActionTypes.FAILURE: return { isLoading: false, isSuccess: false, errorMessage: action.errorMessage }; case SingpassMyInfoLoginActionTypes.RESET: return defaultSingpassState; default: return state; } }; var useSingpassMyInfoLogin = ({ legalEntity, accountHolder }) => { const [state, dispatch] = useReducer(singpassReducer, { isLoading: false, isSuccess: getTrustedFieldsProvider(legalEntity) === TrustedFieldsProviders.SINGPASS }); const { refetch: fetchOpenIdAuthorizationLink } = useOpenIdAuthorizationLink({ enabled: false }); const isEligibleForSingpass = useMemo$1(() => { if (!legalEntity) return false; if (getLegalEntityCountry(legalEntity) !== CountryCodes.Singapore) return false; if (accountHolder) return accountHolder === "theCompanyIWorkFor" || accountHolder === "myName"; const legalEntityType = legalEntity.type; const isPartOfTrust = isPartOfTrustFromLegalEntity(legalEntity); const isVanillaOrganization = legalEntityType === LegalEntityTypes.ORGANIZATION && !isPartOfTrust; const hasSoleProprietor = hasSolePropInLegalEntity(legalEntity); const isVanillaIndividual = legalEntityType === LegalEntityTypes.INDIVIDUAL && !hasSoleProprietor; return isVanillaOrganization || isVanillaIndividual; }, [legalEntity, accountHolder]); const handleInitiateSingpassMyInfoLogin = async () => { dispatch({ ...state, type: SingpassMyInfoLoginActionTypes.LOADING }); const { data } = await fetchOpenIdAuthorizationLink(); return data?.item.authUrl; }; const handleSingpassMyInfoLoginSuccess = () => { dispatch({ ...state, type: SingpassMyInfoLoginActionTypes.SUCCESS }); }; const handleSingpassMyInfoLoginFailure = (errorMessage) => { dispatch({ ...state, errorMessage, type: SingpassMyInfoLoginActionTypes.FAILURE }); }; const handleSingpassMyInfoLoginReset = () => { dispatch({ ...state, type: SingpassMyInfoLoginActionTypes.RESET }); }; return { isEligibleForSingpass, state, handleInitiateSingpassMyInfoLogin, handleSingpassMyInfoLoginSuccess, handleSingpassMyInfoLoginFailure, handleSingpassMyInfoLoginReset }; }; //#endregion //#region src/hooks/useAssociatedLegalRepresentative.ts var useAssociatedLegalRepresentative = (legalEntity) => { const matchingAssociation = useMemo$1(() => { return getLegalRepresentative(legalEntity); }, [legalEntity]); const { data } = useLegalEntity(doesLegalEntityRequiresLegalRepresentative(legalEntity) && matchingAssociation?.legalEntityId ? matchingAssociation.legalEntityId : skipToken); return data; }; //#endregion //#region src/hooks/useCanSeeEntitySelection.ts var getCanSeeEntitySelectionStorageKey = (legalEntityId) => `ENTITY_SELECTION_SEEN-${legalEntityId}`; var useCanSeeEntitySelection = (legalEntityId) => { const [canSeeEntitySelectionFromLocalStorage, setCanSeeEntitySelectionIntoLocalStorage] = useLocalStorage(getCanSeeEntitySelectionStorageKey(legalEntityId), true); return { canSeeEntitySelection: canSeeEntitySelectionFromLocalStorage, setCanSeeEntitySelection: setCanSeeEntitySelectionIntoLocalStorage }; }; var SingpassBanner_module_default = { "provider-button": "adyen-kyc-provider-button", providerButton: "adyen-kyc-provider-button" }; //#endregion //#region src/components/Shared/SingpassBanner/SingpassBanner.tsx var singpassLogo = lazy(() => import("./singpass-logo-small-BcAlrN2f.js")); var legalEntityTypeToSubtitleTranslationKey = { [LegalEntityTypes.INDIVIDUAL]: "myInfoYouCanGetVerifiedDetails", [LegalEntityTypes.ORGANIZATION]: "myInfoBusinessYouCanGetVerifiedDetails" }; var legalEntityTypeToButtonLabelKey = { [LegalEntityTypes.INDIVIDUAL]: "retrieveMyinfo", [LegalEntityTypes.ORGANIZATION]: "retrieveMyinfoBusiness" }; var successAlertTitleText = { [LegalEntityTypes.INDIVIDUAL]: "myinfoDetailsRetrieved", [LegalEntityTypes.ORGANIZATION]: "myinfoBusinessDetailsRetrieved" }; var successAlertContentText = { [LegalEntityTypes.INDIVIDUAL]: "yourDetailsArePreFilledInTheRelevantSections", [LegalEntityTypes.ORGANIZATION]: "yourBusinesssDetailsArePreFilledInTheRelevantSections" }; var SingpassBanner = ({ isLoading, isSuccess, errorMessage, onClick, onAlertClose, onMessage, legalEntityType }) => { const { t } = useTranslation("common"); const { t: tUi } = useTranslation("ui"); const { baseUrl, rootLegalEntityId } = useApiContext(); const singpassEventListener = useCallback$1((event) => { if (event.origin !== new URL(baseUrl.value).origin) return; if (event.data.legalEntityReference !== rootLegalEntityId.value) return; onMessage({ data: { isSuccessful: event.data.isSuccessful } }); }, [ baseUrl.value, rootLegalEntityId.value, onMessage ]); useEffect$1(() => { window.addEventListener("message", singpassEventListener); return () => window.removeEventListener("message", singpassEventListener); }, [singpassEventListener]); if (isLoading) return /* @__PURE__ */ jsx(Skeleton, {}); if (isSuccess) { const successTitleText = successAlertTitleText[legalEntityType]; const successContentText = successAlertContentText[legalEntityType]; return /* @__PURE__ */ jsx(Alert, { variant: "success", title: successTitleText && t(($) => $[successTitleText]), onClose: onAlertClose, children: successContentText && t(($) => $[successContentText]) }); } const buttonLabelKey = legalEntityTypeToButtonLabelKey[legalEntityType]; const singpassButton = buttonLabelKey && /* @__PURE__ */ jsx(Button, { onClick, fullWidth: true, variant: "secondary", children: /* @__PURE__ */ jsxs("div", { className: SingpassBanner_module_default.providerButton, children: [tUi(($) => $[buttonLabelKey]), /* @__PURE__ */ jsx(Image, { lazyLoadedImage: singpassLogo })] }) }); if (errorMessage) return /* @__PURE__ */ jsx(Alert, { variant: "warning", title: translateTranslatable(t, errorMessage), onClose: onAlertClose, children: /* @__PURE__ */ jsxs(Typography, { variant: "body", children: [t(($) => $["tryAgainOrContinueEnteringTheDetailsYourself"]), singpassButton] }) }); const subtitleTranslationKey = legalEntityTypeToSubtitleTranslationKey[legalEntityType]; return /* @__PURE__ */ jsxs(Alert, { className: cx("adyen-task-list-singpass-banner"), icon: false, title: t(($) => $["getSetUpInstantly"]), children: [subtitleTranslationKey && /* @__PURE__ */ jsx("div", { className: cx("adyen-task-list-singpass-banner__subtitle"), children: t(($) => $[subtitleTranslationKey]) }), singpassButton] }); }; //#endregion //#region src/components/Trust/hooks/useTrustMemberNavigation.hook.ts var useTrustMemberNavigation = ({ navigateTo, trust }) => { const { t } = useTranslation("trust"); const { showToast } = useToastContext(); const [trustMember, setTrustMember] = useState$1(); const { setTrustMembers } = useGlobalStore(); const trustMembers = useTrustMembers(); const memberId = trustMember?.trustMemberType === "undefinedBeneficiary" ? trustMember.reference : trustMember?.legalEntityId; useEffect$1(() => setTrustMembers(trustMembers), [trustMembers]); const onNavigateToTrustMemberEditDetails = async (tm) => { try { if (tm.legalEntityId === isNewEntity) setTrustMember(tm); const id = tm.legalEntityId === isNewEntity ? void 0 : tm.legalEntityId; navigateTo(tm.trustMemberType === "company" ? TaskTypes.TRUST_MEMBER_COMPANY : TaskTypes.TRUST_MEMBER_INDIVIDUAL, id ? { memberId: id } : void 0); } catch { showToast({ label: t(($) => $["failedToFetchTrustMemberDetails"]), variant: "error" }); } }; const onNavigateToTrustMemberRoleAndType = (tm) => { setTrustMember(tm === "new" ? void 0 : tm); let id; if (tm !== "new") { if (tm.trustMemberType === "undefinedBeneficiary") id = tm.reference !== isNewEntity ? tm.reference : void 0; else if (tm.legalEntityId !== isNewEntity) id = tm.legalEntityId; } navigateTo(TaskTypes.TRUST_MEMBER_ROLE_AND_TYPE, id ? { memberId: id } : void 0); }; const onNavigateToTrust = async (task = TaskTypes.TRUST) => { try { if (trust) navigateTo(task); else navigateTo(TaskTypes.TRUST); } catch { showToast({ label: t(($) => $["failedToFetchTrustDetails"]), variant: "error" }); } }; return { trustMember, trustMemberId: memberId === isNewEntity ? void 0 : memberId, trustMembers, onNavigateToTrust, onNavigateToTrustMemberRoleAndType, onNavigateToTrustMemberEditDetails }; }; //#endregion //#region src/components/UnincorporatedPartnership/hooks/useUnincorporatedPartnershipNavigation.ts var createDefaultMember = (selectedMember, selectedEntityType, selectedRoles) => { const firstRole = selectedRoles?.[0]; return { memberType: selectedMember?.memberType || firstRole, roles: selectedRoles || selectedMember?.roles || [UnincorporatedPartnershipMemberTypes.SECONDARY_PARTNER], legalEntityType: selectedEntityType, legalEntityId: selectedMember?.legalEntityId || "", name: selectedMember?.name || "" }; }; var useUnincorporatedPartnershipNavigation = ({ navigateTo }) => { const [activeMember, setActiveMember] = useState$1(); const { rootLegalEntityId } = useApiContext(); const onNavigateToMember = async ({ selectedMember, selectedRoles, selectedEntityType, roleAndType }) => { const createdMember = createDefaultMember(selectedMember, selectedEntityType, selectedRoles); setActiveMember(createdMember); if (rootLegalEntityId.value === createdMember?.legalEntityId) { navigateTo(createdMember.legalEntityType === LegalEntityTypes.INDIVIDUAL ? TaskTypes.INDIVIDUAL : TaskTypes.BUSINESS_DETAILS); return; } const memberParams = createdMember.legalEntityId ? { memberId: createdMember.legalEntityId } : void 0; if (roleAndType) { navigateTo(TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_ROLE_AND_TYPE, memberParams); return; } navigateTo(createdMember?.legalEntityType === LegalEntityTypes.ORGANIZATION ? TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY : TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_INDIVIDUAL, memberParams); }; return { onNavigateToMember, activeMember, setActiveMember }; }; //#endregion //#region src/router/MemoryRouterContext.tsx var MemoryRouterContext = createContext$1(null); var useMemoryRouter = () => useContext$1(MemoryRouterCon