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,038 lines 110 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] = "c3962387-9bf6-475d-aec5-95a5d7e3e1b4", e._sentryDebugIdIdentifier = "sentry-dbid-c3962387-9bf6-475d-aec5-95a5d7e3e1b4"); } catch (e) {} import { a as Icon, i as Typography, n as addResourceBundles, o as createLogger, r as useTranslation } from "./translation-BYvhW5zA.js"; import { A as _rolldown_dynamic_import_helper_default, F as useToggles, N as FeatureNames, O as useSetting, _ as isPartOfTrustFromLegalEntity, a as doesLegalEntityRequiresLegalRepresentative, b as isInstantVerifiedAccount, d as hasRejectedCapabilities, ft as useAccountHolder, g as getOwnTrustProblems, i as useGlobalStore, j as useToggleContext, m as isPartOfUnincorporatedPartnership, mt as stylesheets, n as EmbedShell, p as getOwnUnincorporatedPartnershipProblems, pt as useLocalStorage, r as useGetTaskStatus, t as resolveEnvironment, u as hasAllCapabilitiesResolved, x as Alert, y as getObscuredAccountNumber } from "./resolveEnvironment-DNmu53Rr.js"; import { n as IconButton, r as Loader, t as Button } from "./Button-i8I2dHP8.js"; import { n as httpGet, r as httpPost, s as useApiContext } from "./http-8qgzqVqk.js"; import { r as useLegalEntity, t as ROOT_LE } from "./useLegalEntity-CtlUQv_J.js"; import { t as LegalEntityTypes } from "./legal-entity-type-0MfCGzUf.js"; import { t as getLegalEntityCountry } from "./getLegalEntityCountry-BHh7Ux8v.js"; import { t as useSettingsContext } from "./useSettingsContext-Bpf4UqRT.js"; import { a as noop, o as objectsDeepEqual } from "./AnalyticsContext-BFrJmsp0.js"; import { t as StackLayout } from "./StackLayout-IUdNMDgW.js"; import { i as TaskStatuses, n as TASK_STATUS_POLLING_INTERVAL_MS, t as TASK_STATUS_COMPLETED_POLLING_INTERVAL_MS } from "./taskStatus-BtekPA8E.js"; import { t as CountryCodes } from "./country-code-CJk2hdPu.js"; import { n as Skeleton } from "./Accordion-IXKjwyLD.js"; import { t as TaskTypes } from "./taskTypes-NawDTp5n.js"; import { a as getLegalRepresentative, c as getOwnSolePropProblems, f as hasSolePropInLegalEntity } from "./entityAssociationUtil-C-wflW8q.js"; import { a as getOwnSignatories, i as getOwnDecisionMakersLegalEntityIds } from "./decisionMakerRoles-DIG8zo1C.js"; import { n as canShowAdaptivePoc, t as TaskListItem } from "./TaskListItem-DYISbC7G.js"; import { t as useBusinessLines } from "./useBusinessLines-BFsRoAAj.js"; import { n as usePciQuestionnaireList, t as getPciQuestionnaireList } from "./usePciQuestionnaireList-CbkNC_Ye.js"; import { n as usePciStatus, t as useSalesChannels } from "./useSalesChannels-DW5ilTS0.js"; import { n as useTermsOfServiceAcceptanceInfos, t as useTermsOfServiceStatus } from "./useTermsOfServiceStatus-D1_ECrkO.js"; import { t as Card } from "./Card-BCGLpdw7.js"; import { i as useAnalyticsContext } from "./Modal-BLP2aF-u.js"; import { t as SettingNames } from "./types-Cwq1JAWT.js"; import { n as useToastContext } from "./invalidateRootLegalEntity-DLpPeD5p.js"; import { t as useCanSeeIntroduction } from "./useCanSeeIntroduction-DeC5D9Io.js"; import { a as idNowPostSubmit, c as CompanyTypesValues, n as isBafinSignatoryFlow, s as showIdNowModal } from "./bafinUtils-BKq-s1Ka.js"; import { n as getDefaultAccountHolderType } from "./accountHolderUtils-BqC40MeW.js"; import { t as useDataMissingRemediations } from "./useDataMissingRemediations-QYShC4SG.js"; import { t as EndStateLayout } from "./EndStateLayout-CBRHUXyY.js"; import { n as useCapabilityProblems } from "./getProblemsForEntity-D6XC4DZ2.js"; import { t as downloadFile } from "./file-1IenVoh8.js"; import { t as filterProblemsByTaskForms } from "./filterProblemsByTaskForms-CQby20PN.js"; import { n as useDeleteTransferInstrument } from "./VerificationErrorAlert-B_RKlfIG.js"; import { n as translateTranslatable } from "./utils-C1buyvRw.js"; import { t as HandlerContext } from "./HandlerContext-DeMa68z0.js"; import { t as TrustedFieldsProviders } from "./trusted-fields-provider-DLz8KKVf.js"; import { r as getTrustedFieldsProvider } from "./getTrustedFields-BJ88GlM-.js"; import { t as useAssociatedLegalEntity } from "./useAssociatedLegalEntity-CkuvFV-D.js"; import { n as Image, t as UnincorporatedPartnershipMemberTypes } from "./unincorporated-partnership-nnTW3FnG.js"; import { t as isNewEntity } from "./isNewEntity-vML86iIM.js"; import { t as useTrustMembers } from "./useTrustMembers-BIdqkIX1.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-i7J4ofUG.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/api/taskStatus/useTaskStatuses.ts var getTaskStatuses = async (legalEntityId, baseUrl) => { return httpGet({ baseUrl, path: `legalEntities/${legalEntityId}/taskStatus` }); }; /** * @param options additional options passed to Tanstack Query, eg; refetchInterval for polling */ var useTaskStatuses = (options) => { const { rootLegalEntityId, baseUrl } = useApiContext(); return useQuery({ queryKey: ["taskStatus"], queryFn: () => getTaskStatuses(rootLegalEntityId.value, baseUrl.value), select: makeTaskStatusMap, ...options }); }; var makeTaskStatusMap = (data) => data.statuses.reduce((acc, item) => ({ [item.type]: item, ...acc }), {}); //#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", "companyProofOfAddressDocument", "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/utils.ts var logger$2 = createLogger(); var getAccountTaskStatus = (accountId, payinPayoutTaskStatus) => { const taskStatusEntry = (payinPayoutTaskStatus?.taskStatusEntries)?.find((entry) => entry.id.includes(accountId)); if (!taskStatusEntry) { logger$2.warn(`No task status for this account: ${accountId}`); if (!payinPayoutTaskStatus?.status) return TaskStatuses.PROCESSING; return TaskStatuses[payinPayoutTaskStatus.status]; } return TaskStatuses[taskStatusEntry.status]; }; //#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: taskStatuses } = useTaskStatuses({ 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 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: taskStatuses?.BUSINESS_DETAILS?.status ?? TaskStatuses.UNKNOWN, 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: taskStatuses?.ACQUIRING_BUSINESS_LINE?.status ?? TaskStatuses.UNKNOWN }), showCustomerSupportV4 && tasks.includes(TaskTypes.CUSTOMER_SUPPORT) && /* @__PURE__ */ jsx(TaskListItem, { onNavigateToTask: handleOnNavigateToTaskCustomerSupport, icon: "webinar", titleKey: "customerSupport", status: taskStatuses?.CUSTOMER_SUPPORT?.status ?? TaskStatuses.UNKNOWN, 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: taskStatuses?.SOURCE_OF_FUNDS?.status ?? TaskStatuses.UNKNOWN }), tasks.includes(TaskTypes.BUSINESS_FINANCING) && /* @__PURE__ */ jsx(TaskListItem, { onNavigateToTask: handleOnNavigateToBusinessFinancing, icon: "capital", titleKey: "businessFinancing", status: taskStatuses?.BUSINESS_FINANCING?.status ?? TaskStatuses.UNKNOWN })] }), tasks.includes(TaskTypes.TAX_REPORTING) && /* @__PURE__ */ jsx(TaskListGroup, { children: /* @__PURE__ */ jsx(TaskListItem, { onNavigateToTask: handleOnNavigateToTaxReporting, icon: "reporting", titleKey: "taxReporting", status: taskStatuses?.TAX_REPORTING?.status ?? TaskStatuses.UNKNOWN }) }), (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: taskStatuses?.PAYOUT ?? taskStatuses?.PAYIN }, 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": "_provider-button_126ab_1", providerButton: "_provider-button_126ab_1" }; //#endregion //#region src/components/Shared/SingpassBanner/SingpassBanner.tsx var singpassLogo = lazy(() => import("./singpass-logo-small-Dj6yeaQx.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, i18n } = useTranslation("singpassBanner"); const { t: tUi } = useTranslation("ui"); const { t: commonT } = useTranslation("common"); addResourceBundles(i18n, [{ ns: "singpassBanner", importFn: (lang) => _rolldown_dynamic_import_helper_default(/* @__PURE__ */ Object.assign({ "./language/en-US.json": () => import("./en-US-CKZZNUWW.js") }), `./language/${lang}.json`, 3) }]); 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(commonT, 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(MemoryRouterContext); //#endregion //#region src/hooks/introduction/useShouldShowIntroduction.ts var useShouldShowIntroduction = ({ legalEntity }) => { const canSeeIntroduction = useCanSeeIntroduction({ legalEntity }); const { hasSeenIntroduction } = useHasSeenIntroduction({ legalEntityId: legalEntity.id }); return canSeeIntroduction && !hasSeenIntroduction; }; //#endregion //#region src/router/DefaultRouteRedirect.tsx function DefaultRouteRedirect({ legalEntity, children }) { const navigate = useNavigate(); const { isSettingEnabled } = useSettingsContext(); const { accountHolder } = useAccountHolder(); const { canSeeEntitySelection } = useCanSeeEntitySelection(legalEntity.id); const { hasSeenSingpassSelection } = useHasSeenSingpassSelection({ legalEntityId: legalEntity.id }); const { isEligibleForSingpass } = useSingpassMyInfoLogin({ legalEntity, accountHolder }); const showIntroduction = useShouldShowIntroduction({ legalEntity }); const showServiceAgreementsFirst = isSettingEnabled(SettingNames.ShowServiceAgreementsFirst); const showBusinessFinancingFirst = isSettingEnabled(SettingNames.ShowBusinessFinancingFirst); const canChangeEntityType = isSettingEnabled(SettingNames.AllowLegalEntityTypeChange); const shouldShowSingpassSelection = isEligibleForSingpass && !hasSeenSingpassSelection; const defaultTask = useMemo$1(() => getDefaultTask$1({ legalEntity, canSeeEntitySelection, canChangeEntityType, showIntroduction, shouldShowSingpassSelection, showServiceAgreementsFirst, showBusinessFinancingFirst }), [ legalEntity, canSeeEntitySelection, canChangeEntityType, showIntroduction, shouldShowSingpassSelection, showServiceAgreementsFirst, showBusinessFinancingFirst ]); const shouldRenderInline = defaultTask === TaskTypes.TASKS_OVERVIEW && !!children; useEffect$1(() => { if (shouldRenderInline) return; navigate.replace(defaultTask); }, [ defaultTask, navigate, shouldRenderInline ]); if (shouldRenderInline) return /* @__PURE__ */ jsx(Fragment$1, { children }); return /* @__PURE__ */ jsx(Loader, {}); } //#endregion //#region src/router/SuspenseRoute.tsx function SuspenseRoute({ path, children }) { return /* @__PURE__ */ jsx(Route, { path, children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Loader, {}), children }) }); } //#endregion //#region src/router/OnboardingRouter.tsx function OnboardingRouter({ legalEntity, rootLegalEntityCountry, trust, unincorporatedPartnership, soleProp, associatedLegalRepresentative, refetchLegalEntity, refetchTrust, refetchUnincorporatedPartnership, onExternalSubmit, accountHolder, setAccountHolder, setCanSeeEntitySelection, setHasSeenIntroduction, taskTypes, targetLegalEntityType, setTargetLegalEntityType, trustMember, onNavigateToTrust, onNavigateToTrustMemberRoleAndType, onNavigateToTrustMemberEditDetails, unincorporatedPartnershipMember, setActiveMember, onNavigateToMember, singpassBanner, handleSingpassSelectionNextClick, openBankingPartnerConfigId }) { const navigate = useNavigate(); const userEvents = useAnalyticsContext(); const handleOnSubmit = async (data, backStepCount) => { onExternalSubmit?.(data); await refetchLegalEntity(); navigate.back(backStepCount); }; const onNavigateToDecisionMakerIndividual = (task, decisionMakerId, parentId) => { navigate.to(task, { parentId: parentId ?? legalEntity