@tesouro/embedded-components-react 0.5.36 → 0.5.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +14 -14
  2. package/dist/index.d.ts +41 -3
  3. package/dist/index.js +5 -5
  4. package/dist/lib/BankAccountOnboardingWidget.d.ts +41 -3
  5. package/dist/lib/BankAccountOnboardingWidget.js +5 -5
  6. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index.js +1 -1
  7. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index10.js +184 -109
  8. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index11.js +29 -174
  9. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index12.js +117 -67
  10. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index13.js +137 -44
  11. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index14.js +77 -107
  12. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index15.js +84 -87
  13. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index16.js +116 -88
  14. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index17.js +99 -5
  15. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index18.js +100 -28
  16. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index19.js +5 -5
  17. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index20.js +26 -383
  18. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index21.js +19 -0
  19. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index22.js +407 -0
  20. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index6.js +2 -10
  21. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index7.js +22 -6
  22. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index8.js +11 -182
  23. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index9.js +8 -29
  24. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index.js +12 -12
  25. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index10.js +27 -26
  26. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index11.js +34 -91
  27. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index12.js +96 -12
  28. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index13.js +14 -2
  29. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index14.js +0 -2
  30. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index15.js +4 -175
  31. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index16.js +180 -28
  32. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index17.js +31 -21
  33. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index18.js +21 -65
  34. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index19.js +60 -215
  35. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index20.js +230 -29
  36. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index21.js +32 -26
  37. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index22.js +26 -71
  38. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index23.js +71 -82
  39. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index24.js +87 -0
  40. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index3.js +38 -28
  41. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index4.js +2 -46
  42. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index5.js +48 -139
  43. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index6.js +138 -48
  44. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index7.js +47 -26
  45. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index8.js +32 -33
  46. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index9.js +31 -38
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +20 -8
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +1 -0
  49. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  50. package/package.json +1 -1
@@ -2,120 +2,90 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { bankAccountOnboardingTestIds as e } from "./index9.js";
6
- import { ADDITIONAL_OWNERS_LABELS_EN as t } from "../../ui/dist/index4.js";
7
- import { AdditionalOwnersForm as n } from "../../ui/dist/index5.js";
5
+ import { isIdentifierEnteredOrStored as e } from "./index7.js";
6
+ import { bankAccountOnboardingTestIds as t } from "./index11.js";
7
+ import { AboutYouPanel as n } from "../../ui/dist/index23.js";
8
8
  import "../../ui/dist/index.js";
9
- import { isAtLeastMinOwnerAge as r } from "./index7.js";
10
- import { EMPTY_ADDITIONAL_OWNER as i, buildAdditionalOwnerEditDisplay as a, buildAdditionalOwnerEditFields as o, normalizeAdditionalOwnerDraft as s } from "./index13.js";
11
- import { useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
12
- import { jsx as f } from "react/jsx-runtime";
13
- import { z as p } from "zod";
9
+ import { getMaxBirthDate as r, isAtLeastMinOwnerAge as i } from "./index9.js";
10
+ import { buildAboutYouEditFields as a, buildAboutYouPanelLabels as o, buildAboutYouSummaryRows as s, buildSsnDisplayValues as c, mergePersonalDetailsLabels as l } from "./index13.js";
11
+ import { useEffect as u, useMemo as d, useRef as f, useState as p } from "react";
12
+ import { jsx as m } from "react/jsx-runtime";
13
+ import { z as h } from "zod";
14
14
  //#region ../../libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index14.js
15
- function m(e) {
16
- return p.object({
17
- id: p.string().optional(),
18
- firstName: p.string().min(1),
19
- lastName: p.string().min(1),
20
- dateOfBirth: p.date().refine(r, { message: e.dateOfBirthMinAgeError }),
21
- ssn: p.string().refine((e) => /^\d{9}$/.test(e), { message: e.ssnInvalid }),
22
- homeAddress: p.string().min(1),
23
- city: p.string().min(1),
24
- state: p.string().min(2),
25
- zipCode: p.string().min(5),
26
- mobilePhoneNumber: p.string().refine((e) => e.replace(/\D/g, "").length === 10, { message: e.mobilePhoneNumberInvalid }),
27
- ownsOver25Percent: p.literal(!0),
28
- ownershipPercentage: p.number().min(25).max(100)
15
+ function g(t) {
16
+ return h.object({
17
+ firstName: h.string().min(1),
18
+ lastName: h.string().min(1),
19
+ dateOfBirth: h.date().refine(i, { message: t.dateOfBirthMinAgeError }),
20
+ ssn: h.string(),
21
+ ssnOnFileLast4: h.string().optional(),
22
+ homeAddress: h.string().min(1),
23
+ city: h.string().min(1),
24
+ state: h.string().min(2),
25
+ zipCode: h.string().min(5),
26
+ mobilePhoneNumber: h.string().refine((e) => e.replace(/\D/g, "").length === 10, { message: t.mobilePhoneNumberInvalid }),
27
+ workEmail: h.email(),
28
+ ownsOver25Percent: h.boolean(),
29
+ ownershipPercentage: h.number().min(0).max(100).nullable()
30
+ }).refine((t) => e(t.ssn, t.ssnOnFileLast4), {
31
+ message: t.ssnInvalid,
32
+ path: ["ssn"]
33
+ }).refine((e) => e.ownsOver25Percent === !1 || e.ownershipPercentage !== null && e.ownershipPercentage >= 25 && e.ownershipPercentage <= 100, {
34
+ message: t.ownershipPercentageRangeError,
35
+ path: ["ownershipPercentage"]
29
36
  });
30
37
  }
31
- function h(e) {
32
- return e.ownershipPercentage !== null && e.ownershipPercentage >= 25 ? e.ownershipPercentage : 0;
33
- }
34
- function g(e) {
35
- return `${h(e)}%`;
36
- }
37
- function _(e) {
38
- return {
39
- name: `${e.firstName} ${e.lastName}`.trim(),
40
- shareDisplay: g(e)
41
- };
42
- }
43
- function v({ owners: r, onOwnersChange: p, primaryOwnerName: g, primaryOwnerPercentage: v, stateOptions: y, onSnapshotChange: b, isSubmitting: x, labels: S }) {
44
- let C = l(() => ({
45
- ...t,
46
- ...S
47
- }), [S]), w = l(() => m(C), [C]), [T, E] = d(null), [D, O] = d(null), [k, A] = d(null), [j, M] = d(!1), N = (e) => {
48
- E(s(e));
49
- }, P = v + r.reduce((e, t) => e + h(t), 0), F = P > 100 ? C.totalOwnershipExceedsTemplate(P) : null, I = P > 75, L = `${v}%`, R = v >= 25, z = r.every((e) => w.safeParse(e).success), B = T !== null && w.safeParse(T).success, V = z && F === null && T === null && k === null ? r : null, H = JSON.stringify({ snapshot: V?.map((e) => ({
50
- ...e,
51
- dateOfBirth: e.dateOfBirth?.toISOString()
52
- })) }), U = u(b);
53
- U.current = b, c(() => {
54
- U.current(V);
55
- }, [H]);
56
- let W = () => {
57
- O(null), M(!1), E({ ...i });
58
- }, G = (e) => {
59
- O(e), M(!1), E(s({ ...r[e] }));
60
- }, K = (e) => {
61
- let t = r[e];
62
- A({
63
- index: e,
64
- displayName: `${t.firstName} ${t.lastName}`.trim()
65
- });
66
- }, q = () => {
67
- k && (p(r.filter((e, t) => t !== k.index)), A(null));
68
- }, J = () => {
69
- A(null);
70
- }, Y = T ? {
71
- fields: o(T, N, { stateOptions: y }),
72
- display: a(T),
73
- isExisting: D !== null,
74
- isValid: B,
75
- ssnRevealed: j,
76
- ssnToggleAriaLabel: j ? C.ssnHide : C.ssnShow,
77
- onToggleSsnVisibility: () => M((e) => !e),
78
- onSubmit: () => {
79
- if (!T) return;
80
- let e = w.safeParse(T);
81
- if (e.success) {
82
- if (D === null) p([...r, e.data]);
83
- else {
84
- let t = [...r];
85
- t[D] = e.data, p(t);
86
- }
87
- E(null), O(null), M(!1);
88
- }
89
- },
90
- onCancel: () => {
91
- E(null), O(null), M(!1);
92
- }
93
- } : null;
94
- return /* @__PURE__ */ f(n, {
95
- ownerRows: r.map(_),
96
- primaryOwnerName: g,
97
- primaryOwnerShareDisplay: L,
98
- showPrimaryOwner: R,
99
- totalOwnershipError: F,
100
- addOwnerDisabled: I,
101
- onAddOwner: W,
102
- onEditOwner: G,
103
- onDeleteOwnerRequest: K,
104
- deletingOwnerName: k?.displayName ?? null,
105
- onDeleteOwnerConfirm: q,
106
- onDeleteOwnerCancel: J,
107
- editingOverlay: Y,
108
- isSubmitting: x,
109
- labels: S,
38
+ function _({ value: e, onValueChange: i, onSnapshotChange: h, stateOptions: _, isSubmitting: v, labels: y }) {
39
+ let b = d(() => l(y), [y]), x = d(() => g(b), [b]).safeParse(e), S = x.success ? x.data : null, C = JSON.stringify({
40
+ ...S,
41
+ dateOfBirth: S?.dateOfBirth?.toISOString()
42
+ }), w = f(h);
43
+ w.current = h, u(() => {
44
+ w.current(S);
45
+ }, [C]);
46
+ let [T, E] = p(() => S === null), [D, O] = p(!1);
47
+ u(() => {
48
+ S === null && E(!0);
49
+ }, [C]);
50
+ let k = d(() => ({
51
+ stateOptions: _,
52
+ labels: y
53
+ }), [_, y]), A = d(() => o(y), [y]), j = d(() => s(e, k), [e, k]), M = d(() => a(e, i, k), [
54
+ e,
55
+ i,
56
+ k
57
+ ]), N = d(() => c(e.ssn, e.ssnOnFileLast4, y), [
58
+ e.ssn,
59
+ e.ssnOnFileLast4,
60
+ y
61
+ ]), P = d(() => r(), []);
62
+ return /* @__PURE__ */ m(n, {
63
+ isEditing: T,
64
+ onEditClick: () => E(!0),
65
+ summaryRows: j,
66
+ editFields: M,
67
+ labels: A,
68
+ isDisabled: v,
69
+ ssnRevealed: D,
70
+ ssnToggleAriaLabel: D ? A.ssnHide : A.ssnShow,
71
+ onToggleSsnVisibility: () => O((e) => !e),
72
+ showOwnershipPercentage: e.ownsOver25Percent === !0,
73
+ maxBirthDate: P,
74
+ ssnMaskedDisplay: N.masked,
75
+ ssnFormattedDisplay: N.formatted,
76
+ ssnRequired: N.required,
77
+ ssnPlaceholder: N.placeholder,
78
+ ssnHelpText: N.helpText,
110
79
  testIds: {
111
- addOwnerButton: e.addOwnerButton,
112
- overlay: { root: e.shellOverlay },
113
- deleteOverlay: {
114
- root: e.ownerDeleteOverlay,
115
- content: e.ownerDeleteContent
80
+ root: t.aboutYouPanel,
81
+ editButton: t.aboutYouEditButton,
82
+ summary: { root: t.aboutYouSummary },
83
+ editForm: {
84
+ root: t.aboutYouEditForm,
85
+ ownsOver25Question: t.aboutYouOwnsOver25Question
116
86
  }
117
87
  }
118
88
  });
119
89
  }
120
90
  //#endregion
121
- export { v as AdditionalOwnersStep, h as getAdditionalOwnerShare };
91
+ export { _ as PersonalDetailsStep };
@@ -1,100 +1,97 @@
1
+ import { storedIdentifierFieldDisplay as e } from "./index7.js";
2
+ import { formatPhoneNumberInput as t } from "./index2.js";
3
+ import { sanitizeZipCodeInput as n } from "./index3.js";
4
+ import { ADDITIONAL_OWNERS_LABELS_EN as r } from "../../ui/dist/index5.js";
5
+ import "../../ui/dist/index.js";
6
+ import { getMaxBirthDate as i, isAtLeastMinOwnerAge as a } from "./index9.js";
7
+ import { formatSsnInput as o, maskSsn as s, sanitizeSsnDigits as c } from "./index4.js";
1
8
  //#region ../../libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index15.js
2
- var e = (e) => e.replace(/\D/g, "").slice(0, 10), t = (e) => `${e.getFullYear().toString().padStart(4, "0")}-${(e.getMonth() + 1).toString().padStart(2, "0")}-${e.getDate().toString().padStart(2, "0")}`;
3
- function n(e) {
9
+ var l = {
10
+ firstName: "",
11
+ lastName: "",
12
+ dateOfBirth: void 0,
13
+ ssn: "",
14
+ homeAddress: "",
15
+ city: "",
16
+ state: "",
17
+ zipCode: "",
18
+ mobilePhoneNumber: "",
19
+ ownsOver25Percent: null,
20
+ ownershipPercentage: null
21
+ };
22
+ function u(e) {
4
23
  return {
5
- address1: e.address1,
6
- city: e.city,
7
- state: e.state,
8
- postalCode: e.postalCode,
9
- countryCode: "USA"
24
+ ...e,
25
+ ssn: c(e.ssn),
26
+ zipCode: n(e.zipCode),
27
+ mobilePhoneNumber: t(e.mobilePhoneNumber),
28
+ ownsOver25Percent: e.ownershipPercentage === null ? null : e.ownershipPercentage >= 25
10
29
  };
11
30
  }
12
- function r(t) {
31
+ function d(t, n) {
32
+ let c = {
33
+ ...r,
34
+ ...n
35
+ }, l = e(t.ssnOnFileLast4, c.ssnOnFileTemplate);
13
36
  return {
14
- legalName: t.companyLegalName,
15
- dbaName: t.companyDbaName.trim() || null,
16
- address: n({
17
- address1: t.businessAddress,
18
- city: t.city,
19
- state: t.state,
20
- postalCode: t.zipCode
21
- }),
22
- phoneNumber: e(t.companyPhoneNumber),
23
- businessStructureType: t.companyStructure,
24
- website: t.website.trim() || null,
25
- taxId: {
26
- type: t.companyStructure === "SOLE_PROPRIETORSHIP" ? "SSN" : "EIN",
27
- value: t.taxId
28
- },
29
- northAmericanIndustryClassificationSystemCode: t.naicsCode
30
- };
31
- }
32
- function i(e) {
33
- return {
34
- isLegallyAuthorized: e.isAuthorized,
35
- hasAcceptedDisclosures: e.isCheckboxChecked
37
+ ssnRequired: l.required,
38
+ ssnPlaceholder: l.placeholder,
39
+ ssnHelpText: l.helpText,
40
+ dateOfBirthInvalid: t.dateOfBirth !== void 0 && !a(t.dateOfBirth),
41
+ ownershipPercentageInvalid: t.ownershipPercentage !== null && t.ownershipPercentage < 25,
42
+ maxBirthDate: i(),
43
+ ssnMaskedDisplay: s(t.ssn),
44
+ ssnFormattedDisplay: o(t.ssn)
36
45
  };
37
46
  }
38
- var a = 1;
39
- function o(r, { isSoleProprietor: i = !1 } = {}) {
47
+ function f(e, t, n) {
48
+ let r = (n) => (r) => t(u({
49
+ ...e,
50
+ [n]: r
51
+ }));
40
52
  return {
41
- firstName: r.firstName,
42
- lastName: r.lastName,
43
- birthDate: t(r.dateOfBirth),
44
- personalIdentificationNumber: {
45
- type: "SSN",
46
- value: r.ssn
53
+ firstName: {
54
+ value: e.firstName,
55
+ onValueChange: r("firstName")
47
56
  },
48
- homeAddress: n({
49
- address1: r.homeAddress,
50
- city: r.city,
51
- state: r.state,
52
- postalCode: r.zipCode
53
- }),
54
- mobilePhoneNumber: e(r.mobilePhoneNumber),
55
- workEmailAddress: r.workEmail,
56
- ownershipPercentage: i ? a : r.ownsOver25Percent && r.ownershipPercentage !== null ? r.ownershipPercentage / 100 : 0
57
- };
58
- }
59
- function s(r) {
60
- return r.map((r) => ({
61
- ...r.id ? { id: r.id } : {},
62
- firstName: r.firstName,
63
- lastName: r.lastName,
64
- birthDate: r.dateOfBirth ? t(r.dateOfBirth) : void 0,
65
- homeAddress: n({
66
- address1: r.homeAddress,
67
- city: r.city,
68
- state: r.state,
69
- postalCode: r.zipCode
70
- }),
71
- mobilePhoneNumber: e(r.mobilePhoneNumber),
72
- ownershipPercentage: r.ownershipPercentage !== null && r.ownershipPercentage >= 25 ? r.ownershipPercentage / 100 : 0,
73
- personalIdentificationNumber: {
74
- type: "SSN",
75
- value: r.ssn
57
+ lastName: {
58
+ value: e.lastName,
59
+ onValueChange: r("lastName")
60
+ },
61
+ dateOfBirth: {
62
+ value: e.dateOfBirth,
63
+ onValueChange: r("dateOfBirth")
64
+ },
65
+ ssn: {
66
+ value: e.ssn,
67
+ onValueChange: (e) => r("ssn")(e)
68
+ },
69
+ homeAddress: {
70
+ value: e.homeAddress,
71
+ onValueChange: r("homeAddress")
72
+ },
73
+ city: {
74
+ value: e.city,
75
+ onValueChange: r("city")
76
+ },
77
+ state: {
78
+ value: e.state,
79
+ onValueChange: r("state"),
80
+ options: n.stateOptions
81
+ },
82
+ zipCode: {
83
+ value: e.zipCode,
84
+ onValueChange: (e) => r("zipCode")(e)
85
+ },
86
+ mobilePhoneNumber: {
87
+ value: e.mobilePhoneNumber,
88
+ onValueChange: (e) => r("mobilePhoneNumber")(e)
89
+ },
90
+ ownershipPercentage: {
91
+ value: e.ownershipPercentage,
92
+ onValueChange: r("ownershipPercentage")
76
93
  }
77
- }));
78
- }
79
- function c(e) {
80
- return {
81
- businessDetails: r(e),
82
- applicant: i(e)
83
- };
84
- }
85
- function l(e) {
86
- let t = e.businessDetails?.companyStructure === "SOLE_PROPRIETORSHIP", n = e.carryConsent && e.businessDetails && {
87
- isLegallyAuthorized: e.businessDetails.isAuthorized,
88
- hasAcceptedDisclosures: e.businessDetails.isCheckboxChecked
89
- };
90
- return {
91
- ...e.businessDetails && { businessDetails: r(e.businessDetails) },
92
- ...(e.applicant || n) && { applicant: {
93
- ...e.applicant ? o(e.applicant, { isSoleProprietor: t }) : {},
94
- ...n
95
- } },
96
- ...(t || e.businessOwners !== void 0) && { businessOwners: !t && e.businessOwners?.length ? s(e.businessOwners) : null }
97
94
  };
98
95
  }
99
96
  //#endregion
100
- export { i as buildApplicantForCreate, o as buildApplicantForUpdate, r as buildBusinessDetails, s as buildBusinessOwners, c as buildCreateApplicationBody, l as buildUpdateApplicationBody };
97
+ export { l as EMPTY_ADDITIONAL_OWNER, d as buildAdditionalOwnerEditDisplay, f as buildAdditionalOwnerEditFields, u as normalizeAdditionalOwnerDraft };
@@ -1,98 +1,126 @@
1
- import { formatPhoneNumberInput as e } from "./index2.js";
2
- import { sanitizeZipCodeInput as t } from "./index3.js";
3
- import { normalizeAdditionalOwnerDraft as n } from "./index13.js";
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { isIdentifierEnteredOrStored as e } from "./index7.js";
6
+ import { bankAccountOnboardingTestIds as t } from "./index11.js";
7
+ import { ADDITIONAL_OWNERS_LABELS_EN as n } from "../../ui/dist/index5.js";
8
+ import { AdditionalOwnersForm as r } from "../../ui/dist/index6.js";
9
+ import "../../ui/dist/index.js";
10
+ import { isAtLeastMinOwnerAge as i } from "./index9.js";
11
+ import { EMPTY_ADDITIONAL_OWNER as a, buildAdditionalOwnerEditDisplay as o, buildAdditionalOwnerEditFields as s, normalizeAdditionalOwnerDraft as c } from "./index15.js";
12
+ import { useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
13
+ import { jsx as p } from "react/jsx-runtime";
14
+ import { z as m } from "zod";
4
15
  //#region ../../libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index16.js
5
- var r = .25, i = (t) => t ? e(t) : void 0, a = (e) => e ? t(e) : void 0;
6
- function o(e) {
7
- return Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0));
8
- }
9
- function s(e) {
10
- if (!e) return;
11
- let t = /^(\d{4})-(\d{2})-(\d{2})/.exec(e);
12
- if (!t) return;
13
- let [, n, r, i] = t;
14
- return new Date(Number(n), Number(r) - 1, Number(i));
16
+ function h(t) {
17
+ return m.object({
18
+ id: m.string().optional(),
19
+ firstName: m.string().min(1),
20
+ lastName: m.string().min(1),
21
+ dateOfBirth: m.date().refine(i, { message: t.dateOfBirthMinAgeError }),
22
+ ssn: m.string(),
23
+ ssnOnFileLast4: m.string().optional(),
24
+ homeAddress: m.string().min(1),
25
+ city: m.string().min(1),
26
+ state: m.string().min(2),
27
+ zipCode: m.string().min(5),
28
+ mobilePhoneNumber: m.string().refine((e) => e.replace(/\D/g, "").length === 10, { message: t.mobilePhoneNumberInvalid }),
29
+ ownsOver25Percent: m.literal(!0),
30
+ ownershipPercentage: m.number().min(25).max(100)
31
+ }).refine((t) => e(t.ssn, t.ssnOnFileLast4), {
32
+ message: t.ssnInvalid,
33
+ path: ["ssn"]
34
+ });
15
35
  }
16
- function c(e) {
17
- if (e == null || e === "") return null;
18
- let t = typeof e == "string" ? Number(e) : e;
19
- return Number.isFinite(t) ? Math.round(t * 1e6) / 1e4 : null;
36
+ function g(e) {
37
+ return e.ownershipPercentage !== null && e.ownershipPercentage >= 25 ? e.ownershipPercentage : 0;
20
38
  }
21
- function l(e) {
22
- if (e == null || e === "") return null;
23
- let t = typeof e == "string" ? Number(e) : e;
24
- return Number.isFinite(t) ? t >= r : null;
39
+ function _(e) {
40
+ return `${g(e)}%`;
25
41
  }
26
- function u(e) {
42
+ function v(e) {
27
43
  return {
28
- line1: e?.address1 ?? void 0,
29
- city: e?.city ?? void 0,
30
- state: e?.state ?? void 0,
31
- zipCode: e?.postalCode ?? void 0
44
+ name: `${e.firstName} ${e.lastName}`.trim(),
45
+ shareDisplay: _(e)
32
46
  };
33
47
  }
34
- function d(e, t) {
35
- let n = u(e.address);
36
- return o({
37
- companyLegalName: e.legalName ?? void 0,
38
- companyDbaName: e.dbaName ?? "",
39
- businessAddress: n.line1,
40
- city: n.city,
41
- state: n.state,
42
- zipCode: a(n.zipCode),
43
- companyPhoneNumber: i(e.phoneNumber),
44
- companyStructure: e.businessStructureType ?? void 0,
45
- website: e.website ?? "",
46
- naicsCode: e.northAmericanIndustryClassificationSystemCode ?? void 0,
47
- isAuthorized: t?.isLegallyAuthorized ?? void 0,
48
- taxId: "",
49
- isCheckboxChecked: !1
50
- });
51
- }
52
- function f(e) {
53
- let t = u(e.homeAddress);
54
- return o({
55
- firstName: e.firstName ?? void 0,
56
- lastName: e.lastName ?? void 0,
57
- dateOfBirth: s(e.birthDate),
58
- homeAddress: t.line1,
59
- city: t.city,
60
- state: t.state,
61
- zipCode: a(t.zipCode),
62
- mobilePhoneNumber: i(e.mobilePhoneNumber),
63
- workEmail: e.workEmailAddress ?? void 0,
64
- ownsOver25Percent: l(e.ownershipPercentage) ?? void 0,
65
- ownershipPercentage: c(e.ownershipPercentage) ?? void 0,
66
- ssn: ""
67
- });
68
- }
69
- function p(e) {
70
- let t = u(e.homeAddress);
71
- return n({
72
- ...e.id ? { id: e.id } : {},
73
- firstName: e.firstName ?? "",
74
- lastName: e.lastName ?? "",
75
- dateOfBirth: s(e.birthDate),
76
- ssn: "",
77
- homeAddress: t.line1 ?? "",
78
- city: t.city ?? "",
79
- state: t.state ?? "",
80
- zipCode: t.zipCode ?? "",
81
- mobilePhoneNumber: e.mobilePhoneNumber ?? "",
82
- ownsOver25Percent: null,
83
- ownershipPercentage: c(e.ownershipPercentage)
84
- });
85
- }
86
- function m(e) {
87
- if (!e) return;
88
- let { applicant: t, businessDetails: n, businessOwners: r } = e, i = {
89
- businessDetails: {
90
- taxId: "",
91
- isCheckboxChecked: !1
48
+ function y({ owners: e, onOwnersChange: i, primaryOwnerName: m, primaryOwnerPercentage: _, stateOptions: y, onSnapshotChange: b, isSubmitting: x, labels: S }) {
49
+ let C = u(() => ({
50
+ ...n,
51
+ ...S
52
+ }), [S]), w = u(() => h(C), [C]), [T, E] = f(null), [D, O] = f(null), [k, A] = f(null), [j, M] = f(!1), N = (e) => {
53
+ E(c(e));
54
+ }, P = _ + e.reduce((e, t) => e + g(t), 0), F = P > 100 ? C.totalOwnershipExceedsTemplate(P) : null, I = P > 75, L = `${_}%`, R = _ >= 25, z = e.every((e) => w.safeParse(e).success), B = T !== null && w.safeParse(T).success, V = z && F === null && T === null && k === null ? e : null, H = JSON.stringify({ snapshot: V?.map((e) => ({
55
+ ...e,
56
+ dateOfBirth: e.dateOfBirth?.toISOString()
57
+ })) }), U = d(b);
58
+ U.current = b, l(() => {
59
+ U.current(V);
60
+ }, [H]);
61
+ let W = () => {
62
+ O(null), M(!1), E({ ...a });
63
+ }, G = (t) => {
64
+ O(t), M(!1), E(c({ ...e[t] }));
65
+ }, K = (t) => {
66
+ let n = e[t];
67
+ A({
68
+ index: t,
69
+ displayName: `${n.firstName} ${n.lastName}`.trim()
70
+ });
71
+ }, q = () => {
72
+ k && (i(e.filter((e, t) => t !== k.index)), A(null));
73
+ }, J = () => {
74
+ A(null);
75
+ }, Y = T ? {
76
+ fields: s(T, N, { stateOptions: y }),
77
+ display: o(T, C),
78
+ isExisting: D !== null,
79
+ isValid: B,
80
+ ssnRevealed: j,
81
+ ssnToggleAriaLabel: j ? C.ssnHide : C.ssnShow,
82
+ onToggleSsnVisibility: () => M((e) => !e),
83
+ onSubmit: () => {
84
+ if (!T) return;
85
+ let t = w.safeParse(T);
86
+ if (t.success) {
87
+ if (D === null) i([...e, t.data]);
88
+ else {
89
+ let n = [...e];
90
+ n[D] = t.data, i(n);
91
+ }
92
+ E(null), O(null), M(!1);
93
+ }
92
94
  },
93
- personalDetails: { ssn: "" }
94
- };
95
- return n && (i.businessDetails = d(n, t)), t && (i.personalDetails = f(t)), r !== void 0 && (i.additionalOwners = r?.map(p) ?? []), i;
95
+ onCancel: () => {
96
+ E(null), O(null), M(!1);
97
+ }
98
+ } : null;
99
+ return /* @__PURE__ */ p(r, {
100
+ ownerRows: e.map(v),
101
+ primaryOwnerName: m,
102
+ primaryOwnerShareDisplay: L,
103
+ showPrimaryOwner: R,
104
+ totalOwnershipError: F,
105
+ addOwnerDisabled: I,
106
+ onAddOwner: W,
107
+ onEditOwner: G,
108
+ onDeleteOwnerRequest: K,
109
+ deletingOwnerName: k?.displayName ?? null,
110
+ onDeleteOwnerConfirm: q,
111
+ onDeleteOwnerCancel: J,
112
+ editingOverlay: Y,
113
+ isSubmitting: x,
114
+ labels: S,
115
+ testIds: {
116
+ addOwnerButton: t.addOwnerButton,
117
+ overlay: { root: t.shellOverlay },
118
+ deleteOverlay: {
119
+ root: t.ownerDeleteOverlay,
120
+ content: t.ownerDeleteContent
121
+ }
122
+ }
123
+ });
96
124
  }
97
125
  //#endregion
98
- export { m as buildOnboardingPrefill };
126
+ export { y as AdditionalOwnersStep, g as getAdditionalOwnerShare };